From 9bb2c0ddad281351dd603c07f74796f4d9062c75 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 13:59:14 -0800 Subject: [PATCH 01/11] feat(box): Name the packs and the plugin of box with the @box/ scope [strands-agents/staging-boxy#570](https://github.com/strands-agents/staging-boxy/pull/570) gives each pack and plugin that box ships the name @box/. A box from the staging-boxy main branch rejects the previous box/ name, for example: "box/base" is not a pack name; the pack that box ships is @box/base. The next box release comes from the main branch. Thus it rejects each box profile that the CLI writes, and each Runtime profile that build stages. With this change, the CLI writes these names: - box/base is @box/base, and box/bedrock is @box/bedrock, in each box profile that create writes and in each Runtime profile. - box/agentcore is @box/agentcore, and box/agentcore-codezip is @box/agentcore-codezip. This is the packs entry and the [pack] name of each pack that build writes. The path of each pack does not change. - box/aws-secrets-manager is @box/aws-secrets-manager in plugins. This is the name in the plugin.toml of the AWS Secrets Manager plugin on the feature/secret-source-shipped-plugins branch of staging-boxy. The profile writer and the bedrock.region copy of build use one BOX_BEDROCK_PACK constant. Thus the copy finds @box/bedrock. Comments in the code, Dockerfile.template, and start.py use the new names. Build does not change the profile of a user. If the local profile names box/ in packs or in plugins, build stops before it starts box. The message gives the file, each previous name, and its @box/ name. The open routes fixture for a list of destinations is new output of box profile show, from a box with [strands-agents/staging-boxy#625](https://github.com/strands-agents/staging-boxy/pull/625). Only its pack name changed. The fixture of 0.1.11-linux-preview.6 stays the output of that box, with box/base. Tests: the tests of boxProfile.test.ts, manager.boxNetwork.test.ts, and the other tests examine the new names. boxNetworkSource.test.ts examines the stop and its message, and that box does not start. It also examines that build starts box for @box/ names and names of the user. The tests show an error in each of these conditions: - One of these names goes back to box/. - The bedrock.region copy finds only box/bedrock. - Build does not stop. An agentcore build of a project from create used the box of [strands-agents/staging-boxy#625](https://github.com/strands-agents/staging-boxy/pull/625), and its box profile show accepted the @box/ names. That box also accepted the staged Runtime profile, with @box/agentcore, if the copy had the text us-west-2 in auth.aws.region. With the placeholder, that box rejects auth.aws.region. This is not a problem, because the next release has [strands-agents/staging-boxy#549](https://github.com/strands-agents/staging-boxy/pull/549). A build of a project with box/base and box/bedrock stopped with the new message, and the profile did not change. boxRelease.json does not change. typecheck, lint:check, format:check, and bun test show no errors. --- .../Dockerfile.template | 2 +- src/assets/templates/box-codezip/start.py | 2 +- src/core/dev/boxEnvLocal.test.ts | 2 +- .../box-profile-show-open-routes-list.json | 2 +- src/core/project/backends/boxCodeZip.ts | 2 +- .../project/backends/boxContainer.test.ts | 4 +- src/core/project/boxNetwork/network.test.ts | 4 +- .../project/boxNetwork/profileParser.test.ts | 2 +- src/core/project/boxNetworkSource.test.ts | 37 ++++++++++++++++- src/core/project/boxNetworkSource.ts | 41 ++++++++++++++++--- src/core/project/boxNetworkWriters.test.ts | 2 +- src/core/project/boxNetworkWriters.ts | 4 +- src/core/project/boxProfileEgress.ts | 2 +- .../boxProfileResolver-test-support.ts | 2 +- src/core/project/boxProfileResolver.test.ts | 13 +++--- src/core/project/manager.boxNetwork.test.ts | 8 ++-- src/core/project/manager.test.ts | 2 +- src/core/project/templates/boxProfile.test.ts | 36 ++++++++-------- src/core/project/templates/boxProfile.ts | 38 +++++++++-------- src/core/project/templates/project.ts | 2 +- 20 files changed, 140 insertions(+), 67 deletions(-) diff --git a/src/assets/templates/agent-python-strands-box/Dockerfile.template b/src/assets/templates/agent-python-strands-box/Dockerfile.template index d74924b8b..9ac16b792 100644 --- a/src/assets/templates/agent-python-strands-box/Dockerfile.template +++ b/src/assets/templates/agent-python-strands-box/Dockerfile.template @@ -41,7 +41,7 @@ RUN uv sync --frozen --no-dev --no-install-project COPY --chown=bedrock_agentcore:bedrock_agentcore . . RUN uv sync --frozen --no-dev && /usr/local/bin/python -m pip uninstall -y uv -# The box profile, its policy files, and the generated box/agentcore pack, which build and deploy +# The box profile, its policy files, and the generated @box/agentcore pack, which build and deploy # stage in the box dist folder; dev stages the project's .box/profile.toml there. The profile reads # the gateway URL and the deployed resources from the environment through the pack and signs with a # bare `aws://`, so the image runs `box run` directly, with no start script. box requires the profile diff --git a/src/assets/templates/box-codezip/start.py b/src/assets/templates/box-codezip/start.py index c3a7086f0..27209258b 100644 --- a/src/assets/templates/box-codezip/start.py +++ b/src/assets/templates/box-codezip/start.py @@ -4,7 +4,7 @@ # code paths that only the microVM knows, and hands over to `box run`. # # The box profile reads the deployed resources, the gateway URL, the Python interpreter and the code -# directory from the environment through the box/agentcore and box/agentcore-codezip packs, and +# directory from the environment through the @box/agentcore and @box/agentcore-codezip packs, and # signs AWS routes with the execution role through a bare `aws://`. So there is nothing to fill in, # no credentials to write, and no start.sh. import os diff --git a/src/core/dev/boxEnvLocal.test.ts b/src/core/dev/boxEnvLocal.test.ts index d7edcf5a1..bf1ab7457 100644 --- a/src/core/dev/boxEnvLocal.test.ts +++ b/src/core/dev/boxEnvLocal.test.ts @@ -73,7 +73,7 @@ describe("writeBoxDevEnvLocal", () => { test("leaves out a pack's variable and a route without an env:// secret", async () => { const root = await project( - 'packs = ["box/bedrock"]\n[egress.s3]\ndestinations = ["s3.amazonaws.com"]\nsecret.ref = "aws://default"\n', + 'packs = ["@box/bedrock"]\n[egress.s3]\ndestinations = ["s3.amazonaws.com"]\nsecret.ref = "aws://default"\n', ); expect( diff --git a/src/core/project/__fixtures__/box-profile-show-open-routes-list.json b/src/core/project/__fixtures__/box-profile-show-open-routes-list.json index 516ef5d7c..97ade88c0 100644 --- a/src/core/project/__fixtures__/box-profile-show-open-routes-list.json +++ b/src/core/project/__fixtures__/box-profile-show-open-routes-list.json @@ -1 +1 @@ -{"profile":"open","packs":[{"name":"box/base","version":"1"}],"policies":["policy.dw"],"storage":"/private/tmp/acbox/home/.box/storage/open/default","project":null,"inputs":[{"name":"terminal.colorterm","value":"truecolor","source":"env:COLORTERM"},{"name":"terminal.term","value":"xterm-256color","source":"env:TERM"}],"skipped":[],"dropped":[],"open_routes":[{"route":"auth","destinations":["login.example.com","auth.example.com:8443"]},{"route":"github","destinations":["api.github.com"]}],"copies":[],"links":[],"parts":[],"mcp":{"unstarted":[],"servers":[],"dropped":[],"path_dropped":[],"skipped":[],"unread":[]},"warnings":[],"box_toml":{"name":"open-preview","box_dir":"/private/tmp/acbox/home/.box/runs/open-preview/box","policy":"policy.dw","file-attributes":true,"agent":{"command":["/bin/sh"],"workspace":"/private/tmp/acbox/demo","env":{"COLORTERM":"truecolor","PATH":"/usr/bin:/bin","TERM":"xterm-256color"},"filesystem":{"deny":["/private/tmp/acbox/demo/.box"]}},"tool":{"uname":{"command":["/usr/bin/uname"],"env":{"PATH":"/usr/bin:/bin","TMPDIR":"/private/tmp/acbox/home/.box/runs/open-preview/tool-tmp/uname"},"filesystem":{"read":["/private/tmp/acbox/home/.box/runs/open-preview/tool-tmp/uname"],"write":["/private/tmp/acbox/home/.box/runs/open-preview/tool-tmp/uname"],"deny":["/private/tmp/acbox/demo/.box"]}}},"egress":{"keyed":{"destinations":["k.example.com:8443"],"secret":{"ref":"env://KEY"}}},"telemetry":{"records":{"destination":"/private/tmp/acbox/home/.box/runs/open-preview/records.jsonl","include":["deny","permit","trace","logs"],"kind":"file"}}},"policy":"// No admin paths on GitHub.\n@id(\"no_admin\") forbid (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"api.github.com\" && context.input.path like \"/admin/*\" };\n\n@id(\"spawn_uname\") permit (principal, action == Box::Action::\"shell:spawn\", resource) when { context.input.program_path == \"/usr/bin/uname\" && context.input.program == \"uname\" };\n\n@id(\"route_auth_connect\") permit (principal, action == Box::Action::\"net:connect\", resource) when { (context.input.host == \"login.example.com\" && context.input.port == 443) || (context.input.host == \"auth.example.com\" && context.input.port == 8443) };\n@id(\"route_auth_request\") permit (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"login.example.com\" || context.input.host == \"auth.example.com\" };\n@id(\"route_github_connect\") permit (principal, action == Box::Action::\"net:connect\", resource) when { (context.input.host == \"api.github.com\" && context.input.port == 443) };\n@id(\"route_github_request\") permit (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"api.github.com\" };\n@id(\"route_keyed_connect\") permit (principal, action == Box::Action::\"net:connect\", resource) when { (context.input.host == \"k.example.com\" && context.input.port == 8443) };\n@id(\"route_keyed_request\") permit (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"k.example.com\" };\n@id(\"box_home_write\") forbid (principal, action == Box::Action::\"fs:write\", resource) when { (context.input.path == \"~/.box\" || context.input.path like \"~/.box/*\") };\n@id(\"box_home_delete\") forbid (principal, action == Box::Action::\"fs:delete\", resource) when { (context.input.path == \"~/.box\" || context.input.path like \"~/.box/*\") };\n@id(\"box_home_move\") forbid (principal, action == Box::Action::\"fs:move\", resource) when { (context.input.path == \"~/.box\" || context.input.path like \"~/.box/*\") };\n\n@id(\"project_configuration_write\") forbid (principal, action == Box::Action::\"fs:write\", resource) when { context.input.path == \"/private/tmp/acbox/demo/.box\" || context.input.path like \"/private/tmp/acbox/demo/.box/*\" };\n@id(\"project_configuration_delete\") forbid (principal, action == Box::Action::\"fs:delete\", resource) when { context.input.path == \"/private/tmp/acbox/demo/.box\" || context.input.path like \"/private/tmp/acbox/demo/.box/*\" };\n@id(\"project_configuration_move\") forbid (principal, action == Box::Action::\"fs:move\", resource) when { context.input.path == \"/private/tmp/acbox/demo/.box\" || context.input.path like \"/private/tmp/acbox/demo/.box/*\" };\n"} +{"profile":"open","packs":[{"name":"@box/base","version":"1"}],"policies":["policy.dw"],"storage":"/private/tmp/acbox/home/.box/storage/open/default","project":null,"inputs":[{"name":"terminal.colorterm","value":"truecolor","source":"env:COLORTERM"},{"name":"terminal.term","value":"xterm-256color","source":"env:TERM"}],"skipped":[],"dropped":[],"open_routes":[{"route":"auth","destinations":["login.example.com","auth.example.com:8443"]},{"route":"github","destinations":["api.github.com"]}],"copies":[],"links":[],"parts":[],"mcp":{"unstarted":[],"servers":[],"dropped":[],"path_dropped":[],"skipped":[],"unread":[]},"warnings":[],"box_toml":{"name":"open-preview","box_dir":"/private/tmp/acbox/home/.box/runs/open-preview/box","policy":"policy.dw","file-attributes":true,"agent":{"command":["/bin/sh"],"workspace":"/private/tmp/acbox/demo","env":{"COLORTERM":"truecolor","PATH":"/usr/bin:/bin","TERM":"xterm-256color"},"filesystem":{"deny":["/private/tmp/acbox/demo/.box"]}},"tool":{"uname":{"command":["/usr/bin/uname"],"env":{"PATH":"/usr/bin:/bin","TMPDIR":"/private/tmp/acbox/home/.box/runs/open-preview/tool-tmp/uname"},"filesystem":{"read":["/private/tmp/acbox/home/.box/runs/open-preview/tool-tmp/uname"],"write":["/private/tmp/acbox/home/.box/runs/open-preview/tool-tmp/uname"],"deny":["/private/tmp/acbox/demo/.box"]}}},"egress":{"keyed":{"destinations":["k.example.com:8443"],"secret":{"ref":"env://KEY"}}},"telemetry":{"records":{"destination":"/private/tmp/acbox/home/.box/runs/open-preview/records.jsonl","include":["deny","permit","trace","logs"],"kind":"file"}}},"policy":"// No admin paths on GitHub.\n@id(\"no_admin\") forbid (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"api.github.com\" && context.input.path like \"/admin/*\" };\n\n@id(\"spawn_uname\") permit (principal, action == Box::Action::\"shell:spawn\", resource) when { context.input.program_path == \"/usr/bin/uname\" && context.input.program == \"uname\" };\n\n@id(\"route_auth_connect\") permit (principal, action == Box::Action::\"net:connect\", resource) when { (context.input.host == \"login.example.com\" && context.input.port == 443) || (context.input.host == \"auth.example.com\" && context.input.port == 8443) };\n@id(\"route_auth_request\") permit (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"login.example.com\" || context.input.host == \"auth.example.com\" };\n@id(\"route_github_connect\") permit (principal, action == Box::Action::\"net:connect\", resource) when { (context.input.host == \"api.github.com\" && context.input.port == 443) };\n@id(\"route_github_request\") permit (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"api.github.com\" };\n@id(\"route_keyed_connect\") permit (principal, action == Box::Action::\"net:connect\", resource) when { (context.input.host == \"k.example.com\" && context.input.port == 8443) };\n@id(\"route_keyed_request\") permit (principal, action == Box::Action::\"http:request\", resource) when { context.input.host == \"k.example.com\" };\n@id(\"box_home_write\") forbid (principal, action == Box::Action::\"fs:write\", resource) when { (context.input.path == \"~/.box\" || context.input.path like \"~/.box/*\") };\n@id(\"box_home_delete\") forbid (principal, action == Box::Action::\"fs:delete\", resource) when { (context.input.path == \"~/.box\" || context.input.path like \"~/.box/*\") };\n@id(\"box_home_move\") forbid (principal, action == Box::Action::\"fs:move\", resource) when { (context.input.path == \"~/.box\" || context.input.path like \"~/.box/*\") };\n\n@id(\"project_configuration_write\") forbid (principal, action == Box::Action::\"fs:write\", resource) when { context.input.path == \"/private/tmp/acbox/demo/.box\" || context.input.path like \"/private/tmp/acbox/demo/.box/*\" };\n@id(\"project_configuration_delete\") forbid (principal, action == Box::Action::\"fs:delete\", resource) when { context.input.path == \"/private/tmp/acbox/demo/.box\" || context.input.path like \"/private/tmp/acbox/demo/.box/*\" };\n@id(\"project_configuration_move\") forbid (principal, action == Box::Action::\"fs:move\", resource) when { context.input.path == \"/private/tmp/acbox/demo/.box\" || context.input.path like \"/private/tmp/acbox/demo/.box/*\" };\n"} diff --git a/src/core/project/backends/boxCodeZip.ts b/src/core/project/backends/boxCodeZip.ts index 1669280cd..968c6c556 100644 --- a/src/core/project/backends/boxCodeZip.ts +++ b/src/core/project/backends/boxCodeZip.ts @@ -34,7 +34,7 @@ export async function stageBoxCodeZip( runtime: runtime.name, dist: posix.join(runtime.codeLocation, BOX_CODEZIP_DIST), // A CodeZip deploy reads the deployed resources, its Python and its code path through the - // box/agentcore and box/agentcore-codezip packs. + // @box/agentcore and @box/agentcore-codezip packs. kind: "codezip" as const, })); const { files } = boxNetworkEdits([runtimeProfileWriter(staged)], networks, { diff --git a/src/core/project/backends/boxContainer.test.ts b/src/core/project/backends/boxContainer.test.ts index cebdc9c34..9236f0305 100644 --- a/src/core/project/backends/boxContainer.test.ts +++ b/src/core/project/backends/boxContainer.test.ts @@ -10,7 +10,7 @@ import { renderAgentCorePack, renderRuntimeBoxProfile } from "../templates/boxPr import { stageBoxContainers } from "./boxContainer"; import { BOX_RELEASE, type BoxRelease } from "./boxRelease"; -/** The staged path of the generated box/agentcore pack, from `.box-dist/`. */ +/** The staged path of the generated @box/agentcore pack, from `.box-dist/`. */ const PACK_PATH = join("resources", "packs", "agentcore", "pack.toml"); const directories: string[] = []; @@ -87,7 +87,7 @@ describe("stageBoxContainers", () => { `BOX_REPO=${BOX_RELEASE.repo}\nBOX_VERSION=2.0.0\nBOX_ASSET=${BOX_RELEASE.linux.asset}\n` + `BOX_SHA256=${BOX_RELEASE.linux.sha256}\n`, ); - // The container also stages the box/agentcore pack, beside box's own packs in the image. + // The container also stages the @box/agentcore pack, beside box's own packs in the image. expect(await readFile(join(dist, PACK_PATH), "utf8")).toBe(renderAgentCorePack(demo.spec)); expect((await readdir(dist)).sort()).toEqual([...STAGED, "resources"].sort()); }); diff --git a/src/core/project/boxNetwork/network.test.ts b/src/core/project/boxNetwork/network.test.ts index 2fd9516ad..52d1f16d3 100644 --- a/src/core/project/boxNetwork/network.test.ts +++ b/src/core/project/boxNetwork/network.test.ts @@ -72,7 +72,7 @@ function model(policy: string, egress: Record = {}, options: Op } as unknown as ProjectSpec; const mcp = options.mcp ?? {}; const profile = [ - 'packs = ["box/base"]', + 'packs = ["@box/base"]', ...Object.keys(egress).map((name) => `[egress.${JSON.stringify(name)}]`), ...Object.keys(mcp).map((name) => `[mcp.${JSON.stringify(name)}]`), ].join("\n"); @@ -918,7 +918,7 @@ describe("the default targets", () => { expect(r.failures()).toEqual([]); }); - test("gives box/bedrock's model endpoint to the bedrock target build adds", () => { + test("gives @box/bedrock's model endpoint to the bedrock target build adds", () => { const signed = { secret: { ref: "aws://default" } }; const r = model( "", diff --git a/src/core/project/boxNetwork/profileParser.test.ts b/src/core/project/boxNetwork/profileParser.test.ts index 7253f6513..106b54eca 100644 --- a/src/core/project/boxNetwork/profileParser.test.ts +++ b/src/core/project/boxNetwork/profileParser.test.ts @@ -168,7 +168,7 @@ describe("profilePlaces", () => { test("places each entry by its header, its dotted key, or its key under [egress]", () => { const places = profilePlaces( [ - 'packs = ["box/base", "box/bedrock"]', + 'packs = ["@box/base", "@box/bedrock"]', 'policies = ["policy.dw"]', "", "[egress.github]", diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index 37a0c4399..ab6e07c45 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test"; import { link, mkdir, mkdtemp, rm, symlink, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { InvalidEnvironmentError } from "../../errors/errors"; +import { InvalidEnvironmentError, ProjectStateError } from "../../errors/errors"; import { boxGatewaySpec, type ProjectSpec } from "../../projectSchemas/project"; import { boxNetworkFailureMessage, readBoxNetworks } from "./boxNetworkSource"; import type { BoxProfileResolver } from "./boxProfileResolver"; @@ -145,6 +145,41 @@ describe("readBoxNetworks", () => { ).rejects.toBe(refused); }); + test("stops before box runs when the profile names a pack or a plugin that box ships by its old box/ name", async () => { + const root = await project([]); + await writeFile( + join(root, ...LOCAL, "profile.toml"), + 'packs = ["box/base", "box/bedrock", "@box/node", "team-pack", "box/base"]\n' + + 'plugins = ["box/aws-secrets-manager"]\n', + ); + const box = new FakeBoxProfileResolver(); + + const stopped = readBoxNetworks(SPEC, root, box); + + await expect(stopped).rejects.toBeInstanceOf(ProjectStateError); + await expect(stopped).rejects.toThrow( + 'The box profile .box/agent/local/profile.toml names "box/base", "box/bedrock", ' + + '"box/aws-secrets-manager". Box now names each pack and plugin that it ships ' + + '"@box/", and it refuses the old "box/" name. In ' + + '.box/agent/local/profile.toml, change "box/base" to "@box/base", "box/bedrock" to ' + + '"@box/bedrock", "box/aws-secrets-manager" to "@box/aws-secrets-manager", then build again.', + ); + expect(box.calls).toEqual([]); + }); + + test("runs box for a profile with only @box/ names and names of its own", async () => { + const root = await project([]); + await writeFile( + join(root, ...LOCAL, "profile.toml"), + 'packs = ["@box/base", "@box/bedrock", "team-pack"]\nplugins = ["@box/aws-secrets-manager"]\n', + ); + const box = new FakeBoxProfileResolver(); + + await readBoxNetworks(SPEC, root, box); + + expect(box.calls).toHaveLength(1); + }); + test("refuses a policy file Box would refuse, each at `policies`, and says how to fix it", async () => { const root = await project([ "missing.dw", diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 2abca9543..16548259e 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -14,6 +14,7 @@ import type { PolicyFileCopy } from "./backends/boxContainer"; import { DEFAULT_EGRESS_BEDROCK_REGION } from "../../handlers/project/shortcuts"; import { addBoxGatewayTargets, BOX_BEDROCK_POLICY_FILE, BOX_MEMORY_POLICY_FILE } from "./boxMemory"; import { + BOX_BEDROCK_PACK, boxLocalDir, boxLocalProfileFile, boxLocalProfilePath, @@ -123,6 +124,7 @@ async function readResolvedPolicy( const profileFile = boxLocalProfileFile(agentName); const text = profileText(projectRoot, agentName); if (text === undefined) return { parsed: noPolicy(profileFile), failures: [] }; + refuseOldShippedNames(text, profileFile); const named = profilePolicyFiles(text, profileFile); const places = profilePlaces(text, profileFile); const files = readPolicyFiles( @@ -132,7 +134,7 @@ async function readResolvedPolicy( places.policies, ); // The Runtime profile sets `[options] bedrock.region` to the region build builds for, so Box - // resolves box/bedrock's route for that region, not the one `agentcore dev` uses. A profile with + // resolves @box/bedrock's route for that region, not the one `agentcore dev` uses. A profile with // a failure of its own stops build either way, so Box resolves it as it is. const forRegion = named.ok && files.failures.length === 0 ? profileForRegion(text, region) : undefined; @@ -153,15 +155,44 @@ async function readResolvedPolicy( }; } +/** The old name of a pack or a plugin that box ships, before box named them `@box/`. */ +const OLD_SHIPPED_NAME = /^box\/[^/]+$/; + +/** + * Throws when the `packs` or `plugins` of the box profile `text` at `profileFile` name a pack or a + * plugin that box ships by its old `box/` name, which box refuses. The message names each old + * name and its `@box/` name. Box reports a profile that is not TOML itself. + */ +function refuseOldShippedNames(text: string, profileFile: string): void { + let table: Record; + try { + table = parseToml(text) as Record; + } catch { + return; + } + const names = [table.packs, table.plugins].flatMap((list) => (Array.isArray(list) ? list : [])); + const old = [ + ...new Set( + names.filter( + (name): name is string => typeof name === "string" && OLD_SHIPPED_NAME.test(name), + ), + ), + ]; + if (old.length === 0) return; + const changes = old.map((name) => `"${name}" to "@${name}"`); + throw new ProjectStateError( + `The box profile ${profileFile} names ${old.map((name) => `"${name}"`).join(", ")}. Box now ` + + 'names each pack and plugin that it ships "@box/", and it refuses the old "box/" ' + + `name. In ${profileFile}, change ${changes.join(", ")}, then build again.`, + ); +} + /** The text of the local box profile of `agentName`, or `undefined` when the agent has none. */ function profileText(projectRoot: string, agentName: string): string | undefined { const path = boxLocalProfilePath(projectRoot, agentName); return existsSync(path) ? readFileSync(path, "utf8") : undefined; } -/** The pack whose `[options] bedrock.region` the AgentCore Runtime profile sets. */ -const BOX_BEDROCK_PACK = "box/bedrock"; - const isTable = (value: unknown): value is Record => typeof value === "object" && value !== null && !Array.isArray(value); @@ -175,7 +206,7 @@ function bedrockRegionOf(table: Record): unknown { /** * The box profile `text` with `[options] bedrock.region` set to `region`, as the AgentCore Runtime - * profile sets it, or `undefined` when the profile imports no box/bedrock or already has that + * profile sets it, or `undefined` when the profile imports no @box/bedrock or already has that * region. An edit of the line that sets the region keeps every other line where it is. */ function profileForRegion(text: string, region: string): string | undefined { diff --git a/src/core/project/boxNetworkWriters.test.ts b/src/core/project/boxNetworkWriters.test.ts index 75fa678b7..51697b0c3 100644 --- a/src/core/project/boxNetworkWriters.test.ts +++ b/src/core/project/boxNetworkWriters.test.ts @@ -469,7 +469,7 @@ describe("runtimeProfileWriter", () => { ); }); - test("stages only the box/agentcore pack for a container", () => { + test("stages only the @box/agentcore pack for a container", () => { const writer = runtimeProfileWriter([ { runtime: "agent", dist: "app/agent/.box-dist", kind: "container" }, ]); diff --git a/src/core/project/boxNetworkWriters.ts b/src/core/project/boxNetworkWriters.ts index cbd9104a0..065c237c5 100644 --- a/src/core/project/boxNetworkWriters.ts +++ b/src/core/project/boxNetworkWriters.ts @@ -366,8 +366,8 @@ export interface StagedRuntime { readonly runtime: string; readonly dist: string; /** - * How the runtime deploys. Both kinds stage the `box/agentcore` pack; a CodeZip deploy also - * stages the `box/agentcore-codezip` pack. + * How the runtime deploys. Both kinds stage the `@box/agentcore` pack; a CodeZip deploy also + * stages the `@box/agentcore-codezip` pack. */ readonly kind: "container" | "codezip"; } diff --git a/src/core/project/boxProfileEgress.ts b/src/core/project/boxProfileEgress.ts index d655f0100..d2635bc2b 100644 --- a/src/core/project/boxProfileEgress.ts +++ b/src/core/project/boxProfileEgress.ts @@ -15,7 +15,7 @@ export type BoxEnvRoutes = { routes: BoxEnvRoute[]; error?: string }; /** * The profile's own `[egress]` routes whose `secret.ref` is an `env://` reference, in profile - * order. A pack's routes, such as box/bedrock's, are not in the profile's own `[egress]` table, so + * order. A pack's routes, such as @box/bedrock's, are not in the profile's own `[egress]` table, so * they are not here. An `egress` that is not a table (an array of tables, or a scalar) has no * routes, and nor does a ref with no variable after `env://`. */ diff --git a/src/core/project/boxProfileResolver-test-support.ts b/src/core/project/boxProfileResolver-test-support.ts index 99c412209..b47d39bc4 100644 --- a/src/core/project/boxProfileResolver-test-support.ts +++ b/src/core/project/boxProfileResolver-test-support.ts @@ -92,7 +92,7 @@ export function boxShowOf(input: { boxToml: { name: "test-preview", egress: kept, mcp }, policy: `${input.policy ?? ""}\n${boxNetworkRules(egress, mcp)}`, openRoutes, - packs: [{ name: "box/base", version: "1" }], + packs: [{ name: "@box/base", version: "1" }], warnings: [], }); } diff --git a/src/core/project/boxProfileResolver.test.ts b/src/core/project/boxProfileResolver.test.ts index 94f18d281..ce8d24938 100644 --- a/src/core/project/boxProfileResolver.test.ts +++ b/src/core/project/boxProfileResolver.test.ts @@ -19,7 +19,7 @@ const SHOWN = String.raw`{ "profile": ".box/profile.toml", "packs": [ { - "name": "box/base", + "name": "@box/base", "version": "1" } ], @@ -103,7 +103,8 @@ const PINNED = * `box profile show open --format json --full` for a profile with the routes `auth` and `github` * with no secret, the route `keyed` with one, and {@link POLICY}, as box prints it, with HOME at * /tmp/acbox/home. Box 0.1.11-linux-preview.6 joins the destinations of an open route into one - * string, and later boxes give a list. + * string, and later boxes give a list. preview.6 printed the first for the same profile with its + * pack named box/base, the name it had before `@box/`. */ const OPEN_ROUTES_SHOWN = Object.entries({ "one string": readFileSync( @@ -133,7 +134,7 @@ describe("parseBoxProfileShow", () => { }, policy: SHOWN_POLICY, openRoutes: [], - packs: [{ name: "box/base", version: "1" }], + packs: [{ name: "@box/base", version: "1" }], warnings: [], }); expect(Object.keys(resolved.boxToml)).toEqual([ @@ -151,7 +152,7 @@ describe("parseBoxProfileShow", () => { test("refuses output that is not one JSON document, such as the text that `show` prints", () => { expect(() => parseBoxProfileShow( - "profile .box/profile.toml resolves for this directory\n packs box/base 1\n", + "profile .box/profile.toml resolves for this directory\n packs @box/base 1\n", ".box/profile.toml", ), ).toThrow( @@ -190,7 +191,7 @@ describe("parseBoxProfileShow", () => { { ...noBoxToml, box_toml: [], policy: undefined }, "a box.toml table or the policy.dw text", ], - ["packs as text", { ...document, packs: "box/base 1" }, "a list of packs"], + ["packs as text", { ...document, packs: "@box/base 1" }, "a list of packs"], [ "a destination that is not text", { ...document, open_routes: [{ route: "auth", destinations: ["login.example.com", 443] }] }, @@ -414,7 +415,7 @@ describe("the box on PATH", () => { await mkdir(join(root, ".box"), { recursive: true }); await writeFile( join(root, ".box", "profile.toml"), - 'packs = ["box/base"]\npolicies = ["policy.dw"]\n\n[profile]\nname = "resolver-test"\n\n' + + 'packs = ["@box/base"]\npolicies = ["policy.dw"]\n\n[profile]\nname = "resolver-test"\n\n' + '[agent]\ncommand = ["/bin/sh"]\n\n[egress.github]\ndestinations = ["api.github.com"]\n\n' + '[egress.keyed]\ndestinations = ["k.example.com:8443"]\nsecret.ref = "env://KEY"\n\n' + '[mcp.docs]\ntype = "http"\ndestinations = ["docs.example.com"]\n', diff --git a/src/core/project/manager.boxNetwork.test.ts b/src/core/project/manager.boxNetwork.test.ts index b7eb05b54..2ed9c9d23 100644 --- a/src/core/project/manager.boxNetwork.test.ts +++ b/src/core/project/manager.boxNetwork.test.ts @@ -30,7 +30,7 @@ const POLICY = `@id("httpbin_get") permit (principal, ${HR}, resource) when { context.input.host == "httpbin.org" && context.input.path == "/get" };\n`; const GITHUB_ROUTE = '\n[egress.github]\ndestinations = ["api.github.com"]\nsecret.ref = "env://GITHUB_TOKEN"\n'; -/** Box's resolution of the Bedrock route of the profile `create` writes, with box/bedrock. */ +/** Box's resolution of the Bedrock route of the profile `create` writes, with @box/bedrock. */ const BEDROCK = { destinations: ["bedrock-runtime.us-west-2.amazonaws.com"], secret: { ref: "aws://default" }, @@ -40,7 +40,7 @@ const GITHUB = { destinations: ["api.github.com"], secret: { ref: "env://GITHUB_ const shows = (routes: Record = {}, policy?: string) => boxShowOf({ egress: { bedrock: BEDROCK, ...routes }, policy }); /** - * A fake box that resolves box/bedrock for the Bedrock region of the profile it reads, as box does: + * A fake box that resolves @box/bedrock for the Bedrock region of the profile it reads, as box does: * its answer's Bedrock host moves from us-west-2 to that region. Records the text of each profile. */ class RegionalBoxProfileResolver extends FakeBoxProfileResolver { @@ -786,7 +786,7 @@ describe("build reads the box profile as box resolves it", () => { const profile = await text(root, PROFILE); await writeFile( path(root, PROFILE), - profile.replace('"box/bedrock"]', '"box/bedrock", "team/search"]'), + profile.replace('"@box/bedrock"]', '"@box/bedrock", "team/search"]'), ); // `box profile show --format json --full` resolves team/search to this route, with its secret. box.answer = shows({ @@ -865,7 +865,7 @@ describe("build writes the Bedrock and Memory targets for the region it builds f await build(manager, root); - // box/bedrock's route is for eu-central-1, so the bedrock target serves it, and no + // @box/bedrock's route is for eu-central-1, so the bedrock target serves it, and no // egress-bedrock target is added for the us-west-2 host that `agentcore dev` calls. expect(await targetNames(root)).toEqual(["bedrock", "agentcore"]); const [call] = box.calls; diff --git a/src/core/project/manager.test.ts b/src/core/project/manager.test.ts index 0e8817c4d..cf41804a7 100644 --- a/src/core/project/manager.test.ts +++ b/src/core/project/manager.test.ts @@ -882,7 +882,7 @@ describe("FsProjectManager.create box profile", () => { }); const appDir = join(directory, "example", "app", "agent_python_strands_box"); - // start.py execs box run and exports the paths the box/agentcore-codezip pack reads; no start.sh. + // start.py execs box run and exports the paths the @box/agentcore-codezip pack reads; no start.sh. const startPy = await readFile(join(appDir, "start.py"), "utf8"); expect(startPy).toContain("os.execve"); expect(startPy).toContain("BOX_PYTHON"); diff --git a/src/core/project/templates/boxProfile.test.ts b/src/core/project/templates/boxProfile.test.ts index 906a110af..b34740b7a 100644 --- a/src/core/project/templates/boxProfile.test.ts +++ b/src/core/project/templates/boxProfile.test.ts @@ -71,7 +71,7 @@ const UVICORN = [ describe("renderBoxProfile", () => { test("runs the Strands agent from the project's venv, reached through ingress", () => { expect(parse(renderBoxProfile("V3Demo", STRANDS)!) as unknown).toEqual({ - packs: ["box/base", "box/bedrock"], + packs: ["@box/base", "@box/bedrock"], profile: { name: "V3Demo" }, project: { access: "write" }, options: { bedrock: { region: "us-west-2" } }, @@ -103,7 +103,7 @@ describe("renderBoxProfile", () => { "runs %s with uvicorn on Bedrock, like the Strands agent", (name) => { const { packs, agent, egress } = profile(name); - expect(packs).toEqual(["box/base", "box/bedrock"]); + expect(packs).toEqual(["@box/base", "@box/bedrock"]); expect(agent.command).toEqual(UVICORN); expect(agent.filesystem).toEqual(VENV_GRANTS); expect(egress.bedrock).toEqual({ secret: { ref: "aws://default" } }); @@ -136,7 +136,7 @@ describe("renderBoxProfile", () => { test("gives the MCP server no route, because it calls no model", () => { const mcp = profile("mcp-python-fastmcp"); - expect(mcp.packs).toEqual(["box/base"]); + expect(mcp.packs).toEqual(["@box/base"]); expect(mcp.options).toBeUndefined(); expect(mcp.egress).toBeUndefined(); }); @@ -199,7 +199,7 @@ describe("renderBoxProfile", () => { apiKey: "sk-test", ...overrides, }); - expect(packs).toEqual(["box/base"]); + expect(packs).toEqual(["@box/base"]); expect(options).toBeUndefined(); expect(egress).toEqual({ [route]: expected }); }, @@ -207,7 +207,7 @@ describe("renderBoxProfile", () => { test("routes a LiteLLM agent on a bedrock/ model through Bedrock", () => { const { packs, egress } = profile("agent-python-strands", { modelProvider: "LiteLLM" }); - expect(packs).toEqual(["box/base", "box/bedrock"]); + expect(packs).toEqual(["@box/base", "@box/bedrock"]); expect(egress).toEqual({ bedrock: { secret: { ref: "aws://default" } } }); }); @@ -322,7 +322,7 @@ const RUNTIME_AWS_STAND_INS = { AWS_SECRET_ACCESS_KEY: "box-stand-in", }; -/** The Runtime's region on a Bedrock agent: box/bedrock sets AWS_REGION, the profile the rest. */ +/** The Runtime's region on a Bedrock agent: @box/bedrock sets AWS_REGION, the profile the rest. */ const RUNTIME_REGION_WITH_BEDROCK = { AWS_DEFAULT_REGION: "${{ inputs.aws.region }}" }; const IMAGE_PYTHON_FILESYSTEM = { @@ -351,7 +351,7 @@ describe("renderBoxProfile for AgentCore Runtime", () => { expect((parse(text) as { egress?: unknown }).egress).toBeUndefined(); }); - test("passes the Runtime's region to an agent that imports no box/bedrock", () => { + test("passes the Runtime's region to an agent that imports no @box/bedrock", () => { const spec = { name: "V3Demo", runtimes: [{ name: "agent", build: "CodeZip", protocol: "HTTP", modelProvider: "OpenAI" }], @@ -359,7 +359,7 @@ describe("renderBoxProfile for AgentCore Runtime", () => { } as unknown as ProjectSpec; const profile = parse(renderRuntimeBoxProfile(spec, spec.runtimes[0]!)) as Record; - expect(profile.packs).not.toContain("box/bedrock"); + expect(profile.packs).not.toContain("@box/bedrock"); // The Memory client in the box calls the deploy region that the profile routes. expect(profile.agent.env.AWS_REGION).toBe("${{ inputs.aws.region }}"); expect(profile.agent.env.AWS_DEFAULT_REGION).toBe("${{ inputs.aws.region }}"); @@ -373,10 +373,10 @@ describe("renderBoxProfile for AgentCore Runtime", () => { "runtime", )!; // No start.sh fills this profile in: the packs carry the deployed resources, Python, and code. - expect(text).toContain("box/agentcore-codezip packs carry"); + expect(text).toContain("@box/agentcore-codezip packs carry"); expect(text).not.toContain("# @AGENT_ENV@"); expect(parse(text)).toEqual({ - packs: ["box/base", "box/bedrock", "box/agentcore", "box/agentcore-codezip"], + packs: ["@box/base", "@box/bedrock", "@box/agentcore", "@box/agentcore-codezip"], profile: { name: "V3Demo" }, project: { access: "write" }, options: { bedrock: { region: "us-west-2" } }, @@ -415,11 +415,11 @@ describe("renderBoxProfile for AgentCore Runtime", () => { (name) => { const text = renderBoxProfile("V3Demo", template(name), "us-west-2", "runtime")!; // No start.sh fills this profile in: the agentcore pack carries the deployed resources. - expect(text).toContain("The box/agentcore pack carries the deployed resources' variables."); + expect(text).toContain("The @box/agentcore pack carries the deployed resources' variables."); expect(text).not.toContain("# @AGENT_ENV@"); expect(runtimeProfile(name)).toEqual({ - // The container reads the deployed resources from the environment through box/agentcore. - packs: ["box/base", "box/bedrock", "box/agentcore"], + // The container reads the deployed resources from the environment through @box/agentcore. + packs: ["@box/base", "@box/bedrock", "@box/agentcore"], profile: { name: "V3Demo" }, project: { access: "read" }, options: { bedrock: { region: "us-west-2" } }, @@ -462,7 +462,7 @@ describe("renderBoxProfile for AgentCore Runtime", () => { modelProvider: "OpenAI", apiKey: "sk-test", }); - expect(openai.packs).toEqual(["box/base", "box/agentcore", "box/agentcore-codezip"]); + expect(openai.packs).toEqual(["@box/base", "@box/agentcore", "@box/agentcore-codezip"]); expect(openai.egress).toBeUndefined(); }); }); @@ -872,9 +872,9 @@ describe("renderAgentCorePack", () => { ) as Record; } - test("names itself box/agentcore and ships as a support pack", () => { + test("names itself @box/agentcore and ships as a support pack", () => { const toml = pack([]); - expect(toml.pack).toEqual({ name: "box/agentcore", version: 1, kind: "support" }); + expect(toml.pack).toEqual({ name: "@box/agentcore", version: 1, kind: "support" }); }); test("declares the gateway URL input from the environment, bounded by a pattern", () => { @@ -926,8 +926,8 @@ describe("renderAgentCorePack", () => { describe("renderAgentCoreCodeZipPack", () => { const toml = () => parse(renderAgentCoreCodeZipPack()) as Record; - test("names itself box/agentcore-codezip and ships as a support pack", () => { - expect(toml().pack).toEqual({ name: "box/agentcore-codezip", version: 1, kind: "support" }); + test("names itself @box/agentcore-codezip and ships as a support pack", () => { + expect(toml().pack).toEqual({ name: "@box/agentcore-codezip", version: 1, kind: "support" }); }); test("declares the Runtime Python and code directory from the environment start.py exports", () => { diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index d72610bb4..835094adb 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -47,12 +47,18 @@ const BOX_PYTHON_ENV = "BOX_PYTHON"; const BOX_PYTHON_PREFIX_ENV = "BOX_PYTHON_PREFIX"; const BOX_CODE_ENV = "BOX_CODE"; +/** The pack of box that each box profile imports. */ +export const BOX_BASE_PACK = "@box/base"; + +/** The pack of box that routes the Bedrock model calls, with its `[options] bedrock.region`. */ +export const BOX_BEDROCK_PACK = "@box/bedrock"; + /** {@link renderAgentCorePack}. */ -export const AGENTCORE_PACK_NAME = "box/agentcore"; +export const AGENTCORE_PACK_NAME = "@box/agentcore"; export const AGENTCORE_PACK_PATH = "resources/packs/agentcore/pack.toml"; /** {@link renderAgentCoreCodeZipPack}. */ -export const AGENTCORE_CODEZIP_PACK_NAME = "box/agentcore-codezip"; +export const AGENTCORE_CODEZIP_PACK_NAME = "@box/agentcore-codezip"; export const AGENTCORE_CODEZIP_PACK_PATH = "resources/packs/agentcore-codezip/pack.toml"; /** @@ -63,7 +69,7 @@ export const AGENTCORE_CODEZIP_PACK_PATH = "resources/packs/agentcore-codezip/pa const GATEWAY_URL_PATTERN = "https://[a-z0-9][-a-z0-9.]*[.]amazonaws[.]com(/[A-Za-z0-9_-][A-Za-z0-9_.-]*)*"; -/** As box/bedrock bounds `bedrock.region`. */ +/** As @box/bedrock bounds `bedrock.region`. */ const AWS_REGION_PATTERN = "[a-z]{2}(-[a-z]+)?-(central|north|south|east|west)+-[0-9]+"; /** @@ -73,9 +79,9 @@ const AWS_REGION_PATTERN = "[a-z]{2}(-[a-z]+)?-(central|north|south|east|west)+- const ABSOLUTE_PATH_PATTERN = "(/[.]{0,2}[A-Za-z0-9_+-][A-Za-z0-9_.+-]*)+"; /** - * The Runtime's region in the agent's environment, read through the box/agentcore pack's + * The Runtime's region in the agent's environment, read through the @box/agentcore pack's * `aws.region` input. The AWS SDKs in the box, such as the Memory client, need it to call the - * deploy region whose hosts the profile routes. box/bedrock sets `AWS_REGION` itself, so the + * deploy region whose hosts the profile routes. @box/bedrock sets `AWS_REGION` itself, so the * profile sets it only without that pack. */ function runtimeRegionEnv(bedrock: boolean): Record { @@ -100,9 +106,9 @@ const RUNTIME_AWS_STAND_IN_LINES = [ ].join("\n"); /** - * The tools of box/base that get the project's write grant: box gives each one its own grant, so - * each lists the agent's `deny_write` folders as well. Taken from box/base in the box release that - * `boxRelease.json` pins (0.1.11-linux-preview.6). When the pin moves, check box/base's tools: box + * The tools of @box/base that get the project's write grant: box gives each one its own grant, so + * each lists the agent's `deny_write` folders as well. Taken from @box/base in the box release that + * `boxRelease.json` pins (0.1.11-linux-preview.6). When the pin moves, check @box/base's tools: box * refuses a CodeZip box profile if a tool it misses gets the project write grant. */ const BOX_BASE_PROJECT_WRITE_TOOLS = ["uname"]; @@ -402,7 +408,7 @@ function containerRunner(workloadPort: number, dev: boolean): Runner { /** * A Python agent on a CodeZip deploy: the Runtime unpacks the zip into a * read-only folder and runs its own Python, at paths only the microVM knows. - * The box/agentcore-codezip pack reads them from the environment start.py + * The @box/agentcore-codezip pack reads them from the environment start.py * exports (`${{ inputs.code.dir }}`, `${{ inputs.python.path }}`, * `${{ inputs.python.prefix }}`), and the box starts in a writable folder * outside the code, so nothing the agent runs needs `deny_write`. @@ -492,9 +498,9 @@ export function renderBoxProfile( // The optional sections, each empty or ending in a newline. const header = codeZipOnRuntime - ? "# Rendered by agentcore build and deploy from agentcore.json, for AgentCore Runtime. The box/agentcore and box/agentcore-codezip packs carry the deployed resources, the Runtime Python, and the code directory." + ? "# Rendered by agentcore build and deploy from agentcore.json, for AgentCore Runtime. The @box/agentcore and @box/agentcore-codezip packs carry the deployed resources, the Runtime Python, and the code directory." : onRuntime - ? "# Rendered by agentcore build and deploy from agentcore.json, for AgentCore Runtime. The box/agentcore pack carries the deployed resources' variables." + ? "# Rendered by agentcore build and deploy from agentcore.json, for AgentCore Runtime. The @box/agentcore pack carries the deployed resources' variables." : container ? "# Written by `agentcore create` for the agent's image, to run with `box run` in /app." : `# Written by \`agentcore create\` or \`agentcore add runtime\`. Run \`box run ${boxLocalProfileFile(runtime.runtimeName)}\` in the project folder.`; @@ -529,14 +535,14 @@ export function renderBoxProfile( "" : ` # Sign the model calls with your default AWS profile, as \`agentcore dev\` does without a box, -# rather than with the Bedrock API key that box/bedrock reads from AWS_BEARER_TOKEN_BEDROCK. +# rather than with the Bedrock API key that @box/bedrock reads from AWS_BEARER_TOKEN_BEDROCK. [egress.bedrock] secret.ref = "aws://default" `; const keyedRoute = keyed ? apiKeyRouteSection(keyed, apiKeyVariable(runtime, keyed)) : ""; const packs = list([ - "box/base", - ...(bedrock ? ["box/bedrock"] : []), + BOX_BASE_PACK, + ...(bedrock ? [BOX_BEDROCK_PACK] : []), // Both Runtime profiles read the deployed resources from the environment through this pack. ...(onRuntime ? [AGENTCORE_PACK_NAME] : []), // The CodeZip Runtime also reads its Python and code paths through this one. @@ -812,7 +818,7 @@ export function boxProfileWarnings(runtime: ScaffoldRuntimeInput): string[] { } /** - * The `box/agentcore` pack each Runtime profile imports, CodeZip and container: it declares the + * The `@box/agentcore` pack each Runtime profile imports, CodeZip and container: it declares the * inputs the profile reads from the environment the Runtime sets after deploy. The `aws.region` * input carries the Runtime's region into the agent's environment. The `gateway.url` input fills each * egress backend `url`, bounded by a pattern so a value from the environment names only the host the @@ -859,7 +865,7 @@ ${agentEnv}`; } /** - * The `box/agentcore-codezip` pack a CodeZip Runtime profile adds: the Runtime's Python interpreter + * The `@box/agentcore-codezip` pack a CodeZip Runtime profile adds: the Runtime's Python interpreter * and base prefix, and the read-only code directory, which only the microVM knows. start.py exports * them ({@link BOX_PYTHON_ENV}, {@link BOX_PYTHON_PREFIX_ENV}, {@link BOX_CODE_ENV}) before it runs * box, and the profile reads them through these inputs, so no start script fills the profile in. box diff --git a/src/core/project/templates/project.ts b/src/core/project/templates/project.ts index 548f63f57..54b76af26 100644 --- a/src/core/project/templates/project.ts +++ b/src/core/project/templates/project.ts @@ -92,7 +92,7 @@ export async function createProjectTree( */ function withBoxStartScript(config: CreateProjectConfig, template: Template): void { // start.py is the Runtime's entry point: it sets HOME and a writable workspace, exports the - // Python and code paths the box/agentcore-codezip pack reads, then execs `box run`. No start.sh. + // Python and code paths the @box/agentcore-codezip pack reads, then execs `box run`. No start.sh. template.tree.children.push( FsTreeNode.createFile(BOX_CODEZIP_ENTRYPOINT, () => config.assetSource.read(`templates/box-codezip/${BOX_CODEZIP_ENTRYPOINT}`), From 52c2cf6e6e4d1a085f8b9601777336f704d8a8e2 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 14:39:07 -0800 Subject: [PATCH 02/11] feat(box): Pin box 0.1.11-linux-preview.7 The CLI pinned box 0.1.11-linux-preview.6. That box rejects the profiles that the CLI writes after the @box/ pack names and the key input of the log group of the runtime. Its error for a @box/ pack is "@box/base" is not a pack name. The CLI then told the user only to correct what Box reports. The install hints named the release list, and not a version. With this change, boxRelease.json pins [box 0.1.11-linux-preview.7](https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7). The Linux asset has SHA-256 782290ca3f0f0de3faa6c3943a0b51d521f16b135178ab7e4425986a97ee7622. The ffi pin stays 0.1.11-linux-preview.2. scripts/bump-box-release.ts wrote the file from the SHA256SUMS.txt of the release. BOX_MINIMUM_VERSION is 0.1.11-linux-preview.7, the first box that reads the profiles of the CLI. BOX_RELEASE_PAGE is the release page of the pinned box. BOX_INSTALL_HINT and each install hint of the profile resolver use that page and the pinned version. If a box rejects a @box/ pack name, the resolver says that the box comes before BOX_MINIMUM_VERSION, and gives the hint. The open routes fixture for a list of destinations is byte for byte the output of the published macOS preview.7. Tests: boxRelease.test.ts makes sure that the pinned box is at least BOX_MINIMUM_VERSION, that its asset names its version, and that its SHA-256 has 64 hex digits. boxProfileResolver.test.ts examines each install hint, and the hint for a box before preview.7. Each test shows an error in each of these conditions: - The pin goes back to preview.6. - The SHA-256 is not 64 hex digits. - The asset names a different version. - The resolver gives no hint for a box before preview.7. A build with the pinned SHA-256 set to 64 f characters stopped with "not the pinned ffff...". Nothing was installed. The SHA-256 of the two downloaded assets agreed with SHA256SUMS.txt. The macOS preview.7 was on PATH for agentcore build of a container project and of a CodeZip project, and the two builds had no errors. The CodeZip build downloaded the pinned Linux box and staged it. box profile show on each staged Runtime profile, with dummy AWS_REGION, OTEL_EXPORTER_OTLP_LOGS_HEADERS, and AGENTCORE_GATEWAY_BOX_URL, filled these values: - the log group and the log stream of the variable - the region of AWS_REGION in the telemetry target - the region of AWS_REGION in auth.aws.region of each backend The macOS box did this with eu-central-1, and the Linux box in finch, with no network, did this with ap-south-1. The build region was us-west-2. typecheck, lint:check, format:check, and bun test show no errors. docs/box-local-testing.md does not change. --- src/core/project/backends/boxRelease.json | 6 +-- src/core/project/backends/boxRelease.test.ts | 15 +++++++ src/core/project/backends/boxRelease.ts | 12 +++++- src/core/project/boxProfileResolver.test.ts | 43 +++++++++++++------- src/core/project/boxProfileResolver.ts | 33 ++++++++------- 5 files changed, 75 insertions(+), 34 deletions(-) diff --git a/src/core/project/backends/boxRelease.json b/src/core/project/backends/boxRelease.json index 0b2c71386..f436f10e6 100644 --- a/src/core/project/backends/boxRelease.json +++ b/src/core/project/backends/boxRelease.json @@ -1,11 +1,11 @@ { "box": { "repo": "mquang-amazon/box-releases", - "version": "0.1.11-linux-preview.6", + "version": "0.1.11-linux-preview.7", "linux": { "target": "aarch64-unknown-linux-gnu", - "asset": "box-v0.1.11-linux-preview.6-aarch64-unknown-linux-gnu.tar.gz", - "sha256": "cef02792ec43bd03179246ab4306697a29e7fc831d371c21a3d3b191859936da" + "asset": "box-v0.1.11-linux-preview.7-aarch64-unknown-linux-gnu.tar.gz", + "sha256": "782290ca3f0f0de3faa6c3943a0b51d521f16b135178ab7e4425986a97ee7622" } }, "ffi": { diff --git a/src/core/project/backends/boxRelease.test.ts b/src/core/project/backends/boxRelease.test.ts index 2e4866cd9..194aec809 100644 --- a/src/core/project/backends/boxRelease.test.ts +++ b/src/core/project/backends/boxRelease.test.ts @@ -7,8 +7,11 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { InvalidEnvironmentError } from "../../../errors/errors"; import { type ProcessRunner, runProcess } from "../../../io/exec"; +import { gte } from "semver"; import { + BOX_MINIMUM_VERSION, BOX_RELEASE, + BOX_RELEASE_PAGE, FFI_RELEASE, type BoxRelease, type FfiRelease, @@ -255,6 +258,18 @@ describe("boxReleaseFor a runtime's box.version", () => { }); describe("the pinned releases", () => { + test("box is at least the first release that reads the profiles the CLI writes", () => { + expect(BOX_MINIMUM_VERSION).toBe("0.1.11-linux-preview.7"); + expect(gte(BOX_RELEASE.version, BOX_MINIMUM_VERSION)).toBe(true); + expect(BOX_RELEASE.linux.asset).toBe( + `box-v${BOX_RELEASE.version}-aarch64-unknown-linux-gnu.tar.gz`, + ); + expect(BOX_RELEASE.linux.sha256).toMatch(/^[0-9a-f]{64}$/); + expect(BOX_RELEASE_PAGE).toBe( + `https://github.com/mquang-amazon/box-releases/releases/tag/v${BOX_RELEASE.version}`, + ); + }); + test("box and the ffi shim are pinned on their own, with a shim for each Python box runs", () => { expect(BOX_RELEASE.linux.asset).toContain(BOX_RELEASE.version); expect(Object.keys(FFI_RELEASE.pythons)).toContain("PYTHON_3_14"); diff --git a/src/core/project/backends/boxRelease.ts b/src/core/project/backends/boxRelease.ts index b0cea5661..4d2ed54ca 100644 --- a/src/core/project/backends/boxRelease.ts +++ b/src/core/project/backends/boxRelease.ts @@ -56,6 +56,15 @@ const PINNED = z.object({ box: BoxReleaseSchema, ffi: FfiReleaseSchema }).parse( export const BOX_RELEASE: BoxRelease = PINNED.box; export const FFI_RELEASE: FfiRelease = PINNED.ffi; +/** + * The first box release that reads the profiles that the CLI writes: their `@box/` packs, and + * the `key` of an input of the `@box/agentcore` pack. + */ +export const BOX_MINIMUM_VERSION = "0.1.11-linux-preview.7"; + +/** The GitHub release page of the pinned box, with a build for each machine it supports. */ +export const BOX_RELEASE_PAGE = `https://github.com/${BOX_RELEASE.repo}/releases/tag/v${BOX_RELEASE.version}`; + /** Where a release's asset downloads from: the public GitHub release, no token needed. */ export function boxReleaseAssetUrl( release: Pick, @@ -76,8 +85,7 @@ export const BOX_BINARIES = [ * dev ask for when it is not on PATH. The release has a build for each machine it supports. */ export const BOX_INSTALL_HINT = - `Install box: download the build for your machine from ` + - `https://github.com/${BOX_RELEASE.repo}/releases/tag/v${BOX_RELEASE.version}, unpack it into ` + + `Install box: download the build for your machine from ${BOX_RELEASE_PAGE}, unpack it into ` + "a folder (tar -xzf -C ), and add that folder to your PATH."; /** A Linux arm64 box for AgentCore Runtime, and the Python ffi shims, by runtimeVersion. */ diff --git a/src/core/project/boxProfileResolver.test.ts b/src/core/project/boxProfileResolver.test.ts index ce8d24938..4799291e4 100644 --- a/src/core/project/boxProfileResolver.test.ts +++ b/src/core/project/boxProfileResolver.test.ts @@ -5,6 +5,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { InvalidEnvironmentError } from "../../errors/errors"; import { ProcessFailedError, type ProcessEvent, type StreamProcessOptions } from "../../io"; +import { BOX_RELEASE } from "./backends/boxRelease"; import { BoxCliProfileResolver, parseBoxProfileShow } from "./boxProfileResolver"; import { boxNetworkRules, boxReachRules } from "./boxProfileResolver-test-support"; @@ -95,16 +96,15 @@ const SHOWN_POLICY = boxReachRules("route", "keyed", ["k.example.com:8443"]) + boxReachRules("mcp", "docs", ["docs.example.com"]); -const PINNED = - "box 0.1.11-linux-preview.6 or a later release " + - "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.6)"; +/** The last sentence of each error that says to install another box: the pinned release. */ +const INSTALL = `Install box ${BOX_RELEASE.version} (https://github.com/mquang-amazon/box-releases/releases/tag/v${BOX_RELEASE.version}), then retry.`; /** * `box profile show open --format json --full` for a profile with the routes `auth` and `github` * with no secret, the route `keyed` with one, and {@link POLICY}, as box prints it, with HOME at * /tmp/acbox/home. Box 0.1.11-linux-preview.6 joins the destinations of an open route into one - * string, and later boxes give a list. preview.6 printed the first for the same profile with its - * pack named box/base, the name it had before `@box/`. + * string, and 0.1.11-linux-preview.7 prints the second, a list. preview.6 printed the first for the + * same profile with its pack named box/base, the name it had before `@box/`. */ const OPEN_ROUTES_SHOWN = Object.entries({ "one string": readFileSync( @@ -206,8 +206,8 @@ describe("parseBoxProfileShow", () => { ])("refuses a document with %s, and names what it lacks", (_, shown, lacks) => { expect(() => parseBoxProfileShow(JSON.stringify(shown), ".box/profile.toml")).toThrow( new InvalidEnvironmentError( - `Box printed the profile .box/profile.toml without ${lacks}, which build reads. Install ` + - `${PINNED}, then retry.`, + `Box printed the profile .box/profile.toml without ${lacks}, which build reads. ` + + INSTALL, ), ); }); @@ -294,6 +294,25 @@ describe("BoxCliProfileResolver", () => { ); }); + test("says to install the pinned box when a box older than preview.7 refuses an @box/ pack", async () => { + // Box 0.1.11-linux-preview.6 wraps its error, here inside the pack name's line. + const error = await failure( + refusal([ + 'box: error: /work/demo/.box/agent/local/profile.toml: "@box/base" is', + " not a pack name", + "Usage: box profile show [OPTIONS] ", + ]), + ); + + expect((error as Error).message).toBe( + "Box refused the profile .box/agent/local/profile.toml:\n" + + ' box: error: /work/demo/.box/agent/local/profile.toml: "@box/base" is\n' + + " not a pack name\n" + + "This box is older than 0.1.11-linux-preview.7, the first box that names its packs " + + `@box/. ${INSTALL}`, + ); + }); + test("says to run uv sync in the agent's folder when Box refuses its missing .venv", async () => { const error = await failure( refusal([ @@ -328,11 +347,7 @@ describe("BoxCliProfileResolver", () => { ".box/profile.toml", ), ).rejects.toThrow( - new InvalidEnvironmentError( - "Box is not installed or not on PATH. Install box 0.1.11-linux-preview.6 " + - "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.6), " + - "then retry.", - ), + new InvalidEnvironmentError(`Box is not installed or not on PATH. ${INSTALL}`), ); }); @@ -367,8 +382,8 @@ describe("BoxCliProfileResolver", () => { expect(error).toBeInstanceOf(InvalidEnvironmentError); expect((error as Error).message).toBe( - "This Box cannot print the profile .box/profile.toml as JSON, which build reads. Install " + - `${PINNED}, then retry.`, + "This Box cannot print the profile .box/profile.toml as JSON, which build reads. " + + INSTALL, ); }, ); diff --git a/src/core/project/boxProfileResolver.ts b/src/core/project/boxProfileResolver.ts index 36466d008..943729f46 100644 --- a/src/core/project/boxProfileResolver.ts +++ b/src/core/project/boxProfileResolver.ts @@ -9,7 +9,7 @@ import { z } from "zod"; import { InvalidEnvironmentError } from "../../errors/errors"; import { ProcessFailedError, streamProcess, type ProcessStreamer } from "../../io"; import { resolveExecutable } from "../../io/exec"; -import { BOX_RELEASE } from "./backends/boxRelease"; +import { BOX_MINIMUM_VERSION, BOX_RELEASE, BOX_RELEASE_PAGE } from "./backends/boxRelease"; /** A pack of the profile, at the version Box resolves it to. */ export interface BoxPack { @@ -38,11 +38,11 @@ export interface BoxProfileResolver { resolve(projectRoot: string, profilePath: string): Promise; } -/** The box release that `boxRelease.json` pins, which each error that asks for a box names. */ -const PINNED_BOX = `box ${BOX_RELEASE.version}`; +/** What to install, which each error names when the `box` on PATH cannot resolve a profile. */ +const INSTALL_BOX = `Install box ${BOX_RELEASE.version} (${BOX_RELEASE_PAGE}), then retry.`; -/** Where to get the pinned box. */ -const BOX_RELEASE_URL = `https://github.com/${BOX_RELEASE.repo}/releases/tag/v${BOX_RELEASE.version}`; +/** The refusal of an `@box/` pack by a box older than {@link BOX_MINIMUM_VERSION}. */ +const OLD_BOX_PACK_NAME = /"@box\/[^"\s]+" is not a pack name/; /** The error of a box that has no `--format` or `--full` option, as clap prints it. */ const REFUSED_JSON = /(?:unexpected argument|Found argument) '--(?:format|full)'/; @@ -104,7 +104,7 @@ export function parseBoxProfileShow(stdout: string, profilePath: string): Resolv wrong.length > 0 ? wrong.map(([, part]) => part) : [SHOWN_PARTS.box_toml, SHOWN_PARTS.policy]; throw new InvalidEnvironmentError( `Box printed the profile ${profilePath} without ${LIST.format(parts)}, which build reads. ` + - `Install ${PINNED_BOX} or a later release (${BOX_RELEASE_URL}), then retry.`, + INSTALL_BOX, { cause: shown.error }, ); } @@ -142,15 +142,14 @@ export class BoxCliProfileResolver implements BoxProfileResolver { stderr.length === 0 && resolveExecutable("box", { env: this.env }) === null ) { - throw new InvalidEnvironmentError( - `Box is not installed or not on PATH. Install ${PINNED_BOX} (${BOX_RELEASE_URL}), then retry.`, - { cause: error }, - ); + throw new InvalidEnvironmentError(`Box is not installed or not on PATH. ${INSTALL_BOX}`, { + cause: error, + }); } if (stderr.some((line) => REFUSED_JSON.test(line))) { throw new InvalidEnvironmentError( - `This Box cannot print the profile ${profilePath} as JSON, which build reads. Install ` + - `${PINNED_BOX} or a later release (${BOX_RELEASE_URL}), then retry.`, + `This Box cannot print the profile ${profilePath} as JSON, which build reads. ` + + INSTALL_BOX, { cause: error }, ); } @@ -164,13 +163,17 @@ export class BoxCliProfileResolver implements BoxProfileResolver { ); } const agent = venvAgentFolder(lines, projectRoot); + const oldBox = OLD_BOX_PACK_NAME.test(lines.join(" ").replace(/\s+/g, " ")); throw new InvalidEnvironmentError( [ `Box refused the profile ${profilePath}:`, ...lines.map((line) => ` ${line}`), - agent === undefined - ? "Fix what Box reports, then retry." - : `Run 'uv sync' in ${agent}, then retry.`, + oldBox + ? `This box is older than ${BOX_MINIMUM_VERSION}, the first box that names its packs ` + + `@box/. ${INSTALL_BOX}` + : agent === undefined + ? "Fix what Box reports, then retry." + : `Run 'uv sync' in ${agent}, then retry.`, ].join("\n"), { cause: error }, ); From e8069dda99e8eedb45685b1fda3f88b476126d0f Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 23:10:26 +0000 Subject: [PATCH 03/11] feat(box): run CodeZip agents without the ffi shim Box Core #488 allows executable memory on Linux, so a CodeZip agent's Python runs in a box without the _ctypes/libffi shim. build and deploy no longer download or stage it, and boxRelease.json pins box only. box 0.1.11-linux-preview.7 is built on a Box Core with #488. --- README.md | 21 ++-- scripts/bump-box-release.ts | 61 +++------- .../backends/box-release-test-support.ts | 18 +-- src/core/project/backends/boxCodeZip.test.ts | 33 +----- src/core/project/backends/boxCodeZip.ts | 2 - src/core/project/backends/boxRelease.json | 10 -- src/core/project/backends/boxRelease.test.ts | 71 ++--------- src/core/project/backends/boxRelease.ts | 110 ++---------------- src/core/project/boxNetworkSource.ts | 1 - src/core/project/templates/boxProfile.test.ts | 2 +- src/core/project/templates/boxProfile.ts | 7 +- 11 files changed, 53 insertions(+), 283 deletions(-) diff --git a/README.md b/README.md index d9cec7fb3..617056741 100644 --- a/README.md +++ b/README.md @@ -202,25 +202,19 @@ Two templates run their agent in a box, both under `agentcore dev` and on AgentC `agentcore create --template ` makes a Box project from either; every other template runs its agent without box. A Box project holds that one runtime, so `agentcore add runtime` and `agentcore export harness` refuse it. The runtime needs its `"box": { "version": ... }` in -`agentcore.json`, which create writes; build and deploy stop without it. box comes from the public GitHub release `v0.1.11-linux-preview.6` of +`agentcore.json`, which create writes; build and deploy stop without it. box comes from the public GitHub release `v0.1.11-linux-preview.7` of [mquang-amazon/box-releases](https://github.com/mquang-amazon/box-releases). No token or account is needed to download it. -`src/core/project/backends/boxRelease.json` pins two releases on their own, each with its -repository, version and SHA-256s: - -- `box`: the Linux build that ships to AgentCore Runtime. -- `ffi`: the Python ffi shim a CodeZip agent needs in a box, by Python version. It can come from - another repository or version than box. - -`bun scripts/bump-box-release.ts --box ` (or `--ffi `, with `--box-repo` or -`--ffi-repo` to move repository) rewrites the file from the release's `SHA256SUMS.txt`. +`src/core/project/backends/boxRelease.json` pins the Linux build of box that ships to AgentCore +Runtime, with its repository, version and SHA-256. `bun scripts/bump-box-release.ts --box ` +(with `--box-repo` to move repository) rewrites the file from the release's `SHA256SUMS.txt`. How each command uses it: - A CodeZip agent's zip carries box. `build` and `deploy` download box once with `curl` into - `~/.agentcore/box/` and the ffi shim into `~/.agentcore/box-ffi/`, check each against its pinned - SHA-256, and stage box, its packs and the shim into the runtime's `.box-dist/`. + `~/.agentcore/box/`, check it against its pinned SHA-256, and stage box and its packs into the + runtime's `.box-dist/`. - A container agent's image downloads box while it builds. `dev`, `build` and `deploy` stage the release that `box.version` names, with its checksum, as `box-release.env` beside the Dockerfile (`.box-dist/`, or `.box-dev/` under `dev`), and the Dockerfile downloads that release with `curl`, @@ -234,8 +228,7 @@ How each command uses it: Each box runtime names its release in `agentcore.json` with `"box": { "version": "" }`, which `agentcore create` writes. The pinned version keeps the checksums in `boxRelease.json`; -another version takes them from its release's `SHA256SUMS.txt`. `box.version` picks box only: the -ffi shim always comes from `boxRelease.json`. To try an unreleased box build, +another version takes them from its release's `SHA256SUMS.txt`. To try an unreleased box build, publish it as a pre-release with the same file names and set `box.version` to it. On AgentCore Runtime, box signs the agent's Bedrock and Memory calls with the execution role: the diff --git a/scripts/bump-box-release.ts b/scripts/bump-box-release.ts index 7b7162794..d339c296c 100644 --- a/scripts/bump-box-release.ts +++ b/scripts/bump-box-release.ts @@ -1,12 +1,11 @@ #!/usr/bin/env bun /** - Pins box, the box ffi shim, or both to a published GitHub release, in - src/core/project/backends/boxRelease.json. It reads each release's SHA256SUMS.txt, so the file - changes only to a version whose archives are published. It imports nothing from src/. + Pins box to a published GitHub release, in src/core/project/backends/boxRelease.json. It reads + the release's SHA256SUMS.txt, so the file changes only to a version whose archives are published. + It imports nothing from src/. bun scripts/bump-box-release.ts --box [--box-repo ] - bun scripts/bump-box-release.ts --ffi [--ffi-repo ] **/ import { join, resolve } from "node:path"; @@ -21,20 +20,16 @@ const FILE = join( "boxRelease.json", ); const LINUX_TARGET = "aarch64-unknown-linux-gnu"; -/** box-ffi-python3.14-aarch64-unknown-linux-gnu.tar.gz is the shim for PYTHON_3_14. */ -const FFI_ASSET = new RegExp(`^box-ffi-python(\\d+)\\.(\\d+)-${LINUX_TARGET}\\.tar\\.gz$`); const { values } = parseArgs({ args: Bun.argv.slice(2), options: { box: { type: "string" }, "box-repo": { type: "string" }, - ffi: { type: "string" }, - "ffi-repo": { type: "string" }, }, }); -if (!values.box && !values.ffi) { - console.error("Name a version: --box , --ffi , or both."); +if (!values.box) { + console.error("Name a version: --box ."); process.exit(2); } @@ -52,39 +47,13 @@ async function checksums(repo: string, version: string): Promise `box-v${version}-${target}.tar.gz`; - const linux = sums.get(asset(LINUX_TARGET)); - if (!linux) throw new Error(`${repo} v${version} lists no ${asset(LINUX_TARGET)}`); - console.log(`box: ${pinned.box.repo} ${pinned.box.version} → ${repo} ${version}`); - pinned.box = { - repo, - version, - linux: { target: LINUX_TARGET, asset: asset(LINUX_TARGET), sha256: linux }, - }; -} - -if (values.ffi) { - const repo = values["ffi-repo"] ?? pinned.ffi.repo; - const version = values.ffi; - const sums = await checksums(repo, version); - const pythons: Record = {}; - for (const [asset, sha256] of sums) { - const match = FFI_ASSET.exec(asset); - if (match) pythons[`PYTHON_${match[1]}_${match[2]}`] = { asset, sha256 }; - } - if (Object.keys(pythons).length === 0) { - throw new Error(`${repo} v${version} lists no box-ffi-python*-${LINUX_TARGET}.tar.gz`); - } - console.log( - `ffi: ${pinned.ffi.repo} ${pinned.ffi.version} → ${repo} ${version} ` + - `(${Object.keys(pythons).join(", ")})`, - ); - pinned.ffi = { repo, version, pythons }; -} - -await Bun.write(FILE, `${JSON.stringify(pinned, null, 2)}\n`); +const repo = values["box-repo"] ?? pinned.box.repo; +const version = values.box; +const sums = await checksums(repo, version); +const asset = `box-v${version}-${LINUX_TARGET}.tar.gz`; +const linux = sums.get(asset); +if (!linux) throw new Error(`${repo} v${version} lists no ${asset}`); +console.log(`box: ${pinned.box.repo} ${pinned.box.version} → ${repo} ${version}`); +const box = { repo, version, linux: { target: LINUX_TARGET, asset, sha256: linux } }; + +await Bun.write(FILE, `${JSON.stringify({ box }, null, 2)}\n`); diff --git a/src/core/project/backends/box-release-test-support.ts b/src/core/project/backends/box-release-test-support.ts index c72198109..bec153079 100644 --- a/src/core/project/backends/box-release-test-support.ts +++ b/src/core/project/backends/box-release-test-support.ts @@ -1,17 +1,10 @@ import { mkdir, writeFile } from "node:fs/promises"; import { join } from "node:path"; -import { - BOX_BINARIES, - BOX_RELEASE, - boxCachePath, - FFI_CACHE_MARKER, - FFI_RELEASE, - ffiCachePath, -} from "./boxRelease"; +import { BOX_BINARIES, BOX_RELEASE, boxCachePath } from "./boxRelease"; /** - * Fills the caches under `home` with stand-ins of the pinned box release and ffi shims, so - * build, deploy and dev find them and download nothing. + * Fills the cache under `home` with a stand-in of the pinned box release, so build, deploy and + * dev find it and download nothing. */ export async function seedBoxCache(home: string): Promise { const root = boxCachePath(home, BOX_RELEASE.version, BOX_RELEASE.linux.target); @@ -19,9 +12,4 @@ export async function seedBoxCache(home: string): Promise { await writeFile(join(root, "resources", "config.toml"), ""); for (const binary of BOX_BINARIES) await writeFile(join(root, binary), `#!${binary}\n`); await writeFile(join(root, "release.json"), JSON.stringify({ box_version: BOX_RELEASE.version })); - for (const [runtimeVersion, { sha256 }] of Object.entries(FFI_RELEASE.pythons)) { - const ffi = ffiCachePath(home, FFI_RELEASE.version, runtimeVersion); - await mkdir(ffi, { recursive: true }); - await writeFile(join(ffi, FFI_CACHE_MARKER), `${sha256}\n`); - } } diff --git a/src/core/project/backends/boxCodeZip.test.ts b/src/core/project/backends/boxCodeZip.test.ts index b9c795c5a..a966a0eca 100644 --- a/src/core/project/backends/boxCodeZip.test.ts +++ b/src/core/project/backends/boxCodeZip.test.ts @@ -34,23 +34,14 @@ const BINARIES = ["box", "strands-box-sock-alias", "strands-box-contain-trampoli /** * A Linux box build laid out as the release cache holds it, and as deploy resolves it: box, its - * helpers and its packs in one folder, and optionally the Python 3.14 shim under ffi/. + * helpers and its packs in one folder. */ -async function linuxBuild(options: { ffi?: boolean } = {}): Promise { +async function linuxBuild(): Promise { const root = await temp("box-build-"); for (const binary of BINARIES) await writeFile(join(root, binary), `#!${binary}\n`); await mkdir(join(root, "resources", "shared", "base"), { recursive: true }); await writeFile(join(root, "resources", "shared", "base", "pack.toml"), "[pack]\n"); - const ffi = join(root, "ffi", "PYTHON_3_14"); - if (options.ffi) { - await mkdir(ffi, { recursive: true }); - await writeFile(join(ffi, "libffi.so.8"), "ffi"); - } - return { - binaries: root, - resources: join(root, "resources"), - ffi: options.ffi ? { PYTHON_3_14: ffi } : {}, - }; + return { binaries: root, resources: join(root, "resources") }; } async function project(entrypoint: string, runtimeVersion = "PYTHON_3_14"): Promise { @@ -81,8 +72,8 @@ async function project(entrypoint: string, runtimeVersion = "PYTHON_3_14"): Prom } describe("stageBoxCodeZip", () => { - test("stages box, its packs, the shim, and the Runtime profile into the code folder", async () => { - const build = await linuxBuild({ ffi: true }); + test("stages box, its packs, and the Runtime profile into the code folder", async () => { + const build = await linuxBuild(); const demo = await project("start.py"); expect(await stageBoxCodeZip(demo, [], async () => build)).toEqual(["agent"]); @@ -98,7 +89,6 @@ describe("stageBoxCodeZip", () => { expect(await readFile(join(dist, "resources", "shared", "base", "pack.toml"), "utf8")).toBe( "[pack]\n", ); - expect(await readFile(join(dist, "ffi", "libffi.so.8"), "utf8")).toBe("ffi"); // The Runtime profile is rendered from agentcore.json. expect(await readFile(join(dist, "profile.toml"), "utf8")).toBe( renderRuntimeBoxProfile(demo.spec, demo.spec.runtimes[0]!), @@ -114,7 +104,7 @@ describe("stageBoxCodeZip", () => { }); test("asks for the box of the runtime's box.version", async () => { - const build = await linuxBuild({ ffi: true }); + const build = await linuxBuild(); const demo = await project("start.py"); demo.spec.runtimes[0]!.box = { version: "2.0.0" }; const versions: (string | undefined)[] = []; @@ -127,17 +117,6 @@ describe("stageBoxCodeZip", () => { expect(versions).toEqual(["2.0.0"]); }); - test("ships no shim to a runtime whose Python it was not built for", async () => { - const build = await linuxBuild({ ffi: true }); - const demo = await project("start.py", "PYTHON_3_13"); - - await stageBoxCodeZip(demo, [], async () => build); - - const dist = join(demo.rootPath, "app", "agent", ".box-dist"); - expect(await Bun.file(join(dist, "box")).exists()).toBe(true); - expect(await Bun.file(join(dist, "ffi", "libffi.so.8")).exists()).toBe(false); - }); - test.each([ ["a user's own start.py, with no box.version", false, "box"], ["a box runtime outside a Box project", true, undefined], diff --git a/src/core/project/backends/boxCodeZip.ts b/src/core/project/backends/boxCodeZip.ts index 968c6c556..37312ce19 100644 --- a/src/core/project/backends/boxCodeZip.ts +++ b/src/core/project/backends/boxCodeZip.ts @@ -62,8 +62,6 @@ export async function stageBoxCodeZip( chmodSync(join(folder, binary), 0o755); } cpSync(build.resources, join(folder, "resources"), { recursive: true }); - const ffi = entry.runtimeVersion ? build.ffi[entry.runtimeVersion] : undefined; - if (ffi) cpSync(ffi, join(folder, "ffi"), { recursive: true }); writeBoxNetworkFiles(project.rootPath, filesOf(dist)); writeRenderedBoxFiles(project.rootPath, runtime, dist, filesOf(dist)); } diff --git a/src/core/project/backends/boxRelease.json b/src/core/project/backends/boxRelease.json index f436f10e6..e165cc1d2 100644 --- a/src/core/project/backends/boxRelease.json +++ b/src/core/project/backends/boxRelease.json @@ -7,15 +7,5 @@ "asset": "box-v0.1.11-linux-preview.7-aarch64-unknown-linux-gnu.tar.gz", "sha256": "782290ca3f0f0de3faa6c3943a0b51d521f16b135178ab7e4425986a97ee7622" } - }, - "ffi": { - "repo": "mquang-amazon/box-releases", - "version": "0.1.11-linux-preview.2", - "pythons": { - "PYTHON_3_14": { - "asset": "box-ffi-python3.14-aarch64-unknown-linux-gnu.tar.gz", - "sha256": "1266d484cbdbfa9df53a0aa29efbc0a1063e0ace9945bca5489b5f828f68b54e" - } - } } } diff --git a/src/core/project/backends/boxRelease.test.ts b/src/core/project/backends/boxRelease.test.ts index 194aec809..4a5db242b 100644 --- a/src/core/project/backends/boxRelease.test.ts +++ b/src/core/project/backends/boxRelease.test.ts @@ -12,9 +12,7 @@ import { BOX_MINIMUM_VERSION, BOX_RELEASE, BOX_RELEASE_PAGE, - FFI_RELEASE, type BoxRelease, - type FfiRelease, boxReleaseFor, resolveBoxLinuxBuild, } from "./boxRelease"; @@ -35,7 +33,6 @@ async function temp(prefix: string): Promise { const BINARIES = ["box", "strands-box-sock-alias", "strands-box-contain-trampoline"]; const VERSION = "9.9.9-linux-preview.1"; -const FFI_VERSION = "3.0.0"; /** A tarball of `files` (relative path to content), and its SHA-256. */ async function tarball(name: string, files: Record) { @@ -61,9 +58,6 @@ async function fakeRelease(boxFiles?: Record) { "release.json": JSON.stringify({ box_version: VERSION }), }; const box = await tarball(`box-v${VERSION}-aarch64-unknown-linux-gnu.tar.gz`, files); - const ffi = await tarball("box-ffi-python3.14-aarch64-unknown-linux-gnu.tar.gz", { - "libffi.so.8": "ffi", - }); const release: BoxRelease = { repo: "owner/box-releases", version: VERSION, @@ -73,21 +67,7 @@ async function fakeRelease(boxFiles?: Record) { sha256: box.sha256, }, }; - // The ffi shim ships from its own repository and version. - const ffiRelease: FfiRelease = { - repo: "other/ffi-releases", - version: FFI_VERSION, - pythons: { - PYTHON_3_14: { - asset: "box-ffi-python3.14-aarch64-unknown-linux-gnu.tar.gz", - sha256: ffi.sha256, - }, - }, - }; - const assets: Record = { - [release.linux.asset]: box.archive, - [ffiRelease.pythons.PYTHON_3_14!.asset]: ffi.archive, - }; + const assets: Record = { [release.linux.asset]: box.archive }; const commands: string[][] = []; // curl writes the asset its URL names to -o; tar runs for real. The tests pass an empty // environment, which on Windows leaves no PATH to find tar by, so tar gets this process's. @@ -100,77 +80,55 @@ async function fakeRelease(boxFiles?: Record) { const output = command[command.indexOf("-o") + 1]!; await writeFile(output, await readFile(assets[url.slice(url.lastIndexOf("/") + 1)]!)); }; - return { release, ffi: ffiRelease, runner, commands }; + return { release, runner, commands }; } describe("resolveBoxLinuxBuild from the box release", () => { - test("downloads box and the ffi shim, each from its own release, checks them, and caches each on its own", async () => { + test("downloads box, checks it, and caches it", async () => { const home = await temp("box-home-"); - const { release, ffi, runner, commands } = await fakeRelease(); + const { release, runner, commands } = await fakeRelease(); const downloads: string[] = []; const build = await resolveBoxLinuxBuild( {}, - { runner, home, release, ffi, onDownload: ({ name }) => downloads.push(name) }, + { runner, home, release, onDownload: ({ name }) => downloads.push(name) }, ); const root = join(home, ".agentcore", "box", `${VERSION}-aarch64-unknown-linux-gnu`); - const shim = join(home, ".agentcore", "box-ffi", FFI_VERSION, "PYTHON_3_14"); expect(build.binaries).toBe(root); expect(build.resources).toBe(join(root, "resources")); - expect(build.ffi).toEqual({ PYTHON_3_14: shim }); + expect(build).toEqual({ binaries: root, resources: join(root, "resources") }); // Windows has no mode bits. if (process.platform !== "win32") { for (const binary of BINARIES) { expect((await stat(join(root, binary))).mode & 0o777).toBe(0o755); } } - expect(await readFile(join(shim, "libffi.so.8"), "utf8")).toBe("ffi"); - expect(downloads).toEqual(["box", "the box ffi shim for PYTHON_3_14"]); + expect(downloads).toEqual(["box"]); expect( commands.filter((command) => command[0] === "curl").map((command) => command.at(-1)), ).toEqual([ `https://github.com/owner/box-releases/releases/download/v${VERSION}/${release.linux.asset}`, - `https://github.com/other/ffi-releases/releases/download/v${FFI_VERSION}/box-ffi-python3.14-aarch64-unknown-linux-gnu.tar.gz`, ]); }); - test("downloads only the ffi shim when its pin changes and box is cached", async () => { - const home = await temp("box-home-"); - const { release, ffi, runner, commands } = await fakeRelease(); - await resolveBoxLinuxBuild({}, { runner, home, release, ffi }); - commands.length = 0; - // A shim pinned with another checksum is not the cached one, so it downloads again. - const repinned = { - ...ffi, - pythons: { PYTHON_3_14: { ...ffi.pythons.PYTHON_3_14!, sha256: "0".repeat(64) } }, - }; - - await expect( - resolveBoxLinuxBuild({}, { runner, home, release, ffi: repinned }), - ).rejects.toThrow(/not the pinned 0{64}/); - - expect(commands.filter((command) => command[0] === "curl")).toHaveLength(1); - expect(commands[0]!.at(-1)).toContain("other/ffi-releases"); - }); - test("reuses an installed release without downloading again", async () => { const home = await temp("box-home-"); - const { release, ffi, runner, commands } = await fakeRelease(); - await resolveBoxLinuxBuild({}, { runner, home, release, ffi }); + const { release, runner, commands } = await fakeRelease(); + await resolveBoxLinuxBuild({}, { runner, home, release }); commands.length = 0; - await resolveBoxLinuxBuild({}, { runner, home, release, ffi }); + await resolveBoxLinuxBuild({}, { runner, home, release }); expect(commands).toEqual([]); }); test("installs nothing when an asset's checksum is not the pinned one", async () => { const home = await temp("box-home-"); - const { release, ffi, runner } = await fakeRelease(); + const { release, runner } = await fakeRelease(); const pinned = { ...release, linux: { ...release.linux, sha256: "0".repeat(64) } }; - const result = resolveBoxLinuxBuild({}, { runner, home, release: pinned, ffi }); + const result = resolveBoxLinuxBuild({}, { runner, home, release: pinned }); await expect(result).rejects.toThrow(InvalidEnvironmentError); await expect(result).rejects.toThrow(/not the pinned 0{64}\. Nothing was installed/); @@ -269,9 +227,4 @@ describe("the pinned releases", () => { `https://github.com/mquang-amazon/box-releases/releases/tag/v${BOX_RELEASE.version}`, ); }); - - test("box and the ffi shim are pinned on their own, with a shim for each Python box runs", () => { - expect(BOX_RELEASE.linux.asset).toContain(BOX_RELEASE.version); - expect(Object.keys(FFI_RELEASE.pythons)).toContain("PYTHON_3_14"); - }); }); diff --git a/src/core/project/backends/boxRelease.ts b/src/core/project/backends/boxRelease.ts index 4d2ed54ca..d7b78fda6 100644 --- a/src/core/project/backends/boxRelease.ts +++ b/src/core/project/backends/boxRelease.ts @@ -1,13 +1,5 @@ import { createHash } from "node:crypto"; -import { - chmodSync, - mkdirSync, - mkdtempSync, - readFileSync, - renameSync, - rmSync, - writeFileSync, -} from "node:fs"; +import { chmodSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; import { z } from "zod"; @@ -33,28 +25,15 @@ const BoxReleaseSchema = z.object({ linux: TargetAssetSchema, }); -/** - * A release of the Python ffi shim that a CodeZip agent's Python needs in a box: the `_ctypes` - * and libffi that Box Core's W^X filter allows, by the runtimeVersion they are built for. It ships - * on its own, so it can come from another repository or version than box. - */ -const FfiReleaseSchema = z.object({ - repo: z.string().min(1), - version: z.string().min(1), - pythons: z.record(z.string(), AssetSchema), -}); - export type BoxRelease = z.infer; -export type FfiRelease = z.infer; /** - * The releases this CLI pins, from boxRelease.json. The checksums are pinned there, not read + * The release this CLI pins, from boxRelease.json. The checksums are pinned there, not read * from a release's SHA256SUMS.txt, so a changed asset fails instead of shipping. * `scripts/bump-box-release.ts` rewrites the file. */ -const PINNED = z.object({ box: BoxReleaseSchema, ffi: FfiReleaseSchema }).parse(pinned); +const PINNED = z.object({ box: BoxReleaseSchema }).parse(pinned); export const BOX_RELEASE: BoxRelease = PINNED.box; -export const FFI_RELEASE: FfiRelease = PINNED.ffi; /** * The first box release that reads the profiles that the CLI writes: their `@box/` packs, and @@ -88,14 +67,12 @@ export const BOX_INSTALL_HINT = `Install box: download the build for your machine from ${BOX_RELEASE_PAGE}, unpack it into ` + "a folder (tar -xzf -C ), and add that folder to your PATH."; -/** A Linux arm64 box for AgentCore Runtime, and the Python ffi shims, by runtimeVersion. */ +/** A Linux arm64 box for AgentCore Runtime. */ export type BoxLinuxBuild = { /** The folder that holds box and its helpers. */ binaries: string; /** box's packs. */ resources: string; - /** The `_ctypes` and libffi that Box Core's W^X filter allows, for each Python it is built for. */ - ffi: Partial>; }; /** What is about to download, which happens once per version. */ @@ -118,8 +95,6 @@ export type ResolveBoxLinuxBuildOptions = { home?: string; /** The box release to install; BOX_RELEASE by default. */ release?: BoxRelease; - /** The ffi release to install; FFI_RELEASE by default. */ - ffi?: FfiRelease; }; /** The cache of box builds, by version and target. */ @@ -127,55 +102,27 @@ function boxCache(home: string): string { return join(home, ".agentcore", "box"); } -/** The cache of ffi shims, by version and runtimeVersion. */ -function ffiCache(home: string): string { - return join(home, ".agentcore", "box-ffi"); -} - /** Where a box build is cached. */ export function boxCachePath(home: string, version: string, target: string): string { return join(boxCache(home), `${version}-${target}`); } -/** Where an ffi shim is cached. */ -export function ffiCachePath(home: string, version: string, runtimeVersion: string): string { - return join(ffiCache(home), version, runtimeVersion); -} - -/** The file in an ffi cache folder that names the SHA-256 of the archive it came from. */ -export const FFI_CACHE_MARKER = ".sha256"; - /** - * The Linux box for AgentCore Runtime from `release`, and the ffi shims from `ffi`. Each - * downloads once with curl from its public URL, after its checksum matches: box into - * `~/.agentcore/box/-/`, each shim into - * `~/.agentcore/box-ffi///`. Later runs reuse them. + * The Linux box for AgentCore Runtime from `release`. It downloads once with curl from its public + * URL, after its checksum matches, into `~/.agentcore/box/-/`. Later runs reuse it. */ export async function resolveBoxLinuxBuild( env: NodeJS.ProcessEnv, options: ResolveBoxLinuxBuildOptions = {}, ): Promise { const release = options.release ?? BOX_RELEASE; - const ffi = options.ffi ?? FFI_RELEASE; // HOME from the environment the CLI was given, so the caches follow it. const home = options.home ?? env.HOME ?? homedir(); const runner = options.runner ?? runProcess; const root = await installBox(release, release.linux, env, runner, home, options.onDownload, { forWhat: "AgentCore Runtime", }); - const shims: Partial> = {}; - for (const [runtimeVersion, asset] of Object.entries(ffi.pythons)) { - shims[runtimeVersion] = await installFfi( - ffi, - runtimeVersion, - asset, - env, - runner, - home, - options.onDownload, - ); - } - return { binaries: root, resources: join(root, "resources"), ffi: shims }; + return { binaries: root, resources: join(root, "resources") }; } /** Whether `root` holds box `version`: release.json, box, its helpers, and its packs. */ @@ -271,46 +218,6 @@ async function installBox( return root; } -/** Installs the ffi shim of `runtimeVersion` into its cache folder, once, and returns it. */ -async function installFfi( - ffi: FfiRelease, - runtimeVersion: string, - asset: { asset: string; sha256: string }, - env: NodeJS.ProcessEnv, - runner: ProcessRunner, - home: string, - onDownload: OnBoxDownload | undefined, -): Promise { - const root = ffiCachePath(home, ffi.version, runtimeVersion); - const marker = join(root, FFI_CACHE_MARKER); - if (isFile(marker) && readFileSync(marker, "utf8").trim() === asset.sha256) return root; - - const url = boxReleaseAssetUrl(ffi, asset.asset); - onDownload?.({ name: `the box ffi shim for ${runtimeVersion}`, version: ffi.version, url }); - const { work, archive } = await downloadChecked( - ffi, - asset, - ffiCache(home), - env, - runner, - (failed) => - `a CodeZip runtime on ${runtimeVersion} runs its agent in a box, so this ships the box ffi ` + - `shim ${ffi.version}, downloaded from ${failed}, which failed. Check your network, then retry.`, - ); - try { - const payload = join(work, "payload"); - mkdirSync(payload); - await runner(["tar", "-xzf", archive, "-C", payload], { cwd: work, env }); - writeFileSync(join(payload, FFI_CACHE_MARKER), `${asset.sha256}\n`); - rmSync(root, { recursive: true, force: true }); - mkdirSync(join(root, ".."), { recursive: true }); - renameSync(payload, root); - } finally { - rmSync(work, { recursive: true, force: true }); - } - return root; -} - async function download( release: Pick, asset: string, @@ -336,8 +243,7 @@ async function download( /** * The box release of `version`, which a runtime's `box.version` names: the pinned one, else one * in BOX_RELEASE's repository, in its layout, whose checksums come from the release's own - * SHA256SUMS.txt. No version means BOX_RELEASE. The ffi shim does not follow it: FFI_RELEASE pins - * that on its own. + * SHA256SUMS.txt. No version means BOX_RELEASE. */ export async function boxReleaseFor( version: string | undefined, diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 16548259e..f8c694e1f 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -302,7 +302,6 @@ const BOX_DIST_NAMES: ReadonlySet = new Set([ "strands-box-sock-alias", "strands-box-contain-trampoline", "resources", - "ffi", "profile.toml", ]); diff --git a/src/core/project/templates/boxProfile.test.ts b/src/core/project/templates/boxProfile.test.ts index b34740b7a..d268c30b8 100644 --- a/src/core/project/templates/boxProfile.test.ts +++ b/src/core/project/templates/boxProfile.test.ts @@ -395,7 +395,7 @@ describe("renderBoxProfile for AgentCore Runtime", () => { ], env: { PORT: "8081", - PYTHONPATH: "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + PYTHONPATH: "${{ inputs.code.dir }}", PYTHONUNBUFFERED: "1", PYTHONUTF8: "1", ...RUNTIME_AWS_STAND_INS, diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index 835094adb..5489f8e2e 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -420,12 +420,7 @@ function runtimeCodeZipRunner(protocol: Protocol, workloadPort: number): Runner const { command, env } = serve(protocol, code, workloadPort, false, python); return { command, - env: { - ...env, - // Python finds the _ctypes that deploy stages before its own: its libffi uses static - // trampolines, which Box Core's W^X filter allows. - PYTHONPATH: `${code}/${BOX_CODEZIP_DIST}/ffi:${code}`, - }, + env: { ...env, PYTHONPATH: code }, read: [code, pythonPrefix, "/usr/lib64", "/lib64"].map(str), execComment: "# Box Core adds the loader folders itself and refuses exec on them, so they are read only.\n" + From baa1fe0970c709b0874b06db2e5205249ec5fb15 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 23:06:01 +0000 Subject: [PATCH 04/11] docs(box): drop the ffi shim from what a CodeZip zip carries --- src/core/project/backends/boxCodeZip.ts | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/core/project/backends/boxCodeZip.ts b/src/core/project/backends/boxCodeZip.ts index 37312ce19..9aa71a39a 100644 --- a/src/core/project/backends/boxCodeZip.ts +++ b/src/core/project/backends/boxCodeZip.ts @@ -14,12 +14,11 @@ import { BOX_BINARIES, type BoxLinuxBuild } from "./boxRelease"; /** * Stages box into each CodeZip runtime that runs in a box ({@link runtimeRunsInBox}), * so the zip carries it: `/.box-dist/` gets box, its helpers, its - * packs, the libffi shim built for the runtime's Python, and what the runtime - * profile writer writes from the runtime's Box network model (the Runtime profile - * and a byte copy of each policy file it names). `.box//aws/` gets only what - * the writer writes, for people to read. Both folders are rewritten on every build - * and deploy. `box` is asked for only when a runtime needs it. Returns the names - * of the runtimes it staged. + * packs, and what the runtime profile writer writes from the runtime's Box network + * model (the Runtime profile and a byte copy of each policy file it names). + * `.box//aws/` gets only what the writer writes, for people to read. Both + * folders are rewritten on every build and deploy. `box` is asked for only when a + * runtime needs it. Returns the names of the runtimes it staged. */ export async function stageBoxCodeZip( project: Project, From 3934bbeda2380e5ff9d86117ad8630382bbf301a Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 23:34:23 +0000 Subject: [PATCH 05/11] feat(box): Pin box 0.1.11-mquang.preview.9 --- README.md | 2 +- src/core/project/backends/boxRelease.json | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 617056741..50663195e 100644 --- a/README.md +++ b/README.md @@ -202,7 +202,7 @@ Two templates run their agent in a box, both under `agentcore dev` and on AgentC `agentcore create --template ` makes a Box project from either; every other template runs its agent without box. A Box project holds that one runtime, so `agentcore add runtime` and `agentcore export harness` refuse it. The runtime needs its `"box": { "version": ... }` in -`agentcore.json`, which create writes; build and deploy stop without it. box comes from the public GitHub release `v0.1.11-linux-preview.7` of +`agentcore.json`, which create writes; build and deploy stop without it. box comes from the public GitHub release `v0.1.11-mquang.preview.9` of [mquang-amazon/box-releases](https://github.com/mquang-amazon/box-releases). No token or account is needed to download it. diff --git a/src/core/project/backends/boxRelease.json b/src/core/project/backends/boxRelease.json index e165cc1d2..654733e45 100644 --- a/src/core/project/backends/boxRelease.json +++ b/src/core/project/backends/boxRelease.json @@ -1,11 +1,11 @@ { "box": { "repo": "mquang-amazon/box-releases", - "version": "0.1.11-linux-preview.7", + "version": "0.1.11-mquang.preview.9", "linux": { "target": "aarch64-unknown-linux-gnu", - "asset": "box-v0.1.11-linux-preview.7-aarch64-unknown-linux-gnu.tar.gz", - "sha256": "782290ca3f0f0de3faa6c3943a0b51d521f16b135178ab7e4425986a97ee7622" + "asset": "box-v0.1.11-mquang.preview.9-aarch64-unknown-linux-gnu.tar.gz", + "sha256": "5b0f8802fb1c5cbc22db4bfcefc9061e048e931c972584350ebce6c1b15da884" } } } From 6508ade323e786ca2cf9a6d2811bbeab32433fae Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 19:54:45 -0800 Subject: [PATCH 06/11] fix(box): Fit the box pin port to box-integration - The old-box hint test names box-integration's .box/profile.toml, not the development branch's .box/agent/local/profile.toml. - The README's CodeBuild check names box 0.1.11-mquang.preview.9, the pinned box, not preview.6. --- README.md | 2 +- src/core/project/boxProfileResolver.test.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 50663195e..0770c3ef4 100644 --- a/README.md +++ b/README.md @@ -247,7 +247,7 @@ agentcore invoke --runtime agent --session-id my-box-session-0000000000000000000 agentcore logs runtime --name agent --since 15m --query '"running profile"' ``` -The CodeBuild log of the deploy shows `/tmp/box.tar.gz: OK` and `box 0.1.11-linux-preview.6`. The +The CodeBuild log of the deploy shows `/tmp/box.tar.gz: OK` and `box 0.1.11-mquang.preview.9`. The second answer should say teal, and the runtime log shows `running profile ...` with no `ERROR`, `blocked by egress control` or `AccessDenied` line. For a CodeZip agent, use `--template agent-python-strands-box` and skip the container settings. diff --git a/src/core/project/boxProfileResolver.test.ts b/src/core/project/boxProfileResolver.test.ts index 4799291e4..26b6b5358 100644 --- a/src/core/project/boxProfileResolver.test.ts +++ b/src/core/project/boxProfileResolver.test.ts @@ -298,15 +298,15 @@ describe("BoxCliProfileResolver", () => { // Box 0.1.11-linux-preview.6 wraps its error, here inside the pack name's line. const error = await failure( refusal([ - 'box: error: /work/demo/.box/agent/local/profile.toml: "@box/base" is', + 'box: error: /work/demo/.box/profile.toml: "@box/base" is', " not a pack name", "Usage: box profile show [OPTIONS] ", ]), ); expect((error as Error).message).toBe( - "Box refused the profile .box/agent/local/profile.toml:\n" + - ' box: error: /work/demo/.box/agent/local/profile.toml: "@box/base" is\n' + + "Box refused the profile .box/profile.toml:\n" + + ' box: error: /work/demo/.box/profile.toml: "@box/base" is\n' + " not a pack name\n" + "This box is older than 0.1.11-linux-preview.7, the first box that names its packs " + `@box/. ${INSTALL}`, From 7543e1ed8f313f8d90e1ba8678b406f4be949a49 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 20:01:10 -0800 Subject: [PATCH 07/11] style(box): Format the box resolver test --- src/core/project/boxProfileResolver.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/project/boxProfileResolver.test.ts b/src/core/project/boxProfileResolver.test.ts index 26b6b5358..0da3a11bd 100644 --- a/src/core/project/boxProfileResolver.test.ts +++ b/src/core/project/boxProfileResolver.test.ts @@ -206,8 +206,7 @@ describe("parseBoxProfileShow", () => { ])("refuses a document with %s, and names what it lacks", (_, shown, lacks) => { expect(() => parseBoxProfileShow(JSON.stringify(shown), ".box/profile.toml")).toThrow( new InvalidEnvironmentError( - `Box printed the profile .box/profile.toml without ${lacks}, which build reads. ` + - INSTALL, + `Box printed the profile .box/profile.toml without ${lacks}, which build reads. ` + INSTALL, ), ); }); From e5ee285ff6e5b545d004e1a9b6ffbe8cc8003d1e Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 20:35:23 -0800 Subject: [PATCH 08/11] fix(box): Refuse a box.version from before the @box/ pack names Every Box project created before the @box/ rename names box 0.1.11-linux-preview.6 under box.version. Build and deploy staged that box with a Runtime profile that names @box/ packs, which it refuses. Build could not see it, since box profile show runs the box on PATH, so the agent failed only when it started on AgentCore Runtime. - boxReleaseFor refuses a box that boxPredatesPackNames (a 0.1.11-linux-preview.N below BOX_MINIMUM_VERSION's N, or any box before 0.1.11) before it downloads anything, and says to set box.version to the pinned box or remove it. - The old box/ stop says the same when the runtime's box.version is such a box. - The pin test checks boxPredatesPackNames, not a semver gte, which passed only because "mquang" sorts after "linux-preview". - The BOX_BASE_PROJECT_WRITE_TOOLS comment names the pinned preview.9, whose @box/base still has only [tool.uname]. Review of #2867. New code; box-integration-development has the same gap. --- src/core/project/backends/boxRelease.test.ts | 33 ++++++++++++++++-- src/core/project/backends/boxRelease.ts | 35 +++++++++++++++++++- src/core/project/boxNetworkSource.test.ts | 17 +++++++++- src/core/project/boxNetworkSource.ts | 23 ++++++++++--- src/core/project/templates/boxProfile.ts | 2 +- 5 files changed, 100 insertions(+), 10 deletions(-) diff --git a/src/core/project/backends/boxRelease.test.ts b/src/core/project/backends/boxRelease.test.ts index 4a5db242b..5f45d499c 100644 --- a/src/core/project/backends/boxRelease.test.ts +++ b/src/core/project/backends/boxRelease.test.ts @@ -7,12 +7,12 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { InvalidEnvironmentError } from "../../../errors/errors"; import { type ProcessRunner, runProcess } from "../../../io/exec"; -import { gte } from "semver"; import { BOX_MINIMUM_VERSION, BOX_RELEASE, BOX_RELEASE_PAGE, type BoxRelease, + boxPredatesPackNames, boxReleaseFor, resolveBoxLinuxBuild, } from "./boxRelease"; @@ -213,12 +213,41 @@ describe("boxReleaseFor a runtime's box.version", () => { /box 2\.0\.0, which agentcore\.json names under box\.version, has no box-v2\.0\.0-aarch64-unknown-linux-gnu\.tar\.gz/, ); }); + test("refuses a box from before the @box/ pack names, and downloads nothing", async () => { + const home = await temp("box-home-"); + const { runner, urls } = sumsServer(""); + + await expect(boxReleaseFor("0.1.11-linux-preview.6", {}, { runner, home })).rejects.toThrow( + new InvalidEnvironmentError( + "agentcore.json names box 0.1.11-linux-preview.6 under box.version, a box before " + + "0.1.11-linux-preview.7 that refuses the @box/ packs the CLI writes. Set " + + `box.version to ${BOX_RELEASE.version}, or remove it to use that box. Then retry.`, + ), + ); + expect(urls).toEqual([]); + }); +}); + +describe("boxPredatesPackNames", () => { + test.each([ + ["0.1.11-linux-preview.2", true], + ["0.1.11-linux-preview.6", true], + ["0.1.10", true], + ["0.1.11-linux-preview.7", false], + ["0.1.11-linux-preview.10", false], + ["0.1.11-mquang.preview.9", false], + ["0.1.11", false], + ["0.2.0", false], + ["not-a-version", false], + ])("%s: %p", (version, old) => { + expect(boxPredatesPackNames(version)).toBe(old); + }); }); describe("the pinned releases", () => { test("box is at least the first release that reads the profiles the CLI writes", () => { expect(BOX_MINIMUM_VERSION).toBe("0.1.11-linux-preview.7"); - expect(gte(BOX_RELEASE.version, BOX_MINIMUM_VERSION)).toBe(true); + expect(boxPredatesPackNames(BOX_RELEASE.version)).toBe(false); expect(BOX_RELEASE.linux.asset).toBe( `box-v${BOX_RELEASE.version}-aarch64-unknown-linux-gnu.tar.gz`, ); diff --git a/src/core/project/backends/boxRelease.ts b/src/core/project/backends/boxRelease.ts index d7b78fda6..bfd19cb67 100644 --- a/src/core/project/backends/boxRelease.ts +++ b/src/core/project/backends/boxRelease.ts @@ -2,6 +2,7 @@ import { createHash } from "node:crypto"; import { chmodSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; +import { lt, valid } from "semver"; import { z } from "zod"; import { InvalidEnvironmentError } from "../../../errors/errors"; import { type ProcessRunner, runProcess } from "../../../io/exec"; @@ -41,6 +42,34 @@ export const BOX_RELEASE: BoxRelease = PINNED.box; */ export const BOX_MINIMUM_VERSION = "0.1.11-linux-preview.7"; +/** The `0.1.11-linux-preview.` line of box releases, the line {@link BOX_MINIMUM_VERSION} is in. */ +const LINUX_PREVIEW = /^0\.1\.11-linux-preview\.(\d+)$/; + +/** + * Whether box `version` is a release from before {@link BOX_MINIMUM_VERSION}, which refuses the + * `@box/` packs the CLI writes: `0.1.11-linux-preview.` below that release's N, or any + * box before 0.1.11. Releases are not ordered across prerelease lines (`mquang.preview.9` is not + * later than `linux-preview.7` by any rule they share), so a version on another line passes. + */ +export function boxPredatesPackNames(version: string): boolean { + const minimum = Number(LINUX_PREVIEW.exec(BOX_MINIMUM_VERSION)![1]); + const preview = LINUX_PREVIEW.exec(version); + if (preview) return Number(preview[1]) < minimum; + return valid(version) !== null && lt(version, "0.1.11-0"); +} + +/** + * The sentence that tells the user to move `box.version` off `version`, a box that + * {@link boxPredatesPackNames}. + */ +export function boxVersionTooOld(version: string): string { + return ( + `agentcore.json names box ${version} under box.version, a box before ${BOX_MINIMUM_VERSION} ` + + `that refuses the @box/ packs the CLI writes. Set box.version to ${BOX_RELEASE.version}, ` + + "or remove it to use that box." + ); +} + /** The GitHub release page of the pinned box, with a build for each machine it supports. */ export const BOX_RELEASE_PAGE = `https://github.com/${BOX_RELEASE.repo}/releases/tag/v${BOX_RELEASE.version}`; @@ -243,7 +272,8 @@ async function download( /** * The box release of `version`, which a runtime's `box.version` names: the pinned one, else one * in BOX_RELEASE's repository, in its layout, whose checksums come from the release's own - * SHA256SUMS.txt. No version means BOX_RELEASE. + * SHA256SUMS.txt. No version means BOX_RELEASE. Refuses a box that {@link boxPredatesPackNames}: + * it would start on AgentCore Runtime with a profile it refuses, which build cannot see. */ export async function boxReleaseFor( version: string | undefined, @@ -251,6 +281,9 @@ export async function boxReleaseFor( options: { runner?: ProcessRunner; home?: string } = {}, ): Promise { if (version === undefined || version === BOX_RELEASE.version) return BOX_RELEASE; + if (boxPredatesPackNames(version)) { + throw new InvalidEnvironmentError(`${boxVersionTooOld(version)} Then retry.`); + } const target = BOX_RELEASE.linux.target; const linux = `box-v${version}-${target}.tar.gz`; const release = { repo: BOX_RELEASE.repo, version }; diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index ab6e07c45..dfa3652d9 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -4,6 +4,7 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { InvalidEnvironmentError, ProjectStateError } from "../../errors/errors"; import { boxGatewaySpec, type ProjectSpec } from "../../projectSchemas/project"; +import { BOX_RELEASE } from "./backends/boxRelease"; import { boxNetworkFailureMessage, readBoxNetworks } from "./boxNetworkSource"; import type { BoxProfileResolver } from "./boxProfileResolver"; import { boxShowOf, FakeBoxProfileResolver } from "./boxProfileResolver-test-support"; @@ -162,11 +163,25 @@ describe("readBoxNetworks", () => { '"box/aws-secrets-manager". Box now names each pack and plugin that it ships ' + '"@box/", and it refuses the old "box/" name. In ' + '.box/agent/local/profile.toml, change "box/base" to "@box/base", "box/bedrock" to ' + - '"@box/bedrock", "box/aws-secrets-manager" to "@box/aws-secrets-manager", then build again.', + '"@box/bedrock", "box/aws-secrets-manager" to "@box/aws-secrets-manager". Then build again.', ); expect(box.calls).toEqual([]); }); + test("also says to move box.version when it names a box from before the @box/ names", async () => { + const root = await project([]); + await writeFile(join(root, ...LOCAL, "profile.toml"), 'packs = ["box/base"]\n'); + const spec = structuredClone(SPEC); + spec.runtimes[0]!.box = { version: "0.1.11-linux-preview.6" }; + + await expect(readBoxNetworks(spec, root, new FakeBoxProfileResolver())).rejects.toThrow( + 'change "box/base" to "@box/base". agentcore.json names box 0.1.11-linux-preview.6 under ' + + "box.version, a box before 0.1.11-linux-preview.7 that refuses the @box/ packs the " + + `CLI writes. Set box.version to ${BOX_RELEASE.version}, or remove it to use that box. ` + + "Then build again.", + ); + }); + test("runs box for a profile with only @box/ names and names of its own", async () => { const root = await project([]); await writeFile( diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index f8c694e1f..f8feccfd6 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -11,6 +11,7 @@ import { parse as parseToml, stringify as stringifyToml } from "smol-toml"; import type { ProjectSpec } from "../../projectSchemas/project"; import { InvalidEnvironmentError, ProjectStateError } from "../../errors/errors"; import type { PolicyFileCopy } from "./backends/boxContainer"; +import { boxPredatesPackNames, boxVersionTooOld } from "./backends/boxRelease"; import { DEFAULT_EGRESS_BEDROCK_REGION } from "../../handlers/project/shortcuts"; import { addBoxGatewayTargets, BOX_BEDROCK_POLICY_FILE, BOX_MEMORY_POLICY_FILE } from "./boxMemory"; import { @@ -69,6 +70,7 @@ export async function readBoxNetworks( runtime.name, resolver, region, + runtime.box?.version, ); const granted = grantedActions(projectRoot, entry.name, entry.additionalPolicies ?? []); const network = buildBoxNetwork(parsed, found, { @@ -113,18 +115,19 @@ export function boxPolicyFileCopies(projectRoot: string, agentName: string): Pol /** * Box's resolution of the local box profile of `agentName` for a build in `region`, parsed, with * the profile's own policy files to place its rules and to stage; nothing when the agent has no - * local box profile. + * local box profile. `boxVersion` is the runtime's `box.version`. */ async function readResolvedPolicy( projectRoot: string, agentName: string, resolver: BoxProfileResolver, region: string, + boxVersion: string | undefined, ): Promise<{ parsed: ParsedPolicy; failures: readonly BoxNetworkFailure[] }> { const profileFile = boxLocalProfileFile(agentName); const text = profileText(projectRoot, agentName); if (text === undefined) return { parsed: noPolicy(profileFile), failures: [] }; - refuseOldShippedNames(text, profileFile); + refuseOldShippedNames(text, profileFile, boxVersion); const named = profilePolicyFiles(text, profileFile); const places = profilePlaces(text, profileFile); const files = readPolicyFiles( @@ -161,9 +164,15 @@ const OLD_SHIPPED_NAME = /^box\/[^/]+$/; /** * Throws when the `packs` or `plugins` of the box profile `text` at `profileFile` name a pack or a * plugin that box ships by its old `box/` name, which box refuses. The message names each old - * name and its `@box/` name. Box reports a profile that is not TOML itself. + * name and its `@box/` name, and also says to move `boxVersion`, the runtime's `box.version`, + * when it names a box from before those names, which would refuse the renamed profile on AgentCore + * Runtime. Box reports a profile that is not TOML itself. */ -function refuseOldShippedNames(text: string, profileFile: string): void { +function refuseOldShippedNames( + text: string, + profileFile: string, + boxVersion: string | undefined, +): void { let table: Record; try { table = parseToml(text) as Record; @@ -180,10 +189,14 @@ function refuseOldShippedNames(text: string, profileFile: string): void { ]; if (old.length === 0) return; const changes = old.map((name) => `"${name}" to "@${name}"`); + const version = + boxVersion !== undefined && boxPredatesPackNames(boxVersion) + ? ` ${boxVersionTooOld(boxVersion)}` + : ""; throw new ProjectStateError( `The box profile ${profileFile} names ${old.map((name) => `"${name}"`).join(", ")}. Box now ` + 'names each pack and plugin that it ships "@box/", and it refuses the old "box/" ' + - `name. In ${profileFile}, change ${changes.join(", ")}, then build again.`, + `name. In ${profileFile}, change ${changes.join(", ")}.${version} Then build again.`, ); } diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index 5489f8e2e..f91d99e61 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -108,7 +108,7 @@ const RUNTIME_AWS_STAND_IN_LINES = [ /** * The tools of @box/base that get the project's write grant: box gives each one its own grant, so * each lists the agent's `deny_write` folders as well. Taken from @box/base in the box release that - * `boxRelease.json` pins (0.1.11-linux-preview.6). When the pin moves, check @box/base's tools: box + * `boxRelease.json` pins (0.1.11-mquang.preview.9). When the pin moves, check @box/base's tools: box * refuses a CodeZip box profile if a tool it misses gets the project write grant. */ const BOX_BASE_PROJECT_WRITE_TOOLS = ["uname"]; From 602461c3a5b08a5815f596042f58748bc2bfa2ac Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 21:00:09 -0800 Subject: [PATCH 09/11] fix(box): Ship only the pinned box Review of #2867 (vvargu): box.version must be the box that boxRelease.json pins. Before, boxReleaseFor took any other version and its checksums from that release's own SHA256SUMS.txt, so a box untested with this CLI could ship (0.1.11-linux-preview.6 refuses the @box/ packs, and build cannot see that, since it checks the profile with the box on PATH), and a changed asset matched its own published checksum. - boxReleaseFor refuses any version but BOX_RELEASE.version, naming both and saying to set box.version to the pinned one. Build, deploy and container dev all read the release through it. - The SHA256SUMS.txt lookup and its tests are gone. So are boxPredatesPackNames and the box.version sentence in the old box/ stop from e5ee285f: the pin check covers that case. - README and docs/box-local-testing.md: box.version must be the pinned version; trying an unreleased box means bumping boxRelease.json with scripts/bump-box-release.ts. New code; box-integration-development still accepts other versions. --- README.md | 5 +- docs/box-local-testing.md | 7 +- src/core/dev/container.ts | 2 +- src/core/project/backends/boxRelease.test.ts | 94 ++++--------------- src/core/project/backends/boxRelease.ts | 96 ++------------------ src/core/project/backends/cdk.ts | 6 +- src/core/project/boxNetworkSource.test.ts | 17 +--- src/core/project/boxNetworkSource.ts | 23 +---- 8 files changed, 41 insertions(+), 209 deletions(-) diff --git a/README.md b/README.md index 0770c3ef4..0b9eca24f 100644 --- a/README.md +++ b/README.md @@ -227,9 +227,8 @@ How each command uses it: with that instruction when `box` is not on your PATH. Container agents need no local box. Each box runtime names its release in `agentcore.json` with `"box": { "version": "" }`, -which `agentcore create` writes. The pinned version keeps the checksums in `boxRelease.json`; -another version takes them from its release's `SHA256SUMS.txt`. To try an unreleased box build, -publish it as a pre-release with the same file names and set `box.version` to it. +which `agentcore create` writes. It must be the pinned version, whose checksums `boxRelease.json` +keeps; build and deploy stop on any other version and say to set the pinned one. On AgentCore Runtime, box signs the agent's Bedrock and Memory calls with the execution role: the profile's bare `aws://` resolves the AWS default credential chain, which box reads and refreshes diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index 292777f27..2a65cbe75 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -30,9 +30,10 @@ only for the box templates. The runtime's entry point and Dockerfile never decid `start.py` runs the usual way. A runtime with `box.version` in a project without `"projectType": "box"` stops dev with `agentcore.json has no "projectType": "box"`. -To try an unreleased box build, publish it as a pre-release with the same file names and set -`box.version` to it: a version the CLI does not pin takes its checksums from the release's -`SHA256SUMS.txt`. +`box.version` must be the box version the CLI pins in +`src/core/project/backends/boxRelease.json`; build and deploy stop on any other version. To try an +unreleased box build, publish it as a pre-release with the same file names and run +`bun scripts/bump-box-release.ts --box ` in your CLI checkout, then set `box.version` to it. ## Prerequisites diff --git a/src/core/dev/container.ts b/src/core/dev/container.ts index 0182becf9..5640415a6 100644 --- a/src/core/dev/container.ts +++ b/src/core/dev/container.ts @@ -129,7 +129,7 @@ export class ContainerDevRunner implements DevRunner { this.toolAvailable = config.toolAvailable ?? toolAvailable; this.awsDirectory = config.awsDirectory ?? join(homedir(), ".aws"); this.processEnv = config.processEnv ?? process.env; - this.releaseFor = config.releaseFor ?? ((version) => boxReleaseFor(version, this.processEnv)); + this.releaseFor = config.releaseFor ?? boxReleaseFor; this.resolveAwsCredentials = config.resolveAwsCredentials ?? resolveDefaultAwsCredentials; } diff --git a/src/core/project/backends/boxRelease.test.ts b/src/core/project/backends/boxRelease.test.ts index 5f45d499c..09f7abbdb 100644 --- a/src/core/project/backends/boxRelease.test.ts +++ b/src/core/project/backends/boxRelease.test.ts @@ -12,7 +12,6 @@ import { BOX_RELEASE, BOX_RELEASE_PAGE, type BoxRelease, - boxPredatesPackNames, boxReleaseFor, resolveBoxLinuxBuild, } from "./boxRelease"; @@ -165,89 +164,28 @@ describe("resolveBoxLinuxBuild from the box release", () => { }); describe("boxReleaseFor a runtime's box.version", () => { - /** A runner whose curl serves SHA256SUMS.txt with `text`, and records each URL. */ - function sumsServer(text: string) { - const urls: string[] = []; - const runner: ProcessRunner = async (command) => { - urls.push(command.at(-1)!); - await writeFile(command[command.indexOf("-o") + 1]!, text); - }; - return { runner, urls }; - } - - test("is the pinned release, with no download, for no version or a pinned one", async () => { - const { runner, urls } = sumsServer(""); - - expect(await boxReleaseFor(undefined, {}, { runner })).toBe(BOX_RELEASE); - expect(await boxReleaseFor(BOX_RELEASE.version, {}, { runner })).toBe(BOX_RELEASE); - expect(urls).toEqual([]); + test("is the pinned release for no version or the pinned one", async () => { + expect(await boxReleaseFor(undefined)).toBe(BOX_RELEASE); + expect(await boxReleaseFor(BOX_RELEASE.version)).toBe(BOX_RELEASE); }); - test("takes another version's checksums from its release's SHA256SUMS.txt", async () => { - const home = await temp("box-home-"); - const linux = "a".repeat(64); - const mac = "c".repeat(64); - const { runner, urls } = sumsServer( - `${linux} box-v2.0.0-aarch64-unknown-linux-gnu.tar.gz\n` + - `${mac} box-v2.0.0-aarch64-apple-darwin.tar.gz\n`, - ); - - const release = await boxReleaseFor("2.0.0", {}, { runner, home }); - - expect(urls).toEqual([ - `https://github.com/${BOX_RELEASE.repo}/releases/download/v2.0.0/SHA256SUMS.txt`, - ]); - expect(release.version).toBe("2.0.0"); - expect(release.linux).toEqual({ - target: "aarch64-unknown-linux-gnu", - asset: "box-v2.0.0-aarch64-unknown-linux-gnu.tar.gz", - sha256: linux, - }); - }); - - test("refuses a version whose release lists no Linux box", async () => { - const home = await temp("box-home-"); - const { runner } = sumsServer(`${"c".repeat(64)} box-v2.0.0-aarch64-apple-darwin.tar.gz\n`); - - await expect(boxReleaseFor("2.0.0", {}, { runner, home })).rejects.toThrow( - /box 2\.0\.0, which agentcore\.json names under box\.version, has no box-v2\.0\.0-aarch64-unknown-linux-gnu\.tar\.gz/, - ); - }); - test("refuses a box from before the @box/ pack names, and downloads nothing", async () => { - const home = await temp("box-home-"); - const { runner, urls } = sumsServer(""); - - await expect(boxReleaseFor("0.1.11-linux-preview.6", {}, { runner, home })).rejects.toThrow( - new InvalidEnvironmentError( - "agentcore.json names box 0.1.11-linux-preview.6 under box.version, a box before " + - "0.1.11-linux-preview.7 that refuses the @box/ packs the CLI writes. Set " + - `box.version to ${BOX_RELEASE.version}, or remove it to use that box. Then retry.`, - ), - ); - expect(urls).toEqual([]); - }); -}); - -describe("boxPredatesPackNames", () => { - test.each([ - ["0.1.11-linux-preview.2", true], - ["0.1.11-linux-preview.6", true], - ["0.1.10", true], - ["0.1.11-linux-preview.7", false], - ["0.1.11-linux-preview.10", false], - ["0.1.11-mquang.preview.9", false], - ["0.1.11", false], - ["0.2.0", false], - ["not-a-version", false], - ])("%s: %p", (version, old) => { - expect(boxPredatesPackNames(version)).toBe(old); - }); + test.each(["0.1.11-linux-preview.6", "2.0.0"])( + "refuses %s, a box this CLI does not pin, and says to set the pinned one", + async (version) => { + await expect(boxReleaseFor(version)).rejects.toThrow( + new InvalidEnvironmentError( + `agentcore.json names box ${version} under box.version, but this CLI ships box ` + + `${BOX_RELEASE.version}, the one box it pins. Set box.version to ` + + `${BOX_RELEASE.version}, then retry.`, + ), + ); + }, + ); }); describe("the pinned releases", () => { - test("box is at least the first release that reads the profiles the CLI writes", () => { + test("pins one box, with the asset of its own version and a SHA-256", () => { expect(BOX_MINIMUM_VERSION).toBe("0.1.11-linux-preview.7"); - expect(boxPredatesPackNames(BOX_RELEASE.version)).toBe(false); expect(BOX_RELEASE.linux.asset).toBe( `box-v${BOX_RELEASE.version}-aarch64-unknown-linux-gnu.tar.gz`, ); diff --git a/src/core/project/backends/boxRelease.ts b/src/core/project/backends/boxRelease.ts index bfd19cb67..44006c39d 100644 --- a/src/core/project/backends/boxRelease.ts +++ b/src/core/project/backends/boxRelease.ts @@ -2,7 +2,6 @@ import { createHash } from "node:crypto"; import { chmodSync, mkdirSync, mkdtempSync, readFileSync, renameSync, rmSync } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; -import { lt, valid } from "semver"; import { z } from "zod"; import { InvalidEnvironmentError } from "../../../errors/errors"; import { type ProcessRunner, runProcess } from "../../../io/exec"; @@ -42,34 +41,6 @@ export const BOX_RELEASE: BoxRelease = PINNED.box; */ export const BOX_MINIMUM_VERSION = "0.1.11-linux-preview.7"; -/** The `0.1.11-linux-preview.` line of box releases, the line {@link BOX_MINIMUM_VERSION} is in. */ -const LINUX_PREVIEW = /^0\.1\.11-linux-preview\.(\d+)$/; - -/** - * Whether box `version` is a release from before {@link BOX_MINIMUM_VERSION}, which refuses the - * `@box/` packs the CLI writes: `0.1.11-linux-preview.` below that release's N, or any - * box before 0.1.11. Releases are not ordered across prerelease lines (`mquang.preview.9` is not - * later than `linux-preview.7` by any rule they share), so a version on another line passes. - */ -export function boxPredatesPackNames(version: string): boolean { - const minimum = Number(LINUX_PREVIEW.exec(BOX_MINIMUM_VERSION)![1]); - const preview = LINUX_PREVIEW.exec(version); - if (preview) return Number(preview[1]) < minimum; - return valid(version) !== null && lt(version, "0.1.11-0"); -} - -/** - * The sentence that tells the user to move `box.version` off `version`, a box that - * {@link boxPredatesPackNames}. - */ -export function boxVersionTooOld(version: string): string { - return ( - `agentcore.json names box ${version} under box.version, a box before ${BOX_MINIMUM_VERSION} ` + - `that refuses the @box/ packs the CLI writes. Set box.version to ${BOX_RELEASE.version}, ` + - "or remove it to use that box." - ); -} - /** The GitHub release page of the pinned box, with a build for each machine it supports. */ export const BOX_RELEASE_PAGE = `https://github.com/${BOX_RELEASE.repo}/releases/tag/v${BOX_RELEASE.version}`; @@ -270,63 +241,16 @@ async function download( } /** - * The box release of `version`, which a runtime's `box.version` names: the pinned one, else one - * in BOX_RELEASE's repository, in its layout, whose checksums come from the release's own - * SHA256SUMS.txt. No version means BOX_RELEASE. Refuses a box that {@link boxPredatesPackNames}: - * it would start on AgentCore Runtime with a profile it refuses, which build cannot see. + * The box release that `version`, a runtime's `box.version`, names. It must be the pinned one, + * BOX_RELEASE, whose checksums `boxRelease.json` pins: another box is untested with this CLI (box + * 0.1.11-linux-preview.6, for one, refuses the `@box/` packs the CLI writes), and build cannot + * see that, since it checks the profile with the box on PATH. No version means BOX_RELEASE. */ -export async function boxReleaseFor( - version: string | undefined, - env: NodeJS.ProcessEnv, - options: { runner?: ProcessRunner; home?: string } = {}, -): Promise { +export async function boxReleaseFor(version: string | undefined): Promise { if (version === undefined || version === BOX_RELEASE.version) return BOX_RELEASE; - if (boxPredatesPackNames(version)) { - throw new InvalidEnvironmentError(`${boxVersionTooOld(version)} Then retry.`); - } - const target = BOX_RELEASE.linux.target; - const linux = `box-v${version}-${target}.tar.gz`; - const release = { repo: BOX_RELEASE.repo, version }; - const sums = await releaseChecksums(release, env, options.runner ?? runProcess, options.home); - const linuxSha = sums.get(linux); - if (!linuxSha) { - throw new InvalidEnvironmentError( - `box ${version}, which agentcore.json names under box.version, has no ${linux} in the ` + - `SHA256SUMS.txt of its release at github.com/${release.repo}. Name a box version that ` + - `release has, or remove box.version to use box ${BOX_RELEASE.version}.`, - ); - } - return { ...release, linux: { target, asset: linux, sha256: linuxSha } }; -} - -/** The SHA-256 of each asset of `release`, from the SHA256SUMS.txt it publishes. */ -async function releaseChecksums( - release: Pick, - env: NodeJS.ProcessEnv, - runner: ProcessRunner, - home: string | undefined, -): Promise> { - const cache = boxCache(home ?? env.HOME ?? homedir()); - mkdirSync(cache, { recursive: true }); - const work = mkdtempSync(join(cache, ".download-")); - try { - await download( - release, - "SHA256SUMS.txt", - work, - env, - runner, - (url) => - `agentcore.json names box ${release.version} under box.version, whose checksums ` + - `download from ${url}, which failed. Check the version and your network, then retry.`, - ); - const sums = new Map(); - for (const line of readFileSync(join(work, "SHA256SUMS.txt"), "utf8").split("\n")) { - const match = /^([0-9a-f]{64})\s+\*?(\S+)$/.exec(line.trim()); - if (match) sums.set(match[2]!, match[1]!); - } - return sums; - } finally { - rmSync(work, { recursive: true, force: true }); - } + throw new InvalidEnvironmentError( + `agentcore.json names box ${version} under box.version, but this CLI ships box ` + + `${BOX_RELEASE.version}, the one box it pins. Set box.version to ${BOX_RELEASE.version}, ` + + "then retry.", + ); } diff --git a/src/core/project/backends/cdk.ts b/src/core/project/backends/cdk.ts index 183659dd7..f16d8a3bc 100644 --- a/src/core/project/backends/cdk.ts +++ b/src/core/project/backends/cdk.ts @@ -227,7 +227,7 @@ export class CdkBackend implements ProjectBackend { // the code. The box release downloads only when a CodeZip runtime runs in a box. const events: ProjectEvent[] = []; const box = async (version: string | undefined) => { - const release = await boxReleaseFor(version, this.processEnv, { runner: this.runner }); + const release = await boxReleaseFor(version); return resolveBoxLinuxBuild(this.processEnv, { runner: this.runner, release, @@ -239,9 +239,7 @@ export class CdkBackend implements ProjectBackend { }); }; await stageBoxCodeZip(project, boxNetworks, box); - await stageBoxContainers(project, boxNetworks, (version) => - boxReleaseFor(version, this.processEnv, { runner: this.runner }), - ); + await stageBoxContainers(project, boxNetworks, boxReleaseFor); return events; } diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index dfa3652d9..ab6e07c45 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -4,7 +4,6 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { InvalidEnvironmentError, ProjectStateError } from "../../errors/errors"; import { boxGatewaySpec, type ProjectSpec } from "../../projectSchemas/project"; -import { BOX_RELEASE } from "./backends/boxRelease"; import { boxNetworkFailureMessage, readBoxNetworks } from "./boxNetworkSource"; import type { BoxProfileResolver } from "./boxProfileResolver"; import { boxShowOf, FakeBoxProfileResolver } from "./boxProfileResolver-test-support"; @@ -163,25 +162,11 @@ describe("readBoxNetworks", () => { '"box/aws-secrets-manager". Box now names each pack and plugin that it ships ' + '"@box/", and it refuses the old "box/" name. In ' + '.box/agent/local/profile.toml, change "box/base" to "@box/base", "box/bedrock" to ' + - '"@box/bedrock", "box/aws-secrets-manager" to "@box/aws-secrets-manager". Then build again.', + '"@box/bedrock", "box/aws-secrets-manager" to "@box/aws-secrets-manager", then build again.', ); expect(box.calls).toEqual([]); }); - test("also says to move box.version when it names a box from before the @box/ names", async () => { - const root = await project([]); - await writeFile(join(root, ...LOCAL, "profile.toml"), 'packs = ["box/base"]\n'); - const spec = structuredClone(SPEC); - spec.runtimes[0]!.box = { version: "0.1.11-linux-preview.6" }; - - await expect(readBoxNetworks(spec, root, new FakeBoxProfileResolver())).rejects.toThrow( - 'change "box/base" to "@box/base". agentcore.json names box 0.1.11-linux-preview.6 under ' + - "box.version, a box before 0.1.11-linux-preview.7 that refuses the @box/ packs the " + - `CLI writes. Set box.version to ${BOX_RELEASE.version}, or remove it to use that box. ` + - "Then build again.", - ); - }); - test("runs box for a profile with only @box/ names and names of its own", async () => { const root = await project([]); await writeFile( diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index f8feccfd6..f8c694e1f 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -11,7 +11,6 @@ import { parse as parseToml, stringify as stringifyToml } from "smol-toml"; import type { ProjectSpec } from "../../projectSchemas/project"; import { InvalidEnvironmentError, ProjectStateError } from "../../errors/errors"; import type { PolicyFileCopy } from "./backends/boxContainer"; -import { boxPredatesPackNames, boxVersionTooOld } from "./backends/boxRelease"; import { DEFAULT_EGRESS_BEDROCK_REGION } from "../../handlers/project/shortcuts"; import { addBoxGatewayTargets, BOX_BEDROCK_POLICY_FILE, BOX_MEMORY_POLICY_FILE } from "./boxMemory"; import { @@ -70,7 +69,6 @@ export async function readBoxNetworks( runtime.name, resolver, region, - runtime.box?.version, ); const granted = grantedActions(projectRoot, entry.name, entry.additionalPolicies ?? []); const network = buildBoxNetwork(parsed, found, { @@ -115,19 +113,18 @@ export function boxPolicyFileCopies(projectRoot: string, agentName: string): Pol /** * Box's resolution of the local box profile of `agentName` for a build in `region`, parsed, with * the profile's own policy files to place its rules and to stage; nothing when the agent has no - * local box profile. `boxVersion` is the runtime's `box.version`. + * local box profile. */ async function readResolvedPolicy( projectRoot: string, agentName: string, resolver: BoxProfileResolver, region: string, - boxVersion: string | undefined, ): Promise<{ parsed: ParsedPolicy; failures: readonly BoxNetworkFailure[] }> { const profileFile = boxLocalProfileFile(agentName); const text = profileText(projectRoot, agentName); if (text === undefined) return { parsed: noPolicy(profileFile), failures: [] }; - refuseOldShippedNames(text, profileFile, boxVersion); + refuseOldShippedNames(text, profileFile); const named = profilePolicyFiles(text, profileFile); const places = profilePlaces(text, profileFile); const files = readPolicyFiles( @@ -164,15 +161,9 @@ const OLD_SHIPPED_NAME = /^box\/[^/]+$/; /** * Throws when the `packs` or `plugins` of the box profile `text` at `profileFile` name a pack or a * plugin that box ships by its old `box/` name, which box refuses. The message names each old - * name and its `@box/` name, and also says to move `boxVersion`, the runtime's `box.version`, - * when it names a box from before those names, which would refuse the renamed profile on AgentCore - * Runtime. Box reports a profile that is not TOML itself. + * name and its `@box/` name. Box reports a profile that is not TOML itself. */ -function refuseOldShippedNames( - text: string, - profileFile: string, - boxVersion: string | undefined, -): void { +function refuseOldShippedNames(text: string, profileFile: string): void { let table: Record; try { table = parseToml(text) as Record; @@ -189,14 +180,10 @@ function refuseOldShippedNames( ]; if (old.length === 0) return; const changes = old.map((name) => `"${name}" to "@${name}"`); - const version = - boxVersion !== undefined && boxPredatesPackNames(boxVersion) - ? ` ${boxVersionTooOld(boxVersion)}` - : ""; throw new ProjectStateError( `The box profile ${profileFile} names ${old.map((name) => `"${name}"`).join(", ")}. Box now ` + 'names each pack and plugin that it ships "@box/", and it refuses the old "box/" ' + - `name. In ${profileFile}, change ${changes.join(", ")}.${version} Then build again.`, + `name. In ${profileFile}, change ${changes.join(", ")}, then build again.`, ); } From f40ebce7477d501256aef4251343e73b5abfcaf8 Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 21:27:00 -0800 Subject: [PATCH 10/11] refactor(box): Drop the old box/ pack-name stop Review of #2867 (vvargu): refuseOldShippedNames only gave a fix hint for profiles an earlier CLI wrote. Box projects are new, and create writes @box/, as #2859 dropped the hint for the old .box/profile.toml layout. A profile with an old name still fails at build: box refuses it ("box/base" is not a pack name; the pack that box ships is @box/base). The resolver's hint for a box on PATH older than preview.7 stays. The README and the testing guide also say that container dev, not only build and deploy, stops on a box.version other than the pinned one (review, leo237). --- README.md | 2 +- docs/box-local-testing.md | 2 +- src/core/project/boxNetworkSource.test.ts | 37 +---------------------- src/core/project/boxNetworkSource.ts | 33 -------------------- 4 files changed, 3 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index 0b9eca24f..b3a986811 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ How each command uses it: Each box runtime names its release in `agentcore.json` with `"box": { "version": "" }`, which `agentcore create` writes. It must be the pinned version, whose checksums `boxRelease.json` -keeps; build and deploy stop on any other version and say to set the pinned one. +keeps; build, deploy and container `dev` stop on any other version and say to set the pinned one. On AgentCore Runtime, box signs the agent's Bedrock and Memory calls with the execution role: the profile's bare `aws://` resolves the AWS default credential chain, which box reads and refreshes diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index ebe411c3e..93e276f97 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -31,7 +31,7 @@ only for the box templates. The runtime's entry point and Dockerfile never decid `"projectType": "box"` stops dev with `agentcore.json has no "projectType": "box"`. `box.version` must be the box version the CLI pins in -`src/core/project/backends/boxRelease.json`; build and deploy stop on any other version. To try an +`src/core/project/backends/boxRelease.json`; build, deploy and container `dev` stop on any other version. To try an unreleased box build, publish it as a pre-release with the same file names and run `bun scripts/bump-box-release.ts --box ` in your CLI checkout, then set `box.version` to it. diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index ab6e07c45..37a0c4399 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -2,7 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test"; import { link, mkdir, mkdtemp, rm, symlink, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import { InvalidEnvironmentError, ProjectStateError } from "../../errors/errors"; +import { InvalidEnvironmentError } from "../../errors/errors"; import { boxGatewaySpec, type ProjectSpec } from "../../projectSchemas/project"; import { boxNetworkFailureMessage, readBoxNetworks } from "./boxNetworkSource"; import type { BoxProfileResolver } from "./boxProfileResolver"; @@ -145,41 +145,6 @@ describe("readBoxNetworks", () => { ).rejects.toBe(refused); }); - test("stops before box runs when the profile names a pack or a plugin that box ships by its old box/ name", async () => { - const root = await project([]); - await writeFile( - join(root, ...LOCAL, "profile.toml"), - 'packs = ["box/base", "box/bedrock", "@box/node", "team-pack", "box/base"]\n' + - 'plugins = ["box/aws-secrets-manager"]\n', - ); - const box = new FakeBoxProfileResolver(); - - const stopped = readBoxNetworks(SPEC, root, box); - - await expect(stopped).rejects.toBeInstanceOf(ProjectStateError); - await expect(stopped).rejects.toThrow( - 'The box profile .box/agent/local/profile.toml names "box/base", "box/bedrock", ' + - '"box/aws-secrets-manager". Box now names each pack and plugin that it ships ' + - '"@box/", and it refuses the old "box/" name. In ' + - '.box/agent/local/profile.toml, change "box/base" to "@box/base", "box/bedrock" to ' + - '"@box/bedrock", "box/aws-secrets-manager" to "@box/aws-secrets-manager", then build again.', - ); - expect(box.calls).toEqual([]); - }); - - test("runs box for a profile with only @box/ names and names of its own", async () => { - const root = await project([]); - await writeFile( - join(root, ...LOCAL, "profile.toml"), - 'packs = ["@box/base", "@box/bedrock", "team-pack"]\nplugins = ["@box/aws-secrets-manager"]\n', - ); - const box = new FakeBoxProfileResolver(); - - await readBoxNetworks(SPEC, root, box); - - expect(box.calls).toHaveLength(1); - }); - test("refuses a policy file Box would refuse, each at `policies`, and says how to fix it", async () => { const root = await project([ "missing.dw", diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 2252820f5..20a7b775a 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -125,7 +125,6 @@ async function readResolvedPolicy( const profileFile = boxLocalProfileFile(agentName); const text = profileText(projectRoot, agentName); if (text === undefined) return { parsed: noPolicy(profileFile), failures: [] }; - refuseOldShippedNames(text, profileFile); const named = profilePolicyFiles(text, profileFile); const places = profilePlaces(text, profileFile); const files = readPolicyFiles( @@ -157,38 +156,6 @@ async function readResolvedPolicy( }; } -/** The old name of a pack or a plugin that box ships, before box named them `@box/`. */ -const OLD_SHIPPED_NAME = /^box\/[^/]+$/; - -/** - * Throws when the `packs` or `plugins` of the box profile `text` at `profileFile` name a pack or a - * plugin that box ships by its old `box/` name, which box refuses. The message names each old - * name and its `@box/` name. Box reports a profile that is not TOML itself. - */ -function refuseOldShippedNames(text: string, profileFile: string): void { - let table: Record; - try { - table = parseToml(text) as Record; - } catch { - return; - } - const names = [table.packs, table.plugins].flatMap((list) => (Array.isArray(list) ? list : [])); - const old = [ - ...new Set( - names.filter( - (name): name is string => typeof name === "string" && OLD_SHIPPED_NAME.test(name), - ), - ), - ]; - if (old.length === 0) return; - const changes = old.map((name) => `"${name}" to "@${name}"`); - throw new ProjectStateError( - `The box profile ${profileFile} names ${old.map((name) => `"${name}"`).join(", ")}. Box now ` + - 'names each pack and plugin that it ships "@box/", and it refuses the old "box/" ' + - `name. In ${profileFile}, change ${changes.join(", ")}, then build again.`, - ); -} - /** The text of the local box profile of `agentName`, or `undefined` when the agent has none. */ function profileText(projectRoot: string, agentName: string): string | undefined { const path = boxLocalProfilePath(projectRoot, agentName); From 7f50e901a118ebd9190ed7eb9efc03be98b5e76f Mon Sep 17 00:00:00 2001 From: Quang Nguyen Date: Thu, 19 Nov 2026 23:24:32 -0800 Subject: [PATCH 11/11] style(box): Drop the unused semver import from the box release test --- src/core/project/backends/boxRelease.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/core/project/backends/boxRelease.test.ts b/src/core/project/backends/boxRelease.test.ts index d8aaadefb..913be4240 100644 --- a/src/core/project/backends/boxRelease.test.ts +++ b/src/core/project/backends/boxRelease.test.ts @@ -7,7 +7,6 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { InvalidEnvironmentError } from "../../../errors/errors"; import { type ProcessRunner, runProcess } from "../../../io/exec"; -import { gte } from "semver"; import { BOX_INSTALL_HINT, BOX_MINIMUM_VERSION,