From 35f0ffaf02642d0e21295b4558d113e1cd7bba6e Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 13:23:45 -0800 Subject: [PATCH 01/51] feat(box): Stop for .box/profile.toml, and give each local box profile the name of its runtime [aws/agentcore-cli#2859](https://github.com/aws/agentcore-cli/pull/2859) ([1405932a](https://github.com/aws/agentcore-cli/commit/1405932ae6dc5c02b16295aa98c0a1509509af7f)) keeps a box profile for each runtime in .box//{local,aws}. This commit is a cherry-pick of [1fbbc907](https://github.com/SaiAbhishek98/agentcore-cli/commit/1fbbc907c74daf55f21b470c27d987e5b96ad40f), which makes the same layout. It keeps only what 1fbbc907 does and commit keeps the words of #2859. The problems that #2859 does not stop: - Each local profile has the name of the project, and box keeps one profile of each name on a machine. Thus, after dev runs one runtime, box refuses the profile of each other runtime. - No command reads .box/profile.toml, the one profile of the earlier layout. Build and deploy give a runtime with no .box//local/profile.toml an empty profile, and say nothing about the old file. - An API key credential has the name of its [egress] entry. Two runtimes can thus give one credential two different env:// values. Then the gateway target of the second runtime sends the key of the first runtime. - docs/box-local-testing.md and the Dockerfile of the box container template name .box/profile.toml. What this commit adds: - The [profile] name of a local profile is - (boxLocalProfileName). The AgentCore Runtime profile keeps the name of the project, because each microVM runs one profile. - When a project has .box/profile.toml, build, deploy, and dev of a box runtime stop (assertNoProjectBoxProfile). The message tells the user to move the profile and its policy files into .box//local/. The CLI does not move the file. - Build and deploy stop for an [egress] entry when an earlier box runtime uses its API key credential for a different env:// variable (API_KEY_CREDENTIAL_SHARED, in readBoxNetworks). - The guide and the Dockerfile comment name .box//local/. box limits the length of a profile name, and a long HOME makes the limit less. With a HOME of 45 characters, box refused pr5demo-second (14 characters) and ran p5-second (9 characters). Tests: boxNetworkSource.test.ts "refuses a project that keeps .box/profile.toml, and runs no box" and "refuses an entry whose API key credential another runtime takes for another variable". box.test.ts "refuses a box runtime in a project that keeps .box/profile.toml" (two tests). container.test.ts "refuses a project that keeps .box/profile.toml, and stages nothing". boxProfile.test.ts "names itself after the project and the runtime". For each of these, a change that removes the check, or that names the profile after the project only, causes an error in its test. The commit also adds tests for two runtimes: each one reads, stages, and runs only its own profile (box.test.ts, container.test.ts, boxEnvLocal.test.ts, boxCodeZip.test.ts, boxContainer.test.ts, and boxNetworkSource.test.ts "reads each runtime's own local box profile and policy files, one after the other"). The tests of #2859 do not change. Co-authored-by: Varun Gunda --- docs/box-local-testing.md | 15 +-- .../Dockerfile.template | 10 +- src/core/dev/box.test.ts | 95 ++++++++++++++++++ src/core/dev/box.ts | 2 + src/core/dev/boxEnvLocal.test.ts | 22 +++++ src/core/dev/container.test.ts | 28 ++++++ src/core/dev/container.ts | 7 +- src/core/project/backends/boxCodeZip.test.ts | 78 +++++++++++---- .../project/backends/boxContainer.test.ts | 8 ++ src/core/project/boxNetworkSource.test.ts | 98 ++++++++++++++++++- src/core/project/boxNetworkSource.ts | 53 +++++++++- src/core/project/manager.tsx | 5 +- src/core/project/templates/boxProfile.test.ts | 16 ++- src/core/project/templates/boxProfile.ts | 31 +++++- 14 files changed, 427 insertions(+), 41 deletions(-) diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index 292777f27..69326a399 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -109,13 +109,15 @@ credential's egress to any host not in the list. Each entry is a `` or `:` string. The default port is 443. A port must be 1 to 65535. ``` -printf '\n[egress.github]\ndestinations = ["api.github.com"]\nsecret.ref = "env://GITHUB_TOKEN"\n' >> "$DEMO/$PROJECT/.box/profile.toml" +printf '\n[egress.github]\ndestinations = ["api.github.com"]\nsecret.ref = "env://GITHUB_TOKEN"\n' >> "$DEMO/$PROJECT/.box/agent/local/profile.toml" ``` ### What build and deploy do with the box profile -Build and deploy read `.box/profile.toml` and the policy files it lists under `policies`, and -turn them into the runtime's Box network. They change nothing in `.box/`. +Build and deploy read each runtime's own `.box//local/profile.toml` and the policy files +it lists under `policies`, and turn them into that runtime's Box network. They change nothing in +`.box//local/`; they generate the Runtime profile and its resources under +`.box//aws/`. - **Gateway targets.** Each host or `host:port` that an `[egress]` entry or a policy permit names, and that the policy allows at least one request to, gets one passthrough target on @@ -130,9 +132,10 @@ turn them into the runtime's Box network. They change nothing in `.box/`. - **Warnings.** Build warns when Box enforces rules that the gateway does not (a path, method, or forbid), when an entry's host gets no target, and when a target is signed for an AWS service that no policy of the gateway's role grants. -- **The AgentCore Runtime profile.** The staged `.box-dist/profile.toml` has one - `[egress.]` route through the gateway for each target of `-box-egress`. Each policy - file is copied beside it, byte for byte, and listed under `policies`. +- **The AgentCore Runtime profile.** The generated `.box//aws/profile.toml`, copied into + `.box-dist/`, has one `[egress.]` route through the gateway for each target of + `-box-egress`. Each policy file is copied beside it, byte for byte, and listed under + `policies`. - **No-auth targets need a newer L3.** A passthrough target with no outbound auth synthesizes only with an `@aws/agentcore-cdk` that accepts it. Until that release is pinned, use a local L3 build, as in step 5. diff --git a/src/assets/templates/agent-python-strands-box/Dockerfile.template b/src/assets/templates/agent-python-strands-box/Dockerfile.template index d74924b8b..ecdb6dee7 100644 --- a/src/assets/templates/agent-python-strands-box/Dockerfile.template +++ b/src/assets/templates/agent-python-strands-box/Dockerfile.template @@ -42,11 +42,11 @@ 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 -# 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 -# be owned by the agent and writable only by it, and outside /app; the generated pack joins box's own -# packs beside the binary. +# stage in the box dist folder; dev stages the runtime's .box//local/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 be owned by the agent and writable only by it, and outside /app; the +# generated pack joins box's own packs beside the binary. COPY --chown=bedrock_agentcore:bedrock_agentcore ${BOX_DIST}/ /home/bedrock_agentcore/box-profile/ RUN set -eu; \ if [ -d /home/bedrock_agentcore/box-profile/resources ]; then \ diff --git a/src/core/dev/box.test.ts b/src/core/dev/box.test.ts index d6432a53f..e316b59f4 100644 --- a/src/core/dev/box.test.ts +++ b/src/core/dev/box.test.ts @@ -32,6 +32,14 @@ async function temp(prefix: string): Promise { return directory; } +/** Writes the local box profile of the runtime `name`, and the venv of its app folder. */ +async function profile(projectRoot: string, name: string): Promise { + const local = join(projectRoot, ".box", name, "local"); + await mkdir(local, { recursive: true }); + await writeFile(join(local, "profile.toml"), PROFILE.replace("app/agent", `app/${name}`)); + await mkdir(join(projectRoot, "app", name, ".venv"), { recursive: true }); +} + /** A project named `Demo` that holds the agent's box profile in .box/agent/local when `profiled`. */ async function scene(profiled: boolean, boxOnPath = true) { const projectRoot = await temp("agentcore-box-project-"); @@ -94,6 +102,14 @@ function input( }; } +/** `agent`'s dev input for the runtime `second`, in app/second. */ +function secondOf(agent: DevServerInput): DevServerInput { + return { + ...agent, + runtime: { ...agent.runtime, name: "second", codeLocation: "app/second" } as ProjectRuntime, + }; +} + async function collect(events: AsyncIterable): Promise { const collected: DevEvent[] = []; for await (const event of events) collected.push(event); @@ -142,6 +158,20 @@ describe("BoxDevRunner", () => { ]); }); + test("runs each runtime with the box profile of that runtime", async () => { + const { projectRoot, calls, fallbackRuns, runner } = await scene(true); + await profile(projectRoot, "second"); + + await collect(runner.run(secondOf(input(projectRoot)))); + await collect(runner.run(input(projectRoot))); + + expect(calls.map(({ command }) => command[2])).toEqual([ + ".box/second/local/profile.toml", + ".box/agent/local/profile.toml", + ]); + expect(fallbackRuns).toEqual([]); + }); + test("hands box run the .env.local values, so it can attach the API key, and not dev's OTEL ones", async () => { const { projectRoot, calls, runner } = await scene(true); @@ -270,9 +300,74 @@ describe("BoxDevRunner", () => { expect(calls).toEqual([]); expect(fallbackRuns).toHaveLength(1); + // The profile of `agent` is not the profile of `second`, so dev says nothing about it. expect(events).toEqual([{ type: "stdout", line: "fallback" }]); }); + test("says why it runs a runtime with its own box profile but no box.version the usual way", async () => { + const { projectRoot, fallbackRuns, runner } = await scene(false); + await profile(projectRoot, "second"); + const second = secondOf(input(projectRoot, 8080, undefined, "main.py", true, /* box */ false)); + + const events = await collect(runner.run(second)); + + expect(fallbackRuns).toHaveLength(1); + expect(events).toEqual([ + { + type: "status", + message: 'Running without a box: runtime "second" has no box.version in agentcore.json', + }, + { type: "stdout", line: "fallback" }, + ]); + }); + + test("refuses a box runtime that has no box profile of its own, though another runtime has one", async () => { + const { projectRoot, calls, fallbackRuns, runner } = await scene(true); + + const run = collect(runner.run(secondOf(input(projectRoot)))); + + await expect(run).rejects.toBeInstanceOf(ResourceNotFoundError); + await expect(run).rejects.toThrow( + `but ${join(projectRoot, ".box", "second", "local", "profile.toml")} does not exist.`, + ); + expect(calls).toEqual([]); + expect(fallbackRuns).toEqual([]); + }); + + test.each([ + ["has no box profile of its own", false], + ["has its own box profile too", true], + ])( + "refuses a box runtime in a project that keeps .box/profile.toml, when it %s", + async (_label, profiled) => { + const { projectRoot, calls, fallbackRuns, runner } = await scene(profiled); + await mkdir(join(projectRoot, ".box"), { recursive: true }); + await writeFile(join(projectRoot, ".box", "profile.toml"), PROFILE); + + const run = collect(runner.run(input(projectRoot, 8080, "HTTP", "start.py"))); + + await expect(run).rejects.toBeInstanceOf(ProjectStateError); + await expect(run).rejects.toThrow( + ".box/profile.toml is the box profile of an earlier layout, and no command reads it " + + "now: each agent has its own profile, .box//local/profile.toml.", + ); + expect(calls).toEqual([]); + expect(fallbackRuns).toEqual([]); + }, + ); + + test("runs a runtime with no box.version the usual way in a project that keeps .box/profile.toml", async () => { + const { projectRoot, fallbackRuns, runner } = await scene(false); + await mkdir(join(projectRoot, ".box")); + await writeFile(join(projectRoot, ".box", "profile.toml"), PROFILE); + + await collect( + runner.run(input(projectRoot, 8080, undefined, "main.py", true, /* box */ false)), + ); + + expect(fallbackRuns).toHaveLength(1); + }); + test("tells the user to run uv sync when the runtime has no .venv", async () => { const { projectRoot, calls, runner } = await scene(true); await rm(join(projectRoot, "app", "agent", ".venv"), { recursive: true }); diff --git a/src/core/dev/box.ts b/src/core/dev/box.ts index 1bfbf4eff..c2afcaaf7 100644 --- a/src/core/dev/box.ts +++ b/src/core/dev/box.ts @@ -6,6 +6,7 @@ import { streamProcess, type ProcessStreamer } from "../../io"; import { requireTool } from "../../io/exec"; import { BOX_INSTALL_HINT } from "../project/backends/boxRelease"; import { + assertNoProjectBoxProfile, boxIngressPort, boxLocalProfileFile, boxLocalProfilePath, @@ -58,6 +59,7 @@ export class BoxDevRunner implements DevRunner { yield* this.fallback.run(input); return; } + assertNoProjectBoxProfile(input.projectRoot); if (!existsSync(profile)) { throw new ResourceNotFoundError( `runtime "${input.runtime.name}" runs its agent in a box (it has box.version in ` + diff --git a/src/core/dev/boxEnvLocal.test.ts b/src/core/dev/boxEnvLocal.test.ts index d7edcf5a1..5d243962c 100644 --- a/src/core/dev/boxEnvLocal.test.ts +++ b/src/core/dev/boxEnvLocal.test.ts @@ -29,6 +29,13 @@ async function project(profile?: string): Promise { return root; } +/** Writes `profile` as the local box profile of the runtime `agentName`. */ +async function writeProfile(root: string, agentName: string, profile: string): Promise { + const local = join(root, ".box", agentName, "local"); + await mkdir(local, { recursive: true }); + await writeFile(join(local, "profile.toml"), profile); +} + const envLocal = (root: string) => new EnvLocalFile(root).read(); describe("writeBoxDevEnvLocal", () => { @@ -82,6 +89,21 @@ describe("writeBoxDevEnvLocal", () => { expect(existsSync(new EnvLocalFile(root).path)).toBe(false); }); + test("reads only the named runtime's own box profile", async () => { + const root = await project(GITHUB_ROUTE); + await writeProfile( + root, + "second", + '[egress.docs]\ndestinations = ["docs.example.com"]\nsecret.ref = "env://DOCS_KEY"\n', + ); + const env = { GITHUB_TOKEN: "ghp_1", DOCS_KEY: "docs_1" }; + + expect(await writeBoxDevEnvLocal(root, "second", env)).toEqual([ + `writing DOCS_KEY to ${ENV_LOCAL_RELATIVE_PATH} for box egress 'docs' (env://DOCS_KEY)`, + ]); + expect(await envLocal(root)).toEqual({ DOCS_KEY: "docs_1" }); + }); + test("does nothing without a box profile", async () => { const root = await project(); diff --git a/src/core/dev/container.test.ts b/src/core/dev/container.test.ts index e00e5dd2a..64423c46d 100644 --- a/src/core/dev/container.test.ts +++ b/src/core/dev/container.test.ts @@ -860,6 +860,34 @@ describe("ContainerDevRunner", () => { expect(commandCall(calls, "run").command).not.toContain("--cap-add"); }); + test("stages the runtime's own box profile, not the profile of another runtime", async () => { + const { projectRuntime, root, context } = await boxedScene(); + await mkdir(join(root, ".box", "other", "local"), { recursive: true }); + await writeFile(join(root, ".box", "other", "local", "profile.toml"), "# other\n"); + const { runner } = harness({ processEnv: credentials }); + + await collect(runner.run(input(root, projectRuntime))); + + expect(await readFile(join(context, ".box-dist", "profile.toml"), "utf8")).toBe( + "# local profile\n", + ); + }); + + test("refuses a project that keeps .box/profile.toml, and stages nothing", async () => { + const { projectRuntime, root, context } = await boxedScene(); + await writeFile(join(root, ".box", "profile.toml"), "# earlier layout\n"); + const { calls, runner } = harness({ processEnv: credentials }); + + const run = collect(runner.run(input(root, projectRuntime))); + + await expect(run).rejects.toBeInstanceOf(ProjectStateError); + await expect(run).rejects.toThrow( + ".box/profile.toml is the box profile of an earlier layout", + ); + expect(existsSync(join(context, ".box-dist"))).toBe(false); + expect(calls.filter(({ command }) => command[1] === "build")).toEqual([]); + }); + test("stages the local profile in .box-dist/, and lets box's sandbox run", async () => { const { projectRuntime, root, context } = await boxedScene(); const { calls, runner } = harness({ processEnv: credentials }); diff --git a/src/core/dev/container.ts b/src/core/dev/container.ts index 0182becf9..53e030daa 100644 --- a/src/core/dev/container.ts +++ b/src/core/dev/container.ts @@ -27,7 +27,11 @@ import { } from "../project/backends/boxContainer"; import { boxReleaseFor, type BoxRelease } from "../project/backends/boxRelease"; import { boxPolicyFileCopies } from "../project/boxNetworkSource"; -import { boxLocalProfilePath, runsInBox } from "../project/templates/boxProfile"; +import { + assertNoProjectBoxProfile, + boxLocalProfilePath, + runsInBox, +} from "../project/templates/boxProfile"; import { BOX_DEV_AWS_REFRESH_MS, resolveDefaultAwsCredentials, @@ -343,6 +347,7 @@ export class ContainerDevRunner implements DevRunner { } return undefined; } + assertNoProjectBoxProfile(input.projectRoot); const profile = boxLocalProfilePath(input.projectRoot, input.runtime.name); if (!existsSync(profile)) { throw new ResourceNotFoundError( diff --git a/src/core/project/backends/boxCodeZip.test.ts b/src/core/project/backends/boxCodeZip.test.ts index b9c795c5a..65efe4019 100644 --- a/src/core/project/backends/boxCodeZip.test.ts +++ b/src/core/project/backends/boxCodeZip.test.ts @@ -53,29 +53,31 @@ async function linuxBuild(options: { ffi?: boolean } = {}): Promise { +async function project( + entrypoint: string, + runtimeVersion = "PYTHON_3_14", + names = ["agent"], +): Promise { const rootPath = await temp("box-project-"); - await mkdir(join(rootPath, "app", "agent"), { recursive: true }); + for (const name of names) await mkdir(join(rootPath, "app", name), { recursive: true }); return { name: "demo", rootPath, spec: { name: "demo", - runtimes: [ - { - name: "agent", - build: "CodeZip", - entrypoint, - codeLocation: "app/agent", - runtimeVersion, - modelProvider: "Bedrock", - // create writes box.version only for a box template, whose entry point is start.py. - ...(entrypoint === "start.py" && { box: { version: "1.0.0" } }), - }, - ], + runtimes: names.map((name) => ({ + name, + build: "CodeZip", + entrypoint, + codeLocation: `app/${name}`, + runtimeVersion, + modelProvider: "Bedrock", + // create writes box.version only for a box template, whose entry point is start.py. + ...(entrypoint === "start.py" && { box: { version: "1.0.0" } }), + })), memories: [], projectType: "box", - agentCoreGateways: [boxGatewaySpec("agent")], + agentCoreGateways: names.map((name) => boxGatewaySpec(name)), }, } as unknown as Project; } @@ -111,6 +113,14 @@ describe("stageBoxCodeZip", () => { expect(await readFile(join(dist, AGENTCORE_CODEZIP_PACK_PATH), "utf8")).toBe( renderAgentCoreCodeZipPack(), ); + // The runtime's .box/agent/aws/ holds a copy of what the profile writer stages, and no box. + const aws = join(demo.rootPath, ".box", "agent", "aws"); + expect(await Bun.file(join(aws, "box")).exists()).toBe(false); + for (const file of ["profile.toml", AGENTCORE_PACK_PATH, AGENTCORE_CODEZIP_PACK_PATH]) { + expect(await readFile(join(aws, file), "utf8")).toBe( + await readFile(join(dist, file), "utf8"), + ); + } }); test("asks for the box of the runtime's box.version", async () => { @@ -203,6 +213,36 @@ describe("stageBoxCodeZip", () => { ); }); + test("stages each runtime's own Runtime profile and policy files into its own code folder", async () => { + const build = await linuxBuild(); + const demo = await project("start.py", "PYTHON_3_14", ["agent", "second"]); + for (const [name, file] of [ + ["agent", "policy.dw"], + ["second", "rules.dw"], + ] as const) { + await mkdir(join(demo.rootPath, ".box", name, "local"), { recursive: true }); + await writeFile(join(demo.rootPath, ".box", name, "local", file), `// ${name}\n`); + } + const networks = [model(["policy.dw"]), model(["rules.dw"], "second")]; + + expect(await stageBoxCodeZip(demo, networks, async () => build)).toEqual(["agent", "second"]); + + for (const [name, file, other] of [ + ["agent", "policy.dw", "rules.dw"], + ["second", "rules.dw", "policy.dw"], + ] as const) { + const dist = join(demo.rootPath, "app", name, ".box-dist"); + expect(await readFile(join(dist, file), "utf8")).toBe(`// ${name}\n`); + expect(await Bun.file(join(dist, other)).exists()).toBe(false); + const profile = await readFile(join(dist, "profile.toml"), "utf8"); + expect(profile).toContain(`policies = ["${file}"]`); + expect(profile).toContain(`# The policy files of .box/${name}/local/profile.toml,`); + expect(await readFile(join(demo.rootPath, ".box", name, "aws", "profile.toml"), "utf8")).toBe( + profile, + ); + } + }); + test("stages no policy file and names none when the model has none", async () => { const build = await linuxBuild(); const demo = await project("start.py"); @@ -214,11 +254,11 @@ describe("stageBoxCodeZip", () => { }); }); -/** A model of runtime `agent` with no host and the policy files given. */ -function model(policyFiles: string[]): BoxNetwork { +/** A model of the runtime `runtime` with no host and the policy files given. */ +function model(policyFiles: string[], runtime = "agent"): BoxNetwork { return { - runtime: "agent", - gateway: "agent-box-egress", + runtime, + gateway: `${runtime}-box-egress`, region: "us-west-2", hosts: [], envRoutes: [], diff --git a/src/core/project/backends/boxContainer.test.ts b/src/core/project/backends/boxContainer.test.ts index cebdc9c34..2402413ea 100644 --- a/src/core/project/backends/boxContainer.test.ts +++ b/src/core/project/backends/boxContainer.test.ts @@ -90,6 +90,14 @@ describe("stageBoxContainers", () => { // 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()); + // The runtime's .box/agent/aws/ holds a copy of what the profile writer stages, and no box. + const aws = join(demo.rootPath, ".box", "agent", "aws"); + expect(await Bun.file(join(aws, "box-release.env")).exists()).toBe(false); + for (const file of ["profile.toml", PACK_PATH]) { + expect(await readFile(join(aws, file), "utf8")).toBe( + await readFile(join(dist, file), "utf8"), + ); + } }); test("replaces what an earlier build staged", async () => { diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index 37a0c4399..ca78717f0 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"; @@ -54,6 +54,18 @@ async function writeProfile(root: string, agentName: string, policies: string[]) ); } +/** {@link SPEC} with a box runtime and a bound Box gateway for each of `names` after `agent`. */ +function specWith(...names: string[]): ProjectSpec { + return { + ...SPEC, + runtimes: [ + ...SPEC.runtimes, + ...names.map((name) => ({ ...SPEC.runtimes[0]!, name, codeLocation: `app/${name}` })), + ], + agentCoreGateways: [boxGatewaySpec("agent"), ...names.map((name) => boxGatewaySpec(name))], + } as unknown as ProjectSpec; +} + const failuresOf = async (root: string) => (await readBoxNetworks(SPEC, root, new FakeBoxProfileResolver()))[0]!.failures.map( ({ code, reason, place }) => ({ code, reason, place }), @@ -96,6 +108,90 @@ describe("readBoxNetworks", () => { expect(network?.gateway).toBe("renamed"); }); + test("reads each runtime's own local box profile and policy files, one after the other", async () => { + const root = await project(["policy.dw"]); + await writeProfile(root, "second", ["rules.dw"]); + await writeFile(join(root, ".box", "second", "local", "rules.dw"), "// second\n"); + const egress: Record> = { + ".box/agent/local/profile.toml": API_ROUTE, + ".box/second/local/profile.toml": { docs: { destinations: ["docs.example.com"] } }, + }; + const calls: string[] = []; + const resolver: BoxProfileResolver = { + resolve: async (_root, profilePath) => { + calls.push(profilePath); + return boxShowOf({ egress: egress[profilePath] ?? {} }); + }, + }; + + const networks = await readBoxNetworks(specWith("second", "quiet"), root, resolver); + + expect(calls).toEqual([".box/agent/local/profile.toml", ".box/second/local/profile.toml"]); + expect( + networks.map(({ runtime, gateway, hosts, policyFiles }) => [ + runtime, + gateway, + hosts.map(({ authority }) => authority), + policyFiles, + ]), + ).toEqual([ + ["agent", "agent-box-egress", ["api.example.com"], ["policy.dw"]], + ["second", "second-box-egress", ["docs.example.com"], ["rules.dw"]], + ["quiet", "quiet-box-egress", [], []], + ]); + }); + + test("refuses an entry whose API key credential another runtime takes for another variable", async () => { + const root = await project([]); + const github = (variable: string, host: string) => ({ + github: { destinations: [host], secret: { ref: `env://${variable}` } }, + }); + const profiles: Record> = { + ".box/agent/local/profile.toml": github("GITHUB_TOKEN", "api.github.com"), + ".box/second/local/profile.toml": github("OTHER_TOKEN", "api.other.example.com"), + ".box/third/local/profile.toml": github("GITHUB_TOKEN", "uploads.github.com"), + }; + for (const [file, egress] of Object.entries(profiles)) { + const { destinations, secret } = egress.github; + await mkdir(join(root, file, ".."), { recursive: true }); + await writeFile( + join(root, file), + `# ${file}\n[egress.github]\ndestinations = ${JSON.stringify(destinations)}\n` + + `secret.ref = "${secret.ref}"\n`, + ); + } + const resolver: BoxProfileResolver = { + resolve: async (_root, profilePath) => boxShowOf({ egress: profiles[profilePath] }), + }; + + const networks = await readBoxNetworks(specWith("second", "third"), root, resolver); + + expect( + networks.map(({ failures }) => failures.map(({ code, place }) => [code, place])), + ).toEqual([[], [["API_KEY_CREDENTIAL_SHARED", ".box/second/local/profile.toml:2:1"]], []]); + expect(networks[1]!.failures[0]!.reason).toBe( + "[egress.github] needs the API key credential 'github' for env://OTHER_TOKEN, and runtime " + + "'agent' takes that credential for env://GITHUB_TOKEN. One credential holds one key. " + + "Rename the entry in one of the two profiles.", + ); + }); + + test("refuses a project that keeps .box/profile.toml, and runs no box", async () => { + const root = await project([]); + await writeFile(join(root, ".box", "profile.toml"), "# earlier layout\n"); + const box = new FakeBoxProfileResolver(); + + const read = readBoxNetworks(SPEC, root, box); + + await expect(read).rejects.toBeInstanceOf(ProjectStateError); + await expect(read).rejects.toThrow( + ".box/profile.toml is the box profile of an earlier layout, and no command reads it now: " + + "each agent has its own profile, .box//local/profile.toml. Move the profile and " + + "its policy files into that folder of the runtime it runs, then remove .box/profile.toml.", + ); + expect(box.calls).toEqual([]); + }); + test("places a rule of a policy file at its line, and an entry at its line in the profile", async () => { const root = await project(["policy.dw"]); await writeFile( diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 2abca9543..0e8c56737 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 { + assertNoProjectBoxProfile, boxLocalDir, boxLocalProfileFile, boxLocalProfilePath, @@ -43,7 +44,8 @@ const noPolicy = (profilePath: string): ParsedPolicy => ({ /** * The Box network model of each runtime of `spec` that runs its agent in a box, from the agent's * own local box profile as `resolver` resolves it for a build in `region`. A project with no box - * runtime resolves nothing, and an agent with no local box profile resolves no profile. + * runtime resolves nothing, and an agent with no local box profile resolves no profile. Throws for + * a project that keeps the one box profile of the earlier layout. */ export async function readBoxNetworks( spec: ProjectSpec, @@ -53,11 +55,13 @@ export async function readBoxNetworks( ): Promise { const runtimes = spec.runtimes.filter((runtime) => runtimeRunsInBox(spec, runtime)); if (runtimes.length === 0) return []; + assertNoProjectBoxProfile(projectRoot); // The model sees the targets build adds for the model and Memory calls, so no host takes a // second target for their endpoints. const withDefaults = structuredClone(spec); addBoxGatewayTargets(withDefaults, region); const networks: BoxNetwork[] = []; + const keys: SharedKeys = new Map(); for (const runtime of runtimes) { // ProjectSpecSchema requires a Box project to keep a gateway bound to each runtime. const entry = boxGatewayOf(withDefaults, runtime.name); @@ -78,11 +82,56 @@ export async function readBoxNetworks( targets: entry.targets, grantedActions: granted.actions, }); - networks.push({ ...network, warnings: [...network.warnings, ...granted.warnings] }); + networks.push({ + ...network, + warnings: [...network.warnings, ...granted.warnings], + failures: [...network.failures, ...sharedKeyFailures(network, parsed, keys)], + }); } return networks; } +/** By API key credential, the variable and the runtime of the first entry that takes it. */ +type SharedKeys = Map; + +/** + * A failure for each `[egress]` entry of `network` whose API key credential an entry of an earlier + * box runtime takes for another variable, as `keys` records them. Each runtime has its own + * profile, but agentcore.json has one credential of each name, and one credential holds one key. + */ +function sharedKeyFailures( + network: BoxNetwork, + parsed: ParsedPolicy, + keys: SharedKeys, +): BoxNetworkFailure[] { + const failures: BoxNetworkFailure[] = []; + for (const { outboundAuth: auth, sources } of network.hosts) { + if (auth.kind !== "apiKey") continue; + const holder = keys.get(auth.credentialName); + if (holder === undefined) { + keys.set(auth.credentialName, { variable: auth.variable, runtime: network.runtime }); + continue; + } + // hostTargets already refuses two entries of one profile that share a credential. + if (holder.variable === auth.variable || holder.runtime === network.runtime) continue; + const source = sources.find((candidate) => candidate.kind === "entry"); + const entry = source?.kind === "entry" ? source.egressEntry : undefined; + failures.push({ + code: "API_KEY_CREDENTIAL_SHARED", + ...(entry !== undefined && { egressEntry: entry }), + reason: + `${entry === undefined ? "An entry" : `[egress.${entry}]`} needs the API key credential ` + + `'${auth.credentialName}' for env://${auth.variable}, and runtime '${holder.runtime}' ` + + `takes that credential for env://${holder.variable}. One credential holds one key. ` + + "Rename the entry in one of the two profiles.", + place: + (entry === undefined ? undefined : parsed.profile.places?.entries.get(`egress.${entry}`)) ?? + parsed.profile.path, + }); + } + return failures; +} + /** * Each policy file the local box profile of `agentName` names, as an image's `.box-dist/` takes it * under `agentcore dev`, which stages the profile itself and not the Runtime one, runs no box diff --git a/src/core/project/manager.tsx b/src/core/project/manager.tsx index 2fcadc881..4b074b62b 100644 --- a/src/core/project/manager.tsx +++ b/src/core/project/manager.tsx @@ -2167,8 +2167,9 @@ export class FsProjectManager implements ProjectManager { /** * Writes the box profile that runs the scaffolded agent into the agent's - * `.box//local/` folder, named after the project, calling Bedrock in - * `region`. An existing profile is the user's, so it is never overwritten. + * `.box//local/` folder, named after the project and the runtime, + * calling Bedrock in `region`. An existing profile is the user's, so it is + * never overwritten. */ private async *writeBoxProfile( projectRoot: string, diff --git a/src/core/project/templates/boxProfile.test.ts b/src/core/project/templates/boxProfile.test.ts index 906a110af..871c2e6fa 100644 --- a/src/core/project/templates/boxProfile.test.ts +++ b/src/core/project/templates/boxProfile.test.ts @@ -72,7 +72,7 @@ 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"], - profile: { name: "V3Demo" }, + profile: { name: "V3Demo-agent" }, project: { access: "write" }, options: { bedrock: { region: "us-west-2" } }, agent: { @@ -86,8 +86,18 @@ describe("renderBoxProfile", () => { }); }); - test("names itself after the project, so `box run .box/agent/local/profile.toml` can load it by its path", () => { - expect(profile("agent-python-minimal").profile).toEqual({ name: "V3Demo" }); + test("names itself after the project and the runtime, so `box run .box/agent/local/profile.toml` can load it by its path", () => { + // box keeps one profile of each name on a machine, and each runtime has its own local profile. + expect(profile("agent-python-minimal").profile).toEqual({ name: "V3Demo-agent" }); + expect( + ( + parse( + renderBoxProfile("V3Demo", template("agent-python-minimal", { runtimeName: "second" }))!, + ) as { + profile: unknown; + } + ).profile, + ).toEqual({ name: "V3Demo-second" }); expect(renderBoxProfile("V3Demo", STRANDS)).toContain( "Run `box run .box/agent/local/profile.toml`", ); diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index d72610bb4..e3f4e433b 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -1,5 +1,6 @@ +import { existsSync } from "node:fs"; import { join, posix } from "node:path"; -import { InputValidationError } from "../../../errors/errors"; +import { InputValidationError, ProjectStateError } from "../../../errors/errors"; import { DEFAULT_EGRESS_BEDROCK_REGION, callsBedrockModel, @@ -158,11 +159,33 @@ export function boxLocalProfileFile(agentName: string): string { return posix.join(boxLocalDir(agentName), "profile.toml"); } +/** The `[profile] name` of an agent's local box profile: the project's name, then the agent's. */ +export function boxLocalProfileName(projectName: string, agentName: string): string { + return `${projectName}-${agentName}`; +} + /** An agent's local box profile at `projectRoot`. */ export function boxLocalProfilePath(projectRoot: string, agentName: string): string { return join(projectRoot, boxLocalProfileFile(agentName)); } +/** The one box profile of a project in the layout before each agent had its own. */ +const PROJECT_BOX_PROFILE_FILE = posix.join(BOX_ROOT, "profile.toml"); + +/** + * Throws when the project at `projectRoot` keeps `.box/profile.toml`, the one box profile of the + * earlier layout, which no command reads now. + */ +export function assertNoProjectBoxProfile(projectRoot: string): void { + if (!existsSync(join(projectRoot, ...PROJECT_BOX_PROFILE_FILE.split("/")))) return; + throw new ProjectStateError( + `${PROJECT_BOX_PROFILE_FILE} is the box profile of an earlier layout, and no command reads ` + + `it now: each agent has its own profile, ${boxLocalProfileFile("")}. Move the ` + + "profile and its policy files into that folder of the runtime it runs, then remove " + + `${PROJECT_BOX_PROFILE_FILE}.`, + ); +} + /** * Whether create writes a box profile for this runtime: a box template, CodeZip or container, * which runs its agent in Strands Box. Every other template runs its agent the usual way. @@ -489,6 +512,10 @@ export function renderBoxProfile( ...PYTHON_ENV, ...(onRuntime && runtimeRegionEnv(bedrock)), }; + // box keeps one profile of each name on a machine, so each runtime's local profile has its own. + const profileName = onRuntime + ? projectName + : boxLocalProfileName(projectName, runtime.runtimeName); // The optional sections, each empty or ending in a newline. const header = codeZipOnRuntime @@ -554,7 +581,7 @@ ${header} packs = ${packs} ${policies} [profile] -name = ${str(projectName)} +name = ${str(profileName)} ${projectSection} ${options}[agent] From 4a1e720e37c8c8b5f4f72aef18ef8dabd39348a4 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 18:45:24 -0800 Subject: [PATCH 02/51] feat(box): Stop build for a box runtime that has no local box profile Build and deploy derive the AgentCore Runtime profile of each box runtime from its .box//local/profile.toml. When that file is not there, readBoxNetworks resolves no profile, and build has nothing to derive from. Then the runtime profile writer stops with a message that names no missing file. With this change, build and deploy stop before they run box for a box runtime with no local profile. The message names the profile to create for each runtime: "runtime "" runs its agent in a box (it has box.version in agentcore.json), but .box//local/profile.toml does not exist. Create that box profile for the runtime, or remove its box.version, then retry." This part of the earlier local commit a094c5eb (branch sa-5/box-profile-per-agent-v4, worktree /Volumes/workplace/box-v3/agentcore-cli-pr5v4) stays. The rest of that commit, the box runtime that add runtime makes, is now in [aws/agentcore-cli#2859](https://github.com/aws/agentcore-cli/pull/2859). Tests: boxNetworkSource.test.ts "stops for a box runtime with no box profile of its own, and names the profile to create". The test "reads each runtime's own local box profile and policy files, one after the other" gives its third runtime a profile. --- src/core/project/boxNetworkSource.test.ts | 32 ++++++++++++++++++++--- src/core/project/boxNetworkSource.ts | 25 ++++++++++++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index ca78717f0..8f8b771d2 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -54,6 +54,12 @@ async function writeProfile(root: string, agentName: string, policies: string[]) ); } +/** Writes the local box profile of the runtime `quiet`, which has no route. */ +async function quietProfile(root: string): Promise { + await mkdir(join(root, ".box", "quiet", "local"), { recursive: true }); + await writeFile(join(root, ".box", "quiet", "local", "profile.toml"), "# quiet\n"); +} + /** {@link SPEC} with a box runtime and a bound Box gateway for each of `names` after `agent`. */ function specWith(...names: string[]): ProjectSpec { return { @@ -112,6 +118,7 @@ describe("readBoxNetworks", () => { const root = await project(["policy.dw"]); await writeProfile(root, "second", ["rules.dw"]); await writeFile(join(root, ".box", "second", "local", "rules.dw"), "// second\n"); + await quietProfile(root); const egress: Record> = { ".box/agent/local/profile.toml": API_ROUTE, ".box/second/local/profile.toml": { docs: { destinations: ["docs.example.com"] } }, @@ -126,7 +133,11 @@ describe("readBoxNetworks", () => { const networks = await readBoxNetworks(specWith("second", "quiet"), root, resolver); - expect(calls).toEqual([".box/agent/local/profile.toml", ".box/second/local/profile.toml"]); + expect(calls).toEqual([ + ".box/agent/local/profile.toml", + ".box/second/local/profile.toml", + ".box/quiet/local/profile.toml", + ]); expect( networks.map(({ runtime, gateway, hosts, policyFiles }) => [ runtime, @@ -223,13 +234,26 @@ describe("readBoxNetworks", () => { ]); }); - test("runs no box for a project that is not a Box project, or that has no box profile", async () => { + test("runs no box for a project that is not a Box project", async () => { const box = new FakeBoxProfileResolver(); const root = await project([]); expect(await readBoxNetworks({ ...SPEC, projectType: undefined }, root, box)).toEqual([]); - await rm(join(root, ...LOCAL, "profile.toml")); - expect((await readBoxNetworks(SPEC, root, box))[0]?.hosts).toEqual([]); + expect(box.calls).toEqual([]); + }); + + test("stops for a box runtime with no box profile of its own, and names the profile to create", async () => { + const box = new FakeBoxProfileResolver(); + const root = await project([]); + + const read = readBoxNetworks(specWith("second"), root, box); + + await expect(read).rejects.toBeInstanceOf(ProjectStateError); + await expect(read).rejects.toThrow( + 'runtime "second" runs its agent in a box (it has box.version in agentcore.json), but ' + + ".box/second/local/profile.toml does not exist. Create that box profile for the " + + "runtime, or remove its box.version, then retry.", + ); expect(box.calls).toEqual([]); }); diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 0e8c56737..5aad94d64 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -56,6 +56,7 @@ export async function readBoxNetworks( const runtimes = spec.runtimes.filter((runtime) => runtimeRunsInBox(spec, runtime)); if (runtimes.length === 0) return []; assertNoProjectBoxProfile(projectRoot); + assertBoxRuntimesHaveProfiles(projectRoot, runtimes); // The model sees the targets build adds for the model and Memory calls, so no host takes a // second target for their endpoints. const withDefaults = structuredClone(spec); @@ -91,6 +92,30 @@ export async function readBoxNetworks( return networks; } +/** + * Throws, naming each profile to create, when a runtime that runs its agent in a box has no local + * box profile of its own: build has nothing to derive its AgentCore Runtime profile from. + */ +function assertBoxRuntimesHaveProfiles( + projectRoot: string, + runtimes: readonly ProjectSpec["runtimes"][number][], +): void { + const missing = runtimes.filter( + ({ name }) => !existsSync(boxLocalProfilePath(projectRoot, name)), + ); + if (missing.length === 0) return; + throw new ProjectStateError( + missing + .map( + ({ name }) => + `runtime "${name}" runs its agent in a box (it has box.version in agentcore.json), but ` + + `${boxLocalProfileFile(name)} does not exist. Create that box profile for the runtime, ` + + "or remove its box.version, then retry.", + ) + .join("\n"), + ); +} + /** By API key credential, the variable and the runtime of the first entry that takes it. */ type SharedKeys = Map; From b60ff0f95f8b1c3352c5ce1e9b5fa23af7d497da Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 13:45:19 -0800 Subject: [PATCH 03/51] refactor(box): Add the frame to derive the Runtime box profile from the local profile Build makes the AgentCore Runtime profile from agentcore.json and from the Box network model. It does not read the local profile of the runtime. Thus a key of the local profile that build does not know is not on AgentCore Runtime, and build gives no message. For example, the Runtime profile has no stdio [mcp] server. This commit adds the frame of the fix, src/core/project/runtimeProfile/. It does not change the output of build. - deriveRuntimeProfile(local, context), in derive.ts, starts from the local profile and runs 4 rules in this sequence: refusals, gateway, additions, paths. Each rule gives a new table, its problems, and its warnings. A problem stops build. - types.ts has the context of a rule, the problem, and the rule. The context has the runtime, the region, the Box gateway and its targets, the hosts, the CloudWatch targets, the policy files, the paths on AgentCore Runtime, the template profiles, and the position of each key. - context.ts makes the context: runtimePaths, runtimeTemplate, and profileKeyPlaces, which finds the line of each key of a profile. - rules/refusals.ts, rules/gateway.ts, rules/additions.ts, and rules/paths.ts do not change a table in this commit. The comment of each rule tells its work, and the functions of templates/boxProfile.ts that it replaces. - serialize.ts writes a profile table as TOML, with smol-toml. - The network source keeps the text of the local profile as a TOML table, with the position of each key (ParsedProfile.source). buildBoxNetwork runs deriveRuntimeProfile on it. It adds each problem to the failures of the network, each warning to its warnings, and the profile to BoxNetwork.runtimeProfile. The runtime profile writer writes renderRuntimeBoxProfile, the same as before. - FAILURE_CODES has the 3 problem codes: RUNTIME_PATH_NOT_FOUND, RUNTIME_PROGRAM_NOT_FOUND, and RUNTIME_EGRESS_NOT_CONTAINED. Tests: runtimeProfile/derive.test.ts: the sequence of the rules, a key that no rule changes stays the same for CodeZip and for a container, the derivation changes no table that it gets, the paths, the template profiles, the position of each key, and the TOML text. boxNetworkSource.test.ts "derives the runtime's AgentCore Runtime profile from the text of its own local profile". bun test: 5369 pass, 7 skip, 0 fail. --- src/core/project/boxNetwork/network.ts | 31 ++++ src/core/project/boxNetwork/profileParser.ts | 9 + src/core/project/boxNetwork/types.ts | 2 + src/core/project/boxNetworkSource.test.ts | 14 ++ src/core/project/boxNetworkSource.ts | 26 ++- src/core/project/runtimeProfile/context.ts | 138 ++++++++++++++ .../project/runtimeProfile/derive.test.ts | 168 ++++++++++++++++++ src/core/project/runtimeProfile/derive.ts | 62 +++++++ .../project/runtimeProfile/rules/additions.ts | 19 ++ .../project/runtimeProfile/rules/gateway.ts | 15 ++ .../project/runtimeProfile/rules/paths.ts | 14 ++ .../project/runtimeProfile/rules/refusals.ts | 13 ++ src/core/project/runtimeProfile/serialize.ts | 15 ++ src/core/project/runtimeProfile/types.ts | 110 ++++++++++++ 14 files changed, 635 insertions(+), 1 deletion(-) create mode 100644 src/core/project/runtimeProfile/context.ts create mode 100644 src/core/project/runtimeProfile/derive.test.ts create mode 100644 src/core/project/runtimeProfile/derive.ts create mode 100644 src/core/project/runtimeProfile/rules/additions.ts create mode 100644 src/core/project/runtimeProfile/rules/gateway.ts create mode 100644 src/core/project/runtimeProfile/rules/paths.ts create mode 100644 src/core/project/runtimeProfile/rules/refusals.ts create mode 100644 src/core/project/runtimeProfile/serialize.ts create mode 100644 src/core/project/runtimeProfile/types.ts diff --git a/src/core/project/boxNetwork/network.ts b/src/core/project/boxNetwork/network.ts index 1f97ebc12..619940cf7 100644 --- a/src/core/project/boxNetwork/network.ts +++ b/src/core/project/boxNetwork/network.ts @@ -23,6 +23,9 @@ import { } from "./egress"; import { describeEntry, describeRule, ruleOrigin } from "./places"; import { placeOf, type ParsedPolicy } from "./policyParser"; +import { runtimeProfileContext } from "../runtimeProfile/context"; +import { deriveRuntimeProfile } from "../runtimeProfile/derive"; +import type { TomlTable } from "../runtimeProfile/types"; import { withDeployRegion, type CloudWatchTelemetry } from "./telemetry"; import { outboundAuthWords, sameOutboundAuth, targetOutboundAuth } from "./projectSpec"; import { @@ -117,6 +120,12 @@ export interface BoxNetwork { readonly policyFiles: readonly string[]; /** The CloudWatch targets of the profile's `[telemetry]`; absent means none. */ readonly telemetry?: readonly CloudWatchTelemetry[]; + /** + * The AgentCore Runtime profile that build derives from the local profile (`deriveRuntimeProfile` + * in runtimeProfile/derive.ts); absent when build has no profile text. The runtime profile writer + * still writes `renderRuntimeBoxProfile` until each rule of the derivation is in place. + */ + readonly runtimeProfile?: TomlTable; /** * The IAM actions that the gateway's `additionalPolicies` files grant its role, except the * policy files that build writes. @@ -184,6 +193,26 @@ export function buildBoxNetwork( const telemetry = parsed.profile.telemetry && withDeployRegion(parsed.profile.telemetry, project.region, parsed.profile.path); + const source = parsed.profile.source; + const derived = + source && + deriveRuntimeProfile( + source.table, + runtimeProfileContext({ + spec: project.spec, + runtime: project.runtime, + profileFile: parsed.profile.path, + region: project.region, + gateway: { name: project.gateway, targets: project.targets }, + hosts: targets.hosts, + telemetry: telemetry?.telemetry ?? [], + policyFiles: parsed.profile.policyFiles, + places: source.places, + }), + ); + failures.push( + ...(derived?.problems ?? []).map(({ code, reason, place }) => ({ code, reason, place })), + ); return { runtime: project.runtime.name, gateway: project.gateway, @@ -192,6 +221,7 @@ export function buildBoxNetwork( envRoutes: envRoutesOf(targets.hosts), policyFiles: parsed.profile.policyFiles, ...(telemetry && { telemetry: telemetry.telemetry }), + ...(derived && { runtimeProfile: derived.profile }), grantedActions: project.grantedActions, warnings: [ ...hostWarnings(targets.hosts), @@ -203,6 +233,7 @@ export function buildBoxNetwork( ); }), ...(telemetry?.warnings ?? []), + ...(derived?.warnings ?? []), ], failures, }; diff --git a/src/core/project/boxNetwork/profileParser.ts b/src/core/project/boxNetwork/profileParser.ts index 44eb55916..8b8576d73 100644 --- a/src/core/project/boxNetwork/profileParser.ts +++ b/src/core/project/boxNetwork/profileParser.ts @@ -7,6 +7,7 @@ import { posix } from "node:path"; import { parse as parseToml } from "smol-toml"; import type { ResolvedBoxProfile } from "../boxProfileResolver"; +import type { TomlTable } from "../runtimeProfile/types"; import { cloudWatchTelemetry, type ProfileCloudWatchTelemetry } from "./telemetry"; /** Where the profile's own text sets a key, as `:line:column`. */ @@ -29,6 +30,14 @@ export interface ParsedProfile { readonly telemetry?: readonly ProfileCloudWatchTelemetry[]; /** Where the profile's own text sets each entry; absent when build has no profile text. */ readonly places?: ProfilePlaces; + /** + * The profile's own text as a TOML table, which build derives the AgentCore Runtime profile from, + * and where the text sets each key, by its dotted path; absent when build has no profile text. + */ + readonly source?: { + readonly table: Readonly; + readonly places: ReadonlyMap; + }; } /** A failure of the profile, or of Box's resolution of it, at its line when one is known. */ diff --git a/src/core/project/boxNetwork/types.ts b/src/core/project/boxNetwork/types.ts index d4a881f5a..f9d8ad25f 100644 --- a/src/core/project/boxNetwork/types.ts +++ b/src/core/project/boxNetwork/types.ts @@ -1,3 +1,4 @@ +import { RUNTIME_PROFILE_PROBLEM_CODES } from "../runtimeProfile/types"; import type { SourceSpan } from "./dogwood"; /** AgentCore's limit on the targets of one gateway. */ @@ -44,6 +45,7 @@ export const FAILURE_CODES = [ "TARGET_NAME_INVALID", "TARGET_NAME_COLLISION", "TOO_MANY_TARGETS", + ...RUNTIME_PROFILE_PROBLEM_CODES, ] as const; export type FailureCode = (typeof FAILURE_CODES)[number]; diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index 8f8b771d2..904c9e246 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -95,6 +95,20 @@ describe("readBoxNetworks", () => { expect(network?.hosts.map(({ target }) => target)).toEqual(["egress-api"]); }); + test("derives the runtime's AgentCore Runtime profile from the text of its own local profile", async () => { + const root = await project([]); + await writeFile( + join(root, ...LOCAL, "profile.toml"), + '[limits]\nshell = { timeout = 30 }\n\n[project]\naccess = "read"\n', + ); + + const [network] = await readBoxNetworks(SPEC, root, new FakeBoxProfileResolver()); + + // A key that no rule of the derivation changes reaches the Runtime profile as it is. + expect(network?.runtimeProfile?.limits).toEqual({ shell: { timeout: 30 } }); + expect(network?.runtimeProfile?.project).toEqual({ access: "read" }); + }); + test("finds each runtime's Box gateway by boundRuntime, whatever its name", async () => { const root = await project([]); const spec = { diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 5aad94d64..ec7a1eb1c 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -33,6 +33,8 @@ import { type PolicyFileText, } from "./boxNetwork"; import type { BoxProfileResolver, ResolvedBoxProfile } from "./boxProfileResolver"; +import { profileKeyPlaces } from "./runtimeProfile/context"; +import type { TomlTable } from "./runtimeProfile/types"; /** The policy of an agent that has no local box profile at `profilePath`. */ const noPolicy = (profilePath: string): ParsedPolicy => ({ @@ -215,7 +217,12 @@ async function readResolvedPolicy( ? await resolver.resolve(projectRoot, profileFile) : await resolveCopy(projectRoot, agentName, resolver, forRegion, files.texts); const profile = parseResolvedProfile(resolved, named.ok ? named.files : [], profileFile); - const policy = parseResolvedPolicy({ ...profile.profile, places }, resolved.policy, files.texts); + const source = profileSource(text, profileFile); + const policy = parseResolvedPolicy( + { ...profile.profile, places, ...(source && { source }) }, + resolved.policy, + files.texts, + ); return { parsed: policy.parsed, failures: [ @@ -227,6 +234,23 @@ async function readResolvedPolicy( }; } +/** + * The box profile `text` at `profileFile` as a TOML table, with where it sets each key, or + * `undefined` when it is not TOML; the profile parser stops build for that. + */ +function profileSource(text: string, profileFile: string): ParsedProfileSource | undefined { + try { + return { + table: parseToml(text) as TomlTable, + places: profileKeyPlaces(text, profileFile), + }; + } catch { + return undefined; + } +} + +type ParsedProfileSource = NonNullable; + /** 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); diff --git a/src/core/project/runtimeProfile/context.ts b/src/core/project/runtimeProfile/context.ts new file mode 100644 index 000000000..dafb65878 --- /dev/null +++ b/src/core/project/runtimeProfile/context.ts @@ -0,0 +1,138 @@ +/** + * What the derivation of the AgentCore Runtime box profile knows of a runtime: its paths there, the + * profile `agentcore create` writes for it, and where the local profile sets each key. + */ +import { posix } from "node:path"; +import { parse as parseToml } from "smol-toml"; +import type { ScaffoldRuntimeInput } from "../../../handlers/project/types"; +import type { ProjectRuntime } from "../../../projectSchemas/runtime"; +import { renderBoxProfile } from "../templates/boxProfile"; +import { + RUNTIME_INPUTS, + type RuntimePaths, + type RuntimeProfileContext, + type TomlTable, +} from "./types"; + +const WORKSPACE = "${{ workspace }}"; +const HOME = "${{ home }}"; + +/** + * Where the paths of the local profile of `runtime` are on AgentCore Runtime. A container image runs + * the profile in /app, its workspace, under `agentcore dev` and on the Runtime alike, so each path + * stays. A CodeZip runtime runs it in the project folder under `agentcore dev`. + */ +export function runtimePaths( + runtime: Pick, +): RuntimePaths { + if (runtime.build !== "CodeZip") { + return { + build: "Container", + localCode: WORKSPACE, + localVenv: `${WORKSPACE}/.venv`, + localPythons: "/usr/local", + runtimeCode: WORKSPACE, + runtimePython: `${WORKSPACE}/.venv/bin/python`, + runtimePythonPrefix: "/usr/local", + shownCode: "/app/", + }; + } + const folder = posix + .normalize(runtime.codeLocation.replace(/\\/g, "/")) + .replace(/^\.\/|\/+$/g, ""); + const root = folder === "." || folder === ""; + const localCode = root ? WORKSPACE : `${WORKSPACE}/${folder}`; + return { + build: "CodeZip", + localCode, + localVenv: `${localCode}/.venv`, + localPythons: `${HOME}/.local/share/uv/python`, + runtimeCode: RUNTIME_INPUTS.codeDir, + runtimePython: RUNTIME_INPUTS.pythonPath, + runtimePythonPrefix: RUNTIME_INPUTS.pythonPrefix, + shownCode: root ? "./" : `${folder}/`, + }; +} + +/** + * The profile that `agentcore create` writes for `runtime`, `local`, and its Runtime form with no + * route, `runtime`, as TOML tables. agentcore.json does not record the framework, and the profile + * does not depend on it beyond the container case, as in renderRuntimeBoxProfile. + */ +export function runtimeTemplate( + projectName: string, + runtime: ProjectRuntime, + region: string, + policyFiles: readonly string[], +): { local: TomlTable; runtime: TomlTable } { + const input = { + runtimeName: runtime.name, + build: runtime.build, + language: "Python", + framework: "strands", + protocol: runtime.protocol, + modelProvider: runtime.modelProvider, + modelId: runtime.modelId, + boxTemplate: true, + } as ScaffoldRuntimeInput; + const table = (target: "local" | "runtime") => + parseToml( + renderBoxProfile(projectName, input, region, target, "", policyFiles) ?? "", + ) as TomlTable; + return { local: table("local"), runtime: table("runtime") }; +} + +/** + * Where the box profile `text`, at `profileFile` from the project root, sets each key: the first + * line of each table header and each key, by the dotted path of the key (`mcp.notes.command`). + */ +export function profileKeyPlaces(text: string, profileFile: string): Map { + const places = new Map(); + let table: string[] = []; + text.split("\n").forEach((line, index) => { + const place = `${profileFile}:${index + 1}:${line.search(/\S/) + 1}`; + const header = /^\s*\[\[?([^\]]*)\]\]?\s*(?:#.*)?$/.exec(line); + const assignment = header ? undefined : /^\s*([^\s=#[][^=]*?)\s*=/.exec(line); + if (!header && !assignment) return; + const path = header ? keyPath(header[1]!) : [...table, ...keyPath(assignment![1]!)]; + if (header) table = path; + for (let depth = 1; depth <= path.length; depth++) { + const key = path.slice(0, depth).join("."); + if (!places.has(key)) places.set(key, place); + } + }); + return places; +} + +/** The parts of a TOML key: `egress."dot.name".secret` as `["egress", "dot.name", "secret"]`. */ +function keyPath(text: string): string[] { + const parts: string[] = []; + const part = /\s*(?:"((?:[^"\\]|\\.)*)"|'([^']*)'|([A-Za-z0-9_-]+))\s*(?:\.|$)/y; + let match: RegExpExecArray | null; + while (part.lastIndex < text.length && (match = part.exec(text)) !== null) { + parts.push(match[1] ?? match[2] ?? match[3]!); + } + return parts; +} + +/** The context of the derivation for one runtime, from what the Box network model knows. */ +export function runtimeProfileContext( + input: Omit & { + /** Where the local profile sets each key: {@link profileKeyPlaces}. */ + readonly places: ReadonlyMap; + }, +): RuntimeProfileContext { + const { places, ...rest } = input; + return { + ...rest, + paths: runtimePaths(input.runtime), + template: runtimeTemplate(input.spec.name, input.runtime, input.region, input.policyFiles), + placeOf: (key) => { + for (let depth = key.length; depth > 0; depth--) { + const place = places.get(key.slice(0, depth).join(".")); + if (place !== undefined) return place; + } + return input.profileFile; + }, + }; +} diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts new file mode 100644 index 000000000..7d2261c4b --- /dev/null +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -0,0 +1,168 @@ +import { describe, expect, test } from "bun:test"; +import { parse } from "smol-toml"; +import type { ProjectSpec } from "../../../projectSchemas/project"; +import type { ProjectRuntime } from "../../../projectSchemas/runtime"; +import { profileKeyPlaces, runtimePaths, runtimeProfileContext, runtimeTemplate } from "./context"; +import { deriveRuntimeProfile, keyLabel, RUNTIME_PROFILE_RULES } from "./derive"; +import { serializeRuntimeProfile } from "./serialize"; +import type { TomlTable } from "./types"; + +const CODEZIP = { + name: "agent", + build: "CodeZip", + entrypoint: "start.py", + codeLocation: "app/agent", + protocol: "HTTP", + modelProvider: "Bedrock", + box: { version: "1.0.0" }, +} as ProjectRuntime; +const CONTAINER = { ...CODEZIP, build: "Container", entrypoint: "main.py" } as ProjectRuntime; +const SPEC = { name: "demo", runtimes: [CODEZIP] } as unknown as ProjectSpec; + +const context = (runtime: ProjectRuntime, places = new Map()) => + runtimeProfileContext({ + spec: SPEC, + runtime, + profileFile: ".box/agent/local/profile.toml", + region: "us-west-2", + gateway: { name: "agent-box-egress", targets: [] }, + hosts: [], + telemetry: [], + policyFiles: [], + places, + }); + +/** The keys of a profile that no rule of the derivation changes, as box 0.1.11-linux-preview.6 takes them. */ +const CARRIED: TomlTable = { + "agent-args": ["--verbose"], + "file-attributes": true, + limits: { shell: { timeout: 30 } }, + "experimental-features": { "native-filesystem-policy": true }, + project: { access: "read" }, +}; + +describe("deriveRuntimeProfile", () => { + test("runs the rules in their order: refusals, gateway, additions, then paths", () => { + expect(RUNTIME_PROFILE_RULES.map(({ name }) => name)).toEqual([ + "refusals", + "gateway", + "additions", + "paths", + ]); + }); + + test.each([CODEZIP, CONTAINER])( + "carries each key that no rule changes as the local profile has it ($build)", + (runtime) => { + const local = { packs: ["box/base"], ...CARRIED, agent: { command: ["/bin/echo"] } }; + + const { profile, problems } = deriveRuntimeProfile(local, context(runtime)); + + expect(problems).toEqual([]); + for (const [key, value] of Object.entries(CARRIED)) expect(profile[key]).toEqual(value); + }, + ); + + test("changes no table it gets", () => { + const local = structuredClone({ + ...CARRIED, + mcp: { notes: { type: "stdio", command: ["x"] } }, + }); + const frozen = structuredClone(local); + + deriveRuntimeProfile(local, context(CODEZIP)); + + expect(local).toEqual(frozen); + }); +}); + +describe("runtimePaths", () => { + test("moves a CodeZip runtime's code and Python to the inputs of box/agentcore-codezip", () => { + expect(runtimePaths(CODEZIP)).toEqual({ + build: "CodeZip", + localCode: "${{ workspace }}/app/agent", + localVenv: "${{ workspace }}/app/agent/.venv", + localPythons: "${{ home }}/.local/share/uv/python", + runtimeCode: "${{ inputs.code.dir }}", + runtimePython: "${{ inputs.python.path }}", + runtimePythonPrefix: "${{ inputs.python.prefix }}", + shownCode: "app/agent/", + }); + expect( + runtimePaths({ ...CODEZIP, codeLocation: "./app/agent/" } as ProjectRuntime).localCode, + ).toBe("${{ workspace }}/app/agent"); + }); + + test("keeps each path of a container image, which runs in /app under dev and on the Runtime", () => { + const paths = runtimePaths(CONTAINER); + + expect(paths.runtimeCode).toBe(paths.localCode); + expect(paths.runtimePython).toBe("${{ workspace }}/.venv/bin/python"); + }); +}); + +describe("runtimeTemplate", () => { + test("gives the profile create writes and its Runtime form, as tables", () => { + const { local, runtime } = runtimeTemplate("demo", CODEZIP, "us-west-2", []); + + expect((local.agent as { command: string[] }).command).toContain("--reload"); + expect((runtime.agent as { command: string[] }).command[0]).toBe("${{ inputs.python.path }}"); + expect(runtime.packs).toContain("box/agentcore-codezip"); + }); +}); + +describe("profileKeyPlaces", () => { + test("places each table, each key, and each dotted key at its first line", () => { + const text = [ + 'packs = ["box/base"]', + 'egress.github.destinations = ["api.github.com"]', + "", + "[mcp.notes]", + 'type = "stdio"', + 'command = ["x"]', + "[mcp.notes.filesystem]", + ' read = ["y"]', + ].join("\n"); + + const places = profileKeyPlaces(text, "p.toml"); + + expect(places.get("packs")).toBe("p.toml:1:1"); + expect(places.get("egress.github")).toBe("p.toml:2:1"); + expect(places.get("egress.github.destinations")).toBe("p.toml:2:1"); + expect(places.get("mcp.notes")).toBe("p.toml:4:1"); + expect(places.get("mcp.notes.command")).toBe("p.toml:6:1"); + expect(places.get("mcp.notes.filesystem.read")).toBe("p.toml:8:3"); + }); + + test("gives a rule the place of the key, of its nearest table, or the profile file", () => { + const { placeOf } = context( + CODEZIP, + new Map([ + ["mcp.notes", "p.toml:3:1"], + ["mcp.notes.command", "p.toml:5:1"], + ]), + ); + + expect(placeOf(["mcp", "notes", "command"])).toBe("p.toml:5:1"); + expect(placeOf(["mcp", "notes", "env", "A"])).toBe("p.toml:3:1"); + expect(placeOf(["tool", "x"])).toBe(".box/agent/local/profile.toml"); + }); +}); + +describe("keyLabel", () => { + test("names a key as a message does", () => { + expect(keyLabel(["packs"])).toBe("packs"); + expect(keyLabel(["mcp", "notes", "command"])).toBe("[mcp.notes] command"); + }); +}); + +describe("serializeRuntimeProfile", () => { + test("writes the profile as TOML after its header comments", () => { + const profile = { packs: ["box/base"], ...CARRIED, mcp: { notes: { type: "stdio" } } }; + + const text = serializeRuntimeProfile(profile, ["Rendered by agentcore build."]); + + expect(text.startsWith("# Rendered by agentcore build.\n")).toBe(true); + expect(parse(text)).toEqual(profile); + }); +}); diff --git a/src/core/project/runtimeProfile/derive.ts b/src/core/project/runtimeProfile/derive.ts new file mode 100644 index 000000000..5bc6957f9 --- /dev/null +++ b/src/core/project/runtimeProfile/derive.ts @@ -0,0 +1,62 @@ +/** + * The AgentCore Runtime box profile of a runtime, derived from its local box profile, + * `.box//local/profile.toml`. Each key of the local profile goes to the Runtime profile, + * and each rule changes only what must be different on AgentCore Runtime. A key that cannot work + * there, and that no rule can map, is a problem, and build stops for it. + * + * | Rule | What it does | + * | --- | --- | + * | `refusals` | stops for a key that cannot work on the Runtime whatever its paths are | + * | `gateway` | sends each call of the box through the runtime's Box gateway | + * | `additions` | adds what only the Runtime needs, and replaces each value that works only under dev | + * | `paths` | moves each path of the project to where the code is on the Runtime | + */ +import * as additions from "./rules/additions"; +import * as gateway from "./rules/gateway"; +import * as paths from "./rules/paths"; +import * as refusals from "./rules/refusals"; +import type { + RuntimeProfileContext, + RuntimeProfileProblem, + RuntimeProfileRule, + TomlTable, +} from "./types"; + +/** + * The rules, in the order they run. `refusals` reads the local profile as the user wrote it. + * `gateway` and `additions` write Runtime values, which name only the Runtime's inputs. `paths` + * runs last, so it moves each path that the user's own keys name, and no Runtime value. + */ +export const RUNTIME_PROFILE_RULES: readonly { + readonly name: string; + readonly apply: RuntimeProfileRule; +}[] = [ + { name: "refusals", apply: refusals.apply }, + { name: "gateway", apply: gateway.apply }, + { name: "additions", apply: additions.apply }, + { name: "paths", apply: paths.apply }, +]; + +/** The Runtime profile of the local profile `local`, with each problem and warning of each rule. */ +export function deriveRuntimeProfile( + local: Readonly, + context: RuntimeProfileContext, +): { profile: TomlTable; problems: RuntimeProfileProblem[]; warnings: string[] } { + let profile: TomlTable = structuredClone(local) as TomlTable; + const problems: RuntimeProfileProblem[] = []; + const warnings: string[] = []; + for (const rule of RUNTIME_PROFILE_RULES) { + const result = rule.apply(profile, context); + profile = result.table; + problems.push(...result.problems); + warnings.push(...result.warnings); + } + return { profile, problems, warnings }; +} + +/** A key as a message names it: `[mcp.notes] command`, `[agent.filesystem] read`, `packs`. */ +export function keyLabel(key: readonly string[]): string { + if (key.length === 1) return key[0]!; + const table = key.slice(0, -1).join("."); + return `[${table}] ${key[key.length - 1]}`; +} diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts new file mode 100644 index 000000000..4d166588d --- /dev/null +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -0,0 +1,19 @@ +/** + * Rule 3 of the derivation: what only AgentCore Runtime needs, and the Runtime value of each + * setting that works only under `agentcore dev`. To do: `[profile] name` is the project's name; + * `packs` adds box/agentcore, and box/agentcore-codezip for CodeZip; `[options] bedrock.region` is + * the build region; `policies` names the policy files that staging copies; in `[agent]`, each value + * that is the template's own (`context.template.local`) becomes the template's Runtime value + * (`context.template.runtime`): the command with no `--reload`, the env with no `LOCAL_DEV` and with + * the region, the AWS stand-ins and the ffi `PYTHONPATH`, the filesystem grants, and the ingress on + * 0.0.0.0, and each value of the user's own stays; each CloudWatch `[telemetry.]` is signed + * with a bare `aws://` in the deploy region. It absorbs, from templates/boxProfile.ts: the Runtime + * branch of renderBoxProfile (runtimeCodeZipRunner, containerRunner with dev false, + * runtimeRegionEnv, RUNTIME_AWS_STAND_IN_LINES, the packs, the header, the name, the options, the + * ingress) and runtimeTelemetrySection. + */ +import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; + +export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { + return { table: { ...table }, problems: [], warnings: [] }; +} diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts new file mode 100644 index 000000000..37dd3c07e --- /dev/null +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -0,0 +1,15 @@ +/** + * Rule 2 of the derivation: the calls of the box go through its Box gateway on AgentCore Runtime. + * To do: replace each `[egress.]` whose host gets a gateway target with one + * `[egress.]` route for each target, with one backend to `${{ inputs.gateway.url }}/` + * signed with a bare `aws://` for the gateway region, and no secret (the target sends it); add the + * routes of the targets build adds (`bedrock`, `agentcore`, permit-only hosts); give each HTTP + * `[mcp.]` its gateway backend and keep its `env://` secret. It absorbs, from + * templates/boxProfile.ts: runtimeGatewayRoutes, runtimeGatewayRouteSection, + * runtimeMcpServerSection, runtimeMcpServers, and runtimeGatewayBackend. + */ +import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; + +export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { + return { table: { ...table }, problems: [], warnings: [] }; +} diff --git a/src/core/project/runtimeProfile/rules/paths.ts b/src/core/project/runtimeProfile/rules/paths.ts new file mode 100644 index 000000000..821ff6c10 --- /dev/null +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -0,0 +1,14 @@ +/** + * Rule 4 of the derivation, the last: each path of the project or the home folder, in every table, + * where it is on AgentCore Runtime (`context.paths`). A container image keeps each path. On CodeZip, + * the venv's Python goes to `${{ inputs.python.path }}`, the venv and the code folder to + * `${{ inputs.code.dir }}`, and the uv Pythons to `${{ inputs.python.prefix }}`, as the agent + * command moves today in runtimeCodeZipRunner (templates/boxProfile.ts). To do: a path of the + * project outside the code folder, a path in the home folder, or a path in the venv has no place + * there (RUNTIME_PATH_NOT_FOUND); and one grant for each path where two move to one. + */ +import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; + +export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { + return { table: { ...table }, problems: [], warnings: [] }; +} diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts new file mode 100644 index 000000000..981704817 --- /dev/null +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -0,0 +1,13 @@ +/** + * Rule 1 of the derivation: the keys of the local profile that cannot work on AgentCore Runtime + * whatever their paths are. To do: a stdio `[mcp.]` or a `[tool.]` with + * `network.contain_egress = false` (RUNTIME_EGRESS_NOT_CONTAINED); on a CodeZip runtime, a stdio + * server or tool program that is not the venv's Python or a file in the code folder + * (RUNTIME_PROGRAM_NOT_FOUND); and each `[telemetry.]` that is not CloudWatch, which it + * removes with a warning, as `cloudWatchTelemetry` in boxNetwork/telemetry.ts leaves it out today. + */ +import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; + +export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { + return { table: { ...table }, problems: [], warnings: [] }; +} diff --git a/src/core/project/runtimeProfile/serialize.ts b/src/core/project/runtimeProfile/serialize.ts new file mode 100644 index 000000000..cb08b694b --- /dev/null +++ b/src/core/project/runtimeProfile/serialize.ts @@ -0,0 +1,15 @@ +/** + * The text of a derived AgentCore Runtime box profile: a header comment, then the profile as TOML. + * smol-toml writes each key, and the profile's own key order stays. + */ +import { stringify } from "smol-toml"; +import type { TomlTable } from "./types"; + +/** The text of `profile`, after the comment lines of `header`. */ +export function serializeRuntimeProfile( + profile: Readonly, + header: readonly string[] = [], +): string { + const comments = header.map((line) => `# ${line}\n`).join(""); + return `${comments}${stringify(profile)}\n`; +} diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts new file mode 100644 index 000000000..e6aa8673f --- /dev/null +++ b/src/core/project/runtimeProfile/types.ts @@ -0,0 +1,110 @@ +/** + * The shared types of the AgentCore Runtime box profile that build derives from a runtime's local + * box profile. The local profile goes in as a TOML table. Each rule changes only what must be + * different on AgentCore Runtime, and keeps every other key. A problem stops build. + */ +import type { AgentCoreGatewayTarget } from "../../../projectSchemas/gateway"; +import type { ProjectSpec } from "../../../projectSchemas/project"; +import type { ProjectRuntime } from "../../../projectSchemas/runtime"; +import type { BoxNetworkHost, CloudWatchTelemetry } from "../boxNetwork"; + +/** A TOML table as smol-toml parses it: a key holds a string, a number, a boolean, a list, or a table. */ +export type TomlTable = Record; + +/** The inputs that the generated packs fill in on AgentCore Runtime, as a profile names them. */ +export const RUNTIME_INPUTS = { + /** The runtime's Box gateway URL (box/agentcore). */ + gatewayUrl: "${{ inputs.gateway.url }}", + /** The Runtime's region (box/agentcore). */ + awsRegion: "${{ inputs.aws.region }}", + /** The unpacked zip of a CodeZip runtime (box/agentcore-codezip). */ + codeDir: "${{ inputs.code.dir }}", + /** The Python of a CodeZip Runtime (box/agentcore-codezip). */ + pythonPath: "${{ inputs.python.path }}", + /** The base prefix of that Python (box/agentcore-codezip). */ + pythonPrefix: "${{ inputs.python.prefix }}", +} as const; + +/** + * Where a path of the local profile is on AgentCore Runtime. A container image runs the same paths + * under `agentcore dev` and on the Runtime. A CodeZip zip holds only the code folder, and the + * Runtime runs its own Python. + */ +export interface RuntimePaths { + readonly build: "CodeZip" | "Container"; + /** The code folder, as the local profile names it: `${{ workspace }}/`. */ + readonly localCode: string; + /** The venv of the code folder, as the local profile names it. */ + readonly localVenv: string; + /** The uv-managed Pythons that the local profile grants: `${{ home }}/.local/share/uv/python`. */ + readonly localPythons: string; + /** The code folder on the Runtime: `${{ inputs.code.dir }}` (CodeZip), `${{ workspace }}` (image). */ + readonly runtimeCode: string; + /** The Python on the Runtime, for the venv's Python: `${{ inputs.python.path }}` on CodeZip. */ + readonly runtimePython: string; + /** The prefix of that Python, for the uv Pythons: `${{ inputs.python.prefix }}` on CodeZip. */ + readonly runtimePythonPrefix: string; + /** The code folder as a message names it: `app/agent/`. */ + readonly shownCode: string; +} + +/** What a rule knows of the runtime besides the local profile. */ +export interface RuntimeProfileContext { + readonly spec: ProjectSpec; + readonly runtime: ProjectRuntime; + /** The local profile's path from the project root: `.box//local/profile.toml`. */ + readonly profileFile: string; + /** The region build builds for: of the Box gateway and its `bedrock` and `agentcore` targets. */ + readonly region: string; + /** The runtime's Box gateway: its name, and its targets with the ones build adds. */ + readonly gateway: { readonly name: string; readonly targets: readonly AgentCoreGatewayTarget[] }; + /** The hosts of the Box network model, each with the gateway target it gets. */ + readonly hosts: readonly BoxNetworkHost[]; + /** The CloudWatch targets of the local profile, with the deploy region set. */ + readonly telemetry: readonly CloudWatchTelemetry[]; + /** The local profile's policy files, from its folder, which staging copies beside it. */ + readonly policyFiles: readonly string[]; + readonly paths: RuntimePaths; + /** + * The profile that `agentcore create` writes for this runtime, `local`, and its Runtime form, + * `runtime`, with no route: a rule tells the template's own values from the user's by them. + */ + readonly template: { readonly local: TomlTable; readonly runtime: TomlTable }; + /** Where the local profile sets `key`, as `file:line:column`, or the profile file. */ + readonly placeOf: (key: readonly string[]) => string; +} + +/** Why a key of the local profile cannot go to AgentCore Runtime. */ +export const RUNTIME_PROFILE_PROBLEM_CODES = [ + /** A path of the project or the home folder that is not on the Runtime. */ + "RUNTIME_PATH_NOT_FOUND", + /** A program that build cannot find on the Runtime. */ + "RUNTIME_PROGRAM_NOT_FOUND", + /** A process whose calls on the Runtime would not go through the Box gateway. */ + "RUNTIME_EGRESS_NOT_CONTAINED", +] as const; +export type RuntimeProfileProblemCode = (typeof RUNTIME_PROFILE_PROBLEM_CODES)[number]; + +/** A key of the local profile that cannot go to AgentCore Runtime: build stops for it. */ +export interface RuntimeProfileProblem { + readonly code: RuntimeProfileProblemCode; + /** The key in the local profile: `["mcp", "notes", "command"]`. */ + readonly key: readonly string[]; + /** What is wrong and how to fix it, in whole sentences that start with the key. */ + readonly reason: string; + /** `file:line:column` of the key, or the profile file. */ + readonly place: string; +} + +/** What one rule makes of the table it gets. */ +export interface RuleResult { + readonly table: TomlTable; + readonly problems: readonly RuntimeProfileProblem[]; + readonly warnings: readonly string[]; +} + +/** One rule of the derivation: it returns a new table, and changes no table it gets. */ +export type RuntimeProfileRule = ( + table: Readonly, + context: RuntimeProfileContext, +) => RuleResult; From 2ac22d6345863df021e38800c01c54a6381c282f Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 13:46:15 -0800 Subject: [PATCH 04/51] feat(box): Add a problem code for Runtime telemetry that is not CloudWatch At this time, a box on AgentCore Runtime cannot send telemetry to a [telemetry.] target that is not CloudWatch. Today, cloudWatchTelemetry removes such a target from the Runtime profile, and build gives no message. This commit adds RUNTIME_TELEMETRY_NOT_CLOUDWATCH to RUNTIME_PROFILE_PROBLEM_CODES, and thus to FAILURE_CODES. The refusals rule of the next commit uses it. This commit does not change the output of build. --- src/core/project/runtimeProfile/types.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts index e6aa8673f..6a424cde1 100644 --- a/src/core/project/runtimeProfile/types.ts +++ b/src/core/project/runtimeProfile/types.ts @@ -82,6 +82,8 @@ export const RUNTIME_PROFILE_PROBLEM_CODES = [ "RUNTIME_PROGRAM_NOT_FOUND", /** A process whose calls on the Runtime would not go through the Box gateway. */ "RUNTIME_EGRESS_NOT_CONTAINED", + /** A telemetry target that is not CloudWatch, which the Runtime cannot send to yet. */ + "RUNTIME_TELEMETRY_NOT_CLOUDWATCH", ] as const; export type RuntimeProfileProblemCode = (typeof RUNTIME_PROFILE_PROBLEM_CODES)[number]; From 9df2e6c421113511273850105a9d95aea1b764c9 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 13:58:31 -0800 Subject: [PATCH 05/51] feat(box): Keep stdio MCP servers and tools in the derived Runtime profile The Runtime profile has no stdio [mcp.] server and no [tool.] table, because renderRuntimeBoxProfile makes the profile from agentcore.json and not from the local profile. Build gives no message for them. Build also removes each [telemetry.] target that is not CloudWatch, and gives no message. This commit fills the first rule and the last rule of deriveRuntimeProfile. At this time, build does not use the rules: renderRuntimeBoxProfile writes the Runtime profile. - rules/refusals.ts reads the local profile as the user wrote it. It gives a problem for each key that cannot operate on AgentCore Runtime. The text of each problem starts with the key, and the problem gives the line of the key. - network.contain_egress = false in [agent], in a stdio [mcp.], or in a [tool.]: RUNTIME_EGRESS_NOT_CONTAINED. - A [telemetry.] kind that is not cloudwatch_logs or cloudwatch_traces: RUNTIME_TELEMETRY_NOT_CLOUDWATCH. - CodeZip only: a path of the project that is not in the code folder, a path of the home folder, or a path in the venv: RUNTIME_PATH_NOT_FOUND. - CodeZip only: a stdio server or tool program that is not the venv's Python or a file in the code folder: RUNTIME_PROGRAM_NOT_FOUND. A system program, for example /usr/bin/grep, is also a problem, because build cannot see the file system of the Runtime. - rules/paths.ts is the last rule. On CodeZip, it moves the venv's Python to ${{ inputs.python.path }}, the venv and the code folder to ${{ inputs.code.dir }}, and the uv Pythons to ${{ inputs.python.prefix }}. It moves them in each key, but not in packs, policies, [profile], [egress], an HTTP [mcp.], or [telemetry]. Each entry of a path list moves, and an entry that names a Runtime input stays. Then each filesystem list has one grant for each path. A leaf that runs the Runtime's Python gets the PYTHONPATH of the code folder if it sets none. If it sets a PYTHONPATH, the _ctypes folder goes in front, as the additions rule does for [agent]. A container image keeps each path. - projectPaths.ts has the path moves and the walk of the keys. The 2 rules use them. Each stdio [mcp.] and each [tool.] goes to the Runtime profile with each key that it has, after the path moves. The rules replace the path moves of runtimeCodeZipRunner, and the filter in cloudWatchTelemetry that keeps only CloudWatch targets. Later commits remove these, when build uses the rules. Tests: rules/paths.test.ts and rules/refusals.test.ts have 36 new tests. The test "keeps each stdio [mcp] server and each [tool], with each key, in the Runtime profile" fails with the stub rules of the frame commit. bun test: 5384 pass, 7 skip, 0 fail. Before this commit: 5348 pass, 7 skip, 0 fail. Typecheck, lint, and the format check pass. Box 0.1.11-linux-preview.6 for macOS accepts a Runtime profile with a stdio server that starts .venv/bin/python3.15 and with a [tool.] (box profile show). Box adds the rules mcp_notes_spawn and mcp_notes_call for the server. --- .../project/runtimeProfile/projectPaths.ts | 227 +++++++++++++ .../runtimeProfile/rules/paths.test.ts | 303 +++++++++++++++++ .../project/runtimeProfile/rules/paths.ts | 55 +++- .../runtimeProfile/rules/refusals.test.ts | 310 ++++++++++++++++++ .../project/runtimeProfile/rules/refusals.ts | 151 ++++++++- 5 files changed, 1028 insertions(+), 18 deletions(-) create mode 100644 src/core/project/runtimeProfile/projectPaths.ts create mode 100644 src/core/project/runtimeProfile/rules/paths.test.ts create mode 100644 src/core/project/runtimeProfile/rules/refusals.test.ts diff --git a/src/core/project/runtimeProfile/projectPaths.ts b/src/core/project/runtimeProfile/projectPaths.ts new file mode 100644 index 000000000..d6d53b26f --- /dev/null +++ b/src/core/project/runtimeProfile/projectPaths.ts @@ -0,0 +1,227 @@ +/** + * The paths of the project and the home folder in a local box profile, and where each one is on a + * CodeZip AgentCore Runtime. The refusals rule stops for a path that has no place there, and the + * paths rule moves each other path. A container image keeps each path, so neither rule reads them. + * + * | Path of the local profile | On a CodeZip Runtime | + * | --- | --- | + * | the venv's Python, `/.venv/bin/python[3[.N]]` | `${{ inputs.python.path }}` | + * | the venv, `/.venv` | `${{ inputs.code.dir }}`, where the Runtime installs the dependencies | + * | the uv Pythons, `${{ home }}/.local/share/uv/python` | `${{ inputs.python.prefix }}` | + * | the code folder and each path in it, `[/...]` | `${{ inputs.code.dir }}[/...]` | + * | another path of the project, of the home folder, or in the venv | none: a {@link PathProblem} | + */ +import { BOX_CODEZIP_DIST } from "../templates/boxProfile"; +import type { RuntimePaths, TomlTable } from "./types"; + +const WORKSPACE = "${{ workspace }}"; +const HOME = "${{ home }}"; + +/** Why a path of the local profile has no place on a CodeZip Runtime. */ +export type PathProblem = + /** A path of the project that is not in the code folder, which is all that the zip holds. */ + | "outside-code" + /** A path in the home folder, which is empty on the Runtime. */ + | "home" + /** A path in the venv other than the venv and its Python: the Runtime has no venv. */ + | "venv"; + +/** + * The top-level keys of a profile that the path rules do not read: they hold no path of the + * project, or another rule writes them (`egress` the gateway rule, `telemetry` the additions rule). + * Each HTTP `[mcp.]` is the gateway rule's too. + */ +const NOT_READ: ReadonlySet = new Set([ + "packs", + "policies", + "profile", + "egress", + "telemetry", +]); + +/** A plain TOML table: not a list, and not a date that smol-toml gives as an object. */ +export function isTable(value: unknown): value is TomlTable { + if (typeof value !== "object" || value === null || Array.isArray(value)) return false; + const prototype = Object.getPrototypeOf(value) as unknown; + return prototype === Object.prototype || prototype === null; +} + +/** A literal for a regular expression. */ +const literal = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); + +/** The end of a file name: no more of its letters follow. A `/` can follow. */ +const NAME_END = "(?![A-Za-z0-9_.+-])"; + +/** The end of a path: no more of it follows, not even a `/`. */ +const PATH_END = "(?![A-Za-z0-9_.+/-])"; + +/** + * The string `value` of the local profile, with each path of the project and of the home folder + * where it is on a CodeZip Runtime. If one of these paths has no place there, the problem. A value + * can hold more than one path, as a `:` list or a `--flag=` does. A value with no such path + * stays as it is. + */ +export function moveProjectPath( + value: string, + paths: RuntimePaths, +): string | { readonly problem: PathProblem } { + const normal = value + .replace(/\$\{\{\s*workspace\s*\}\}/g, () => WORKSPACE) + .replace(/\$\{\{\s*home\s*\}\}/g, () => HOME); + if (!normal.includes(WORKSPACE) && !normal.includes(HOME)) return value; + const venv = literal(paths.localVenv); + const moved = normal + .replace( + new RegExp(`${venv}/bin/python(?:3(?:\\.\\d+)?)?${PATH_END}`, "g"), + () => paths.runtimePython, + ) + .replace(new RegExp(`${venv}${PATH_END}`, "g"), () => paths.runtimeCode) + .replace( + new RegExp(`${literal(paths.localPythons)}${PATH_END}`, "g"), + () => paths.runtimePythonPrefix, + ); + if (new RegExp(`${venv}/`).test(moved)) return { problem: "venv" }; + const result = moved.replace( + new RegExp(`${literal(paths.localCode)}${NAME_END}`, "g"), + () => paths.runtimeCode, + ); + if (result.includes(WORKSPACE)) return { problem: "outside-code" }; + if (result.includes(HOME)) return { problem: "home" }; + return result; +} + +/** + * `table` with `move` applied to each string that can hold a path of the project: each string of + * each top-level key, except those of {@link NOT_READ} and of each HTTP `[mcp.]`. `move` gets + * the key of the string: a string in a list, or in a table in a list, has the key of the list. A + * new table. + */ +export function mapProjectPaths( + table: Readonly, + move: (value: string, key: readonly string[]) => string, +): TomlTable { + const result: TomlTable = {}; + for (const [name, value] of Object.entries(table)) { + if (NOT_READ.has(name)) { + result[name] = structuredClone(value); + } else if (name === "mcp" && isTable(value)) { + result[name] = Object.fromEntries( + Object.entries(value).map(([server, entry]) => [ + server, + isTable(entry) && entry.type === "http" + ? structuredClone(entry) + : mapValue(entry, [name, server], false, move), + ]), + ); + } else { + result[name] = mapValue(value, [name], false, move); + } + } + return result; +} + +function mapValue( + value: unknown, + key: readonly string[], + inList: boolean, + move: (value: string, key: readonly string[]) => string, +): unknown { + if (typeof value === "string") return move(value, key); + if (Array.isArray(value)) return value.map((item) => mapValue(item, key, true, move)); + if (isTable(value)) { + return Object.fromEntries( + Object.entries(value).map(([name, item]) => [ + name, + mapValue(item, inList ? key : [...key, name], inList, move), + ]), + ); + } + return structuredClone(value); +} + +/** A table of a profile that starts one process: `[agent]`, a stdio `[mcp.]`, a `[tool.]`. */ +export interface ProcessTable { + /** `["agent"]`, `["mcp", ""]`, or `["tool", ""]`. */ + readonly key: readonly string[]; + readonly table: TomlTable; + /** A stdio `[mcp.]` or a `[tool.]`, which box starts in its own leaf box. */ + readonly leaf: boolean; +} + +/** Each table of `profile` that starts one process, in profile order. */ +export function processTables(profile: Readonly): ProcessTable[] { + const tables: ProcessTable[] = []; + for (const [name, value] of Object.entries(profile)) { + if (name === "agent" && isTable(value)) tables.push({ key: [name], table: value, leaf: false }); + if ((name === "mcp" || name === "tool") && isTable(value)) { + for (const [entry, table] of Object.entries(value)) { + if (!isTable(table) || (name === "mcp" && table.type === "http")) continue; + tables.push({ key: [name, entry], table, leaf: true }); + } + } + } + return tables; +} + +/** The program of a process table: element 0 of its `command`; absent when it names none. */ +export function programOf(table: Readonly): string | undefined { + const command = table.command; + return Array.isArray(command) && typeof command[0] === "string" ? command[0] : undefined; +} + +/** Whether `program`, as a CodeZip Runtime profile names it, is on the Runtime. */ +export function isRuntimeProgram(program: string, paths: RuntimePaths): boolean { + return program === paths.runtimePython || program.startsWith(`${paths.runtimeCode}/`); +} + +/** The folder of the `_ctypes` that deploy stages for the Runtime's Python. */ +export function runtimeFfiPath(paths: RuntimePaths): string { + return `${paths.runtimeCode}/${BOX_CODEZIP_DIST}/ffi`; +} + +/** + * The `PYTHONPATH` of a leaf that runs the Runtime's Python and sets none: the `_ctypes` that + * deploy stages, then the code folder, where the Runtime installs the dependencies that the venv + * held locally. + */ +export function runtimePythonPath(paths: RuntimePaths): string { + return `${runtimeFfiPath(paths)}:${paths.runtimeCode}`; +} + +/** + * `filesystem` with one grant for each path in each list, at the position of the first. Two local + * paths can move to one path, as the code folder and its venv do. A grant that is not optional + * replaces an optional grant of the same path. + */ +export function withOneGrantForEachPath(filesystem: Readonly): TomlTable { + return Object.fromEntries( + Object.entries(filesystem).map(([list, grants]) => { + if (!Array.isArray(grants)) return [list, grants]; + const kept: unknown[] = []; + const places = new Map(); + for (const grant of grants) { + const identity = grantIdentity(grant); + const place = identity === undefined ? undefined : places.get(identity); + if (place === undefined) { + if (identity !== undefined) places.set(identity, kept.length); + kept.push(grant); + } else if (isOptional(kept[place]) && !isOptional(grant)) { + kept[place] = grant; + } + } + return [list, kept]; + }), + ); +} + +/** What makes two grants one: the path, and each other key but `optional`. */ +function grantIdentity(grant: unknown): string | undefined { + if (typeof grant === "string") return JSON.stringify([grant, []]); + if (!isTable(grant) || typeof grant.path !== "string") return undefined; + const others = Object.entries(grant) + .filter(([key]) => key !== "path" && key !== "optional") + .sort(([a], [b]) => a.localeCompare(b)); + return JSON.stringify([grant.path, others]); +} + +const isOptional = (grant: unknown) => isTable(grant) && grant.optional === true; diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts new file mode 100644 index 000000000..212f7ef7e --- /dev/null +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -0,0 +1,303 @@ +import { describe, expect, test } from "bun:test"; +import { parse } from "smol-toml"; +import type { ProjectSpec } from "../../../../projectSchemas/project"; +import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; +import { profileKeyPlaces, runtimeProfileContext } from "../context"; +import { deriveRuntimeProfile } from "../derive"; +import { serializeRuntimeProfile } from "../serialize"; +import type { TomlTable } from "../types"; +import { apply } from "./paths"; + +const CODEZIP = { + name: "agent", + build: "CodeZip", + entrypoint: "start.py", + codeLocation: "app/agent", + protocol: "HTTP", + modelProvider: "Bedrock", + box: { version: "1.0.0" }, +} as ProjectRuntime; +const CONTAINER = { ...CODEZIP, build: "Container", entrypoint: "main.py" } as ProjectRuntime; +const PROFILE = ".box/agent/local/profile.toml"; + +const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => + runtimeProfileContext({ + spec: { name: "demo", runtimes: [runtime] } as unknown as ProjectSpec, + runtime, + profileFile: PROFILE, + region: "us-west-2", + gateway: { name: "agent-box-egress", targets: [] }, + hosts: [], + telemetry: [], + policyFiles: [], + places: profileKeyPlaces(text, PROFILE), + }); + +/** The table of the paths rule for the local profile `text`. */ +const moved = (text: string, runtime: ProjectRuntime = CODEZIP) => { + const result = apply(parse(text) as TomlTable, contextOf(text, runtime)); + expect(result.problems).toEqual([]); + expect(result.warnings).toEqual([]); + return result.table; +}; + +const toml = (...lines: string[]) => lines.join("\n"); + +const APP = "${{ workspace }}/app/agent"; +const CODE = "${{ inputs.code.dir }}"; +const PYTHON = "${{ inputs.python.path }}"; +const PREFIX = "${{ inputs.python.prefix }}"; +const PYTHONPATH = `${CODE}/.box-dist/ffi:${CODE}`; + +/** A local profile with a stdio MCP server and a tool, each with a key build does not know. */ +const LEAVES = toml( + 'packs = ["box/base"]', + "", + "[agent]", + 'command = ["/bin/echo"]', + "", + "[mcp.notes]", + 'type = "stdio"', + `command = ["${APP}/.venv/bin/python3.15", "${APP}/notes_server.py", "--root=${APP}/notes"]`, + `workspace = "${APP}"`, + "argument_wildcards = true", + `env = { NOTES_DIR = "\${{workspace}}/app/agent/notes", LEVEL = "debug" }`, + "", + "[mcp.notes.filesystem]", + `read = ["${APP}", { path = "${APP}/.venv", optional = true }, { path = "\${{ home }}/.local/share/uv/python", optional = true }]`, + `write = ["${APP}/notes/out"]`, + "", + "[mcp.notes.network]", + "contain_egress = true", + "", + "[tool.lister]", + `command = ["${APP}/bin/lister", "--all"]`, + "native-filesystem-policy = false", + "", + "[tool.lister.filesystem]", + `read = ["${APP}/data"]`, +); + +/** {@link LEAVES} on a CodeZip Runtime. */ +const LEAVES_ON_RUNTIME = { + notes: { + type: "stdio", + command: [PYTHON, `${CODE}/notes_server.py`, `--root=${CODE}/notes`], + workspace: CODE, + argument_wildcards: true, + // The Runtime's Python finds the dependencies in the code folder, as the agent does. + env: { NOTES_DIR: `${CODE}/notes`, LEVEL: "debug", PYTHONPATH }, + // The venv moves to the code folder, which the first grant names already. + filesystem: { + read: [CODE, { path: PREFIX, optional: true }], + write: [`${CODE}/notes/out`], + }, + network: { contain_egress: true }, + }, + lister: { + command: [`${CODE}/bin/lister`, "--all"], + "native-filesystem-policy": false, + filesystem: { read: [`${CODE}/data`] }, + }, +}; + +describe("the paths rule", () => { + test("keeps each stdio [mcp] server and each [tool], with each key, in the Runtime profile", () => { + // Today renderRuntimeBoxProfile builds the Runtime profile from agentcore.json, and it has no + // [mcp.notes] and no [tool.lister]. The derived profile keeps both, as they work there. + const { profile, problems } = deriveRuntimeProfile( + parse(LEAVES) as TomlTable, + contextOf(LEAVES), + ); + const written = parse(serializeRuntimeProfile(profile)) as TomlTable; + + expect(problems).toEqual([]); + expect(written.mcp).toEqual({ notes: LEAVES_ON_RUNTIME.notes }); + expect(written.tool).toEqual({ lister: LEAVES_ON_RUNTIME.lister }); + }); + + test("moves the venv's Python, the venv, the uv Pythons, and the code folder in [agent]", () => { + const table = moved( + toml( + 'agent-args = ["--config", "${{ workspace }}/app/agent/agent.json"]', + "[agent]", + `command = ["${APP}/.venv/bin/python", "-m", "main"]`, + `workspace = "${APP}"`, + "[agent.env]", + `PYTHONPATH = "${APP}/src:${APP}"`, + `PYTHON = "${APP}/.venv/bin/python3"`, + 'LEVEL = "debug"', + "[agent.filesystem]", + `read = ["${APP}", { path = "${APP}/.venv", optional = true }, { path = "\${{ home }}/.local/share/uv/python", optional = true }]`, + `exec = [{ path = "${APP}/.venv", optional = true }, { path = "\${{ home }}/.local/share/uv/python", optional = true }]`, + `write_file = ["${APP}/out.json"]`, + ), + ); + + expect(table).toEqual({ + "agent-args": ["--config", `${CODE}/agent.json`], + agent: { + command: [PYTHON, "-m", "main"], + workspace: CODE, + // The agent's own PYTHONPATH is the additions rule's: this rule adds none to [agent]. + env: { PYTHONPATH: `${CODE}/src:${CODE}`, PYTHON, LEVEL: "debug" }, + filesystem: { + read: [CODE, { path: PREFIX, optional: true }], + exec: [ + { path: CODE, optional: true }, + { path: PREFIX, optional: true }, + ], + write_file: [`${CODE}/out.json`], + }, + }, + }); + }); + + test("keeps the grant that is not optional where two grants move to one path", () => { + const table = moved( + toml( + "[tool.lister]", + `command = ["${APP}/lister"]`, + "[tool.lister.filesystem]", + `read = [{ path = "${APP}/.venv", optional = true }, "${APP}/data", "${APP}", { path = "${APP}", when = "macos" }]`, + ), + ); + + expect((table.tool as { lister: TomlTable }).lister.filesystem).toEqual({ + read: [CODE, `${CODE}/data`, { path: CODE, when: "macos" }], + }); + }); + + test("puts the _ctypes folder in front of a leaf's own PYTHONPATH, and adds none to [agent] or a leaf with no Python", () => { + const table = moved( + toml( + "[agent]", + `command = ["${APP}/.venv/bin/python", "-m", "main"]`, + "[mcp.notes]", + 'type = "stdio"', + `command = ["${APP}/.venv/bin/python3.12", "-m", "notes"]`, + `env = { PYTHONPATH = "${APP}/src:${APP}" }`, + "[tool.lister]", + `command = ["${APP}/bin/lister"]`, + ), + ); + + expect(table).toEqual({ + agent: { command: [PYTHON, "-m", "main"] }, + mcp: { + notes: { + type: "stdio", + command: [PYTHON, "-m", "notes"], + env: { PYTHONPATH: `${CODE}/.box-dist/ffi:${CODE}/src:${CODE}` }, + }, + }, + tool: { lister: { command: [`${CODE}/bin/lister`] } }, + }); + }); + + test("moves each project path of a path list behind the _ctypes entry, and keeps that entry", () => { + // The additions rule puts the _ctypes folder in front of the user's own [agent] PYTHONPATH. + const ffi = `${CODE}/.box-dist/ffi`; + const text = toml( + "[agent]", + 'command = ["${{ inputs.python.path }}", "-m", "main"]', + "[agent.env]", + `PYTHONPATH = "${ffi}:${APP}/src:${APP}"`, + "[mcp.notes]", + 'type = "stdio"', + `command = ["${APP}/.venv/bin/python3.15", "-m", "notes"]`, + `env = { PYTHONPATH = "${ffi}:${APP}/lib:${APP}" }`, + ); + + expect(moved(text)).toEqual({ + agent: { + command: [PYTHON, "-m", "main"], + env: { PYTHONPATH: `${ffi}:${CODE}/src:${CODE}` }, + }, + mcp: { + notes: { + type: "stdio", + command: [PYTHON, "-m", "notes"], + env: { PYTHONPATH: `${ffi}:${CODE}/lib:${CODE}` }, + }, + }, + }); + }); + + test("moves the paths of a code folder that is the project folder", () => { + const root = { ...CODEZIP, codeLocation: "." } as ProjectRuntime; + const text = toml( + "[tool.lister]", + 'command = ["${{ workspace }}/.venv/bin/python3.15", "${{ workspace }}/lister.py"]', + ); + + expect(moved(text, root)).toEqual({ + tool: { lister: { command: [PYTHON, `${CODE}/lister.py`], env: { PYTHONPATH } } }, + }); + }); + + test("changes no key that another rule writes, and no value with no path of the project", () => { + const text = toml( + 'packs = ["box/base"]', + 'policies = ["policies/app.dw"]', + "[profile]", + 'name = "demo-agent"', + "[options]", + 'bedrock.region = "us-west-2"', + "[egress.files]", + 'destinations = ["files.example.com"]', + 'secret.ref = "file://${{ workspace }}/app/agent/.files-token"', + "[mcp.docs]", + 'type = "http"', + 'destinations = ["docs.example.com"]', + 'secret.ref = "file://${{ workspace }}/app/agent/.docs-token"', + "[telemetry.local]", + 'kind = "file"', + 'path = "${{ workspace }}/app/agent/telemetry.jsonl"', + "[agent]", + 'command = ["/usr/bin/env", "--flag", "${{ inputs.code.dir }}/x", "https://example.com/a:b"]', + "[[agent.ingress]]", + 'listen = "127.0.0.1:8080"', + "workload_port = 8081", + "[limits.shell]", + "timeout = 30", + ); + + expect(moved(text)).toEqual(parse(text) as TomlTable); + }); + + test("keeps each path of a container image, which runs the same paths under dev and on the Runtime", () => { + const text = toml( + LEAVES, + "[agent.filesystem]", + 'read = ["${{ workspace }}", "${{workspace}}/.venv", "${{ workspace }}", "${{ home }}/.aws"]', + "[tool.image]", + 'command = ["${{ workspace }}/.venv/bin/python", "${{ workspace }}/image.py"]', + ); + + expect(moved(text, CONTAINER)).toEqual(parse(text) as TomlTable); + }); + + test.each(["HTTP", "A2A", "MCP", "AGUI"])( + "moves each path of the profile that create writes for a %s runtime to the Runtime's inputs", + (protocol) => { + const context = contextOf("", { ...CODEZIP, protocol } as ProjectRuntime); + + const text = serializeRuntimeProfile(apply(context.template.local, context).table); + + expect(text).toContain(CODE); + expect(text).not.toContain("${{ workspace }}"); + expect(text).not.toContain("${{ home }}"); + }, + ); + + test("changes no table it gets", () => { + const local = parse(LEAVES) as TomlTable; + const frozen = structuredClone(local); + + const { table } = apply(local, contextOf(LEAVES)); + ((table.mcp as TomlTable).notes as TomlTable).type = "changed"; + + expect(local).toEqual(frozen); + }); +}); diff --git a/src/core/project/runtimeProfile/rules/paths.ts b/src/core/project/runtimeProfile/rules/paths.ts index 821ff6c10..b9edb68aa 100644 --- a/src/core/project/runtimeProfile/rules/paths.ts +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -1,14 +1,51 @@ /** - * Rule 4 of the derivation, the last: each path of the project or the home folder, in every table, - * where it is on AgentCore Runtime (`context.paths`). A container image keeps each path. On CodeZip, - * the venv's Python goes to `${{ inputs.python.path }}`, the venv and the code folder to - * `${{ inputs.code.dir }}`, and the uv Pythons to `${{ inputs.python.prefix }}`, as the agent - * command moves today in runtimeCodeZipRunner (templates/boxProfile.ts). To do: a path of the - * project outside the code folder, a path in the home folder, or a path in the venv has no place - * there (RUNTIME_PATH_NOT_FOUND); and one grant for each path where two move to one. + * Rule 4 of the derivation, the last: each path of the project and of the home folder, where it is + * on AgentCore Runtime (`context.paths`). A container image keeps each path. On CodeZip, the venv's + * Python goes to `${{ inputs.python.path }}`, the venv and the code folder go to + * `${{ inputs.code.dir }}`, and the uv Pythons go to `${{ inputs.python.prefix }}`. The paths move + * in each key that can hold a path (projectPaths.ts): the `[agent]` command, env, and filesystem + * lists, and each key of each stdio `[mcp.]` and `[tool.]`. Then each filesystem list + * has one grant for each path. A leaf that runs the Runtime's Python gets the `PYTHONPATH` of the + * code folder when it sets none, and the `_ctypes` folder in front of a `PYTHONPATH` of its own, as + * the additions rule does for `[agent]`. Each entry of a path list moves, and an entry that names a + * Runtime input stays. The refusals rule stops build for a path that has no place on the + * Runtime, so this rule keeps such a path as it is. It replaces the path moves of + * runtimeCodeZipRunner (templates/boxProfile.ts). */ +import { + isTable, + mapProjectPaths, + moveProjectPath, + processTables, + programOf, + runtimeFfiPath, + runtimePythonPath, + withOneGrantForEachPath, +} from "../projectPaths"; import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; -export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { - return { table: { ...table }, problems: [], warnings: [] }; +export function apply(table: Readonly, context: RuntimeProfileContext): RuleResult { + const { paths } = context; + if (paths.build !== "CodeZip") { + return { table: structuredClone(table) as TomlTable, problems: [], warnings: [] }; + } + const moved = mapProjectPaths(table, (value) => { + const result = moveProjectPath(value, paths); + return typeof result === "string" ? result : value; + }); + for (const { table: process, leaf } of processTables(moved)) { + if (isTable(process.filesystem)) { + process.filesystem = withOneGrantForEachPath(process.filesystem); + } + if (!leaf || programOf(process) !== paths.runtimePython) continue; + const env = isTable(process.env) ? process.env : {}; + const own = env.PYTHONPATH; + const ffi = runtimeFfiPath(paths); + if (own === undefined) { + process.env = { ...env, PYTHONPATH: runtimePythonPath(paths) }; + } else if (typeof own === "string" && !own.split(":").includes(ffi)) { + process.env = { ...env, PYTHONPATH: `${ffi}:${own}` }; + } + } + return { table: moved, problems: [], warnings: [] }; } diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts new file mode 100644 index 000000000..358d1a14e --- /dev/null +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -0,0 +1,310 @@ +import { describe, expect, test } from "bun:test"; +import { parse } from "smol-toml"; +import type { ProjectSpec } from "../../../../projectSchemas/project"; +import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; +import { profileKeyPlaces, runtimeProfileContext } from "../context"; +import { deriveRuntimeProfile } from "../derive"; +import type { RuntimeProfileProblem, TomlTable } from "../types"; +import { apply } from "./refusals"; + +const CODEZIP = { + name: "agent", + build: "CodeZip", + entrypoint: "start.py", + codeLocation: "app/agent", + protocol: "HTTP", + modelProvider: "Bedrock", + box: { version: "1.0.0" }, +} as ProjectRuntime; +const CONTAINER = { ...CODEZIP, build: "Container", entrypoint: "main.py" } as ProjectRuntime; +const PROFILE = ".box/agent/local/profile.toml"; + +const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => + runtimeProfileContext({ + spec: { name: "demo", runtimes: [runtime] } as unknown as ProjectSpec, + runtime, + profileFile: PROFILE, + region: "us-west-2", + gateway: { name: "agent-box-egress", targets: [] }, + hosts: [], + telemetry: [], + policyFiles: [], + places: profileKeyPlaces(text, PROFILE), + }); + +/** The problems of the refusals rule for the local profile `text`. */ +const problemsOf = (text: string, runtime: ProjectRuntime = CODEZIP) => + apply(parse(text) as TomlTable, contextOf(text, runtime)).problems; + +const toml = (...lines: string[]) => lines.join("\n"); + +/** The place of the line of `text` that starts with `start`. */ +const lineOf = (text: string, start: string) => + `${PROFILE}:${text.split("\n").findIndex((line) => line.startsWith(start)) + 1}:1`; + +const APP = "${{ workspace }}/app/agent"; + +/** A local profile that can go to a CodeZip Runtime: each path moves, and each program is there. */ +const WORKS = toml( + 'packs = ["box/base", "box/bedrock"]', + "", + "[agent]", + `command = ["${APP}/.venv/bin/python", "-m", "uvicorn", "main:app", "--app-dir", "${APP}"]`, + "", + "[agent.filesystem]", + `read = ["${APP}", { path = "\${{ home }}/.local/share/uv/python", optional = true }]`, + "", + "[mcp.notes]", + 'type = "stdio"', + `command = ["${APP}/.venv/bin/python3.15", "${APP}/notes_server.py"]`, + "argument_wildcards = true", + "", + "[mcp.notes.network]", + "contain_egress = true", + "", + "[mcp.docs]", + 'type = "http"', + 'destinations = ["docs.example.com"]', + "", + "[tool.lister]", + `command = ["${APP}/bin/lister"]`, + "", + "[telemetry.logs]", + 'kind = "cloudwatch_logs"', + 'log_group = "/demo/agent"', + 'log_stream = "box"', + "", + "[telemetry.traces]", + 'kind = "cloudwatch_traces"', +); + +describe("the refusals rule", () => { + test.each([CODEZIP, CONTAINER])( + "gives the table as it got it, with no problem, when each key can work ($build)", + (runtime) => { + const local = parse(WORKS) as TomlTable; + + const result = apply(local, contextOf(WORKS, runtime)); + + expect(result).toEqual({ table: local, problems: [], warnings: [] }); + expect(result.table).not.toBe(local); + }, + ); + + test.each([ + [ + "a path of the project outside the code folder", + ["mcp", "notes", "command"], + `command = ["${APP}/.venv/bin/python3.15", "\${{ workspace }}/tools/notes.py"]`, + '[mcp.notes] command names "${{ workspace }}/tools/notes.py", which is not in app/agent/. ' + + "The zip of a CodeZip deploy contains only that folder. Move the file into app/agent/, " + + "or remove the path.", + ], + [ + "a path of the home folder", + ["mcp", "notes", "env", "NOTES_DIR"], + 'env = { NOTES_DIR = "${{ home }}/notes" }', + '[mcp.notes.env] NOTES_DIR names "${{ home }}/notes" in the home folder. The home folder ' + + "on AgentCore Runtime is empty. Move the file into app/agent/, or remove the path.", + ], + [ + "a path in the venv", + ["mcp", "notes", "command"], + `command = ["${APP}/.venv/bin/notes-server"]`, + `[mcp.notes] command names "${APP}/.venv/bin/notes-server", a path in the venv. The zip of ` + + "a CodeZip deploy does not contain the venv: the Runtime installs the dependencies in " + + "app/agent/. Use the venv's Python, the venv, or a path in app/agent/.", + ], + [ + "a program in the venv whose name starts as the venv's Python does", + ["mcp", "notes", "command"], + `command = ["${APP}/.venv/bin/python3.15-config"]`, + `[mcp.notes] command names "${APP}/.venv/bin/python3.15-config", a path in the venv. The ` + + "zip of a CodeZip deploy does not contain the venv: the Runtime installs the dependencies " + + "in app/agent/. Use the venv's Python, the venv, or a path in app/agent/.", + ], + [ + "a folder of the project whose name starts as the code folder's does", + ["mcp", "notes", "command"], + 'command = ["${{ workspace }}/app/agent-tools/notes-server"]', + '[mcp.notes] command names "${{ workspace }}/app/agent-tools/notes-server", which is not in ' + + "app/agent/. The zip of a CodeZip deploy contains only that folder. Move the file into " + + "app/agent/, or remove the path.", + ], + ])("stops for %s (RUNTIME_PATH_NOT_FOUND)", (_label, key, line, reason) => { + const text = toml("[mcp.notes]", 'type = "stdio"', line); + + expect(problemsOf(text)).toEqual([ + { code: "RUNTIME_PATH_NOT_FOUND", key, reason, place: `${PROFILE}:3:1` }, + ]); + }); + + test("stops for each path that cannot move, in [agent], a [tool], and a filesystem list", () => { + const text = toml( + "[agent]", + `command = ["${APP}/.venv/bin/python", "-m", "main"]`, + "[agent.env]", + 'AWS_CONFIG_FILE = "${{ home }}/.aws/config"', + "[agent.filesystem]", + `read = ["${APP}", { path = "\${{ home }}/.aws", optional = true }]`, + "[tool.lister]", + `command = ["${APP}/bin/lister"]`, + "[tool.lister.filesystem]", + 'write = ["${{ workspace }}/out", "${{ home }}/.local/share/uv/python/cpython-3.15"]', + ); + + expect(problemsOf(text).map(({ key, place }) => [key.join("."), place])).toEqual([ + ["agent.env.AWS_CONFIG_FILE", `${PROFILE}:4:1`], + ["agent.filesystem.read", `${PROFILE}:6:1`], + ["tool.lister.filesystem.write", `${PROFILE}:10:1`], + ["tool.lister.filesystem.write", `${PROFILE}:10:1`], + ]); + }); + + test.each([ + ["a program that PATH finds", ["mcp", "files"], '"npx", "-y", "files-server"', "npx"], + ["a system program", ["tool", "grep"], '"/usr/bin/grep", "-r"', "/usr/bin/grep"], + ])( + "stops for %s that build cannot find on a CodeZip Runtime (RUNTIME_PROGRAM_NOT_FOUND)", + (_label, table, command, program) => { + const header = `[${table.join(".")}]`; + const text = toml( + header, + ...(table[0] === "mcp" ? ['type = "stdio"'] : []), + `command = [${command}]`, + ); + + expect(problemsOf(text)).toEqual([ + { + code: "RUNTIME_PROGRAM_NOT_FOUND", + key: [...table, "command"], + reason: + `${header} command starts "${program}", which build cannot find on AgentCore ` + + "Runtime. The zip of a CodeZip deploy contains only app/agent/, and the Runtime has " + + "its own Python. Start the process with the venv's Python, for example " + + `${APP}/.venv/bin/python3., or with a program in app/agent/.`, + place: lineOf(text, "command"), + }, + ]); + expect(problemsOf(text, CONTAINER)).toEqual([]); + }, + ); + + test("stops for a [tool] program that box finds on PATH, on a CodeZip Runtime only", () => { + const text = toml("[tool.jq]", 'program = "jq"'); + + expect(problemsOf(text).map(({ code, key }) => [code, key])).toEqual([ + ["RUNTIME_PROGRAM_NOT_FOUND", ["tool", "jq", "program"]], + ]); + expect(problemsOf(text, CONTAINER)).toEqual([]); + }); + + test("gives one problem, of the path, for a program with no place on the Runtime", () => { + const text = toml("[tool.lister]", 'command = ["${{ home }}/bin/lister"]'); + + expect(problemsOf(text).map(({ code }) => code)).toEqual(["RUNTIME_PATH_NOT_FOUND"]); + }); + + test.each([ + ["mcp", 'type = "stdio"\ncommand = ["${{ workspace }}/app/agent/notes-server"]'], + ["tool", 'command = ["${{ workspace }}/app/agent/notes-server"]'], + ["agent", 'command = ["${{ workspace }}/app/agent/notes-server"]'], + ])( + "stops for contain_egress = false in [%s], for CodeZip and a container (RUNTIME_EGRESS_NOT_CONTAINED)", + (group, body) => { + const table = group === "agent" ? "agent" : `${group}.notes`; + const text = toml(`[${table}]`, body, `[${table}.network]`, "contain_egress = false"); + const expected: RuntimeProfileProblem = { + code: "RUNTIME_EGRESS_NOT_CONTAINED", + key: [...table.split("."), "network", "contain_egress"], + reason: + `[${table}.network] contain_egress is false: on AgentCore Runtime, [${table}] connects ` + + "to hosts without the Box gateway. Build does not send such a process to AgentCore " + + "Runtime. Remove contain_egress, and give each host that the process connects to an " + + "[egress] entry.", + place: lineOf(text, "contain_egress"), + }; + + expect(problemsOf(text)).toEqual([expected]); + expect(problemsOf(text, CONTAINER)).toEqual([expected]); + }, + ); + + test.each([CODEZIP, CONTAINER])( + "stops for each [telemetry] target that is not CloudWatch, by its kind ($build)", + (runtime) => { + const text = toml( + "[telemetry.logs]", + 'kind = "cloudwatch_logs"', + 'log_group = "/demo/agent"', + 'log_stream = "box"', + "", + "[telemetry.collector]", + 'kind = "otlp"', + 'endpoint = "https://otel.example.com"', + "", + "[telemetry.local]", + 'path = "/tmp/box.jsonl"', + ); + + expect(problemsOf(text, runtime)).toEqual([ + { + code: "RUNTIME_TELEMETRY_NOT_CLOUDWATCH", + key: ["telemetry", "collector", "kind"], + reason: + '[telemetry.collector] kind is "otlp". At this time, a box on AgentCore Runtime can ' + + 'send telemetry only to CloudWatch: kind "cloudwatch_logs" or "cloudwatch_traces". ' + + "Remove [telemetry.collector], or change its kind to one of these.", + place: `${PROFILE}:7:1`, + }, + { + code: "RUNTIME_TELEMETRY_NOT_CLOUDWATCH", + key: ["telemetry", "local", "kind"], + reason: + "[telemetry.local] kind is not set. At this time, a box on AgentCore Runtime can send " + + 'telemetry only to CloudWatch: kind "cloudwatch_logs" or "cloudwatch_traces". Remove ' + + "[telemetry.local], or change its kind to one of these.", + place: `${PROFILE}:10:1`, + }, + ]); + }, + ); + + test("reads no path of [egress], of an HTTP [mcp], or of [telemetry]: other rules write them", () => { + const text = toml( + "[egress.files]", + 'destinations = ["files.example.com"]', + 'secret.ref = "file://${{ home }}/.files-token"', + "[mcp.docs]", + 'type = "http"', + 'destinations = ["docs.example.com"]', + 'secret.ref = "file://${{ home }}/.docs-token"', + "[telemetry.traces]", + 'kind = "cloudwatch_traces"', + 'note = "${{ home }}/traces"', + ); + + expect(problemsOf(text)).toEqual([]); + }); + + test.each(["HTTP", "A2A", "MCP", "AGUI"])( + "finds no problem in each profile that create writes for a %s runtime", + (protocol) => { + for (const build of [CODEZIP, CONTAINER]) { + const context = contextOf("", { ...build, protocol } as ProjectRuntime); + + expect(apply(context.template.local, context).problems).toEqual([]); + } + }, + ); + + test("reads the local profile as the user wrote it: the first rule of the derivation", () => { + const text = toml("[mcp.files]", 'type = "stdio"', 'command = ["npx", "files-server"]'); + + const { problems } = deriveRuntimeProfile(parse(text) as TomlTable, contextOf(text)); + + expect(problems.map(({ code, place }) => [code, place])).toEqual([ + ["RUNTIME_PROGRAM_NOT_FOUND", `${PROFILE}:3:1`], + ]); + }); +}); diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index 981704817..717f8b28c 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -1,13 +1,146 @@ /** - * Rule 1 of the derivation: the keys of the local profile that cannot work on AgentCore Runtime - * whatever their paths are. To do: a stdio `[mcp.]` or a `[tool.]` with - * `network.contain_egress = false` (RUNTIME_EGRESS_NOT_CONTAINED); on a CodeZip runtime, a stdio - * server or tool program that is not the venv's Python or a file in the code folder - * (RUNTIME_PROGRAM_NOT_FOUND); and each `[telemetry.]` that is not CloudWatch, which it - * removes with a warning, as `cloudWatchTelemetry` in boxNetwork/telemetry.ts leaves it out today. + * Rule 1 of the derivation: the keys of the local profile, as the user wrote it, that cannot work + * on AgentCore Runtime. Each one is a problem that names the key, and build stops for it. Nothing + * is removed: the rule gives the table as it got it. + * + * | Key | Problem | + * | --- | --- | + * | `network.contain_egress = false` on `[agent]`, a stdio `[mcp.]`, or a `[tool.]` | RUNTIME_EGRESS_NOT_CONTAINED | + * | a `[telemetry.]` that is not `cloudwatch_logs` or `cloudwatch_traces` | RUNTIME_TELEMETRY_NOT_CLOUDWATCH | + * | CodeZip: a path of the project outside the code folder, of the home folder, or in the venv | RUNTIME_PATH_NOT_FOUND | + * | CodeZip: a stdio server or tool program that is not the venv's Python or a file in the code folder | RUNTIME_PROGRAM_NOT_FOUND | + * + * A container image runs the same paths and programs under `agentcore dev` and on the Runtime, so + * the last two do not apply to it. It replaces the CloudWatch-only filter of `cloudWatchTelemetry` + * (boxNetwork/telemetry.ts), which leaves out each other target with no message. */ -import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; +import { keyLabel } from "../derive"; +import { + isRuntimeProgram, + isTable, + mapProjectPaths, + moveProjectPath, + processTables, + programOf, + type PathProblem, +} from "../projectPaths"; +import type { + RuleResult, + RuntimeProfileContext, + RuntimeProfileProblem, + RuntimeProfileProblemCode, + TomlTable, +} from "../types"; -export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { - return { table: { ...table }, problems: [], warnings: [] }; +/** The telemetry kinds that a box on AgentCore Runtime can send to, with the execution role. */ +const RUNTIME_TELEMETRY_KINDS: ReadonlySet = new Set([ + "cloudwatch_logs", + "cloudwatch_traces", +]); + +export function apply(table: Readonly, context: RuntimeProfileContext): RuleResult { + const problems: RuntimeProfileProblem[] = []; + const problem = (code: RuntimeProfileProblemCode, key: readonly string[], reason: string) => + problems.push({ code, key, reason: `${keyLabel(key)} ${reason}`, place: context.placeOf(key) }); + + for (const { key, table: process } of processTables(table)) { + const network = process.network; + if (isTable(network) && network.contain_egress === false) { + problem( + "RUNTIME_EGRESS_NOT_CONTAINED", + [...key, "network", "contain_egress"], + `is false: on AgentCore Runtime, [${key.join(".")}] connects to hosts without the Box ` + + "gateway. Build does not send such a process to AgentCore Runtime. Remove " + + "contain_egress, and give each host that the process connects to an [egress] entry.", + ); + } + } + + const telemetry = isTable(table.telemetry) ? table.telemetry : {}; + for (const [name, target] of Object.entries(telemetry)) { + const kind = isTable(target) ? target.kind : undefined; + if (typeof kind === "string" && RUNTIME_TELEMETRY_KINDS.has(kind)) continue; + problem( + "RUNTIME_TELEMETRY_NOT_CLOUDWATCH", + ["telemetry", name, "kind"], + `${typeof kind === "string" ? `is ${JSON.stringify(kind)}` : "is not set"}. At this time, ` + + "a box on AgentCore Runtime can send telemetry only to CloudWatch: kind " + + `"cloudwatch_logs" or "cloudwatch_traces". Remove [telemetry.${name}], or change its ` + + "kind to one of these.", + ); + } + + const { paths } = context; + if (paths.build === "CodeZip") { + const code = paths.shownCode; + const reasons: Record string> = { + "outside-code": (value) => + `names ${value}, which is not in ${code}. The zip of a CodeZip deploy contains only ` + + `that folder. Move the file into ${code}, or remove the path.`, + home: (value) => + `names ${value} in the home folder. The home folder on AgentCore Runtime is empty. Move ` + + `the file into ${code}, or remove the path.`, + venv: (value) => + `names ${value}, a path in the venv. The zip of a CodeZip deploy does not contain the ` + + `venv: the Runtime installs the dependencies in ${code}. Use the venv's Python, the ` + + `venv, or a path in ${code}.`, + }; + mapProjectPaths(table, (value, key) => { + const moved = moveProjectPath(value, paths); + if (typeof moved !== "string") { + problem("RUNTIME_PATH_NOT_FOUND", key, reasons[moved.problem](JSON.stringify(value))); + } + return value; + }); + for (const { key, table: process, leaf } of processTables(table)) { + // The additions rule writes the command of [agent], so this check is for a leaf only. + if (!leaf) continue; + const command = programOf(process); + const moved = command === undefined ? undefined : moveProjectPath(command, paths); + const searched = typeof process.program === "string" ? process.program : undefined; + // A program with no place on the Runtime is a path problem of its command already. + const program = typeof moved === "string" ? moved : undefined; + if (program !== undefined && !isRuntimeProgram(program, paths)) { + problem("RUNTIME_PROGRAM_NOT_FOUND", [...key, "command"], notFound(command!, paths)); + } + if (searched !== undefined) { + problem("RUNTIME_PROGRAM_NOT_FOUND", [...key, "program"], notFound(searched, paths)); + } + } + } + + return { + table: structuredClone(table) as TomlTable, + problems: inProfileOrder(problems), + warnings: [], + }; +} + +/** Why build cannot find the program `program` of a process on a CodeZip Runtime. */ +function notFound(program: string, paths: RuntimeProfileContext["paths"]): string { + return ( + `starts ${JSON.stringify(program)}, which build cannot find on AgentCore Runtime. The zip ` + + `of a CodeZip deploy contains only ${paths.shownCode}, and the Runtime has its own Python. ` + + `Start the process with the venv's Python, for example ` + + `${paths.localVenv}/bin/python3., or with a program in ${paths.shownCode}.` + ); +} + +/** `problems` in the order of their places in the profile, and each problem of one place once. */ +function inProfileOrder(problems: readonly RuntimeProfileProblem[]): RuntimeProfileProblem[] { + const position = ({ place }: RuntimeProfileProblem) => { + const match = /:(\d+):(\d+)$/.exec(place); + return match ? [Number(match[1]), Number(match[2])] : [0, 0]; + }; + const seen = new Set(); + return problems + .filter(({ code, key, reason }) => { + const identity = JSON.stringify([code, key, reason]); + if (seen.has(identity)) return false; + seen.add(identity); + return true; + }) + .map((problem, index) => ({ problem, index, at: position(problem) })) + .sort((a, b) => a.at[0]! - b.at[0]! || a.at[1]! - b.at[1]! || a.index - b.index) + .map(({ problem }) => problem); } From cbddeeced6fe427a7e5e4ca09c85433a10c49192 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 13:59:30 -0800 Subject: [PATCH 06/51] feat(box): Derive the gateway routes of the Runtime box profile from the local profile ## Problem Build makes the gateway routes of the AgentCore Runtime box profile from agentcore.json and the Box network model. It does not make them from the local box profile. Thus the Runtime profile does not have the keys of an `[egress.]` entry or of an HTTP `[mcp.]` server that the renderer does not know. The `gateway` rule of the derivation was a stub, and the derived profile had no gateway routes. ## Solution The `gateway` rule (`runtimeProfile/rules/gateway.ts`) writes the gateway routes into the derived profile: - Each host of an `[egress.]` entry that has a gateway target gets `[egress.]`. This route has one backend to `${{ inputs.gateway.url }}/`, with a bare `aws://` signer for the build region. The rule removes the `secret`, because the gateway target sends the credential. The other keys of the entry stay. - Each HTTP `[mcp.]` server keeps its name and its other keys, and gets the same backend. The rule keeps only an `env://` secret, with no `inject`. - Each passthrough target with no entry gets a route: `bedrock`, `agentcore`, a host that only a permit names, and each other passthrough target of the gateway. A target of an HTTP MCP server that only a pack has becomes that server. - The rule finds the list of targets that build writes. It keeps each target without the `egress-` prefix, and each `egress-` target of a host. It removes the other `egress-` targets. It adds the target of each other host. - The rule removes an entry if the policy denies all of its hosts. The renderer of agentcore.json also removes it, and the Box network model gives a warning for it. - The rule removes an entry with no host in the Box network model. Box keeps each correct entry in its resolution, so the model has no host for an entry only when the model rejects that entry. The model then gives a problem with the key and its file:line:column, and build stops. A second problem from the rule gives the same entry two times. - Two passthrough targets for one host cause the same `InputValidationError` that `runtimeGatewayRoutes` causes. - The rule does not change a stdio `[mcp.]`. The `refusals` and `paths` rules change it. For these tables, the output of the rule is the same output that `runtimeGatewayRoutes`, `runtimeGatewayRouteSection`, `runtimeMcpServerSection`, `runtimeMcpServers`, and `runtimeGatewayBackend` make. This change does not remove these functions. It does not give the derived profile to the runtime profile writer. ## Tests - `gateway.test.ts`, "give the same [egress] and HTTP [mcp] tables on the first build": one project goes through `buildBoxNetwork`, the credentials, gateway targets, and default targets writers, and `renderRuntimeBoxProfile`. The derived `[egress]` and HTTP `[mcp]` tables are equal to the tables of the renderer. The test "on the next build" does the same from the agentcore.json of the first build. - "give no second problem for an entry that the Box network model rejects, and no route": the model rejects a wildcard `[egress]` entry and an `[mcp]` server with a path, with one problem for each. The rule adds no problem. - The other tests of `gateway.test.ts` examine each item above. Each test has a local profile in TOML, and the TOML or the problem that must come out. - A mutation script made 16 changes to the rule, one change at a time. For each change, one or more tests found it. - `box profile show --format json --full` (box 0.1.11-linux-preview.6, macOS) accepted the profile of the renderer and the derived profile of the first test project. The two resolved `[egress]` and `[mcp]` tables were equal. - `bun run typecheck`, `bun run lint:check`, and `bun run format:check` gave no error. `bun test`: 5363 pass, 7 skip, 0 fail. At 94385bb1 it gave 5348 pass, 7 skip, 0 fail, so the 15 new tests pass and no test of 94385bb1 stopped passing. Not in the tests: a host with an API key and no credential, if the credentials writer cannot add one. The gateway targets writer does not write the target of that host, and the renderer gives the host no route. The rule gives the host a route to that target. --- .../runtimeProfile/rules/gateway.test.ts | 599 ++++++++++++++++++ .../project/runtimeProfile/rules/gateway.ts | 224 ++++++- 2 files changed, 810 insertions(+), 13 deletions(-) create mode 100644 src/core/project/runtimeProfile/rules/gateway.test.ts diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts new file mode 100644 index 000000000..445ba9bda --- /dev/null +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -0,0 +1,599 @@ +import { describe, expect, test } from "bun:test"; +import { parse } from "smol-toml"; +import { InputValidationError } from "../../../../errors/errors"; +import { + getBoxGatewayAgentCoreTargetSpec, + getBoxGatewayBedrockTargetSpec, +} from "../../../../handlers/project/shortcuts"; +import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway"; +import { boxGatewaySpec, type ProjectSpec } from "../../../../projectSchemas/project"; +import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; +import { + buildBoxNetwork, + parseResolvedPolicy, + profilePlaces, + type BoxHostSource, + type BoxNetworkHost, +} from "../../boxNetwork"; +import { addBoxGatewayTargets } from "../../boxMemory"; +import { + boxNetworkEdits, + credentialsWriter, + defaultTargetsWriter, + gatewayTargetsWriter, +} from "../../boxNetworkWriters"; +import { boxNetworkRules } from "../../boxProfileResolver-test-support"; +import { renderRuntimeBoxProfile } from "../../templates/boxProfile"; +import { profileKeyPlaces, runtimeProfileContext } from "../context"; +import { deriveRuntimeProfile } from "../derive"; +import { serializeRuntimeProfile } from "../serialize"; +import type { TomlTable } from "../types"; +import { apply } from "./gateway"; + +const PROFILE = ".box/agent/local/profile.toml"; +const GATEWAY = "agent-box-egress"; +const RUNTIME = { + name: "agent", + build: "CodeZip", + entrypoint: "start.py", + codeLocation: "app/agent", + protocol: "HTTP", + modelProvider: "Bedrock", + box: { version: "1.0.0" }, +} as ProjectRuntime; + +/** A Box project whose runtime `agent` has its Box gateway, with `targets`, and `memories`. */ +function project(targets: AgentCoreGatewayTarget[] = [], memories: string[] = []): ProjectSpec { + return { + name: "demo", + projectType: "box", + runtimes: [RUNTIME], + memories: memories.map((name) => ({ name, eventExpiryDuration: 30, strategies: [] })), + credentials: [], + agentCoreGateways: [{ ...boxGatewaySpec("agent"), targets }], + } as unknown as ProjectSpec; +} + +const passthrough = (name: string, endpoint: string): AgentCoreGatewayTarget => ({ + name, + targetType: "passthrough", + passthrough: { endpoint, protocolType: "CUSTOM" }, +}); + +/** A host of the Box network model, named by `source`, with its gateway target if it has one. */ +function host( + authority: string, + source: BoxHostSource | undefined, + target?: string, +): BoxNetworkHost { + const [name, port] = authority.split(":"); + return { + host: name!, + ...(port !== undefined && { port: Number(port) }), + authority, + sources: source ? [source] : [], + outboundAuth: { kind: "none" }, + reachable: target !== undefined, + ...(target !== undefined && { target }), + allowed: target === undefined ? 0 : 3, + samples: 3, + forbiddenBy: target === undefined ? ["deny_all"] : [], + enforcedByBox: [], + }; +} +const entry = (name: string, ...destinations: string[]): BoxHostSource => ({ + kind: "entry", + egressEntry: name, + destinations, +}); +const server = ( + name: string, + destination: string, + secret?: Extract["secret"], +): BoxHostSource => ({ + kind: "mcp", + mcpEntry: name, + destinations: [destination], + ...(secret && { secret }), +}); + +/** The context of the derivation for the local profile `text`, the model's `hosts`, and `targets`. */ +function contextOf( + text: string, + hosts: BoxNetworkHost[], + targets: AgentCoreGatewayTarget[] = [], + region = "us-west-2", +) { + return runtimeProfileContext({ + spec: project(targets), + runtime: RUNTIME, + profileFile: PROFILE, + region, + gateway: { name: GATEWAY, targets }, + hosts, + telemetry: [], + policyFiles: [], + places: profileKeyPlaces(text, PROFILE), + }); +} + +/** What the gateway rule makes of the local profile `text`. */ +function gateway( + text: string, + hosts: BoxNetworkHost[], + targets: AgentCoreGatewayTarget[] = [], + region?: string, +) { + return apply(parse(text) as TomlTable, contextOf(text, hosts, targets, region)); +} + +/** The TOML text of one route's gateway backend, under the table `table`. */ +const backendText = (table: string, target: string, region = "us-west-2") => + `[[${table}.backends]]\n` + + `url = "\${{ inputs.gateway.url }}/${target}"\n` + + 'auth.ref = "aws://"\n' + + 'auth.aws.service = "bedrock-agentcore"\n' + + `auth.aws.region = "${region}"\n`; + +describe("the gateway rule", () => { + test("carries each key it does not own, and a stdio [mcp] server, as the local profile has them", () => { + const text = [ + 'packs = ["box/base", "team/search"]', + 'agent-args = ["--verbose"]', + 'unknown-key = "box refuses it locally first"', + "[agent]", + 'command = ["/bin/echo"]', + "[mcp.notes]", + 'type = "stdio"', + 'command = ["${{ workspace }}/app/agent/notes"]', + "[mcp.notes.network]", + "contain_egress = false", + "[telemetry.records]", + 'kind = "file"', + 'destination = "/tmp/records.jsonl"', + ].join("\n"); + + const { table, problems } = gateway(text, []); + + expect(problems).toEqual([]); + expect(table).toEqual(parse(text)); + }); + + test("sends each host of an [egress] entry to its gateway target, and keeps its other keys", () => { + const text = [ + 'packs = ["box/base"]', + "[egress.github]", + 'destinations = ["api.github.com"]', + 'protocol = "http"', + 'x-later-key = "kept"', + 'secret.ref = "env://GITHUB_TOKEN"', + ].join("\n"); + + const { table, problems } = gateway(text, [ + host("api.github.com", entry("github", "api.github.com"), "egress-github"), + ]); + + expect(problems).toEqual([]); + // The secret moves to the gateway target, which sends the key. + expect(table).toEqual( + parse( + 'packs = ["box/base"]\n' + + "[egress.egress-github]\n" + + 'destinations = ["api.github.com"]\n' + + 'protocol = "http"\n' + + 'x-later-key = "kept"\n' + + backendText("egress.egress-github", "egress-github"), + ), + ); + }); + + test("gives each host of an entry with several destinations its own route, in the region build builds for", () => { + const text = + '[egress.models]\ndestinations = ["api.one.example.com", "api.two.example.com:8443/v1"]\n'; + + const { table } = gateway( + text, + [ + host("api.one.example.com", entry("models", "api.one.example.com"), "egress-models-one"), + host( + "api.two.example.com:8443", + entry("models", "api.two.example.com:8443/v1"), + "egress-models-two", + ), + ], + [], + "eu-central-1", + ); + + expect(table.egress).toEqual( + parse( + '[egress.egress-models-one]\ndestinations = ["api.one.example.com"]\n' + + backendText("egress.egress-models-one", "egress-models-one", "eu-central-1") + + // The route keeps the port of the target's endpoint, and no path. + '[egress.egress-models-two]\ndestinations = ["api.two.example.com:8443"]\n' + + backendText("egress.egress-models-two", "egress-models-two", "eu-central-1"), + ).egress, + ); + }); + + test("adds a route for each target that no entry names, and none for a target build removes", () => { + const targets = [ + passthrough("orders", "https://orders.example.com/v2"), + getBoxGatewayBedrockTargetSpec(), + getBoxGatewayAgentCoreTargetSpec(), + // An earlier build wrote this target, and no host of the profile takes it now. + passthrough("egress-old", "https://old.example.com"), + { name: "lambda", targetType: "lambda" } as unknown as AgentCoreGatewayTarget, + ]; + const text = '[egress.bedrock]\nsecret.ref = "aws://default"\n'; + + const { table } = gateway( + text, + [ + host("bedrock-runtime.us-west-2.amazonaws.com", entry("bedrock"), "bedrock"), + // A host that only a permit names, which gets a target build adds. + host("httpbin.org", { kind: "rule", ruleId: "httpbin_get" }, "egress-httpbin-org"), + ], + targets, + ); + + expect(table.egress).toEqual( + parse( + '[egress.bedrock]\ndestinations = ["bedrock-runtime.us-west-2.amazonaws.com"]\n' + + backendText("egress.bedrock", "bedrock") + + '[egress.orders]\ndestinations = ["orders.example.com"]\n' + + backendText("egress.orders", "orders") + + '[egress.agentcore]\ndestinations = ["bedrock-agentcore.us-west-2.amazonaws.com"]\n' + + backendText("egress.agentcore", "agentcore") + + '[egress.egress-httpbin-org]\ndestinations = ["httpbin.org"]\n' + + backendText("egress.egress-httpbin-org", "egress-httpbin-org"), + ).egress, + ); + }); + + test("removes an entry whose hosts the policy denies, for which the Box network model warns", () => { + const text = '[egress.blocked]\ndestinations = ["blocked.example.com"]\n'; + + const { table, problems, warnings } = gateway(text, [ + host("blocked.example.com", entry("blocked", "blocked.example.com")), + ]); + + expect(table.egress).toBeUndefined(); + expect(problems).toEqual([]); + expect(warnings).toEqual([]); + }); + + test("refuses two passthrough targets for one host, which would give two routes to it", () => { + const targets = [ + passthrough("github", "https://api.github.com"), + passthrough("github-v2", "https://api.github.com/v2"), + ]; + + expect(() => gateway("", [], targets)).toThrow( + new InputValidationError( + "gateway 'agent-box-egress' has two passthrough targets for api.github.com, 'github' and " + + "'github-v2', so runtime 'agent' would get two routes to one host. Remove one of them.", + ), + ); + }); + + test("changes no table it gets", () => { + const text = + '[egress.github]\ndestinations = ["api.github.com"]\nsecret.ref = "env://GITHUB_TOKEN"\n' + + '[mcp.docs]\ntype = "http"\ndestinations = ["docs.example.com"]\nsecret.ref = "env://DOCS"\n'; + const local = parse(text) as TomlTable; + const frozen = structuredClone(local); + + apply( + local, + contextOf(text, [ + host("api.github.com", entry("github", "api.github.com"), "egress-github"), + host("docs.example.com", server("docs", "docs.example.com"), "egress-docs"), + ]), + ); + + expect(local).toEqual(frozen); + }); +}); + +describe("the gateway rule for an HTTP [mcp] server", () => { + const DOCS_SECRET = { + ref: "env://DOCS_TOKEN", + header: "x-api-key", + phantom_prefix: "dk-", + inject: "always", + }; + const DOCS = [ + "[mcp.docs]", + 'type = "http"', + 'destinations = ["docs.example.com"]', + 'description = "kept"', + 'secret.ref = "env://DOCS_TOKEN"', + 'secret.header = "x-api-key"', + 'secret.phantom_prefix = "dk-"', + 'secret.inject = "always"', + ].join("\n"); + + test("keeps the server's name and other keys, gives it its gateway backend, and keeps its env:// secret", () => { + const { table, problems } = gateway(DOCS, [ + host("docs.example.com", server("docs", "docs.example.com", DOCS_SECRET), "egress-docs"), + ]); + + expect(problems).toEqual([]); + // The agent keeps its stand-in, the gateway sends the key, and Box refuses inject beside a backend. + expect(table).toEqual( + parse( + '[mcp.docs]\ntype = "http"\ndestinations = ["docs.example.com"]\ndescription = "kept"\n' + + 'secret.ref = "env://DOCS_TOKEN"\nsecret.header = "x-api-key"\n' + + 'secret.phantom_prefix = "dk-"\n' + + backendText("mcp.docs", "egress-docs"), + ), + ); + expect(table.egress).toBeUndefined(); + }); + + test("keeps no secret that signs, as Box refuses a signed secret beside a backend", () => { + const text = '[mcp.docs]\ntype = "http"\ndestinations = ["docs.example.com"]\n'; + + const { table } = gateway(text, [ + host( + "docs.example.com", + server("docs", "docs.example.com", { ref: "aws://default" }), + "egress-docs", + ), + ]); + + expect(table.mcp).toEqual( + parse( + '[mcp.docs]\ntype = "http"\ndestinations = ["docs.example.com"]\n' + + backendText("mcp.docs", "egress-docs"), + ).mcp, + ); + }); + + test("writes a target that serves a server that only a pack declares as that server", () => { + const { table } = gateway( + "", + [host("docs.example.com", server("docs", "docs.example.com"), "docs")], + [passthrough("docs", "https://docs.example.com")], + ); + + expect(table.egress).toBeUndefined(); + expect(table.mcp).toEqual( + parse( + '[mcp.docs]\ntype = "http"\ndestinations = ["docs.example.com"]\n' + + backendText("mcp.docs", "docs"), + ).mcp, + ); + }); + + test("removes a server whose host the policy denies, for which the Box network model warns", () => { + const text = '[mcp.denied]\ntype = "http"\ndestinations = ["denied.example.com"]\n'; + + const { table, problems } = gateway(text, [ + host("denied.example.com", server("denied", "denied.example.com")), + ]); + + expect(table.mcp).toBeUndefined(); + expect(problems).toEqual([]); + }); +}); + +/** + * One project, given to the old renderer and to the derivation: the local profile's own text, what + * Box resolves it to, and the policy. The Runtime profile that staging renders today, from + * agentcore.json as build writes it, has the same `[egress]` and HTTP `[mcp]` tables as the + * profile that build derives from the local profile. + */ +describe("the gateway rule and renderRuntimeBoxProfile", () => { + const TEXT = [ + 'packs = ["box/base", "box/bedrock"]', + 'policies = ["policy.dw"]', + "", + "[agent]", + 'command = ["/bin/echo"]', + "", + "[egress.bedrock]", + 'secret.ref = "aws://default"', + "", + "[egress.github]", + 'destinations = ["api.github.com"]', + 'secret.ref = "env://GITHUB_TOKEN"', + "", + "[egress.models]", + 'destinations = ["api.one.example.com", "api.two.example.com"]', + "", + "[egress.blocked]", + 'destinations = ["blocked.example.com"]', + "", + "[mcp.docs]", + 'type = "http"', + 'destinations = ["docs.example.com"]', + 'secret.ref = "env://DOCS_TOKEN"', + 'secret.header = "x-api-key"', + "", + "[mcp.notes]", + 'type = "stdio"', + 'command = ["/usr/bin/notes"]', + ].join("\n"); + /** The `[egress]` and `[mcp]` tables that Box resolves the profile to, with box/bedrock. */ + const EGRESS = { + bedrock: { + destinations: ["bedrock-runtime.us-west-2.amazonaws.com"], + secret: { ref: "aws://default" }, + }, + github: { destinations: ["api.github.com"], secret: { ref: "env://GITHUB_TOKEN" } }, + models: { destinations: ["api.one.example.com", "api.two.example.com"] }, + blocked: { destinations: ["blocked.example.com"] }, + }; + const MCP = { + docs: { + type: "http", + destinations: ["docs.example.com"], + secret: { ref: "env://DOCS_TOKEN", header: "x-api-key" }, + }, + notes: { type: "stdio", command: ["/usr/bin/notes"] }, + }; + const HR = 'action == Box::Action::"http:request"'; + const NC = 'action == Box::Action::"net:connect"'; + const POLICY = + `@id("no_blocked") forbid (principal, ${HR}, resource) when { context.input.host == "blocked.example.com" };\n` + + `@id("httpbin_connect") permit (principal, ${NC}, resource) when { context.input.host == "httpbin.org" };\n` + + `@id("httpbin_get") permit (principal, ${HR}, resource) when { context.input.host == "httpbin.org" && context.input.path == "/get" };\n`; + const TARGETS = [ + // The user's own target, which no host of the profile takes. + passthrough("orders", "https://orders.example.com"), + // A target an earlier build wrote for a host the profile no longer names. + passthrough("egress-old", "https://old.example.com"), + ]; + + /** A local profile: its text, the tables Box resolves it to, and its policy. */ + interface Fixture { + readonly text: string; + readonly egress: Record; + readonly mcp: Record; + readonly policy: string; + } + const FIXTURE: Fixture = { text: TEXT, egress: EGRESS, mcp: MCP, policy: POLICY }; + + /** + * What staging renders today for `spec`, from agentcore.json as build then writes it, and what + * build derives from the local profile for it. + */ + function bothProfiles(spec: ProjectSpec, { text, egress, mcp, policy }: Fixture = FIXTURE) { + const withDefaults = structuredClone(spec); + addBoxGatewayTargets(withDefaults, "/project", "us-west-2"); + const targets = withDefaults.agentCoreGateways[0]!.targets; + const { parsed, failures } = parseResolvedPolicy( + { + path: PROFILE, + egress, + mcp, + policyFiles: ["policy.dw"], + places: profilePlaces(text, PROFILE), + source: { table: parse(text) as TomlTable, places: profileKeyPlaces(text, PROFILE) }, + }, + `${policy}${boxNetworkRules(egress, mcp)}`, + [{ file: ".box/agent/local/policy.dw", text: policy }], + ); + const network = buildBoxNetwork(parsed, failures, { + spec, + runtime: RUNTIME, + gateway: GATEWAY, + region: "us-west-2", + targets, + grantedActions: [], + }); + const written = boxNetworkEdits( + [credentialsWriter, gatewayTargetsWriter, defaultTargetsWriter], + [network], + { + spec, + projectRoot: "/project", + env: { GITHUB_TOKEN: "dummy-github", DOCS_TOKEN: "dummy-docs" }, + envLocal: {}, + }, + ).spec; + const derived = deriveRuntimeProfile( + parse(text) as TomlTable, + runtimeProfileContext({ + spec, + runtime: RUNTIME, + profileFile: PROFILE, + region: "us-west-2", + gateway: { name: GATEWAY, targets }, + hosts: network.hosts, + telemetry: [], + policyFiles: network.policyFiles, + places: profileKeyPlaces(text, PROFILE), + }), + ); + return { + network, + written, + rendered: parse(renderRuntimeBoxProfile(written, RUNTIME, network)) as TomlTable, + derived, + }; + } + const http = (mcp: unknown) => + Object.fromEntries( + Object.entries((mcp ?? {}) as TomlTable).filter( + ([, entry]) => (entry as { type?: unknown }).type === "http", + ), + ); + + test("give the same [egress] and HTTP [mcp] tables on the first build", () => { + const { network, rendered, derived } = bothProfiles(project(TARGETS, ["agentMemory"])); + + expect(network.failures).toEqual([]); + expect(derived.problems).toEqual([]); + expect(Object.keys(rendered.egress as TomlTable).sort()).toEqual([ + "agentcore", + "bedrock", + "egress-github", + "egress-httpbin-org", + "egress-models-api-one-example-com", + "egress-models-api-two-example-com", + "orders", + ]); + expect(Object.keys(http(rendered.mcp))).toEqual(["docs"]); + expect(derived.profile.egress).toEqual(rendered.egress); + expect(http(derived.profile.mcp)).toEqual(http(rendered.mcp)); + // The model that build keeps holds the same derived profile. + expect(network.runtimeProfile?.egress).toEqual(rendered.egress); + expect(http(network.runtimeProfile?.mcp)).toEqual(http(rendered.mcp)); + }); + + test("give the same tables on the next build, from the agentcore.json of the first build", () => { + const first = bothProfiles(project(TARGETS, ["agentMemory"])).written; + const { network, rendered, derived } = bothProfiles(first); + + expect(network.failures).toEqual([]); + expect(first.agentCoreGateways[0]!.targets.map(({ name }) => name)).toContain("egress-github"); + expect(derived.profile.egress).toEqual(rendered.egress); + expect(http(derived.profile.mcp)).toEqual(http(rendered.mcp)); + }); + + test("give the same tables for a target name that TOML must quote, and a port", () => { + const { rendered, derived } = bothProfiles( + project([passthrough("tools.v2", "https://tools.example.com:8443/api")]), + ); + + const quoted = parse( + '[egress."tools.v2"]\ndestinations = ["tools.example.com:8443"]\n' + + backendText('egress."tools.v2"', "tools.v2"), + ).egress as TomlTable; + expect((rendered.egress as TomlTable)["tools.v2"]).toEqual(quoted["tools.v2"]); + expect(derived.profile.egress).toEqual(rendered.egress); + expect(parse(serializeRuntimeProfile(derived.profile)).egress as unknown).toEqual( + rendered.egress, + ); + }); + + test("give no second problem for an entry that the Box network model rejects, and no route", () => { + const text = + '[egress.wide]\ndestinations = ["*.wide.example.com"]\n' + + '[mcp.pathed]\ntype = "http"\ndestinations = ["docs.example.com/mcp"]\n'; + const egress = { wide: { destinations: ["*.wide.example.com"] } }; + const mcp = { pathed: { type: "http", destinations: ["docs.example.com/mcp"] } }; + + const { network, rendered, derived } = bothProfiles(project(), { + text, + egress, + mcp, + policy: "", + }); + + // The model gives one problem for each entry, where the entry is, and build stops. + expect( + network.failures.map(({ code, egressEntry, mcpEntry }) => [code, egressEntry ?? mcpEntry]), + ).toEqual([ + ["EGRESS_WILDCARD_DESTINATION", "wide"], + ["MCP_DESTINATION_NOT_ONE_HOST", "pathed"], + ]); + expect(derived.problems).toEqual([]); + expect(derived.profile.egress).toEqual(rendered.egress); + expect(derived.profile.mcp).toBeUndefined(); + expect(rendered.mcp).toBeUndefined(); + }); +}); diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index 37dd3c07e..df20b3b6c 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -1,15 +1,213 @@ /** - * Rule 2 of the derivation: the calls of the box go through its Box gateway on AgentCore Runtime. - * To do: replace each `[egress.]` whose host gets a gateway target with one - * `[egress.]` route for each target, with one backend to `${{ inputs.gateway.url }}/` - * signed with a bare `aws://` for the gateway region, and no secret (the target sends it); add the - * routes of the targets build adds (`bedrock`, `agentcore`, permit-only hosts); give each HTTP - * `[mcp.]` its gateway backend and keep its `env://` secret. It absorbs, from - * templates/boxProfile.ts: runtimeGatewayRoutes, runtimeGatewayRouteSection, - * runtimeMcpServerSection, runtimeMcpServers, and runtimeGatewayBackend. - */ -import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; - -export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { - return { table: { ...table }, problems: [], warnings: [] }; + * Rule 2 of the derivation: on AgentCore Runtime, each call of the box goes through the runtime's + * Box gateway. Each passthrough target of that gateway, as build writes the gateway, gets one + * route: the box sends the calls to the target's host to `${{ inputs.gateway.url }}/`, and + * signs them for the gateway in the build region with a bare `aws://`, the execution role. The + * gateway then calls the host with the target's own auth. + * + * | Local profile | Runtime profile | + * | --- | --- | + * | `[egress.]`, for each of its hosts with a target | `[egress.]`, the other keys kept, no `secret` | + * | HTTP `[mcp.]` | `[mcp.]`, the other keys kept, only an `env://` secret | + * | a target that no entry of the profile names | `[egress.]`, or the `[mcp]` server it serves | + * | an entry whose hosts the policy denies | removed; the Box network model warns for it | + * | an entry with no host in the Box network model | removed; the model fails the entry, and build stops | + * + * A stdio `[mcp.]` stays as it is: the `refusals` and `paths` rules own it. + */ +import { InputValidationError } from "../../../../errors/errors"; +import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway"; +import type { BoxHostSource, BoxNetworkHost } from "../../boxNetwork"; +import { BOX_EGRESS_TARGET_PREFIX } from "../../boxNetwork/egress"; +import { gatewayTargetFor } from "../../boxNetwork/projectSpec"; +import { + RUNTIME_INPUTS, + type RuleResult, + type RuntimeProfileContext, + type TomlTable, +} from "../types"; + +/** The signer of each gateway backend: the AWS default credential chain, the execution role. */ +const RUNTIME_AWS_SIGNER = "aws://"; + +type McpSource = Extract; + +/** One route of the Runtime profile: a passthrough target of the Box gateway and its host. */ +interface GatewayRoute { + readonly target: string; + /** `host`, or `host:port`, of the target's endpoint. */ + readonly host: string; + /** The HTTP MCP server of the Box network model that the target serves. */ + readonly server?: McpSource; +} + +const isTable = (value: unknown): value is TomlTable => + typeof value === "object" && value !== null && !Array.isArray(value); + +export function apply(table: Readonly, context: RuntimeProfileContext): RuleResult { + const routes = gatewayRoutes(context); + const written = new Set(); + + const egress: TomlTable = {}; + for (const [name, entry] of Object.entries(isTable(table.egress) ? table.egress : {})) { + if (!isTable(entry)) { + egress[name] = entry; + continue; + } + const hosts = context.hosts.filter((host) => + host.sources.some((source) => source.kind === "entry" && source.egressEntry === name), + ); + for (const route of routesOf(hosts, routes)) { + egress[route.target] = egressRoute(entry, route, context.region); + written.add(route.target); + } + } + + const mcp: TomlTable = {}; + for (const [name, entry] of Object.entries(isTable(table.mcp) ? table.mcp : {})) { + if (!isTable(entry) || !isHttpServer(entry)) { + mcp[name] = entry; + continue; + } + const route = routes.find(({ server }) => server?.mcpEntry === name); + if (route?.server === undefined) continue; + mcp[name] = mcpServer(entry, route, route.server, context.region); + written.add(route.target); + } + + for (const route of routes) { + if (written.has(route.target)) continue; + if (route.server) { + mcp[route.server.mcpEntry] = mcpServer({}, route, route.server, context.region); + } else { + egress[route.target] = egressRoute({}, route, context.region); + } + } + + // The two tables keep their place in the profile, and an empty one goes. + const result: TomlTable = { ...table, egress, mcp }; + if (Object.keys(egress).length === 0) delete result.egress; + if (Object.keys(mcp).length === 0) delete result.mcp; + return { table: result, problems: [], warnings: [] }; +} + +/** + * The routes of the runtime: one for each passthrough target of its Box gateway, in the order of + * the gateway's targets once build writes them. Build keeps each target it does not manage where + * it is, keeps each `egress-` target that a host takes, removes the other `egress-` targets, and + * adds the target of each other host at the end. Throws for two targets for one host, which would + * give the box two routes to that host. + */ +function gatewayRoutes(context: RuntimeProfileContext): GatewayRoute[] { + const managed = (name: string) => name.startsWith(BOX_EGRESS_TARGET_PREFIX); + const served = context.hosts.filter( + (host): host is BoxNetworkHost & { readonly target: string } => + host.target !== undefined && managed(host.target), + ); + const targets: AgentCoreGatewayTarget[] = []; + for (const target of context.gateway.targets) { + if (!managed(target.name)) { + targets.push(target); + continue; + } + const host = served.find((candidate) => candidate.target === target.name); + if (host) targets.push(gatewayTargetFor(host)); + } + for (const host of served) { + if (!targets.some(({ name }) => name === host.target)) targets.push(gatewayTargetFor(host)); + } + + const passthrough = targets.filter( + (target) => target.targetType === "passthrough" && target.passthrough, + ); + const hostOf = (target: AgentCoreGatewayTarget) => new URL(target.passthrough!.endpoint).host; + const byHost = new Map(); + for (const target of passthrough) { + const other = byHost.get(hostOf(target)); + if (other !== undefined) { + throw new InputValidationError( + `gateway '${context.gateway.name}' has two passthrough targets for ${hostOf(target)}, ` + + `'${other}' and '${target.name}', so runtime '${context.runtime.name}' would get two ` + + "routes to one host. Remove one of them.", + ); + } + byHost.set(hostOf(target), target.name); + } + return passthrough.map((target) => { + const server = context.hosts + .filter((host) => host.target === target.name) + .map(mcpSourceOf) + .find((source) => source !== undefined); + return { target: target.name, host: hostOf(target), ...(server && { server }) }; + }); +} + +/** The routes of `hosts`, in the order of the hosts; a host with no route has none. */ +function routesOf( + hosts: readonly BoxNetworkHost[], + routes: readonly GatewayRoute[], +): GatewayRoute[] { + return hosts.flatMap((host) => routes.filter((route) => route.target === host.target)); +} + +function mcpSourceOf(host: BoxNetworkHost): McpSource | undefined { + return host.sources.find((source): source is McpSource => source.kind === "mcp"); +} + +/** Whether `entry` is an HTTP MCP server: it has no `command`, and it is `http` or names a host. */ +function isHttpServer(entry: Readonly): boolean { + if ("command" in entry || entry.type === "stdio") return false; + return entry.type === "http" || "url" in entry || "destinations" in entry; +} + +/** + * The `[egress.]` route of `route`, with each key of `entry` that the gateway form does not + * set. Its secret goes: the gateway target sends the credential. + */ +function egressRoute(entry: Readonly, route: GatewayRoute, region: string): TomlTable { + const { destinations: _destinations, secret: _secret, backends: _backends, ...kept } = entry; + return { destinations: [route.host], ...kept, backends: [gatewayBackend(route, region)] }; +} + +/** + * The HTTP `[mcp.]` server of `route`, with each key of `entry` that the gateway form does not + * set. The server keeps its name, so the box still decides each `mcp:call`. An `env://` secret of + * the server, as Box resolves it, stays without `inject`: the agent keeps its stand-in, and the + * gateway sends the key. Box refuses a signed secret beside a backend, so that one goes. + */ +function mcpServer( + entry: Readonly, + route: GatewayRoute, + server: McpSource, + region: string, +): TomlTable { + const { + type: _type, + destinations: _destinations, + secret: _secret, + backends: _backends, + ...kept + } = entry; + const secret = server.secret?.ref.startsWith("env://") + ? Object.fromEntries( + Object.entries(server.secret).filter( + ([field, value]) => field !== "inject" && value !== undefined, + ), + ) + : undefined; + return { + type: "http", + destinations: [route.host], + ...(secret && { secret }), + ...kept, + backends: [gatewayBackend(route, region)], + }; +} + +/** The backend of a route: the route's gateway target, signed for the gateway in `region`. */ +function gatewayBackend(route: GatewayRoute, region: string): TomlTable { + return { + url: `${RUNTIME_INPUTS.gatewayUrl}/${route.target}`, + auth: { ref: RUNTIME_AWS_SIGNER, aws: { service: "bedrock-agentcore", region } }, + }; } From 559ae024c834f205d3ea07a871e52ec9f49a7cfa Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 13:42:06 -0800 Subject: [PATCH 07/51] feat(box): Add the Runtime values to the Runtime box profile from the local profile The additions rule of deriveRuntimeProfile did not change a table. Thus the Runtime profile from deriveRuntimeProfile had no box/agentcore pack, no Runtime command, and no execution role on the CloudWatch targets. This commit gives the rule its work. The rule moves no path, because the paths rule comes after it. Build does not use this Runtime profile at this time. - packs: the packs of the user stay in their sequence. The rule adds box/agentcore, and box/agentcore-codezip for CodeZip, when the list does not have them. - [profile] name: the name of the project. - [options] bedrock.region: the build region, as a dotted key or as a key in quotes, or when the profile has box/bedrock. The other options stay. - [agent] command: the command of the template becomes the Runtime command of the template. A command of the user stays, but without --reload and --reload-dir. - [agent.env]: LOCAL_DEV goes. A value of the template becomes its Runtime value. A variable of the template that the user removed stays removed. A value of the user stays. The rule sets AWS_REGION (only without box/bedrock), AWS_DEFAULT_REGION, and the 2 AWS stand-ins, when the user does not set them. On CodeZip, PYTHONPATH starts with the ffi shim. - [agent.filesystem]: each Runtime grant of the template comes first. A grant of the template that the user removed stays removed. Each grant of the user follows. An empty list goes. - [[agent.ingress]]: the ingress of the template becomes its Runtime ingress. Each other ingress listens on 0.0.0.0, on the same port. - [telemetry]: each CloudWatch target keeps its keys. It gets secret.ref = "aws://", and the deploy region when it has no region. The rule adds each CloudWatch target of the context that the local profile does not have. A target of a different type stays. - policies, and each key that the rule does not change, stay. - runtimeProfileHeader gives the comment lines of the Runtime profile. Tests: rules/additions.test.ts. One test gives each template that agentcore create writes to renderRuntimeBoxProfile and to deriveRuntimeProfile: CodeZip with HTTP, MCP, A2A, and AGUI, and a container with HTTP and MCP, with Bedrock or OpenAI, with and without memory, and with and without CloudWatch telemetry and policies. For all 96 inputs, the packs, policies, profile, options, agent, and telemetry tables are the same. Other tests show each change above, a key that build does not know, and that the rule changes no table that it gets. For each of 29 mutations of the rule, 1 or more tests show an error. box 0.1.11-linux-preview.6 on macOS (box profile show --full) accepts the CodeZip and container profiles from deriveRuntimeProfile. --- .../runtimeProfile/rules/additions.test.ts | 500 ++++++++++++++++++ .../project/runtimeProfile/rules/additions.ts | 371 ++++++++++++- 2 files changed, 855 insertions(+), 16 deletions(-) create mode 100644 src/core/project/runtimeProfile/rules/additions.test.ts diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts new file mode 100644 index 000000000..da3a1245d --- /dev/null +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -0,0 +1,500 @@ +import { describe, expect, test } from "bun:test"; +import { parse } from "smol-toml"; +import type { ScaffoldRuntimeInput } from "../../../../handlers/project/types"; +import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway"; +import { boxGatewaySpec, type ProjectSpec } from "../../../../projectSchemas/project"; +import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; +import { cloudWatchTelemetry, withDeployRegion, type CloudWatchTelemetry } from "../../boxNetwork"; +import { renderBoxProfile, renderRuntimeBoxProfile } from "../../templates/boxProfile"; +import { runtimeProfileContext } from "../context"; +import { deriveRuntimeProfile } from "../derive"; +import { serializeRuntimeProfile } from "../serialize"; +import type { TomlTable } from "../types"; +import { apply, runtimeProfileHeader } from "./additions"; + +const PROFILE_FILE = ".box/agent/local/profile.toml"; +/** The region create resolved, which the local profile names: not the build region. */ +const CREATE_REGION = "us-east-1"; +const BUILD_REGION = "us-west-2"; + +type Build = "CodeZip" | "Container"; +type Protocol = NonNullable; + +function runtimeOf(build: Build, protocol: Protocol = "HTTP", modelProvider = "Bedrock") { + return { + name: "agent", + build, + entrypoint: build === "CodeZip" ? "start.py" : "main.py", + codeLocation: "app/agent", + protocol, + modelProvider, + box: { version: "1.0.0" }, + } as ProjectRuntime; +} + +function passthrough(name: string, endpoint: string): AgentCoreGatewayTarget { + return { + name, + targetType: "passthrough", + passthrough: { endpoint }, + outboundAuth: { type: "NONE" }, + } as AgentCoreGatewayTarget; +} + +/** A Box project with `runtime`, its Box gateway with the targets build adds, and `memories`. */ +function specOf(runtime: ProjectRuntime, memories: readonly string[] = []) { + const targets = [ + passthrough("bedrock", `https://bedrock-runtime.${BUILD_REGION}.amazonaws.com`), + ...(memories.length > 0 + ? [passthrough("agentcore", `https://bedrock-agentcore.${BUILD_REGION}.amazonaws.com`)] + : []), + ]; + return { + name: "demo", + runtimes: [runtime], + memories: memories.map((name) => ({ name, eventExpiryDuration: 30, strategies: [] })), + projectType: "box", + agentCoreGateways: [{ ...boxGatewaySpec("agent"), targets }], + } as unknown as ProjectSpec; +} + +function contextOf( + runtime: ProjectRuntime, + options: { + memories?: readonly string[]; + telemetry?: readonly CloudWatchTelemetry[]; + policyFiles?: readonly string[]; + } = {}, +) { + const spec = specOf(runtime, options.memories); + return runtimeProfileContext({ + spec, + runtime, + profileFile: PROFILE_FILE, + region: BUILD_REGION, + gateway: { + name: spec.agentCoreGateways[0]!.name, + targets: spec.agentCoreGateways[0]!.targets, + }, + hosts: [], + telemetry: options.telemetry ?? [], + policyFiles: options.policyFiles ?? [], + places: new Map(), + }); +} + +/** The local profile that `agentcore create` writes for `runtime`, as a table. */ +function createdProfile(runtime: ProjectRuntime): TomlTable { + const input = { + runtimeName: runtime.name, + build: runtime.build, + language: "Python", + framework: "strands", + protocol: runtime.protocol, + modelProvider: runtime.modelProvider, + boxTemplate: true, + } as ScaffoldRuntimeInput; + return parse(renderBoxProfile("demo", input, CREATE_REGION, "local")!) as TomlTable; +} + +/** The `[telemetry]` of a local profile: a CloudWatch target of each kind, signed under dev. */ +const CLOUDWATCH: TomlTable = { + logs: { + kind: "cloudwatch_logs", + region: "eu-west-1", + log_group: "/aws/box", + log_stream: "agent", + include: ["logs", "trace"], + secret: { ref: "aws://default" }, + }, + "x-ray": { kind: "cloudwatch_traces", secret: { ref: "aws://Admin-personal" } }, +}; + +/** The tables that the additions rule owns, which the old renderer wrote. */ +const OWNED = ["packs", "policies", "profile", "options", "agent", "telemetry"] as const; + +const agentOf = (profile: TomlTable) => profile.agent as Record; + +describe("deriveRuntimeProfile on the created templates", () => { + const cases = ( + [ + ["CodeZip", "HTTP"], + ["CodeZip", "MCP"], + ["CodeZip", "A2A"], + ["CodeZip", "AGUI"], + ["Container", "HTTP"], + ["Container", "MCP"], + ] as const + ).flatMap(([build, protocol]) => + ["Bedrock", "OpenAI"].flatMap((provider) => + [[], ["agentMemory"]].flatMap((memories) => + [false, true].map((extras) => ({ build, protocol, provider, memories, extras })), + ), + ), + ); + + test.each(cases)( + "gives the tables the old renderer wrote ($build $protocol $provider, memories $memories, telemetry and policies $extras)", + ({ build, protocol, provider, memories, extras }) => { + const runtime = runtimeOf(build, protocol, provider); + const local = createdProfile(runtime); + if (extras) { + local.policies = ["policy.dw"]; + local.telemetry = structuredClone(CLOUDWATCH); + } + const telemetry = withDeployRegion( + cloudWatchTelemetry(local), + BUILD_REGION, + PROFILE_FILE, + ).telemetry; + const policyFiles = extras ? ["policy.dw"] : []; + const spec = specOf(runtime, memories); + const old = parse( + renderRuntimeBoxProfile(spec, runtime, { + policyFiles, + region: BUILD_REGION, + hosts: [], + telemetry, + }), + ) as TomlTable; + + const { profile, problems } = deriveRuntimeProfile( + local, + contextOf(runtime, { memories, telemetry, policyFiles }), + ); + + expect(problems).toEqual([]); + for (const key of OWNED) expect([key, profile[key]]).toEqual([key, old[key]]); + }, + ); +}); + +describe("the additions rule", () => { + const CODEZIP = runtimeOf("CodeZip"); + const CONTAINER = runtimeOf("Container"); + + test("carries each key and table that it does not own, with keys that build does not know", () => { + const local: TomlTable = { + ...createdProfile(CODEZIP), + "agent-args": ["--verbose"], + "future-key": { anything: [1, 2] }, + tool: { notes: { program: "/usr/bin/notes" } }, + mcp: { files: { type: "stdio", command: ["/usr/bin/files"] } }, + }; + (local.agent as TomlTable).when = { "future-agent-key": true }; + + const { table, problems } = apply(local, contextOf(CODEZIP)); + + expect(problems).toEqual([]); + expect(table["agent-args"]).toEqual(["--verbose"]); + expect(table["future-key"]).toEqual({ anything: [1, 2] }); + expect(table.tool).toEqual(local.tool); + expect(table.mcp).toEqual(local.mcp); + expect(table.egress).toEqual(local.egress); + expect(agentOf(table).when).toEqual({ "future-agent-key": true }); + }); + + test("changes no table that it gets", () => { + const local = { ...createdProfile(CODEZIP), telemetry: structuredClone(CLOUDWATCH) }; + const before = structuredClone(local); + + apply(local, contextOf(CODEZIP)); + + expect(local).toEqual(before); + }); + + test("keeps the user's packs in their order, then adds the Runtime packs once", () => { + const packs = ["box/gh", "box/base", "box/bedrock"]; + + expect(apply({ packs }, contextOf(CODEZIP)).table.packs).toEqual([ + ...packs, + "box/agentcore", + "box/agentcore-codezip", + ]); + expect(apply({ packs }, contextOf(CONTAINER)).table.packs).toEqual([...packs, "box/agentcore"]); + expect( + apply({ packs: ["box/agentcore", "box/base"] }, contextOf(CONTAINER)).table.packs, + ).toEqual(["box/agentcore", "box/base"]); + expect(apply({}, contextOf(CONTAINER)).table.packs).toEqual(["box/agentcore"]); + }); + + test("names the profile for the project, and keeps the other [profile] keys", () => { + const local = { profile: { name: "demo-agent", description: "mine" } }; + + expect(apply(local, contextOf(CODEZIP)).table.profile).toEqual({ + name: "demo", + description: "mine", + }); + }); + + test("sets bedrock.region to the build region, and keeps the other options", () => { + const dotted = { options: { bedrock: { region: CREATE_REGION }, other: { input: "x" } } }; + const quoted = { options: { "bedrock.region": CREATE_REGION } }; + + expect(apply(dotted, contextOf(CODEZIP)).table.options).toEqual({ + bedrock: { region: BUILD_REGION }, + other: { input: "x" }, + }); + expect(apply(quoted, contextOf(CODEZIP)).table.options).toEqual({ + "bedrock.region": BUILD_REGION, + }); + expect(apply({ packs: ["box/bedrock"] }, contextOf(CODEZIP)).table.options).toEqual({ + bedrock: { region: BUILD_REGION }, + }); + expect(apply({ packs: ["box/base"] }, contextOf(CODEZIP)).table.options).toBeUndefined(); + }); + + describe("[agent] command", () => { + test("gives the template's own command its Runtime command", () => { + expect(agentOf(apply(createdProfile(CODEZIP), contextOf(CODEZIP)).table).command).toEqual([ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081", + ]); + }); + + test("removes --reload and --reload-dir from a command of the user, and moves no path", () => { + const local = createdProfile(CODEZIP); + agentOf(local).command = [ + "${{ workspace }}/app/agent/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--reload", + "--reload-dir", + "${{ workspace }}/app/agent", + "--reload-dir=${{ workspace }}/app/agent/lib", + "--log-level", + "debug", + ]; + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).command).toEqual([ + "${{ workspace }}/app/agent/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--log-level", + "debug", + ]); + }); + }); + + describe("[agent.env]", () => { + test("removes LOCAL_DEV, swaps the template's values, adds the Runtime's, and keeps the user's", () => { + const local = createdProfile(CODEZIP); + agentOf(local).env = { + ...agentOf(local).env, + LOCAL_DEV: "0", + LOG_LEVEL: "debug", + DATA: "${{ workspace }}/app/agent/data", + }; + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).env).toEqual({ + PORT: "8081", + PYTHONPATH: "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + PYTHONUTF8: "1", + PYTHONUNBUFFERED: "1", + AWS_DEFAULT_REGION: "${{ inputs.aws.region }}", + AWS_ACCESS_KEY_ID: "box-stand-in", + AWS_SECRET_ACCESS_KEY: "box-stand-in", + LOG_LEVEL: "debug", + DATA: "${{ workspace }}/app/agent/data", + }); + }); + + test("keeps a template variable that the user changed, and leaves out one the user removed", () => { + const local = createdProfile(CONTAINER); + const { PYTHONUNBUFFERED: _removed, ...env } = agentOf(local).env; + agentOf(local).env = { ...env, PORT: "9999", AWS_DEFAULT_REGION: "eu-west-1" }; + + const result = agentOf(apply(local, contextOf(CONTAINER)).table).env; + + expect(result.PORT).toBe("9999"); + expect(result.AWS_DEFAULT_REGION).toBe("eu-west-1"); + expect(result).not.toHaveProperty("PYTHONUNBUFFERED"); + expect(result).not.toHaveProperty("PYTHONPATH"); + }); + + test("sets AWS_REGION only when the profile imports no box/bedrock", () => { + const local = createdProfile(CODEZIP); + + const bedrock = agentOf(apply(local, contextOf(CODEZIP)).table).env; + const other = agentOf(apply({ ...local, packs: ["box/base"] }, contextOf(CODEZIP)).table).env; + + expect(bedrock).not.toHaveProperty("AWS_REGION"); + expect(other.AWS_REGION).toBe("${{ inputs.aws.region }}"); + expect(other.AWS_DEFAULT_REGION).toBe("${{ inputs.aws.region }}"); + }); + + test("puts the ffi shim first in a PYTHONPATH of the user on CodeZip, and not on a container", () => { + const env = { PYTHONPATH: "${{ workspace }}/app/agent/lib" }; + + expect(agentOf(apply({ agent: { env } }, contextOf(CODEZIP)).table).env.PYTHONPATH).toBe( + "${{ inputs.code.dir }}/.box-dist/ffi:${{ workspace }}/app/agent/lib", + ); + expect(agentOf(apply({ agent: { env } }, contextOf(CONTAINER)).table).env.PYTHONPATH).toBe( + "${{ workspace }}/app/agent/lib", + ); + }); + + test("sets the region, the AWS stand-ins, and the ffi PYTHONPATH whatever the template's Runtime env", () => { + const openAi = runtimeOf("CodeZip", "HTTP", "OpenAI"); + const context = contextOf(openAi); + const runtime = structuredClone(context.template.runtime); + (runtime.agent as TomlTable).env = { PORT: "8081", PYTHONUTF8: "1" }; + const template = { ...context.template, runtime }; + + const env = agentOf(apply(createdProfile(openAi), { ...context, template }).table).env; + + expect(env).toEqual({ + PORT: "8081", + PYTHONUTF8: "1", + AWS_REGION: "${{ inputs.aws.region }}", + AWS_DEFAULT_REGION: "${{ inputs.aws.region }}", + AWS_ACCESS_KEY_ID: "box-stand-in", + AWS_SECRET_ACCESS_KEY: "box-stand-in", + PYTHONPATH: "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + }); + }); + }); + + describe("[agent.filesystem]", () => { + test("gives the template's grants their Runtime grants, and keeps each grant of the user", () => { + const local = createdProfile(CODEZIP); + const filesystem = agentOf(local).filesystem; + filesystem.read.push("${{ workspace }}/app/agent/data", "/usr/lib64"); + filesystem.deny_write.push("${{ workspace }}/app/agent/secrets"); + filesystem.write = ["/tmp/agent"]; + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).filesystem).toEqual({ + read: [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64", + "${{ workspace }}/app/agent/data", + ], + exec: ["${{ inputs.code.dir }}", "${{ inputs.python.prefix }}"], + deny_write: ["${{ workspace }}/app/agent/secrets"], + write: ["/tmp/agent"], + }); + }); + + test("leaves out a grant that the user removed from a container's template", () => { + const local = createdProfile(CONTAINER); + const filesystem = agentOf(local).filesystem; + filesystem.exec = filesystem.exec.filter((grant: unknown) => grant !== "/usr/local/bin"); + + expect(agentOf(apply(local, contextOf(CONTAINER)).table).filesystem.exec).toEqual( + filesystem.exec, + ); + }); + }); + + test("gives the template's ingress its Runtime ingress, and puts each other on 0.0.0.0", () => { + const local = createdProfile(CODEZIP); + agentOf(local).ingress.push({ listen: "127.0.0.1:9100", workload_port: 9101 }); + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).ingress).toEqual([ + { listen: "0.0.0.0:8080", workload_port: 8081 }, + { listen: "0.0.0.0:9100", workload_port: 9101 }, + ]); + }); + + describe("[telemetry]", () => { + test("signs each CloudWatch target with a bare aws://, and keeps its keys and its region", () => { + const local = { + telemetry: { + logs: { ...(CLOUDWATCH.logs as TomlTable), batch: { max: 5 } }, + "x-ray": CLOUDWATCH["x-ray"], + }, + }; + + expect(apply(local, contextOf(CODEZIP)).table.telemetry).toEqual({ + logs: { + ...(CLOUDWATCH.logs as TomlTable), + batch: { max: 5 }, + secret: { ref: "aws://" }, + }, + "x-ray": { kind: "cloudwatch_traces", region: BUILD_REGION, secret: { ref: "aws://" } }, + }); + }); + + test("gives a target with no region the region of the box network model", () => { + const local = { telemetry: { "x-ray": CLOUDWATCH["x-ray"] } }; + const telemetry = [ + { name: "x-ray", kind: "cloudwatch_traces", region: "ap-south-1" } as const, + ]; + + expect(apply(local, contextOf(CODEZIP, { telemetry })).table.telemetry).toEqual({ + "x-ray": { kind: "cloudwatch_traces", region: "ap-south-1", secret: { ref: "aws://" } }, + }); + }); + + test("leaves a target of another kind as it is", () => { + const others = { + records: { kind: "file", destination: "/tmp/records.jsonl" }, + langfuse: { kind: "langfuse", secret: { ref: "env://LANGFUSE_AUTH" } }, + }; + + expect(apply({ telemetry: others }, contextOf(CODEZIP)).table.telemetry).toEqual(others); + }); + + test("adds each CloudWatch target of the context that the local profile does not declare", () => { + const telemetry: CloudWatchTelemetry[] = [ + { + name: "pack-logs", + kind: "cloudwatch_logs", + region: "eu-west-1", + logGroup: "/aws/pack", + logStream: "s", + include: ["logs"], + }, + ]; + + expect(apply({}, contextOf(CODEZIP, { telemetry })).table.telemetry).toEqual({ + "pack-logs": { + kind: "cloudwatch_logs", + region: "eu-west-1", + log_group: "/aws/pack", + log_stream: "s", + include: ["logs"], + secret: { ref: "aws://" }, + }, + }); + expect(apply({}, contextOf(CODEZIP)).table).not.toHaveProperty("telemetry"); + }); + }); + + test("keeps the policies list as the local profile names it", () => { + const local = { policies: ["./policy.dw", "rules/extra.dw"] }; + + expect( + apply(local, contextOf(CODEZIP, { policyFiles: ["policy.dw", "rules/extra.dw"] })).table + .policies, + ).toEqual(["./policy.dw", "rules/extra.dw"]); + }); + + test("writes a header that names the local profile and the Runtime packs", () => { + const [, derived, standIns] = runtimeProfileHeader(contextOf(CODEZIP)); + + expect(derived).toContain(`from ${PROFILE_FILE}, for AgentCore Runtime`); + expect(derived).toContain("box/agentcore and box/agentcore-codezip packs"); + expect(runtimeProfileHeader(contextOf(CONTAINER))[1]).not.toContain("box/agentcore-codezip"); + expect(standIns).toContain("AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are stand-ins"); + const text = serializeRuntimeProfile( + apply(createdProfile(CODEZIP), contextOf(CODEZIP)).table, + runtimeProfileHeader(contextOf(CODEZIP)), + ); + expect(text.startsWith("# Runs the agent of the AgentCore project 'demo' in a box.\n")).toBe( + true, + ); + }); +}); diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 4d166588d..020c1a4c9 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -1,19 +1,358 @@ /** * Rule 3 of the derivation: what only AgentCore Runtime needs, and the Runtime value of each - * setting that works only under `agentcore dev`. To do: `[profile] name` is the project's name; - * `packs` adds box/agentcore, and box/agentcore-codezip for CodeZip; `[options] bedrock.region` is - * the build region; `policies` names the policy files that staging copies; in `[agent]`, each value - * that is the template's own (`context.template.local`) becomes the template's Runtime value - * (`context.template.runtime`): the command with no `--reload`, the env with no `LOCAL_DEV` and with - * the region, the AWS stand-ins and the ffi `PYTHONPATH`, the filesystem grants, and the ingress on - * 0.0.0.0, and each value of the user's own stays; each CloudWatch `[telemetry.]` is signed - * with a bare `aws://` in the deploy region. It absorbs, from templates/boxProfile.ts: the Runtime - * branch of renderBoxProfile (runtimeCodeZipRunner, containerRunner with dev false, - * runtimeRegionEnv, RUNTIME_AWS_STAND_IN_LINES, the packs, the header, the name, the options, the - * ingress) and runtimeTelemetrySection. - */ -import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; - -export function apply(table: Readonly, _context: RuntimeProfileContext): RuleResult { - return { table: { ...table }, problems: [], warnings: [] }; + * setting that works only under `agentcore dev`. Each other key stays as the local profile has it. + * + * | Key | Runtime profile | + * | --- | --- | + * | `packs` | the user's packs in their order, then box/agentcore, and box/agentcore-codezip for CodeZip | + * | `[profile] name` | the project's name | + * | `[options] bedrock.region` | the build region, where the profile sets it or imports box/bedrock | + * | `[agent] command` | the template's own command becomes its Runtime command; a command of the user loses `--reload` and `--reload-dir ` | + * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region, the AWS stand-ins, and (CodeZip) the ffi `PYTHONPATH` come in; a value of the user stays | + * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | + * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | + * | `[telemetry.]` | each CloudWatch target is signed with a bare `aws://`, in the deploy region when it names none | + * + * It moves no path: the paths rule runs after it and moves each path of the user. + */ +import { + AGENTCORE_CODEZIP_PACK_NAME, + AGENTCORE_PACK_NAME, + BOX_CODEZIP_DIST, +} from "../../templates/boxProfile"; +import { + RUNTIME_INPUTS, + type RuleResult, + type RuntimeProfileContext, + type TomlTable, +} from "../types"; + +/** The credential that signs an AWS call on AgentCore Runtime: the execution role. */ +export const RUNTIME_AWS_SIGNER = "aws://"; + +/** The pack that sets `AWS_REGION` itself, from its `bedrock.region` input. */ +const BEDROCK_PACK = "box/bedrock"; + +/** The variable that tells the template's agent that it runs under `agentcore dev`. */ +const LOCAL_DEV = "LOCAL_DEV"; + +/** The `kind` of each CloudWatch target. */ +const CLOUDWATCH_KINDS: ReadonlySet = new Set(["cloudwatch_logs", "cloudwatch_traces"]); + +/** + * Stand-in AWS keys for boto3 in the box on AgentCore Runtime. They authenticate nothing: each AWS + * route goes to the Box gateway, and box signs each call for it with the execution role. + */ +export const RUNTIME_AWS_STAND_INS: Readonly> = { + AWS_ACCESS_KEY_ID: "box-stand-in", + AWS_SECRET_ACCESS_KEY: "box-stand-in", +}; + +/** The variables that this rule sets for the Runtime itself, whatever the template's Runtime form. */ +const RUNTIME_ENV_NAMES: ReadonlySet = new Set([ + "AWS_REGION", + "AWS_DEFAULT_REGION", + ...Object.keys(RUNTIME_AWS_STAND_INS), +]); + +/** + * The Runtime's region in the agent's environment, from the box/agentcore `aws.region` input. + * box/bedrock sets `AWS_REGION` itself, so the profile sets it only without that pack. + */ +export function runtimeRegionEnv(bedrock: boolean): Record { + const region = RUNTIME_INPUTS.awsRegion; + return { ...(!bedrock && { AWS_REGION: region }), AWS_DEFAULT_REGION: region }; +} + +/** The comment lines above the Runtime profile of `context.runtime`. */ +export function runtimeProfileHeader(context: RuntimeProfileContext): string[] { + const packs = + context.paths.build === "CodeZip" + ? `The ${AGENTCORE_PACK_NAME} and ${AGENTCORE_CODEZIP_PACK_NAME} packs carry the deployed ` + + "resources, the Runtime Python, and the code directory." + : `The ${AGENTCORE_PACK_NAME} pack carries the deployed resources' variables.`; + return [ + `Runs the agent of the AgentCore project '${context.spec.name}' in a box.`, + `Derived by agentcore build and deploy from ${context.profileFile}, for AgentCore Runtime. ${packs}`, + `${Object.keys(RUNTIME_AWS_STAND_INS).join(" and ")} are stand-ins so boto3 in the box can ` + + "build its requests. They authenticate nothing: every AWS route goes to the Box gateway, " + + "and box signs each request for it with the execution role.", + ]; +} + +export function apply(table: Readonly, context: RuntimeProfileContext): RuleResult { + const result = structuredClone(table) as TomlTable; + const packs = runtimePacks(result.packs, context); + result.packs = packs; + result.profile = { ...(isTable(result.profile) ? result.profile : {}), name: context.spec.name }; + const bedrock = Array.isArray(packs) && packs.includes(BEDROCK_PACK); + const options = runtimeOptions(result.options, bedrock, context.region); + if (options !== undefined) result.options = options; + result.agent = runtimeAgent(result.agent, bedrock, context); + if (result.telemetry !== undefined || context.telemetry.length > 0) { + result.telemetry = runtimeTelemetry(result.telemetry, context); + } + return { table: result, problems: [], warnings: [] }; +} + +/** The user's packs in their order, then each Runtime pack that they do not import. */ +function runtimePacks(packs: unknown, context: RuntimeProfileContext): unknown { + // box refuses `packs` that is not a list before build gets the profile. + if (packs !== undefined && !Array.isArray(packs)) return packs; + const runtime = [ + AGENTCORE_PACK_NAME, + ...(context.paths.build === "CodeZip" ? [AGENTCORE_CODEZIP_PACK_NAME] : []), + ]; + const own = (packs ?? []) as unknown[]; + return [...own, ...runtime.filter((pack) => !own.includes(pack))]; +} + +/** + * `[options]` with `bedrock.region` in the build region, the region of the gateway's `bedrock` + * target: where the profile sets it, as a dotted or a quoted key, or where it imports box/bedrock. + */ +function runtimeOptions(options: unknown, bedrock: boolean, region: string): unknown { + if (options !== undefined && !isTable(options)) return options; + const quoted = options !== undefined && Object.hasOwn(options, "bedrock.region"); + const dotted = options !== undefined && isTable(options.bedrock); + if (!quoted && !dotted && !bedrock) return options; + const result: TomlTable = { ...options }; + if (quoted) result["bedrock.region"] = region; + if (dotted || !quoted) result.bedrock = { ...(result.bedrock as TomlTable), region }; + return result; +} + +/** `[agent]` with its command, env, filesystem, and ingress for the Runtime; other keys stay. */ +function runtimeAgent(agent: unknown, bedrock: boolean, context: RuntimeProfileContext): unknown { + if (agent !== undefined && !isTable(agent)) return agent; + const local: TomlTable = agent ?? {}; + const templateLocal = tableOf(context.template.local.agent); + const templateRuntime = tableOf(context.template.runtime.agent); + const result: TomlTable = { ...local }; + if (local.command !== undefined) { + result.command = sameValue(local.command, templateLocal.command) + ? structuredClone(templateRuntime.command) + : withoutReload(local.command); + } + result.env = runtimeEnv( + local.env, + tableOf(templateLocal.env), + tableOf(templateRuntime.env), + bedrock, + context, + ); + const filesystem = runtimeFilesystem( + local.filesystem, + tableOf(templateLocal.filesystem), + tableOf(templateRuntime.filesystem), + ); + if (filesystem !== undefined) result.filesystem = filesystem; + if (local.ingress !== undefined) { + result.ingress = runtimeIngress(local.ingress, templateLocal.ingress, templateRuntime.ingress); + } + return result; +} + +/** A command with no `--reload`, `--reload-dir `, or `--reload-dir=`. */ +function withoutReload(command: unknown): unknown { + if (!Array.isArray(command)) return command; + const result: unknown[] = []; + for (let index = 0; index < command.length; index++) { + const word: unknown = command[index]; + if (word === "--reload") continue; + if (word === "--reload-dir") { + index++; + continue; + } + if (typeof word === "string" && word.startsWith("--reload-dir=")) continue; + result.push(word); + } + return result; +} + +/** + * `[agent.env]` for the Runtime. A variable of the template that the local profile keeps with the + * template's value gets its Runtime value, or goes when the Runtime has none. A variable that only + * the Runtime has comes in, unless the user sets it. A variable of the user stays. `LOCAL_DEV` + * goes, whatever its value. This rule sets the region and the AWS stand-ins itself. On CodeZip, + * `PYTHONPATH` starts with the ffi shim. + */ +function runtimeEnv( + env: unknown, + templateLocal: TomlTable, + templateRuntime: TomlTable, + bedrock: boolean, + context: RuntimeProfileContext, +): unknown { + if (env !== undefined && !isTable(env)) return env; + const local: TomlTable = env ?? {}; + const has = (name: string) => Object.hasOwn(local, name); + const ofTemplate = (name: string) => + Object.hasOwn(templateLocal, name) && sameValue(local[name], templateLocal[name]); + const added: TomlTable = { ...runtimeRegionEnv(bedrock), ...RUNTIME_AWS_STAND_INS }; + const result: TomlTable = {}; + for (const [name, value] of Object.entries(templateRuntime)) { + if (RUNTIME_ENV_NAMES.has(name)) continue; + if (!Object.hasOwn(templateLocal, name)) result[name] = has(name) ? local[name] : value; + else if (has(name)) result[name] = ofTemplate(name) ? value : local[name]; + } + for (const [name, value] of Object.entries(added)) { + result[name] = has(name) ? local[name] : value; + } + for (const [name, value] of Object.entries(local)) { + if (name === LOCAL_DEV || Object.hasOwn(result, name) || ofTemplate(name)) continue; + result[name] = value; + } + if (context.paths.build === "CodeZip") { + // The ffi shim that deploy stages: its libffi uses static trampolines, which W^X allows. + const code = context.paths.runtimeCode; + const shim = `${code}/${BOX_CODEZIP_DIST}/ffi`; + const path = result.PYTHONPATH; + if (path === undefined) result.PYTHONPATH = `${shim}:${code}`; + else if (typeof path === "string" && path.split(":")[0] !== shim) { + result.PYTHONPATH = `${shim}:${path}`; + } + } + return result; +} + +/** + * `[agent.filesystem]` for the Runtime. In each list, the template's Runtime grants come first: + * each one that only the Runtime has, and each one that the template has under dev too and the + * local profile keeps. Each grant of the user follows in its order. A list that ends empty goes. + */ +function runtimeFilesystem( + filesystem: unknown, + templateLocal: TomlTable, + templateRuntime: TomlTable, +): unknown { + if (filesystem !== undefined && !isTable(filesystem)) return filesystem; + const local: TomlTable = filesystem ?? {}; + const result: TomlTable = {}; + const names = [...new Set([...Object.keys(local), ...Object.keys(templateRuntime)])]; + for (const name of names) { + const own = local[name]; + if (own !== undefined && !Array.isArray(own)) { + result[name] = own; + continue; + } + const grants = (own ?? []) as unknown[]; + const localGrants = listOf(templateLocal[name]); + const kept = listOf(templateRuntime[name]).filter( + (grant) => !includes(localGrants, grant) || includes(grants, grant), + ); + const users = grants.filter( + (grant, index) => + !includes(localGrants, grant) && + !includes(kept, grant) && + !includes(grants.slice(0, index), grant), + ); + const list = [...structuredClone(kept), ...users]; + if (list.length > 0) result[name] = list; + } + return filesystem !== undefined || Object.keys(result).length > 0 ? result : undefined; +} + +/** + * Each `[[agent.ingress]]` for the Runtime: the template's own ingress becomes its Runtime ingress, + * and each other one listens on `0.0.0.0` on its own port, as the Runtime reaches the microVM there. + */ +function runtimeIngress( + ingress: unknown, + templateLocal: unknown, + templateRuntime: unknown, +): unknown { + if (isTable(ingress)) return onAllAddresses(ingress); + if (!Array.isArray(ingress)) return ingress; + const localEntries = listOf(templateLocal); + const runtimeEntries = listOf(templateRuntime); + return ingress.map((entry: unknown) => { + const index = localEntries.findIndex((other) => sameValue(other, entry)); + const runtime = index >= 0 ? runtimeEntries[index] : undefined; + return runtime !== undefined ? structuredClone(runtime) : onAllAddresses(entry); + }); +} + +/** An ingress whose `listen` is `0.0.0.0:`. */ +function onAllAddresses(entry: unknown): unknown { + if (!isTable(entry) || typeof entry.listen !== "string") return entry; + const port = /:(\d+)$/.exec(entry.listen)?.[1]; + return port === undefined ? entry : { ...entry, listen: `0.0.0.0:${port}` }; +} + +/** + * `[telemetry]` for the Runtime: each CloudWatch target of the local profile with its keys, signed + * with a bare `aws://`, in the deploy region when it names none; then each CloudWatch target of the + * context that the local profile does not declare, as box resolves it. A target of another kind + * stays as it is. + */ +function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): unknown { + if (telemetry !== undefined && !isTable(telemetry)) return telemetry; + const local: TomlTable = telemetry ?? {}; + const resolved = new Map(context.telemetry.map((target) => [target.name, target])); + const result: TomlTable = {}; + for (const [name, entry] of Object.entries(local)) { + if (!isTable(entry) || !CLOUDWATCH_KINDS.has(entry.kind)) { + result[name] = entry; + continue; + } + const { kind, region, ...rest } = entry; + result[name] = { + kind, + region: region ?? resolved.get(name)?.region ?? context.region, + ...rest, + secret: { ref: RUNTIME_AWS_SIGNER }, + }; + } + for (const target of context.telemetry) { + if (Object.hasOwn(local, target.name)) continue; + result[target.name] = { + kind: target.kind, + region: target.region, + ...(target.kind === "cloudwatch_logs" && { + log_group: target.logGroup, + log_stream: target.logStream, + }), + ...(target.include && { include: [...target.include] }), + secret: { ref: RUNTIME_AWS_SIGNER }, + }; + } + return result; +} + +const isTable = (value: unknown): value is TomlTable => + typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date); + +/** `value` when it is a table, or an empty table. */ +const tableOf = (value: unknown): TomlTable => (isTable(value) ? value : {}); + +/** `value` when it is a list, or an empty list. */ +const listOf = (value: unknown): readonly unknown[] => (Array.isArray(value) ? value : []); + +/** Whether `list` holds a value equal to `value`. */ +const includes = (list: readonly unknown[], value: unknown) => + list.some((other) => sameValue(other, value)); + +/** Whether two TOML values are equal: tables by their keys in any order, lists in order. */ +function sameValue(left: unknown, right: unknown): boolean { + if (Array.isArray(left) || Array.isArray(right)) { + return ( + Array.isArray(left) && + Array.isArray(right) && + left.length === right.length && + left.every((value, index) => sameValue(value, right[index])) + ); + } + if (left instanceof Date || right instanceof Date) { + return left instanceof Date && right instanceof Date && left.getTime() === right.getTime(); + } + if (isTable(left) || isTable(right)) { + if (!isTable(left) || !isTable(right)) return false; + const keys = Object.keys(left); + return ( + keys.length === Object.keys(right).length && + keys.every((key) => Object.hasOwn(right, key) && sameValue(left[key], right[key])) + ); + } + return Object.is(left, right); } From 7a1e4da570e17dddf87a9130153ae59a441388e7 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 14:03:18 -0800 Subject: [PATCH 08/51] test(box): Fit the gateway rule tests to box-integration and to the refusals rule addBoxGatewayTargets takes no project root on box-integration (aws/agentcore-cli#2853). The stdio server of the gateway fixture now starts a program in the code folder, because the refusals rule refuses a system program on a CodeZip runtime. The gateway rule does not change a stdio server, so the tests prove the same thing. --- src/core/project/runtimeProfile/rules/gateway.test.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index 445ba9bda..0dfeeefce 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -414,7 +414,7 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { "", "[mcp.notes]", 'type = "stdio"', - 'command = ["/usr/bin/notes"]', + 'command = ["${{ workspace }}/app/agent/notes"]', ].join("\n"); /** The `[egress]` and `[mcp]` tables that Box resolves the profile to, with box/bedrock. */ const EGRESS = { @@ -432,7 +432,7 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { destinations: ["docs.example.com"], secret: { ref: "env://DOCS_TOKEN", header: "x-api-key" }, }, - notes: { type: "stdio", command: ["/usr/bin/notes"] }, + notes: { type: "stdio", command: ["/project/app/agent/notes"] }, }; const HR = 'action == Box::Action::"http:request"'; const NC = 'action == Box::Action::"net:connect"'; @@ -462,7 +462,7 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { */ function bothProfiles(spec: ProjectSpec, { text, egress, mcp, policy }: Fixture = FIXTURE) { const withDefaults = structuredClone(spec); - addBoxGatewayTargets(withDefaults, "/project", "us-west-2"); + addBoxGatewayTargets(withDefaults, "us-west-2"); const targets = withDefaults.agentCoreGateways[0]!.targets; const { parsed, failures } = parseResolvedPolicy( { From c6dc336e667503cb04b614e76cc33b4518b94253 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 14:06:17 -0800 Subject: [PATCH 09/51] feat(box): Send box telemetry to the log group of the runtime by default On AgentCore Runtime, a box with no cloudwatch_logs target sends its records to no log group. Thus the records of the box are not in the log group of the runtime, where the agent writes its logs. The runtime ID is part of the name of that log group, and agentcore build cannot know the ID, because deploy makes the runtime. This commit makes the change of e2bdcd61 on dev in the Runtime profile that deriveRuntimeProfile makes. When the derived profile has no cloudwatch_logs target, the additions rule adds [telemetry.agentcore] last. Its name is agentcore_default when a target has the name agentcore. The target holds no literal value: box fills it when the run starts. - region is ${{ inputs.aws.region }}, from AWS_REGION. - log_group and log_stream are ${{ inputs.runtime.log_group }} and ${{ inputs.runtime.log_stream }}. The box/agentcore pack has the 2 inputs. They read the x-aws-log-group and x-aws-log-stream keys of OTEL_EXPORTER_OTLP_LOGS_HEADERS. The Runtime sets this variable to /aws/bedrock-agentcore/runtimes/-DEFAULT and otel-rt-logs. - include is deny, permit, and trace. secret.ref is "aws://". A cloudwatch_logs target of the user, or one that box resolves from a pack, replaces the default target. The rule keeps it with its keys, and signs it as before. A cloudwatch_traces target or a target of a different type does not replace the default target. runtimeProfileHeader(context, profile) adds a comment line that names the default target. IAM: this commit adds no grant. The Runtime construct of aws-cdk-lib 2.269.0 gives the execution role logs:CreateLogStream and logs:PutLogEvents on log-group:/aws/bedrock-agentcore/runtimes/*: log-stream:*, in its account and region. The L3 at box-integration (1.0.2) makes the role with that construct. The telemetry policy of the CLI reads the CloudWatch targets that box resolves in the local profile, not the Runtime profile. A target with an input in its log group or its region is not in that list, so build writes no grant for the text of the input, and build does not stop. box-integration grants xray:PutTraceSegments for an X-Ray target before this commit, so this commit does not include 9014fe31. Box reads a key of a list variable only with [strands-agents/staging-boxy#625](https://github.com/strands-agents/staging-boxy/pull/625). Box 0.1.11-linux-preview.6 stops on the new pack with this error: "holds `key`, which is not a declaration key". The pinned box must have that change before a deploy of this commit. Tests: rules/additions.test.ts. The test of the created templates now has 144 inputs, with no telemetry, with CloudWatch logs and traces, and with traces only. The tables are the same as the tables of renderRuntimeBoxProfile, with the default target when no target is cloudwatch_logs. Other tests show the full default target, that each value of the target names an input of the pack, that a cloudwatch_logs target of the user or of a pack replaces it, that a cloudwatch_traces target or a third-party target does not replace it, the name agentcore_default, and the header line. boxProfile.test.ts shows the 2 inputs of the pack. boxNetworkSource.test.ts shows that a cloudwatch_logs target with inputs gives no telemetry grant, and no failure or warning. For each of 10 mutations of the new code, 1 or more tests show an error. The 29 mutations of the first commit continue to show an error. A synth of a scratch agent-python-strands-box-container project, with the L3 at box-integration (c8019bc), holds the LogStreamAccess statement on the role of the runtime. A box from [fd15d288](https://github.com/strands-agents/staging-boxy/commit/fd15d2884993458379ce15071999eb52b2a597c0) filled the default target of the CodeZip and container profiles with box profile show. The values were the log group and the stream of the variable, and the region of AWS_REGION. That box accepts only the @box/ pack names, so a copy of each profile and pack used them for that check. There was no deploy. --- src/core/project/boxNetworkSource.test.ts | 36 ++++ .../runtimeProfile/rules/additions.test.ts | 155 +++++++++++++++++- .../project/runtimeProfile/rules/additions.ts | 47 +++++- src/core/project/templates/boxProfile.test.ts | 16 ++ src/core/project/templates/boxProfile.ts | 26 ++- 5 files changed, 262 insertions(+), 18 deletions(-) diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index 904c9e246..b329910fb 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -7,6 +7,8 @@ import { boxGatewaySpec, type ProjectSpec } from "../../projectSchemas/project"; import { boxNetworkFailureMessage, readBoxNetworks } from "./boxNetworkSource"; import type { BoxProfileResolver } from "./boxProfileResolver"; import { boxShowOf, FakeBoxProfileResolver } from "./boxProfileResolver-test-support"; +import { telemetryPolicyWriter } from "./boxNetworkWriters"; +import { boxTelemetryPolicyFile } from "./boxTelemetry"; const directories: string[] = []; afterEach(async () => { @@ -166,6 +168,40 @@ describe("readBoxNetworks", () => { ]); }); + test("grants nothing for a cloudwatch_logs target whose log group is an input, and does not stop for it", async () => { + const root = await project([]); + const inputs = { + kind: "cloudwatch_logs", + region: "${{ inputs.aws.region }}", + log_group: "${{ inputs.runtime.log_group }}", + log_stream: "${{ inputs.runtime.log_stream }}", + secret: { ref: "aws://" }, + }; + const shown = boxShowOf({ egress: API_ROUTE }); + const plain = new FakeBoxProfileResolver(shown); + const withInputs = new FakeBoxProfileResolver({ + ...shown, + boxToml: { ...shown.boxToml, telemetry: { mine: inputs } }, + }); + + const [base] = await readBoxNetworks(SPEC, root, plain); + const [network] = await readBoxNetworks(SPEC, root, withInputs); + + // The Runtime profile sends to the runtime's own log group through inputs by default. + const telemetry = network?.runtimeProfile?.telemetry as Record; + expect(telemetry.agentcore).toMatchObject({ log_group: "${{ inputs.runtime.log_group }}" }); + expect(network?.telemetry).toBeUndefined(); + expect(network?.failures).toEqual(base!.failures); + expect(network?.warnings).toEqual(base!.warnings); + const { files } = telemetryPolicyWriter.edits([network!], { + spec: SPEC, + projectRoot: root, + env: {}, + envLocal: {}, + }); + expect(files).toEqual([{ path: boxTelemetryPolicyFile("agent"), remove: true }]); + }); + test("refuses an entry whose API key credential another runtime takes for another variable", async () => { const root = await project([]); const github = (variable: string, host: string) => ({ diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index da3a1245d..97eac805a 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -5,12 +5,16 @@ import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway" import { boxGatewaySpec, type ProjectSpec } from "../../../../projectSchemas/project"; import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; import { cloudWatchTelemetry, withDeployRegion, type CloudWatchTelemetry } from "../../boxNetwork"; -import { renderBoxProfile, renderRuntimeBoxProfile } from "../../templates/boxProfile"; +import { + renderAgentCorePack, + renderBoxProfile, + renderRuntimeBoxProfile, +} from "../../templates/boxProfile"; import { runtimeProfileContext } from "../context"; import { deriveRuntimeProfile } from "../derive"; import { serializeRuntimeProfile } from "../serialize"; import type { TomlTable } from "../types"; -import { apply, runtimeProfileHeader } from "./additions"; +import { apply, DEFAULT_TELEMETRY_TARGET, runtimeProfileHeader } from "./additions"; const PROFILE_FILE = ".box/agent/local/profile.toml"; /** The region create resolved, which the local profile names: not the build region. */ @@ -110,11 +114,34 @@ const CLOUDWATCH: TomlTable = { "x-ray": { kind: "cloudwatch_traces", secret: { ref: "aws://Admin-personal" } }, }; +/** + * The default target of the Runtime profile: the runtime's own log group and log stream, in its own + * region, which box reads through the inputs of the box/agentcore pack. + */ +const DEFAULT_TARGET = { + kind: "cloudwatch_logs", + region: "${{ inputs.aws.region }}", + log_group: "${{ inputs.runtime.log_group }}", + log_stream: "${{ inputs.runtime.log_stream }}", + include: ["deny", "permit", "trace"], + secret: { ref: "aws://" }, +}; + +/** The [telemetry] of a local profile for each case: none, a target of each kind, traces only. */ +const TELEMETRY_CASES: Record = { + none: undefined, + "logs and traces": CLOUDWATCH, + "traces only": { "x-ray": CLOUDWATCH["x-ray"] }, +}; + /** The tables that the additions rule owns, which the old renderer wrote. */ const OWNED = ["packs", "policies", "profile", "options", "agent", "telemetry"] as const; const agentOf = (profile: TomlTable) => profile.agent as Record; +/** The `[telemetry]` of a derived profile. */ +const tableOf = (profile: TomlTable) => profile.telemetry as TomlTable; + describe("deriveRuntimeProfile on the created templates", () => { const cases = ( [ @@ -128,19 +155,27 @@ describe("deriveRuntimeProfile on the created templates", () => { ).flatMap(([build, protocol]) => ["Bedrock", "OpenAI"].flatMap((provider) => [[], ["agentMemory"]].flatMap((memories) => - [false, true].map((extras) => ({ build, protocol, provider, memories, extras })), + Object.keys(TELEMETRY_CASES).map((telemetry) => ({ + build, + protocol, + provider, + memories, + telemetry, + })), ), ), ); test.each(cases)( - "gives the tables the old renderer wrote ($build $protocol $provider, memories $memories, telemetry and policies $extras)", - ({ build, protocol, provider, memories, extras }) => { + "gives the tables the old renderer wrote, and the default target with no cloudwatch_logs target ($build $protocol $provider, memories $memories, telemetry $telemetry)", + ({ build, protocol, provider, memories, telemetry: telemetryCase }) => { const runtime = runtimeOf(build, protocol, provider); const local = createdProfile(runtime); + const tables = TELEMETRY_CASES[telemetryCase]; + const extras = tables !== undefined; if (extras) { local.policies = ["policy.dw"]; - local.telemetry = structuredClone(CLOUDWATCH); + local.telemetry = structuredClone(tables); } const telemetry = withDeployRegion( cloudWatchTelemetry(local), @@ -163,8 +198,13 @@ describe("deriveRuntimeProfile on the created templates", () => { contextOf(runtime, { memories, telemetry, policyFiles }), ); + const logs = telemetry.some(({ kind }) => kind === "cloudwatch_logs"); + const expected: TomlTable = { + ...old, + telemetry: { ...(old.telemetry as TomlTable), ...(!logs && { agentcore: DEFAULT_TARGET }) }, + }; expect(problems).toEqual([]); - for (const key of OWNED) expect([key, profile[key]]).toEqual([key, old[key]]); + for (const key of OWNED) expect([key, profile[key]]).toEqual([key, expected[key]]); }, ); }); @@ -435,6 +475,7 @@ describe("the additions rule", () => { expect(apply(local, contextOf(CODEZIP, { telemetry })).table.telemetry).toEqual({ "x-ray": { kind: "cloudwatch_traces", region: "ap-south-1", secret: { ref: "aws://" } }, + agentcore: DEFAULT_TARGET, }); }); @@ -444,7 +485,10 @@ describe("the additions rule", () => { langfuse: { kind: "langfuse", secret: { ref: "env://LANGFUSE_AUTH" } }, }; - expect(apply({ telemetry: others }, contextOf(CODEZIP)).table.telemetry).toEqual(others); + expect(apply({ telemetry: others }, contextOf(CODEZIP)).table.telemetry).toEqual({ + ...others, + agentcore: DEFAULT_TARGET, + }); }); test("adds each CloudWatch target of the context that the local profile does not declare", () => { @@ -469,7 +513,100 @@ describe("the additions rule", () => { secret: { ref: "aws://" }, }, }); - expect(apply({}, contextOf(CODEZIP)).table).not.toHaveProperty("telemetry"); + }); + }); + + describe("the default CloudWatch Logs target", () => { + test("sends to the runtime's own log group and stream, read when the run starts, when the profile has no [telemetry]", () => { + const { table } = apply(createdProfile(CODEZIP), contextOf(CODEZIP)); + + expect(table.telemetry).toEqual({ agentcore: DEFAULT_TARGET }); + // The target names no literal region, not even the build region, and no log group of build. + const text = JSON.stringify(table.telemetry); + expect(text).not.toContain(BUILD_REGION); + expect(text).not.toContain("/aws/bedrock-agentcore/"); + expect({ ...DEFAULT_TELEMETRY_TARGET } as TomlTable).toEqual(DEFAULT_TARGET); + }); + + test("reads each value through an input that the box/agentcore pack declares", () => { + const { inputs } = parse(renderAgentCorePack(specOf(CODEZIP))) as { + inputs: Record>; + }; + const declared = (placeholder: string) => { + const [group, name] = /^\$\{\{ inputs\.([a-z]+)\.([a-z_]+) \}\}$/ + .exec(placeholder)! + .slice(1); + return inputs[group!]?.[name!]; + }; + + expect(declared(DEFAULT_TARGET.region)).toMatchObject({ from: "env:AWS_REGION" }); + expect(declared(DEFAULT_TARGET.log_group)).toMatchObject({ + from: "env:OTEL_EXPORTER_OTLP_LOGS_HEADERS", + key: "x-aws-log-group", + }); + expect(declared(DEFAULT_TARGET.log_stream)).toMatchObject({ + from: "env:OTEL_EXPORTER_OTLP_LOGS_HEADERS", + key: "x-aws-log-stream", + }); + }); + + test("adds no default target when the profile has its own cloudwatch_logs target", () => { + const local = { telemetry: { logs: CLOUDWATCH.logs } }; + + expect(apply(local, contextOf(CONTAINER)).table.telemetry).toEqual({ + logs: { ...(CLOUDWATCH.logs as TomlTable), secret: { ref: "aws://" } }, + }); + }); + + test("adds no default target when box resolves a cloudwatch_logs target that the profile does not declare", () => { + const telemetry: CloudWatchTelemetry[] = [ + { + name: "pack-logs", + kind: "cloudwatch_logs", + region: "eu-west-1", + logGroup: "g", + logStream: "s", + }, + ]; + + expect(Object.keys(tableOf(apply({}, contextOf(CODEZIP, { telemetry })).table))).toEqual([ + "pack-logs", + ]); + }); + + test("adds the default target beside a cloudwatch_traces target, as it sends no logs", () => { + const local = { telemetry: { "x-ray": CLOUDWATCH["x-ray"] } }; + + expect(apply(local, contextOf(CODEZIP)).table.telemetry).toEqual({ + "x-ray": { kind: "cloudwatch_traces", region: BUILD_REGION, secret: { ref: "aws://" } }, + agentcore: DEFAULT_TARGET, + }); + }); + + test.each([ + ["a CloudWatch target", CLOUDWATCH["x-ray"]], + ["a third-party target", { kind: "langfuse", secret: { ref: "env://LANGFUSE_AUTH" } }], + ])("names the default target agentcore_default when %s is agentcore", (_label, target) => { + const telemetry = tableOf( + apply({ telemetry: { agentcore: target } }, contextOf(CODEZIP)).table, + ); + + expect(Object.keys(telemetry)).toEqual(["agentcore", "agentcore_default"]); + expect(telemetry.agentcore_default).toEqual(DEFAULT_TARGET); + expect((telemetry.agentcore as TomlTable).kind).toBe((target as TomlTable).kind); + }); + + test("names the default target in the header, and no other target", () => { + const context = contextOf(CODEZIP); + const withDefault = apply({}, context).table; + const withOwn = apply({ telemetry: { logs: CLOUDWATCH.logs } }, context).table; + + expect(runtimeProfileHeader(context, withDefault).at(-1)).toBe( + "[telemetry.agentcore] is the default CloudWatch Logs target: the runtime's own log " + + "group and log stream, which box reads from OTEL_EXPORTER_OTLP_LOGS_HEADERS when the " + + `run starts. Add a cloudwatch_logs target to ${PROFILE_FILE} to use another.`, + ); + expect(runtimeProfileHeader(context, withOwn)).toHaveLength(3); }); }); diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 020c1a4c9..dec2721b0 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -12,6 +12,7 @@ * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | * | `[telemetry.]` | each CloudWatch target is signed with a bare `aws://`, in the deploy region when it names none | + * | `[telemetry.agentcore]` | added when no target is `cloudwatch_logs`: the runtime's own log group and log stream | * * It moves no path: the paths rule runs after it and moves each path of the user. */ @@ -55,6 +56,23 @@ const RUNTIME_ENV_NAMES: ReadonlySet = new Set([ ...Object.keys(RUNTIME_AWS_STAND_INS), ]); +/** The variable in which AgentCore Runtime names the runtime's own log group and log stream. */ +const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; + +/** + * The CloudWatch Logs target of a Runtime profile that has no `cloudwatch_logs` target: the + * runtime's own log group and log stream, in its own region. The runtime ID exists only after + * deploy, so box reads the three values through inputs of box/agentcore when the run starts. + */ +export const DEFAULT_TELEMETRY_TARGET = { + kind: "cloudwatch_logs", + region: RUNTIME_INPUTS.awsRegion, + log_group: "${{ inputs.runtime.log_group }}", + log_stream: "${{ inputs.runtime.log_stream }}", + include: ["deny", "permit", "trace"], + secret: { ref: RUNTIME_AWS_SIGNER }, +} as const; + /** * The Runtime's region in the agent's environment, from the box/agentcore `aws.region` input. * box/bedrock sets `AWS_REGION` itself, so the profile sets it only without that pack. @@ -64,8 +82,11 @@ export function runtimeRegionEnv(bedrock: boolean): Record { return { ...(!bedrock && { AWS_REGION: region }), AWS_DEFAULT_REGION: region }; } -/** The comment lines above the Runtime profile of `context.runtime`. */ -export function runtimeProfileHeader(context: RuntimeProfileContext): string[] { +/** The comment lines above `profile`, the Runtime profile of `context.runtime`. */ +export function runtimeProfileHeader( + context: RuntimeProfileContext, + profile: Readonly = {}, +): string[] { const packs = context.paths.build === "CodeZip" ? `The ${AGENTCORE_PACK_NAME} and ${AGENTCORE_CODEZIP_PACK_NAME} packs carry the deployed ` + @@ -77,6 +98,14 @@ export function runtimeProfileHeader(context: RuntimeProfileContext): string[] { `${Object.keys(RUNTIME_AWS_STAND_INS).join(" and ")} are stand-ins so boto3 in the box can ` + "build its requests. They authenticate nothing: every AWS route goes to the Box gateway, " + "and box signs each request for it with the execution role.", + ...Object.entries(tableOf(profile.telemetry)) + .filter(([, target]) => sameValue(target, DEFAULT_TELEMETRY_TARGET)) + .map( + ([name]) => + `[telemetry.${name}] is the default CloudWatch Logs target: the runtime's own log group ` + + `and log stream, which box reads from ${RUNTIME_LOGS_HEADERS_ENV} when the run starts. ` + + `Add a cloudwatch_logs target to ${context.profileFile} to use another.`, + ), ]; } @@ -89,9 +118,7 @@ export function apply(table: Readonly, context: RuntimeProfileContext const options = runtimeOptions(result.options, bedrock, context.region); if (options !== undefined) result.options = options; result.agent = runtimeAgent(result.agent, bedrock, context); - if (result.telemetry !== undefined || context.telemetry.length > 0) { - result.telemetry = runtimeTelemetry(result.telemetry, context); - } + result.telemetry = runtimeTelemetry(result.telemetry, context); return { table: result, problems: [], warnings: [] }; } @@ -284,7 +311,8 @@ function onAllAddresses(entry: unknown): unknown { * `[telemetry]` for the Runtime: each CloudWatch target of the local profile with its keys, signed * with a bare `aws://`, in the deploy region when it names none; then each CloudWatch target of the * context that the local profile does not declare, as box resolves it. A target of another kind - * stays as it is. + * stays as it is. With no `cloudwatch_logs` target, {@link DEFAULT_TELEMETRY_TARGET} comes last, as + * `agentcore`, or as `agentcore_default` when a target has that name. */ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): unknown { if (telemetry !== undefined && !isTable(telemetry)) return telemetry; @@ -317,6 +345,13 @@ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): u secret: { ref: RUNTIME_AWS_SIGNER }, }; } + const logs = Object.values(result).some( + (entry) => isTable(entry) && entry.kind === "cloudwatch_logs", + ); + if (!logs) { + const name = Object.hasOwn(result, "agentcore") ? "agentcore_default" : "agentcore"; + result[name] = structuredClone(DEFAULT_TELEMETRY_TARGET); + } return result; } diff --git a/src/core/project/templates/boxProfile.test.ts b/src/core/project/templates/boxProfile.test.ts index 871c2e6fa..829de4a32 100644 --- a/src/core/project/templates/boxProfile.test.ts +++ b/src/core/project/templates/boxProfile.test.ts @@ -918,6 +918,22 @@ describe("renderAgentCorePack", () => { expect(new RegExp(`^${inputs.aws.region.pattern}$`).test("us-west-2; rm")).toBe(false); }); + test("declares the runtime's log group and log stream inputs as keys of OTEL_EXPORTER_OTLP_LOGS_HEADERS", () => { + const { inputs } = pack([]); + expect(inputs.runtime).toEqual({ + log_group: { + description: "The runtime's own CloudWatch Logs log group.", + from: "env:OTEL_EXPORTER_OTLP_LOGS_HEADERS", + key: "x-aws-log-group", + }, + log_stream: { + description: "The runtime's own CloudWatch Logs log stream.", + from: "env:OTEL_EXPORTER_OTLP_LOGS_HEADERS", + key: "x-aws-log-stream", + }, + }); + }); + test("declares one input per memory and carries each ID into the agent's environment", () => { const toml = pack([{ name: "agentMemory" }, { name: "notes" }]); expect(toml.inputs.memory.agentMemory.id.from).toBe("env:MEMORY_AGENTMEMORY_ID"); diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index e3f4e433b..641b8b3d0 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -48,6 +48,12 @@ const BOX_PYTHON_ENV = "BOX_PYTHON"; const BOX_PYTHON_PREFIX_ENV = "BOX_PYTHON_PREFIX"; const BOX_CODE_ENV = "BOX_CODE"; +/** + * The variable in which AgentCore Runtime names the runtime's own log group and log stream, as + * `x-aws-log-group=,x-aws-log-stream=`, with other keys. + */ +const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; + /** {@link renderAgentCorePack}. */ export const AGENTCORE_PACK_NAME = "box/agentcore"; export const AGENTCORE_PACK_PATH = "resources/packs/agentcore/pack.toml"; @@ -843,8 +849,10 @@ export function boxProfileWarnings(runtime: ScaffoldRuntimeInput): string[] { * 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 - * profile expects. One input per project memory carries its ID into the agent's environment. box - * finds the pack beside its binary at {@link AGENTCORE_PACK_PATH}; build and deploy stage it there. + * profile expects. The `runtime.log_group` and `runtime.log_stream` inputs each read one key of + * {@link RUNTIME_LOGS_HEADERS_ENV}, for the default telemetry target of the Runtime profile. One + * input per project memory carries its ID into the agent's environment. box finds the pack beside + * its binary at {@link AGENTCORE_PACK_PATH}; build and deploy stage it there. */ export function renderAgentCorePack(spec: ProjectSpec): string { const memories = spec.memories ?? []; @@ -881,7 +889,19 @@ pattern = ${str(GATEWAY_URL_PATTERN)} [inputs.aws.region] description = "The AWS region the runtime runs in." from = "env:AWS_REGION" -pattern = ${str(AWS_REGION_PATTERN)}${memoryInputs} +pattern = ${str(AWS_REGION_PATTERN)} + +# The runtime's own log group and log stream, for the default telemetry target. The runtime ID +# exists only after deploy, and the Runtime names both in ${RUNTIME_LOGS_HEADERS_ENV}. +[inputs.runtime.log_group] +description = "The runtime's own CloudWatch Logs log group." +from = ${str(`env:${RUNTIME_LOGS_HEADERS_ENV}`)} +key = "x-aws-log-group" + +[inputs.runtime.log_stream] +description = "The runtime's own CloudWatch Logs log stream." +from = ${str(`env:${RUNTIME_LOGS_HEADERS_ENV}`)} +key = "x-aws-log-stream"${memoryInputs} ${agentEnv}`; } From a3ee1f1c2f29af83f5f8f1cceb95405f30cea731 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 15:03:14 -0800 Subject: [PATCH 10/51] feat(box): Give the derived Runtime profile the changes of aws/agentcore-cli#2857 [aws/agentcore-cli#2857](https://github.com/aws/agentcore-cli/pull/2857) changes the AgentCore Runtime profile that renderRuntimeBoxProfile writes, and adds five box templates. The rules did not have these changes, so the derived profile was different from the profile of the old renderer: - [d6eec45d](https://github.com/aws/agentcore-cli/commit/d6eec45da80665a35ac2e93f801ed2c602f7c7f2) signs each Box gateway backend for ${{ inputs.aws.region }}, the region of the Runtime. The gateway rule signed it for the build region. - [3df66a24](https://github.com/aws/agentcore-cli/commit/3df66a2421a25c28196470e0cf12ebeb0088147e) and [f1f55b8c](https://github.com/aws/agentcore-cli/commit/f1f55b8cb6372b1a8962013bc25f6a12f3ce6014) write [project] access, and a CodeZip local profile gets [tool.uname.filesystem] deny_write for the venv. The Runtime profile has no venv, so the old renderer wrote no [tool.uname]. The derived profile kept that table, with the venv path moved to the code directory. With this change: - The gateway rule signs each backend for ${{ inputs.aws.region }}, which the agentcore pack reads from AWS_REGION. The build region does not go into a backend. - The additions rule replaces each [tool.] table that the local profile keeps as the template writes it with the Runtime table of the template. The Runtime template has no tool table, so [tool.uname] goes. A tool table that the user writes or changes stays. - [project] goes through as the local profile has it. The old renderer wrote the same value for the local and the Runtime profile. Tests: additions.test.ts "deriveRuntimeProfile on each box template of create" compares the whole derived profile with renderRuntimeBoxProfile of box-integration (f5503f02) for each of the seven box templates, the model provider of the template and OpenAI where the template lets the user change it, with and without Memory, and with three telemetry inputs: 66 inputs. The test that compares the owned tables for each build and protocol also compares [project] and [tool]. additions.test.ts "removes the [tool.uname] table that a CodeZip template writes, and keeps each tool table of the user". gateway.test.ts "gives each host of an entry with several destinations its own route, signed for the Runtime's region and not the build region", and the tests that compare the gateway rule with renderRuntimeBoxProfile. --- .../runtimeProfile/rules/additions.test.ts | 127 +++++++++++++++++- .../project/runtimeProfile/rules/additions.ts | 27 ++++ .../runtimeProfile/rules/gateway.test.ts | 15 ++- .../project/runtimeProfile/rules/gateway.ts | 36 ++--- 4 files changed, 180 insertions(+), 25 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 97eac805a..fb6c6ce1c 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -1,5 +1,10 @@ import { describe, expect, test } from "bun:test"; import { parse } from "smol-toml"; +import { + RUNTIME_TEMPLATE_SHORTCUTS, + resolveRuntimeTemplateShortcut, + type RuntimeTemplateShortcutName, +} from "../../../../handlers/project/shortcuts"; import type { ScaffoldRuntimeInput } from "../../../../handlers/project/types"; import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway"; import { boxGatewaySpec, type ProjectSpec } from "../../../../projectSchemas/project"; @@ -58,7 +63,7 @@ function specOf(runtime: ProjectRuntime, memories: readonly string[] = []) { runtimes: [runtime], memories: memories.map((name) => ({ name, eventExpiryDuration: 30, strategies: [] })), projectType: "box", - agentCoreGateways: [{ ...boxGatewaySpec("agent"), targets }], + agentCoreGateways: [{ ...boxGatewaySpec(runtime.name), targets }], } as unknown as ProjectSpec; } @@ -135,7 +140,16 @@ const TELEMETRY_CASES: Record = { }; /** The tables that the additions rule owns, which the old renderer wrote. */ -const OWNED = ["packs", "policies", "profile", "options", "agent", "telemetry"] as const; +const OWNED = [ + "packs", + "policies", + "profile", + "project", + "options", + "agent", + "tool", + "telemetry", +] as const; const agentOf = (profile: TomlTable) => profile.agent as Record; @@ -209,6 +223,99 @@ describe("deriveRuntimeProfile on the created templates", () => { ); }); +/** The name of each box template of `agentcore create`. */ +const BOX_TEMPLATES = (Object.keys(RUNTIME_TEMPLATE_SHORTCUTS) as RuntimeTemplateShortcutName[]) + .filter((name) => (RUNTIME_TEMPLATE_SHORTCUTS[name] as { box?: boolean }).box === true) + .sort(); + +/** The runtime that `agentcore create` writes into agentcore.json for the template `input`. */ +function createdRuntime(input: ScaffoldRuntimeInput): ProjectRuntime { + return { + name: input.runtimeName, + build: input.build, + entrypoint: input.build === "CodeZip" ? "start.py" : "main.py", + codeLocation: `app/${input.runtimeName}`, + ...(input.protocol !== undefined && { protocol: input.protocol }), + ...(input.modelProvider !== undefined && { modelProvider: input.modelProvider }), + box: { version: "1.0.0" }, + } as ProjectRuntime; +} + +describe("deriveRuntimeProfile on each box template of create", () => { + test("covers the seven box templates", () => { + expect(BOX_TEMPLATES).toEqual([ + "a2a-python-strands-box", + "agent-python-langchain-box", + "agent-python-minimal-box", + "agent-python-strands-box", + "agent-python-strands-box-container", + "agui-python-strands-box", + "mcp-python-fastmcp-box", + ]); + }); + + const cases = BOX_TEMPLATES.flatMap((template) => { + const providers = RUNTIME_TEMPLATE_SHORTCUTS[template].supportsModelProviderOverride + ? ["of the template", "OpenAI"] + : ["of the template"]; + return providers.flatMap((provider) => + [[], ["agentMemory"]].flatMap((memories) => + Object.keys(TELEMETRY_CASES).map((telemetry) => ({ + template, + provider, + memories, + telemetry, + })), + ), + ); + }); + + test.each(cases)( + "gives the whole profile that the old renderer wrote, with the default target when no target is cloudwatch_logs ($template, provider $provider, memories $memories, telemetry $telemetry)", + ({ template, provider, memories, telemetry: telemetryCase }) => { + const input = resolveRuntimeTemplateShortcut( + template as RuntimeTemplateShortcutName, + provider === "OpenAI" ? { modelProvider: "OpenAI", apiKey: "sk-test" } : {}, + ); + const runtime = createdRuntime(input); + const local = parse(renderBoxProfile("demo", input, CREATE_REGION, "local")!) as TomlTable; + const tables = TELEMETRY_CASES[telemetryCase]; + const extras = tables !== undefined; + if (extras) { + local.policies = ["policy.dw"]; + local.telemetry = structuredClone(tables); + } + const telemetry = withDeployRegion( + cloudWatchTelemetry(local), + BUILD_REGION, + PROFILE_FILE, + ).telemetry; + const policyFiles = extras ? ["policy.dw"] : []; + const old = parse( + renderRuntimeBoxProfile(specOf(runtime, memories), runtime, { + policyFiles, + region: BUILD_REGION, + hosts: [], + telemetry, + }), + ) as TomlTable; + + const { profile, problems } = deriveRuntimeProfile( + local, + contextOf(runtime, { memories, telemetry, policyFiles }), + ); + + const logs = telemetry.some(({ kind }) => kind === "cloudwatch_logs"); + const expected: TomlTable = { + ...old, + telemetry: { ...(old.telemetry as TomlTable), ...(!logs && { agentcore: DEFAULT_TARGET }) }, + }; + expect(problems).toEqual([]); + expect(profile).toEqual(expected); + }, + ); +}); + describe("the additions rule", () => { const CODEZIP = runtimeOf("CodeZip"); const CONTAINER = runtimeOf("Container"); @@ -243,6 +350,22 @@ describe("the additions rule", () => { expect(local).toEqual(before); }); + test("removes the [tool.uname] table that a CodeZip template writes, and keeps each tool table of the user", () => { + const local = createdProfile(CODEZIP); + const notes = { program: "/usr/bin/notes" }; + const changed = { filesystem: { deny_write: ["${{ workspace }}/app/agent/data"] } }; + + expect(Object.keys(local.tool as TomlTable)).toEqual(["uname"]); + expect(apply(local, contextOf(CODEZIP)).table).not.toHaveProperty("tool"); + expect( + apply({ ...local, tool: { ...(local.tool as TomlTable), notes } }, contextOf(CODEZIP)).table + .tool, + ).toEqual({ notes }); + expect(apply({ ...local, tool: { uname: changed } }, contextOf(CODEZIP)).table.tool).toEqual({ + uname: changed, + }); + }); + test("keeps the user's packs in their order, then adds the Runtime packs once", () => { const packs = ["box/gh", "box/base", "box/bedrock"]; diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index dec2721b0..77ae721af 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -11,6 +11,7 @@ * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region, the AWS stand-ins, and (CodeZip) the ffi `PYTHONPATH` come in; a value of the user stays | * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | + * | `[tool.]` | a table of the template becomes its Runtime table, or goes when the Runtime has none; a table of the user stays | * | `[telemetry.]` | each CloudWatch target is signed with a bare `aws://`, in the deploy region when it names none | * | `[telemetry.agentcore]` | added when no target is `cloudwatch_logs`: the runtime's own log group and log stream | * @@ -118,6 +119,11 @@ export function apply(table: Readonly, context: RuntimeProfileContext const options = runtimeOptions(result.options, bedrock, context.region); if (options !== undefined) result.options = options; result.agent = runtimeAgent(result.agent, bedrock, context); + if (result.tool !== undefined) { + const tool = runtimeTools(result.tool, context); + if (tool === undefined) delete result.tool; + else result.tool = tool; + } result.telemetry = runtimeTelemetry(result.telemetry, context); return { table: result, problems: [], warnings: [] }; } @@ -180,6 +186,27 @@ function runtimeAgent(agent: unknown, bedrock: boolean, context: RuntimeProfileC return result; } +/** + * `[tool]` for the Runtime. A `[tool.]` of the template that the local profile keeps as the + * template has it becomes the template's Runtime table, or goes when the Runtime has none: the + * `deny_write` that a CodeZip template gives a tool of @box/base protects the local venv, and the + * Runtime has no venv. Each other tool table stays. An empty `[tool]` goes. + */ +function runtimeTools(tool: unknown, context: RuntimeProfileContext): unknown { + if (!isTable(tool)) return tool; + const templateLocal = tableOf(context.template.local.tool); + const templateRuntime = tableOf(context.template.runtime.tool); + const result: TomlTable = {}; + for (const [name, entry] of Object.entries(tool)) { + if (!Object.hasOwn(templateLocal, name) || !sameValue(entry, templateLocal[name])) { + result[name] = entry; + } else if (Object.hasOwn(templateRuntime, name)) { + result[name] = structuredClone(templateRuntime[name]); + } + } + return Object.keys(result).length > 0 ? result : undefined; +} + /** A command with no `--reload`, `--reload-dir `, or `--reload-dir=`. */ function withoutReload(command: unknown): unknown { if (!Array.isArray(command)) return command; diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index 0dfeeefce..324bffb17 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -127,13 +127,16 @@ function gateway( return apply(parse(text) as TomlTable, contextOf(text, hosts, targets, region)); } -/** The TOML text of one route's gateway backend, under the table `table`. */ -const backendText = (table: string, target: string, region = "us-west-2") => +/** + * The TOML text of one route's gateway backend, under the table `table`: signed for the Runtime's + * own region, which box reads from the `aws.region` input, whatever region build builds for. + */ +const backendText = (table: string, target: string) => `[[${table}.backends]]\n` + `url = "\${{ inputs.gateway.url }}/${target}"\n` + 'auth.ref = "aws://"\n' + 'auth.aws.service = "bedrock-agentcore"\n' + - `auth.aws.region = "${region}"\n`; + 'auth.aws.region = "${{ inputs.aws.region }}"\n'; describe("the gateway rule", () => { test("carries each key it does not own, and a stdio [mcp] server, as the local profile has them", () => { @@ -187,7 +190,7 @@ describe("the gateway rule", () => { ); }); - test("gives each host of an entry with several destinations its own route, in the region build builds for", () => { + test("gives each host of an entry with several destinations its own route, signed for the Runtime's region and not the build region", () => { const text = '[egress.models]\ndestinations = ["api.one.example.com", "api.two.example.com:8443/v1"]\n'; @@ -208,10 +211,10 @@ describe("the gateway rule", () => { expect(table.egress).toEqual( parse( '[egress.egress-models-one]\ndestinations = ["api.one.example.com"]\n' + - backendText("egress.egress-models-one", "egress-models-one", "eu-central-1") + + backendText("egress.egress-models-one", "egress-models-one") + // The route keeps the port of the target's endpoint, and no path. '[egress.egress-models-two]\ndestinations = ["api.two.example.com:8443"]\n' + - backendText("egress.egress-models-two", "egress-models-two", "eu-central-1"), + backendText("egress.egress-models-two", "egress-models-two"), ).egress, ); }); diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index df20b3b6c..d891e53f8 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -2,7 +2,8 @@ * Rule 2 of the derivation: on AgentCore Runtime, each call of the box goes through the runtime's * Box gateway. Each passthrough target of that gateway, as build writes the gateway, gets one * route: the box sends the calls to the target's host to `${{ inputs.gateway.url }}/`, and - * signs them for the gateway in the build region with a bare `aws://`, the execution role. The + * signs them for the gateway in the Runtime's own region, `${{ inputs.aws.region }}`, with a bare + * `aws://`, the execution role. The * gateway then calls the host with the target's own auth. * * | Local profile | Runtime profile | @@ -58,7 +59,7 @@ export function apply(table: Readonly, context: RuntimeProfileContext host.sources.some((source) => source.kind === "entry" && source.egressEntry === name), ); for (const route of routesOf(hosts, routes)) { - egress[route.target] = egressRoute(entry, route, context.region); + egress[route.target] = egressRoute(entry, route); written.add(route.target); } } @@ -71,16 +72,16 @@ export function apply(table: Readonly, context: RuntimeProfileContext } const route = routes.find(({ server }) => server?.mcpEntry === name); if (route?.server === undefined) continue; - mcp[name] = mcpServer(entry, route, route.server, context.region); + mcp[name] = mcpServer(entry, route, route.server); written.add(route.target); } for (const route of routes) { if (written.has(route.target)) continue; if (route.server) { - mcp[route.server.mcpEntry] = mcpServer({}, route, route.server, context.region); + mcp[route.server.mcpEntry] = mcpServer({}, route, route.server); } else { - egress[route.target] = egressRoute({}, route, context.region); + egress[route.target] = egressRoute({}, route); } } @@ -164,9 +165,9 @@ function isHttpServer(entry: Readonly): boolean { * The `[egress.]` route of `route`, with each key of `entry` that the gateway form does not * set. Its secret goes: the gateway target sends the credential. */ -function egressRoute(entry: Readonly, route: GatewayRoute, region: string): TomlTable { +function egressRoute(entry: Readonly, route: GatewayRoute): TomlTable { const { destinations: _destinations, secret: _secret, backends: _backends, ...kept } = entry; - return { destinations: [route.host], ...kept, backends: [gatewayBackend(route, region)] }; + return { destinations: [route.host], ...kept, backends: [gatewayBackend(route)] }; } /** @@ -175,12 +176,7 @@ function egressRoute(entry: Readonly, route: GatewayRoute, region: st * the server, as Box resolves it, stays without `inject`: the agent keeps its stand-in, and the * gateway sends the key. Box refuses a signed secret beside a backend, so that one goes. */ -function mcpServer( - entry: Readonly, - route: GatewayRoute, - server: McpSource, - region: string, -): TomlTable { +function mcpServer(entry: Readonly, route: GatewayRoute, server: McpSource): TomlTable { const { type: _type, destinations: _destinations, @@ -200,14 +196,20 @@ function mcpServer( destinations: [route.host], ...(secret && { secret }), ...kept, - backends: [gatewayBackend(route, region)], + backends: [gatewayBackend(route)], }; } -/** The backend of a route: the route's gateway target, signed for the gateway in `region`. */ -function gatewayBackend(route: GatewayRoute, region: string): TomlTable { +/** + * The backend of a route: the route's gateway target, signed for the gateway in the Runtime's own + * region, which box reads from the `aws.region` input of the agentcore pack. + */ +function gatewayBackend(route: GatewayRoute): TomlTable { return { url: `${RUNTIME_INPUTS.gatewayUrl}/${route.target}`, - auth: { ref: RUNTIME_AWS_SIGNER, aws: { service: "bedrock-agentcore", region } }, + auth: { + ref: RUNTIME_AWS_SIGNER, + aws: { service: "bedrock-agentcore", region: RUNTIME_INPUTS.awsRegion }, + }, }; } From bab52a941dbf3f914551c553e4077d9909d63634 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 14:27:29 -0800 Subject: [PATCH 11/51] feat(box): Stage the Runtime box profile that build derives from the local profile Build staged the AgentCore Runtime profile that renderRuntimeBoxProfile made from agentcore.json and from the Box network model. That renderer did not read the local profile of the runtime. Thus each stdio [mcp.] server and each [tool.] of the local profile was not on AgentCore Runtime, and build gave no message. With this change, the runtime profile writer stages the profile that deriveRuntimeProfile makes from the local profile, with the comment lines of runtimeProfileHeader. buildBoxNetwork keeps the profile and its comment lines in BoxNetwork.runtimeProfile and BoxNetwork.runtimeProfileHeader. A staged runtime with no Box network stops build with a message, because the writer has no profile for it. - renderBoxProfile writes only the local profile. runtimeAgentTemplate gives the [agent] table of a box template on AgentCore Runtime, in the paths of the local profile. The additions rule gives that table to each value that is the template's own, and the paths rule then moves its paths. Thus only the rules move a path to AgentCore Runtime. - This commit removes renderRuntimeBoxProfile, runtimeGatewayRoutes, runtimeGatewayRouteSection, runtimeMcpServerSection, runtimeMcpServers, runtimeGatewayBackend, runtimeTelemetrySection, runtimeRegionEnv, RUNTIME_AWS_SIGNER, RUNTIME_AWS_STAND_IN_LINES, the Runtime branch of renderBoxProfile, and its runtimeRoutes and runtimePolicies parameters. The rules do this work. - cloudWatchTelemetry keeps its CloudWatch filter. The telemetry policy writer reads it for the IAM grant. The refusals rule stops build for a target of a different type in the local profile. - The guide tells how build derives the Runtime profile. The derived profile is the same as the profile of the old renderer for each box template, with the default telemetry target. Only the sequence of the keys is different. Before this commit removed the renderer, a test wrote the tables of the renderer of box-integration (f5503f02, with [aws/agentcore-cli#2857](https://github.com/aws/agentcore-cli/pull/2857)) into runtimeProfile/__fixtures__/old-renderer-tables.json: the owned tables for 72 inputs (CodeZip HTTP, MCP, A2A, and AGUI, container HTTP and MCP, Bedrock and OpenAI, with and without Memory, and 3 telemetry inputs), the whole profile for 66 inputs of the seven box templates of create, and 4 gateway inputs. Tests: additions.test.ts "gives the tables the old renderer wrote" (72 inputs), "gives the whole profile that the old renderer wrote" (66 inputs), and gateway.test.ts "the gateway rule and the Runtime renderer it replaced" compare deriveRuntimeProfile with that file. boxProfile.test.ts "runtimeAgentTemplate". boxNetworkWriters.test.ts "writes the Runtime profile and a byte copy of each policy file beside it" and "stops for a runtime that it stages with no derived Runtime profile". The staging, build, and cdk tests stage the derived profile of their model. The tests of the old renderer are removed: the rule tests and the fixture cover them. --- docs/box-local-testing.md | 23 +- src/core/project/backends/boxCodeZip.test.ts | 48 +- .../project/backends/boxContainer.test.ts | 27 +- src/core/project/backends/cdk.test.ts | 19 +- src/core/project/boxNetwork/network.ts | 41 +- src/core/project/boxNetworkWriters.test.ts | 22 +- src/core/project/boxNetworkWriters.ts | 22 +- src/core/project/manager.boxNetwork.test.ts | 10 +- .../__fixtures__/old-renderer-tables.json | 13091 ++++++++++++++++ src/core/project/runtimeProfile/context.ts | 22 +- .../project/runtimeProfile/derive.test.ts | 11 +- .../runtimeProfile/rules/additions.test.ts | 105 +- .../runtimeProfile/rules/gateway.test.ts | 66 +- .../runtimeProfile/rules/paths.test.ts | 4 +- src/core/project/templates/boxProfile.test.ts | 577 +- src/core/project/templates/boxProfile.ts | 442 +- 16 files changed, 13506 insertions(+), 1024 deletions(-) create mode 100644 src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index 69326a399..d6b4ce0b3 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -132,10 +132,25 @@ it lists under `policies`, and turn them into that runtime's Box network. They c - **Warnings.** Build warns when Box enforces rules that the gateway does not (a path, method, or forbid), when an entry's host gets no target, and when a target is signed for an AWS service that no policy of the gateway's role grants. -- **The AgentCore Runtime profile.** The generated `.box//aws/profile.toml`, copied into - `.box-dist/`, has one `[egress.]` route through the gateway for each target of - `-box-egress`. Each policy file is copied beside it, byte for byte, and listed under - `policies`. +- **The AgentCore Runtime profile.** Build derives `.box//aws/profile.toml`, copied into + `.box-dist/`, from the local profile. Each key of the local profile stays, and build changes + only what must differ on AgentCore Runtime: + - each `[egress]` host with a gateway target becomes one `[egress.]` route to + `-box-egress`, and an HTTP `[mcp.]` server gets the same gateway backend; + - the agent command, env, filesystem and ingress get their Runtime values (no `--reload`, no + `LOCAL_DEV`, the deployed region, listen on `0.0.0.0`); + - for CodeZip, each path of the code folder moves to the unpacked zip, and the venv's Python to + the Runtime's Python, in every table: the agent, each stdio `[mcp.]` server, each + `[tool.]`; + - the `box/agentcore` packs, the project name, and the build region come in, and each CloudWatch + target signs with the execution role. With no `cloudwatch_logs` target, the box sends its + records to the runtime's own log group. + + Build stops, and names the key and its line, for a value that cannot work on the Runtime: a path + of the project outside the code folder, a home path, a CodeZip program outside the code folder, + `network.contain_egress = false`, or a telemetry target that is not CloudWatch. Each policy file + is copied beside the profile, byte for byte. + - **No-auth targets need a newer L3.** A passthrough target with no outbound auth synthesizes only with an `@aws/agentcore-cdk` that accepts it. Until that release is pinned, use a local L3 build, as in step 5. diff --git a/src/core/project/backends/boxCodeZip.test.ts b/src/core/project/backends/boxCodeZip.test.ts index 65efe4019..b474ad814 100644 --- a/src/core/project/backends/boxCodeZip.test.ts +++ b/src/core/project/backends/boxCodeZip.test.ts @@ -3,6 +3,7 @@ import { existsSync } from "node:fs"; import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; +import { parse } from "smol-toml"; import { boxGatewaySpec } from "../../../projectSchemas/project"; import type { Project } from "../../../handlers/project/types"; import type { BoxNetwork } from "../boxNetwork"; @@ -11,8 +12,9 @@ import { AGENTCORE_PACK_PATH, renderAgentCoreCodeZipPack, renderAgentCorePack, - renderRuntimeBoxProfile, } from "../templates/boxProfile"; +import { serializeRuntimeProfile } from "../runtimeProfile/serialize"; +import type { TomlTable } from "../runtimeProfile/types"; import { stageBoxCodeZip } from "./boxCodeZip"; import type { BoxLinuxBuild } from "./boxRelease"; @@ -87,7 +89,7 @@ describe("stageBoxCodeZip", () => { const build = await linuxBuild({ ffi: true }); const demo = await project("start.py"); - expect(await stageBoxCodeZip(demo, [], async () => build)).toEqual(["agent"]); + expect(await stageBoxCodeZip(demo, [model([])], async () => build)).toEqual(["agent"]); const dist = join(demo.rootPath, "app", "agent", ".box-dist"); for (const binary of BINARIES) { @@ -101,9 +103,10 @@ describe("stageBoxCodeZip", () => { "[pack]\n", ); expect(await readFile(join(dist, "ffi", "libffi.so.8"), "utf8")).toBe("ffi"); - // The Runtime profile is rendered from agentcore.json. + // The Runtime profile is the one build derived from the local profile. + const { runtimeProfile, runtimeProfileHeader } = model([]); expect(await readFile(join(dist, "profile.toml"), "utf8")).toBe( - renderRuntimeBoxProfile(demo.spec, demo.spec.runtimes[0]!), + serializeRuntimeProfile(runtimeProfile!, runtimeProfileHeader), ); // The profile imports these generated packs, which box finds beside its binary. They are // written after box's own resources are copied, so the copy does not remove them. @@ -129,7 +132,7 @@ describe("stageBoxCodeZip", () => { demo.spec.runtimes[0]!.box = { version: "2.0.0" }; const versions: (string | undefined)[] = []; - await stageBoxCodeZip(demo, [], async (version) => { + await stageBoxCodeZip(demo, [model([])], async (version) => { versions.push(version); return build; }); @@ -141,7 +144,7 @@ describe("stageBoxCodeZip", () => { const build = await linuxBuild({ ffi: true }); const demo = await project("start.py", "PYTHON_3_13"); - await stageBoxCodeZip(demo, [], async () => build); + await stageBoxCodeZip(demo, [model([])], async () => build); const dist = join(demo.rootPath, "app", "agent", ".box-dist"); expect(await Bun.file(join(dist, "box")).exists()).toBe(true); @@ -159,7 +162,7 @@ describe("stageBoxCodeZip", () => { const asked: (string | undefined)[] = []; expect( - await stageBoxCodeZip(demo, [], async (version) => { + await stageBoxCodeZip(demo, [model([])], async (version) => { asked.push(version); return linuxBuild(); }), @@ -175,7 +178,7 @@ describe("stageBoxCodeZip", () => { await writeFile(join(dist, "ffi", "stale.so"), "old"); const build = await linuxBuild(); - await stageBoxCodeZip(demo, [], async () => build); + await stageBoxCodeZip(demo, [model([])], async () => build); expect(await Bun.file(join(dist, "ffi", "stale.so")).exists()).toBe(false); expect(await Bun.file(join(dist, "box")).exists()).toBe(true); @@ -187,7 +190,7 @@ describe("stageBoxCodeZip", () => { throw new Error("not asked"); }); - expect(await stageBoxCodeZip(demo, [], box)).toEqual([]); + expect(await stageBoxCodeZip(demo, [model([])], box)).toEqual([]); expect(box).not.toHaveBeenCalled(); expect(await Bun.file(join(demo.rootPath, "app", "agent", ".box-dist", "box")).exists()).toBe( false, @@ -208,9 +211,10 @@ describe("stageBoxCodeZip", () => { const dist = join(demo.rootPath, "app", "agent", ".box-dist"); expect(Buffer.compare(await readFile(join(dist, "policy.dw")), bytes)).toBe(0); expect(await readFile(join(dist, "rules", "extra.dw"), "utf8")).toBe("// extra\n"); - expect(await readFile(join(dist, "profile.toml"), "utf8")).toContain( - 'policies = ["policy.dw", "rules/extra.dw"]', - ); + expect(parse(await readFile(join(dist, "profile.toml"), "utf8")).policies).toEqual([ + "policy.dw", + "rules/extra.dw", + ]); }); test("stages each runtime's own Runtime profile and policy files into its own code folder", async () => { @@ -235,8 +239,7 @@ describe("stageBoxCodeZip", () => { expect(await readFile(join(dist, file), "utf8")).toBe(`// ${name}\n`); expect(await Bun.file(join(dist, other)).exists()).toBe(false); const profile = await readFile(join(dist, "profile.toml"), "utf8"); - expect(profile).toContain(`policies = ["${file}"]`); - expect(profile).toContain(`# The policy files of .box/${name}/local/profile.toml,`); + expect(parse(profile) as TomlTable).toEqual(runtimeProfileOf([file], name)); expect(await readFile(join(demo.rootPath, ".box", name, "aws", "profile.toml"), "utf8")).toBe( profile, ); @@ -254,7 +257,10 @@ describe("stageBoxCodeZip", () => { }); }); -/** A model of the runtime `runtime` with no host and the policy files given. */ +/** + * A model of the runtime `runtime` with no host and the policy files given, with the Runtime + * profile build derived from its local profile. + */ function model(policyFiles: string[], runtime = "agent"): BoxNetwork { return { runtime, @@ -263,8 +269,20 @@ function model(policyFiles: string[], runtime = "agent"): BoxNetwork { hosts: [], envRoutes: [], policyFiles, + runtimeProfile: runtimeProfileOf(policyFiles, runtime), + runtimeProfileHeader: [`Derived from .box/${runtime}/local/profile.toml.`], grantedActions: [], warnings: [], failures: [], }; } + +/** A derived Runtime profile that names `policyFiles`. */ +function runtimeProfileOf(policyFiles: string[], runtime = "agent"): TomlTable { + return { + packs: ["box/base", "box/agentcore", "box/agentcore-codezip"], + ...(policyFiles.length > 0 && { policies: policyFiles }), + profile: { name: "demo" }, + agent: { command: [`\${{ inputs.code.dir }}/${runtime}`] }, + }; +} diff --git a/src/core/project/backends/boxContainer.test.ts b/src/core/project/backends/boxContainer.test.ts index 2402413ea..fcbba4232 100644 --- a/src/core/project/backends/boxContainer.test.ts +++ b/src/core/project/backends/boxContainer.test.ts @@ -6,7 +6,8 @@ import { join } from "node:path"; import { boxGatewaySpec } from "../../../projectSchemas/project"; import type { Project } from "../../../handlers/project/types"; import type { BoxNetwork } from "../boxNetwork"; -import { renderAgentCorePack, renderRuntimeBoxProfile } from "../templates/boxProfile"; +import { renderAgentCorePack } from "../templates/boxProfile"; +import { serializeRuntimeProfile } from "../runtimeProfile/serialize"; import { stageBoxContainers } from "./boxContainer"; import { BOX_RELEASE, type BoxRelease } from "./boxRelease"; @@ -75,13 +76,14 @@ describe("stageBoxContainers", () => { demo.spec.runtimes[0]!.box = { version: "2.0.0" }; const { releaseFor, versions } = releaseOf(); - expect(await stageBoxContainers(demo, [], releaseFor)).toEqual(["agent"]); + expect(await stageBoxContainers(demo, [model([])], releaseFor)).toEqual(["agent"]); expect(versions).toEqual(["2.0.0"]); const dist = join(demo.rootPath, "app", "agent", ".box-dist"); - // The Runtime profile is rendered from agentcore.json. + // The Runtime profile is the one build derived from the local profile. + const { runtimeProfile, runtimeProfileHeader } = model([]); expect(await readFile(join(dist, "profile.toml"), "utf8")).toBe( - renderRuntimeBoxProfile(demo.spec, demo.spec.runtimes[0]!), + serializeRuntimeProfile(runtimeProfile!, runtimeProfileHeader), ); expect(await readFile(join(dist, "box-release.env"), "utf8")).toBe( `BOX_REPO=${BOX_RELEASE.repo}\nBOX_VERSION=2.0.0\nBOX_ASSET=${BOX_RELEASE.linux.asset}\n` + @@ -107,7 +109,7 @@ describe("stageBoxContainers", () => { await writeFile(join(dist, "box"), "old"); await writeFile(join(dist, "stale.dw"), "old"); - await stageBoxContainers(demo, [], releaseOf().releaseFor); + await stageBoxContainers(demo, [model([])], releaseOf().releaseFor); expect((await readdir(dist)).sort()).toEqual([...STAGED, "resources"].sort()); }); @@ -117,7 +119,7 @@ describe("stageBoxContainers", () => { delete demo.spec.runtimes[0]!.box; const { releaseFor, versions } = releaseOf(); - expect(await stageBoxContainers(demo, [], releaseFor)).toEqual([]); + expect(await stageBoxContainers(demo, [model([])], releaseFor)).toEqual([]); expect(versions).toEqual([]); }); @@ -125,7 +127,7 @@ describe("stageBoxContainers", () => { const demo = await project("FROM scratch\n"); const { releaseFor, versions } = releaseOf(); - expect(await stageBoxContainers(demo, [], releaseFor)).toEqual([]); + expect(await stageBoxContainers(demo, [model([])], releaseFor)).toEqual([]); expect(versions).toEqual([]); expect(existsSync(join(demo.rootPath, "app", "agent", ".box-dist"))).toBe(false); }); @@ -161,7 +163,10 @@ const TEMPLATE_DOCKERFILE = readFileSync( "utf8", ); -/** A model of runtime `agent` with no host and the policy files given. */ +/** + * A model of runtime `agent` with no host and the policy files given, with the Runtime profile build + * derived from its local profile. + */ function model(policyFiles: string[]): BoxNetwork { return { runtime: "agent", @@ -170,6 +175,12 @@ function model(policyFiles: string[]): BoxNetwork { hosts: [], envRoutes: [], policyFiles, + runtimeProfile: { + packs: ["box/base", "box/agentcore"], + ...(policyFiles.length > 0 && { policies: policyFiles }), + profile: { name: "demo" }, + }, + runtimeProfileHeader: ["Derived from .box/agent/local/profile.toml."], grantedActions: [], warnings: [], failures: [], diff --git a/src/core/project/backends/cdk.test.ts b/src/core/project/backends/cdk.test.ts index 4f1c3caa8..aea1e455c 100644 --- a/src/core/project/backends/cdk.test.ts +++ b/src/core/project/backends/cdk.test.ts @@ -353,7 +353,24 @@ describe("CdkBackend.build", () => { await mkdir(join(input.rootPath, "app", "agent"), { recursive: true }); await writeFile(join(input.rootPath, "app", "agent", "Dockerfile"), "FROM scratch\n"); - const events = await collect(harness().backend.build(input, NO_BOX_NETWORKS)); + // Build stages box from the runtime's Box network model, with its derived Runtime profile. + const boxNetworks = projectType + ? [ + { + runtime: "agent", + gateway: "agent-box-egress", + region: "us-west-2", + hosts: [], + envRoutes: [], + policyFiles: [], + runtimeProfile: { packs: ["box/base", "box/agentcore"] }, + grantedActions: [], + warnings: [], + failures: [], + }, + ] + : []; + const events = await collect(harness().backend.build(input, { boxNetworks })); const warning: ProjectEvent = { type: "warning", diff --git a/src/core/project/boxNetwork/network.ts b/src/core/project/boxNetwork/network.ts index 619940cf7..c21cbaf86 100644 --- a/src/core/project/boxNetwork/network.ts +++ b/src/core/project/boxNetwork/network.ts @@ -25,6 +25,7 @@ import { describeEntry, describeRule, ruleOrigin } from "./places"; import { placeOf, type ParsedPolicy } from "./policyParser"; import { runtimeProfileContext } from "../runtimeProfile/context"; import { deriveRuntimeProfile } from "../runtimeProfile/derive"; +import { runtimeProfileHeader } from "../runtimeProfile/rules/additions"; import type { TomlTable } from "../runtimeProfile/types"; import { withDeployRegion, type CloudWatchTelemetry } from "./telemetry"; import { outboundAuthWords, sameOutboundAuth, targetOutboundAuth } from "./projectSpec"; @@ -122,10 +123,12 @@ export interface BoxNetwork { readonly telemetry?: readonly CloudWatchTelemetry[]; /** * The AgentCore Runtime profile that build derives from the local profile (`deriveRuntimeProfile` - * in runtimeProfile/derive.ts); absent when build has no profile text. The runtime profile writer - * still writes `renderRuntimeBoxProfile` until each rule of the derivation is in place. + * in runtimeProfile/derive.ts), which the runtime profile writer stages; absent when build has no + * profile text. */ readonly runtimeProfile?: TomlTable; + /** The comment lines above {@link runtimeProfile} in the staged file. */ + readonly runtimeProfileHeader?: readonly string[]; /** * The IAM actions that the gateway's `additionalPolicies` files grant its role, except the * policy files that build writes. @@ -194,22 +197,20 @@ export function buildBoxNetwork( parsed.profile.telemetry && withDeployRegion(parsed.profile.telemetry, project.region, parsed.profile.path); const source = parsed.profile.source; - const derived = + const context = source && - deriveRuntimeProfile( - source.table, - runtimeProfileContext({ - spec: project.spec, - runtime: project.runtime, - profileFile: parsed.profile.path, - region: project.region, - gateway: { name: project.gateway, targets: project.targets }, - hosts: targets.hosts, - telemetry: telemetry?.telemetry ?? [], - policyFiles: parsed.profile.policyFiles, - places: source.places, - }), - ); + runtimeProfileContext({ + spec: project.spec, + runtime: project.runtime, + profileFile: parsed.profile.path, + region: project.region, + gateway: { name: project.gateway, targets: project.targets }, + hosts: targets.hosts, + telemetry: telemetry?.telemetry ?? [], + policyFiles: parsed.profile.policyFiles, + places: source.places, + }); + const derived = source && context && deriveRuntimeProfile(source.table, context); failures.push( ...(derived?.problems ?? []).map(({ code, reason, place }) => ({ code, reason, place })), ); @@ -221,7 +222,11 @@ export function buildBoxNetwork( envRoutes: envRoutesOf(targets.hosts), policyFiles: parsed.profile.policyFiles, ...(telemetry && { telemetry: telemetry.telemetry }), - ...(derived && { runtimeProfile: derived.profile }), + ...(derived && + context && { + runtimeProfile: derived.profile, + runtimeProfileHeader: runtimeProfileHeader(context, derived.profile), + }), grantedActions: project.grantedActions, warnings: [ ...hostWarnings(targets.hosts), diff --git a/src/core/project/boxNetworkWriters.test.ts b/src/core/project/boxNetworkWriters.test.ts index 75fa678b7..9b5c4356e 100644 --- a/src/core/project/boxNetworkWriters.test.ts +++ b/src/core/project/boxNetworkWriters.test.ts @@ -15,6 +15,7 @@ import { type BoxNetworkWriter, } from "./boxNetworkWriters"; import { AGENTCORE_CODEZIP_PACK_PATH, AGENTCORE_PACK_PATH } from "./templates/boxProfile"; +import { serializeRuntimeProfile } from "./runtimeProfile/serialize"; /** A hand-built model of runtime `agent`, which each test changes as it needs. */ function network(overrides: Partial = {}): BoxNetwork { @@ -25,6 +26,8 @@ function network(overrides: Partial = {}): BoxNetwork { hosts: [], envRoutes: [], policyFiles: [], + runtimeProfile: { packs: ["box/base", "box/agentcore"], profile: { name: "demo" } }, + runtimeProfileHeader: ["Derived from .box/agent/local/profile.toml."], grantedActions: [], warnings: [], failures: [], @@ -445,7 +448,9 @@ describe("runtimeProfileWriter", () => { const writer = runtimeProfileWriter([ { runtime: "agent", dist: "app/agent/.box-dist", kind: "codezip" }, ]); - const models = [network({ policyFiles: ["policy.dw", "rules/extra.dw"] })]; + const policies = ["policy.dw", "rules/extra.dw"]; + const runtimeProfile = { packs: ["box/base", "box/agentcore"], policies }; + const models = [network({ policyFiles: policies, runtimeProfile })]; const { files } = run([writer], models); @@ -464,8 +469,19 @@ describe("runtimeProfileWriter", () => { { path: "app/agent/.box-dist/policy.dw", copyOf: ".box/agent/local/policy.dw" }, { path: "app/agent/.box-dist/rules/extra.dw", copyOf: ".box/agent/local/rules/extra.dw" }, ]); - expect("text" in files[0]! && files[0].text).toContain( - 'policies = ["policy.dw", "rules/extra.dw"]', + // The profile is the one build derived from the local profile, after its header. + expect("text" in files[0]! && files[0].text).toBe( + serializeRuntimeProfile(runtimeProfile, ["Derived from .box/agent/local/profile.toml."]), + ); + }); + + test("stops for a runtime that it stages with no derived Runtime profile", () => { + const writer = runtimeProfileWriter([ + { runtime: "agent", dist: ".box/agent/aws", kind: "codezip" }, + ]); + + expect(() => run([writer], [])).toThrow( + 'runtime "agent" runs its agent in a box, but build has no AgentCore Runtime profile for it', ); }); diff --git a/src/core/project/boxNetworkWriters.ts b/src/core/project/boxNetworkWriters.ts index cbd9104a0..b5b54f726 100644 --- a/src/core/project/boxNetworkWriters.ts +++ b/src/core/project/boxNetworkWriters.ts @@ -38,10 +38,12 @@ import { AGENTCORE_PACK_PATH, boxAwsDir, boxLocalDir, + boxLocalProfileFile, renderAgentCoreCodeZipPack, renderAgentCorePack, - renderRuntimeBoxProfile, } from "./templates/boxProfile"; +import { serializeRuntimeProfile } from "./runtimeProfile/serialize"; +import { ProjectStateError } from "../../errors/errors"; /** Something exactly one writer owns. */ export type BoxNetworkOutput = @@ -398,9 +400,8 @@ export function runtimeProfileWriter(staged: readonly StagedRuntime[]): BoxNetwo edits: (networks, { spec }) => ({ files: staged.flatMap(({ runtime, dist, kind }) => { const network = networkOf(networks, runtime); - const entry = spec.runtimes.find(({ name }) => name === runtime)!; return [ - { path: `${dist}/profile.toml`, text: renderRuntimeBoxProfile(spec, entry, network) }, + { path: `${dist}/profile.toml`, text: runtimeProfileText(runtime, network) }, { path: `${dist}/${AGENTCORE_PACK_PATH}`, text: renderAgentCorePack(spec) }, ...(kind === "codezip" ? [ @@ -420,6 +421,21 @@ export function runtimeProfileWriter(staged: readonly StagedRuntime[]): BoxNetwo }; } +/** + * The text of the AgentCore Runtime profile of `runtime`, which build derived from its local box + * profile into the Box network model (`BoxNetwork.runtimeProfile`). + */ +function runtimeProfileText(runtime: string, network: BoxNetwork | undefined): string { + if (network?.runtimeProfile === undefined) { + throw new ProjectStateError( + `runtime "${runtime}" runs its agent in a box, but build has no AgentCore Runtime profile ` + + `for it: it derives that profile from ${boxLocalProfileFile(runtime)}, and found no ` + + "Box network for the runtime. Check that its Box gateway is in agentcore.json, then retry.", + ); + } + return serializeRuntimeProfile(network.runtimeProfile, network.runtimeProfileHeader); +} + /** The writers that build and deploy run before synth, in order. */ export const BOX_NETWORK_WRITERS: readonly BoxNetworkWriter[] = [ credentialsWriter, diff --git a/src/core/project/manager.boxNetwork.test.ts b/src/core/project/manager.boxNetwork.test.ts index b7eb05b54..faa69635f 100644 --- a/src/core/project/manager.boxNetwork.test.ts +++ b/src/core/project/manager.boxNetwork.test.ts @@ -14,7 +14,6 @@ import { boxShowOf, FakeBoxProfileResolver } from "./boxProfileResolver-test-sup import type { ResolvedBoxProfile } from "./boxProfileResolver"; import { seedBoxCache } from "./backends/box-release-test-support"; import { FsProjectManager } from "./manager"; -import { renderRuntimeBoxProfile } from "./templates/boxProfile"; /** The golden files of this suite; `RECORD=1 bun test ` rewrites them, with no AWS call. */ const FIXTURES = join(import.meta.dir, "__fixtures__"); @@ -280,11 +279,11 @@ describe("build writes the Box network of the box profile", () => { expect(profile.policies).toEqual(["policy.dw"]); expect(await text(root, "app/agent_python_strands/.box-dist/policy.dw")).toBe(POLICY); const egress = profile.egress as Record; - expect(Object.keys(egress)).toEqual([ + expect(Object.keys(egress).sort()).toEqual([ + "agentcore", + "bedrock", "egress-github", "egress-httpbin-org", - "bedrock", - "agentcore", ]); expect(egress["egress-github"]).toEqual(gatewayRoute("egress-github", "api.github.com")); expect(egress["egress-httpbin-org"]).toEqual(gatewayRoute("egress-httpbin-org", "httpbin.org")); @@ -766,8 +765,7 @@ describe("build writes the telemetry policy of the box profile", () => { ); const [network] = calls[0]!.boxNetworks; - const runtime = project.spec.runtimes[0]!; - expect(parse(renderRuntimeBoxProfile(project.spec, runtime, network)).telemetry).toEqual({ + expect(network?.runtimeProfile?.telemetry).toEqual({ logs: logsIn("ap-south-1"), }); expect(JSON.parse(await text(root, TELEMETRY_POLICY)).Statement).toEqual([ diff --git a/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json b/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json new file mode 100644 index 000000000..c1fc2af94 --- /dev/null +++ b/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json @@ -0,0 +1,13091 @@ +{ + "templates": { + "CodeZip HTTP Bedrock memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP Bedrock memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP Bedrock memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP Bedrock memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP Bedrock memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP Bedrock memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip HTTP OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP Bedrock memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP Bedrock memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP Bedrock memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP Bedrock memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP Bedrock memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP Bedrock memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip MCP OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A Bedrock memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A Bedrock memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A Bedrock memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A Bedrock memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A Bedrock memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A Bedrock memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip A2A OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI Bedrock memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI Bedrock memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI Bedrock memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI Bedrock memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI Bedrock memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI Bedrock memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "CodeZip AGUI OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP Bedrock memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP Bedrock memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP Bedrock memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP Bedrock memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP Bedrock memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP Bedrock memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container HTTP OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP Bedrock memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP Bedrock memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP Bedrock memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP Bedrock memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP Bedrock memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP Bedrock memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "Container MCP OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8001" + ], + "env": { + "PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + } + }, + "boxTemplates": { + "a2a-python-strands-box provider=of the template memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=of the template memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=of the template memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=of the template memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=of the template memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=of the template memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "a2a-python-strands-box provider=OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "http://localhost:9000/", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:9000", + "workload_port": 9001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-langchain-box provider=of the template memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-langchain-box provider=of the template memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-langchain-box provider=of the template memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-langchain-box provider=of the template memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-langchain-box provider=of the template memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-langchain-box provider=of the template memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-minimal-box provider=of the template memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-minimal-box provider=of the template memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-minimal-box provider=of the template memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-minimal-box provider=of the template memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-minimal-box provider=of the template memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-minimal-box provider=of the template memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=of the template memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=of the template memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=of the template memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=of the template memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=of the template memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=of the template memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box provider=OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ inputs.code.dir }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=of the template memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=of the template memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=of the template memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=of the template memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=of the template memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=of the template memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agent-python-strands-box-container provider=OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "read" + }, + "agent": { + "command": [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081" + ], + "env": { + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ workspace }}", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "exec": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + }, + "/usr/local/bin", + "/usr/local/lib", + "/usr/lib/aarch64-linux-gnu" + ], + "deny_write": [ + { + "path": "${{ workspace }}/.venv", + "optional": true + } + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=of the template memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=of the template memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=of the template memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=of the template memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=of the template memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=of the template memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/bedrock", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "options": { + "bedrock": { + "region": "us-west-2" + } + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=OpenAI memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=OpenAI memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=OpenAI memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=OpenAI memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=OpenAI memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "agui-python-strands-box provider=OpenAI memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PORT": "8081", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8080", + "workload_port": 8081 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "mcp-python-fastmcp-box provider=of the template memories=0 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "mcp-python-fastmcp-box provider=of the template memories=0 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "mcp-python-fastmcp-box provider=of the template memories=0 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "mcp-python-fastmcp-box provider=of the template memories=1 telemetry=none": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + }, + "mcp-python-fastmcp-box provider=of the template memories=1 telemetry=logs and traces": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "logs": { + "kind": "cloudwatch_logs", + "region": "eu-west-1", + "log_group": "/aws/box", + "log_stream": "agent", + "include": [ + "logs", + "trace" + ], + "secret": { + "ref": "aws://" + } + }, + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + } + } + }, + "mcp-python-fastmcp-box provider=of the template memories=1 telemetry=traces only": { + "packs": [ + "box/base", + "box/agentcore", + "box/agentcore-codezip" + ], + "policies": [ + "policy.dw" + ], + "profile": { + "name": "demo" + }, + "project": { + "access": "write" + }, + "agent": { + "command": [ + "${{ inputs.python.path }}", + "-m", + "main" + ], + "env": { + "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "FASTMCP_PORT": "8001", + "PYTHONUTF8": "1", + "PYTHONUNBUFFERED": "1", + "AWS_REGION": "${{ inputs.aws.region }}", + "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", + "AWS_ACCESS_KEY_ID": "box-stand-in", + "AWS_SECRET_ACCESS_KEY": "box-stand-in" + }, + "filesystem": { + "read": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}", + "/usr/lib64", + "/lib64" + ], + "exec": [ + "${{ inputs.code.dir }}", + "${{ inputs.python.prefix }}" + ] + }, + "ingress": [ + { + "listen": "0.0.0.0:8000", + "workload_port": 8001 + } + ] + }, + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "telemetry": { + "x-ray": { + "kind": "cloudwatch_traces", + "region": "us-west-2", + "secret": { + "ref": "aws://" + } + }, + "agentcore": { + "kind": "cloudwatch_logs", + "region": "${{ inputs.aws.region }}", + "log_group": "${{ inputs.runtime.log_group }}", + "log_stream": "${{ inputs.runtime.log_stream }}", + "include": [ + "deny", + "permit", + "trace" + ], + "secret": { + "ref": "aws://" + } + } + } + } + }, + "gateway": { + "first build": { + "egress": { + "orders": { + "destinations": [ + "orders.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/orders", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-github": { + "destinations": [ + "api.github.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-github", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-models-api-one-example-com": { + "destinations": [ + "api.one.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-models-api-one-example-com", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-models-api-two-example-com": { + "destinations": [ + "api.two.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-models-api-two-example-com", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-httpbin-org": { + "destinations": [ + "httpbin.org" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-httpbin-org", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "mcp": { + "docs": { + "type": "http", + "destinations": [ + "docs.example.com" + ], + "secret": { + "ref": "env://DOCS_TOKEN", + "header": "x-api-key" + }, + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-docs", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + } + }, + "next build": { + "egress": { + "orders": { + "destinations": [ + "orders.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/orders", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-github": { + "destinations": [ + "api.github.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-github", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-models-api-one-example-com": { + "destinations": [ + "api.one.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-models-api-one-example-com", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-models-api-two-example-com": { + "destinations": [ + "api.two.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-models-api-two-example-com", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-httpbin-org": { + "destinations": [ + "httpbin.org" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-httpbin-org", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "agentcore": { + "destinations": [ + "bedrock-agentcore.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/agentcore", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "mcp": { + "docs": { + "type": "http", + "destinations": [ + "docs.example.com" + ], + "secret": { + "ref": "env://DOCS_TOKEN", + "header": "x-api-key" + }, + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-docs", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + } + }, + "quoted target": { + "egress": { + "tools.v2": { + "destinations": [ + "tools.example.com:8443" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/tools.v2", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-github": { + "destinations": [ + "api.github.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-github", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-models-api-one-example-com": { + "destinations": [ + "api.one.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-models-api-one-example-com", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-models-api-two-example-com": { + "destinations": [ + "api.two.example.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-models-api-two-example-com", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "egress-httpbin-org": { + "destinations": [ + "httpbin.org" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-httpbin-org", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + }, + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "mcp": { + "docs": { + "type": "http", + "destinations": [ + "docs.example.com" + ], + "secret": { + "ref": "env://DOCS_TOKEN", + "header": "x-api-key" + }, + "backends": [ + { + "url": "${{ inputs.gateway.url }}/egress-docs", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + } + }, + "rejected entries": { + "egress": { + "bedrock": { + "destinations": [ + "bedrock-runtime.us-west-2.amazonaws.com" + ], + "backends": [ + { + "url": "${{ inputs.gateway.url }}/bedrock", + "auth": { + "ref": "aws://", + "aws": { + "service": "bedrock-agentcore", + "region": "${{ inputs.aws.region }}" + } + } + } + ] + } + }, + "mcp": {} + } + } +} diff --git a/src/core/project/runtimeProfile/context.ts b/src/core/project/runtimeProfile/context.ts index dafb65878..58fb527c7 100644 --- a/src/core/project/runtimeProfile/context.ts +++ b/src/core/project/runtimeProfile/context.ts @@ -6,7 +6,7 @@ import { posix } from "node:path"; import { parse as parseToml } from "smol-toml"; import type { ScaffoldRuntimeInput } from "../../../handlers/project/types"; import type { ProjectRuntime } from "../../../projectSchemas/runtime"; -import { renderBoxProfile } from "../templates/boxProfile"; +import { renderBoxProfile, runtimeAgentTemplate } from "../templates/boxProfile"; import { RUNTIME_INPUTS, type RuntimePaths, @@ -55,15 +55,15 @@ export function runtimePaths( } /** - * The profile that `agentcore create` writes for `runtime`, `local`, and its Runtime form with no - * route, `runtime`, as TOML tables. agentcore.json does not record the framework, and the profile - * does not depend on it beyond the container case, as in renderRuntimeBoxProfile. + * The profile that `agentcore create` writes for `runtime`, `local`, and the `[agent]` of its + * Runtime form, `runtime` (runtimeAgentTemplate), as TOML tables: a rule tells the template's own + * values from the user's by them. agentcore.json does not record the framework, and the profile + * does not depend on it beyond the container case, so the input names Strands. */ export function runtimeTemplate( projectName: string, runtime: ProjectRuntime, region: string, - policyFiles: readonly string[], ): { local: TomlTable; runtime: TomlTable } { const input = { runtimeName: runtime.name, @@ -75,11 +75,11 @@ export function runtimeTemplate( modelId: runtime.modelId, boxTemplate: true, } as ScaffoldRuntimeInput; - const table = (target: "local" | "runtime") => - parseToml( - renderBoxProfile(projectName, input, region, target, "", policyFiles) ?? "", - ) as TomlTable; - return { local: table("local"), runtime: table("runtime") }; + const agent = runtimeAgentTemplate(input); + return { + local: parseToml(renderBoxProfile(projectName, input, region) ?? "") as TomlTable, + runtime: agent ? { agent } : {}, + }; } /** @@ -126,7 +126,7 @@ export function runtimeProfileContext( return { ...rest, paths: runtimePaths(input.runtime), - template: runtimeTemplate(input.spec.name, input.runtime, input.region, input.policyFiles), + template: runtimeTemplate(input.spec.name, input.runtime, input.region), placeOf: (key) => { for (let depth = key.length; depth > 0; depth--) { const place = places.get(key.slice(0, depth).join(".")); diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts index 7d2261c4b..5f0b30695 100644 --- a/src/core/project/runtimeProfile/derive.test.ts +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -102,12 +102,15 @@ describe("runtimePaths", () => { }); describe("runtimeTemplate", () => { - test("gives the profile create writes and its Runtime form, as tables", () => { - const { local, runtime } = runtimeTemplate("demo", CODEZIP, "us-west-2", []); + test("gives the profile create writes, and the [agent] of its Runtime form in the local paths", () => { + const { local, runtime } = runtimeTemplate("demo", CODEZIP, "us-west-2"); expect((local.agent as { command: string[] }).command).toContain("--reload"); - expect((runtime.agent as { command: string[] }).command[0]).toBe("${{ inputs.python.path }}"); - expect(runtime.packs).toContain("box/agentcore-codezip"); + expect(Object.keys(runtime)).toEqual(["agent"]); + const agent = runtime.agent as { command: string[]; env: Record }; + expect(agent.command).not.toContain("--reload"); + expect(agent.command[0]).toBe("${{ workspace }}/app/agent/.venv/bin/python"); + expect(agent.env).not.toHaveProperty("LOCAL_DEV"); }); }); diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index fb6c6ce1c..15b5c78d7 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -10,11 +10,9 @@ import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway" import { boxGatewaySpec, type ProjectSpec } from "../../../../projectSchemas/project"; import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; import { cloudWatchTelemetry, withDeployRegion, type CloudWatchTelemetry } from "../../boxNetwork"; -import { - renderAgentCorePack, - renderBoxProfile, - renderRuntimeBoxProfile, -} from "../../templates/boxProfile"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; +import { renderAgentCorePack, renderBoxProfile } from "../../templates/boxProfile"; import { runtimeProfileContext } from "../context"; import { deriveRuntimeProfile } from "../derive"; import { serializeRuntimeProfile } from "../serialize"; @@ -103,7 +101,7 @@ function createdProfile(runtime: ProjectRuntime): TomlTable { modelProvider: runtime.modelProvider, boxTemplate: true, } as ScaffoldRuntimeInput; - return parse(renderBoxProfile("demo", input, CREATE_REGION, "local")!) as TomlTable; + return parse(renderBoxProfile("demo", input, CREATE_REGION)!) as TomlTable; } /** The `[telemetry]` of a local profile: a CloudWatch target of each kind, signed under dev. */ @@ -139,6 +137,20 @@ const TELEMETRY_CASES: Record = { "traces only": { "x-ray": CLOUDWATCH["x-ray"] }, }; +/** + * What the Runtime renderer that the derivation replaced wrote: the owned tables for each build and + * protocol (`templates`), the whole profile for each box template of create (`boxTemplates`), and + * the gateway fixture. Recorded from renderRuntimeBoxProfile of box-integration (f5503f02), with + * the default telemetry target, before that renderer was deleted. + */ +const OLD_RENDERER = JSON.parse( + readFileSync(join(import.meta.dir, "..", "__fixtures__", "old-renderer-tables.json"), "utf8"), +) as { + templates: Record; + boxTemplates: Record; + gateway: Record; +}; + /** The tables that the additions rule owns, which the old renderer wrote. */ const OWNED = [ "packs", @@ -181,7 +193,7 @@ describe("deriveRuntimeProfile on the created templates", () => { ); test.each(cases)( - "gives the tables the old renderer wrote, and the default target with no cloudwatch_logs target ($build $protocol $provider, memories $memories, telemetry $telemetry)", + "gives the tables the old renderer wrote (recorded in __fixtures__), and the default target with no cloudwatch_logs target ($build $protocol $provider, memories $memories, telemetry $telemetry)", ({ build, protocol, provider, memories, telemetry: telemetryCase }) => { const runtime = runtimeOf(build, protocol, provider); const local = createdProfile(runtime); @@ -197,28 +209,17 @@ describe("deriveRuntimeProfile on the created templates", () => { PROFILE_FILE, ).telemetry; const policyFiles = extras ? ["policy.dw"] : []; - const spec = specOf(runtime, memories); - const old = parse( - renderRuntimeBoxProfile(spec, runtime, { - policyFiles, - region: BUILD_REGION, - hosts: [], - telemetry, - }), - ) as TomlTable; - const { profile, problems } = deriveRuntimeProfile( local, contextOf(runtime, { memories, telemetry, policyFiles }), ); - const logs = telemetry.some(({ kind }) => kind === "cloudwatch_logs"); - const expected: TomlTable = { - ...old, - telemetry: { ...(old.telemetry as TomlTable), ...(!logs && { agentcore: DEFAULT_TARGET }) }, - }; + const expected = OLD_RENDERER.templates[ + `${build} ${protocol} ${provider} memories=${memories.length} telemetry=${telemetryCase}` + ] as TomlTable; expect(problems).toEqual([]); - for (const key of OWNED) expect([key, profile[key]]).toEqual([key, expected[key]]); + for (const key of OWNED) + expect([key, profile[key]]).toEqual([key, expected[key] ?? undefined]); }, ); }); @@ -271,14 +272,14 @@ describe("deriveRuntimeProfile on each box template of create", () => { }); test.each(cases)( - "gives the whole profile that the old renderer wrote, with the default target when no target is cloudwatch_logs ($template, provider $provider, memories $memories, telemetry $telemetry)", + "gives the whole profile that the old renderer wrote (recorded in __fixtures__), with the default target when no target is cloudwatch_logs ($template, provider $provider, memories $memories, telemetry $telemetry)", ({ template, provider, memories, telemetry: telemetryCase }) => { const input = resolveRuntimeTemplateShortcut( template as RuntimeTemplateShortcutName, provider === "OpenAI" ? { modelProvider: "OpenAI", apiKey: "sk-test" } : {}, ); const runtime = createdRuntime(input); - const local = parse(renderBoxProfile("demo", input, CREATE_REGION, "local")!) as TomlTable; + const local = parse(renderBoxProfile("demo", input, CREATE_REGION)!) as TomlTable; const tables = TELEMETRY_CASES[telemetryCase]; const extras = tables !== undefined; if (extras) { @@ -291,27 +292,18 @@ describe("deriveRuntimeProfile on each box template of create", () => { PROFILE_FILE, ).telemetry; const policyFiles = extras ? ["policy.dw"] : []; - const old = parse( - renderRuntimeBoxProfile(specOf(runtime, memories), runtime, { - policyFiles, - region: BUILD_REGION, - hosts: [], - telemetry, - }), - ) as TomlTable; const { profile, problems } = deriveRuntimeProfile( local, contextOf(runtime, { memories, telemetry, policyFiles }), ); - const logs = telemetry.some(({ kind }) => kind === "cloudwatch_logs"); - const expected: TomlTable = { - ...old, - telemetry: { ...(old.telemetry as TomlTable), ...(!logs && { agentcore: DEFAULT_TARGET }) }, - }; expect(problems).toEqual([]); - expect(profile).toEqual(expected); + expect(profile).toEqual( + OLD_RENDERER.boxTemplates[ + `${template} provider=${provider} memories=${memories.length} telemetry=${telemetryCase}` + ]!, + ); }, ); }); @@ -408,19 +400,27 @@ describe("the additions rule", () => { }); describe("[agent] command", () => { - test("gives the template's own command its Runtime command", () => { - expect(agentOf(apply(createdProfile(CODEZIP), contextOf(CODEZIP)).table).command).toEqual([ - "${{ inputs.python.path }}", + test("gives the template's own command its Runtime command, which the paths rule then moves", () => { + const runtimeCommand = (app: string, python: string) => [ + python, "-m", "uvicorn", "main:app", "--app-dir", - "${{ inputs.code.dir }}", + app, "--host", "127.0.0.1", "--port", "8081", - ]); + ]; + const local = createdProfile(CODEZIP); + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).command).toEqual( + runtimeCommand("${{ workspace }}/app/agent", "${{ workspace }}/app/agent/.venv/bin/python"), + ); + expect(agentOf(deriveRuntimeProfile(local, contextOf(CODEZIP)).profile).command).toEqual( + runtimeCommand("${{ inputs.code.dir }}", "${{ inputs.python.path }}"), + ); }); test("removes --reload and --reload-dir from a command of the user, and moves no path", () => { @@ -537,15 +537,28 @@ describe("the additions rule", () => { filesystem.write = ["/tmp/agent"]; expect(agentOf(apply(local, contextOf(CODEZIP)).table).filesystem).toEqual({ + read: [ + "${{ workspace }}/app/agent", + "${{ home }}/.local/share/uv/python", + "/usr/lib64", + "/lib64", + "${{ workspace }}/app/agent/data", + ], + exec: ["${{ workspace }}/app/agent", "${{ home }}/.local/share/uv/python"], + deny_write: ["${{ workspace }}/app/agent/secrets"], + write: ["/tmp/agent"], + }); + // The paths rule moves each path of the project after this rule. + expect(agentOf(deriveRuntimeProfile(local, contextOf(CODEZIP)).profile).filesystem).toEqual({ read: [ "${{ inputs.code.dir }}", "${{ inputs.python.prefix }}", "/usr/lib64", "/lib64", - "${{ workspace }}/app/agent/data", + "${{ inputs.code.dir }}/data", ], exec: ["${{ inputs.code.dir }}", "${{ inputs.python.prefix }}"], - deny_write: ["${{ workspace }}/app/agent/secrets"], + deny_write: ["${{ inputs.code.dir }}/secrets"], write: ["/tmp/agent"], }); }); diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index 324bffb17..38cc3b510 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -23,7 +23,8 @@ import { gatewayTargetsWriter, } from "../../boxNetworkWriters"; import { boxNetworkRules } from "../../boxProfileResolver-test-support"; -import { renderRuntimeBoxProfile } from "../../templates/boxProfile"; +import { readFileSync } from "node:fs"; +import { join } from "node:path"; import { profileKeyPlaces, runtimeProfileContext } from "../context"; import { deriveRuntimeProfile } from "../derive"; import { serializeRuntimeProfile } from "../serialize"; @@ -388,7 +389,21 @@ describe("the gateway rule for an HTTP [mcp] server", () => { * agentcore.json as build writes it, has the same `[egress]` and HTTP `[mcp]` tables as the * profile that build derives from the local profile. */ -describe("the gateway rule and renderRuntimeBoxProfile", () => { +/** + * The `[egress]` and HTTP `[mcp]` tables that the Runtime renderer that the derivation replaced + * wrote for each case below, recorded before that renderer was deleted. + */ +const OLD_RENDERER = JSON.parse( + readFileSync(join(import.meta.dir, "..", "__fixtures__", "old-renderer-tables.json"), "utf8"), +).gateway as Record; + +/** The tables of the old renderer for `label`, as parse gives them. */ +function rendered(label: string): TomlTable { + const { egress, mcp } = OLD_RENDERER[label]!; + return { ...(egress && { egress }), ...(Object.keys(mcp).length > 0 && { mcp }) }; +} + +describe("the gateway rule and the Runtime renderer it replaced", () => { const TEXT = [ 'packs = ["box/base", "box/bedrock"]', 'policies = ["policy.dw"]', @@ -511,12 +526,7 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { places: profileKeyPlaces(text, PROFILE), }), ); - return { - network, - written, - rendered: parse(renderRuntimeBoxProfile(written, RUNTIME, network)) as TomlTable, - derived, - }; + return { network, written, derived }; } const http = (mcp: unknown) => Object.fromEntries( @@ -526,11 +536,12 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { ); test("give the same [egress] and HTTP [mcp] tables on the first build", () => { - const { network, rendered, derived } = bothProfiles(project(TARGETS, ["agentMemory"])); + const { network, derived } = bothProfiles(project(TARGETS, ["agentMemory"])); + const old = rendered("first build"); expect(network.failures).toEqual([]); expect(derived.problems).toEqual([]); - expect(Object.keys(rendered.egress as TomlTable).sort()).toEqual([ + expect(Object.keys(old.egress as TomlTable).sort()).toEqual([ "agentcore", "bedrock", "egress-github", @@ -539,38 +550,38 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { "egress-models-api-two-example-com", "orders", ]); - expect(Object.keys(http(rendered.mcp))).toEqual(["docs"]); - expect(derived.profile.egress).toEqual(rendered.egress); - expect(http(derived.profile.mcp)).toEqual(http(rendered.mcp)); + expect(Object.keys(http(old.mcp))).toEqual(["docs"]); + expect(derived.profile.egress).toEqual(old.egress); + expect(http(derived.profile.mcp)).toEqual(http(old.mcp)); // The model that build keeps holds the same derived profile. - expect(network.runtimeProfile?.egress).toEqual(rendered.egress); - expect(http(network.runtimeProfile?.mcp)).toEqual(http(rendered.mcp)); + expect(network.runtimeProfile?.egress).toEqual(old.egress); + expect(http(network.runtimeProfile?.mcp)).toEqual(http(old.mcp)); }); test("give the same tables on the next build, from the agentcore.json of the first build", () => { const first = bothProfiles(project(TARGETS, ["agentMemory"])).written; - const { network, rendered, derived } = bothProfiles(first); + const { network, derived } = bothProfiles(first); + const old = rendered("next build"); expect(network.failures).toEqual([]); expect(first.agentCoreGateways[0]!.targets.map(({ name }) => name)).toContain("egress-github"); - expect(derived.profile.egress).toEqual(rendered.egress); - expect(http(derived.profile.mcp)).toEqual(http(rendered.mcp)); + expect(derived.profile.egress).toEqual(old.egress); + expect(http(derived.profile.mcp)).toEqual(http(old.mcp)); }); test("give the same tables for a target name that TOML must quote, and a port", () => { - const { rendered, derived } = bothProfiles( + const { derived } = bothProfiles( project([passthrough("tools.v2", "https://tools.example.com:8443/api")]), ); + const old = rendered("quoted target"); const quoted = parse( '[egress."tools.v2"]\ndestinations = ["tools.example.com:8443"]\n' + backendText('egress."tools.v2"', "tools.v2"), ).egress as TomlTable; - expect((rendered.egress as TomlTable)["tools.v2"]).toEqual(quoted["tools.v2"]); - expect(derived.profile.egress).toEqual(rendered.egress); - expect(parse(serializeRuntimeProfile(derived.profile)).egress as unknown).toEqual( - rendered.egress, - ); + expect((old.egress as TomlTable)["tools.v2"]).toEqual(quoted["tools.v2"]); + expect(derived.profile.egress).toEqual(old.egress); + expect(parse(serializeRuntimeProfile(derived.profile)).egress as unknown).toEqual(old.egress); }); test("give no second problem for an entry that the Box network model rejects, and no route", () => { @@ -580,7 +591,8 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { const egress = { wide: { destinations: ["*.wide.example.com"] } }; const mcp = { pathed: { type: "http", destinations: ["docs.example.com/mcp"] } }; - const { network, rendered, derived } = bothProfiles(project(), { + const old = rendered("rejected entries"); + const { network, derived } = bothProfiles(project(), { text, egress, mcp, @@ -595,8 +607,8 @@ describe("the gateway rule and renderRuntimeBoxProfile", () => { ["MCP_DESTINATION_NOT_ONE_HOST", "pathed"], ]); expect(derived.problems).toEqual([]); - expect(derived.profile.egress).toEqual(rendered.egress); + expect(derived.profile.egress).toEqual(old.egress); expect(derived.profile.mcp).toBeUndefined(); - expect(rendered.mcp).toBeUndefined(); + expect(old.mcp).toBeUndefined(); }); }); diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 212f7ef7e..5f0c5578f 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -103,8 +103,8 @@ const LEAVES_ON_RUNTIME = { describe("the paths rule", () => { test("keeps each stdio [mcp] server and each [tool], with each key, in the Runtime profile", () => { - // Today renderRuntimeBoxProfile builds the Runtime profile from agentcore.json, and it has no - // [mcp.notes] and no [tool.lister]. The derived profile keeps both, as they work there. + // The renderer that the derivation replaced built the Runtime profile from agentcore.json, with + // no [mcp.notes] and no [tool.lister]. The derived profile keeps both, as they work there. const { profile, problems } = deriveRuntimeProfile( parse(LEAVES) as TomlTable, contextOf(LEAVES), diff --git a/src/core/project/templates/boxProfile.test.ts b/src/core/project/templates/boxProfile.test.ts index 829de4a32..70b53e1ae 100644 --- a/src/core/project/templates/boxProfile.test.ts +++ b/src/core/project/templates/boxProfile.test.ts @@ -1,24 +1,18 @@ import { describe, expect, test } from "bun:test"; import { parse } from "smol-toml"; -import { InputValidationError } from "../../../errors/errors"; import { - getBoxGatewayAgentCoreTargetSpec, - getBoxGatewayBedrockTargetSpec, resolveRuntimeTemplateShortcut, type RuntimeTemplateShortcutName, } from "../../../handlers/project/shortcuts"; import type { ModelProvider } from "../../../handlers/project/types"; -import type { AgentCoreGatewayTarget } from "../../../projectSchemas/gateway"; -import { cloudWatchTelemetry, withDeployRegion, type BoxNetworkHost } from "../boxNetwork"; -import { boxGatewaySpec, type ProjectSpec } from "../../../projectSchemas/project"; -import type { ProjectRuntime } from "../../../projectSchemas/runtime"; +import { type ProjectSpec } from "../../../projectSchemas/project"; import { boxProfileWarnings, hasBoxProfile, renderAgentCoreCodeZipPack, renderAgentCorePack, renderBoxProfile, - renderRuntimeBoxProfile, + runtimeAgentTemplate, startsInBoxOnCodeZip, } from "./boxProfile"; @@ -320,538 +314,61 @@ describe("renderBoxProfile", () => { }); }); -function runtimeProfile(name: RuntimeTemplateShortcutName, overrides: Record = {}) { - return parse( - renderBoxProfile("V3Demo", template(name, overrides), "us-west-2", "runtime")!, - ) as Record; -} - -/** The stand-in AWS keys the Runtime profile gives boto3, which box re-signs for the gateway. */ -const RUNTIME_AWS_STAND_INS = { - AWS_ACCESS_KEY_ID: "box-stand-in", - AWS_SECRET_ACCESS_KEY: "box-stand-in", -}; - -/** 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 = { - read: ["${{ workspace }}", "/usr/local/lib", "/usr/lib/aarch64-linux-gnu"], - exec: [ - { path: "${{ workspace }}/.venv", optional: true }, - "/usr/local/bin", - "/usr/local/lib", - "/usr/lib/aarch64-linux-gnu", - ], - deny_write: [{ path: "${{ workspace }}/.venv", optional: true }], -}; - -describe("renderBoxProfile for AgentCore Runtime", () => { - test("names no model host of its own: agentcore.json has no base URL, the Box gateway routes it", () => { - // What deploy renders from agentcore.json, which records no --api-base. - const spec = { - name: "V3Demo", - runtimes: [ - { name: "agent", build: "CodeZip", protocol: "HTTP", modelProvider: "OpenAICompatible" }, +describe("runtimeAgentTemplate", () => { + test("gives a CodeZip template's [agent] on the Runtime in the local paths, with no reload", () => { + expect(runtimeAgentTemplate(STRANDS)).toEqual({ + command: [ + "${{ workspace }}/app/agent/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}/app/agent", + "--host", + "127.0.0.1", + "--port", + "8081", ], - agentCoreGateways: [], - } as unknown as ProjectSpec; - const text = renderRuntimeBoxProfile(spec, spec.runtimes[0]!); - expect(text).not.toContain("api.openai.com"); - expect((parse(text) as { egress?: unknown }).egress).toBeUndefined(); - }); - - 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" }], - agentCoreGateways: [], - } as unknown as ProjectSpec; - const profile = parse(renderRuntimeBoxProfile(spec, spec.runtimes[0]!)) as Record; - - 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 }}"); - }); - - test("runs agent-python-strands from the zip with the Runtime's Python, read through the packs", () => { - const text = renderBoxProfile( - "V3Demo", - template("agent-python-strands"), - "us-west-2", - "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).not.toContain("# @AGENT_ENV@"); - expect(parse(text)).toEqual({ - packs: ["box/base", "box/bedrock", "box/agentcore", "box/agentcore-codezip"], - profile: { name: "V3Demo" }, - project: { access: "write" }, - options: { bedrock: { region: "us-west-2" } }, - agent: { - command: [ - "${{ inputs.python.path }}", - "-m", - "uvicorn", - "main:app", - "--app-dir", - "${{ inputs.code.dir }}", - "--host", - "127.0.0.1", - "--port", - "8081", + env: { PORT: "8081", PYTHONUTF8: "1", PYTHONUNBUFFERED: "1" }, + filesystem: { + read: [ + "${{ workspace }}/app/agent", + "${{ home }}/.local/share/uv/python", + "/usr/lib64", + "/lib64", ], - env: { - PORT: "8081", - PYTHONPATH: "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", - PYTHONUNBUFFERED: "1", - PYTHONUTF8: "1", - ...RUNTIME_AWS_STAND_INS, - ...RUNTIME_REGION_WITH_BEDROCK, - }, - filesystem: { - read: ["${{ inputs.code.dir }}", "${{ inputs.python.prefix }}", "/usr/lib64", "/lib64"], - exec: ["${{ inputs.code.dir }}", "${{ inputs.python.prefix }}"], - }, - ingress: [{ listen: "0.0.0.0:8080", workload_port: 8081 }], + exec: ["${{ workspace }}/app/agent", "${{ home }}/.local/share/uv/python"], }, + ingress: [{ listen: "0.0.0.0:8080", workload_port: 8081 }], }); }); - test.each(["agent-python-strands-container"] as const)( - "runs %s from /app without --reload, signing calls with the Runtime's role", - (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).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"], - profile: { name: "V3Demo" }, - project: { access: "read" }, - options: { bedrock: { region: "us-west-2" } }, - agent: { - command: [ - "${{ workspace }}/.venv/bin/python", - "-m", - "uvicorn", - "main:app", - "--app-dir", - "${{ workspace }}", - "--host", - "127.0.0.1", - "--port", - "8081", - ], - env: { - PORT: "8081", - PYTHONUNBUFFERED: "1", - PYTHONUTF8: "1", - ...RUNTIME_AWS_STAND_INS, - ...RUNTIME_REGION_WITH_BEDROCK, - }, - filesystem: IMAGE_PYTHON_FILESYSTEM, - ingress: [{ listen: "0.0.0.0:8080", workload_port: 8081 }], - }, - }); - }, - ); - - test("serves the MCP server on all interfaces on the Runtime", () => { - const mcp = runtimeProfile("mcp-python-fastmcp"); - expect(mcp.agent.ingress).toEqual([{ listen: "0.0.0.0:8000", workload_port: 8001 }]); - // The template has no default Memory route; build and deploy add it when the project has one. - expect(mcp.egress).toBeUndefined(); - }); - - test("gives a non-Bedrock model no route, since its key comes from AgentCore Identity", () => { - const openai = runtimeProfile("agent-python-strands", { - modelProvider: "OpenAI", - apiKey: "sk-test", - }); - expect(openai.packs).toEqual(["box/base", "box/agentcore", "box/agentcore-codezip"]); - expect(openai.egress).toBeUndefined(); - }); -}); - -describe("renderRuntimeBoxProfile", () => { - const GITHUB: AgentCoreGatewayTarget = { - name: "github", - targetType: "passthrough", - passthrough: { endpoint: "https://api.github.com" }, - outboundAuth: { type: "NONE" }, - } as AgentCoreGatewayTarget; - - function passthrough(name: string, endpoint: string): AgentCoreGatewayTarget { - return { ...GITHUB, name, passthrough: { endpoint } } as AgentCoreGatewayTarget; - } - - /** A Box project whose runtime `agent`'s Box gateway holds `targets`. */ - function spec( - memories: string[], - runtime: Partial = {}, - targets: AgentCoreGatewayTarget[] = [], - ) { - return { - name: "V3Demo", - runtimes: [ - { - name: "agent", - build: "CodeZip", - entrypoint: "start.py", - codeLocation: "app/agent", - protocol: "HTTP", - modelProvider: "Bedrock", - ...runtime, - } as ProjectRuntime, - ], - memories: memories.map((name) => ({ name, eventExpiryDuration: 30, strategies: [] })), - projectType: "box", - agentCoreGateways: [{ ...boxGatewaySpec("agent"), targets }], - } as unknown as ProjectSpec; - } - - const egressOf = (project: ProjectSpec) => - (parse(renderRuntimeBoxProfile(project, project.runtimes[0]!)).egress ?? {}) as Record< - string, - unknown - >; - - /** The route a passthrough target gets: its host, sent to the target, signed for the gateway. */ - const gatewayRoute = (target: string, host: string) => ({ - // No destination secret: the backend's own auth signs the call to the gateway. - destinations: [host], - backends: [ - { - url: `\${{ inputs.gateway.url }}/${target}`, - // Signed for the Runtime's own region, which box reads from AWS_REGION there. - auth: { - ref: "aws://", - aws: { service: "bedrock-agentcore", region: "${{ inputs.aws.region }}" }, - }, - }, - ], - }); - - test("signs a container's gateway route with a bare aws://, from the gateway URL input", () => { - const container = spec([], { build: "Container", entrypoint: "main.py" }, [ - getBoxGatewayAgentCoreTargetSpec(), - ]); - expect(egressOf(container).agentcore as unknown).toEqual({ - destinations: ["bedrock-agentcore.us-west-2.amazonaws.com"], - backends: [ - { - // The gateway URL comes from the agentcore pack's input, not a start.sh placeholder. - url: "${{ inputs.gateway.url }}/agentcore", - auth: { - ref: "aws://", - aws: { service: "bedrock-agentcore", region: "${{ inputs.aws.region }}" }, - }, - }, - ], - }); - }); - - test("names the model's policy files under policies, at the top of the profile", () => { - const project = spec([]); - const text = renderRuntimeBoxProfile(project, project.runtimes[0]!, { - policyFiles: ["policy.dw", "rules/extra.dw"], - }); - - expect(parse(text).policies).toEqual(["policy.dw", "rules/extra.dw"]); - expect(text).toContain('policies = ["policy.dw", "rules/extra.dw"]\n'); - expect(parse(renderRuntimeBoxProfile(project, project.runtimes[0]!)).policies).toBeUndefined(); - }); - - test("routes the default Memory's calls through the Box gateway's agentcore target", () => { - const project = spec(["agentMemory"], {}, [getBoxGatewayAgentCoreTargetSpec()]); - - expect(egressOf(project).agentcore).toEqual( - gatewayRoute("agentcore", "bedrock-agentcore.us-west-2.amazonaws.com"), - ); - }); - - test("routes no Memory calls when the project has only another Memory", () => { - expect(egressOf(spec(["ordersMemory"]))).toEqual({}); - }); - - test("gives each passthrough target of the runtime's Box gateway one route to it", () => { - const project = spec([], {}, [ - getBoxGatewayBedrockTargetSpec(), - getBoxGatewayAgentCoreTargetSpec(), - GITHUB, + test("gives the container template's [agent] on the Runtime, which keeps the image's paths", () => { + const agent = runtimeAgentTemplate(template("agent-python-strands-container"))!; + const local = profile("agent-python-strands-container").agent; + + expect(agent.command).toEqual([ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--host", + "127.0.0.1", + "--port", + "8081", ]); - - expect(egressOf(project)).toEqual({ - // The model calls go through the gateway's bedrock target, which build adds. - bedrock: gatewayRoute("bedrock", "bedrock-runtime.us-west-2.amazonaws.com"), - agentcore: gatewayRoute("agentcore", "bedrock-agentcore.us-west-2.amazonaws.com"), - github: gatewayRoute("github", "api.github.com"), - }); + expect(local.command).toContain("--reload"); + expect(agent.env).toEqual({ PORT: "8081", PYTHONUTF8: "1", PYTHONUNBUFFERED: "1" }); + expect(agent.filesystem).toEqual(local.filesystem); + expect(agent.ingress).toEqual(local.ingress); }); - test("signs each route for the gateway in the Runtime's own region", () => { - const project = spec([], {}, [getBoxGatewayBedrockTargetSpec("eu-central-1")]); - const profile = parse( - renderRuntimeBoxProfile(project, project.runtimes[0]!, { - policyFiles: [], - region: "eu-central-1", - }), + test("gives no [agent] for a template that is not a box template", () => { + expect(runtimeAgentTemplate(resolveRuntimeTemplateShortcut("agent-python-strands"))).toBe( + undefined, ); - - expect(profile.options).toEqual({ bedrock: { region: "eu-central-1" } }); - expect((profile.egress as Record).bedrock).toEqual({ - destinations: ["bedrock-runtime.eu-central-1.amazonaws.com"], - backends: [ - { - url: "${{ inputs.gateway.url }}/bedrock", - // The gateway is in the Runtime's region, which box reads from AWS_REGION there. - auth: { - ref: "aws://", - aws: { service: "bedrock-agentcore", region: "${{ inputs.aws.region }}" }, - }, - }, - ], - }); - }); - - test("keeps the endpoint's port, and quotes a target name that is not a bare TOML key", () => { - const project = spec([], {}, [passthrough("tools.v2", "https://tools.example.com:8443/api")]); - - expect(egressOf(project)["tools.v2"]).toEqual( - gatewayRoute("tools.v2", "tools.example.com:8443"), - ); - }); - - test("gives a target that is not passthrough no route", () => { - const lambda = { name: "orders", targetType: "lambda" } as unknown as AgentCoreGatewayTarget; - - expect(egressOf(spec([], {}, [lambda]))).toEqual({}); - }); - - test("finds the runtime's Box gateway by boundRuntime, not by name", () => { - const project = spec([], {}, [GITHUB]); - project.agentCoreGateways[0] = { ...project.agentCoreGateways[0]!, name: "renamed" }; - - expect(egressOf(project).github).toEqual(gatewayRoute("github", "api.github.com")); - expect(renderRuntimeBoxProfile(project, project.runtimes[0]!)).toContain( - "through the 'renamed' gateway's 'github' target", - ); - }); - - test("routes nothing through a gateway outside a Box project", () => { - const project = spec([], {}, [GITHUB]); - delete (project as { projectType?: string }).projectType; - - expect(egressOf(project)).toEqual({}); - }); - - test("refuses two passthrough targets for one host, which would give two routes to it", () => { - const project = spec([], {}, [GITHUB, passthrough("github-v2", "https://api.github.com/v2")]); - - expect(() => renderRuntimeBoxProfile(project, project.runtimes[0]!)).toThrow( - new InputValidationError( - "gateway 'agent-box-egress' has two passthrough targets for api.github.com, 'github' and " + - "'github-v2', so runtime 'agent' would get two routes to one host. Remove one of them.", - ), - ); - }); - - describe("for an HTTP MCP server", () => { - const TOOLS = passthrough("egress-tools", "https://tools.example.com"); - const BACKENDS = gatewayRoute("egress-tools", "tools.example.com").backends; - /** The model's host for the server `tools`, which the target `egress-tools` serves. */ - const toolsHost = (secret?: Record) => - ({ - host: "tools.example.com", - authority: "tools.example.com", - sources: [ - { - kind: "mcp", - mcpEntry: "tools", - destinations: ["tools.example.com"], - ...(secret && { secret }), - }, - { kind: "rule", ruleId: "mcp_tools_connect" }, - ], - outboundAuth: { kind: "none" }, - reachable: true, - target: "egress-tools", - allowed: 3, - samples: 3, - forbiddenBy: [], - enforcedByBox: [], - }) as BoxNetworkHost; - const rendered = (secret?: Record) => { - const project = spec([], {}, [TOOLS]); - const text = renderRuntimeBoxProfile(project, project.runtimes[0]!, { - policyFiles: [], - hosts: [toolsHost(secret)], - }); - return { - text, - toml: parse(text) as { egress?: Record; mcp?: Record }, - }; - }; - - test("writes the server's target as the server, with its env:// secret, and no [egress] route", () => { - const { text, toml } = rendered({ - ref: "env://TOOLS_TOKEN", - header: "x-api-key", - phantom_prefix: "tk-", - inject: "always", - }); - - expect(toml.egress?.["egress-tools"]).toBeUndefined(); - expect(toml.mcp).toEqual({ - tools: { - type: "http", - destinations: ["tools.example.com"], - // The agent keeps its stand-in; inject has no effect beside a backend, and Box refuses it. - secret: { ref: "env://TOOLS_TOKEN", header: "x-api-key", phantom_prefix: "tk-" }, - backends: BACKENDS, - }, - }); - expect(text).toContain( - "\n# The MCP server 'tools' at tools.example.com, through the 'agent-box-egress' " + - "gateway's 'egress-tools' target.\n" + - '[mcp.tools]\ntype = "http"\ndestinations = ["tools.example.com"]\n' + - 'secret.ref = "env://TOOLS_TOKEN"\nsecret.header = "x-api-key"\n' + - 'secret.phantom_prefix = "tk-"\n\n' + - "[[mcp.tools.backends]]\n" + - 'url = "${{ inputs.gateway.url }}/egress-tools"\nauth.ref = "aws://"\n' + - 'auth.aws.service = "bedrock-agentcore"\nauth.aws.region = "${{ inputs.aws.region }}"\n', - ); - }); - - test("keeps no secret of a server that signs, or has none, as Box refuses a signed one beside a backend", () => { - for (const secret of [{ ref: "aws://default" }, undefined]) { - expect(rendered(secret).toml.mcp).toEqual({ - tools: { type: "http", destinations: ["tools.example.com"], backends: BACKENDS }, - }); - } - }); - - test("writes a target that serves no server of the model as an [egress] route", () => { - const project = spec([], {}, [TOOLS]); - const toml = parse(renderRuntimeBoxProfile(project, project.runtimes[0]!)) as { - egress: Record; - mcp?: unknown; - }; - - expect(toml.egress["egress-tools"]).toEqual( - gatewayRoute("egress-tools", "tools.example.com"), - ); - expect(toml.mcp).toBeUndefined(); - }); - }); - - describe("for the [telemetry] of the box profile", () => { - /** The resolved `[telemetry]` of a box profile with a target of each kind Box takes. */ - const TELEMETRY = { - records: { kind: "file", destination: "/tmp/records.jsonl" }, - collector: { kind: "otlp", destination: "https://collector.example.com" }, - langfuse: { kind: "langfuse", secret: { ref: "env://LANGFUSE_AUTH" } }, - langsmith: { kind: "langsmith", secret: { ref: "env://LANGSMITH_KEY" } }, - logs: { - kind: "cloudwatch_logs", - region: "us-west-2", - log_group: "/aws/box", - log_stream: "agent", - include: ["logs", "trace"], - secret: { ref: "aws://Admin-personal" }, - }, - "x-ray": { kind: "cloudwatch_traces", region: "eu-west-1", secret: { ref: "aws://" } }, - }; - /** The Runtime profile when the model sets `region` on a target with none. */ - const rendered = (telemetry: Record, region = "us-west-2") => { - const project = spec([]); - const text = renderRuntimeBoxProfile(project, project.runtimes[0]!, { - policyFiles: [], - telemetry: withDeployRegion(cloudWatchTelemetry({ telemetry }), region, "profile.toml") - .telemetry, - }); - return { text, toml: parse(text) as { telemetry?: Record } }; - }; - - test("copies each CloudWatch target with its keys, signed with the execution role", () => { - const { text, toml } = rendered(TELEMETRY); - - expect(toml.telemetry).toEqual({ - logs: { - kind: "cloudwatch_logs", - region: "us-west-2", - log_group: "/aws/box", - log_stream: "agent", - include: ["logs", "trace"], - // On the Runtime, a bare aws:// is the default credential chain: the execution role. - secret: { ref: "aws://" }, - }, - "x-ray": { - kind: "cloudwatch_traces", - region: "eu-west-1", - secret: { ref: "aws://" }, - }, - }); - expect(text).toContain( - "\n# The [telemetry.logs] target of .box/agent/local/profile.toml, signed with the " + - "execution role.\n" + - '[telemetry.logs]\nkind = "cloudwatch_logs"\nregion = "us-west-2"\n' + - 'log_group = "/aws/box"\nlog_stream = "agent"\ninclude = ["logs", "trace"]\n' + - 'secret.ref = "aws://"\n', - ); - expect(text).not.toContain("Admin-personal"); - }); - - test("copies no file, otlp, langfuse, or langsmith target", () => { - const { records, collector, langfuse, langsmith } = TELEMETRY; - - expect(rendered({ records, collector, langfuse, langsmith }).toml.telemetry).toBeUndefined(); - }); - - test("copies no CloudWatch target that Box refuses, as it grants it nothing", () => { - const logs = { ...TELEMETRY.logs, log_stream: "a:b" }; - - expect( - rendered({ logs, traces: { ...TELEMETRY["x-ray"], include: [] } }).toml.telemetry, - ).toBeUndefined(); - }); - - test("writes the deploy region on a target with no region, and keeps a target's own region", () => { - const { region: _region, ...logs } = TELEMETRY.logs; - - expect(rendered({ logs, "x-ray": TELEMETRY["x-ray"] }, "ap-south-1").toml.telemetry).toEqual({ - logs: { ...TELEMETRY.logs, region: "ap-south-1", secret: { ref: "aws://" } }, - "x-ray": { - kind: "cloudwatch_traces", - region: "eu-west-1", - secret: { ref: "aws://" }, - }, - }); - }); - }); - - test("renders the CodeZip form for start.py and the image form for a container", () => { - const codeZip = spec(["agentMemory"]); - const container = spec(["agentMemory"], { build: "Container", entrypoint: "main.py" }); - - expect(renderRuntimeBoxProfile(codeZip, codeZip.runtimes[0]!)).toContain( - '"${{ inputs.python.path }}"', - ); - expect(renderRuntimeBoxProfile(container, container.runtimes[0]!)).toContain( - '"${{ workspace }}/.venv/bin/python"', - ); - }); - - test("signs no Bedrock route for an agent on another model provider", () => { - const project = spec(["agentMemory"], { modelProvider: "OpenAI" }, [ - getBoxGatewayAgentCoreTargetSpec(), - ]); - - expect(Object.keys(egressOf(project))).toEqual(["agentcore"]); }); }); diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index 641b8b3d0..2e1150241 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -1,6 +1,6 @@ import { existsSync } from "node:fs"; import { join, posix } from "node:path"; -import { InputValidationError, ProjectStateError } from "../../../errors/errors"; +import { ProjectStateError } from "../../../errors/errors"; import { DEFAULT_EGRESS_BEDROCK_REGION, callsBedrockModel, @@ -11,7 +11,6 @@ import { memoryEnvVarName } from "../../../projectSchemas/memory"; import { isBoxProject, type ProjectSpec } from "../../../projectSchemas/project"; import { DEFAULT_MODEL_IDS, type ProjectRuntime } from "../../../projectSchemas/runtime"; import { DEV_PORTS } from "../../dev/port"; -import type { BoxHostSource, BoxNetwork, CloudWatchTelemetry } from "../boxNetwork"; import { PYTHON_ENV } from "../../dev/codezip"; import { modelProviderCredentialName } from "./runtime"; @@ -79,33 +78,6 @@ 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 - * `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 - * profile sets it only without that pack. - */ -function runtimeRegionEnv(bedrock: boolean): Record { - const region = "${{ inputs.aws.region }}"; - return { ...(!bedrock && { AWS_REGION: region }), AWS_DEFAULT_REGION: region }; -} - -/** The AWS default credential chain, which on AgentCore Runtime is the execution role. */ -const RUNTIME_AWS_SIGNER = "aws://"; - -/** - * Stand-in AWS keys for the agent on AgentCore Runtime. They let boto3 in the box sign a request, - * which box then sends to the Box gateway signed again with the execution role, so they - * authenticate nothing. box made these itself for the `aws://` secret.ref the Bedrock route had; - * a backend-only route has no secret, so the profile names them. - */ -const RUNTIME_AWS_STAND_IN_LINES = [ - "# Stand-ins so boto3 in the box can build its requests. They authenticate nothing: every AWS", - "# route goes to the Box gateway, and box signs each request for it with the execution role.", - 'AWS_ACCESS_KEY_ID = "box-stand-in"', - 'AWS_SECRET_ACCESS_KEY = "box-stand-in"', -].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 @@ -372,6 +344,12 @@ function serve( }; } +/** A filesystem grant: a path, or a path that box skips when it does not exist. */ +type Grant = string | { readonly path: string; readonly optional: true }; + +/** A grant that box skips when the path does not exist, such as a venv not yet installed. */ +const optionalGrant = (path: string): Grant => ({ path, optional: true }); + /** * Where the agent's code and venv are, and what the box grants it. The venv * is inside the project, which the agent can write, and box refuses to run a @@ -382,11 +360,9 @@ function serve( type Runner = { command: string[]; env: Record; - read: string[]; - /** Comment lines above `exec`, each ending in a newline. */ - execComment?: string; - exec: string[]; - denyWrite: string[]; + read: Grant[]; + exec: Grant[]; + denyWrite: Grant[]; }; /** A CodeZip agent: its code and venv are in the project's app/ folder. */ @@ -394,13 +370,13 @@ function codeZipRunner(protocol: Protocol, appDir: string, workloadPort: number) const { command, env } = serve(protocol, appDir, workloadPort, true); // Create runs `uv sync` with boxUvSyncEnv, so the venv links to a Python in this folder. // Optional, so a venv rebuilt on another Python still starts; that Python then needs its own grant. - const uvPython = `{ path = ${str(UV_PYTHON_INSTALL_DIR)}, optional = true }`; + const uvPython = optionalGrant(UV_PYTHON_INSTALL_DIR); return { command, env: { LOCAL_DEV: "1", ...env }, - read: [str(appDir), optional(`${appDir}/.venv`), uvPython], - exec: [optional(`${appDir}/.venv`), uvPython], - denyWrite: [optional(`${appDir}/.venv`)], + read: [appDir, optionalGrant(`${appDir}/.venv`), uvPython], + exec: [optionalGrant(`${appDir}/.venv`), uvPython], + denyWrite: [optionalGrant(`${appDir}/.venv`)], }; } @@ -417,82 +393,49 @@ function containerRunner(workloadPort: number, dev: boolean): Runner { env: { ...(dev && { LOCAL_DEV: "1" }), ...env }, // The image's Python loads its own native modules (lib-dynload) from /usr/local/lib, and the // system libraries they link, such as libssl, from the multiarch folder. - read: [str(appDir), str("/usr/local/lib"), str(LINUX_LIBRARIES)], - exec: [ - optional(`${appDir}/.venv`), - str("/usr/local/bin"), - str("/usr/local/lib"), - str(LINUX_LIBRARIES), - ], - denyWrite: [optional(`${appDir}/.venv`)], + read: [appDir, "/usr/local/lib", LINUX_LIBRARIES], + exec: [optionalGrant(`${appDir}/.venv`), "/usr/local/bin", "/usr/local/lib", LINUX_LIBRARIES], + denyWrite: [optionalGrant(`${appDir}/.venv`)], }; } /** - * 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 - * 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`. + * A CodeZip agent on AgentCore Runtime, in the paths of the local profile: the paths rule of the + * Runtime profile derivation moves them to the Runtime's code folder and Python. It does not + * reload. Box Core adds the loader folders itself and refuses exec on them, so they are read only. + * One grant may not sit inside another, so the Python's prefix covers its bin/ folder. The box + * starts in a writable folder outside the code, so nothing the agent runs needs `deny_write`. */ -function runtimeCodeZipRunner(protocol: Protocol, workloadPort: number): Runner { - const code = "${{ inputs.code.dir }}"; - const python = "${{ inputs.python.path }}"; - const pythonPrefix = "${{ inputs.python.prefix }}"; - const { command, env } = serve(protocol, code, workloadPort, false, python); +function runtimeCodeZipRunner(protocol: Protocol, appDir: string, workloadPort: number): Runner { + const { command, env } = serve(protocol, appDir, workloadPort, false); 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}`, - }, - 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" + - "# One grant may not sit inside another, so the Python prefix covers its bin/ folder.\n", - exec: [code, pythonPrefix].map(str), + env, + read: [appDir, UV_PYTHON_INSTALL_DIR, "/usr/lib64", "/lib64"], + exec: [appDir, UV_PYTHON_INSTALL_DIR], denyWrite: [], }; } -/** Which profile to render: the one `agentcore dev` runs, or the one AgentCore Runtime runs. */ -export type BoxProfileTarget = "local" | "runtime"; - /** - * The box profile that runs the scaffolded agent, or `undefined` when the - * template has none. It holds no host path: boxy fills `${{ workspace }}` (the - * folder `box run` starts in) and `${{ home }}` at run time. - * - * - `local`: what `agentcore dev` runs. On a Mac, box starts in the project - * root and names no interpreter, only the folder of every uv-managed Python, - * so it is the same with and without `--skip-install`. The agent calls - * Bedrock in `region`, the one create resolved. The container template's - * runs in its dev image, in /app. - * - `runtime`: what AgentCore Runtime runs, with no reload, signed with the - * execution role. Build and deploy render it from agentcore.json with - * {@link renderRuntimeBoxProfile}; `runtimeRoutes` holds the routes they - * derive from it, as sections that start with a blank line, and - * `runtimePolicies` the box profile's policy files, which staging copies - * beside it. + * The box profile that `agentcore dev` runs for the scaffolded agent, or `undefined` when the + * template has none. It holds no host path: box fills `${{ workspace }}` (the folder `box run` + * starts in) and `${{ home }}` at run time. On a Mac, box starts in the project root and names no + * interpreter, only the folder of every uv-managed Python, so it is the same with and without + * `--skip-install`. The agent calls Bedrock in `region`, the one create resolved. The container + * template's runs in its dev image, in /app. Build and deploy derive the AgentCore Runtime profile + * from it (runtimeProfile/derive.ts). */ export function renderBoxProfile( projectName: string, runtime: ScaffoldRuntimeInput, region: string = DEFAULT_EGRESS_BEDROCK_REGION, - target: BoxProfileTarget = "local", - runtimeRoutes = "", - runtimePolicies: readonly string[] = [], ) { if (!hasBoxProfile(runtime)) return undefined; const protocol = runtime.protocol ?? "HTTP"; - const appDir = `\${{ workspace }}/app/${runtime.runtimeName}`; const ingressPort = boxIngressPort(protocol); const workloadPort = boxWorkloadPort(protocol); - const onRuntime = target === "runtime"; const container = isBoxedContainer(runtime); // The image's agent reads /app and writes nothing there. Build resolves the profile on the host, // where the image's /app/.venv does not exist, so a write grant would leave its Python unprotected @@ -500,300 +443,105 @@ export function renderBoxProfile( const projectSection = container ? '# The agent, and the tools its packs add, can read the folder box starts in.\n[project]\naccess = "read"\n' : '# The agent, and the tools its packs add, can read and write the folder box starts in.\n[project]\naccess = "write"\n'; - const codeZipOnRuntime = onRuntime && !container; const runner = container - ? containerRunner(workloadPort, !onRuntime) - : onRuntime - ? runtimeCodeZipRunner(protocol, workloadPort) - : codeZipRunner(protocol, appDir, workloadPort); - // In an image or the Runtime's microVM, the port is reached on the machine's own address. - const listenHost = container || onRuntime ? "0.0.0.0" : "127.0.0.1"; - const callsModel = protocol !== "MCP"; + ? containerRunner(workloadPort, true) + : codeZipRunner(protocol, boxAppDir(runtime), workloadPort); + // In an image, the port is reached on the machine's own address. + const listenHost = container ? "0.0.0.0" : "127.0.0.1"; const bedrock = writesBedrockRoute(runtime); - // On the Runtime, each model route is a Box gateway target that build derives from the local - // profile's [egress] sections, so only the local profile names the provider's host here. - const keyed = callsModel && !onRuntime ? apiKeyRoute(runtime) : undefined; - const environment = { - ...runner.env, - ...PYTHON_ENV, - ...(onRuntime && runtimeRegionEnv(bedrock)), - }; - // box keeps one profile of each name on a machine, so each runtime's local profile has its own. - const profileName = onRuntime - ? projectName - : boxLocalProfileName(projectName, runtime.runtimeName); + const keyed = protocol !== "MCP" ? apiKeyRoute(runtime) : undefined; + const environment = { ...runner.env, ...PYTHON_ENV }; // 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." - : onRuntime - ? "# 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.`; - const regionComment = onRuntime - ? "" - : "# The AWS region `agentcore create` resolved. Change it to call Bedrock in another region\n" + - "# under `agentcore dev`; build and deploy set the region they deploy to.\n"; - const options = bedrock ? `[options]\n${regionComment}bedrock.region = ${str(region)}\n\n` : ""; - // Both Runtime profiles read the deployed resources' variables through the agentcore pack's inputs. - const execComment = runner.execComment ?? ""; - const denyWrite = - runner.denyWrite.length > 0 ? `deny_write = [${runner.denyWrite.join(", ")}]\n` : ""; + const header = 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.`; + const options = bedrock + ? "[options]\n" + + "# The AWS region `agentcore create` resolved. Change it to call Bedrock in another region\n" + + "# under `agentcore dev`; build and deploy set the region they deploy to.\n" + + `bedrock.region = ${str(region)}\n\n` + : ""; + const denyWrite = runner.denyWrite.length > 0 ? `deny_write = ${grants(runner.denyWrite)}\n` : ""; // box refuses to run a program from a folder that any process in the box can write, so each // tool that gets the project's write grant lists the venv too. const toolDenyWrite = !container && runner.denyWrite.length > 0 ? BOX_BASE_PROJECT_WRITE_TOOLS.map( - (tool) => `\n[tool.${tool}.filesystem]\ndeny_write = [${runner.denyWrite.join(", ")}]\n`, + (tool) => `\n[tool.${tool}.filesystem]\ndeny_write = ${grants(runner.denyWrite)}\n`, ).join("") : ""; - // Only the Runtime agent calls AgentCore: locally, LOCAL_DEV=1 skips Identity, and no memory ID - // reaches the box, so Memory is off. - const routes = onRuntime ? runtimeRoutes : ""; - const policies = - onRuntime && runtimePolicies.length > 0 - ? `# The policy files of ${boxLocalProfileFile(runtime.runtimeName)}, copied unchanged beside this profile.\npolicies = ${list([...runtimePolicies])}\n` - : ""; - const bedrockRoute = !bedrock - ? "" - : onRuntime - ? // The Box gateway's `bedrock` target makes this route, with the rest of runtimeRoutes. - "" - : ` + const bedrockRoute = bedrock + ? ` # 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. [egress.bedrock] secret.ref = "aws://default" -`; +` + : ""; const keyedRoute = keyed ? apiKeyRouteSection(keyed, apiKeyVariable(runtime, keyed)) : ""; - const packs = list([ - "box/base", - ...(bedrock ? ["box/bedrock"] : []), - // 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. - ...(codeZipOnRuntime ? [AGENTCORE_CODEZIP_PACK_NAME] : []), - ]); + const packs = list(["box/base", ...(bedrock ? ["box/bedrock"] : [])]); const env = Object.entries(environment) .map(([name, value]) => `${name} = ${str(value)}`) .join("\n"); - // On the Runtime every AWS route is a Box gateway backend, and box adds no stand-in AWS keys for - // a backend-only route, so boto3 in the box would find none and refuse to build a request. - const awsStandIns = onRuntime ? `\n${RUNTIME_AWS_STAND_IN_LINES}` : ""; + // box keeps one profile of each name on a machine, so each runtime's local profile has its own. return `# Runs the agent of the AgentCore project '${projectName}' in a box. ${header} packs = ${packs} -${policies} + [profile] -name = ${str(profileName)} +name = ${str(boxLocalProfileName(projectName, runtime.runtimeName))} ${projectSection} ${options}[agent] command = ${list(runner.command)} [agent.env] -${env}${awsStandIns} +${env} [agent.filesystem] -read = [${runner.read.join(", ")}] -${execComment}exec = [${runner.exec.join(", ")}] +read = ${grants(runner.read)} +exec = ${grants(runner.exec)} ${denyWrite} [[agent.ingress]] listen = ${str(`${listenHost}:${ingressPort}`)} workload_port = ${workloadPort} -${toolDenyWrite}${routes}${bedrockRoute}${keyedRoute}`; -} - -/** - * A route the agent's calls take on the Runtime: the box sends calls to `host` - * to the runtime's Box gateway target `target`, signing them for the gateway in - * the Runtime's region with the execution role; the gateway calls `host` with the target's - * own auth. Every `[egress.]` on the Runtime is one of these, so every - * outbound call goes through the Box gateway. Starts with a blank line. - */ -function runtimeGatewayRouteSection(gatewayName: string, target: string, host: string): string { - const key = tomlKey(target); - return ` -# Calls to ${host}, through the '${gatewayName}' gateway's '${target}' target. -[egress.${key}] -destinations = [${str(host)}] -${runtimeGatewayBackend(`egress.${key}`, target)}`; +${toolDenyWrite}${bedrockRoute}${keyedRoute}`; } -/** An HTTP MCP server of the box profile that a Box gateway target serves. */ -type RuntimeMcpServer = { readonly name: string; readonly secret?: McpSource["secret"] }; -type McpSource = Extract; - -/** - * An HTTP MCP server on the Runtime: the box sends the server's calls to `host` - * to the runtime's Box gateway target, as {@link runtimeGatewayRouteSection} - * does, and still decides each `mcp:call`, as the server keeps its name. An - * `env://` secret stays, so the agent keeps its stand-in and box removes it; the - * gateway sends the key. Box refuses a signed secret beside a backend, and - * `inject` has no effect there, so neither stays. Starts with a blank line. - */ -function runtimeMcpServerSection( - gatewayName: string, - server: RuntimeMcpServer, - target: string, - host: string, -): string { - const key = tomlKey(server.name); - const secret = server.secret?.ref.startsWith("env://") - ? Object.entries(server.secret) - .filter(([field, value]) => field !== "inject" && value !== undefined) - .map(([field, value]) => `secret.${tomlKey(field)} = ${str(value as string)}\n`) - .join("") - : ""; - return ` -# The MCP server '${server.name}' at ${host}, through the '${gatewayName}' gateway's '${target}' target. -[mcp.${key}] -type = "http" -destinations = [${str(host)}] -${secret}${runtimeGatewayBackend(`mcp.${key}`, target)}`; +/** The code folder of a box template's agent in its local profile: `${{ workspace }}/app/`. */ +function boxAppDir(runtime: ScaffoldRuntimeInput): string { + return `\${{ workspace }}/app/${runtime.runtimeName}`; } /** - * The backend of a Runtime route or MCP server: the runtime's Box gateway - * target. Both Runtime profiles read the gateway URL and the region from the - * environment through the agentcore pack's inputs, and sign with the execution - * role through a bare `aws://`, so the backend names no region. Starts with a - * blank line. + * The `[agent]` table of a box template's agent on AgentCore Runtime, or `undefined` when the + * template has none: what the additions rule of the Runtime profile derivation gives each value + * that is the template's own. It names the paths of the local profile, which the paths rule then + * moves. It differs from the local `[agent]` only where the Runtime needs it: no reload and no + * `LOCAL_DEV`, the ingress on every address, and for CodeZip the Runtime's loader folders read and + * no `deny_write`. */ -function runtimeGatewayBackend(table: string, target: string): string { - return ` -[[${table}.backends]] -url = ${str(`\${{ inputs.gateway.url }}/${target}`)} -auth.ref = ${str(RUNTIME_AWS_SIGNER)} -auth.aws.service = "bedrock-agentcore" -auth.aws.region = "\${{ inputs.aws.region }}" -`; -} - -/** - * The Runtime routes of a runtime: one for each passthrough target of its Box gateway (the - * gateway bound to it), named for the target and sent to it, so a target in agentcore.json is - * what gives the boxed agent a route. A target that serves an HTTP MCP server of `servers` is - * that `[mcp.]`, and every other target is an `[egress.]`. Build adds the targets - * it needs, the model's `bedrock` and Memory's `agentcore` (see `addBoxGatewayTargets`), before it - * renders. Other target types get no route. None outside a Box project. - */ -function runtimeGatewayRoutes( - spec: ProjectSpec, - runtime: ProjectRuntime, - servers: ReadonlyMap, -): string { - if (!isBoxProject(spec)) return ""; - const gateway = spec.agentCoreGateways.find(({ boundRuntime }) => boundRuntime === runtime.name); - if (!gateway) return ""; - const targets = gateway.targets.filter( - (target) => target.targetType === "passthrough" && target.passthrough, - ); - const hostOf = (target: (typeof targets)[number]) => new URL(target.passthrough!.endpoint).host; - // Two routes with one destination would leave box to pick one, so a host has one target. - const byHost = new Map(); - for (const target of targets) { - const other = byHost.get(hostOf(target)); - if (other !== undefined) { - throw new InputValidationError( - `gateway '${gateway.name}' has two passthrough targets for ${hostOf(target)}, '${other}' ` + - `and '${target.name}', so runtime '${runtime.name}' would get two routes to one host. ` + - "Remove one of them.", - ); - } - byHost.set(hostOf(target), target.name); - } - return targets - .map((target) => { - const server = servers.get(target.name); - return server - ? runtimeMcpServerSection(gateway.name, server, target.name, hostOf(target)) - : runtimeGatewayRouteSection(gateway.name, target.name, hostOf(target)); - }) - .join(""); -} - -/** The HTTP MCP server each Box gateway target of `hosts` serves, by the target's name. */ -function runtimeMcpServers(hosts: BoxNetwork["hosts"]): Map { - const servers = new Map(); - for (const host of hosts) { - const source = host.sources.find((s): s is McpSource => s.kind === "mcp"); - if (source === undefined || host.target === undefined) continue; - servers.set(host.target, { - name: source.mcpEntry, - ...(source.secret && { secret: source.secret }), - }); - } - return servers; -} - -/** - * A CloudWatch target of the box profile `profileFile` on the Runtime: its - * `[telemetry.]` table with the same keys, signed with the execution - * role, whatever the box profile signs it with. Starts with a blank line. - */ -function runtimeTelemetrySection(target: CloudWatchTelemetry, profileFile: string): string { - const logs = - target.kind === "cloudwatch_logs" - ? `log_group = ${str(target.logGroup)}\nlog_stream = ${str(target.logStream)}\n` - : ""; - const include = target.include ? `include = ${list([...target.include])}\n` : ""; - const key = tomlKey(target.name); - return ` -# The [telemetry.${key}] target of ${profileFile}, signed with the execution role. -[telemetry.${key}] -kind = ${str(target.kind)} -region = ${str(target.region)} -${logs}${include}secret.ref = ${str(RUNTIME_AWS_SIGNER)} -`; -} - -/** - * The AgentCore Runtime box profile of a runtime that runs its agent in a box, - * derived from agentcore.json: the runtime's build, protocol, and model - * provider, and a route for each passthrough target of its Box gateway (see - * `runtimeGatewayRoutes`); and, from the runtime's Box network model, the box - * profile's policy files under `policies`, the region build builds for, the - * HTTP MCP server that a target serves, and each CloudWatch `[telemetry]` - * target. agentcore.json does not record the framework, and the profile does not - * depend on it beyond the container case, so the input names Strands, one of - * the frameworks that run in a box. - */ -export function renderRuntimeBoxProfile( - spec: ProjectSpec, - runtime: ProjectRuntime, - network?: Pick & - Partial>, -): string { - const region = network?.region ?? DEFAULT_EGRESS_BEDROCK_REGION; - const input = { - runtimeName: runtime.name, - build: runtime.build, - language: "Python", - framework: "strands", - protocol: runtime.protocol, - modelProvider: runtime.modelProvider, - modelId: runtime.modelId, - // Build and deploy render this only for a runtime that runs its agent in a box. - boxTemplate: true, - } as ScaffoldRuntimeInput; - const profile = renderBoxProfile( - spec.name, - input, - region, - "runtime", - runtimeGatewayRoutes(spec, runtime, runtimeMcpServers(network?.hosts ?? [])), - network?.policyFiles, - )!; - const profileFile = boxLocalProfileFile(runtime.name); - return ( - profile + - (network?.telemetry ?? []) - .map((target) => runtimeTelemetrySection(target, profileFile)) - .join("") - ); +export function runtimeAgentTemplate( + runtime: ScaffoldRuntimeInput, +): Record | undefined { + if (!hasBoxProfile(runtime)) return undefined; + const protocol = runtime.protocol ?? "HTTP"; + const workloadPort = boxWorkloadPort(protocol); + const runner = isBoxedContainer(runtime) + ? containerRunner(workloadPort, false) + : runtimeCodeZipRunner(protocol, boxAppDir(runtime), workloadPort); + return { + command: runner.command, + env: { ...runner.env, ...PYTHON_ENV }, + filesystem: { + read: runner.read, + exec: runner.exec, + ...(runner.denyWrite.length > 0 && { deny_write: runner.denyWrite }), + }, + ingress: [{ listen: `0.0.0.0:${boxIngressPort(protocol)}`, workload_port: workloadPort }], + }; } /** @@ -958,9 +706,11 @@ function str(value: string): string { return JSON.stringify(value); } -/** A filesystem entry the box skips when the path does not exist, such as a venv not yet installed. */ -function optional(path: string): string { - return `{ path = ${str(path)}, optional = true }`; +/** A list of filesystem grants as TOML. */ +function grants(values: readonly Grant[]): string { + const grant = (value: Grant) => + typeof value === "string" ? str(value) : `{ path = ${str(value.path)}, optional = true }`; + return `[${values.map(grant).join(", ")}]`; } function list(values: string[]): string { From 92649771079d8daa2b9ad34dba9c4def3d97b103 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 14:30:35 -0800 Subject: [PATCH 12/51] fix(box): Give box the Runtime Python by a name that box does not alias start.py exported sys.executable as BOX_PYTHON. When the Python of the Runtime has the name python or python3, box refuses each stdio MCP server that runs on ${{ inputs.python.path }}, because these names are the interpreter aliases of box. The paths rule moves the venv's Python of a stdio server to that input. box_python in start.py gives the Python by its versioned name: python3. beside it, else the file that it links to, else the same path. start.py runs main() only as __main__, and it imports tomllib only in main(). Thus a test can read box_python on Python 3.9. Tests: boxStartPy.test.ts gives box_python a python3 with a versioned file beside it, a python link, a versioned name, and a python3 with no other name, with python3 from PATH. It also examines that start.py exports the value of box_python. Not tested: start.py on AgentCore Runtime. --- src/assets/templates/box-codezip/start.py | 86 +++++++++++------ src/core/project/templates/boxStartPy.test.ts | 94 +++++++++++++++++++ 2 files changed, 149 insertions(+), 31 deletions(-) create mode 100644 src/core/project/templates/boxStartPy.test.ts diff --git a/src/assets/templates/box-codezip/start.py b/src/assets/templates/box-codezip/start.py index c3a7086f0..ae94a7f7f 100644 --- a/src/assets/templates/box-codezip/start.py +++ b/src/assets/templates/box-codezip/start.py @@ -11,11 +11,6 @@ import shutil import sys -try: - import tomllib -except ModuleNotFoundError: # Python 3.10: the template depends on tomli there. - import tomli as tomllib - CODE = os.path.dirname(os.path.abspath(__file__)) DIST = os.path.join(CODE, ".box-dist") BOX = os.path.join(DIST, "box") @@ -24,29 +19,58 @@ PROFILE_DIR = "/tmp/box/profile" PROFILE = os.path.join(PROFILE_DIR, "profile.toml") -for directory in (HOME, WORKSPACE, PROFILE_DIR): - os.makedirs(directory, exist_ok=True) - -# box reads a profile's policy files from beside it, so copy the profile and each file its -# `policies` names out of the read-only zip, into this user's folder, outside the workspace. -staged_profile = os.path.join(DIST, "profile.toml") -shutil.copyfile(staged_profile, PROFILE) -with open(staged_profile, "rb") as handle: - policies = tomllib.load(handle).get("policies", []) -for policy in policies: - destination = os.path.join(PROFILE_DIR, policy) - os.makedirs(os.path.dirname(destination), exist_ok=True) - shutil.copyfile(os.path.join(DIST, policy), destination) - -os.chdir(WORKSPACE) -os.execve( - BOX, - ["box", "run", PROFILE, "--no-banner"], - { - **os.environ, - "HOME": HOME, - "BOX_CODE": CODE, - "BOX_PYTHON": sys.executable, - "BOX_PYTHON_PREFIX": sys.base_prefix, - }, -) +# The names of box's own interpreter aliases. box refuses a stdio MCP server whose program has one +# of these names, so a server on the Runtime's Python needs that Python by its versioned name. +INTERPRETER_ALIASES = ("python", "python3") + + +def box_python(executable, version): + """The Runtime's Python, `executable`, by a name that is not an interpreter alias of box: its + versioned file beside it (python3.12), else the file it links to, else `executable` itself.""" + if os.path.basename(executable) not in INTERPRETER_ALIASES: + return executable + versioned = os.path.join(os.path.dirname(executable), f"python{version[0]}.{version[1]}") + if os.path.isfile(versioned) and os.access(versioned, os.X_OK): + return versioned + linked = os.path.realpath(executable) + if os.path.basename(linked) not in INTERPRETER_ALIASES: + return linked + return executable + + +def main(): + try: + import tomllib + except ModuleNotFoundError: # Python 3.10: the template depends on tomli there. + import tomli as tomllib + + for directory in (HOME, WORKSPACE, PROFILE_DIR): + os.makedirs(directory, exist_ok=True) + + # box reads a profile's policy files from beside it, so copy the profile and each file its + # `policies` names out of the read-only zip, into this user's folder, outside the workspace. + staged_profile = os.path.join(DIST, "profile.toml") + shutil.copyfile(staged_profile, PROFILE) + with open(staged_profile, "rb") as handle: + policies = tomllib.load(handle).get("policies", []) + for policy in policies: + destination = os.path.join(PROFILE_DIR, policy) + os.makedirs(os.path.dirname(destination), exist_ok=True) + shutil.copyfile(os.path.join(DIST, policy), destination) + + os.chdir(WORKSPACE) + os.execve( + BOX, + ["box", "run", PROFILE, "--no-banner"], + { + **os.environ, + "HOME": HOME, + "BOX_CODE": CODE, + "BOX_PYTHON": box_python(sys.executable, sys.version_info), + "BOX_PYTHON_PREFIX": sys.base_prefix, + }, + ) + + +if __name__ == "__main__": + main() diff --git a/src/core/project/templates/boxStartPy.test.ts b/src/core/project/templates/boxStartPy.test.ts new file mode 100644 index 000000000..4cb1319db --- /dev/null +++ b/src/core/project/templates/boxStartPy.test.ts @@ -0,0 +1,94 @@ +import { afterEach, describe, expect, test } from "bun:test"; +import { spawnSync } from "node:child_process"; +import { + chmodSync, + mkdirSync, + mkdtempSync, + readFileSync, + realpathSync, + rmSync, + symlinkSync, + writeFileSync, +} from "node:fs"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + +/** The start.py that create writes as a CodeZip box runtime's entry point. */ +const START_PY = join(import.meta.dir, "..", "..", "..", "assets", "templates", "box-codezip"); + +const hasPython = spawnSync("python3", ["--version"]).status === 0; + +const directories: string[] = []; +afterEach(() => { + for (const directory of directories.splice(0)) + rmSync(directory, { recursive: true, force: true }); +}); + +/** A bin folder with an executable for each name, and a symbolic link for each `[link, target]`. */ +function binFolder(files: string[], links: [string, string][] = []): string { + const root = mkdtempSync(join(tmpdir(), "box-start-py-")); + directories.push(root); + const bin = join(root, "bin"); + mkdirSync(bin); + for (const name of files) { + writeFileSync(join(bin, name), "#!/bin/sh\n"); + chmodSync(join(bin, name), 0o755); + } + for (const [link, target] of links) symlinkSync(target, join(bin, link)); + return bin; +} + +/** What start.py exports as BOX_PYTHON for the Runtime Python `executable`, of version 3.12. */ +function boxPython(executable: string): string { + // Imported, not run: start.py hands over to box only as __main__. + const out = spawnSync( + "python3", + [ + "-I", + "-c", + "import sys; sys.path.insert(0, sys.argv[1]); import start; " + + "print(start.box_python(sys.argv[2], (3, 12)))", + START_PY, + executable, + ], + { encoding: "utf8" }, + ); + expect(out.stderr).toBe(""); + return out.stdout.trim(); +} + +describe("start.py BOX_PYTHON", () => { + test("exports the Python of box_python to box, not sys.executable", () => { + const text = readFileSync(join(START_PY, "start.py"), "utf8"); + + expect(text).toContain('"BOX_PYTHON": box_python(sys.executable, sys.version_info),'); + }); + + test.skipIf(!hasPython)("keeps a Python whose name box does not alias", () => { + const bin = binFolder(["python3.12"]); + + expect(boxPython(join(bin, "python3.12"))).toBe(join(bin, "python3.12")); + }); + + test.skipIf(!hasPython)("names python3 by the versioned file beside it", () => { + const bin = binFolder(["python3", "python3.12"]); + + expect(boxPython(join(bin, "python3"))).toBe(join(bin, "python3.12")); + }); + + test.skipIf(!hasPython)( + "names python by the file it links to when no versioned file is beside it", + () => { + const bin = binFolder(["python3.12-real"], [["python", "python3.12-real"]]); + + // The link resolves to its real path, as /var is /private/var on macOS. + expect(boxPython(join(bin, "python"))).toBe(realpathSync(join(bin, "python3.12-real"))); + }, + ); + + test.skipIf(!hasPython)("keeps an aliased name when nothing else names that Python", () => { + const bin = binFolder(["python3"]); + + expect(boxPython(join(bin, "python3"))).toBe(join(bin, "python3")); + }); +}); From 04f6bccb582e7f7273d55660e662cfd84578512e Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 14:35:04 -0800 Subject: [PATCH 13/51] feat(box): Name the packs that box ships 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 with that change refuses the previous box/ name. The next box release has it. Thus that box refuses each local profile that create writes, and each Runtime profile that build stages. With this change, the CLI writes these names: - @box/base and @box/bedrock, in each local profile that create writes, and in each Runtime profile. BOX_BASE_PACK and BOX_BEDROCK_PACK are the names. The renderer, the bedrock.region copy of build, and the additions rule use them. - @box/agentcore and @box/agentcore-codezip, in the packs of the Runtime profile and in the [pack] name of each pack that build writes. The path of each pack does not change. - The comments of the code, of Dockerfile.template, of start.py, and of the guide use the new names. Build does not change the profile of the user. When 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. This change comes from the local commit 967cc9f1 on the branch dev/runtime-log-group-from-env, in the worktree /Volumes/workplace/box-v3/agentcore-cli-devlog. The code of this branch is different, so the change is made again here. The Runtime profile fixture of the replaced renderer gets the new names. The open routes fixture for a list of destinations is the 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: boxNetworkSource.test.ts "stops before box runs when the profile names a pack or a plugin that box ships by its old box/ name" and "runs box for a profile with only @box/ names and names of its own". The other tests examine the new names. --- docs/box-local-testing.md | 2 +- .../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.test.ts | 2 +- src/core/project/backends/boxCodeZip.ts | 2 +- .../project/backends/boxContainer.test.ts | 6 +- src/core/project/backends/cdk.test.ts | 2 +- src/core/project/boxNetwork/network.test.ts | 4 +- .../project/boxNetwork/profileParser.test.ts | 2 +- src/core/project/boxNetworkSource.test.ts | 35 + src/core/project/boxNetworkSource.ts | 42 +- src/core/project/boxNetworkWriters.test.ts | 6 +- src/core/project/boxNetworkWriters.ts | 4 +- src/core/project/boxProfileEgress.ts | 2 +- .../boxProfileResolver-test-support.ts | 2 +- src/core/project/boxProfileResolver.test.ts | 10 +- src/core/project/manager.boxNetwork.test.ts | 8 +- src/core/project/manager.test.ts | 2 +- .../__fixtures__/old-renderer-tables.json | 876 +++++++++--------- .../project/runtimeProfile/derive.test.ts | 8 +- .../runtimeProfile/rules/additions.test.ts | 30 +- .../project/runtimeProfile/rules/additions.ts | 19 +- .../runtimeProfile/rules/gateway.test.ts | 10 +- .../runtimeProfile/rules/paths.test.ts | 4 +- .../runtimeProfile/rules/refusals.test.ts | 2 +- src/core/project/runtimeProfile/types.ts | 10 +- src/core/project/templates/boxProfile.test.ts | 18 +- src/core/project/templates/boxProfile.ts | 26 +- src/core/project/templates/project.ts | 2 +- 31 files changed, 608 insertions(+), 536 deletions(-) diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index d6b4ce0b3..f39ce6023 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -142,7 +142,7 @@ it lists under `policies`, and turn them into that runtime's Box network. They c - for CodeZip, each path of the code folder moves to the unpacked zip, and the venv's Python to the Runtime's Python, in every table: the agent, each stdio `[mcp.]` server, each `[tool.]`; - - the `box/agentcore` packs, the project name, and the build region come in, and each CloudWatch + - the `@box/agentcore` packs, the project name, and the build region come in, and each CloudWatch target signs with the execution role. With no `cloudwatch_logs` target, the box sends its records to the runtime's own log group. diff --git a/src/assets/templates/agent-python-strands-box/Dockerfile.template b/src/assets/templates/agent-python-strands-box/Dockerfile.template index ecdb6dee7..a46f803d6 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 runtime's .box//local/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. diff --git a/src/assets/templates/box-codezip/start.py b/src/assets/templates/box-codezip/start.py index ae94a7f7f..aa47bc3b1 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 5d243962c..eb1adcda8 100644 --- a/src/core/dev/boxEnvLocal.test.ts +++ b/src/core/dev/boxEnvLocal.test.ts @@ -80,7 +80,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.test.ts b/src/core/project/backends/boxCodeZip.test.ts index b474ad814..89af732d7 100644 --- a/src/core/project/backends/boxCodeZip.test.ts +++ b/src/core/project/backends/boxCodeZip.test.ts @@ -280,7 +280,7 @@ function model(policyFiles: string[], runtime = "agent"): BoxNetwork { /** A derived Runtime profile that names `policyFiles`. */ function runtimeProfileOf(policyFiles: string[], runtime = "agent"): TomlTable { return { - packs: ["box/base", "box/agentcore", "box/agentcore-codezip"], + packs: ["@box/base", "@box/agentcore", "@box/agentcore-codezip"], ...(policyFiles.length > 0 && { policies: policyFiles }), profile: { name: "demo" }, agent: { command: [`\${{ inputs.code.dir }}/${runtime}`] }, 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 fcbba4232..2bb9f1a03 100644 --- a/src/core/project/backends/boxContainer.test.ts +++ b/src/core/project/backends/boxContainer.test.ts @@ -11,7 +11,7 @@ import { serializeRuntimeProfile } from "../runtimeProfile/serialize"; 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[] = []; @@ -89,7 +89,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()); // The runtime's .box/agent/aws/ holds a copy of what the profile writer stages, and no box. @@ -176,7 +176,7 @@ function model(policyFiles: string[]): BoxNetwork { envRoutes: [], policyFiles, runtimeProfile: { - packs: ["box/base", "box/agentcore"], + packs: ["@box/base", "@box/agentcore"], ...(policyFiles.length > 0 && { policies: policyFiles }), profile: { name: "demo" }, }, diff --git a/src/core/project/backends/cdk.test.ts b/src/core/project/backends/cdk.test.ts index aea1e455c..cee22253f 100644 --- a/src/core/project/backends/cdk.test.ts +++ b/src/core/project/backends/cdk.test.ts @@ -363,7 +363,7 @@ describe("CdkBackend.build", () => { hosts: [], envRoutes: [], policyFiles: [], - runtimeProfile: { packs: ["box/base", "box/agentcore"] }, + runtimeProfile: { packs: ["@box/base", "@box/agentcore"] }, grantedActions: [], warnings: [], failures: [], 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 b329910fb..6031f04d9 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -111,6 +111,41 @@ describe("readBoxNetworks", () => { expect(network?.runtimeProfile?.project).toEqual({ access: "read" }); }); + 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("finds each runtime's Box gateway by boundRuntime, whatever its name", async () => { const root = await project([]); const spec = { diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index ec7a1eb1c..ba3b6f9ee 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -15,6 +15,7 @@ import { DEFAULT_EGRESS_BEDROCK_REGION } from "../../handlers/project/shortcuts" import { addBoxGatewayTargets, BOX_BEDROCK_POLICY_FILE, BOX_MEMORY_POLICY_FILE } from "./boxMemory"; import { assertNoProjectBoxProfile, + BOX_BEDROCK_PACK, boxLocalDir, boxLocalProfileFile, boxLocalProfilePath, @@ -199,6 +200,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( @@ -208,7 +210,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; @@ -251,15 +253,45 @@ function profileSource(text: string, profileFile: string): ParsedProfileSource | type ParsedProfileSource = NonNullable; +/** 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. Build does not change the profile. 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); @@ -273,7 +305,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 9b5c4356e..d63c5a501 100644 --- a/src/core/project/boxNetworkWriters.test.ts +++ b/src/core/project/boxNetworkWriters.test.ts @@ -26,7 +26,7 @@ function network(overrides: Partial = {}): BoxNetwork { hosts: [], envRoutes: [], policyFiles: [], - runtimeProfile: { packs: ["box/base", "box/agentcore"], profile: { name: "demo" } }, + runtimeProfile: { packs: ["@box/base", "@box/agentcore"], profile: { name: "demo" } }, runtimeProfileHeader: ["Derived from .box/agent/local/profile.toml."], grantedActions: [], warnings: [], @@ -449,7 +449,7 @@ describe("runtimeProfileWriter", () => { { runtime: "agent", dist: "app/agent/.box-dist", kind: "codezip" }, ]); const policies = ["policy.dw", "rules/extra.dw"]; - const runtimeProfile = { packs: ["box/base", "box/agentcore"], policies }; + const runtimeProfile = { packs: ["@box/base", "@box/agentcore"], policies }; const models = [network({ policyFiles: policies, runtimeProfile })]; const { files } = run([writer], models); @@ -485,7 +485,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 b5b54f726..e54847a36 100644 --- a/src/core/project/boxNetworkWriters.ts +++ b/src/core/project/boxNetworkWriters.ts @@ -368,8 +368,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..9b2bae5cb 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" } ], @@ -133,7 +133,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 +151,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 +190,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 +414,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 faa69635f..7469568df 100644 --- a/src/core/project/manager.boxNetwork.test.ts +++ b/src/core/project/manager.boxNetwork.test.ts @@ -29,7 +29,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" }, @@ -39,7 +39,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 { @@ -784,7 +784,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({ @@ -863,7 +863,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/runtimeProfile/__fixtures__/old-renderer-tables.json b/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json index c1fc2af94..ec76045ec 100644 --- a/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json +++ b/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json @@ -2,10 +2,10 @@ "templates": { "CodeZip HTTP Bedrock memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -78,10 +78,10 @@ }, "CodeZip HTTP Bedrock memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -163,10 +163,10 @@ }, "CodeZip HTTP Bedrock memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -249,10 +249,10 @@ }, "CodeZip HTTP Bedrock memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -325,10 +325,10 @@ }, "CodeZip HTTP Bedrock memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -410,10 +410,10 @@ }, "CodeZip HTTP Bedrock memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -496,9 +496,9 @@ }, "CodeZip HTTP OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -567,9 +567,9 @@ }, "CodeZip HTTP OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -647,9 +647,9 @@ }, "CodeZip HTTP OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -728,9 +728,9 @@ }, "CodeZip HTTP OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -799,9 +799,9 @@ }, "CodeZip HTTP OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -879,9 +879,9 @@ }, "CodeZip HTTP OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -960,9 +960,9 @@ }, "CodeZip MCP Bedrock memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -1024,9 +1024,9 @@ }, "CodeZip MCP Bedrock memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1097,9 +1097,9 @@ }, "CodeZip MCP Bedrock memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1171,9 +1171,9 @@ }, "CodeZip MCP Bedrock memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -1235,9 +1235,9 @@ }, "CodeZip MCP Bedrock memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1308,9 +1308,9 @@ }, "CodeZip MCP Bedrock memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1382,9 +1382,9 @@ }, "CodeZip MCP OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -1446,9 +1446,9 @@ }, "CodeZip MCP OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1519,9 +1519,9 @@ }, "CodeZip MCP OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1593,9 +1593,9 @@ }, "CodeZip MCP OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -1657,9 +1657,9 @@ }, "CodeZip MCP OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1730,9 +1730,9 @@ }, "CodeZip MCP OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1804,10 +1804,10 @@ }, "CodeZip A2A Bedrock memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -1874,10 +1874,10 @@ }, "CodeZip A2A Bedrock memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -1953,10 +1953,10 @@ }, "CodeZip A2A Bedrock memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2033,10 +2033,10 @@ }, "CodeZip A2A Bedrock memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -2103,10 +2103,10 @@ }, "CodeZip A2A Bedrock memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2182,10 +2182,10 @@ }, "CodeZip A2A Bedrock memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2262,9 +2262,9 @@ }, "CodeZip A2A OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -2327,9 +2327,9 @@ }, "CodeZip A2A OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2401,9 +2401,9 @@ }, "CodeZip A2A OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2476,9 +2476,9 @@ }, "CodeZip A2A OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -2541,9 +2541,9 @@ }, "CodeZip A2A OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2615,9 +2615,9 @@ }, "CodeZip A2A OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2690,10 +2690,10 @@ }, "CodeZip AGUI Bedrock memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -2759,10 +2759,10 @@ }, "CodeZip AGUI Bedrock memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2837,10 +2837,10 @@ }, "CodeZip AGUI Bedrock memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -2916,10 +2916,10 @@ }, "CodeZip AGUI Bedrock memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -2985,10 +2985,10 @@ }, "CodeZip AGUI Bedrock memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -3063,10 +3063,10 @@ }, "CodeZip AGUI Bedrock memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -3142,9 +3142,9 @@ }, "CodeZip AGUI OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -3206,9 +3206,9 @@ }, "CodeZip AGUI OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -3279,9 +3279,9 @@ }, "CodeZip AGUI OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -3353,9 +3353,9 @@ }, "CodeZip AGUI OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -3417,9 +3417,9 @@ }, "CodeZip AGUI OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -3490,9 +3490,9 @@ }, "CodeZip AGUI OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -3564,9 +3564,9 @@ }, "Container HTTP Bedrock memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "profile": { "name": "demo" @@ -3648,9 +3648,9 @@ }, "Container HTTP Bedrock memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -3741,9 +3741,9 @@ }, "Container HTTP Bedrock memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -3835,9 +3835,9 @@ }, "Container HTTP Bedrock memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "profile": { "name": "demo" @@ -3919,9 +3919,9 @@ }, "Container HTTP Bedrock memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4012,9 +4012,9 @@ }, "Container HTTP Bedrock memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4106,8 +4106,8 @@ }, "Container HTTP OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -4185,8 +4185,8 @@ }, "Container HTTP OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4273,8 +4273,8 @@ }, "Container HTTP OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4362,8 +4362,8 @@ }, "Container HTTP OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -4441,8 +4441,8 @@ }, "Container HTTP OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4529,8 +4529,8 @@ }, "Container HTTP OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4618,8 +4618,8 @@ }, "Container MCP Bedrock memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -4697,8 +4697,8 @@ }, "Container MCP Bedrock memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4785,8 +4785,8 @@ }, "Container MCP Bedrock memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -4874,8 +4874,8 @@ }, "Container MCP Bedrock memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -4953,8 +4953,8 @@ }, "Container MCP Bedrock memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -5041,8 +5041,8 @@ }, "Container MCP Bedrock memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -5130,8 +5130,8 @@ }, "Container MCP OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -5209,8 +5209,8 @@ }, "Container MCP OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -5297,8 +5297,8 @@ }, "Container MCP OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -5386,8 +5386,8 @@ }, "Container MCP OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -5465,8 +5465,8 @@ }, "Container MCP OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -5553,8 +5553,8 @@ }, "Container MCP OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -5644,10 +5644,10 @@ "boxTemplates": { "a2a-python-strands-box provider=of the template memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -5733,10 +5733,10 @@ }, "a2a-python-strands-box provider=of the template memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -5831,10 +5831,10 @@ }, "a2a-python-strands-box provider=of the template memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -5930,10 +5930,10 @@ }, "a2a-python-strands-box provider=of the template memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -6036,10 +6036,10 @@ }, "a2a-python-strands-box provider=of the template memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -6151,10 +6151,10 @@ }, "a2a-python-strands-box provider=of the template memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -6267,9 +6267,9 @@ }, "a2a-python-strands-box provider=OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -6351,9 +6351,9 @@ }, "a2a-python-strands-box provider=OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -6444,9 +6444,9 @@ }, "a2a-python-strands-box provider=OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -6538,9 +6538,9 @@ }, "a2a-python-strands-box provider=OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -6639,9 +6639,9 @@ }, "a2a-python-strands-box provider=OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -6749,9 +6749,9 @@ }, "a2a-python-strands-box provider=OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -6860,10 +6860,10 @@ }, "agent-python-langchain-box provider=of the template memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -6955,10 +6955,10 @@ }, "agent-python-langchain-box provider=of the template memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -7059,10 +7059,10 @@ }, "agent-python-langchain-box provider=of the template memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -7164,10 +7164,10 @@ }, "agent-python-langchain-box provider=of the template memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -7276,10 +7276,10 @@ }, "agent-python-langchain-box provider=of the template memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -7397,10 +7397,10 @@ }, "agent-python-langchain-box provider=of the template memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -7519,10 +7519,10 @@ }, "agent-python-minimal-box provider=of the template memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -7614,10 +7614,10 @@ }, "agent-python-minimal-box provider=of the template memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -7718,10 +7718,10 @@ }, "agent-python-minimal-box provider=of the template memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -7823,10 +7823,10 @@ }, "agent-python-minimal-box provider=of the template memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -7935,10 +7935,10 @@ }, "agent-python-minimal-box provider=of the template memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -8056,10 +8056,10 @@ }, "agent-python-minimal-box provider=of the template memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -8178,10 +8178,10 @@ }, "agent-python-strands-box provider=of the template memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -8273,10 +8273,10 @@ }, "agent-python-strands-box provider=of the template memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -8377,10 +8377,10 @@ }, "agent-python-strands-box provider=of the template memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -8482,10 +8482,10 @@ }, "agent-python-strands-box provider=of the template memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -8594,10 +8594,10 @@ }, "agent-python-strands-box provider=of the template memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -8715,10 +8715,10 @@ }, "agent-python-strands-box provider=of the template memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -8837,9 +8837,9 @@ }, "agent-python-strands-box provider=OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -8927,9 +8927,9 @@ }, "agent-python-strands-box provider=OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -9026,9 +9026,9 @@ }, "agent-python-strands-box provider=OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -9126,9 +9126,9 @@ }, "agent-python-strands-box provider=OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -9233,9 +9233,9 @@ }, "agent-python-strands-box provider=OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -9349,9 +9349,9 @@ }, "agent-python-strands-box provider=OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -9466,9 +9466,9 @@ }, "agent-python-strands-box-container provider=of the template memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "profile": { "name": "demo" @@ -9569,9 +9569,9 @@ }, "agent-python-strands-box-container provider=of the template memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -9681,9 +9681,9 @@ }, "agent-python-strands-box-container provider=of the template memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -9794,9 +9794,9 @@ }, "agent-python-strands-box-container provider=of the template memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "profile": { "name": "demo" @@ -9914,9 +9914,9 @@ }, "agent-python-strands-box-container provider=of the template memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -10043,9 +10043,9 @@ }, "agent-python-strands-box-container provider=of the template memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore" + "@box/base", + "@box/bedrock", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -10173,8 +10173,8 @@ }, "agent-python-strands-box-container provider=OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -10271,8 +10271,8 @@ }, "agent-python-strands-box-container provider=OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -10378,8 +10378,8 @@ }, "agent-python-strands-box-container provider=OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -10486,8 +10486,8 @@ }, "agent-python-strands-box-container provider=OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "profile": { "name": "demo" @@ -10601,8 +10601,8 @@ }, "agent-python-strands-box-container provider=OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -10725,8 +10725,8 @@ }, "agent-python-strands-box-container provider=OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore" + "@box/base", + "@box/agentcore" ], "policies": [ "policy.dw" @@ -10850,10 +10850,10 @@ }, "agui-python-strands-box provider=of the template memories=0 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -10938,10 +10938,10 @@ }, "agui-python-strands-box provider=of the template memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -11035,10 +11035,10 @@ }, "agui-python-strands-box provider=of the template memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -11133,10 +11133,10 @@ }, "agui-python-strands-box provider=of the template memories=1 telemetry=none": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -11238,10 +11238,10 @@ }, "agui-python-strands-box provider=of the template memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -11352,10 +11352,10 @@ }, "agui-python-strands-box provider=of the template memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/bedrock", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/bedrock", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -11467,9 +11467,9 @@ }, "agui-python-strands-box provider=OpenAI memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -11550,9 +11550,9 @@ }, "agui-python-strands-box provider=OpenAI memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -11642,9 +11642,9 @@ }, "agui-python-strands-box provider=OpenAI memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -11735,9 +11735,9 @@ }, "agui-python-strands-box provider=OpenAI memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -11835,9 +11835,9 @@ }, "agui-python-strands-box provider=OpenAI memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -11944,9 +11944,9 @@ }, "agui-python-strands-box provider=OpenAI memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -12054,9 +12054,9 @@ }, "mcp-python-fastmcp-box provider=of the template memories=0 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -12137,9 +12137,9 @@ }, "mcp-python-fastmcp-box provider=of the template memories=0 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -12229,9 +12229,9 @@ }, "mcp-python-fastmcp-box provider=of the template memories=0 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -12322,9 +12322,9 @@ }, "mcp-python-fastmcp-box provider=of the template memories=1 telemetry=none": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "profile": { "name": "demo" @@ -12422,9 +12422,9 @@ }, "mcp-python-fastmcp-box provider=of the template memories=1 telemetry=logs and traces": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" @@ -12531,9 +12531,9 @@ }, "mcp-python-fastmcp-box provider=of the template memories=1 telemetry=traces only": { "packs": [ - "box/base", - "box/agentcore", - "box/agentcore-codezip" + "@box/base", + "@box/agentcore", + "@box/agentcore-codezip" ], "policies": [ "policy.dw" diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts index 5f0b30695..96777d4b4 100644 --- a/src/core/project/runtimeProfile/derive.test.ts +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -54,7 +54,7 @@ describe("deriveRuntimeProfile", () => { test.each([CODEZIP, CONTAINER])( "carries each key that no rule changes as the local profile has it ($build)", (runtime) => { - const local = { packs: ["box/base"], ...CARRIED, agent: { command: ["/bin/echo"] } }; + const local = { packs: ["@box/base"], ...CARRIED, agent: { command: ["/bin/echo"] } }; const { profile, problems } = deriveRuntimeProfile(local, context(runtime)); @@ -77,7 +77,7 @@ describe("deriveRuntimeProfile", () => { }); describe("runtimePaths", () => { - test("moves a CodeZip runtime's code and Python to the inputs of box/agentcore-codezip", () => { + test("moves a CodeZip runtime's code and Python to the inputs of @box/agentcore-codezip", () => { expect(runtimePaths(CODEZIP)).toEqual({ build: "CodeZip", localCode: "${{ workspace }}/app/agent", @@ -117,7 +117,7 @@ describe("runtimeTemplate", () => { describe("profileKeyPlaces", () => { test("places each table, each key, and each dotted key at its first line", () => { const text = [ - 'packs = ["box/base"]', + 'packs = ["@box/base"]', 'egress.github.destinations = ["api.github.com"]', "", "[mcp.notes]", @@ -161,7 +161,7 @@ describe("keyLabel", () => { describe("serializeRuntimeProfile", () => { test("writes the profile as TOML after its header comments", () => { - const profile = { packs: ["box/base"], ...CARRIED, mcp: { notes: { type: "stdio" } } }; + const profile = { packs: ["@box/base"], ...CARRIED, mcp: { notes: { type: "stdio" } } }; const text = serializeRuntimeProfile(profile, ["Rendered by agentcore build."]); diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 15b5c78d7..546f08a94 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -119,7 +119,7 @@ const CLOUDWATCH: TomlTable = { /** * The default target of the Runtime profile: the runtime's own log group and log stream, in its own - * region, which box reads through the inputs of the box/agentcore pack. + * region, which box reads through the inputs of the @box/agentcore pack. */ const DEFAULT_TARGET = { kind: "cloudwatch_logs", @@ -359,18 +359,18 @@ describe("the additions rule", () => { }); test("keeps the user's packs in their order, then adds the Runtime packs once", () => { - const packs = ["box/gh", "box/base", "box/bedrock"]; + const packs = ["box/gh", "@box/base", "@box/bedrock"]; expect(apply({ packs }, contextOf(CODEZIP)).table.packs).toEqual([ ...packs, - "box/agentcore", - "box/agentcore-codezip", + "@box/agentcore", + "@box/agentcore-codezip", ]); - expect(apply({ packs }, contextOf(CONTAINER)).table.packs).toEqual([...packs, "box/agentcore"]); + expect(apply({ packs }, contextOf(CONTAINER)).table.packs).toEqual([...packs, "@box/agentcore"]); expect( - apply({ packs: ["box/agentcore", "box/base"] }, contextOf(CONTAINER)).table.packs, - ).toEqual(["box/agentcore", "box/base"]); - expect(apply({}, contextOf(CONTAINER)).table.packs).toEqual(["box/agentcore"]); + apply({ packs: ["@box/agentcore", "@box/base"] }, contextOf(CONTAINER)).table.packs, + ).toEqual(["@box/agentcore", "@box/base"]); + expect(apply({}, contextOf(CONTAINER)).table.packs).toEqual(["@box/agentcore"]); }); test("names the profile for the project, and keeps the other [profile] keys", () => { @@ -393,10 +393,10 @@ describe("the additions rule", () => { expect(apply(quoted, contextOf(CODEZIP)).table.options).toEqual({ "bedrock.region": BUILD_REGION, }); - expect(apply({ packs: ["box/bedrock"] }, contextOf(CODEZIP)).table.options).toEqual({ + expect(apply({ packs: ["@box/bedrock"] }, contextOf(CODEZIP)).table.options).toEqual({ bedrock: { region: BUILD_REGION }, }); - expect(apply({ packs: ["box/base"] }, contextOf(CODEZIP)).table.options).toBeUndefined(); + expect(apply({ packs: ["@box/base"] }, contextOf(CODEZIP)).table.options).toBeUndefined(); }); describe("[agent] command", () => { @@ -485,11 +485,11 @@ describe("the additions rule", () => { expect(result).not.toHaveProperty("PYTHONPATH"); }); - test("sets AWS_REGION only when the profile imports no box/bedrock", () => { + test("sets AWS_REGION only when the profile imports no @box/bedrock", () => { const local = createdProfile(CODEZIP); const bedrock = agentOf(apply(local, contextOf(CODEZIP)).table).env; - const other = agentOf(apply({ ...local, packs: ["box/base"] }, contextOf(CODEZIP)).table).env; + const other = agentOf(apply({ ...local, packs: ["@box/base"] }, contextOf(CODEZIP)).table).env; expect(bedrock).not.toHaveProperty("AWS_REGION"); expect(other.AWS_REGION).toBe("${{ inputs.aws.region }}"); @@ -664,7 +664,7 @@ describe("the additions rule", () => { expect({ ...DEFAULT_TELEMETRY_TARGET } as TomlTable).toEqual(DEFAULT_TARGET); }); - test("reads each value through an input that the box/agentcore pack declares", () => { + test("reads each value through an input that the @box/agentcore pack declares", () => { const { inputs } = parse(renderAgentCorePack(specOf(CODEZIP))) as { inputs: Record>; }; @@ -759,8 +759,8 @@ describe("the additions rule", () => { const [, derived, standIns] = runtimeProfileHeader(contextOf(CODEZIP)); expect(derived).toContain(`from ${PROFILE_FILE}, for AgentCore Runtime`); - expect(derived).toContain("box/agentcore and box/agentcore-codezip packs"); - expect(runtimeProfileHeader(contextOf(CONTAINER))[1]).not.toContain("box/agentcore-codezip"); + expect(derived).toContain("@box/agentcore and @box/agentcore-codezip packs"); + expect(runtimeProfileHeader(contextOf(CONTAINER))[1]).not.toContain("@box/agentcore-codezip"); expect(standIns).toContain("AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are stand-ins"); const text = serializeRuntimeProfile( apply(createdProfile(CODEZIP), contextOf(CODEZIP)).table, diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 77ae721af..f9ee8a73a 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -4,9 +4,9 @@ * * | Key | Runtime profile | * | --- | --- | - * | `packs` | the user's packs in their order, then box/agentcore, and box/agentcore-codezip for CodeZip | + * | `packs` | the user's packs in their order, then @box/agentcore, and @box/agentcore-codezip for CodeZip | * | `[profile] name` | the project's name | - * | `[options] bedrock.region` | the build region, where the profile sets it or imports box/bedrock | + * | `[options] bedrock.region` | the build region, where the profile sets it or imports @box/bedrock | * | `[agent] command` | the template's own command becomes its Runtime command; a command of the user loses `--reload` and `--reload-dir ` | * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region, the AWS stand-ins, and (CodeZip) the ffi `PYTHONPATH` come in; a value of the user stays | * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | @@ -20,6 +20,7 @@ import { AGENTCORE_CODEZIP_PACK_NAME, AGENTCORE_PACK_NAME, + BOX_BEDROCK_PACK, BOX_CODEZIP_DIST, } from "../../templates/boxProfile"; import { @@ -32,9 +33,6 @@ import { /** The credential that signs an AWS call on AgentCore Runtime: the execution role. */ export const RUNTIME_AWS_SIGNER = "aws://"; -/** The pack that sets `AWS_REGION` itself, from its `bedrock.region` input. */ -const BEDROCK_PACK = "box/bedrock"; - /** The variable that tells the template's agent that it runs under `agentcore dev`. */ const LOCAL_DEV = "LOCAL_DEV"; @@ -63,7 +61,7 @@ const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; /** * The CloudWatch Logs target of a Runtime profile that has no `cloudwatch_logs` target: the * runtime's own log group and log stream, in its own region. The runtime ID exists only after - * deploy, so box reads the three values through inputs of box/agentcore when the run starts. + * deploy, so box reads the three values through inputs of @box/agentcore when the run starts. */ export const DEFAULT_TELEMETRY_TARGET = { kind: "cloudwatch_logs", @@ -75,8 +73,8 @@ export const DEFAULT_TELEMETRY_TARGET = { } as const; /** - * The Runtime's region in the agent's environment, from the box/agentcore `aws.region` input. - * box/bedrock sets `AWS_REGION` itself, so the profile sets it only without that pack. + * The Runtime's region in the agent's environment, from the @box/agentcore `aws.region` input. + * @box/bedrock sets `AWS_REGION` itself, so the profile sets it only without that pack. */ export function runtimeRegionEnv(bedrock: boolean): Record { const region = RUNTIME_INPUTS.awsRegion; @@ -115,7 +113,8 @@ export function apply(table: Readonly, context: RuntimeProfileContext const packs = runtimePacks(result.packs, context); result.packs = packs; result.profile = { ...(isTable(result.profile) ? result.profile : {}), name: context.spec.name }; - const bedrock = Array.isArray(packs) && packs.includes(BEDROCK_PACK); + // The pack that sets `AWS_REGION` itself, from its `bedrock.region` input. + const bedrock = Array.isArray(packs) && packs.includes(BOX_BEDROCK_PACK); const options = runtimeOptions(result.options, bedrock, context.region); if (options !== undefined) result.options = options; result.agent = runtimeAgent(result.agent, bedrock, context); @@ -142,7 +141,7 @@ function runtimePacks(packs: unknown, context: RuntimeProfileContext): unknown { /** * `[options]` with `bedrock.region` in the build region, the region of the gateway's `bedrock` - * target: where the profile sets it, as a dotted or a quoted key, or where it imports box/bedrock. + * target: where the profile sets it, as a dotted or a quoted key, or where it imports @box/bedrock. */ function runtimeOptions(options: unknown, bedrock: boolean, region: string): unknown { if (options !== undefined && !isTable(options)) return options; diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index 38cc3b510..a6710d268 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -142,7 +142,7 @@ const backendText = (table: string, target: string) => describe("the gateway rule", () => { test("carries each key it does not own, and a stdio [mcp] server, as the local profile has them", () => { const text = [ - 'packs = ["box/base", "team/search"]', + 'packs = ["@box/base", "team/search"]', 'agent-args = ["--verbose"]', 'unknown-key = "box refuses it locally first"', "[agent]", @@ -165,7 +165,7 @@ describe("the gateway rule", () => { test("sends each host of an [egress] entry to its gateway target, and keeps its other keys", () => { const text = [ - 'packs = ["box/base"]', + 'packs = ["@box/base"]', "[egress.github]", 'destinations = ["api.github.com"]', 'protocol = "http"', @@ -181,7 +181,7 @@ describe("the gateway rule", () => { // The secret moves to the gateway target, which sends the key. expect(table).toEqual( parse( - 'packs = ["box/base"]\n' + + 'packs = ["@box/base"]\n' + "[egress.egress-github]\n" + 'destinations = ["api.github.com"]\n' + 'protocol = "http"\n' + @@ -405,7 +405,7 @@ function rendered(label: string): TomlTable { describe("the gateway rule and the Runtime renderer it replaced", () => { const TEXT = [ - 'packs = ["box/base", "box/bedrock"]', + 'packs = ["@box/base", "@box/bedrock"]', 'policies = ["policy.dw"]', "", "[agent]", @@ -434,7 +434,7 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { 'type = "stdio"', 'command = ["${{ workspace }}/app/agent/notes"]', ].join("\n"); - /** The `[egress]` and `[mcp]` tables that Box resolves the profile to, with box/bedrock. */ + /** The `[egress]` and `[mcp]` tables that Box resolves the profile to, with @box/bedrock. */ const EGRESS = { bedrock: { destinations: ["bedrock-runtime.us-west-2.amazonaws.com"], diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 5f0c5578f..6e3464aa1 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -51,7 +51,7 @@ const PYTHONPATH = `${CODE}/.box-dist/ffi:${CODE}`; /** A local profile with a stdio MCP server and a tool, each with a key build does not know. */ const LEAVES = toml( - 'packs = ["box/base"]', + 'packs = ["@box/base"]', "", "[agent]", 'command = ["/bin/echo"]', @@ -238,7 +238,7 @@ describe("the paths rule", () => { test("changes no key that another rule writes, and no value with no path of the project", () => { const text = toml( - 'packs = ["box/base"]', + 'packs = ["@box/base"]', 'policies = ["policies/app.dw"]', "[profile]", 'name = "demo-agent"', diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index 358d1a14e..3cddaf549 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -46,7 +46,7 @@ const APP = "${{ workspace }}/app/agent"; /** A local profile that can go to a CodeZip Runtime: each path moves, and each program is there. */ const WORKS = toml( - 'packs = ["box/base", "box/bedrock"]', + 'packs = ["@box/base", "@box/bedrock"]', "", "[agent]", `command = ["${APP}/.venv/bin/python", "-m", "uvicorn", "main:app", "--app-dir", "${APP}"]`, diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts index 6a424cde1..648ae9b1e 100644 --- a/src/core/project/runtimeProfile/types.ts +++ b/src/core/project/runtimeProfile/types.ts @@ -13,15 +13,15 @@ export type TomlTable = Record; /** The inputs that the generated packs fill in on AgentCore Runtime, as a profile names them. */ export const RUNTIME_INPUTS = { - /** The runtime's Box gateway URL (box/agentcore). */ + /** The runtime's Box gateway URL (@box/agentcore). */ gatewayUrl: "${{ inputs.gateway.url }}", - /** The Runtime's region (box/agentcore). */ + /** The Runtime's region (@box/agentcore). */ awsRegion: "${{ inputs.aws.region }}", - /** The unpacked zip of a CodeZip runtime (box/agentcore-codezip). */ + /** The unpacked zip of a CodeZip runtime (@box/agentcore-codezip). */ codeDir: "${{ inputs.code.dir }}", - /** The Python of a CodeZip Runtime (box/agentcore-codezip). */ + /** The Python of a CodeZip Runtime (@box/agentcore-codezip). */ pythonPath: "${{ inputs.python.path }}", - /** The base prefix of that Python (box/agentcore-codezip). */ + /** The base prefix of that Python (@box/agentcore-codezip). */ pythonPrefix: "${{ inputs.python.prefix }}", } as const; diff --git a/src/core/project/templates/boxProfile.test.ts b/src/core/project/templates/boxProfile.test.ts index 70b53e1ae..be01c00cd 100644 --- a/src/core/project/templates/boxProfile.test.ts +++ b/src/core/project/templates/boxProfile.test.ts @@ -65,7 +65,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-agent" }, project: { access: "write" }, options: { bedrock: { region: "us-west-2" } }, @@ -107,7 +107,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" } }); @@ -140,7 +140,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(); }); @@ -203,7 +203,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 }); }, @@ -211,7 +211,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" } } }); }); @@ -399,9 +399,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", () => { @@ -469,8 +469,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 2e1150241..a218a84fb 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -53,12 +53,18 @@ const BOX_CODE_ENV = "BOX_CODE"; */ const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; +/** 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"; /** @@ -69,7 +75,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]+"; /** @@ -79,9 +85,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 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 the tools of @box/base: box * refuses a CodeZip box profile if a tool it misses gets the project write grant. */ const BOX_BASE_PROJECT_WRITE_TOOLS = ["uname"]; @@ -474,13 +480,13 @@ export function renderBoxProfile( const bedrockRoute = bedrock ? ` # 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"] : [])]); + const packs = list([BOX_BASE_PACK, ...(bedrock ? [BOX_BEDROCK_PACK] : [])]); const env = Object.entries(environment) .map(([name, value]) => `${name} = ${str(value)}`) .join("\n"); @@ -593,7 +599,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 @@ -654,7 +660,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 6c53232edaf7c978909789e10512af05ad023d65 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 14:36:38 -0800 Subject: [PATCH 14/51] chore(box): Pin box 0.1.11-linux-preview.7 Box 0.1.11-linux-preview.6 refuses the profiles of this branch: it does not know the @box/ pack names, and it refuses the key of an input, which the default telemetry target reads. 0.1.11-linux-preview.7 has [strands-agents/staging-boxy#570](https://github.com/strands-agents/staging-boxy/pull/570) and [strands-agents/staging-boxy#625](https://github.com/strands-agents/staging-boxy/pull/625). bun scripts/bump-box-release.ts --box 0.1.11-linux-preview.7 wrote boxRelease.json from the SHA256SUMS.txt of the release (https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7). The Linux SHA-256 is 782290ca3f0f0de3faa6c3943a0b51d521f16b135178ab7e4425986a97ee7622. The ffi shim stays at 0.1.11-linux-preview.2. The README and the tests that name the pinned box name preview.7. @box/base of preview.7 has one tool, uname, so BOX_BASE_PROJECT_WRITE_TOOLS does not change, and its comment names preview.7. Tests: boxProfileResolver.test.ts names preview.7 in the install message. The other tests read the pin from boxRelease.json. --- README.md | 4 ++-- src/core/project/backends/boxRelease.json | 6 +++--- src/core/project/boxProfileResolver.test.ts | 8 ++++---- src/core/project/templates/boxProfile.ts | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index d9cec7fb3..95ab3190e 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.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. @@ -254,7 +254,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-linux-preview.7`. 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/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/boxProfileResolver.test.ts b/src/core/project/boxProfileResolver.test.ts index 9b2bae5cb..8e48ac958 100644 --- a/src/core/project/boxProfileResolver.test.ts +++ b/src/core/project/boxProfileResolver.test.ts @@ -96,8 +96,8 @@ const SHOWN_POLICY = 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)"; + "box 0.1.11-linux-preview.7 or a later release " + + "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7)"; /** * `box profile show open --format json --full` for a profile with the routes `auth` and `github` @@ -328,8 +328,8 @@ describe("BoxCliProfileResolver", () => { ), ).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), " + + "Box is not installed or not on PATH. Install box 0.1.11-linux-preview.7 " + + "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7), " + "then retry.", ), ); diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index a218a84fb..d598fa5b3 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -85,10 +85,10 @@ 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 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 the tools of @box/base: box - * refuses a CodeZip box profile if a tool it misses gets the project write grant. + * 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.7). When the pin moves, check the tools of + * @box/base: box refuses a CodeZip box profile if a tool it misses gets the project write grant. */ const BOX_BASE_PROJECT_WRITE_TOOLS = ["uname"]; From eb30924bcdb794b51c8292c967075c5b362be979 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 18:50:39 -0800 Subject: [PATCH 15/51] test(box): Pin what build does with two routes of one profile to one host The Runtime profile has one route to the Box gateway for each host, and the gateway has one target for each host. A local profile can give one host two routes: two [egress] entries that name it, or one entry that names it two times. No test said what build then does, so a change could drop the keys of one entry, or route a host twice, and give no message. The tests pin these rules, end to end from box profile show to the derived Runtime profile: - Two [egress] entries that name one host stop build with one EGRESS_DESTINATION_OVERLAP problem, at the second entry, that names the two entries. This applies to two open routes, and for a route with a secret and an open route. Box itself refuses two routes with a secret to one host. - One entry that names its host two times, as api.example.com and api.example.com:443, gets one target and one route. - The additions rule adds @box/agentcore and @box/agentcore-codezip only when the profile does not list them. - The additions rule adds the ffi shim to PYTHONPATH only when PYTHONPATH does not start with it. Tests: boxNetworkSource.test.ts "stop build for %s to one host, with one problem that names both entries" (two inputs) and "gives an entry that names its host twice one target and one route". additions.test.ts "adds no Runtime pack that the profile already lists, on CodeZip and on a container" and "adds no second ffi entry to a PYTHONPATH that starts with the ffi shim". With box 0.1.11-linux-preview.7 on macOS, box profile show accepts two open routes, and a route with a secret and an open route, to one host, and refuses two routes with a secret. --- src/core/project/boxNetworkSource.test.ts | 68 +++++++++++++++++++ .../runtimeProfile/rules/additions.test.ts | 30 +++++++- 2 files changed, 96 insertions(+), 2 deletions(-) diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index 6031f04d9..cae38fe04 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -454,6 +454,74 @@ describe("the telemetry of each box runtime", () => { }); }); +describe("two routes of one profile to one host", () => { + /** The Box network model of `agent` for the local profile `text`, which box resolves to `egress`. */ + async function networkOf(text: string, egress: Record) { + const root = await project([]); + await writeFile(join(root, ...LOCAL, "profile.toml"), text); + const [network] = await readBoxNetworks( + SPEC, + root, + new FakeBoxProfileResolver(boxShowOf({ egress })), + ); + return network!; + } + const open = { destinations: ["api.example.com"] }; + const keyed = { destinations: ["api.example.com"], secret: { ref: "env://A_TOKEN" } }; + + test.each([ + [ + "two open routes", + '[egress.a]\ndestinations = ["api.example.com"]\n' + + '[egress.b]\ndestinations = ["api.example.com"]\n', + { a: open, b: open }, + ".box/agent/local/profile.toml:3:1", + ], + [ + "a route with a secret and an open route", + '[egress.a]\ndestinations = ["api.example.com"]\nsecret.ref = "env://A_TOKEN"\n' + + '[egress.b]\ndestinations = ["api.example.com"]\n', + { a: keyed, b: open }, + ".box/agent/local/profile.toml:4:1", + ], + ])( + "stop build for %s to one host, with one problem that names both entries", + async (_label, text, egress, place) => { + const network = await networkOf(text, egress); + + expect(network.failures.map(({ code, reason, place }) => [code, reason, place])).toEqual([ + [ + "EGRESS_DESTINATION_OVERLAP", + "[egress.b] names api.example.com, and [egress.a] names it too, but one host has only " + + "one entry. Keep api.example.com in only one of the two.", + place, + ], + ]); + expect(boxNetworkFailureMessage([network], "build")).toStartWith("Build stopped: 1 problem"); + }, + ); + + test("gives an entry that names its host twice one target and one route", async () => { + const twice = { destinations: ["api.example.com", "api.example.com:443"] }; + const network = await networkOf( + '[egress.a]\ndestinations = ["api.example.com", "api.example.com:443"]\n' + + 'secret.ref = "env://A_TOKEN"\n', + { a: { ...twice, secret: keyed.secret } }, + ); + + expect(network.failures).toEqual([]); + expect(network.hosts.map(({ authority, target }) => [authority, target])).toEqual([ + ["api.example.com", "egress-a"], + ]); + const routes = Object.entries(network.runtimeProfile!.egress as Record).filter( + ([, route]) => route.destinations.includes("api.example.com"), + ); + expect(routes.map(([name, route]) => [name, route.destinations])).toEqual([ + ["egress-a", ["api.example.com"]], + ]); + }); +}); + describe("the IAM policy files of the Box gateway", () => { test("counts the actions of each listed file, and warns for one it cannot count", async () => { const root = await project([]); diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 546f08a94..9320af3f1 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -366,13 +366,24 @@ describe("the additions rule", () => { "@box/agentcore", "@box/agentcore-codezip", ]); - expect(apply({ packs }, contextOf(CONTAINER)).table.packs).toEqual([...packs, "@box/agentcore"]); + expect(apply({ packs }, contextOf(CONTAINER)).table.packs).toEqual([ + ...packs, + "@box/agentcore", + ]); expect( apply({ packs: ["@box/agentcore", "@box/base"] }, contextOf(CONTAINER)).table.packs, ).toEqual(["@box/agentcore", "@box/base"]); expect(apply({}, contextOf(CONTAINER)).table.packs).toEqual(["@box/agentcore"]); }); + test("adds no Runtime pack that the profile already lists, on CodeZip and on a container", () => { + const codeZip = ["@box/agentcore-codezip", "@box/base", "@box/agentcore"]; + const container = ["@box/base", "@box/agentcore"]; + + expect(apply({ packs: codeZip }, contextOf(CODEZIP)).table.packs).toEqual(codeZip); + expect(apply({ packs: container }, contextOf(CONTAINER)).table.packs).toEqual(container); + }); + test("names the profile for the project, and keeps the other [profile] keys", () => { const local = { profile: { name: "demo-agent", description: "mine" } }; @@ -489,7 +500,9 @@ describe("the additions rule", () => { const local = createdProfile(CODEZIP); const bedrock = agentOf(apply(local, contextOf(CODEZIP)).table).env; - const other = agentOf(apply({ ...local, packs: ["@box/base"] }, contextOf(CODEZIP)).table).env; + const other = agentOf( + apply({ ...local, packs: ["@box/base"] }, contextOf(CODEZIP)).table, + ).env; expect(bedrock).not.toHaveProperty("AWS_REGION"); expect(other.AWS_REGION).toBe("${{ inputs.aws.region }}"); @@ -507,6 +520,19 @@ describe("the additions rule", () => { ); }); + test("adds no second ffi entry to a PYTHONPATH that starts with the ffi shim", () => { + for (const path of [ + "${{ inputs.code.dir }}/.box-dist/ffi", + "${{ inputs.code.dir }}/.box-dist/ffi:${{ workspace }}/app/agent/lib", + ]) { + const env = { PYTHONPATH: path }; + + expect(agentOf(apply({ agent: { env } }, contextOf(CODEZIP)).table).env.PYTHONPATH).toBe( + path, + ); + } + }); + test("sets the region, the AWS stand-ins, and the ffi PYTHONPATH whatever the template's Runtime env", () => { const openAi = runtimeOf("CodeZip", "HTTP", "OpenAI"); const context = contextOf(openAi); From 08f7334cb7e64e18cb41dc552aa46aa882a1bfd9 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:01:02 -0800 Subject: [PATCH 16/51] feat(box): Stop build for a write grant in the code folder of a CodeZip runtime On a CodeZip AgentCore Runtime, the paths rule moves each path of the code folder to ${{ inputs.code.dir }}, and the agent gets exec on that folder. box refuses a write grant in a folder that the box can run files from. Thus a local write grant in the code folder, for example [mcp.notes.filesystem] write = ["${{ workspace }}/app/agent/notes"], gave a Runtime profile that box refused when the agent started on the Runtime. Build ran box profile show only on the local profile, where the agent has no exec on the code folder, so build gave no message. The real check found this. With box 0.1.11-linux-preview.7, box profile show of the derived profile of such a server stopped on macOS and in the Linux image: "the `exec` folder .../app/agent holds the write grant .../app/agent/notes, so the workload can run a file it writes". With this change, the refusals rule stops build for each write or write_file grant of [agent], a stdio [mcp.], or a [tool.] that is in the code folder on a CodeZip runtime (RUNTIME_WRITE_IN_CODE). The message names the key, the path, and the reason. A container runtime keeps its grants, because the image runs the same paths under agentcore dev and on the Runtime. Tests: refusals.test.ts "stops for a write grant in the code folder of [agent], a stdio [mcp], and a [tool], on a CodeZip Runtime only (RUNTIME_WRITE_IN_CODE)". The paths rule test of the stdio server no longer has a write grant in the code folder. --- .../runtimeProfile/rules/paths.test.ts | 2 - .../runtimeProfile/rules/refusals.test.ts | 42 +++++++++++++++++++ .../project/runtimeProfile/rules/refusals.ts | 38 ++++++++++++++++- src/core/project/runtimeProfile/types.ts | 2 + 4 files changed, 81 insertions(+), 3 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 6e3464aa1..97238d909 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -65,7 +65,6 @@ const LEAVES = toml( "", "[mcp.notes.filesystem]", `read = ["${APP}", { path = "${APP}/.venv", optional = true }, { path = "\${{ home }}/.local/share/uv/python", optional = true }]`, - `write = ["${APP}/notes/out"]`, "", "[mcp.notes.network]", "contain_egress = true", @@ -90,7 +89,6 @@ const LEAVES_ON_RUNTIME = { // The venv moves to the code folder, which the first grant names already. filesystem: { read: [CODE, { path: PREFIX, optional: true }], - write: [`${CODE}/notes/out`], }, network: { contain_egress: true }, }, diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index 3cddaf549..a5a030567 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -190,6 +190,48 @@ describe("the refusals rule", () => { }, ); + test("stops for a write grant in the code folder of [agent], a stdio [mcp], and a [tool], on a CodeZip Runtime only (RUNTIME_WRITE_IN_CODE)", () => { + const text = toml( + "[agent.filesystem]", + `write = ["${APP}/cache"]`, + "[mcp.notes]", + 'type = "stdio"', + `command = ["${APP}/.venv/bin/python3.15", "${APP}/notes_server.py"]`, + "[mcp.notes.filesystem]", + `write_file = [{ path = "${APP}/notes.db", optional = true }]`, + "[tool.lister]", + `command = ["${APP}/bin/lister"]`, + "[tool.lister.filesystem]", + `write = ["${APP}"]`, + ); + const reason = (key: string, path: string) => + `${key} names "${path}", a path in app/agent/. On AgentCore Runtime, the agent can run ` + + "each file in app/agent/, and box refuses a write grant in a folder that the box can run " + + "files from. Remove the path from the list."; + + expect(problemsOf(text)).toEqual([ + { + code: "RUNTIME_WRITE_IN_CODE", + key: ["agent", "filesystem", "write"], + reason: reason("[agent.filesystem] write", `${APP}/cache`), + place: `${PROFILE}:2:1`, + }, + { + code: "RUNTIME_WRITE_IN_CODE", + key: ["mcp", "notes", "filesystem", "write_file"], + reason: reason("[mcp.notes.filesystem] write_file", `${APP}/notes.db`), + place: `${PROFILE}:7:1`, + }, + { + code: "RUNTIME_WRITE_IN_CODE", + key: ["tool", "lister", "filesystem", "write"], + reason: reason("[tool.lister.filesystem] write", APP), + place: `${PROFILE}:11:1`, + }, + ]); + expect(problemsOf(text, CONTAINER)).toEqual([]); + }); + test("stops for a [tool] program that box finds on PATH, on a CodeZip Runtime only", () => { const text = toml("[tool.jq]", 'program = "jq"'); diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index 717f8b28c..8ba968a40 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -9,9 +9,10 @@ * | a `[telemetry.]` that is not `cloudwatch_logs` or `cloudwatch_traces` | RUNTIME_TELEMETRY_NOT_CLOUDWATCH | * | CodeZip: a path of the project outside the code folder, of the home folder, or in the venv | RUNTIME_PATH_NOT_FOUND | * | CodeZip: a stdio server or tool program that is not the venv's Python or a file in the code folder | RUNTIME_PROGRAM_NOT_FOUND | + * | CodeZip: a `write` or `write_file` grant in the code folder, which the agent runs files from on the Runtime | RUNTIME_WRITE_IN_CODE | * * A container image runs the same paths and programs under `agentcore dev` and on the Runtime, so - * the last two do not apply to it. It replaces the CloudWatch-only filter of `cloudWatchTelemetry` + * the last three do not apply to it. It replaces the CloudWatch-only filter of `cloudWatchTelemetry` * (boxNetwork/telemetry.ts), which leaves out each other target with no message. */ import { keyLabel } from "../derive"; @@ -32,6 +33,9 @@ import type { TomlTable, } from "../types"; +/** The filesystem lists that let a process write. */ +const WRITE_LISTS = ["write", "write_file"] as const; + /** The telemetry kinds that a box on AgentCore Runtime can send to, with the execution role. */ const RUNTIME_TELEMETRY_KINDS: ReadonlySet = new Set([ "cloudwatch_logs", @@ -107,6 +111,27 @@ export function apply(table: Readonly, context: RuntimeProfileContext problem("RUNTIME_PROGRAM_NOT_FOUND", [...key, "program"], notFound(searched, paths)); } } + // On the Runtime the agent gets exec on the code folder, and box refuses a write grant in a + // folder that it can run files from. + for (const { key, table: process } of processTables(table)) { + const filesystem = isTable(process.filesystem) ? process.filesystem : {}; + for (const list of WRITE_LISTS) { + const grants = filesystem[list]; + if (!Array.isArray(grants)) continue; + for (const grant of grants) { + const path = grantPath(grant); + const moved = path === undefined ? undefined : moveProjectPath(path, paths); + if (typeof moved !== "string" || !inRuntimeCode(moved, paths)) continue; + problem( + "RUNTIME_WRITE_IN_CODE", + [...key, "filesystem", list], + `names ${JSON.stringify(path)}, a path in ${code}. On AgentCore Runtime, the agent ` + + `can run each file in ${code}, and box refuses a write grant in a folder that the ` + + "box can run files from. Remove the path from the list.", + ); + } + } + } } return { @@ -116,6 +141,17 @@ export function apply(table: Readonly, context: RuntimeProfileContext }; } +/** The path of a filesystem grant: the string, or the `path` of a grant table. */ +function grantPath(grant: unknown): string | undefined { + if (typeof grant === "string") return grant; + return isTable(grant) && typeof grant.path === "string" ? grant.path : undefined; +} + +/** Whether `path`, as a CodeZip Runtime profile names it, is the code folder or in it. */ +function inRuntimeCode(path: string, paths: RuntimeProfileContext["paths"]): boolean { + return path === paths.runtimeCode || path.startsWith(`${paths.runtimeCode}/`); +} + /** Why build cannot find the program `program` of a process on a CodeZip Runtime. */ function notFound(program: string, paths: RuntimeProfileContext["paths"]): string { return ( diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts index 648ae9b1e..0147b78f4 100644 --- a/src/core/project/runtimeProfile/types.ts +++ b/src/core/project/runtimeProfile/types.ts @@ -80,6 +80,8 @@ export const RUNTIME_PROFILE_PROBLEM_CODES = [ "RUNTIME_PATH_NOT_FOUND", /** A program that build cannot find on the Runtime. */ "RUNTIME_PROGRAM_NOT_FOUND", + /** A write grant in the code folder of a CodeZip Runtime, which box runs files from. */ + "RUNTIME_WRITE_IN_CODE", /** A process whose calls on the Runtime would not go through the Box gateway. */ "RUNTIME_EGRESS_NOT_CONTAINED", /** A telemetry target that is not CloudWatch, which the Runtime cannot send to yet. */ From ac3a9d536b98e50f05321c066789178ce3f93b13 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:03:01 -0800 Subject: [PATCH 17/51] test(box): Write no bytecode into src/assets when the start.py test imports it boxStartPy.test.ts imports start.py from src/assets/templates/box-codezip with python3 -I. A Python that writes bytecode then leaves a __pycache__ folder in that template folder, and build copies src/assets into the package. With a Python 3.12 import, the folder came to exist. The test now runs python3 with -B, which writes no bytecode. Tests: boxStartPy.test.ts passes, and git status shows no new file after it. --- src/core/project/templates/boxStartPy.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/project/templates/boxStartPy.test.ts b/src/core/project/templates/boxStartPy.test.ts index 4cb1319db..951cfb432 100644 --- a/src/core/project/templates/boxStartPy.test.ts +++ b/src/core/project/templates/boxStartPy.test.ts @@ -45,6 +45,8 @@ function boxPython(executable: string): string { "python3", [ "-I", + // No __pycache__ in src/assets, which build copies into the package. + "-B", "-c", "import sys; sys.path.insert(0, sys.argv[1]); import start; " + "print(start.box_python(sys.argv[2], (3, 12)))", From 737e1079b1eeb6e9fc195d6f02f586c0607ac04b Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:24:25 -0800 Subject: [PATCH 18/51] fix(box): Name the Runtime route of an entry with one host after the entry The derived Runtime profile keeps each pack of the local profile. The gateway rule named each [egress] route after its gateway target, for example [egress.egress-anthropic] for the [egress.anthropic] entry of @box/anthropic. On AgentCore Runtime, the pack adds its own [egress.anthropic] again, so the profile had two routes to api.anthropic.com, and box refuses that when the agent starts. The same happened when the profile changes an entry of a pack, for example [egress.anthropic] secret.ref = "env://MY_KEY". The renderer that the derivation replaced removed each pack of the user, so it did not have this problem. The independent review of this PR found it. With this change, the route of an entry with one host has the name of the entry. Its backend still names the gateway target. box merges the table of the pack with the route of the same name, as it merges [egress.bedrock] of @box/bedrock with the bedrock route of each box template. A route keeps the name of its target when its entry has more than one host, when it serves no entry, or when a target of the entry's name serves another host. The route names on the Runtime are different from the names of the old renderer, for example [egress.github] and not [egress.egress-github]. The routes are the same. The tests that compare the gateway rule with the recorded output of the old renderer compare the routes under the new names. Tests: gateway.test.ts "gives the route of an entry %s the name of the entry, so the table of the pack merges with it" (an entry that a pack adds, and an entry that the profile changes) and "names a route after its target when a target of the entry's name serves another host". manager.boxNetwork.test.ts and boxNetworkSource.test.ts expect the entry names. box 0.1.11-linux-preview.7 on macOS (box profile show), with packs = ["@box/base", "@box/anthropic"] and a gateway route to api.anthropic.com: under the name egress-anthropic, box refuses the profile ("`egress-anthropic` and `anthropic` both name host "api.anthropic.com""). Under the name anthropic, box accepts it, and merges the secret of the pack with the backend of the route. Not tested: a call through that route on AgentCore Runtime. --- src/core/project/boxNetworkSource.test.ts | 2 +- src/core/project/manager.boxNetwork.test.ts | 13 ++-- .../runtimeProfile/rules/gateway.test.ts | 66 ++++++++++++++++--- .../project/runtimeProfile/rules/gateway.ts | 31 ++++++++- 4 files changed, 97 insertions(+), 15 deletions(-) diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index cae38fe04..12f7e07ee 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -517,7 +517,7 @@ describe("two routes of one profile to one host", () => { ([, route]) => route.destinations.includes("api.example.com"), ); expect(routes.map(([name, route]) => [name, route.destinations])).toEqual([ - ["egress-a", ["api.example.com"]], + ["a", ["api.example.com"]], ]); }); }); diff --git a/src/core/project/manager.boxNetwork.test.ts b/src/core/project/manager.boxNetwork.test.ts index 7469568df..2a94bb25b 100644 --- a/src/core/project/manager.boxNetwork.test.ts +++ b/src/core/project/manager.boxNetwork.test.ts @@ -279,13 +279,14 @@ describe("build writes the Box network of the box profile", () => { expect(profile.policies).toEqual(["policy.dw"]); expect(await text(root, "app/agent_python_strands/.box-dist/policy.dw")).toBe(POLICY); const egress = profile.egress as Record; + // The route of [egress.github] keeps the name of its entry, and goes to its target. expect(Object.keys(egress).sort()).toEqual([ "agentcore", "bedrock", - "egress-github", "egress-httpbin-org", + "github", ]); - expect(egress["egress-github"]).toEqual(gatewayRoute("egress-github", "api.github.com")); + expect(egress.github).toEqual(gatewayRoute("egress-github", "api.github.com")); expect(egress["egress-httpbin-org"]).toEqual(gatewayRoute("egress-httpbin-org", "httpbin.org")); expect(egress.bedrock).toEqual( gatewayRoute("bedrock", "bedrock-runtime.us-west-2.amazonaws.com"), @@ -401,7 +402,7 @@ describe("build writes the Box network of the box profile", () => { expect(await targetNames(root)).toEqual(["gh", "weather", "bedrock", "agentcore"]); const egress = (await runtimeProfile(root)).egress as Record; - expect(egress.gh).toMatchObject({ destinations: ["api.github.com"] }); + expect(egress.github).toEqual(gatewayRoute("gh", "api.github.com")); }); test("removes a target it added when the profile no longer allows its host, and only that one", async () => { @@ -440,7 +441,11 @@ describe("build writes the Box network of the box profile", () => { expect(await targetNames(root)).toEqual(["bedrock", "agentcore"]); const egress = (await runtimeProfile(root)).egress as Record; - expect(Object.keys(egress)).toEqual(["bedrock", "agentcore"]); + // The route of [egress.memory] keeps the name of its entry, and goes to the agentcore target. + expect(Object.keys(egress)).toEqual(["bedrock", "memory"]); + expect(egress.memory).toEqual( + gatewayRoute("agentcore", "bedrock-agentcore.us-west-2.amazonaws.com"), + ); }); test("on a first build, stops with every problem, where it is, and writes nothing", async () => { diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index a6710d268..9e52791b7 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -182,15 +182,50 @@ describe("the gateway rule", () => { expect(table).toEqual( parse( 'packs = ["@box/base"]\n' + - "[egress.egress-github]\n" + + // The route keeps the name of its entry; its backend names the target. + "[egress.github]\n" + 'destinations = ["api.github.com"]\n' + 'protocol = "http"\n' + 'x-later-key = "kept"\n' + - backendText("egress.egress-github", "egress-github"), + backendText("egress.github", "egress-github"), ), ); }); + test.each([ + ["that a pack adds", 'packs = ["@box/base", "@box/anthropic"]\n'], + [ + "that the profile changes", + 'packs = ["@box/base", "@box/anthropic"]\n[egress.anthropic]\nsecret.ref = "env://MY_KEY"\n', + ], + ])( + "gives the route of an entry %s the name of the entry, so the table of the pack merges with it", + (_label, text) => { + const { table } = gateway(text, [ + host("api.anthropic.com", entry("anthropic", "api.anthropic.com"), "egress-anthropic"), + ]); + + // A route under the target's name beside the pack's own [egress.anthropic] would be a second + // route to api.anthropic.com, which box refuses. + expect(table.egress).toEqual( + parse( + '[egress.anthropic]\ndestinations = ["api.anthropic.com"]\n' + + backendText("egress.anthropic", "egress-anthropic"), + ).egress, + ); + }, + ); + + test("names a route after its target when a target of the entry's name serves another host", () => { + const { table } = gateway( + '[egress.orders]\ndestinations = ["api.example.com"]\n', + [host("api.example.com", entry("orders", "api.example.com"), "egress-orders")], + [passthrough("orders", "https://orders.example.com")], + ); + + expect(Object.keys(table.egress as TomlTable).sort()).toEqual(["egress-orders", "orders"]); + }); + test("gives each host of an entry with several destinations its own route, signed for the Runtime's region and not the build region", () => { const text = '[egress.models]\ndestinations = ["api.one.example.com", "api.two.example.com:8443/v1"]\n'; @@ -403,6 +438,19 @@ function rendered(label: string): TomlTable { return { ...(egress && { egress }), ...(Object.keys(mcp).length > 0 && { mcp }) }; } +/** + * The `[egress]` routes of the old renderer under the keys that the gateway rule gives them: the + * old renderer named each route after its target, and the rule names the route of an entry with one + * host after the entry, so that a pack table of that name merges with it. The routes are the same. + */ +const withEntryKeys = (egress: unknown) => + Object.fromEntries( + Object.entries(egress as TomlTable).map(([key, route]) => [ + key === "egress-github" ? "github" : key, + route, + ]), + ); + describe("the gateway rule and the Runtime renderer it replaced", () => { const TEXT = [ 'packs = ["@box/base", "@box/bedrock"]', @@ -551,10 +599,10 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { "orders", ]); expect(Object.keys(http(old.mcp))).toEqual(["docs"]); - expect(derived.profile.egress).toEqual(old.egress); + expect(derived.profile.egress).toEqual(withEntryKeys(old.egress)); expect(http(derived.profile.mcp)).toEqual(http(old.mcp)); // The model that build keeps holds the same derived profile. - expect(network.runtimeProfile?.egress).toEqual(old.egress); + expect(network.runtimeProfile?.egress).toEqual(withEntryKeys(old.egress)); expect(http(network.runtimeProfile?.mcp)).toEqual(http(old.mcp)); }); @@ -565,7 +613,7 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { expect(network.failures).toEqual([]); expect(first.agentCoreGateways[0]!.targets.map(({ name }) => name)).toContain("egress-github"); - expect(derived.profile.egress).toEqual(old.egress); + expect(derived.profile.egress).toEqual(withEntryKeys(old.egress)); expect(http(derived.profile.mcp)).toEqual(http(old.mcp)); }); @@ -580,8 +628,10 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { backendText('egress."tools.v2"', "tools.v2"), ).egress as TomlTable; expect((old.egress as TomlTable)["tools.v2"]).toEqual(quoted["tools.v2"]); - expect(derived.profile.egress).toEqual(old.egress); - expect(parse(serializeRuntimeProfile(derived.profile)).egress as unknown).toEqual(old.egress); + expect(derived.profile.egress).toEqual(withEntryKeys(old.egress)); + expect(parse(serializeRuntimeProfile(derived.profile)).egress as unknown).toEqual( + withEntryKeys(old.egress), + ); }); test("give no second problem for an entry that the Box network model rejects, and no route", () => { @@ -607,7 +657,7 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { ["MCP_DESTINATION_NOT_ONE_HOST", "pathed"], ]); expect(derived.problems).toEqual([]); - expect(derived.profile.egress).toEqual(old.egress); + expect(derived.profile.egress).toEqual(withEntryKeys(old.egress)); expect(derived.profile.mcp).toBeUndefined(); expect(old.mcp).toBeUndefined(); }); diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index d891e53f8..4e5c7bcbc 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -59,7 +59,7 @@ export function apply(table: Readonly, context: RuntimeProfileContext host.sources.some((source) => source.kind === "entry" && source.egressEntry === name), ); for (const route of routesOf(hosts, routes)) { - egress[route.target] = egressRoute(entry, route); + egress[routeKey(route, routes, context)] = egressRoute(entry, route); written.add(route.target); } } @@ -81,7 +81,7 @@ export function apply(table: Readonly, context: RuntimeProfileContext if (route.server) { mcp[route.server.mcpEntry] = mcpServer({}, route, route.server); } else { - egress[route.target] = egressRoute({}, route); + egress[routeKey(route, routes, context)] = egressRoute({}, route); } } @@ -143,6 +143,33 @@ function gatewayRoutes(context: RuntimeProfileContext): GatewayRoute[] { }); } +/** + * The key of the `[egress]` route of `route`: the name of the one entry whose one host the route + * serves, else the name of the target. A pack that the profile imports keeps its own + * `[egress.]` on the Runtime, and box merges it with the route of that name, as + * `[egress.bedrock]` of @box/bedrock does. A route under another name would be a second route to + * the host, which box refuses. A target of the same name for another host keeps its name. + */ +function routeKey( + route: GatewayRoute, + routes: readonly GatewayRoute[], + context: RuntimeProfileContext, +): string { + const entriesOf = (host: BoxNetworkHost) => [ + ...new Set( + host.sources.flatMap((source) => (source.kind === "entry" ? [source.egressEntry] : [])), + ), + ]; + const served = context.hosts.filter((host) => host.target === route.target); + const entries = [...new Set(served.flatMap(entriesOf))]; + if (entries.length !== 1) return route.target; + const name = entries[0]!; + const hosts = context.hosts.filter((host) => entriesOf(host).includes(name)); + if (hosts.length !== 1) return route.target; + if (name !== route.target && routes.some(({ target }) => target === name)) return route.target; + return name; +} + /** The routes of `hosts`, in the order of the hosts; a host with no route has none. */ function routesOf( hosts: readonly BoxNetworkHost[], From 398299fc3ac66d1edad5519eddbce028f392f417 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:29:23 -0800 Subject: [PATCH 19/51] fix(box): Stop build for a host home path and an agent program that a CodeZip Runtime does not have The refusals rule examined only a path that names ${{ workspace }} or ${{ home }}, and the program of a stdio server or a tool. Thus build let these through to a CodeZip Runtime, where box refuses them when the agent starts: - a grant or a value in the home folder that names no ${{ home }}: ~, ~/data, /Users/me/data, or /home/me/data. box expands ~ to the home folder, which is empty on the Runtime, and the Runtime has no /Users or /home of the host; - an [agent] command of the user that starts a program that is not the venv's Python or a file in the code folder, for example /opt/homebrew/bin/python3. The comment of the rule said that the additions rule writes the [agent] command, but that rule keeps a command of the user. The independent review of this PR found these. With this change, the refusals rule gives RUNTIME_PATH_NOT_FOUND for a value that starts with ~, ~/, /Users/, or /home/, and RUNTIME_PROGRAM_NOT_FOUND for the [agent] program, as it does for a leaf. The command of the template moves to the Runtime's Python, so it is not a problem. A container runtime keeps each path and program. Two comments that were not correct now say what the rules do. Other absolute paths stay as the local profile has them, for example /etc/ssl/certs: build cannot see the file system of the Runtime. Tests: refusals.test.ts "stops for an [agent] program of the user that build cannot find, on a CodeZip Runtime only" and "stops for the host home path %s, on a CodeZip Runtime only (RUNTIME_PATH_NOT_FOUND)" (4 paths). The test fixtures that used [agent] command = ["/bin/echo"] on CodeZip now start a program in the code folder. --- .../project/runtimeProfile/derive.test.ts | 6 +++- .../project/runtimeProfile/projectPaths.ts | 5 ++++ .../runtimeProfile/rules/gateway.test.ts | 2 +- .../runtimeProfile/rules/paths.test.ts | 2 +- .../project/runtimeProfile/rules/paths.ts | 4 +-- .../runtimeProfile/rules/refusals.test.ts | 28 +++++++++++++++++++ .../project/runtimeProfile/rules/refusals.ts | 13 ++++----- 7 files changed, 48 insertions(+), 12 deletions(-) diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts index 96777d4b4..0b398ce5e 100644 --- a/src/core/project/runtimeProfile/derive.test.ts +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -54,7 +54,11 @@ describe("deriveRuntimeProfile", () => { test.each([CODEZIP, CONTAINER])( "carries each key that no rule changes as the local profile has it ($build)", (runtime) => { - const local = { packs: ["@box/base"], ...CARRIED, agent: { command: ["/bin/echo"] } }; + const local = { + packs: ["@box/base"], + ...CARRIED, + agent: { command: ["${{ workspace }}/app/agent/run"] }, + }; const { profile, problems } = deriveRuntimeProfile(local, context(runtime)); diff --git a/src/core/project/runtimeProfile/projectPaths.ts b/src/core/project/runtimeProfile/projectPaths.ts index d6d53b26f..c96fbeb6e 100644 --- a/src/core/project/runtimeProfile/projectPaths.ts +++ b/src/core/project/runtimeProfile/projectPaths.ts @@ -52,6 +52,9 @@ const literal = (text: string) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); /** The end of a file name: no more of its letters follow. A `/` can follow. */ const NAME_END = "(?![A-Za-z0-9_.+-])"; +/** A path in a home folder that names no `${{ home }}`: `~`, `~/...`, `/Users/...`, `/home/...`. */ +const HOST_HOME = /^(?:~(?:\/|$)|\/(?:Users|home)\/)/; + /** The end of a path: no more of it follows, not even a `/`. */ const PATH_END = "(?![A-Za-z0-9_.+/-])"; @@ -65,6 +68,8 @@ export function moveProjectPath( value: string, paths: RuntimePaths, ): string | { readonly problem: PathProblem } { + // box expands `~` to the home folder, and a host's own home is under /Users or /home. + if (HOST_HOME.test(value)) return { problem: "home" }; const normal = value .replace(/\$\{\{\s*workspace\s*\}\}/g, () => WORKSPACE) .replace(/\$\{\{\s*home\s*\}\}/g, () => HOME); diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index 9e52791b7..c978874d8 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -457,7 +457,7 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { 'policies = ["policy.dw"]', "", "[agent]", - 'command = ["/bin/echo"]', + 'command = ["${{ workspace }}/app/agent/run"]', "", "[egress.bedrock]", 'secret.ref = "aws://default"', diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 97238d909..20e4d892a 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -54,7 +54,7 @@ const LEAVES = toml( 'packs = ["@box/base"]', "", "[agent]", - 'command = ["/bin/echo"]', + 'command = ["${{ workspace }}/app/agent/run"]', "", "[mcp.notes]", 'type = "stdio"', diff --git a/src/core/project/runtimeProfile/rules/paths.ts b/src/core/project/runtimeProfile/rules/paths.ts index b9edb68aa..9e2de1a3a 100644 --- a/src/core/project/runtimeProfile/rules/paths.ts +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -9,8 +9,8 @@ * code folder when it sets none, and the `_ctypes` folder in front of a `PYTHONPATH` of its own, as * the additions rule does for `[agent]`. Each entry of a path list moves, and an entry that names a * Runtime input stays. The refusals rule stops build for a path that has no place on the - * Runtime, so this rule keeps such a path as it is. It replaces the path moves of - * runtimeCodeZipRunner (templates/boxProfile.ts). + * Runtime, so this rule keeps such a path as it is. runtimeCodeZipRunner (templates/boxProfile.ts) + * gives the Runtime grants of the template in the local paths, and this rule moves them too. */ import { isTable, diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index a5a030567..8f976bf74 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -232,6 +232,34 @@ describe("the refusals rule", () => { expect(problemsOf(text, CONTAINER)).toEqual([]); }); + test("stops for an [agent] program of the user that build cannot find, on a CodeZip Runtime only", () => { + const text = toml("[agent]", 'command = ["/opt/homebrew/bin/python3", "main.py"]'); + + expect(problemsOf(text).map(({ code, key, place }) => [code, key, place])).toEqual([ + ["RUNTIME_PROGRAM_NOT_FOUND", ["agent", "command"], `${PROFILE}:2:1`], + ]); + expect(problemsOf(text, CONTAINER)).toEqual([]); + }); + + test.each(["~", "~/data", "/Users/me/data", "/home/me/data"])( + "stops for the host home path %s, on a CodeZip Runtime only (RUNTIME_PATH_NOT_FOUND)", + (path) => { + const text = toml("[agent.filesystem]", `read = ["${APP}", "${path}"]`); + + expect(problemsOf(text)).toEqual([ + { + code: "RUNTIME_PATH_NOT_FOUND", + key: ["agent", "filesystem", "read"], + reason: + `[agent.filesystem] read names "${path}" in the home folder. The home folder on ` + + "AgentCore Runtime is empty. Move the file into app/agent/, or remove the path.", + place: `${PROFILE}:2:1`, + }, + ]); + expect(problemsOf(text, CONTAINER)).toEqual([]); + }, + ); + test("stops for a [tool] program that box finds on PATH, on a CodeZip Runtime only", () => { const text = toml("[tool.jq]", 'program = "jq"'); diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index 8ba968a40..cfa60b052 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -7,13 +7,13 @@ * | --- | --- | * | `network.contain_egress = false` on `[agent]`, a stdio `[mcp.]`, or a `[tool.]` | RUNTIME_EGRESS_NOT_CONTAINED | * | a `[telemetry.]` that is not `cloudwatch_logs` or `cloudwatch_traces` | RUNTIME_TELEMETRY_NOT_CLOUDWATCH | - * | CodeZip: a path of the project outside the code folder, of the home folder, or in the venv | RUNTIME_PATH_NOT_FOUND | - * | CodeZip: a stdio server or tool program that is not the venv's Python or a file in the code folder | RUNTIME_PROGRAM_NOT_FOUND | + * | CodeZip: a path of the project outside the code folder, of the home folder (`${{ home }}`, `~`, `/Users`, `/home`), or in the venv | RUNTIME_PATH_NOT_FOUND | + * | CodeZip: an `[agent]`, stdio server, or tool program that is not the venv's Python or a file in the code folder | RUNTIME_PROGRAM_NOT_FOUND | * | CodeZip: a `write` or `write_file` grant in the code folder, which the agent runs files from on the Runtime | RUNTIME_WRITE_IN_CODE | * * A container image runs the same paths and programs under `agentcore dev` and on the Runtime, so - * the last three do not apply to it. It replaces the CloudWatch-only filter of `cloudWatchTelemetry` - * (boxNetwork/telemetry.ts), which leaves out each other target with no message. + * the last three do not apply to it. The rule reads only the text of the local profile: a key that + * a pack adds is not in that text, so the rule does not examine it. */ import { keyLabel } from "../derive"; import { @@ -97,11 +97,10 @@ export function apply(table: Readonly, context: RuntimeProfileContext return value; }); for (const { key, table: process, leaf } of processTables(table)) { - // The additions rule writes the command of [agent], so this check is for a leaf only. - if (!leaf) continue; + // The command of the template moves to the Runtime's Python. A command of the user stays. const command = programOf(process); const moved = command === undefined ? undefined : moveProjectPath(command, paths); - const searched = typeof process.program === "string" ? process.program : undefined; + const searched = leaf && typeof process.program === "string" ? process.program : undefined; // A program with no place on the Runtime is a path problem of its command already. const program = typeof moved === "string" ? moved : undefined; if (program !== undefined && !isRuntimeProgram(program, paths)) { From 2913cd26632b15c1b6a0be41b49dc914560e9c31 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:31:27 -0800 Subject: [PATCH 20/51] fix(box): Give the Runtime no template grant that the local profile removed The additions rule gives each [agent.filesystem] list the Runtime grants of the template, and leaves out a template grant that the user removed. It compared the grants by value. The local grants of the template are tables with optional = true, and its Runtime grants are strings, so no Runtime grant was equal to a local one. Thus each CodeZip agent got exec on the code folder and on the Runtime Python, and read on /usr/lib64 and /lib64, whatever its local profile had. An [agent] with no filesystem table got exec on the whole code folder, which holds .box-dist/box. The independent review of this PR found this. With this change, a grant is the same as another when its path is. A list gets each Runtime grant of the template only when the local list keeps each grant of the template. When the user removed a grant of the template, the list gets only the Runtime grants that it names. Thus the Runtime gets no grant that the local profile does not give. The profile that create writes gets the same grants as before. Tests: additions.test.ts "gives a list no Runtime grant of the template when the user removed a grant of the template from it" and "gives an [agent] with no filesystem table no grant". The 72 and 66 inputs of the created templates give the same profile as before. --- .../runtimeProfile/rules/additions.test.ts | 19 ++++++++++ .../project/runtimeProfile/rules/additions.ts | 35 ++++++++++++------- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 9320af3f1..a42a79edc 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -589,6 +589,25 @@ describe("the additions rule", () => { }); }); + test("gives a list no Runtime grant of the template when the user removed a grant of the template from it", () => { + const local = createdProfile(CODEZIP); + const filesystem = agentOf(local).filesystem; + // The user keeps the code folder, and removes the venv and the uv Pythons. + filesystem.read = ["${{ workspace }}/app/agent"]; + filesystem.exec = []; + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).filesystem).toEqual({ + read: ["${{ workspace }}/app/agent"], + }); + }); + + test("gives an [agent] with no filesystem table no grant", () => { + const local = createdProfile(CODEZIP); + delete agentOf(local).filesystem; + + expect(agentOf(apply(local, contextOf(CODEZIP)).table)).not.toHaveProperty("filesystem"); + }); + test("leaves out a grant that the user removed from a container's template", () => { const local = createdProfile(CONTAINER); const filesystem = agentOf(local).filesystem; diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index f9ee8a73a..f3fc643bb 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -270,9 +270,12 @@ function runtimeEnv( } /** - * `[agent.filesystem]` for the Runtime. In each list, the template's Runtime grants come first: - * each one that only the Runtime has, and each one that the template has under dev too and the - * local profile keeps. Each grant of the user follows in its order. A list that ends empty goes. + * `[agent.filesystem]` for the Runtime. In each list, the template's Runtime grants come first, and + * each grant of the user follows in its order. When the local list keeps each grant of the + * template, the list gets each Runtime grant of the template. When the user removed a grant of the + * template, the list gets only the Runtime grants that it names, so the Runtime gets no grant that + * the local profile does not give. A grant is the same as another when its path is, whether it is + * optional or not. A list that ends empty goes. */ function runtimeFilesystem( filesystem: unknown, @@ -291,14 +294,16 @@ function runtimeFilesystem( } const grants = (own ?? []) as unknown[]; const localGrants = listOf(templateLocal[name]); - const kept = listOf(templateRuntime[name]).filter( - (grant) => !includes(localGrants, grant) || includes(grants, grant), - ); + const runtimeGrants = listOf(templateRuntime[name]); + const keepsTemplate = localGrants.every((grant) => includesPath(grants, grant)); + const kept = keepsTemplate + ? runtimeGrants + : runtimeGrants.filter((grant) => includesPath(grants, grant)); const users = grants.filter( (grant, index) => - !includes(localGrants, grant) && - !includes(kept, grant) && - !includes(grants.slice(0, index), grant), + !includesPath(localGrants, grant) && + !includesPath(kept, grant) && + !includesPath(grants.slice(0, index), grant), ); const list = [...structuredClone(kept), ...users]; if (list.length > 0) result[name] = list; @@ -306,6 +311,14 @@ function runtimeFilesystem( return filesystem !== undefined || Object.keys(result).length > 0 ? result : undefined; } +/** The path of a filesystem grant: the string, or the `path` of a grant table. */ +const pathOf = (grant: unknown): unknown => + isTable(grant) && typeof grant.path === "string" ? grant.path : grant; + +/** Whether `list` holds a grant of the path of `grant`, optional or not. */ +const includesPath = (list: readonly unknown[], grant: unknown) => + list.some((other) => sameValue(pathOf(other), pathOf(grant))); + /** * Each `[[agent.ingress]]` for the Runtime: the template's own ingress becomes its Runtime ingress, * and each other one listens on `0.0.0.0` on its own port, as the Runtime reaches the microVM there. @@ -390,10 +403,6 @@ const tableOf = (value: unknown): TomlTable => (isTable(value) ? value : {}); /** `value` when it is a list, or an empty list. */ const listOf = (value: unknown): readonly unknown[] => (Array.isArray(value) ? value : []); -/** Whether `list` holds a value equal to `value`. */ -const includes = (list: readonly unknown[], value: unknown) => - list.some((other) => sameValue(other, value)); - /** Whether two TOML values are equal: tables by their keys in any order, lists in order. */ function sameValue(left: unknown, right: unknown): boolean { if (Array.isArray(left) || Array.isArray(right)) { From e43ee627fa6520b16e6a46650f7f00861267a99e Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:33:28 -0800 Subject: [PATCH 21/51] fix(box): Take a telemetry table with no kind that adds to a CloudWatch target of a pack A [telemetry.] table with no kind adds keys to the target of that name that a pack gives. The refusals rule stopped build for it ("kind is not set"), and the additions rule did not sign it with the execution role. The independent review of this PR found this. With this change, when box resolves a CloudWatch target of that name, the refusals rule takes the table, and the additions rule signs it with a bare aws://, in the region of the resolved target. A cloudwatch_logs target of this kind replaces the default log target. A table with no kind and no CloudWatch target of its name still stops build. Tests: refusals.test.ts "takes a [telemetry] table with no kind that adds to a CloudWatch target of a pack". additions.test.ts "signs a table with no kind that adds to the CloudWatch target of a pack". --- .../runtimeProfile/rules/additions.test.ts | 18 ++++++++++++++++++ .../project/runtimeProfile/rules/additions.ts | 11 +++++++---- .../runtimeProfile/rules/refusals.test.ts | 15 +++++++++++++++ .../project/runtimeProfile/rules/refusals.ts | 3 +++ 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index a42a79edc..20a3a40a8 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -648,6 +648,24 @@ describe("the additions rule", () => { }); }); + test("signs a table with no kind that adds to the CloudWatch target of a pack", () => { + const local = { telemetry: { logs: { include: ["deny"] } } }; + const telemetry = [ + { + name: "logs", + kind: "cloudwatch_logs", + region: "ap-south-1", + logGroup: "/team/agent", + logStream: "box", + } as const, + ]; + + // The pack gives the kind, the log group, and the log stream on the Runtime too. + expect(apply(local, contextOf(CODEZIP, { telemetry })).table.telemetry).toEqual({ + logs: { region: "ap-south-1", include: ["deny"], secret: { ref: "aws://" } }, + }); + }); + test("gives a target with no region the region of the box network model", () => { const local = { telemetry: { "x-ray": CLOUDWATCH["x-ray"] } }; const telemetry = [ diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index f3fc643bb..96c50dc09 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -359,13 +359,15 @@ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): u const resolved = new Map(context.telemetry.map((target) => [target.name, target])); const result: TomlTable = {}; for (const [name, entry] of Object.entries(local)) { - if (!isTable(entry) || !CLOUDWATCH_KINDS.has(entry.kind)) { + // A table with no kind adds to the CloudWatch target of that name that a pack gives. + const addsToPack = isTable(entry) && entry.kind === undefined && resolved.has(name); + if (!isTable(entry) || (!CLOUDWATCH_KINDS.has(entry.kind) && !addsToPack)) { result[name] = entry; continue; } const { kind, region, ...rest } = entry; result[name] = { - kind, + ...(kind !== undefined && { kind }), region: region ?? resolved.get(name)?.region ?? context.region, ...rest, secret: { ref: RUNTIME_AWS_SIGNER }, @@ -384,8 +386,9 @@ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): u secret: { ref: RUNTIME_AWS_SIGNER }, }; } - const logs = Object.values(result).some( - (entry) => isTable(entry) && entry.kind === "cloudwatch_logs", + const logs = Object.entries(result).some( + ([name, entry]) => + isTable(entry) && (entry.kind ?? resolved.get(name)?.kind) === "cloudwatch_logs", ); if (!logs) { const name = Object.hasOwn(result, "agentcore") ? "agentcore_default" : "agentcore"; diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index 8f976bf74..a6eab2db5 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -260,6 +260,21 @@ describe("the refusals rule", () => { }, ); + test("takes a [telemetry] table with no kind that adds to a CloudWatch target of a pack", () => { + const text = toml("[telemetry.logs]", 'include = ["deny"]'); + const resolved = { + name: "logs", + kind: "cloudwatch_logs" as const, + region: "us-west-2", + logGroup: "/team/agent", + logStream: "box", + }; + const context = { ...contextOf(text), telemetry: [resolved] }; + + expect(apply(parse(text) as TomlTable, context).problems).toEqual([]); + expect(problemsOf(text).map(({ code }) => code)).toEqual(["RUNTIME_TELEMETRY_NOT_CLOUDWATCH"]); + }); + test("stops for a [tool] program that box finds on PATH, on a CodeZip Runtime only", () => { const text = toml("[tool.jq]", 'program = "jq"'); diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index cfa60b052..72f47b7af 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -64,6 +64,9 @@ export function apply(table: Readonly, context: RuntimeProfileContext for (const [name, target] of Object.entries(telemetry)) { const kind = isTable(target) ? target.kind : undefined; if (typeof kind === "string" && RUNTIME_TELEMETRY_KINDS.has(kind)) continue; + // A table with no kind adds to the target of that name that a pack gives, which box resolves. + if (kind === undefined && context.telemetry.some((resolved) => resolved.name === name)) + continue; problem( "RUNTIME_TELEMETRY_NOT_CLOUDWATCH", ["telemetry", name, "kind"], From 42832149f445df9c220a76d991a7c4bf60bb6863 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:34:18 -0800 Subject: [PATCH 22/51] docs(box): Say where build stages the Runtime profile, and each stop of the derivation The guide said that build writes the Runtime profile in .box//aws/ and copies it into .box-dist/. [aws/agentcore-cli#2859](https://github.com/aws/agentcore-cli/pull/2859) changed this: build stages the profile, its policy files, and box in .box-dist/, and writes a copy of the profile, the generated packs, and the policy files into .box//aws/ for people to read. The list of the stops of the derivation did not have the stops that this PR adds. The guide now says where build stages the profile, lists each stop (the home paths, the program of the agent, and a write grant in the code folder), and says that the route of an entry with one host keeps the name of the entry. Tests: none; this changes only the guide. --- docs/box-local-testing.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index f39ce6023..44b8d6b45 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -116,8 +116,9 @@ printf '\n[egress.github]\ndestinations = ["api.github.com"]\nsecret.ref = "env: Build and deploy read each runtime's own `.box//local/profile.toml` and the policy files it lists under `policies`, and turn them into that runtime's Box network. They change nothing in -`.box//local/`; they generate the Runtime profile and its resources under -`.box//aws/`. +`.box//local/`. They stage the Runtime profile, its policy files, and box in the +`.box-dist/` folder of the code folder or of the build context, and write a copy of the profile, +the generated packs, and the policy files into `.box//aws/` for you to read. - **Gateway targets.** Each host or `host:port` that an `[egress]` entry or a policy permit names, and that the policy allows at least one request to, gets one passthrough target on @@ -132,8 +133,8 @@ it lists under `policies`, and turn them into that runtime's Box network. They c - **Warnings.** Build warns when Box enforces rules that the gateway does not (a path, method, or forbid), when an entry's host gets no target, and when a target is signed for an AWS service that no policy of the gateway's role grants. -- **The AgentCore Runtime profile.** Build derives `.box//aws/profile.toml`, copied into - `.box-dist/`, from the local profile. Each key of the local profile stays, and build changes +- **The AgentCore Runtime profile.** Build derives `.box-dist/profile.toml` from the local + profile. Each key of the local profile stays, and build changes only what must differ on AgentCore Runtime: - each `[egress]` host with a gateway target becomes one `[egress.]` route to `-box-egress`, and an HTTP `[mcp.]` server gets the same gateway backend; @@ -147,8 +148,11 @@ it lists under `policies`, and turn them into that runtime's Box network. They c records to the runtime's own log group. Build stops, and names the key and its line, for a value that cannot work on the Runtime: a path - of the project outside the code folder, a home path, a CodeZip program outside the code folder, - `network.contain_egress = false`, or a telemetry target that is not CloudWatch. Each policy file + of the project outside the code folder, a home path (`${{ home }}`, `~`, `/Users`, `/home`), a + CodeZip program of the agent, a stdio server, or a tool outside the code folder, a CodeZip write + grant in the code folder, `network.contain_egress = false`, or a telemetry target that is not + CloudWatch. The route of an `[egress]` entry with one host keeps the name of the entry, so a + pack's own entry of that name merges with it. Each policy file is copied beside the profile, byte for byte. - **No-auth targets need a newer L3.** A passthrough target with no outbound auth synthesizes From 3ba0bb6e38068ba09f2607d8231af98e8c7fa602 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 19:55:43 -0800 Subject: [PATCH 23/51] test(box): Compare each route destination for equality, so that CodeQL reads no URL substring check --- src/core/project/boxNetworkSource.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index 12f7e07ee..798596d8d 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -514,7 +514,7 @@ describe("two routes of one profile to one host", () => { ["api.example.com", "egress-a"], ]); const routes = Object.entries(network.runtimeProfile!.egress as Record).filter( - ([, route]) => route.destinations.includes("api.example.com"), + ([, route]) => (route.destinations as string[]).some((host) => host === "api.example.com"), ); expect(routes.map(([name, route]) => [name, route.destinations])).toEqual([ ["a", ["api.example.com"]], From 4d165cd9c530b27f6ef7133ac464ef0ffa787eff Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:41:32 -0800 Subject: [PATCH 24/51] fix(box): Stop build for a CloudWatch target that box refuses, and copy only the targets box takes The additions rule copied each cloudwatch_logs and cloudwatch_traces table of the local profile to the Runtime profile. cloudWatchTelemetry leaves out a target that box refuses when a run starts, for example a log_stream with ":" or an empty include, so the telemetry policy gave it no grant. Such a target also counted as a cloudwatch_logs target, so the default [telemetry.agentcore] did not come in. Build passed, and the run stopped when it started. The renderer that the derivation replaced copied only the targets that box takes. Leo found this in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). With this change: - The refusals rule stops build for a CloudWatch table of the local profile that is not in context.telemetry, the targets that box takes (RUNTIME_TELEMETRY_REFUSED). The message names the table and the values that box takes. Build stops and does not remove the table, because box refuses the same table under agentcore dev: the local profile cannot run, and a Runtime profile with no such target would hide that. - The additions rule copies only the CloudWatch tables that box takes. A table that box refuses does not reach the Runtime, and does not stop the default target. Tests: refusals.test.ts "stops for a CloudWatch target that box refuses when a run starts (RUNTIME_TELEMETRY_REFUSED)". additions.test.ts "copies no CloudWatch target that box refuses, as it grants it nothing, and adds the default target", the test of the old renderer that the wiring commit removed. The refusals tests now give the rule the targets that box takes from each profile, as build does. --- .../runtimeProfile/rules/additions.test.ts | 36 ++++++++++++++--- .../project/runtimeProfile/rules/additions.ts | 9 +++-- .../runtimeProfile/rules/refusals.test.ts | 40 ++++++++++++++++++- .../project/runtimeProfile/rules/refusals.ts | 16 +++++++- src/core/project/runtimeProfile/types.ts | 2 + 5 files changed, 93 insertions(+), 10 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 20a3a40a8..2ed85cbf4 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -130,6 +130,10 @@ const DEFAULT_TARGET = { secret: { ref: "aws://" }, }; +/** The CloudWatch targets that box takes from the local profile `local`, as build gives them. */ +const acceptedTelemetry = (local: TomlTable) => + withDeployRegion(cloudWatchTelemetry(local), BUILD_REGION, PROFILE_FILE).telemetry; + /** The [telemetry] of a local profile for each case: none, a target of each kind, traces only. */ const TELEMETRY_CASES: Record = { none: undefined, @@ -638,7 +642,9 @@ describe("the additions rule", () => { }, }; - expect(apply(local, contextOf(CODEZIP)).table.telemetry).toEqual({ + expect( + apply(local, contextOf(CODEZIP, { telemetry: acceptedTelemetry(local) })).table.telemetry, + ).toEqual({ logs: { ...(CLOUDWATCH.logs as TomlTable), batch: { max: 5 }, @@ -648,6 +654,20 @@ describe("the additions rule", () => { }); }); + test("copies no CloudWatch target that box refuses, as it grants it nothing, and adds the default target", () => { + const local = { + telemetry: { + logs: { ...(CLOUDWATCH.logs as TomlTable), log_stream: "a:b" }, + "x-ray": { ...(CLOUDWATCH["x-ray"] as TomlTable), include: [] }, + }, + }; + + expect(acceptedTelemetry(local)).toEqual([]); + expect( + apply(local, contextOf(CODEZIP, { telemetry: acceptedTelemetry(local) })).table.telemetry, + ).toEqual({ agentcore: DEFAULT_TARGET }); + }); + test("signs a table with no kind that adds to the CloudWatch target of a pack", () => { const local = { telemetry: { logs: { include: ["deny"] } } }; const telemetry = [ @@ -752,7 +772,9 @@ describe("the additions rule", () => { test("adds no default target when the profile has its own cloudwatch_logs target", () => { const local = { telemetry: { logs: CLOUDWATCH.logs } }; - expect(apply(local, contextOf(CONTAINER)).table.telemetry).toEqual({ + expect( + apply(local, contextOf(CONTAINER, { telemetry: acceptedTelemetry(local) })).table.telemetry, + ).toEqual({ logs: { ...(CLOUDWATCH.logs as TomlTable), secret: { ref: "aws://" } }, }); }); @@ -776,7 +798,9 @@ describe("the additions rule", () => { test("adds the default target beside a cloudwatch_traces target, as it sends no logs", () => { const local = { telemetry: { "x-ray": CLOUDWATCH["x-ray"] } }; - expect(apply(local, contextOf(CODEZIP)).table.telemetry).toEqual({ + expect( + apply(local, contextOf(CODEZIP, { telemetry: acceptedTelemetry(local) })).table.telemetry, + ).toEqual({ "x-ray": { kind: "cloudwatch_traces", region: BUILD_REGION, secret: { ref: "aws://" } }, agentcore: DEFAULT_TARGET, }); @@ -786,8 +810,9 @@ describe("the additions rule", () => { ["a CloudWatch target", CLOUDWATCH["x-ray"]], ["a third-party target", { kind: "langfuse", secret: { ref: "env://LANGFUSE_AUTH" } }], ])("names the default target agentcore_default when %s is agentcore", (_label, target) => { + const local = { telemetry: { agentcore: target } }; const telemetry = tableOf( - apply({ telemetry: { agentcore: target } }, contextOf(CODEZIP)).table, + apply(local, contextOf(CODEZIP, { telemetry: acceptedTelemetry(local) })).table, ); expect(Object.keys(telemetry)).toEqual(["agentcore", "agentcore_default"]); @@ -798,7 +823,8 @@ describe("the additions rule", () => { test("names the default target in the header, and no other target", () => { const context = contextOf(CODEZIP); const withDefault = apply({}, context).table; - const withOwn = apply({ telemetry: { logs: CLOUDWATCH.logs } }, context).table; + const own = { telemetry: { logs: CLOUDWATCH.logs } }; + const withOwn = apply(own, contextOf(CODEZIP, { telemetry: acceptedTelemetry(own) })).table; expect(runtimeProfileHeader(context, withDefault).at(-1)).toBe( "[telemetry.agentcore] is the default CloudWatch Logs target: the runtime's own log " + diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 96c50dc09..24fd45d61 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -12,7 +12,7 @@ * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | * | `[tool.]` | a table of the template becomes its Runtime table, or goes when the Runtime has none; a table of the user stays | - * | `[telemetry.]` | each CloudWatch target is signed with a bare `aws://`, in the deploy region when it names none | + * | `[telemetry.]` | each CloudWatch target that box takes is signed with a bare `aws://`, in the deploy region when it names none; one that box refuses goes | * | `[telemetry.agentcore]` | added when no target is `cloudwatch_logs`: the runtime's own log group and log stream | * * It moves no path: the paths rule runs after it and moves each path of the user. @@ -347,8 +347,9 @@ function onAllAddresses(entry: unknown): unknown { } /** - * `[telemetry]` for the Runtime: each CloudWatch target of the local profile with its keys, signed - * with a bare `aws://`, in the deploy region when it names none; then each CloudWatch target of the + * `[telemetry]` for the Runtime: each CloudWatch target of the local profile that box takes (the + * names of `context.telemetry`) with its keys, signed with a bare `aws://`, in the deploy region + * when it names none; one that box refuses goes; then each CloudWatch target of the * context that the local profile does not declare, as box resolves it. A target of another kind * stays as it is. With no `cloudwatch_logs` target, {@link DEFAULT_TELEMETRY_TARGET} comes last, as * `agentcore`, or as `agentcore_default` when a target has that name. @@ -365,6 +366,8 @@ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): u result[name] = entry; continue; } + // A CloudWatch target that box refuses gets no grant, and the refusals rule stops build for it. + if (!resolved.has(name)) continue; const { kind, region, ...rest } = entry; result[name] = { ...(kind !== undefined && { kind }), diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index a6eab2db5..5c9a83c4b 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -2,6 +2,7 @@ import { describe, expect, test } from "bun:test"; import { parse } from "smol-toml"; import type { ProjectSpec } from "../../../../projectSchemas/project"; import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; +import { cloudWatchTelemetry, withDeployRegion } from "../../boxNetwork"; import { profileKeyPlaces, runtimeProfileContext } from "../context"; import { deriveRuntimeProfile } from "../derive"; import type { RuntimeProfileProblem, TomlTable } from "../types"; @@ -19,6 +20,7 @@ const CODEZIP = { const CONTAINER = { ...CODEZIP, build: "Container", entrypoint: "main.py" } as ProjectRuntime; const PROFILE = ".box/agent/local/profile.toml"; +/** The context of the local profile `text`, with the CloudWatch targets that box takes from it. */ const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => runtimeProfileContext({ spec: { name: "demo", runtimes: [runtime] } as unknown as ProjectSpec, @@ -27,7 +29,8 @@ const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => region: "us-west-2", gateway: { name: "agent-box-egress", targets: [] }, hosts: [], - telemetry: [], + telemetry: withDeployRegion(cloudWatchTelemetry(parse(text) as TomlTable), "us-west-2", PROFILE) + .telemetry, policyFiles: [], places: profileKeyPlaces(text, PROFILE), }); @@ -260,6 +263,41 @@ describe("the refusals rule", () => { }, ); + test("stops for a CloudWatch target that box refuses when a run starts (RUNTIME_TELEMETRY_REFUSED)", () => { + const text = toml( + "[telemetry.logs]", + 'kind = "cloudwatch_logs"', + 'log_group = "/demo/agent"', + 'log_stream = "a:b"', + "[telemetry.traces]", + 'kind = "cloudwatch_traces"', + "include = []", + "[telemetry.kept]", + 'kind = "cloudwatch_traces"', + ); + const reason = (name: string) => + `[telemetry] ${name} is a CloudWatch target that box refuses when a run starts, under \`agentcore ` + + "dev` and on AgentCore Runtime. Give it a region of lower-case letters, digits, and -, and " + + "an include of one or more different words of deny, permit, trace, logs, and metrics. For " + + "cloudwatch_logs, give it a log_group of letters, digits, and . _ - / #, and a log_stream " + + "with no : or *."; + + expect(problemsOf(text)).toEqual([ + { + code: "RUNTIME_TELEMETRY_REFUSED", + key: ["telemetry", "logs"], + reason: reason("logs"), + place: `${PROFILE}:1:1`, + }, + { + code: "RUNTIME_TELEMETRY_REFUSED", + key: ["telemetry", "traces"], + reason: reason("traces"), + place: `${PROFILE}:5:1`, + }, + ]); + }); + test("takes a [telemetry] table with no kind that adds to a CloudWatch target of a pack", () => { const text = toml("[telemetry.logs]", 'include = ["deny"]'); const resolved = { diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index 72f47b7af..f53f73397 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -7,6 +7,7 @@ * | --- | --- | * | `network.contain_egress = false` on `[agent]`, a stdio `[mcp.]`, or a `[tool.]` | RUNTIME_EGRESS_NOT_CONTAINED | * | a `[telemetry.]` that is not `cloudwatch_logs` or `cloudwatch_traces` | RUNTIME_TELEMETRY_NOT_CLOUDWATCH | + * | a CloudWatch `[telemetry.]` that box refuses when a run starts, so it is not in `context.telemetry` | RUNTIME_TELEMETRY_REFUSED | * | CodeZip: a path of the project outside the code folder, of the home folder (`${{ home }}`, `~`, `/Users`, `/home`), or in the venv | RUNTIME_PATH_NOT_FOUND | * | CodeZip: an `[agent]`, stdio server, or tool program that is not the venv's Python or a file in the code folder | RUNTIME_PROGRAM_NOT_FOUND | * | CodeZip: a `write` or `write_file` grant in the code folder, which the agent runs files from on the Runtime | RUNTIME_WRITE_IN_CODE | @@ -63,7 +64,20 @@ export function apply(table: Readonly, context: RuntimeProfileContext const telemetry = isTable(table.telemetry) ? table.telemetry : {}; for (const [name, target] of Object.entries(telemetry)) { const kind = isTable(target) ? target.kind : undefined; - if (typeof kind === "string" && RUNTIME_TELEMETRY_KINDS.has(kind)) continue; + if (typeof kind === "string" && RUNTIME_TELEMETRY_KINDS.has(kind)) { + // context.telemetry holds each CloudWatch target that box takes (cloudWatchTelemetry). + if (context.telemetry.some((resolved) => resolved.name === name)) continue; + problem( + "RUNTIME_TELEMETRY_REFUSED", + ["telemetry", name], + "is a CloudWatch target that box refuses when a run starts, under `agentcore dev` and " + + "on AgentCore Runtime. Give it a region of lower-case letters, digits, and -, and an " + + "include of one or more different words of deny, permit, trace, logs, and metrics. " + + "For cloudwatch_logs, give it a log_group of letters, digits, and . _ - / #, and a " + + "log_stream with no : or *.", + ); + continue; + } // A table with no kind adds to the target of that name that a pack gives, which box resolves. if (kind === undefined && context.telemetry.some((resolved) => resolved.name === name)) continue; diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts index 0147b78f4..ab882f2a7 100644 --- a/src/core/project/runtimeProfile/types.ts +++ b/src/core/project/runtimeProfile/types.ts @@ -86,6 +86,8 @@ export const RUNTIME_PROFILE_PROBLEM_CODES = [ "RUNTIME_EGRESS_NOT_CONTAINED", /** A telemetry target that is not CloudWatch, which the Runtime cannot send to yet. */ "RUNTIME_TELEMETRY_NOT_CLOUDWATCH", + /** A CloudWatch telemetry target that box refuses when a run starts. */ + "RUNTIME_TELEMETRY_REFUSED", ] as const; export type RuntimeProfileProblemCode = (typeof RUNTIME_PROFILE_PROBLEM_CODES)[number]; From afe56a6eb681d2f3672eb25930464e2d42eb28dc Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:42:29 -0800 Subject: [PATCH 25/51] docs(box): Make four comments and one message say what the code does From the review of Leo on [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866): - The table of the gateway rule said that each [egress.] becomes [egress.]. Since 737e1079, an entry with one host keeps its name. The table now gives the two cases. - inProfileOrder removes problems by code, key, and reason, not by place. Its comment now says "each identical problem once". - The comment of applyBoxNetwork said that staging renders the routes from the targets of the Box gateway. Staging writes the profile that each model derives, BoxNetwork.runtimeProfile. - The message of the runtime profile writer said only "found no Box network". It also comes when a network has no derived profile, so it now says that too. Tests: boxNetworkWriters.test.ts passes; no test reads the changed part of the message. --- src/core/project/boxNetworkWriters.ts | 3 ++- src/core/project/manager.tsx | 9 +++++---- src/core/project/runtimeProfile/rules/gateway.ts | 3 ++- src/core/project/runtimeProfile/rules/refusals.ts | 2 +- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/core/project/boxNetworkWriters.ts b/src/core/project/boxNetworkWriters.ts index e54847a36..90c433d92 100644 --- a/src/core/project/boxNetworkWriters.ts +++ b/src/core/project/boxNetworkWriters.ts @@ -430,7 +430,8 @@ function runtimeProfileText(runtime: string, network: BoxNetwork | undefined): s throw new ProjectStateError( `runtime "${runtime}" runs its agent in a box, but build has no AgentCore Runtime profile ` + `for it: it derives that profile from ${boxLocalProfileFile(runtime)}, and found no ` + - "Box network for the runtime. Check that its Box gateway is in agentcore.json, then retry.", + "Box network for the runtime, or a Box network with no derived profile. Check that its " + + "Box gateway is in agentcore.json and that the profile is there, then retry.", ); } return serializeRuntimeProfile(network.runtimeProfile, network.runtimeProfileHeader); diff --git a/src/core/project/manager.tsx b/src/core/project/manager.tsx index 4b074b62b..34ce24a88 100644 --- a/src/core/project/manager.tsx +++ b/src/core/project/manager.tsx @@ -1642,10 +1642,11 @@ export class FsProjectManager implements ProjectManager { /** * Builds the Box network model of each box runtime from the box profile as Box resolves it * (`box profile show --format json --full`) for `region`, then writes what the Box network - * writers derive from it, before synth reads agentcore.json and staging renders each Runtime - * profile's routes from its Box gateway's targets: agentcore.json once, patched in the raw file - * so unknown fields and key order survive and checked against the schema first, then the files, - * then `.env.local`. A failure of any model stops `command` before anything is written. + * writers derive from it, before synth reads agentcore.json and staging writes the Runtime + * profile that each model derives (`BoxNetwork.runtimeProfile`): agentcore.json once, patched in + * the raw file so unknown fields and key order survive and checked against the schema first, + * then the files, then `.env.local`. A failure of any model stops `command` before anything is + * written. */ private async applyBoxNetwork( project: Project, diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index 4e5c7bcbc..857eedd62 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -8,7 +8,8 @@ * * | Local profile | Runtime profile | * | --- | --- | - * | `[egress.]`, for each of its hosts with a target | `[egress.]`, the other keys kept, no `secret` | + * | `[egress.]` with one host that has a target | `[egress.]`, the other keys kept, no `secret`, a backend to its target | + * | `[egress.]` with several hosts, or whose name a target of another host has | `[egress.]` for each host with a target, the other keys kept, no `secret` | * | HTTP `[mcp.]` | `[mcp.]`, the other keys kept, only an `env://` secret | * | a target that no entry of the profile names | `[egress.]`, or the `[mcp]` server it serves | * | an entry whose hosts the policy denies | removed; the Box network model warns for it | diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index f53f73397..4c578f5f5 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -178,7 +178,7 @@ function notFound(program: string, paths: RuntimeProfileContext["paths"]): strin ); } -/** `problems` in the order of their places in the profile, and each problem of one place once. */ +/** `problems` in the order of their places in the profile, and each identical problem once. */ function inProfileOrder(problems: readonly RuntimeProfileProblem[]): RuntimeProfileProblem[] { const position = ({ place }: RuntimeProfileProblem) => { const match = /:(\d+):(\d+)$/.exec(place); From 797ed4bff4c65910bbc4ac62d70b8a4301696419 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:43:37 -0800 Subject: [PATCH 26/51] refactor(box): Give the rules one isTable and one RUNTIME_AWS_SIGNER The gateway rule and the additions rule each had their own isTable, and only the one of the additions rule left out a date. The two rules also each had RUNTIME_AWS_SIGNER. Leo found this in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). The three rules now use isTable of projectPaths.ts, which takes only a plain table, so a TomlDate is not a table. RUNTIME_AWS_SIGNER is in types.ts, beside RUNTIME_INPUTS. The behaviour does not change. Tests: the runtimeProfile and boxNetwork tests pass (414). --- src/core/project/runtimeProfile/rules/additions.ts | 8 ++------ src/core/project/runtimeProfile/rules/gateway.ts | 8 ++------ src/core/project/runtimeProfile/types.ts | 6 ++++++ 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 24fd45d61..258fa7051 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -23,16 +23,15 @@ import { BOX_BEDROCK_PACK, BOX_CODEZIP_DIST, } from "../../templates/boxProfile"; +import { isTable } from "../projectPaths"; import { + RUNTIME_AWS_SIGNER, RUNTIME_INPUTS, type RuleResult, type RuntimeProfileContext, type TomlTable, } from "../types"; -/** The credential that signs an AWS call on AgentCore Runtime: the execution role. */ -export const RUNTIME_AWS_SIGNER = "aws://"; - /** The variable that tells the template's agent that it runs under `agentcore dev`. */ const LOCAL_DEV = "LOCAL_DEV"; @@ -400,9 +399,6 @@ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): u return result; } -const isTable = (value: unknown): value is TomlTable => - typeof value === "object" && value !== null && !Array.isArray(value) && !(value instanceof Date); - /** `value` when it is a table, or an empty table. */ const tableOf = (value: unknown): TomlTable => (isTable(value) ? value : {}); diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index 857eedd62..a4dccf5ed 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -22,16 +22,15 @@ import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway" import type { BoxHostSource, BoxNetworkHost } from "../../boxNetwork"; import { BOX_EGRESS_TARGET_PREFIX } from "../../boxNetwork/egress"; import { gatewayTargetFor } from "../../boxNetwork/projectSpec"; +import { isTable } from "../projectPaths"; import { + RUNTIME_AWS_SIGNER, RUNTIME_INPUTS, type RuleResult, type RuntimeProfileContext, type TomlTable, } from "../types"; -/** The signer of each gateway backend: the AWS default credential chain, the execution role. */ -const RUNTIME_AWS_SIGNER = "aws://"; - type McpSource = Extract; /** One route of the Runtime profile: a passthrough target of the Box gateway and its host. */ @@ -43,9 +42,6 @@ interface GatewayRoute { readonly server?: McpSource; } -const isTable = (value: unknown): value is TomlTable => - typeof value === "object" && value !== null && !Array.isArray(value); - export function apply(table: Readonly, context: RuntimeProfileContext): RuleResult { const routes = gatewayRoutes(context); const written = new Set(); diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts index ab882f2a7..616da997b 100644 --- a/src/core/project/runtimeProfile/types.ts +++ b/src/core/project/runtimeProfile/types.ts @@ -11,6 +11,12 @@ import type { BoxNetworkHost, CloudWatchTelemetry } from "../boxNetwork"; /** A TOML table as smol-toml parses it: a key holds a string, a number, a boolean, a list, or a table. */ export type TomlTable = Record; +/** + * The credential that signs an AWS call on AgentCore Runtime, a gateway backend and a CloudWatch + * target: the AWS default credential chain, which is the execution role there. + */ +export const RUNTIME_AWS_SIGNER = "aws://"; + /** The inputs that the generated packs fill in on AgentCore Runtime, as a profile names them. */ export const RUNTIME_INPUTS = { /** The runtime's Box gateway URL (@box/agentcore). */ From 5d2eb4afe3281a2320c17d2cd6847eeb4f53756c Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:43:53 -0800 Subject: [PATCH 27/51] test(box): Skip the start.py tests on Windows boxStartPy.test.ts makes symbolic links, sets file modes, and writes #!/bin/sh files, and then runs python3. On Windows the tests skip only because python3 is not on PATH there. A runner with python3 can fail with EPERM on symlinkSync. Leo found this in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). Each test that uses these files now skips when python3 is not on PATH or the platform is win32. Tests: boxStartPy.test.ts passes on macOS (5). --- src/core/project/templates/boxStartPy.test.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/project/templates/boxStartPy.test.ts b/src/core/project/templates/boxStartPy.test.ts index 951cfb432..7abc61fd1 100644 --- a/src/core/project/templates/boxStartPy.test.ts +++ b/src/core/project/templates/boxStartPy.test.ts @@ -18,6 +18,9 @@ const START_PY = join(import.meta.dir, "..", "..", "..", "assets", "templates", const hasPython = spawnSync("python3", ["--version"]).status === 0; +/** The tests make symbolic links and `#!/bin/sh` files, which Windows does not run. */ +const skipped = !hasPython || process.platform === "win32"; + const directories: string[] = []; afterEach(() => { for (const directory of directories.splice(0)) @@ -66,19 +69,19 @@ describe("start.py BOX_PYTHON", () => { expect(text).toContain('"BOX_PYTHON": box_python(sys.executable, sys.version_info),'); }); - test.skipIf(!hasPython)("keeps a Python whose name box does not alias", () => { + test.skipIf(skipped)("keeps a Python whose name box does not alias", () => { const bin = binFolder(["python3.12"]); expect(boxPython(join(bin, "python3.12"))).toBe(join(bin, "python3.12")); }); - test.skipIf(!hasPython)("names python3 by the versioned file beside it", () => { + test.skipIf(skipped)("names python3 by the versioned file beside it", () => { const bin = binFolder(["python3", "python3.12"]); expect(boxPython(join(bin, "python3"))).toBe(join(bin, "python3.12")); }); - test.skipIf(!hasPython)( + test.skipIf(skipped)( "names python by the file it links to when no versioned file is beside it", () => { const bin = binFolder(["python3.12-real"], [["python", "python3.12-real"]]); @@ -88,7 +91,7 @@ describe("start.py BOX_PYTHON", () => { }, ); - test.skipIf(!hasPython)("keeps an aliased name when nothing else names that Python", () => { + test.skipIf(skipped)("keeps an aliased name when nothing else names that Python", () => { const bin = binFolder(["python3"]); expect(boxPython(join(bin, "python3"))).toBe(join(bin, "python3")); From 981588abb7727d8db730e396d313367969c9af4b Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:52:43 -0800 Subject: [PATCH 28/51] feat(box): Tell the user what the default log target sends, and let the runtime turn it off When the derived Runtime profile has no cloudwatch_logs target, build adds [telemetry.agentcore]: box sends its deny, permit, and trace records to the log group of the runtime. No command said so, no document said what it costs or how long the records stay, and the user could not turn it off without a cloudwatch_logs target of their own. The pre-review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this, and Leo asked the guide to say that the target needs OTEL_EXPORTER_OTLP_LOGS_HEADERS. With this change: - agentcore create and agentcore add runtime give a notice for each box runtime: what box sends, the log group /aws/bedrock-agentcore/runtimes/-DEFAULT and the stream otel-rt-logs, that the log group is the Runtime's and stays after the runtime is removed, that CloudWatch Logs charges for the records, and how to send none. add runtime gives it after agentcore.json is written, so a failed write gives no notice. - The Runtime profile gets no default target when the envVars of the runtime set DISABLE_ADOT_OBSERVABILITY to "true". This is the switch that the CLI already documents to turn off observability. The switch is not instrumentation.enableOtel: each box template writes enableOtel = false (aws/agentcore-cli#2862), because the agent in a box does not run under opentelemetry-instrument, and that says nothing about the records of box. - The guide says what the target sends, that box does not start when the Runtime does not set OTEL_EXPORTER_OTLP_LOGS_HEADERS, the retention and the cost, and the two ways to change it. Tests: additions.test.ts "adds the default target only when the envVars do not set DISABLE_ADOT_OBSERVABILITY to true" (3 values). manager.test.ts "writes the box profile into the agent's .box//local folder" checks the notice of create. manager.box.test.ts "add runtime gives the new runtime a box, its Box gateway, and its own box profile" checks that the notice comes after the write of agentcore.json, and "a failed write of agentcore.json gives no notice of the default log target". --- docs/box-local-testing.md | 14 ++++++- src/core/project/manager.box.test.ts | 41 +++++++++++++++++++ src/core/project/manager.test.ts | 5 +++ src/core/project/manager.tsx | 27 ++++++++++++ .../runtimeProfile/rules/additions.test.ts | 18 ++++++++ .../project/runtimeProfile/rules/additions.ts | 34 ++++++++++++++- 6 files changed, 135 insertions(+), 4 deletions(-) diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index 44b8d6b45..2b3c8deb9 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -144,8 +144,18 @@ the generated packs, and the policy files into `.box//aws/` for you to the Runtime's Python, in every table: the agent, each stdio `[mcp.]` server, each `[tool.]`; - the `@box/agentcore` packs, the project name, and the build region come in, and each CloudWatch - target signs with the execution role. With no `cloudwatch_logs` target, the box sends its - records to the runtime's own log group. + target signs with the execution role. + + **The default log target.** With no `cloudwatch_logs` target, the Runtime profile gets + `[telemetry.agentcore]`: box sends its deny, permit, and trace records to the log group of the + runtime, `/aws/bedrock-agentcore/runtimes/-DEFAULT`, log stream `otel-rt-logs`. box + reads these two names from `OTEL_EXPORTER_OTLP_LOGS_HEADERS`, which the Runtime sets. If the + Runtime does not set it, box does not start. The Runtime makes that log group, so its retention + applies, and it stays after you remove the runtime. CloudWatch Logs charges for the records it + gets. To send none, set `DISABLE_ADOT_OBSERVABILITY` to `"true"` in the `envVars` of the runtime + in `agentcore.json`. To send them to another log group, add a `cloudwatch_logs` target to the + local profile. `agentcore create` and `agentcore add runtime` give this notice for each box + runtime. Build stops, and names the key and its line, for a value that cannot work on the Runtime: a path of the project outside the code folder, a home path (`${{ home }}`, `~`, `/Users`, `/home`), a diff --git a/src/core/project/manager.box.test.ts b/src/core/project/manager.box.test.ts index 663a0400e..d0ffbb9f1 100644 --- a/src/core/project/manager.box.test.ts +++ b/src/core/project/manager.box.test.ts @@ -10,6 +10,7 @@ import { createSilentLogger, TestIdentityClient } from "../../testing"; import { BOX_RELEASE } from "./backends/boxRelease"; import { FsProjectManager } from "./manager"; import { newProjectSpec } from "./templates/project"; +import { defaultLogTargetNotice } from "./runtimeProfile/rules/additions"; import { boxGatewaySpec, ProjectSpecSchema } from "../../projectSchemas/project"; /** @@ -347,6 +348,18 @@ describe("gateway targets in a Box project", () => { expect(events).toContainEqual({ type: "step", message: `writing box profile ${profile}` }); expect(existsSync(join(project.rootPath, "app", "search", "start.py"))).toBe(true); expect(existsSync(join(project.rootPath, "app", "search", ".venv"))).toBe(true); + // The notice of the default log target comes after agentcore.json is written. + const notice = { + type: "warning", + message: defaultLogTargetNotice("search", ".box/search/local/profile.toml"), + }; + const written = events.findIndex((event) => + (event as { message?: string }).message?.startsWith("updating project spec file"), + ); + expect( + events.indexOf(events.find((event) => JSON.stringify(event) === JSON.stringify(notice))), + ).toBeGreaterThan(written); + expect(events).toContainEqual(notice); // The first runtime keeps its own profile folder and gateway. expect(spec.agentCoreGateways.map(({ boundRuntime }) => boundRuntime)).toEqual([ "agent", @@ -544,6 +557,34 @@ describe("gateway targets in a Box project", () => { expect(await readFile(blocked, "utf8")).toBe("not a folder\n"); }); + test("a failed write of agentcore.json gives no notice of the default log target", async () => { + const manager = subject(); + const project = await createdProject(manager); + const agentcore = join(project.rootPath, "agentcore"); + const specFile = join(agentcore, "agentcore.json"); + await chmod(specFile, 0o444); + await chmod(agentcore, 0o555); + const events: unknown[] = []; + try { + const generator = manager.addResource(project, { + resourceType: "runtime", + resourceConfig: { name: "search", language: "Python", protocol: "HTTP" }, + } as never); + await expect( + (async () => { + for (let next = await generator.next(); !next.done; next = await generator.next()) { + events.push(next.value); + } + })(), + ).rejects.toThrow(); + } finally { + await chmod(agentcore, 0o755); + await chmod(specFile, 0o644); + } + + expect(events.some((event) => (event as { type?: string }).type === "warning")).toBe(false); + }); + test("add runtime warns when the kept box profile is for another protocol", async () => { const manager = subject(); let project = await createdProject(manager, ["agent", "search"]); diff --git a/src/core/project/manager.test.ts b/src/core/project/manager.test.ts index cf41804a7..99f66dc18 100644 --- a/src/core/project/manager.test.ts +++ b/src/core/project/manager.test.ts @@ -47,6 +47,7 @@ import { } from "../../handlers/project/types"; import { createSilentLogger, TestIdentityClient } from "../../testing"; import { boxLocalProfileFile, boxProfileWarnings, renderBoxProfile } from "./templates/boxProfile"; +import { defaultLogTargetNotice } from "./runtimeProfile/rules/additions"; import type { DeployBackendInput, ProjectBackend } from "./backends/types"; import { BOX_INSTALL_HINT, BOX_RELEASE } from "./backends/boxRelease"; import { MissingToolError } from "../../io/exec"; @@ -853,6 +854,10 @@ describe("FsProjectManager.create box profile", () => { renderBoxProfile("example", AGENT_PYTHON_STRANDS_BOX, "eu-west-1")!, ); expect(events).toContainEqual({ type: "step", message: `writing box profile ${path}` }); + expect(events).toContainEqual({ + type: "warning", + message: defaultLogTargetNotice(AGENT_PYTHON_STRANDS_BOX.runtimeName, BOX_PROFILE_FILE), + }); }, ); diff --git a/src/core/project/manager.tsx b/src/core/project/manager.tsx index 34ce24a88..34e7034bc 100644 --- a/src/core/project/manager.tsx +++ b/src/core/project/manager.tsx @@ -64,13 +64,16 @@ import { BOX_CODEZIP_ENTRYPOINT, boxAgentDir, boxAwsDir, + boxLocalProfileFile, boxLocalProfilePath, boxProfileWarnings, boxUvSyncEnv, hasBoxProfile, renderBoxProfile, + runsInBox, startsInBoxOnCodeZip, } from "./templates/boxProfile"; +import { defaultLogTargetNotice, observabilityOff } from "./runtimeProfile/rules/additions"; import { validateBoxRuntimes } from "./boxValidation"; import { BOX_INSTALL_HINT, BOX_RELEASE } from "./backends/boxRelease"; import { getRuntimeTemplateResolver } from "./templates/runtime"; @@ -628,6 +631,7 @@ export class FsProjectManager implements ProjectManager { `the project scaffolded at ${destination} could not be read back`, ); } + yield* defaultLogTargetNotices(project.spec, project.spec.runtimes); return project; } @@ -1088,6 +1092,13 @@ export class FsProjectManager implements ProjectManager { ]); throw err; } + // After the write, so a failed write gives no notice for a runtime that was not written. + if (input.resourceType === "runtime") { + yield* defaultLogTargetNotices( + newProjectSpec, + newProjectSpec.runtimes.filter(({ name }) => name === input.resourceConfig.name), + ); + } return { ...project, @@ -2384,6 +2395,22 @@ function ingressPort(text: string): string | undefined { * Refuses to export a harness as a runtime into a Box project. Every runtime of a Box project runs * in a box, and the exported harness runs its agent the usual way. */ +/** + * The notice of the default log target (defaultLogTargetNotice) for each runtime of `runtimes` that + * runs in a box in `spec`, and that does not turn observability off. + */ +function defaultLogTargetNotices( + spec: z.infer, + runtimes: readonly z.infer["runtimes"][number][], +): ProjectEvent[] { + return runtimes + .filter((runtime) => runsInBox(isBoxProject(spec), runtime) && !observabilityOff(runtime)) + .map((runtime) => ({ + type: "warning", + message: defaultLogTargetNotice(runtime.name, boxLocalProfileFile(runtime.name)), + })); +} + function assertNotBoxProject(spec: z.infer, what: string): void { if (!isBoxProject(spec)) return; throw new ProjectStateError( diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 2ed85cbf4..bad0cd427 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -795,6 +795,24 @@ describe("the additions rule", () => { ]); }); + test.each([ + ["true", false], + [" TRUE ", false], + ["false", true], + ])( + "adds the default target only when the envVars do not set DISABLE_ADOT_OBSERVABILITY to true (%j)", + (value, added) => { + const runtime = { + ...CODEZIP, + envVars: [{ name: "DISABLE_ADOT_OBSERVABILITY", value }], + } as ProjectRuntime; + + expect(Object.hasOwn(tableOf(apply({}, contextOf(runtime)).table), "agentcore")).toBe( + added, + ); + }, + ); + test("adds the default target beside a cloudwatch_traces target, as it sends no logs", () => { const local = { telemetry: { "x-ray": CLOUDWATCH["x-ray"] } }; diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 258fa7051..43d952fc9 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -23,6 +23,7 @@ import { BOX_BEDROCK_PACK, BOX_CODEZIP_DIST, } from "../../templates/boxProfile"; +import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; import { isTable } from "../projectPaths"; import { RUNTIME_AWS_SIGNER, @@ -80,6 +81,34 @@ export function runtimeRegionEnv(bedrock: boolean): Record { return { ...(!bedrock && { AWS_REGION: region }), AWS_DEFAULT_REGION: region }; } +/** + * The variable that turns off the observability of a runtime on AgentCore Runtime. When the envVars + * of the runtime set it to `true`, the Runtime profile gets no default log target. + */ +export const OBSERVABILITY_OFF_ENV = "DISABLE_ADOT_OBSERVABILITY"; + +/** Whether the envVars of `runtime` set {@link OBSERVABILITY_OFF_ENV} to `true`. */ +export function observabilityOff(runtime: Pick): boolean { + return (runtime.envVars ?? []).some( + ({ name, value }) => name === OBSERVABILITY_OFF_ENV && value.trim().toLowerCase() === "true", + ); +} + +/** + * The notice that `agentcore create` and `agentcore add runtime` give for a box runtime: what the + * default log target sends, where, what it costs, and how to turn it off. + */ +export function defaultLogTargetNotice(runtimeName: string, profileFile: string): string { + return ( + `runtime "${runtimeName}": when ${profileFile} has no cloudwatch_logs target, box on ` + + "AgentCore Runtime sends its deny, permit, and trace records to the log group of the " + + "runtime, /aws/bedrock-agentcore/runtimes/-DEFAULT, log stream otel-rt-logs. The " + + "Runtime makes that log group, so its retention applies, and the log group stays after the " + + "runtime is removed. CloudWatch Logs charges for the records. To send none, set " + + `${OBSERVABILITY_OFF_ENV} to "true" in the envVars of the runtime in agentcore.json.` + ); +} + /** The comment lines above `profile`, the Runtime profile of `context.runtime`. */ export function runtimeProfileHeader( context: RuntimeProfileContext, @@ -351,7 +380,8 @@ function onAllAddresses(entry: unknown): unknown { * when it names none; one that box refuses goes; then each CloudWatch target of the * context that the local profile does not declare, as box resolves it. A target of another kind * stays as it is. With no `cloudwatch_logs` target, {@link DEFAULT_TELEMETRY_TARGET} comes last, as - * `agentcore`, or as `agentcore_default` when a target has that name. + * `agentcore`, or as `agentcore_default` when a target has that name, unless the envVars of the + * runtime turn observability off ({@link OBSERVABILITY_OFF_ENV}). */ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): unknown { if (telemetry !== undefined && !isTable(telemetry)) return telemetry; @@ -392,7 +422,7 @@ function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): u ([name, entry]) => isTable(entry) && (entry.kind ?? resolved.get(name)?.kind) === "cloudwatch_logs", ); - if (!logs) { + if (!logs && !observabilityOff(context.runtime)) { const name = Object.hasOwn(result, "agentcore") ? "agentcore_default" : "agentcore"; result[name] = structuredClone(DEFAULT_TELEMETRY_TARGET); } From dc1938e19bf0c1908bb95d6abac39441e4f2acba Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:54:34 -0800 Subject: [PATCH 29/51] fix(box): Stage no Runtime route to a target that build does not write When a host sends an API key and agentcore.json holds no credential for it, the gateway targets writer writes no target for the host and says so. The derived Runtime profile still had a route to that target, so the calls of the agent to the host went to a target that is not on the gateway. The renderer that the derivation replaced made the routes from the targets that build wrote, so it gave that host no route. The pre-review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this. The derivation runs before the writers, so it cannot know which credential the credentials writer adds. With this change, the runtime profile writer removes from the derived profile each [egress] route and each [mcp] server whose backend goes to the target of such a host. It uses undeclaredKey, the same test that the gateway targets writer uses. Tests: manager.boxNetwork.test.ts "writes no target for an env:// route whose key build cannot find, and says what to set" now also checks that the staged Runtime profile has no route to api.github.com. --- src/core/project/boxNetworkWriters.ts | 50 +++++++++++++++++++-- src/core/project/manager.boxNetwork.test.ts | 6 +++ 2 files changed, 53 insertions(+), 3 deletions(-) diff --git a/src/core/project/boxNetworkWriters.ts b/src/core/project/boxNetworkWriters.ts index 90c433d92..8e99318ce 100644 --- a/src/core/project/boxNetworkWriters.ts +++ b/src/core/project/boxNetworkWriters.ts @@ -42,7 +42,9 @@ import { renderAgentCoreCodeZipPack, renderAgentCorePack, } from "./templates/boxProfile"; +import { isTable } from "./runtimeProfile/projectPaths"; import { serializeRuntimeProfile } from "./runtimeProfile/serialize"; +import { RUNTIME_INPUTS, type TomlTable } from "./runtimeProfile/types"; import { ProjectStateError } from "../../errors/errors"; /** Something exactly one writer owns. */ @@ -401,7 +403,7 @@ export function runtimeProfileWriter(staged: readonly StagedRuntime[]): BoxNetwo files: staged.flatMap(({ runtime, dist, kind }) => { const network = networkOf(networks, runtime); return [ - { path: `${dist}/profile.toml`, text: runtimeProfileText(runtime, network) }, + { path: `${dist}/profile.toml`, text: runtimeProfileText(runtime, network, spec) }, { path: `${dist}/${AGENTCORE_PACK_PATH}`, text: renderAgentCorePack(spec) }, ...(kind === "codezip" ? [ @@ -425,7 +427,11 @@ export function runtimeProfileWriter(staged: readonly StagedRuntime[]): BoxNetwo * The text of the AgentCore Runtime profile of `runtime`, which build derived from its local box * profile into the Box network model (`BoxNetwork.runtimeProfile`). */ -function runtimeProfileText(runtime: string, network: BoxNetwork | undefined): string { +function runtimeProfileText( + runtime: string, + network: BoxNetwork | undefined, + spec: ProjectSpec, +): string { if (network?.runtimeProfile === undefined) { throw new ProjectStateError( `runtime "${runtime}" runs its agent in a box, but build has no AgentCore Runtime profile ` + @@ -434,7 +440,45 @@ function runtimeProfileText(runtime: string, network: BoxNetwork | undefined): s "Box gateway is in agentcore.json and that the profile is there, then retry.", ); } - return serializeRuntimeProfile(network.runtimeProfile, network.runtimeProfileHeader); + return serializeRuntimeProfile( + withoutUnsentRoutes(network.runtimeProfile, network, spec), + network.runtimeProfileHeader, + ); +} + +/** + * `profile` with no `[egress]` route and no `[mcp]` server to the target of a host that sends an + * API key that agentcore.json holds no credential for: the gateway targets writer writes no such + * target (writeGatewayTargets), and says so. + */ +function withoutUnsentRoutes( + profile: Readonly, + network: BoxNetwork, + spec: ProjectSpec, +): TomlTable { + const unsent = new Set( + network.hosts.flatMap((host) => + host.target !== undefined && undeclaredKey(spec, host) !== undefined + ? [`${RUNTIME_INPUTS.gatewayUrl}/${host.target}`] + : [], + ), + ); + const result: TomlTable = { ...profile }; + if (unsent.size === 0) return result; + const routesToUnsent = (entry: unknown) => + isTable(entry) && + Array.isArray(entry.backends) && + entry.backends.some((backend) => isTable(backend) && unsent.has(backend.url as string)); + for (const key of ["egress", "mcp"]) { + const table = profile[key]; + if (!isTable(table)) continue; + const kept = Object.fromEntries( + Object.entries(table).filter(([, entry]) => !routesToUnsent(entry)), + ); + if (Object.keys(kept).length > 0) result[key] = kept; + else delete result[key]; + } + return result; } /** The writers that build and deploy run before synth, in order. */ diff --git a/src/core/project/manager.boxNetwork.test.ts b/src/core/project/manager.boxNetwork.test.ts index 2a94bb25b..45f2a6af5 100644 --- a/src/core/project/manager.boxNetwork.test.ts +++ b/src/core/project/manager.boxNetwork.test.ts @@ -326,6 +326,12 @@ describe("build writes the Box network of the box profile", () => { "the key of env://GITHUB_TOKEN, and agentcore.json has no API key credential 'github' " + "to hold it", ); + // With no target, the Runtime profile has no route to api.github.com, as the old renderer. + const egress = (await runtimeProfile(root)).egress as Record< + string, + { destinations: string[] } + >; + expect(Object.keys(egress).sort()).toEqual(["agentcore", "bedrock"]); }); test("changes nothing on a second build", async () => { From 086bc4622e07d5f85a7b465b4132a1890818a0ed Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:55:16 -0800 Subject: [PATCH 30/51] fix(box): Keep the grants that only the Runtime has when the user removed a template grant 2913cd26 gave a list only the Runtime grants that the local list names when the user removed one grant of the template from it. Then a CodeZip agent lost read on /usr/lib64 and /lib64 and exec on the code folder, where the Runtime installs the dependencies and their native modules, so the agent could not start on the Runtime. The pre-review and Varun in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this. With this change, a Runtime grant of the template whose path the local template list has stays only when the local list keeps it. A Runtime grant that only the Runtime has always stays. Grants are still the same when their paths are, so a grant of the user that is not optional matches an optional grant of the template. An [agent] with no filesystem table gets only the grants that only the Runtime has. Tests: additions.test.ts "keeps the grants that only the Runtime has, and no grant of the template that the user removed" (the read grant of the uv Pythons removed) and "gives an [agent] with no filesystem table only the grants that only the Runtime has". --- .../runtimeProfile/rules/additions.test.ts | 20 ++++++++++++------- .../project/runtimeProfile/rules/additions.ts | 20 +++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index bad0cd427..995e7a330 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -593,23 +593,29 @@ describe("the additions rule", () => { }); }); - test("gives a list no Runtime grant of the template when the user removed a grant of the template from it", () => { + test("keeps the grants that only the Runtime has, and no grant of the template that the user removed", () => { const local = createdProfile(CODEZIP); const filesystem = agentOf(local).filesystem; - // The user keeps the code folder, and removes the venv and the uv Pythons. - filesystem.read = ["${{ workspace }}/app/agent"]; - filesystem.exec = []; + // The user removes the read grant of the uv Pythons. + filesystem.read = filesystem.read.filter( + (grant: unknown) => + (grant as { path?: string }).path !== "${{ home }}/.local/share/uv/python", + ); expect(agentOf(apply(local, contextOf(CODEZIP)).table).filesystem).toEqual({ - read: ["${{ workspace }}/app/agent"], + read: ["${{ workspace }}/app/agent", "/usr/lib64", "/lib64"], + exec: ["${{ workspace }}/app/agent", "${{ home }}/.local/share/uv/python"], }); }); - test("gives an [agent] with no filesystem table no grant", () => { + test("gives an [agent] with no filesystem table only the grants that only the Runtime has", () => { const local = createdProfile(CODEZIP); delete agentOf(local).filesystem; - expect(agentOf(apply(local, contextOf(CODEZIP)).table)).not.toHaveProperty("filesystem"); + expect(agentOf(apply(local, contextOf(CODEZIP)).table).filesystem).toEqual({ + read: ["/usr/lib64", "/lib64"], + exec: ["${{ workspace }}/app/agent"], + }); }); test("leaves out a grant that the user removed from a container's template", () => { diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 43d952fc9..ec7921a45 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -298,12 +298,13 @@ function runtimeEnv( } /** - * `[agent.filesystem]` for the Runtime. In each list, the template's Runtime grants come first, and - * each grant of the user follows in its order. When the local list keeps each grant of the - * template, the list gets each Runtime grant of the template. When the user removed a grant of the - * template, the list gets only the Runtime grants that it names, so the Runtime gets no grant that - * the local profile does not give. A grant is the same as another when its path is, whether it is - * optional or not. A list that ends empty goes. + * `[agent.filesystem]` for the Runtime. In each list, the template's Runtime grants come first, + * and each grant of the user follows in its order. A Runtime grant of the template whose path the + * local template list has stays only when the local list keeps it, so a grant that the user removed + * stays removed. A Runtime grant that only the Runtime has (the loader folders, and exec on the code + * folder, where the Runtime installs the dependencies and their native modules) always stays. A + * grant is the same as another when its path is, whether it is optional or not. A list that ends + * empty goes. */ function runtimeFilesystem( filesystem: unknown, @@ -323,10 +324,9 @@ function runtimeFilesystem( const grants = (own ?? []) as unknown[]; const localGrants = listOf(templateLocal[name]); const runtimeGrants = listOf(templateRuntime[name]); - const keepsTemplate = localGrants.every((grant) => includesPath(grants, grant)); - const kept = keepsTemplate - ? runtimeGrants - : runtimeGrants.filter((grant) => includesPath(grants, grant)); + const kept = runtimeGrants.filter( + (grant) => !includesPath(localGrants, grant) || includesPath(grants, grant), + ); const users = grants.filter( (grant, index) => !includesPath(localGrants, grant) && From bbc643033a6fcc3a9502db8387cae53ccf7e0fd2 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 20:57:43 -0800 Subject: [PATCH 31/51] fix(box): Give the agent the region of the Runtime, and send no AWS_PROFILE to it A local profile can set AWS_REGION or AWS_DEFAULT_REGION in [agent.env], for example to call Bedrock in another region under agentcore dev. The additions rule kept that value on the Runtime, so the AWS SDKs in the box called a region whose hosts the Runtime profile does not route. It also kept AWS_PROFILE, and AgentCore Runtime has no AWS profiles. The pre-review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this. With this change, the region of the Runtime replaces a region of the user: ${{ inputs.aws.region }}, or, with @box/bedrock, the AWS_REGION of that pack. AWS_PROFILE does not go to the Runtime. Build gives a warning for each value that it does not use, with the key and the profile. Tests: additions.test.ts "gives the agent the region of the Runtime over a region of the user, and says so" (with and without @box/bedrock) and "sends no AWS_PROFILE to the Runtime, and says so". --- .../runtimeProfile/rules/additions.test.ts | 38 ++++++++++++++- .../project/runtimeProfile/rules/additions.ts | 46 ++++++++++++++++--- 2 files changed, 76 insertions(+), 8 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 995e7a330..71ba65b44 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -490,16 +490,50 @@ describe("the additions rule", () => { test("keeps a template variable that the user changed, and leaves out one the user removed", () => { const local = createdProfile(CONTAINER); const { PYTHONUNBUFFERED: _removed, ...env } = agentOf(local).env; - agentOf(local).env = { ...env, PORT: "9999", AWS_DEFAULT_REGION: "eu-west-1" }; + agentOf(local).env = { ...env, PORT: "9999" }; const result = agentOf(apply(local, contextOf(CONTAINER)).table).env; expect(result.PORT).toBe("9999"); - expect(result.AWS_DEFAULT_REGION).toBe("eu-west-1"); expect(result).not.toHaveProperty("PYTHONUNBUFFERED"); expect(result).not.toHaveProperty("PYTHONPATH"); }); + test("gives the agent the region of the Runtime over a region of the user, and says so", () => { + const local = { packs: ["@box/base"], agent: { env: { AWS_REGION: "eu-west-1" } } }; + const withBedrock = { ...local, packs: ["@box/base", "@box/bedrock"] }; + + const own = apply(local, contextOf(CODEZIP)); + const bedrock = apply(withBedrock, contextOf(CODEZIP)); + + expect(agentOf(own.table).env.AWS_REGION).toBe("${{ inputs.aws.region }}"); + expect(own.warnings).toEqual([ + `[agent.env] AWS_REGION is "eu-west-1" in ${PROFILE_FILE}. On AgentCore Runtime the ` + + "agent gets the region of the Runtime, ${{ inputs.aws.region }}, so build does not use " + + "this value.", + ]); + // @box/bedrock sets AWS_REGION itself, so the profile does not. + expect(agentOf(bedrock.table).env).not.toHaveProperty("AWS_REGION"); + expect(bedrock.warnings).toEqual([ + `[agent.env] AWS_REGION is "eu-west-1" in ${PROFILE_FILE}. On AgentCore Runtime the ` + + "agent gets the region of the Runtime from @box/bedrock, so build does not use this value.", + ]); + }); + + test("sends no AWS_PROFILE to the Runtime, and says so", () => { + const { table, warnings } = apply( + { agent: { env: { AWS_PROFILE: "Admin" } } }, + contextOf(CODEZIP), + ); + + expect(agentOf(table).env).not.toHaveProperty("AWS_PROFILE"); + expect(warnings).toEqual([ + `[agent.env] AWS_PROFILE is "Admin" in ${PROFILE_FILE}. AgentCore Runtime has no AWS ` + + "profiles: box signs each AWS call with the execution role. Build does not send " + + "AWS_PROFILE to the Runtime.", + ]); + }); + test("sets AWS_REGION only when the profile imports no @box/bedrock", () => { const local = createdProfile(CODEZIP); diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index ec7921a45..9e1d3130f 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -8,7 +8,7 @@ * | `[profile] name` | the project's name | * | `[options] bedrock.region` | the build region, where the profile sets it or imports @box/bedrock | * | `[agent] command` | the template's own command becomes its Runtime command; a command of the user loses `--reload` and `--reload-dir ` | - * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region, the AWS stand-ins, and (CodeZip) the ffi `PYTHONPATH` come in; a value of the user stays | + * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region of the Runtime replaces a region of the user, with a warning; `AWS_PROFILE` goes, with a warning; the AWS stand-ins and (CodeZip) the ffi `PYTHONPATH` come in; each other value of the user stays | * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | * | `[tool.]` | a table of the template becomes its Runtime table, or goes when the Runtime has none; a table of the user stays | @@ -33,6 +33,12 @@ import { type TomlTable, } from "../types"; +/** The variables of the region of the agent, which get the region of the Runtime. */ +const REGION_ENV_NAMES: ReadonlySet = new Set(["AWS_REGION", "AWS_DEFAULT_REGION"]); + +/** The variable of a named AWS profile, which AgentCore Runtime does not have. */ +const AWS_PROFILE = "AWS_PROFILE"; + /** The variable that tells the template's agent that it runs under `agentcore dev`. */ const LOCAL_DEV = "LOCAL_DEV"; @@ -145,14 +151,15 @@ export function apply(table: Readonly, context: RuntimeProfileContext const bedrock = Array.isArray(packs) && packs.includes(BOX_BEDROCK_PACK); const options = runtimeOptions(result.options, bedrock, context.region); if (options !== undefined) result.options = options; - result.agent = runtimeAgent(result.agent, bedrock, context); + const warnings: string[] = []; + result.agent = runtimeAgent(result.agent, bedrock, context, warnings); if (result.tool !== undefined) { const tool = runtimeTools(result.tool, context); if (tool === undefined) delete result.tool; else result.tool = tool; } result.telemetry = runtimeTelemetry(result.telemetry, context); - return { table: result, problems: [], warnings: [] }; + return { table: result, problems: [], warnings }; } /** The user's packs in their order, then each Runtime pack that they do not import. */ @@ -183,7 +190,12 @@ function runtimeOptions(options: unknown, bedrock: boolean, region: string): unk } /** `[agent]` with its command, env, filesystem, and ingress for the Runtime; other keys stay. */ -function runtimeAgent(agent: unknown, bedrock: boolean, context: RuntimeProfileContext): unknown { +function runtimeAgent( + agent: unknown, + bedrock: boolean, + context: RuntimeProfileContext, + warnings: string[], +): unknown { if (agent !== undefined && !isTable(agent)) return agent; const local: TomlTable = agent ?? {}; const templateLocal = tableOf(context.template.local.agent); @@ -200,6 +212,7 @@ function runtimeAgent(agent: unknown, bedrock: boolean, context: RuntimeProfileC tableOf(templateRuntime.env), bedrock, context, + warnings, ); const filesystem = runtimeFilesystem( local.filesystem, @@ -264,6 +277,7 @@ function runtimeEnv( templateRuntime: TomlTable, bedrock: boolean, context: RuntimeProfileContext, + warnings: string[], ): unknown { if (env !== undefined && !isTable(env)) return env; const local: TomlTable = env ?? {}; @@ -278,10 +292,30 @@ function runtimeEnv( else if (has(name)) result[name] = ofTemplate(name) ? value : local[name]; } for (const [name, value] of Object.entries(added)) { - result[name] = has(name) ? local[name] : value; + // The region of the Runtime wins: the hosts that the profile routes are in that region. + result[name] = has(name) && !REGION_ENV_NAMES.has(name) ? local[name] : value; + } + for (const name of REGION_ENV_NAMES) { + if (!has(name) || sameValue(local[name], result[name])) continue; + warnings.push( + `[agent.env] ${name} is ${JSON.stringify(local[name])} in ${context.profileFile}. On ` + + "AgentCore Runtime the agent gets the region of the Runtime" + + (Object.hasOwn(result, name) + ? `, ${RUNTIME_INPUTS.awsRegion}` + : ` from ${BOX_BEDROCK_PACK}`) + + ", so build does not use this value.", + ); + } + if (has(AWS_PROFILE)) { + warnings.push( + `[agent.env] ${AWS_PROFILE} is ${JSON.stringify(local[AWS_PROFILE])} in ` + + `${context.profileFile}. AgentCore Runtime has no AWS profiles: box signs each AWS call ` + + `with the execution role. Build does not send ${AWS_PROFILE} to the Runtime.`, + ); } for (const [name, value] of Object.entries(local)) { - if (name === LOCAL_DEV || Object.hasOwn(result, name) || ofTemplate(name)) continue; + if (name === LOCAL_DEV || name === AWS_PROFILE || REGION_ENV_NAMES.has(name)) continue; + if (Object.hasOwn(result, name) || ofTemplate(name)) continue; result[name] = value; } if (context.paths.build === "CodeZip") { From aa1e11c53d5541f250e5025b25c99973a6031297 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:03:01 -0800 Subject: [PATCH 32/51] fix(box): Stop build only for a key that cannot work on the Runtime, and warn for the rest The refusals rule stopped build for some keys that the Runtime can do without, and the home check read any string as a path. The pre-review and Varun in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found these. With this change, on a CodeZip runtime: - A deny or deny_write entry, or an optional grant, whose path is not on the Runtime does not stop build. The paths rule leaves it out of the Runtime profile, with a warning. A required grant with no place on the Runtime still stops build (RUNTIME_PATH_NOT_FOUND). - A program at an absolute path of the system, for example /usr/bin/grep or /opt/homebrew/bin/python3, goes to the Runtime with a warning that build cannot check the Runtime image; box stops the run when the program is not there. This is one rule for the [agent], a stdio server, and a tool. A program in the project outside the code folder, in the home folder, or in the venv still stops build (RUNTIME_PATH_NOT_FOUND), and so does a program that PATH finds, such as npx (RUNTIME_PROGRAM_NOT_FOUND). - The check for a host home path (~, ~/, /Users/, /home/) reads only a value that is a path: a filesystem grant, a word of a command, or a program. It reads each part of a : list and the value of a --flag=, as the ${{ home }} check does. An env value such as "/home/page" is not a path for this check. On each runtime, a telemetry target of kind "file" does not stop build. The additions rule leaves it out of the Runtime profile, with a warning, because nothing reads the files of the microVM. Each other kind that is not CloudWatch still stops build. keyLabel moved from derive.ts to projectPaths.ts, so the refusals rule does not import derive.ts, which imports the rules. Tests: refusals.test.ts "stops for a program of %s that PATH finds, on a CodeZip Runtime only (RUNTIME_PROGRAM_NOT_FOUND)" (3 tables), "carries a system program of %s, with a warning that build cannot check it, on a CodeZip Runtime only" (2), "reads each part of a : list and the value of a --flag= in a command for a host home path", the optional grant in "stops for each path that cannot move", and the file target in "stops for each [telemetry] target that is not CloudWatch". paths.test.ts "leaves out a deny entry and an optional grant that are not on the Runtime, with a warning". additions.test.ts "leaves a target of another kind as it is, and leaves out a file target with a warning". --- .../project/runtimeProfile/derive.test.ts | 3 +- src/core/project/runtimeProfile/derive.ts | 7 -- .../project/runtimeProfile/projectPaths.ts | 43 +++++++++- .../runtimeProfile/rules/additions.test.ts | 20 +++-- .../project/runtimeProfile/rules/additions.ts | 19 ++++- .../runtimeProfile/rules/paths.test.ts | 25 ++++++ .../project/runtimeProfile/rules/paths.ts | 47 ++++++++++- .../runtimeProfile/rules/refusals.test.ts | 50 +++++++++--- .../project/runtimeProfile/rules/refusals.ts | 78 ++++++++++++++----- 9 files changed, 238 insertions(+), 54 deletions(-) diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts index 0b398ce5e..d5990ae90 100644 --- a/src/core/project/runtimeProfile/derive.test.ts +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -3,7 +3,8 @@ import { parse } from "smol-toml"; import type { ProjectSpec } from "../../../projectSchemas/project"; import type { ProjectRuntime } from "../../../projectSchemas/runtime"; import { profileKeyPlaces, runtimePaths, runtimeProfileContext, runtimeTemplate } from "./context"; -import { deriveRuntimeProfile, keyLabel, RUNTIME_PROFILE_RULES } from "./derive"; +import { deriveRuntimeProfile, RUNTIME_PROFILE_RULES } from "./derive"; +import { keyLabel } from "./projectPaths"; import { serializeRuntimeProfile } from "./serialize"; import type { TomlTable } from "./types"; diff --git a/src/core/project/runtimeProfile/derive.ts b/src/core/project/runtimeProfile/derive.ts index 5bc6957f9..2596018e0 100644 --- a/src/core/project/runtimeProfile/derive.ts +++ b/src/core/project/runtimeProfile/derive.ts @@ -53,10 +53,3 @@ export function deriveRuntimeProfile( } return { profile, problems, warnings }; } - -/** A key as a message names it: `[mcp.notes] command`, `[agent.filesystem] read`, `packs`. */ -export function keyLabel(key: readonly string[]): string { - if (key.length === 1) return key[0]!; - const table = key.slice(0, -1).join("."); - return `[${table}] ${key[key.length - 1]}`; -} diff --git a/src/core/project/runtimeProfile/projectPaths.ts b/src/core/project/runtimeProfile/projectPaths.ts index c96fbeb6e..2f9588e60 100644 --- a/src/core/project/runtimeProfile/projectPaths.ts +++ b/src/core/project/runtimeProfile/projectPaths.ts @@ -39,6 +39,13 @@ const NOT_READ: ReadonlySet = new Set([ "telemetry", ]); +/** A key as a message names it: `[mcp.notes] command`, `[agent.filesystem] read`, `packs`. */ +export function keyLabel(key: readonly string[]): string { + if (key.length === 1) return key[0]!; + const table = key.slice(0, -1).join("."); + return `[${table}] ${key[key.length - 1]}`; +} + /** A plain TOML table: not a list, and not a date that smol-toml gives as an object. */ export function isTable(value: unknown): value is TomlTable { if (typeof value !== "object" || value === null || Array.isArray(value)) return false; @@ -55,6 +62,40 @@ const NAME_END = "(?![A-Za-z0-9_.+-])"; /** A path in a home folder that names no `${{ home }}`: `~`, `~/...`, `/Users/...`, `/home/...`. */ const HOST_HOME = /^(?:~(?:\/|$)|\/(?:Users|home)\/)/; +/** + * Whether the path `value` names a home folder of the host with no `${{ home }}`: box expands `~` + * to the home folder, and a host keeps its homes under /Users or /home. As {@link moveProjectPath} + * does, it reads each part of a `:` list and the value of a `--flag=`. Use it only for a + * value that is a path, such as a grant or a word of a command, and not for any string. + */ +export function namesHostHome(value: string): boolean { + return value + .split(":") + .some((part) => HOST_HOME.test(part) || HOST_HOME.test(part.slice(part.indexOf("=") + 1))); +} + +/** Why the path `value` has no place on a CodeZip Runtime, or `undefined` when it has one. */ +export function pathProblem(value: string, paths: RuntimePaths): PathProblem | undefined { + if (namesHostHome(value)) return "home"; + const moved = moveProjectPath(value, paths); + return typeof moved === "string" ? undefined : moved.problem; +} + +/** The path of a filesystem grant: the string, or the `path` of a grant table. */ +export function grantPath(grant: unknown): string | undefined { + if (typeof grant === "string") return grant; + return isTable(grant) && typeof grant.path === "string" ? grant.path : undefined; +} + +/** + * Whether a grant of the filesystem list `list` can go from the Runtime profile when its path is + * not on the Runtime: an entry of `deny` or `deny_write`, which only takes access away, or an + * optional grant, which box skips when its path is not there. + */ +export function isDroppableGrant(list: string, grant: unknown): boolean { + return list === "deny" || list === "deny_write" || (isTable(grant) && grant.optional === true); +} + /** The end of a path: no more of it follows, not even a `/`. */ const PATH_END = "(?![A-Za-z0-9_.+/-])"; @@ -68,8 +109,6 @@ export function moveProjectPath( value: string, paths: RuntimePaths, ): string | { readonly problem: PathProblem } { - // box expands `~` to the home folder, and a host's own home is under /Users or /home. - if (HOST_HOME.test(value)) return { problem: "home" }; const normal = value .replace(/\$\{\{\s*workspace\s*\}\}/g, () => WORKSPACE) .replace(/\$\{\{\s*home\s*\}\}/g, () => HOME); diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 71ba65b44..81769d787 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -738,16 +738,20 @@ describe("the additions rule", () => { }); }); - test("leaves a target of another kind as it is", () => { - const others = { - records: { kind: "file", destination: "/tmp/records.jsonl" }, - langfuse: { kind: "langfuse", secret: { ref: "env://LANGFUSE_AUTH" } }, + test("leaves a target of another kind as it is, and leaves out a file target with a warning", () => { + const langfuse = { kind: "langfuse", secret: { ref: "env://LANGFUSE_AUTH" } }; + const local = { + telemetry: { records: { kind: "file", destination: "/tmp/records.jsonl" }, langfuse }, }; - expect(apply({ telemetry: others }, contextOf(CODEZIP)).table.telemetry).toEqual({ - ...others, - agentcore: DEFAULT_TARGET, - }); + const { table, warnings } = apply(local, contextOf(CODEZIP)); + + expect(table.telemetry).toEqual({ langfuse, agentcore: DEFAULT_TARGET }); + expect(warnings).toEqual([ + "[telemetry.records] writes its records to a file. On AgentCore Runtime that file is in " + + "the microVM, where nothing reads it, so build leaves the target out of the Runtime " + + "profile.", + ]); }); test("adds each CloudWatch target of the context that the local profile does not declare", () => { diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 9e1d3130f..f4c6a93ce 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -12,7 +12,7 @@ * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | * | `[tool.]` | a table of the template becomes its Runtime table, or goes when the Runtime has none; a table of the user stays | - * | `[telemetry.]` | each CloudWatch target that box takes is signed with a bare `aws://`, in the deploy region when it names none; one that box refuses goes | + * | `[telemetry.]` | each CloudWatch target that box takes is signed with a bare `aws://`, in the deploy region when it names none; one that box refuses goes; a `file` target goes, with a warning | * | `[telemetry.agentcore]` | added when no target is `cloudwatch_logs`: the runtime's own log group and log stream | * * It moves no path: the paths rule runs after it and moves each path of the user. @@ -25,6 +25,7 @@ import { } from "../../templates/boxProfile"; import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; import { isTable } from "../projectPaths"; +import { FILE_TELEMETRY_KIND } from "./refusals"; import { RUNTIME_AWS_SIGNER, RUNTIME_INPUTS, @@ -158,7 +159,7 @@ export function apply(table: Readonly, context: RuntimeProfileContext if (tool === undefined) delete result.tool; else result.tool = tool; } - result.telemetry = runtimeTelemetry(result.telemetry, context); + result.telemetry = runtimeTelemetry(result.telemetry, context, warnings); return { table: result, problems: [], warnings }; } @@ -417,12 +418,24 @@ function onAllAddresses(entry: unknown): unknown { * `agentcore`, or as `agentcore_default` when a target has that name, unless the envVars of the * runtime turn observability off ({@link OBSERVABILITY_OFF_ENV}). */ -function runtimeTelemetry(telemetry: unknown, context: RuntimeProfileContext): unknown { +function runtimeTelemetry( + telemetry: unknown, + context: RuntimeProfileContext, + warnings: string[], +): unknown { if (telemetry !== undefined && !isTable(telemetry)) return telemetry; const local: TomlTable = telemetry ?? {}; const resolved = new Map(context.telemetry.map((target) => [target.name, target])); const result: TomlTable = {}; for (const [name, entry] of Object.entries(local)) { + if (isTable(entry) && entry.kind === FILE_TELEMETRY_KIND) { + warnings.push( + `[telemetry.${name}] writes its records to a file. On AgentCore Runtime that file is in ` + + "the microVM, where nothing reads it, so build leaves the target out of the Runtime " + + "profile.", + ); + continue; + } // A table with no kind adds to the CloudWatch target of that name that a pack gives. const addsToPack = isTable(entry) && entry.kind === undefined && resolved.has(name); if (!isTable(entry) || (!CLOUDWATCH_KINDS.has(entry.kind) && !addsToPack)) { diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 20e4d892a..0e1a4fd8d 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -100,6 +100,31 @@ const LEAVES_ON_RUNTIME = { }; describe("the paths rule", () => { + test("leaves out a deny entry and an optional grant that are not on the Runtime, with a warning", () => { + const text = [ + "[agent.filesystem]", + 'read = ["${{ workspace }}/app/agent", { path = "${{ home }}/.aws", optional = true }]', + 'deny = ["${{ home }}/.ssh", "${{ workspace }}/app/agent/secrets"]', + ].join("\n"); + + const { profile, problems, warnings } = deriveRuntimeProfile( + parse(text) as TomlTable, + contextOf(text), + ); + + expect(problems).toEqual([]); + expect((profile.agent as TomlTable).filesystem).toMatchObject({ + read: expect.not.arrayContaining([expect.objectContaining({ path: "${{ home }}/.aws" })]), + deny: ["${{ inputs.code.dir }}/secrets"], + }); + expect(warnings).toEqual([ + '[agent.filesystem] read names "${{ home }}/.aws", which is not on AgentCore Runtime, so ' + + "build leaves it out of the Runtime profile.", + '[agent.filesystem] deny names "${{ home }}/.ssh", which is not on AgentCore Runtime, so ' + + "build leaves it out of the Runtime profile.", + ]); + }); + test("keeps each stdio [mcp] server and each [tool], with each key, in the Runtime profile", () => { // The renderer that the derivation replaced built the Runtime profile from agentcore.json, with // no [mcp.notes] and no [tool.lister]. The derived profile keeps both, as they work there. diff --git a/src/core/project/runtimeProfile/rules/paths.ts b/src/core/project/runtimeProfile/rules/paths.ts index 9e2de1a3a..2ebac9bc9 100644 --- a/src/core/project/runtimeProfile/rules/paths.ts +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -13,29 +13,36 @@ * gives the Runtime grants of the template in the local paths, and this rule moves them too. */ import { + grantPath, + isDroppableGrant, isTable, + keyLabel, mapProjectPaths, moveProjectPath, + pathProblem, processTables, programOf, runtimeFfiPath, runtimePythonPath, withOneGrantForEachPath, } from "../projectPaths"; -import type { RuleResult, RuntimeProfileContext, TomlTable } from "../types"; +import type { RuleResult, RuntimePaths, RuntimeProfileContext, TomlTable } from "../types"; export function apply(table: Readonly, context: RuntimeProfileContext): RuleResult { const { paths } = context; if (paths.build !== "CodeZip") { return { table: structuredClone(table) as TomlTable, problems: [], warnings: [] }; } + const warnings: string[] = []; const moved = mapProjectPaths(table, (value) => { const result = moveProjectPath(value, paths); return typeof result === "string" ? result : value; }); - for (const { table: process, leaf } of processTables(moved)) { + for (const { key, table: process, leaf } of processTables(moved)) { if (isTable(process.filesystem)) { - process.filesystem = withOneGrantForEachPath(process.filesystem); + process.filesystem = withOneGrantForEachPath( + withoutLostGrants(process.filesystem, key, paths, warnings), + ); } if (!leaf || programOf(process) !== paths.runtimePython) continue; const env = isTable(process.env) ? process.env : {}; @@ -47,5 +54,37 @@ export function apply(table: Readonly, context: RuntimeProfileContext process.env = { ...env, PYTHONPATH: `${ffi}:${own}` }; } } - return { table: moved, problems: [], warnings: [] }; + return { table: moved, problems: [], warnings }; +} + +/** + * `filesystem` with no deny entry and no optional grant whose path is not on the Runtime, with a + * warning for each. The refusals rule stops build for each other grant with no place there. A + * moved path names no `${{ workspace }}` or `${{ home }}`, so only a grant that did not move is + * left out. + */ +function withoutLostGrants( + filesystem: Readonly, + key: readonly string[], + paths: RuntimePaths, + warnings: string[], +): TomlTable { + const result: TomlTable = {}; + for (const [list, grants] of Object.entries(filesystem)) { + if (!Array.isArray(grants)) { + result[list] = grants; + continue; + } + result[list] = grants.filter((grant) => { + const path = grantPath(grant); + if (path === undefined || pathProblem(path, paths) === undefined) return true; + if (!isDroppableGrant(list, grant)) return true; + warnings.push( + `${keyLabel([...key, "filesystem", list])} names ${JSON.stringify(path)}, which is not on ` + + "AgentCore Runtime, so build leaves it out of the Runtime profile.", + ); + return false; + }); + } + return result; } diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index 5c9a83c4b..3c3d740e1 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -156,19 +156,20 @@ describe("the refusals rule", () => { 'write = ["${{ workspace }}/out", "${{ home }}/.local/share/uv/python/cpython-3.15"]', ); + // The optional grant of ~/.aws is not a problem: the paths rule leaves it out, with a warning. expect(problemsOf(text).map(({ key, place }) => [key.join("."), place])).toEqual([ ["agent.env.AWS_CONFIG_FILE", `${PROFILE}:4:1`], - ["agent.filesystem.read", `${PROFILE}:6:1`], ["tool.lister.filesystem.write", `${PROFILE}:10:1`], ["tool.lister.filesystem.write", `${PROFILE}:10:1`], ]); }); test.each([ - ["a program that PATH finds", ["mcp", "files"], '"npx", "-y", "files-server"', "npx"], - ["a system program", ["tool", "grep"], '"/usr/bin/grep", "-r"', "/usr/bin/grep"], + ["a stdio server", ["mcp", "files"], '"npx", "-y", "files-server"', "npx"], + ["a tool", ["tool", "jq"], '"jq", "."', "jq"], + ["the agent", ["agent"], '"uv", "run", "main.py"', "uv"], ])( - "stops for %s that build cannot find on a CodeZip Runtime (RUNTIME_PROGRAM_NOT_FOUND)", + "stops for a program of %s that PATH finds, on a CodeZip Runtime only (RUNTIME_PROGRAM_NOT_FOUND)", (_label, table, command, program) => { const header = `[${table.join(".")}]`; const text = toml( @@ -235,13 +236,39 @@ describe("the refusals rule", () => { expect(problemsOf(text, CONTAINER)).toEqual([]); }); - test("stops for an [agent] program of the user that build cannot find, on a CodeZip Runtime only", () => { - const text = toml("[agent]", 'command = ["/opt/homebrew/bin/python3", "main.py"]'); + test.each([ + ["the agent", ["agent"], "/opt/homebrew/bin/python3"], + ["a tool", ["tool", "grep"], "/usr/bin/grep"], + ])( + "carries a system program of %s, with a warning that build cannot check it, on a CodeZip Runtime only", + (_label, table, program) => { + const text = toml(`[${table.join(".")}]`, `command = ["${program}", "main.py"]`); + + const result = apply(parse(text) as TomlTable, contextOf(text)); + + expect(result.problems).toEqual([]); + expect(result.warnings).toEqual([ + `[${table.join(".")}] command starts "${program}", a program of the system. Build cannot ` + + "see the image of AgentCore Runtime, so it cannot check that the program is there. box " + + "stops the run when it is not.", + ]); + expect(apply(parse(text) as TomlTable, contextOf(text, CONTAINER)).warnings).toEqual([]); + }, + ); - expect(problemsOf(text).map(({ code, key, place }) => [code, key, place])).toEqual([ - ["RUNTIME_PROGRAM_NOT_FOUND", ["agent", "command"], `${PROFILE}:2:1`], + test("reads each part of a : list and the value of a --flag= in a command for a host home path", () => { + const text = toml( + "[tool.lister]", + `command = ["${APP}/bin/lister", "--root=~/data", "${APP}/a:/Users/me/b"]`, + "[agent.env]", + // An env value can be any string: it is not a path unless it names ${{ home }}. + 'PAGE = "/home/page"', + ); + + expect(problemsOf(text).map(({ code, key }) => [code, key.join(".")])).toEqual([ + ["RUNTIME_PATH_NOT_FOUND", "tool.lister.command"], + ["RUNTIME_PATH_NOT_FOUND", "tool.lister.command"], ]); - expect(problemsOf(text, CONTAINER)).toEqual([]); }); test.each(["~", "~/data", "/Users/me/data", "/home/me/data"])( @@ -368,6 +395,11 @@ describe("the refusals rule", () => { "", "[telemetry.local]", 'path = "/tmp/box.jsonl"', + "", + // A file target is not a problem: the additions rule leaves it out, with a warning. + "[telemetry.records]", + 'kind = "file"', + 'destination = "/tmp/records.jsonl"', ); expect(problemsOf(text, runtime)).toEqual([ diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index 4c578f5f5..696bb878a 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -6,7 +6,7 @@ * | Key | Problem | * | --- | --- | * | `network.contain_egress = false` on `[agent]`, a stdio `[mcp.]`, or a `[tool.]` | RUNTIME_EGRESS_NOT_CONTAINED | - * | a `[telemetry.]` that is not `cloudwatch_logs` or `cloudwatch_traces` | RUNTIME_TELEMETRY_NOT_CLOUDWATCH | + * | a `[telemetry.]` that is not `cloudwatch_logs`, `cloudwatch_traces`, or `file` | RUNTIME_TELEMETRY_NOT_CLOUDWATCH | * | a CloudWatch `[telemetry.]` that box refuses when a run starts, so it is not in `context.telemetry` | RUNTIME_TELEMETRY_REFUSED | * | CodeZip: a path of the project outside the code folder, of the home folder (`${{ home }}`, `~`, `/Users`, `/home`), or in the venv | RUNTIME_PATH_NOT_FOUND | * | CodeZip: an `[agent]`, stdio server, or tool program that is not the venv's Python or a file in the code folder | RUNTIME_PROGRAM_NOT_FOUND | @@ -16,12 +16,15 @@ * the last three do not apply to it. The rule reads only the text of the local profile: a key that * a pack adds is not in that text, so the rule does not examine it. */ -import { keyLabel } from "../derive"; import { + grantPath, + isDroppableGrant, isRuntimeProgram, isTable, + keyLabel, mapProjectPaths, moveProjectPath, + pathProblem, processTables, programOf, type PathProblem, @@ -37,6 +40,9 @@ import type { /** The filesystem lists that let a process write. */ const WRITE_LISTS = ["write", "write_file"] as const; +/** The kind of a telemetry target that writes a file. */ +export const FILE_TELEMETRY_KIND = "file"; + /** The telemetry kinds that a box on AgentCore Runtime can send to, with the execution role. */ const RUNTIME_TELEMETRY_KINDS: ReadonlySet = new Set([ "cloudwatch_logs", @@ -45,6 +51,7 @@ const RUNTIME_TELEMETRY_KINDS: ReadonlySet = new Set([ export function apply(table: Readonly, context: RuntimeProfileContext): RuleResult { const problems: RuntimeProfileProblem[] = []; + const warnings: string[] = []; const problem = (code: RuntimeProfileProblemCode, key: readonly string[], reason: string) => problems.push({ code, key, reason: `${keyLabel(key)} ${reason}`, place: context.placeOf(key) }); @@ -78,6 +85,8 @@ export function apply(table: Readonly, context: RuntimeProfileContext ); continue; } + // The additions rule leaves out a file target, with a warning: nobody reads the microVM's files. + if (kind === FILE_TELEMETRY_KIND) continue; // A table with no kind adds to the target of that name that a pack gives, which box resolves. if (kind === undefined && context.telemetry.some((resolved) => resolved.name === name)) continue; @@ -106,25 +115,60 @@ export function apply(table: Readonly, context: RuntimeProfileContext `venv: the Runtime installs the dependencies in ${code}. Use the venv's Python, the ` + `venv, or a path in ${code}.`, }; + const moved = (value: string) => { + const result = moveProjectPath(value, paths); + return typeof result === "string" ? undefined : result.problem; + }; mapProjectPaths(table, (value, key) => { - const moved = moveProjectPath(value, paths); - if (typeof moved !== "string") { - problem("RUNTIME_PATH_NOT_FOUND", key, reasons[moved.problem](JSON.stringify(value))); + // Each grant of a filesystem list is read below, with its list. + if (key.at(-2) === "filesystem") return value; + // A word of a command or a program is a path; another value, such as an env value, can + // be any string, so only ${{ workspace }} and ${{ home }} mark a path in it. + const isPath = key.at(-1) === "command" || key.at(-1) === "program"; + const found = isPath ? pathProblem(value, paths) : moved(value); + if (found !== undefined) { + problem("RUNTIME_PATH_NOT_FOUND", key, reasons[found](JSON.stringify(value))); } return value; }); + for (const { key, table: process } of processTables(table)) { + const filesystem = isTable(process.filesystem) ? process.filesystem : {}; + for (const [list, grants] of Object.entries(filesystem)) { + if (!Array.isArray(grants)) continue; + for (const grant of grants) { + const path = grantPath(grant); + const found = path === undefined ? undefined : pathProblem(path, paths); + // The paths rule leaves out a deny entry or an optional grant, with a warning. + if (found === undefined || isDroppableGrant(list, grant)) continue; + problem( + "RUNTIME_PATH_NOT_FOUND", + [...key, "filesystem", list], + reasons[found](JSON.stringify(path)), + ); + } + } + } for (const { key, table: process, leaf } of processTables(table)) { // The command of the template moves to the Runtime's Python. A command of the user stays. const command = programOf(process); - const moved = command === undefined ? undefined : moveProjectPath(command, paths); const searched = leaf && typeof process.program === "string" ? process.program : undefined; - // A program with no place on the Runtime is a path problem of its command already. - const program = typeof moved === "string" ? moved : undefined; - if (program !== undefined && !isRuntimeProgram(program, paths)) { - problem("RUNTIME_PROGRAM_NOT_FOUND", [...key, "command"], notFound(command!, paths)); - } - if (searched !== undefined) { - problem("RUNTIME_PROGRAM_NOT_FOUND", [...key, "program"], notFound(searched, paths)); + for (const [name, program] of [ + ["command", command], + ["program", searched], + ] as const) { + if (program === undefined || pathProblem(program, paths) !== undefined) continue; + // A program with no place on the Runtime is a path problem already. + const runtimeProgram = moveProjectPath(program, paths) as string; + if (isRuntimeProgram(runtimeProgram, paths)) continue; + if (runtimeProgram.startsWith("/")) { + warnings.push( + `${keyLabel([...key, name])} starts ${JSON.stringify(program)}, a program of the ` + + "system. Build cannot see the image of AgentCore Runtime, so it cannot check that " + + "the program is there. box stops the run when it is not.", + ); + continue; + } + problem("RUNTIME_PROGRAM_NOT_FOUND", [...key, name], notFound(program, paths)); } } // On the Runtime the agent gets exec on the code folder, and box refuses a write grant in a @@ -153,16 +197,10 @@ export function apply(table: Readonly, context: RuntimeProfileContext return { table: structuredClone(table) as TomlTable, problems: inProfileOrder(problems), - warnings: [], + warnings, }; } -/** The path of a filesystem grant: the string, or the `path` of a grant table. */ -function grantPath(grant: unknown): string | undefined { - if (typeof grant === "string") return grant; - return isTable(grant) && typeof grant.path === "string" ? grant.path : undefined; -} - /** Whether `path`, as a CodeZip Runtime profile names it, is the code folder or in it. */ function inRuntimeCode(path: string, paths: RuntimeProfileContext["paths"]): boolean { return path === paths.runtimeCode || path.startsWith(`${paths.runtimeCode}/`); From 5595c28eb89a535234458e90582b523a6abe3d6b Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:05:49 -0800 Subject: [PATCH 33/51] revert(box): Remove the stop for a .box/profile.toml of the earlier layout 35f0ffaf made build, deploy, and dev stop when a project had .box/profile.toml, the one profile of the layout before each runtime had its own. Varun asked in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) to remove it: box applies only to new projects from the box templates, and aws/agentcore-cli#2859 decided that such a project needs no migration and no check for the old file. This commit removes assertNoProjectBoxProfile, its calls in readBoxNetworks, BoxDevRunner, and ContainerDevRunner, and its 4 tests. The comment of readBoxNetworks now says that it stops for a box runtime with no local profile (4a1e720e), and no longer says that such a runtime resolves no profile. Tests: the dev, project, and runtimeProfile tests pass (2030). --- src/core/dev/box.test.ts | 34 ----------------------- src/core/dev/box.ts | 2 -- src/core/dev/container.test.ts | 15 ---------- src/core/dev/container.ts | 7 +---- src/core/project/boxNetworkSource.test.ts | 16 ----------- src/core/project/boxNetworkSource.ts | 5 +--- src/core/project/templates/boxProfile.ts | 19 ------------- 7 files changed, 2 insertions(+), 96 deletions(-) diff --git a/src/core/dev/box.test.ts b/src/core/dev/box.test.ts index e316b59f4..25ae47645 100644 --- a/src/core/dev/box.test.ts +++ b/src/core/dev/box.test.ts @@ -334,40 +334,6 @@ describe("BoxDevRunner", () => { expect(fallbackRuns).toEqual([]); }); - test.each([ - ["has no box profile of its own", false], - ["has its own box profile too", true], - ])( - "refuses a box runtime in a project that keeps .box/profile.toml, when it %s", - async (_label, profiled) => { - const { projectRoot, calls, fallbackRuns, runner } = await scene(profiled); - await mkdir(join(projectRoot, ".box"), { recursive: true }); - await writeFile(join(projectRoot, ".box", "profile.toml"), PROFILE); - - const run = collect(runner.run(input(projectRoot, 8080, "HTTP", "start.py"))); - - await expect(run).rejects.toBeInstanceOf(ProjectStateError); - await expect(run).rejects.toThrow( - ".box/profile.toml is the box profile of an earlier layout, and no command reads it " + - "now: each agent has its own profile, .box//local/profile.toml.", - ); - expect(calls).toEqual([]); - expect(fallbackRuns).toEqual([]); - }, - ); - - test("runs a runtime with no box.version the usual way in a project that keeps .box/profile.toml", async () => { - const { projectRoot, fallbackRuns, runner } = await scene(false); - await mkdir(join(projectRoot, ".box")); - await writeFile(join(projectRoot, ".box", "profile.toml"), PROFILE); - - await collect( - runner.run(input(projectRoot, 8080, undefined, "main.py", true, /* box */ false)), - ); - - expect(fallbackRuns).toHaveLength(1); - }); - test("tells the user to run uv sync when the runtime has no .venv", async () => { const { projectRoot, calls, runner } = await scene(true); await rm(join(projectRoot, "app", "agent", ".venv"), { recursive: true }); diff --git a/src/core/dev/box.ts b/src/core/dev/box.ts index c2afcaaf7..1bfbf4eff 100644 --- a/src/core/dev/box.ts +++ b/src/core/dev/box.ts @@ -6,7 +6,6 @@ import { streamProcess, type ProcessStreamer } from "../../io"; import { requireTool } from "../../io/exec"; import { BOX_INSTALL_HINT } from "../project/backends/boxRelease"; import { - assertNoProjectBoxProfile, boxIngressPort, boxLocalProfileFile, boxLocalProfilePath, @@ -59,7 +58,6 @@ export class BoxDevRunner implements DevRunner { yield* this.fallback.run(input); return; } - assertNoProjectBoxProfile(input.projectRoot); if (!existsSync(profile)) { throw new ResourceNotFoundError( `runtime "${input.runtime.name}" runs its agent in a box (it has box.version in ` + diff --git a/src/core/dev/container.test.ts b/src/core/dev/container.test.ts index 64423c46d..813b50d43 100644 --- a/src/core/dev/container.test.ts +++ b/src/core/dev/container.test.ts @@ -873,21 +873,6 @@ describe("ContainerDevRunner", () => { ); }); - test("refuses a project that keeps .box/profile.toml, and stages nothing", async () => { - const { projectRuntime, root, context } = await boxedScene(); - await writeFile(join(root, ".box", "profile.toml"), "# earlier layout\n"); - const { calls, runner } = harness({ processEnv: credentials }); - - const run = collect(runner.run(input(root, projectRuntime))); - - await expect(run).rejects.toBeInstanceOf(ProjectStateError); - await expect(run).rejects.toThrow( - ".box/profile.toml is the box profile of an earlier layout", - ); - expect(existsSync(join(context, ".box-dist"))).toBe(false); - expect(calls.filter(({ command }) => command[1] === "build")).toEqual([]); - }); - test("stages the local profile in .box-dist/, and lets box's sandbox run", async () => { const { projectRuntime, root, context } = await boxedScene(); const { calls, runner } = harness({ processEnv: credentials }); diff --git a/src/core/dev/container.ts b/src/core/dev/container.ts index 53e030daa..0182becf9 100644 --- a/src/core/dev/container.ts +++ b/src/core/dev/container.ts @@ -27,11 +27,7 @@ import { } from "../project/backends/boxContainer"; import { boxReleaseFor, type BoxRelease } from "../project/backends/boxRelease"; import { boxPolicyFileCopies } from "../project/boxNetworkSource"; -import { - assertNoProjectBoxProfile, - boxLocalProfilePath, - runsInBox, -} from "../project/templates/boxProfile"; +import { boxLocalProfilePath, runsInBox } from "../project/templates/boxProfile"; import { BOX_DEV_AWS_REFRESH_MS, resolveDefaultAwsCredentials, @@ -347,7 +343,6 @@ export class ContainerDevRunner implements DevRunner { } return undefined; } - assertNoProjectBoxProfile(input.projectRoot); const profile = boxLocalProfilePath(input.projectRoot, input.runtime.name); if (!existsSync(profile)) { throw new ResourceNotFoundError( diff --git a/src/core/project/boxNetworkSource.test.ts b/src/core/project/boxNetworkSource.test.ts index 798596d8d..07d4e13a5 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -272,22 +272,6 @@ describe("readBoxNetworks", () => { ); }); - test("refuses a project that keeps .box/profile.toml, and runs no box", async () => { - const root = await project([]); - await writeFile(join(root, ".box", "profile.toml"), "# earlier layout\n"); - const box = new FakeBoxProfileResolver(); - - const read = readBoxNetworks(SPEC, root, box); - - await expect(read).rejects.toBeInstanceOf(ProjectStateError); - await expect(read).rejects.toThrow( - ".box/profile.toml is the box profile of an earlier layout, and no command reads it now: " + - "each agent has its own profile, .box//local/profile.toml. Move the profile and " + - "its policy files into that folder of the runtime it runs, then remove .box/profile.toml.", - ); - expect(box.calls).toEqual([]); - }); - test("places a rule of a policy file at its line, and an entry at its line in the profile", async () => { const root = await project(["policy.dw"]); await writeFile( diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index ba3b6f9ee..802751e75 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -14,7 +14,6 @@ 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 { - assertNoProjectBoxProfile, BOX_BEDROCK_PACK, boxLocalDir, boxLocalProfileFile, @@ -47,8 +46,7 @@ const noPolicy = (profilePath: string): ParsedPolicy => ({ /** * The Box network model of each runtime of `spec` that runs its agent in a box, from the agent's * own local box profile as `resolver` resolves it for a build in `region`. A project with no box - * runtime resolves nothing, and an agent with no local box profile resolves no profile. Throws for - * a project that keeps the one box profile of the earlier layout. + * runtime resolves nothing. Throws, naming the file, for a box runtime with no local box profile. */ export async function readBoxNetworks( spec: ProjectSpec, @@ -58,7 +56,6 @@ export async function readBoxNetworks( ): Promise { const runtimes = spec.runtimes.filter((runtime) => runtimeRunsInBox(spec, runtime)); if (runtimes.length === 0) return []; - assertNoProjectBoxProfile(projectRoot); assertBoxRuntimesHaveProfiles(projectRoot, runtimes); // The model sees the targets build adds for the model and Memory calls, so no host takes a // second target for their endpoints. diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index d598fa5b3..936de5d41 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -1,6 +1,4 @@ -import { existsSync } from "node:fs"; import { join, posix } from "node:path"; -import { ProjectStateError } from "../../../errors/errors"; import { DEFAULT_EGRESS_BEDROCK_REGION, callsBedrockModel, @@ -153,23 +151,6 @@ export function boxLocalProfilePath(projectRoot: string, agentName: string): str return join(projectRoot, boxLocalProfileFile(agentName)); } -/** The one box profile of a project in the layout before each agent had its own. */ -const PROJECT_BOX_PROFILE_FILE = posix.join(BOX_ROOT, "profile.toml"); - -/** - * Throws when the project at `projectRoot` keeps `.box/profile.toml`, the one box profile of the - * earlier layout, which no command reads now. - */ -export function assertNoProjectBoxProfile(projectRoot: string): void { - if (!existsSync(join(projectRoot, ...PROJECT_BOX_PROFILE_FILE.split("/")))) return; - throw new ProjectStateError( - `${PROJECT_BOX_PROFILE_FILE} is the box profile of an earlier layout, and no command reads ` + - `it now: each agent has its own profile, ${boxLocalProfileFile("")}. Move the ` + - "profile and its policy files into that folder of the runtime it runs, then remove " + - `${PROJECT_BOX_PROFILE_FILE}.`, - ); -} - /** * Whether create writes a box profile for this runtime: a box template, CodeZip or container, * which runs its agent in Strands Box. Every other template runs its agent the usual way. From 797024a27c27913f00bb956edbf63ce56388e6f3 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:08:20 -0800 Subject: [PATCH 34/51] fix(box): Leave out a deny entry on the venv, as the venv is the code folder on the Runtime On a CodeZip runtime, the paths rule moves the venv to the code folder. So a local deny = ["${{ workspace }}/app/agent/.venv"] became deny = ["${{ inputs.code.dir }}"] on the Runtime, and the agent could not read its own code. Build gave no message. Quang found this in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). With this change, the paths rule leaves out each deny entry on the venv or in it before it moves the paths, with a warning that names the key and the path. This is the same as for each other protective entry with no place on the Runtime: build leaves it out and warns, and does not stop. A deny_write entry on the venv stays, and moves to the code folder, where it takes away only write access. The rule reads the venv from the paths of the runtime, so it also holds when the local profile names the code folder as ${{ workspace }}. Tests: paths.test.ts "leaves out a deny entry on the venv or in it, with a warning, and keeps deny_write on the venv". --- .../runtimeProfile/rules/paths.test.ts | 25 ++++++++++++ .../project/runtimeProfile/rules/paths.ts | 40 ++++++++++++++++++- 2 files changed, 63 insertions(+), 2 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 0e1a4fd8d..6687d5275 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -100,6 +100,31 @@ const LEAVES_ON_RUNTIME = { }; describe("the paths rule", () => { + test("leaves out a deny entry on the venv or in it, with a warning, and keeps deny_write on the venv", () => { + const text = [ + "[agent.filesystem]", + 'read = ["${{ workspace }}/app/agent"]', + 'deny = ["${{ workspace }}/app/agent/.venv", { path = "${{workspace}}/app/agent/.venv/bin" }]', + 'deny_write = ["${{ workspace }}/app/agent/.venv"]', + ].join("\n"); + + // The paths rule alone: the additions rule removes the deny_write of the template. + const { table, problems, warnings } = apply(parse(text) as TomlTable, contextOf(text)); + + expect(problems).toEqual([]); + const filesystem = (table.agent as TomlTable).filesystem as TomlTable; + expect(filesystem).not.toHaveProperty("deny"); + expect(filesystem.deny_write).toEqual(["${{ inputs.code.dir }}"]); + expect(warnings).toEqual( + ["${{ workspace }}/app/agent/.venv", "${{workspace}}/app/agent/.venv/bin"].map( + (path) => + `[agent.filesystem] deny names ${JSON.stringify(path)}, in the venv. On AgentCore ` + + "Runtime the venv is the code folder, ${{ inputs.code.dir }}, so the entry would keep " + + "the process from its own code. Build leaves it out of the Runtime profile.", + ), + ); + }); + test("leaves out a deny entry and an optional grant that are not on the Runtime, with a warning", () => { const text = [ "[agent.filesystem]", diff --git a/src/core/project/runtimeProfile/rules/paths.ts b/src/core/project/runtimeProfile/rules/paths.ts index 2ebac9bc9..6cc166b14 100644 --- a/src/core/project/runtimeProfile/rules/paths.ts +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -34,7 +34,7 @@ export function apply(table: Readonly, context: RuntimeProfileContext return { table: structuredClone(table) as TomlTable, problems: [], warnings: [] }; } const warnings: string[] = []; - const moved = mapProjectPaths(table, (value) => { + const moved = mapProjectPaths(withoutVenvDeny(table, paths, warnings), (value) => { const result = moveProjectPath(value, paths); return typeof result === "string" ? result : value; }); @@ -57,6 +57,40 @@ export function apply(table: Readonly, context: RuntimeProfileContext return { table: moved, problems: [], warnings }; } +/** + * `table` with no `deny` entry on the venv or in it, with a warning for each: on a CodeZip Runtime + * the venv is the code folder, so such an entry would keep the process from its own code. A + * `deny_write` entry on the venv stays. + */ +function withoutVenvDeny( + table: Readonly, + paths: RuntimePaths, + warnings: string[], +): TomlTable { + const result = structuredClone(table) as TomlTable; + const venv = (path: string) => { + const normal = path.replace(/\$\{\{\s*workspace\s*\}\}/g, "${{ workspace }}"); + return normal === paths.localVenv || normal.startsWith(`${paths.localVenv}/`); + }; + for (const { key, table: process } of processTables(result)) { + const filesystem = process.filesystem; + if (!isTable(filesystem) || !Array.isArray(filesystem.deny)) continue; + const deny = filesystem.deny.filter((grant) => { + const path = grantPath(grant); + if (path === undefined || !venv(path)) return true; + warnings.push( + `${keyLabel([...key, "filesystem", "deny"])} names ${JSON.stringify(path)}, in the venv. ` + + `On AgentCore Runtime the venv is the code folder, ${paths.runtimeCode}, so the entry ` + + "would keep the process from its own code. Build leaves it out of the Runtime profile.", + ); + return false; + }); + if (deny.length > 0) filesystem.deny = deny; + else delete filesystem.deny; + } + return result; +} + /** * `filesystem` with no deny entry and no optional grant whose path is not on the Runtime, with a * warning for each. The refusals rule stops build for each other grant with no place there. A @@ -75,7 +109,7 @@ function withoutLostGrants( result[list] = grants; continue; } - result[list] = grants.filter((grant) => { + const kept = grants.filter((grant) => { const path = grantPath(grant); if (path === undefined || pathProblem(path, paths) === undefined) return true; if (!isDroppableGrant(list, grant)) return true; @@ -85,6 +119,8 @@ function withoutLostGrants( ); return false; }); + // A list that build empties goes. + if (kept.length > 0 || grants.length === 0) result[list] = kept; } return result; } From cbd378c31f01afc2b0edcba68b8e145ce0589e8a Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:08:54 -0800 Subject: [PATCH 35/51] docs(box): Say in the README what a Box project holds after aws/agentcore-cli#2859 The README said that two templates run their agent in a box, and that a Box project holds one runtime, so add runtime and export harness refuse it. Since aws/agentcore-cli#2857 there are seven box templates, and since aws/agentcore-cli#2859 add runtime adds a box runtime to a Box project. The pre-review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this. The paragraph now names the seven templates, says that each runtime has its own box profile, says what add runtime and export harness do in a Box project, and says that build derives the Runtime profile from the local profile. Tests: none; this changes only the README. --- README.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 95ab3190e..6c565f713 100644 --- a/README.md +++ b/README.md @@ -197,12 +197,18 @@ declares, not the ones you add in the stack. ## Running agents in Box (preview) -Two templates run their agent in a box, both under `agentcore dev` and on AgentCore Runtime: -`agent-python-strands-box` (CodeZip) and `agent-python-strands-box-container` (Container). -`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 +Seven templates run their agent in a box, both under `agentcore dev` and on AgentCore Runtime: +the CodeZip templates `agent-python-strands-box`, `agent-python-minimal-box`, +`agent-python-langchain-box`, `a2a-python-strands-box`, `agui-python-strands-box`, and +`mcp-python-fastmcp-box`, and the container template `agent-python-strands-box-container`. +`agentcore create --template ` makes a Box project from one of them; every other template +runs its agent without box. Each runtime of a Box project runs in a box, with its own box profile, +`.box//local/profile.toml`. `agentcore add runtime` adds a Python CodeZip runtime in a box +to a Box project, and refuses a TypeScript runtime and a Bedrock Agent import there. +`agentcore export harness` refuses a Box project. Each box runtime needs its +`"box": { "version": ... }` in `agentcore.json`, which create and add runtime write, and its local +box profile; build and deploy stop without them. Build derives the AgentCore Runtime profile of +each runtime from its local profile. 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. From a4f44a139734bbee28a84bad2d2c23ae55151b8b Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:13:36 -0800 Subject: [PATCH 36/51] refactor(box): Remove dead fields, exports, and copies from the derivation From the pre-review and the review of Leo on [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). No behaviour of build changes, except that an [mcp] server that names a url or destinations and has no command is now an HTTP server for the path rules too, as it was for the gateway rule. - RuntimeProfileContext has no policyFiles: no rule read it. The policies key stays as the local profile has it. - runtimeTools has no branch for a Runtime tool table of the template: the Runtime template has none. - One isHttpServer, in projectPaths.ts, for the gateway rule and the path rules. One RUNTIME_LOGS_HEADERS_ENV, in templates/boxProfile.ts. - These are no longer exports, as only their own module uses them: RUNTIME_PROFILE_RULES, RUNTIME_AWS_STAND_INS, runtimeRegionEnv, OBSERVABILITY_OFF_ENV, ProcessTable, BOX_BASE_PACK, and boxLocalProfileName. - Three comments now say what the code does: the program check of the refusals rule, the summary of the gateway rule, and where the [egress] and [mcp] tables of the Runtime profile go. - Two tests that only compared a constant list are gone: the sequence of the rules, and the list of the box templates. - The comment of the box profile show fixtures says why the fixture of preview.6 names box/base. Tests: the runtimeProfile tests pass (256); typecheck and lint pass. --- src/core/project/boxNetwork/network.ts | 1 - src/core/project/boxProfileResolver.test.ts | 3 +- .../project/runtimeProfile/derive.test.ts | 12 +------- src/core/project/runtimeProfile/derive.ts | 2 +- .../project/runtimeProfile/projectPaths.ts | 12 ++++++-- .../runtimeProfile/rules/additions.test.ts | 28 ++++--------------- .../project/runtimeProfile/rules/additions.ts | 22 ++++++--------- .../runtimeProfile/rules/gateway.test.ts | 2 -- .../project/runtimeProfile/rules/gateway.ts | 14 +++------- .../runtimeProfile/rules/paths.test.ts | 1 - .../runtimeProfile/rules/refusals.test.ts | 1 - .../project/runtimeProfile/rules/refusals.ts | 3 +- src/core/project/runtimeProfile/types.ts | 2 -- src/core/project/templates/boxProfile.ts | 6 ++-- 14 files changed, 36 insertions(+), 73 deletions(-) diff --git a/src/core/project/boxNetwork/network.ts b/src/core/project/boxNetwork/network.ts index c21cbaf86..0843cbd58 100644 --- a/src/core/project/boxNetwork/network.ts +++ b/src/core/project/boxNetwork/network.ts @@ -207,7 +207,6 @@ export function buildBoxNetwork( gateway: { name: project.gateway, targets: project.targets }, hosts: targets.hosts, telemetry: telemetry?.telemetry ?? [], - policyFiles: parsed.profile.policyFiles, places: source.places, }); const derived = source && context && deriveRuntimeProfile(source.table, context); diff --git a/src/core/project/boxProfileResolver.test.ts b/src/core/project/boxProfileResolver.test.ts index 8e48ac958..9cb1def39 100644 --- a/src/core/project/boxProfileResolver.test.ts +++ b/src/core/project/boxProfileResolver.test.ts @@ -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. The first file is the output of preview.6, so its pack has + * the name of that release, box/base; the second has the name of later releases, @box/base. */ const OPEN_ROUTES_SHOWN = Object.entries({ "one string": readFileSync( diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts index d5990ae90..e0048c5a3 100644 --- a/src/core/project/runtimeProfile/derive.test.ts +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -3,7 +3,7 @@ import { parse } from "smol-toml"; import type { ProjectSpec } from "../../../projectSchemas/project"; import type { ProjectRuntime } from "../../../projectSchemas/runtime"; import { profileKeyPlaces, runtimePaths, runtimeProfileContext, runtimeTemplate } from "./context"; -import { deriveRuntimeProfile, RUNTIME_PROFILE_RULES } from "./derive"; +import { deriveRuntimeProfile } from "./derive"; import { keyLabel } from "./projectPaths"; import { serializeRuntimeProfile } from "./serialize"; import type { TomlTable } from "./types"; @@ -29,7 +29,6 @@ const context = (runtime: ProjectRuntime, places = new Map()) => gateway: { name: "agent-box-egress", targets: [] }, hosts: [], telemetry: [], - policyFiles: [], places, }); @@ -43,15 +42,6 @@ const CARRIED: TomlTable = { }; describe("deriveRuntimeProfile", () => { - test("runs the rules in their order: refusals, gateway, additions, then paths", () => { - expect(RUNTIME_PROFILE_RULES.map(({ name }) => name)).toEqual([ - "refusals", - "gateway", - "additions", - "paths", - ]); - }); - test.each([CODEZIP, CONTAINER])( "carries each key that no rule changes as the local profile has it ($build)", (runtime) => { diff --git a/src/core/project/runtimeProfile/derive.ts b/src/core/project/runtimeProfile/derive.ts index 2596018e0..d0d4581c1 100644 --- a/src/core/project/runtimeProfile/derive.ts +++ b/src/core/project/runtimeProfile/derive.ts @@ -27,7 +27,7 @@ import type { * `gateway` and `additions` write Runtime values, which name only the Runtime's inputs. `paths` * runs last, so it moves each path that the user's own keys name, and no Runtime value. */ -export const RUNTIME_PROFILE_RULES: readonly { +const RUNTIME_PROFILE_RULES: readonly { readonly name: string; readonly apply: RuntimeProfileRule; }[] = [ diff --git a/src/core/project/runtimeProfile/projectPaths.ts b/src/core/project/runtimeProfile/projectPaths.ts index 2f9588e60..4a9614035 100644 --- a/src/core/project/runtimeProfile/projectPaths.ts +++ b/src/core/project/runtimeProfile/projectPaths.ts @@ -39,6 +39,12 @@ const NOT_READ: ReadonlySet = new Set([ "telemetry", ]); +/** Whether `entry` is an HTTP MCP server: it has no `command`, and it is `http` or names a host. */ +export function isHttpServer(entry: Readonly): boolean { + if ("command" in entry || entry.type === "stdio") return false; + return entry.type === "http" || "url" in entry || "destinations" in entry; +} + /** A key as a message names it: `[mcp.notes] command`, `[agent.filesystem] read`, `packs`. */ export function keyLabel(key: readonly string[]): string { if (key.length === 1) return key[0]!; @@ -152,7 +158,7 @@ export function mapProjectPaths( result[name] = Object.fromEntries( Object.entries(value).map(([server, entry]) => [ server, - isTable(entry) && entry.type === "http" + isTable(entry) && isHttpServer(entry) ? structuredClone(entry) : mapValue(entry, [name, server], false, move), ]), @@ -184,7 +190,7 @@ function mapValue( } /** A table of a profile that starts one process: `[agent]`, a stdio `[mcp.]`, a `[tool.]`. */ -export interface ProcessTable { +interface ProcessTable { /** `["agent"]`, `["mcp", ""]`, or `["tool", ""]`. */ readonly key: readonly string[]; readonly table: TomlTable; @@ -199,7 +205,7 @@ export function processTables(profile: Readonly): ProcessTable[] { if (name === "agent" && isTable(value)) tables.push({ key: [name], table: value, leaf: false }); if ((name === "mcp" || name === "tool") && isTable(value)) { for (const [entry, table] of Object.entries(value)) { - if (!isTable(table) || (name === "mcp" && table.type === "http")) continue; + if (!isTable(table) || (name === "mcp" && isHttpServer(table))) continue; tables.push({ key: [name, entry], table, leaf: true }); } } diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 81769d787..c6393cbe7 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -70,7 +70,6 @@ function contextOf( options: { memories?: readonly string[]; telemetry?: readonly CloudWatchTelemetry[]; - policyFiles?: readonly string[]; } = {}, ) { const spec = specOf(runtime, options.memories); @@ -85,7 +84,6 @@ function contextOf( }, hosts: [], telemetry: options.telemetry ?? [], - policyFiles: options.policyFiles ?? [], places: new Map(), }); } @@ -212,10 +210,9 @@ describe("deriveRuntimeProfile on the created templates", () => { BUILD_REGION, PROFILE_FILE, ).telemetry; - const policyFiles = extras ? ["policy.dw"] : []; const { profile, problems } = deriveRuntimeProfile( local, - contextOf(runtime, { memories, telemetry, policyFiles }), + contextOf(runtime, { memories, telemetry }), ); const expected = OLD_RENDERER.templates[ @@ -247,18 +244,6 @@ function createdRuntime(input: ScaffoldRuntimeInput): ProjectRuntime { } describe("deriveRuntimeProfile on each box template of create", () => { - test("covers the seven box templates", () => { - expect(BOX_TEMPLATES).toEqual([ - "a2a-python-strands-box", - "agent-python-langchain-box", - "agent-python-minimal-box", - "agent-python-strands-box", - "agent-python-strands-box-container", - "agui-python-strands-box", - "mcp-python-fastmcp-box", - ]); - }); - const cases = BOX_TEMPLATES.flatMap((template) => { const providers = RUNTIME_TEMPLATE_SHORTCUTS[template].supportsModelProviderOverride ? ["of the template", "OpenAI"] @@ -295,11 +280,10 @@ describe("deriveRuntimeProfile on each box template of create", () => { BUILD_REGION, PROFILE_FILE, ).telemetry; - const policyFiles = extras ? ["policy.dw"] : []; const { profile, problems } = deriveRuntimeProfile( local, - contextOf(runtime, { memories, telemetry, policyFiles }), + contextOf(runtime, { memories, telemetry }), ); expect(problems).toEqual([]); @@ -900,10 +884,10 @@ describe("the additions rule", () => { test("keeps the policies list as the local profile names it", () => { const local = { policies: ["./policy.dw", "rules/extra.dw"] }; - expect( - apply(local, contextOf(CODEZIP, { policyFiles: ["policy.dw", "rules/extra.dw"] })).table - .policies, - ).toEqual(["./policy.dw", "rules/extra.dw"]); + expect(apply(local, contextOf(CODEZIP)).table.policies).toEqual([ + "./policy.dw", + "rules/extra.dw", + ]); }); test("writes a header that names the local profile and the Runtime packs", () => { diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index f4c6a93ce..95b3dd51b 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -11,7 +11,7 @@ * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region of the Runtime replaces a region of the user, with a warning; `AWS_PROFILE` goes, with a warning; the AWS stand-ins and (CodeZip) the ffi `PYTHONPATH` come in; each other value of the user stays | * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | - * | `[tool.]` | a table of the template becomes its Runtime table, or goes when the Runtime has none; a table of the user stays | + * | `[tool.]` | a table that the template writes, as it writes it, goes; a table of the user stays | * | `[telemetry.]` | each CloudWatch target that box takes is signed with a bare `aws://`, in the deploy region when it names none; one that box refuses goes; a `file` target goes, with a warning | * | `[telemetry.agentcore]` | added when no target is `cloudwatch_logs`: the runtime's own log group and log stream | * @@ -22,6 +22,7 @@ import { AGENTCORE_PACK_NAME, BOX_BEDROCK_PACK, BOX_CODEZIP_DIST, + RUNTIME_LOGS_HEADERS_ENV, } from "../../templates/boxProfile"; import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; import { isTable } from "../projectPaths"; @@ -50,7 +51,7 @@ const CLOUDWATCH_KINDS: ReadonlySet = new Set(["cloudwatch_logs", "clou * Stand-in AWS keys for boto3 in the box on AgentCore Runtime. They authenticate nothing: each AWS * route goes to the Box gateway, and box signs each call for it with the execution role. */ -export const RUNTIME_AWS_STAND_INS: Readonly> = { +const RUNTIME_AWS_STAND_INS: Readonly> = { AWS_ACCESS_KEY_ID: "box-stand-in", AWS_SECRET_ACCESS_KEY: "box-stand-in", }; @@ -62,9 +63,6 @@ const RUNTIME_ENV_NAMES: ReadonlySet = new Set([ ...Object.keys(RUNTIME_AWS_STAND_INS), ]); -/** The variable in which AgentCore Runtime names the runtime's own log group and log stream. */ -const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; - /** * The CloudWatch Logs target of a Runtime profile that has no `cloudwatch_logs` target: the * runtime's own log group and log stream, in its own region. The runtime ID exists only after @@ -83,7 +81,7 @@ export const DEFAULT_TELEMETRY_TARGET = { * The Runtime's region in the agent's environment, from the @box/agentcore `aws.region` input. * @box/bedrock sets `AWS_REGION` itself, so the profile sets it only without that pack. */ -export function runtimeRegionEnv(bedrock: boolean): Record { +function runtimeRegionEnv(bedrock: boolean): Record { const region = RUNTIME_INPUTS.awsRegion; return { ...(!bedrock && { AWS_REGION: region }), AWS_DEFAULT_REGION: region }; } @@ -92,7 +90,7 @@ export function runtimeRegionEnv(bedrock: boolean): Record { * The variable that turns off the observability of a runtime on AgentCore Runtime. When the envVars * of the runtime set it to `true`, the Runtime profile gets no default log target. */ -export const OBSERVABILITY_OFF_ENV = "DISABLE_ADOT_OBSERVABILITY"; +const OBSERVABILITY_OFF_ENV = "DISABLE_ADOT_OBSERVABILITY"; /** Whether the envVars of `runtime` set {@link OBSERVABILITY_OFF_ENV} to `true`. */ export function observabilityOff(runtime: Pick): boolean { @@ -228,21 +226,17 @@ function runtimeAgent( } /** - * `[tool]` for the Runtime. A `[tool.]` of the template that the local profile keeps as the - * template has it becomes the template's Runtime table, or goes when the Runtime has none: the - * `deny_write` that a CodeZip template gives a tool of @box/base protects the local venv, and the - * Runtime has no venv. Each other tool table stays. An empty `[tool]` goes. + * `[tool]` for the Runtime. A `[tool.]` that the local profile keeps as the template writes + * it goes: the `deny_write` that a CodeZip template gives a tool of @box/base protects the local + * venv, and the Runtime has no venv. Each other tool table stays. An empty `[tool]` goes. */ function runtimeTools(tool: unknown, context: RuntimeProfileContext): unknown { if (!isTable(tool)) return tool; const templateLocal = tableOf(context.template.local.tool); - const templateRuntime = tableOf(context.template.runtime.tool); const result: TomlTable = {}; for (const [name, entry] of Object.entries(tool)) { if (!Object.hasOwn(templateLocal, name) || !sameValue(entry, templateLocal[name])) { result[name] = entry; - } else if (Object.hasOwn(templateRuntime, name)) { - result[name] = structuredClone(templateRuntime[name]); } } return Object.keys(result).length > 0 ? result : undefined; diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index c978874d8..9daa6eaef 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -113,7 +113,6 @@ function contextOf( gateway: { name: GATEWAY, targets }, hosts, telemetry: [], - policyFiles: [], places: profileKeyPlaces(text, PROFILE), }); } @@ -570,7 +569,6 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { gateway: { name: GATEWAY, targets }, hosts: network.hosts, telemetry: [], - policyFiles: network.policyFiles, places: profileKeyPlaces(text, PROFILE), }), ); diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index a4dccf5ed..6a6cd8623 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -3,8 +3,7 @@ * Box gateway. Each passthrough target of that gateway, as build writes the gateway, gets one * route: the box sends the calls to the target's host to `${{ inputs.gateway.url }}/`, and * signs them for the gateway in the Runtime's own region, `${{ inputs.aws.region }}`, with a bare - * `aws://`, the execution role. The - * gateway then calls the host with the target's own auth. + * `aws://`, the execution role. The gateway then calls the host with the target's own auth. * * | Local profile | Runtime profile | * | --- | --- | @@ -22,7 +21,7 @@ import type { AgentCoreGatewayTarget } from "../../../../projectSchemas/gateway" import type { BoxHostSource, BoxNetworkHost } from "../../boxNetwork"; import { BOX_EGRESS_TARGET_PREFIX } from "../../boxNetwork/egress"; import { gatewayTargetFor } from "../../boxNetwork/projectSpec"; -import { isTable } from "../projectPaths"; +import { isHttpServer, isTable } from "../projectPaths"; import { RUNTIME_AWS_SIGNER, RUNTIME_INPUTS, @@ -82,7 +81,8 @@ export function apply(table: Readonly, context: RuntimeProfileContext } } - // The two tables keep their place in the profile, and an empty one goes. + // Each table keeps its place when the profile has it, and comes last when it does not. An empty + // table goes. const result: TomlTable = { ...table, egress, mcp }; if (Object.keys(egress).length === 0) delete result.egress; if (Object.keys(mcp).length === 0) delete result.mcp; @@ -179,12 +179,6 @@ function mcpSourceOf(host: BoxNetworkHost): McpSource | undefined { return host.sources.find((source): source is McpSource => source.kind === "mcp"); } -/** Whether `entry` is an HTTP MCP server: it has no `command`, and it is `http` or names a host. */ -function isHttpServer(entry: Readonly): boolean { - if ("command" in entry || entry.type === "stdio") return false; - return entry.type === "http" || "url" in entry || "destinations" in entry; -} - /** * The `[egress.]` route of `route`, with each key of `entry` that the gateway form does not * set. Its secret goes: the gateway target sends the credential. diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 6687d5275..d8739456d 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -29,7 +29,6 @@ const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => gateway: { name: "agent-box-egress", targets: [] }, hosts: [], telemetry: [], - policyFiles: [], places: profileKeyPlaces(text, PROFILE), }); diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index 3c3d740e1..48bef8d07 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -31,7 +31,6 @@ const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => hosts: [], telemetry: withDeployRegion(cloudWatchTelemetry(parse(text) as TomlTable), "us-west-2", PROFILE) .telemetry, - policyFiles: [], places: profileKeyPlaces(text, PROFILE), }); diff --git a/src/core/project/runtimeProfile/rules/refusals.ts b/src/core/project/runtimeProfile/rules/refusals.ts index 696bb878a..95a343bee 100644 --- a/src/core/project/runtimeProfile/rules/refusals.ts +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -149,7 +149,8 @@ export function apply(table: Readonly, context: RuntimeProfileContext } } for (const { key, table: process, leaf } of processTables(table)) { - // The command of the template moves to the Runtime's Python. A command of the user stays. + // The command of the template starts the venv's Python, which moves to the Runtime's Python, + // so only a command of the user can start another program. const command = programOf(process); const searched = leaf && typeof process.program === "string" ? process.program : undefined; for (const [name, program] of [ diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts index 616da997b..1b3d4604d 100644 --- a/src/core/project/runtimeProfile/types.ts +++ b/src/core/project/runtimeProfile/types.ts @@ -68,8 +68,6 @@ export interface RuntimeProfileContext { readonly hosts: readonly BoxNetworkHost[]; /** The CloudWatch targets of the local profile, with the deploy region set. */ readonly telemetry: readonly CloudWatchTelemetry[]; - /** The local profile's policy files, from its folder, which staging copies beside it. */ - readonly policyFiles: readonly string[]; readonly paths: RuntimePaths; /** * The profile that `agentcore create` writes for this runtime, `local`, and its Runtime form, diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index 936de5d41..a7c542ec3 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -49,10 +49,10 @@ const BOX_CODE_ENV = "BOX_CODE"; * The variable in which AgentCore Runtime names the runtime's own log group and log stream, as * `x-aws-log-group=,x-aws-log-stream=`, with other keys. */ -const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; +export const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; /** The pack of box that each box profile imports. */ -export const BOX_BASE_PACK = "@box/base"; +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"; @@ -142,7 +142,7 @@ export function boxLocalProfileFile(agentName: string): string { } /** The `[profile] name` of an agent's local box profile: the project's name, then the agent's. */ -export function boxLocalProfileName(projectName: string, agentName: string): string { +function boxLocalProfileName(projectName: string, agentName: string): string { return `${projectName}-${agentName}`; } From fa622c81e17a02bece7f5b0ec97f2830155be552 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:16:17 -0800 Subject: [PATCH 37/51] fix(box): Keep the code folder in the Runtime PYTHONPATH of the agent and of each leaf On a CodeZip Runtime, the dependencies are in the code folder, and not in a venv. When the local profile set its own PYTHONPATH, for example "${{ workspace }}/app/agent/lib", the derived PYTHONPATH had the ffi shim and that entry, but not the code folder, so `import strands` failed when the agent started. Quang found this in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). With this change, the paths rule, after it moves the paths, gives the PYTHONPATH of [agent], and of each stdio server or tool that runs the Runtime Python, each entry one time, in its order, and adds ${{ inputs.code.dir }} at the end when the PYTHONPATH does not name it. For a leaf, the ffi shim comes first; the additions rule puts it first for [agent]. Two local entries that move to one Runtime path, as the code folder and its venv do, become one entry. aws/agentcore-cli#2867 removes the ffi shim from these lines. The PR that merges second keeps the code folder. Tests: paths.test.ts "keeps the code folder in the PYTHONPATH of [agent] and of a leaf on the Runtime Python, one time". --- .../runtimeProfile/rules/paths.test.ts | 21 ++++++++++++++++ .../project/runtimeProfile/rules/paths.ts | 25 +++++++++++++++---- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index d8739456d..459fe9845 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -99,6 +99,27 @@ const LEAVES_ON_RUNTIME = { }; describe("the paths rule", () => { + test("keeps the code folder in the PYTHONPATH of [agent] and of a leaf on the Runtime Python, one time", () => { + const text = [ + "[agent.env]", + 'PYTHONPATH = "${{ workspace }}/app/agent/lib"', + "[mcp.notes]", + 'type = "stdio"', + 'command = ["${{ workspace }}/app/agent/.venv/bin/python3.15", "-m", "notes"]', + 'env = { PYTHONPATH = "/opt/lib:${{ workspace }}/app/agent:${{ workspace }}/app/agent/.venv" }', + ].join("\n"); + + const { profile } = deriveRuntimeProfile(parse(text) as TomlTable, contextOf(text)); + + // The Runtime installs the dependencies in the code folder, so without it no import works. + expect(((profile.agent as TomlTable).env as TomlTable).PYTHONPATH).toBe( + "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}/lib:${{ inputs.code.dir }}", + ); + expect((((profile.mcp as TomlTable).notes as TomlTable).env as TomlTable).PYTHONPATH).toBe( + "${{ inputs.code.dir }}/.box-dist/ffi:/opt/lib:${{ inputs.code.dir }}", + ); + }); + test("leaves out a deny entry on the venv or in it, with a warning, and keeps deny_write on the venv", () => { const text = [ "[agent.filesystem]", diff --git a/src/core/project/runtimeProfile/rules/paths.ts b/src/core/project/runtimeProfile/rules/paths.ts index 6cc166b14..45f3c6ab9 100644 --- a/src/core/project/runtimeProfile/rules/paths.ts +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -44,19 +44,34 @@ export function apply(table: Readonly, context: RuntimeProfileContext withoutLostGrants(process.filesystem, key, paths, warnings), ); } - if (!leaf || programOf(process) !== paths.runtimePython) continue; + // The additions rule gives [agent] its PYTHONPATH; a leaf gets one when it runs that Python. + if (leaf && programOf(process) !== paths.runtimePython) continue; const env = isTable(process.env) ? process.env : {}; const own = env.PYTHONPATH; - const ffi = runtimeFfiPath(paths); if (own === undefined) { - process.env = { ...env, PYTHONPATH: runtimePythonPath(paths) }; - } else if (typeof own === "string" && !own.split(":").includes(ffi)) { - process.env = { ...env, PYTHONPATH: `${ffi}:${own}` }; + if (leaf) process.env = { ...env, PYTHONPATH: runtimePythonPath(paths) }; + } else if (typeof own === "string") { + process.env = { ...env, PYTHONPATH: withRuntimePythonPath(own, paths, leaf) }; } } return { table: moved, problems: [], warnings }; } +/** + * The `PYTHONPATH` `own` of a process that runs the Runtime's Python, with each entry one time in + * its order, and the code folder, where the Runtime installs the dependencies, at the end when + * `own` does not name it. For a leaf, the `_ctypes` folder that deploy stages comes first; the + * additions rule puts it first for `[agent]`. + */ +function withRuntimePythonPath(own: string, paths: RuntimePaths, leaf: boolean): string { + const ffi = runtimeFfiPath(paths); + const entries = [...new Set(own.split(":").filter((entry) => entry !== ""))]; + const ordered = leaf ? [ffi, ...entries.filter((entry) => entry !== ffi)] : entries; + return [...ordered, ...(ordered.includes(paths.runtimeCode) ? [] : [paths.runtimeCode])].join( + ":", + ); +} + /** * `table` with no `deny` entry on the venv or in it, with a warning for each: on a CodeZip Runtime * the venv is the code folder, so such an entry would keep the process from its own code. A From 77d250e154401187b519a3625f65895a1f071af7 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:42:00 -0800 Subject: [PATCH 38/51] test(box): Run start.py main on both ways to read policies, and keep policies on one line Varun asked in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) to keep staged_policies of aws/agentcore-cli#2862 with box_python, and to make sure that the derived Runtime profile writes `policies` on one line. On Python 3.10 there is no tomllib, and staged_policies reads that line as a JSON list. - boxStartPy.test.ts runs main() of start.py with its folders in a temporary folder and os.execve replaced. It checks the box that main() runs and its arguments, that BOX_PYTHON is what box_python gives, and that the profile and each policy file are copied. It runs one time with tomllib and one time with tomllib set to None, as on Python 3.10. This test replaces the test that read the text of start.py. - derive.test.ts checks that serializeRuntimeProfile writes 30 policy files on one line, and that the line reads as a JSON list. Tests: the two tests pass with python3 3.9.6 on the PATH. A manual run of main() gave the same copies with Python 3.10.21 (no tomllib), 3.12.14 (tomllib), and 3.9.6 (no tomllib). --- .../project/runtimeProfile/derive.test.ts | 10 +++ src/core/project/templates/boxStartPy.test.ts | 76 +++++++++++++++++-- 2 files changed, 80 insertions(+), 6 deletions(-) diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts index 1661ee759..e62f5866e 100644 --- a/src/core/project/runtimeProfile/derive.test.ts +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -172,4 +172,14 @@ describe("serializeRuntimeProfile", () => { expect(text.startsWith("# Rendered by agentcore build.\n")).toBe(true); expect(parse(text)).toEqual(profile); }); + + test("writes policies on one line, which start.py reads as a JSON list on Python 3.10", () => { + const policies = Array.from({ length: 30 }, (_, index) => `rules/policy-file-${index}.dw`); + + const text = serializeRuntimeProfile({ packs: ["@box/base"], policies }); + + const line = /^policies = (\[.*\])$/m.exec(text); + expect(line).not.toBeNull(); + expect(JSON.parse(line![1]!)).toEqual(policies); + }); }); diff --git a/src/core/project/templates/boxStartPy.test.ts b/src/core/project/templates/boxStartPy.test.ts index 7abc61fd1..a831d3f84 100644 --- a/src/core/project/templates/boxStartPy.test.ts +++ b/src/core/project/templates/boxStartPy.test.ts @@ -4,7 +4,6 @@ import { chmodSync, mkdirSync, mkdtempSync, - readFileSync, realpathSync, rmSync, symlinkSync, @@ -62,13 +61,78 @@ function boxPython(executable: string): string { return out.stdout.trim(); } -describe("start.py BOX_PYTHON", () => { - test("exports the Python of box_python to box, not sys.executable", () => { - const text = readFileSync(join(START_PY, "start.py"), "utf8"); - - expect(text).toContain('"BOX_PYTHON": box_python(sys.executable, sys.version_info),'); +/** + * What start.py's main() does in `root`, with its folders there and os.execve replaced: the box it + * runs, its arguments, the BOX_PYTHON it exports and what box_python gives, and the files it copies + * into the profile folder. `withTomllib` false runs it as Python 3.10 does, with no tomllib. + */ +function startRun(root: string, withTomllib: boolean) { + const script = [ + "import json, os, sys", + "sys.path.insert(0, sys.argv[1]); import start", + "root = sys.argv[2]", + "start.DIST = os.path.join(root, 'dist'); start.BOX = os.path.join(start.DIST, 'box')", + "start.HOME = os.path.join(root, 'home'); start.WORKSPACE = os.path.join(root, 'ws')", + "start.PROFILE_DIR = os.path.join(root, 'profile')", + "start.PROFILE = os.path.join(start.PROFILE_DIR, 'profile.toml')", + ...(withTomllib ? [] : ["start.tomllib = None"]), + "def execve(path, argv, env):", + " copied = sorted(os.path.relpath(os.path.join(d, f), start.PROFILE_DIR)", + " for d, _, fs in os.walk(start.PROFILE_DIR) for f in fs)", + " print(json.dumps({'path': path, 'argv': argv, 'python': env['BOX_PYTHON'],", + " 'expected': start.box_python(sys.executable, sys.version_info),", + " 'copied': copied}))", + " sys.exit(0)", + "start.os.execve = execve", + "start.main()", + ].join("\n"); + const out = spawnSync("python3", ["-I", "-B", "-c", script, START_PY, root], { + encoding: "utf8", }); + expect(out.stderr).toBe(""); + return JSON.parse(out.stdout) as { + path: string; + argv: string[]; + python: string; + expected: string; + copied: string[]; + }; +} +describe("start.py main", () => { + test.skipIf(skipped).each([ + ["with tomllib", true], + ["as Python 3.10 does, with no tomllib", false], + ])( + "copies the profile and each policy file, and exports the Python of box_python (%s)", + (_label, withTomllib) => { + const root = mkdtempSync(join(tmpdir(), "box-start-main-")); + directories.push(root); + mkdirSync(join(root, "dist", "rules"), { recursive: true }); + // As the runtime profile writer writes it: policies on one line. + writeFileSync( + join(root, "dist", "profile.toml"), + 'packs = [ "@box/base" ]\npolicies = [ "policy.dw", "rules/extra.dw" ]\n\n[profile]\nname = "demo"\n', + ); + writeFileSync(join(root, "dist", "policy.dw"), "// rules\n"); + writeFileSync(join(root, "dist", "rules", "extra.dw"), "// extra\n"); + + const run = startRun(root, withTomllib); + + expect(run.path).toBe(join(root, "dist", "box")); + expect(run.argv).toEqual([ + "box", + "run", + join(root, "profile", "profile.toml"), + "--no-banner", + ]); + expect(run.python).toBe(run.expected); + expect(run.copied).toEqual(["policy.dw", "profile.toml", join("rules", "extra.dw")]); + }, + ); +}); + +describe("start.py BOX_PYTHON", () => { test.skipIf(skipped)("keeps a Python whose name box does not alias", () => { const bin = binFolder(["python3.12"]); From 664e074c1d1258d4a7de6df7401be40f8155cecc Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:44:07 -0800 Subject: [PATCH 39/51] fix(box): Listen on the port of the protocol on the Runtime, whatever the local port The additions rule kept the port of an [[agent.ingress]] that the user changed, for example listen = "127.0.0.1:8090", and only moved it to 0.0.0.0. AgentCore Runtime sends the requests of a protocol only to the port of that protocol (8080 for HTTP), so the agent got no request. Quang found this in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). This reverses the earlier choice to keep a port that the user changed. With this change, the first ingress of the Runtime profile listens on 0.0.0.0: (boxIngressPort), for CodeZip and for a container. It forwards to the workload port of the template when the agent keeps the command and the port variable of the template, because the Runtime form of the template starts the agent on the same port as the local form. Else it forwards to its own workload_port, where the agent of the user listens under agentcore dev too. Build gives a warning for each port that changes. Each other ingress listens on 0.0.0.0 on its own port, as before. Tests: additions.test.ts "listens on the port of the protocol on the Runtime when the user changed the local port, and says so" and "forwards to the workload port of the template while the agent keeps its command, and else to the port of the user". The created templates give the same ingress as before. --- .../runtimeProfile/rules/additions.test.ts | 32 +++++++++ .../project/runtimeProfile/rules/additions.ts | 67 +++++++++++++++---- 2 files changed, 85 insertions(+), 14 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 3206197b4..2565ae820 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -649,6 +649,38 @@ describe("the additions rule", () => { }); }); + test("listens on the port of the protocol on the Runtime when the user changed the local port, and says so", () => { + const local = createdProfile(CODEZIP); + agentOf(local).ingress = [{ listen: "127.0.0.1:8090", workload_port: 8081 }]; + + const { table, warnings } = apply(local, contextOf(CODEZIP)); + + expect(agentOf(table).ingress).toEqual([{ listen: "0.0.0.0:8080", workload_port: 8081 }]); + expect(warnings).toEqual([ + `[[agent.ingress]] listen is "127.0.0.1:8090" in ${PROFILE_FILE}. AgentCore Runtime sends ` + + "the HTTP requests only to port 8080, so the Runtime profile listens on 0.0.0.0:8080.", + ]); + }); + + test("forwards to the workload port of the template while the agent keeps its command, and else to the port of the user", () => { + const template = createdProfile(CODEZIP); + agentOf(template).ingress = [{ listen: "127.0.0.1:8080", workload_port: 9001 }]; + const own = structuredClone(template); + agentOf(own).command = ["${{ workspace }}/.venv/bin/python", "serve.py", "--port", "9001"]; + + const kept = apply(template, contextOf(CODEZIP)); + const moved = apply(own, contextOf(CODEZIP)); + + expect(agentOf(kept.table).ingress).toEqual([{ listen: "0.0.0.0:8080", workload_port: 8081 }]); + expect(kept.warnings).toEqual([ + `[[agent.ingress]] workload_port is 9001 in ${PROFILE_FILE}, but the agent keeps the ` + + "command and the port of the template, so on AgentCore Runtime it listens on 8081. The " + + "Runtime profile forwards there.", + ]); + expect(agentOf(moved.table).ingress).toEqual([{ listen: "0.0.0.0:8080", workload_port: 9001 }]); + expect(moved.warnings).toEqual([]); + }); + test("gives the template's ingress its Runtime ingress, and puts each other on 0.0.0.0", () => { const local = createdProfile(CODEZIP); agentOf(local).ingress.push({ listen: "127.0.0.1:9100", workload_port: 9101 }); diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 95b3dd51b..cbd1be766 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -10,7 +10,7 @@ * | `[agent] command` | the template's own command becomes its Runtime command; a command of the user loses `--reload` and `--reload-dir ` | * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region of the Runtime replaces a region of the user, with a warning; `AWS_PROFILE` goes, with a warning; the AWS stand-ins and (CodeZip) the ffi `PYTHONPATH` come in; each other value of the user stays | * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | - * | `[[agent.ingress]]` | each listen address is `0.0.0.0`, on its own port | + * | `[[agent.ingress]]` | the first listens on `0.0.0.0` on the port of the protocol, and forwards to the workload port of the template when the agent keeps its command and port, with a warning for each port that changes; each other listens on `0.0.0.0` on its own port | * | `[tool.]` | a table that the template writes, as it writes it, goes; a table of the user stays | * | `[telemetry.]` | each CloudWatch target that box takes is signed with a bare `aws://`, in the deploy region when it names none; one that box refuses goes; a `file` target goes, with a warning | * | `[telemetry.agentcore]` | added when no target is `cloudwatch_logs`: the runtime's own log group and log stream | @@ -22,6 +22,8 @@ import { AGENTCORE_PACK_NAME, BOX_BEDROCK_PACK, BOX_CODEZIP_DIST, + boxIngressPort, + boxWorkloadPort, RUNTIME_LOGS_HEADERS_ENV, } from "../../templates/boxProfile"; import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; @@ -220,7 +222,11 @@ function runtimeAgent( ); if (filesystem !== undefined) result.filesystem = filesystem; if (local.ingress !== undefined) { - result.ingress = runtimeIngress(local.ingress, templateLocal.ingress, templateRuntime.ingress); + const variable = PORT_ENV[context.runtime.protocol ?? "HTTP"] ?? "PORT"; + const keepsTemplatePort = + sameValue(local.command, templateLocal.command) && + sameValue(tableOf(local.env)[variable], tableOf(templateLocal.env)[variable]); + result.ingress = runtimeIngress(local.ingress, keepsTemplatePort, context, warnings); } return result; } @@ -376,24 +382,57 @@ const pathOf = (grant: unknown): unknown => const includesPath = (list: readonly unknown[], grant: unknown) => list.some((other) => sameValue(pathOf(other), pathOf(grant))); +/** The variable that names the port of the agent of a template, for each protocol. */ +const PORT_ENV: Readonly> = { + HTTP: "PORT", + AGUI: "PORT", + A2A: "A2A_PORT", + MCP: "FASTMCP_PORT", +}; + /** - * Each `[[agent.ingress]]` for the Runtime: the template's own ingress becomes its Runtime ingress, - * and each other one listens on `0.0.0.0` on its own port, as the Runtime reaches the microVM there. + * Each `[[agent.ingress]]` for the Runtime. AgentCore Runtime sends the requests of the protocol + * only to its port (boxIngressPort), so the first ingress listens on `0.0.0.0:`. It + * forwards to the workload port of the template when the agent keeps the command and the port + * variable of the template: the Runtime form of the template starts the agent on the same port as + * the local form. Else it forwards to its own `workload_port`, where the agent of the user listens + * under dev too. Each other ingress listens on `0.0.0.0` on its own port. A warning names each port + * that changes. */ function runtimeIngress( ingress: unknown, - templateLocal: unknown, - templateRuntime: unknown, + agentKeepsTemplatePort: boolean, + context: RuntimeProfileContext, + warnings: string[], ): unknown { - if (isTable(ingress)) return onAllAddresses(ingress); - if (!Array.isArray(ingress)) return ingress; - const localEntries = listOf(templateLocal); - const runtimeEntries = listOf(templateRuntime); - return ingress.map((entry: unknown) => { - const index = localEntries.findIndex((other) => sameValue(other, entry)); - const runtime = index >= 0 ? runtimeEntries[index] : undefined; - return runtime !== undefined ? structuredClone(runtime) : onAllAddresses(entry); + const entries = isTable(ingress) ? [ingress] : Array.isArray(ingress) ? ingress : undefined; + if (entries === undefined) return ingress; + const protocol = context.runtime.protocol ?? "HTTP"; + const port = boxIngressPort(protocol); + const listen = `0.0.0.0:${port}`; + const result = entries.map((entry: unknown, index) => { + if (index > 0 || !isTable(entry)) return onAllAddresses(entry); + const workload = agentKeepsTemplatePort ? boxWorkloadPort(protocol) : entry.workload_port; + const localPort = + typeof entry.listen === "string" ? /:(\d+)$/.exec(entry.listen)?.[1] : undefined; + if (localPort !== undefined && Number(localPort) !== port) { + warnings.push( + `[[agent.ingress]] listen is ${JSON.stringify(entry.listen)} in ${context.profileFile}. ` + + `AgentCore Runtime sends the ${protocol} requests only to port ${port}, so the Runtime ` + + `profile listens on ${listen}.`, + ); + } + if (workload !== entry.workload_port) { + warnings.push( + `[[agent.ingress]] workload_port is ${String(entry.workload_port)} in ` + + `${context.profileFile}, but the agent keeps the command and the port of the template, ` + + `so on AgentCore Runtime it listens on ${String(workload)}. The Runtime profile forwards ` + + "there.", + ); + } + return { ...entry, listen, workload_port: workload }; }); + return isTable(ingress) ? result[0] : result; } /** An ingress whose `listen` is `0.0.0.0:`. */ From 07449584ce7d28aa7159024a6f59c58c83a0e1a1 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:46:57 -0800 Subject: [PATCH 40/51] fix(box): Name the route of the first host of an entry after the entry 737e1079 named the route of an entry after the entry only when the entry had one host. With packs = ["@box/anthropic"] and a local [egress.anthropic] for api.anthropic.com and statsig.anthropic.com, each route had the name of its target, so the [egress.anthropic] of the pack for api.anthropic.com stayed beside the route to that host, and box refused the two routes. Quang found this in the review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866). With this change, the route of the first host of an entry has the name of the entry, and each other host of the entry has a route with the name of its target. box merges the table of the pack with the route of the same name, and takes the destinations of the profile. box 0.1.11-linux-preview.7 on macOS (box profile show), with packs = ["@box/base", "@box/anthropic"]: with two routes named after their targets, box refuses the profile ("`egress-anthropic-api-anthropic-com` and `anthropic` both name host "api.anthropic.com""). With the route of the first host or of the second host named anthropic, box accepts it. Tests: gateway.test.ts "names the route of the first host of an entry of a pack after the entry, and each other after its target". The test of an entry with several hosts, and the comparisons with the old renderer, expect [egress.models] for the first host. --- .../runtimeProfile/rules/gateway.test.ts | 38 ++++++++++++++++--- .../project/runtimeProfile/rules/gateway.ts | 14 ++++--- 2 files changed, 41 insertions(+), 11 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index e621c22a3..68cdb2eba 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -215,6 +215,32 @@ describe("the gateway rule", () => { }, ); + test("names the route of the first host of an entry of a pack after the entry, and each other after its target", () => { + const { table } = gateway( + 'packs = ["@box/base", "@box/anthropic"]\n' + + '[egress.anthropic]\ndestinations = ["api.anthropic.com", "statsig.anthropic.com"]\n', + [ + host("api.anthropic.com", entry("anthropic", "api.anthropic.com"), "egress-anthropic-api"), + host( + "statsig.anthropic.com", + entry("anthropic", "statsig.anthropic.com"), + "egress-anthropic-statsig", + ), + ], + ); + + // box merges the [egress.anthropic] of the pack with the route of that name, and takes the + // destinations of the profile, so api.anthropic.com gets no second route. + expect(table.egress).toEqual( + parse( + '[egress.anthropic]\ndestinations = ["api.anthropic.com"]\n' + + backendText("egress.anthropic", "egress-anthropic-api") + + '[egress.egress-anthropic-statsig]\ndestinations = ["statsig.anthropic.com"]\n' + + backendText("egress.egress-anthropic-statsig", "egress-anthropic-statsig"), + ).egress, + ); + }); + test("names a route after its target when a target of the entry's name serves another host", () => { const { table } = gateway( '[egress.orders]\ndestinations = ["api.example.com"]\n', @@ -245,8 +271,9 @@ describe("the gateway rule", () => { expect(table.egress).toEqual( parse( - '[egress.egress-models-one]\ndestinations = ["api.one.example.com"]\n' + - backendText("egress.egress-models-one", "egress-models-one") + + // The first host keeps the name of the entry; its backend names the target. + '[egress.models]\ndestinations = ["api.one.example.com"]\n' + + backendText("egress.models", "egress-models-one") + // The route keeps the port of the target's endpoint, and no path. '[egress.egress-models-two]\ndestinations = ["api.two.example.com:8443"]\n' + backendText("egress.egress-models-two", "egress-models-two"), @@ -439,13 +466,14 @@ function rendered(label: string): TomlTable { /** * The `[egress]` routes of the old renderer under the keys that the gateway rule gives them: the - * old renderer named each route after its target, and the rule names the route of an entry with one - * host after the entry, so that a pack table of that name merges with it. The routes are the same. + * old renderer named each route after its target, and the rule names the route of the first host of + * an entry after the entry, so that a pack table of that name merges with it. The routes are the + * same. */ const withEntryKeys = (egress: unknown) => Object.fromEntries( Object.entries(egress as TomlTable).map(([key, route]) => [ - key === "egress-github" ? "github" : key, + { "egress-github": "github", "egress-models-api-one-example-com": "models" }[key] ?? key, route, ]), ); diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index 6a6cd8623..9082f0bfb 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -7,8 +7,8 @@ * * | Local profile | Runtime profile | * | --- | --- | - * | `[egress.]` with one host that has a target | `[egress.]`, the other keys kept, no `secret`, a backend to its target | - * | `[egress.]` with several hosts, or whose name a target of another host has | `[egress.]` for each host with a target, the other keys kept, no `secret` | + * | `[egress.]`, its first host with a target | `[egress.]`, the other keys kept, no `secret`, a backend to its target | + * | `[egress.]`, each other host with a target, or a name that a target of another host has | `[egress.]`, the other keys kept, no `secret` | * | HTTP `[mcp.]` | `[mcp.]`, the other keys kept, only an `env://` secret | * | a target that no entry of the profile names | `[egress.]`, or the `[mcp]` server it serves | * | an entry whose hosts the policy denies | removed; the Box network model warns for it | @@ -141,8 +141,8 @@ function gatewayRoutes(context: RuntimeProfileContext): GatewayRoute[] { } /** - * The key of the `[egress]` route of `route`: the name of the one entry whose one host the route - * serves, else the name of the target. A pack that the profile imports keeps its own + * The key of the `[egress]` route of `route`: the name of its entry when the route serves the first + * host of one entry, else the name of the target. A pack that the profile imports keeps its own * `[egress.]` on the Runtime, and box merges it with the route of that name, as * `[egress.bedrock]` of @box/bedrock does. A route under another name would be a second route to * the host, which box refuses. A target of the same name for another host keeps its name. @@ -161,8 +161,10 @@ function routeKey( const entries = [...new Set(served.flatMap(entriesOf))]; if (entries.length !== 1) return route.target; const name = entries[0]!; - const hosts = context.hosts.filter((host) => entriesOf(host).includes(name)); - if (hosts.length !== 1) return route.target; + // The first host of the entry: a pack's own entry of that name merges with it, and the profile's + // destinations replace the pack's, so no host of the pack's entry keeps a second route. + const first = context.hosts.find((host) => entriesOf(host).includes(name)); + if (first?.target !== route.target) return route.target; if (name !== route.target && routes.some(({ target }) => target === name)) return route.target; return name; } From 0a00f77f155a23b4976fb52590edcbf7ff41bf65 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 21:47:41 -0800 Subject: [PATCH 41/51] docs(box): Give the guide each change, stop, and warning of the derivation The guide did not have the changes of this batch to the derivation, and it did not say that box refuses, under agentcore dev, a stdio server or a tool that the venv Python runs. The pre-review of [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) asked for this. The guide now says how the routes get their names, what the agent env and the ingress get on the Runtime, which values stop build and which give a warning, and that a CodeZip local profile needs [project] access = "read" to run a stdio server or a tool on the venv Python: box 0.1.11-linux-preview.7 refuses it with "write", which the templates write. Tests: none; this changes only the guide. --- docs/box-local-testing.md | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index 3bf86fc3b..463c5b5f1 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -136,10 +136,13 @@ the generated packs, and the policy files into `.box//aws/` for you to - **The AgentCore Runtime profile.** Build derives `.box-dist/profile.toml` from the local profile. Each key of the local profile stays, and build changes only what must differ on AgentCore Runtime: - - each `[egress]` host with a gateway target becomes one `[egress.]` route to - `-box-egress`, and an HTTP `[mcp.]` server gets the same gateway backend; - - the agent command, env, filesystem and ingress get their Runtime values (no `--reload`, no - `LOCAL_DEV`, the deployed region, listen on `0.0.0.0`); + - each `[egress]` host with a gateway target becomes one route to `-box-egress`: the + first host of an entry keeps the name of the entry, so a pack's own entry of that name merges + with it, and each other host gets `[egress.]`; an HTTP `[mcp.]` server gets the + same gateway backend; + - the agent command, env, filesystem and ingress get their Runtime values: no `--reload`, no + `LOCAL_DEV`, no `AWS_PROFILE`, the region of the Runtime in place of your own, and the first + ingress on `0.0.0.0` on the port of the protocol; - for CodeZip, each path of the code folder moves to the unpacked zip, and the venv's Python to the Runtime's Python, in every table: the agent, each stdio `[mcp.]` server, each `[tool.]`; @@ -157,14 +160,20 @@ the generated packs, and the policy files into `.box//aws/` for you to local profile. `agentcore create` and `agentcore add runtime` give this notice for each box runtime. - Build stops, and names the key and its line, for a value that cannot work on the Runtime: a path - of the project outside the code folder, a home path (`${{ home }}`, `~`, `/Users`, `/home`), a - CodeZip program of the agent, a stdio server, or a tool outside the code folder, a CodeZip write - grant in the code folder, `network.contain_egress = false`, or a telemetry target that is not - CloudWatch. The route of an `[egress]` entry with one host keeps the name of the entry, so a - pack's own entry of that name merges with it. Each policy file + Build stops, and names the key and its line, for a value that cannot work on the Runtime: a + required grant or a command path in the project outside the code folder, in the venv, or in a + home folder (`${{ home }}`, `~`, `/Users`, `/home`); a CodeZip program that `PATH` finds, such as + `npx`; a CodeZip write grant in the code folder; `network.contain_egress = false`; a CloudWatch + target that box refuses; or a telemetry target that is not CloudWatch or `file`. Build warns, and + goes on, for what the Runtime does without: a `deny` entry or an optional grant with no place + there, a `deny` entry on the venv (the venv is the code folder on the Runtime), a `file` telemetry + target, and a program at an absolute path of the system, which build cannot see. Each policy file is copied beside the profile, byte for byte. + Under `agentcore dev`, the CodeZip templates give the box `[project] access = "write"`, and box + then refuses a stdio server or a tool whose program is the venv's Python ("a link out of a folder + the box can write"). To run one, set `access = "read"` in `[project]` of the local profile. + - **No-auth targets need a newer L3.** A passthrough target with no outbound auth synthesizes only with an `@aws/agentcore-cdk` that accepts it. Until that release is pinned, use a local L3 build, as in step 5. From 9637a938352379b084843cdb157c0c42c55a11d9 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:17:36 -0800 Subject: [PATCH 42/51] feat(box): Name the first box that reads the profiles, and say so when an earlier box refuses one The profile resolver told the user to install "box or a later release". It gave no hint when a box before 0.1.11-linux-preview.7 refused an `@box/` pack with `"@box/base" is not a pack name`. The user then got only "Fix what Box reports". This commit takes the same change from [aws/agentcore-cli#2867](https://github.com/aws/agentcore-cli/pull/2867), so that the PR that merges second has a small conflict: [52c2cf6e](https://github.com/aws/agentcore-cli/commit/52c2cf6e6e4d1a085f8b9601777336f704d8a8e2), with the test changes of [6508ade3](https://github.com/aws/agentcore-cli/commit/6508ade323e786ca2cf9a6d2811bbeab32433fae) and [7543e1ed](https://github.com/aws/agentcore-cli/commit/7543e1ed8f313f8d90e1ba8678b406f4be949a49). The boxRelease.json part of 52c2cf6e was in this branch before. - `BOX_MINIMUM_VERSION` is 0.1.11-linux-preview.7, the first box that reads the `@box/` packs and the `key` of a list input. - `BOX_RELEASE_PAGE` is the release page of the pinned box. - `BOX_INSTALL_HINT` and the install hints of the resolver use them. - When a box refuses an `@box/` pack, the resolver says that the box is earlier than `BOX_MINIMUM_VERSION`, and gives the hint. Tests: boxRelease.test.ts examines that the pin is at least `BOX_MINIMUM_VERSION` with semver, and the asset, the SHA-256, and the page of the pin. boxProfileResolver.test.ts examines each hint, and "says to install the pinned box when a box older than preview.7 refuses an @box/ pack". --- src/core/project/backends/boxRelease.test.ts | 15 +++++++ src/core/project/backends/boxRelease.ts | 12 +++++- src/core/project/boxProfileResolver.test.ts | 42 +++++++++++++------- src/core/project/boxProfileResolver.ts | 33 ++++++++------- 4 files changed, 71 insertions(+), 31 deletions(-) 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 50da7b43e..bec507c16 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.7 or a later release " + - "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7)"; +/** 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. The first file is the output of preview.6, so its pack has - * the name of that release, box/base; the second has the name of later releases, @box/base. + * 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,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 ` + - `${PINNED}, then retry.`, + `Box printed the profile .box/profile.toml without ${lacks}, which build reads. ` + INSTALL, ), ); }); @@ -316,6 +315,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/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/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}`, + ); + }); + test("says to run uv sync in the agent's folder when Box refuses its missing .venv", async () => { const error = await failure( refusal([ @@ -350,11 +368,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.7 " + - "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7), " + - "then retry.", - ), + new InvalidEnvironmentError(`Box is not installed or not on PATH. ${INSTALL}`), ); }); @@ -389,8 +403,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 49e29b520..ec902cfaa 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 { @@ -45,11 +45,11 @@ export interface BoxProfileResolver { ): 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)'/; @@ -111,7 +111,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 }, ); } @@ -158,15 +158,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 }, ); } @@ -180,13 +179,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 6ce736315eedd35d77b31e8ef0e253973c6080ec Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:24:10 -0800 Subject: [PATCH 43/51] feat(box): Run CodeZip agents on the Runtime with no ffi shim ## Problem Build downloaded the ffi shim (box-ffi-python3.14, release 0.1.11-linux-preview.2), staged it in `.box-dist/ffi`, and put it first in the Runtime `PYTHONPATH` of the agent and of each leaf on the Runtime Python. The shim was necessary because Box Core refused executable memory on Linux. box 0.1.11-mquang.preview.9 has Box Core 78e752b0, with [strands-agents/box#488](https://github.com/strands-agents/box/pull/488), so the Python of the Runtime runs in a box with no shim. ## Solution This commit has the shim removal of [aws/agentcore-cli#2867](https://github.com/aws/agentcore-cli/pull/2867) ([e8069dda](https://github.com/aws/agentcore-cli/commit/e8069dda99e8eedb45685b1fda3f88b476126d0f) and [baa1fe09](https://github.com/aws/agentcore-cli/commit/baa1fe0970c709b0874b06db2e5205249ec5fb15)), so that the PR that merges second has a small conflict: - `boxRelease.json` pins only `box`. `FFI_RELEASE`, its cache, and its download go. `bump-box-release.ts` accepts only `--box`. - `stageBoxCodeZip` stages no `ffi` folder, and `.box-dist` names no `ffi` folder. - The README says what the zip contains with no shim. The part of e8069dda in `runtimeCodeZipRunner` is not necessary here, because the derivation gives the Runtime `PYTHONPATH`. The derivation changes as follows: - The additions rule adds no shim. An `[agent]` with no `PYTHONPATH` gets the code folder on CodeZip. - The paths rule adds no shim at the start for a leaf. It keeps each entry one time, and keeps the code folder at the end of the `PYTHONPATH` of `[agent]` and of each leaf on the Runtime Python. The template tables of `old-renderer-tables.json` are recorded again from the renderer of aws/agentcore-cli#2867 at f40ebce7. Only the 102 `PYTHONPATH` values change, to `${{ inputs.code.dir }}`. ## Tests - additions.test.ts: "keeps a PYTHONPATH of the user as it is, on CodeZip and on a container", "gives an [agent] with no PYTHONPATH the code folder on CodeZip, and none on a container", and the tests on the recorded tables. - paths.test.ts: "keeps the code folder in the PYTHONPATH of [agent] and of a leaf on the Runtime Python, one time", and "ends a leaf's own PYTHONPATH with the code folder, and adds none to [agent] or a leaf with no Python". - boxCodeZip.test.ts and boxRelease.test.ts, as in aws/agentcore-cli#2867. --- README.md | 19 +- 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 | 13 +- 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 - .../__fixtures__/old-renderer-tables.json | 204 +++++++++--------- .../project/runtimeProfile/projectPaths.ts | 13 +- .../runtimeProfile/rules/additions.test.ts | 43 ++-- .../project/runtimeProfile/rules/additions.ts | 18 +- .../runtimeProfile/rules/paths.test.ts | 22 +- .../project/runtimeProfile/rules/paths.ts | 18 +- 15 files changed, 202 insertions(+), 452 deletions(-) diff --git a/README.md b/README.md index 6c565f713..b1e3b1eed 100644 --- a/README.md +++ b/README.md @@ -212,21 +212,15 @@ each runtime from its local profile. box comes from the public GitHub release `v [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`, @@ -240,8 +234,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 f25f86a4a..bd476d08e 100644 --- a/src/core/project/backends/boxCodeZip.test.ts +++ b/src/core/project/backends/boxCodeZip.test.ts @@ -36,23 +36,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( @@ -85,8 +76,8 @@ async function project( } 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, [model([])], async () => build)).toEqual(["agent"]); @@ -102,7 +93,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 the one build derived from the local profile. const { runtimeProfile, runtimeProfileHeader } = model([]); expect(await readFile(join(dist, "profile.toml"), "utf8")).toBe( @@ -129,7 +119,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)[] = []; @@ -142,17 +132,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, [model([])], 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 c323f95d7..2f2e7b7a7 100644 --- a/src/core/project/backends/boxCodeZip.ts +++ b/src/core/project/backends/boxCodeZip.ts @@ -18,12 +18,11 @@ export const BOX_DIST_GITIGNORE = /** * 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, @@ -69,8 +68,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 56dbc3c2f..31fe49c51 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -402,7 +402,6 @@ const BOX_DIST_NAMES: ReadonlySet = new Set([ "strands-box-sock-alias", "strands-box-contain-trampoline", "resources", - "ffi", "profile.toml", ".gitignore", ]); diff --git a/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json b/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json index 076d48d68..f8f75af16 100644 --- a/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json +++ b/src/core/project/runtimeProfile/__fixtures__/old-renderer-tables.json @@ -33,7 +33,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -112,7 +112,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -197,7 +197,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -280,7 +280,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -359,7 +359,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -444,7 +444,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -521,7 +521,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -595,7 +595,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -675,7 +675,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -753,7 +753,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -827,7 +827,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -907,7 +907,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -977,7 +977,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1044,7 +1044,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1117,7 +1117,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1188,7 +1188,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1255,7 +1255,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1328,7 +1328,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1399,7 +1399,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1466,7 +1466,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1539,7 +1539,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1610,7 +1610,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1677,7 +1677,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1750,7 +1750,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -1827,7 +1827,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -1900,7 +1900,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -1979,7 +1979,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2056,7 +2056,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2129,7 +2129,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2208,7 +2208,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2279,7 +2279,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2347,7 +2347,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2421,7 +2421,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2493,7 +2493,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2561,7 +2561,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2635,7 +2635,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -2713,7 +2713,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -2785,7 +2785,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -2863,7 +2863,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -2939,7 +2939,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3011,7 +3011,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3089,7 +3089,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3159,7 +3159,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3226,7 +3226,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3299,7 +3299,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3370,7 +3370,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3437,7 +3437,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -3510,7 +3510,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -5667,7 +5667,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -5759,7 +5759,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -5857,7 +5857,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -5953,7 +5953,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6062,7 +6062,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6177,7 +6177,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6284,7 +6284,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6371,7 +6371,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6464,7 +6464,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6555,7 +6555,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6659,7 +6659,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6769,7 +6769,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "A2A_PORT": "9001", "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", "PYTHONUTF8": "1", @@ -6891,7 +6891,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -6989,7 +6989,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7093,7 +7093,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7195,7 +7195,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7310,7 +7310,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7431,7 +7431,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7550,7 +7550,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7648,7 +7648,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7752,7 +7752,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7854,7 +7854,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -7969,7 +7969,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8090,7 +8090,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8209,7 +8209,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8307,7 +8307,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8411,7 +8411,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8513,7 +8513,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8628,7 +8628,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8749,7 +8749,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_DEFAULT_REGION": "${{ inputs.aws.region }}", @@ -8862,7 +8862,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -8955,7 +8955,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -9054,7 +9054,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -9151,7 +9151,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -9261,7 +9261,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -9377,7 +9377,7 @@ ], "env": { "PORT": "8081", - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", "AWS_REGION": "${{ inputs.aws.region }}", @@ -10873,7 +10873,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -10964,7 +10964,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11061,7 +11061,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11156,7 +11156,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11264,7 +11264,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11378,7 +11378,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11484,7 +11484,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11570,7 +11570,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11662,7 +11662,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11752,7 +11752,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11855,7 +11855,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -11964,7 +11964,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "PORT": "8081", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -12071,7 +12071,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -12157,7 +12157,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -12249,7 +12249,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -12339,7 +12339,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -12442,7 +12442,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", @@ -12551,7 +12551,7 @@ "main" ], "env": { - "PYTHONPATH": "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + "PYTHONPATH": "${{ inputs.code.dir }}", "FASTMCP_PORT": "8001", "PYTHONUTF8": "1", "PYTHONUNBUFFERED": "1", diff --git a/src/core/project/runtimeProfile/projectPaths.ts b/src/core/project/runtimeProfile/projectPaths.ts index 4a9614035..edbdd3b6f 100644 --- a/src/core/project/runtimeProfile/projectPaths.ts +++ b/src/core/project/runtimeProfile/projectPaths.ts @@ -11,7 +11,6 @@ * | the code folder and each path in it, `[/...]` | `${{ inputs.code.dir }}[/...]` | * | another path of the project, of the home folder, or in the venv | none: a {@link PathProblem} | */ -import { BOX_CODEZIP_DIST } from "../templates/boxProfile"; import type { RuntimePaths, TomlTable } from "./types"; const WORKSPACE = "${{ workspace }}"; @@ -224,18 +223,12 @@ export function isRuntimeProgram(program: string, paths: RuntimePaths): boolean return program === paths.runtimePython || program.startsWith(`${paths.runtimeCode}/`); } -/** The folder of the `_ctypes` that deploy stages for the Runtime's Python. */ -export function runtimeFfiPath(paths: RuntimePaths): string { - return `${paths.runtimeCode}/${BOX_CODEZIP_DIST}/ffi`; -} - /** - * The `PYTHONPATH` of a leaf that runs the Runtime's Python and sets none: the `_ctypes` that - * deploy stages, then the code folder, where the Runtime installs the dependencies that the venv - * held locally. + * The `PYTHONPATH` of a leaf that runs the Runtime's Python and sets none: the code folder, where + * the Runtime installs the dependencies that the venv held locally. */ export function runtimePythonPath(paths: RuntimePaths): string { - return `${runtimeFfiPath(paths)}:${paths.runtimeCode}`; + return paths.runtimeCode; } /** diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 2565ae820..de4437158 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -144,8 +144,10 @@ const TELEMETRY_CASES: Record = { /** * What the Runtime renderer that the derivation replaced wrote: the owned tables for each build and * protocol (`templates`), the whole profile for each box template of create (`boxTemplates`), and - * the gateway fixture. Recorded from renderRuntimeBoxProfile of box-integration (f5503f02), with - * the default telemetry target, before that renderer was deleted. + * the gateway fixture. The gateway fixture is recorded from renderRuntimeBoxProfile of + * box-integration (f5503f02). The two template sets are recorded, with the default telemetry + * target, from the renderer of aws/agentcore-cli#2867 (f40ebce7): box-integration (7252504c) with + * the `@box/` pack names and no ffi shim. */ const OLD_RENDERER = JSON.parse( readFileSync(join(import.meta.dir, "..", "__fixtures__", "old-renderer-tables.json"), "utf8"), @@ -462,7 +464,7 @@ describe("the additions rule", () => { expect(agentOf(apply(local, contextOf(CODEZIP)).table).env).toEqual({ PORT: "8081", - PYTHONPATH: "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + PYTHONPATH: "${{ inputs.code.dir }}", PYTHONUTF8: "1", PYTHONUNBUFFERED: "1", AWS_DEFAULT_REGION: "${{ inputs.aws.region }}", @@ -533,31 +535,26 @@ describe("the additions rule", () => { expect(other.AWS_DEFAULT_REGION).toBe("${{ inputs.aws.region }}"); }); - test("puts the ffi shim first in a PYTHONPATH of the user on CodeZip, and not on a container", () => { + test("keeps a PYTHONPATH of the user as it is, on CodeZip and on a container", () => { const env = { PYTHONPATH: "${{ workspace }}/app/agent/lib" }; - expect(agentOf(apply({ agent: { env } }, contextOf(CODEZIP)).table).env.PYTHONPATH).toBe( - "${{ inputs.code.dir }}/.box-dist/ffi:${{ workspace }}/app/agent/lib", - ); - expect(agentOf(apply({ agent: { env } }, contextOf(CONTAINER)).table).env.PYTHONPATH).toBe( - "${{ workspace }}/app/agent/lib", - ); - }); - - test("adds no second ffi entry to a PYTHONPATH that starts with the ffi shim", () => { - for (const path of [ - "${{ inputs.code.dir }}/.box-dist/ffi", - "${{ inputs.code.dir }}/.box-dist/ffi:${{ workspace }}/app/agent/lib", - ]) { - const env = { PYTHONPATH: path }; - - expect(agentOf(apply({ agent: { env } }, contextOf(CODEZIP)).table).env.PYTHONPATH).toBe( - path, + for (const runtime of [CODEZIP, CONTAINER]) { + expect(agentOf(apply({ agent: { env } }, contextOf(runtime)).table).env.PYTHONPATH).toBe( + "${{ workspace }}/app/agent/lib", ); } }); - test("sets the region, the AWS stand-ins, and the ffi PYTHONPATH whatever the template's Runtime env", () => { + test("gives an [agent] with no PYTHONPATH the code folder on CodeZip, and none on a container", () => { + expect(agentOf(apply({ agent: {} }, contextOf(CODEZIP)).table).env.PYTHONPATH).toBe( + "${{ inputs.code.dir }}", + ); + expect(agentOf(apply({ agent: {} }, contextOf(CONTAINER)).table).env).not.toHaveProperty( + "PYTHONPATH", + ); + }); + + test("sets the region, the AWS stand-ins, and the PYTHONPATH of the code folder whatever the template's Runtime env", () => { const openAi = runtimeOf("CodeZip", "HTTP", "OpenAI"); const context = contextOf(openAi); const runtime = structuredClone(context.template.runtime); @@ -573,7 +570,7 @@ describe("the additions rule", () => { AWS_DEFAULT_REGION: "${{ inputs.aws.region }}", AWS_ACCESS_KEY_ID: "box-stand-in", AWS_SECRET_ACCESS_KEY: "box-stand-in", - PYTHONPATH: "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}", + PYTHONPATH: "${{ inputs.code.dir }}", }); }); }); diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index cbd1be766..572a92b71 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -8,7 +8,7 @@ * | `[profile] name` | the project's name | * | `[options] bedrock.region` | the build region, where the profile sets it or imports @box/bedrock | * | `[agent] command` | the template's own command becomes its Runtime command; a command of the user loses `--reload` and `--reload-dir ` | - * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region of the Runtime replaces a region of the user, with a warning; `AWS_PROFILE` goes, with a warning; the AWS stand-ins and (CodeZip) the ffi `PYTHONPATH` come in; each other value of the user stays | + * | `[agent.env]` | a template value becomes its Runtime value; `LOCAL_DEV` goes; the region of the Runtime replaces a region of the user, with a warning; `AWS_PROFILE` goes, with a warning; the AWS stand-ins and (CodeZip) a `PYTHONPATH` of the code folder come in; each other value of the user stays | * | `[agent.filesystem]` | the template's grants become its Runtime grants; each grant of the user stays | * | `[[agent.ingress]]` | the first listens on `0.0.0.0` on the port of the protocol, and forwards to the workload port of the template when the agent keeps its command and port, with a warning for each port that changes; each other listens on `0.0.0.0` on its own port | * | `[tool.]` | a table that the template writes, as it writes it, goes; a table of the user stays | @@ -21,7 +21,6 @@ import { AGENTCORE_CODEZIP_PACK_NAME, AGENTCORE_PACK_NAME, BOX_BEDROCK_PACK, - BOX_CODEZIP_DIST, boxIngressPort, boxWorkloadPort, RUNTIME_LOGS_HEADERS_ENV, @@ -269,8 +268,8 @@ function withoutReload(command: unknown): unknown { * `[agent.env]` for the Runtime. A variable of the template that the local profile keeps with the * template's value gets its Runtime value, or goes when the Runtime has none. A variable that only * the Runtime has comes in, unless the user sets it. A variable of the user stays. `LOCAL_DEV` - * goes, whatever its value. This rule sets the region and the AWS stand-ins itself. On CodeZip, - * `PYTHONPATH` starts with the ffi shim. + * goes, whatever its value. This rule sets the region and the AWS stand-ins itself. On CodeZip, an + * agent with no `PYTHONPATH` gets the code folder, where the Runtime installs the dependencies. */ function runtimeEnv( env: unknown, @@ -319,15 +318,8 @@ function runtimeEnv( if (Object.hasOwn(result, name) || ofTemplate(name)) continue; result[name] = value; } - if (context.paths.build === "CodeZip") { - // The ffi shim that deploy stages: its libffi uses static trampolines, which W^X allows. - const code = context.paths.runtimeCode; - const shim = `${code}/${BOX_CODEZIP_DIST}/ffi`; - const path = result.PYTHONPATH; - if (path === undefined) result.PYTHONPATH = `${shim}:${code}`; - else if (typeof path === "string" && path.split(":")[0] !== shim) { - result.PYTHONPATH = `${shim}:${path}`; - } + if (context.paths.build === "CodeZip" && result.PYTHONPATH === undefined) { + result.PYTHONPATH = context.paths.runtimeCode; } return result; } diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 98392d673..90ae8ed5b 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -51,7 +51,7 @@ const APP = "${{ workspace }}/app/agent"; const CODE = "${{ inputs.code.dir }}"; const PYTHON = "${{ inputs.python.path }}"; const PREFIX = "${{ inputs.python.prefix }}"; -const PYTHONPATH = `${CODE}/.box-dist/ffi:${CODE}`; +const PYTHONPATH = CODE; /** A local profile with a stdio MCP server and a tool, each with a key build does not know. */ const LEAVES = toml( @@ -118,10 +118,10 @@ describe("the paths rule", () => { // The Runtime installs the dependencies in the code folder, so without it no import works. expect(((profile.agent as TomlTable).env as TomlTable).PYTHONPATH).toBe( - "${{ inputs.code.dir }}/.box-dist/ffi:${{ inputs.code.dir }}/lib:${{ inputs.code.dir }}", + "${{ inputs.code.dir }}/lib:${{ inputs.code.dir }}", ); expect((((profile.mcp as TomlTable).notes as TomlTable).env as TomlTable).PYTHONPATH).toBe( - "${{ inputs.code.dir }}/.box-dist/ffi:/opt/lib:${{ inputs.code.dir }}", + "/opt/lib:${{ inputs.code.dir }}", ); }); @@ -241,7 +241,7 @@ describe("the paths rule", () => { }); }); - test("puts the _ctypes folder in front of a leaf's own PYTHONPATH, and adds none to [agent] or a leaf with no Python", () => { + test("ends a leaf's own PYTHONPATH with the code folder, and adds none to [agent] or a leaf with no Python", () => { const table = moved( toml( "[agent]", @@ -261,37 +261,35 @@ describe("the paths rule", () => { notes: { type: "stdio", command: [PYTHON, "-m", "notes"], - env: { PYTHONPATH: `${CODE}/.box-dist/ffi:${CODE}/src:${CODE}` }, + env: { PYTHONPATH: `${CODE}/src:${CODE}` }, }, }, tool: { lister: { command: [`${CODE}/bin/lister`] } }, }); }); - test("moves each project path of a path list behind the _ctypes entry, and keeps that entry", () => { - // The additions rule puts the _ctypes folder in front of the user's own [agent] PYTHONPATH. - const ffi = `${CODE}/.box-dist/ffi`; + test("moves each project path of a path list, and keeps an entry that names a Runtime input", () => { const text = toml( "[agent]", 'command = ["${{ inputs.python.path }}", "-m", "main"]', "[agent.env]", - `PYTHONPATH = "${ffi}:${APP}/src:${APP}"`, + `PYTHONPATH = "${PREFIX}/lib:${APP}/src:${APP}"`, "[mcp.notes]", 'type = "stdio"', `command = ["${APP}/.venv/bin/python3.15", "-m", "notes"]`, - `env = { PYTHONPATH = "${ffi}:${APP}/lib:${APP}" }`, + `env = { PYTHONPATH = "${PREFIX}/lib:${APP}/lib:${APP}" }`, ); expect(moved(text)).toEqual({ agent: { command: [PYTHON, "-m", "main"], - env: { PYTHONPATH: `${ffi}:${CODE}/src:${CODE}` }, + env: { PYTHONPATH: `${PREFIX}/lib:${CODE}/src:${CODE}` }, }, mcp: { notes: { type: "stdio", command: [PYTHON, "-m", "notes"], - env: { PYTHONPATH: `${ffi}:${CODE}/lib:${CODE}` }, + env: { PYTHONPATH: `${PREFIX}/lib:${CODE}/lib:${CODE}` }, }, }, }); diff --git a/src/core/project/runtimeProfile/rules/paths.ts b/src/core/project/runtimeProfile/rules/paths.ts index 45f3c6ab9..8593ea27e 100644 --- a/src/core/project/runtimeProfile/rules/paths.ts +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -6,9 +6,9 @@ * in each key that can hold a path (projectPaths.ts): the `[agent]` command, env, and filesystem * lists, and each key of each stdio `[mcp.]` and `[tool.]`. Then each filesystem list * has one grant for each path. A leaf that runs the Runtime's Python gets the `PYTHONPATH` of the - * code folder when it sets none, and the `_ctypes` folder in front of a `PYTHONPATH` of its own, as - * the additions rule does for `[agent]`. Each entry of a path list moves, and an entry that names a - * Runtime input stays. The refusals rule stops build for a path that has no place on the + * code folder when it sets none, as the additions rule does for `[agent]`. A `PYTHONPATH` of its + * own, and the one of `[agent]`, keep each entry one time and end with the code folder. Each entry + * of a path list moves, and an entry that names a Runtime input stays. The refusals rule stops build for a path that has no place on the * Runtime, so this rule keeps such a path as it is. runtimeCodeZipRunner (templates/boxProfile.ts) * gives the Runtime grants of the template in the local paths, and this rule moves them too. */ @@ -22,7 +22,6 @@ import { pathProblem, processTables, programOf, - runtimeFfiPath, runtimePythonPath, withOneGrantForEachPath, } from "../projectPaths"; @@ -51,7 +50,7 @@ export function apply(table: Readonly, context: RuntimeProfileContext if (own === undefined) { if (leaf) process.env = { ...env, PYTHONPATH: runtimePythonPath(paths) }; } else if (typeof own === "string") { - process.env = { ...env, PYTHONPATH: withRuntimePythonPath(own, paths, leaf) }; + process.env = { ...env, PYTHONPATH: withRuntimePythonPath(own, paths) }; } } return { table: moved, problems: [], warnings }; @@ -60,14 +59,11 @@ export function apply(table: Readonly, context: RuntimeProfileContext /** * The `PYTHONPATH` `own` of a process that runs the Runtime's Python, with each entry one time in * its order, and the code folder, where the Runtime installs the dependencies, at the end when - * `own` does not name it. For a leaf, the `_ctypes` folder that deploy stages comes first; the - * additions rule puts it first for `[agent]`. + * `own` does not name it. */ -function withRuntimePythonPath(own: string, paths: RuntimePaths, leaf: boolean): string { - const ffi = runtimeFfiPath(paths); +function withRuntimePythonPath(own: string, paths: RuntimePaths): string { const entries = [...new Set(own.split(":").filter((entry) => entry !== ""))]; - const ordered = leaf ? [ffi, ...entries.filter((entry) => entry !== ffi)] : entries; - return [...ordered, ...(ordered.includes(paths.runtimeCode) ? [] : [paths.runtimeCode])].join( + return [...entries, ...(entries.includes(paths.runtimeCode) ? [] : [paths.runtimeCode])].join( ":", ); } From 853a8a56ad4aff54c4106f660242b5b92604b627 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:26:04 -0800 Subject: [PATCH 44/51] build(box): Pin box 0.1.11-mquang.preview.9, and give a box for a machine that it has no build for ## Problem The CLI pinned box 0.1.11-linux-preview.7. Its Box Core refused executable memory on Linux, so the ffi shim was necessary for a CodeZip agent. The previous commit removes the shim. The user selected [box 0.1.11-mquang.preview.9](https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-mquang.preview.9): staging-boxy b0846169 with [strands-agents/staging-boxy#549](https://github.com/strands-agents/staging-boxy/pull/549), on Box Core 78e752b0 with [strands-agents/box#488](https://github.com/strands-agents/box/pull/488). It does not have strands-agents/box#537. That release has only the Linux arm64 build. Each install hint named only the release page of the pin, so on macOS the hint gave a page with no build for the machine. ## Solution - `bun scripts/bump-box-release.ts --box 0.1.11-mquang.preview.9` wrote `boxRelease.json` from the SHA256SUMS.txt of the release. The file is the same as in [3934bbed](https://github.com/aws/agentcore-cli/commit/3934bbeda2380e5ff9d86117ad8630382bbf301a) of [aws/agentcore-cli#2867](https://github.com/aws/agentcore-cli/pull/2867). - `BOX_MINIMUM_RELEASE_PAGE` is the release page of `BOX_MINIMUM_VERSION` (0.1.11-linux-preview.7), which has a macOS build. - `BOX_OTHER_MACHINE_HINT` says to use that box, or a subsequent release with a build for the machine, when the pinned release has none. `BOX_INSTALL_HINT` and each install hint of the profile resolver end with it. - The local box is not compared to the pin. A macOS box 0.1.11-linux-preview.7 on PATH stays correct for `agentcore dev` and for the profile checks of build. - The README, the guide, and the comment on the tools of `@box/base` name the new pin. The packs of preview.9 are the same as the packs of preview.7, so `@box/base` has one tool, `uname`. ## Tests - boxRelease.test.ts: "box is at least the first release that reads the profiles the CLI writes" (semver sorts 0.1.11-mquang.preview.9 after 0.1.11-linux-preview.7), and "the install hint names the pinned release, and the first release for a machine it has no build for". - boxProfileResolver.test.ts: each install hint of the resolver. - The SHA-256 of the archive that curl downloaded into a new empty folder agreed with SHA256SUMS.txt (5b0f8802fb1c5cbc22db4bfcefc9061e048e931c972584350ebce6c1b15da884). A `diff -r` of the resources of preview.7 and preview.9 found no difference. --- README.md | 8 +++++--- docs/box-local-testing.md | 6 ++++-- src/core/project/backends/boxRelease.json | 6 +++--- src/core/project/backends/boxRelease.test.ts | 13 +++++++++++++ src/core/project/backends/boxRelease.ts | 17 +++++++++++++++-- src/core/project/boxProfileResolver.test.ts | 6 +++++- src/core/project/boxProfileResolver.ts | 9 +++++++-- src/core/project/templates/boxProfile.ts | 2 +- 8 files changed, 53 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b1e3b1eed..18605dc28 100644 --- a/README.md +++ b/README.md @@ -208,9 +208,11 @@ to a Box project, and refuses a TypeScript runtime and a Bedrock Agent import th `agentcore export harness` refuses a Box project. Each box runtime needs its `"box": { "version": ... }` in `agentcore.json`, which create and add runtime write, and its local box profile; build and deploy stop without them. Build derives the AgentCore Runtime profile of -each runtime from its local profile. box comes from the public GitHub release `v0.1.11-linux-preview.7` of +each runtime from its local profile. 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. +is needed to download it. That release has only the Linux arm64 build that ships to AgentCore +Runtime. For `agentcore dev` and the profile checks of `build` on macOS, install the macOS build of +`v0.1.11-linux-preview.7`, or of a later release that has one. `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 ` @@ -253,7 +255,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.7`. 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/docs/box-local-testing.md b/docs/box-local-testing.md index 463c5b5f1..c2dc340b5 100644 --- a/docs/box-local-testing.md +++ b/docs/box-local-testing.md @@ -21,8 +21,10 @@ Runtime. Each box runtime names its box release in `agentcore.json` with container they write the release and its checksum into `.box-dist/box-release.env` instead. A container image downloads the Linux build while it builds, under `agentcore dev` too. For a CodeZip agent, `agentcore dev` runs the `box` on your PATH: download the build for your machine -from the release, unpack it into a folder, and add that folder to your PATH. No local box checkout -is needed. +from the release, unpack it into a folder, and add that folder to your PATH. The pinned release, +`0.1.11-mquang.preview.9`, has only the Linux arm64 build. On macOS, use the macOS build of +`0.1.11-linux-preview.7`, the first box that reads the profiles the CLI writes, or of a later release. +No local box checkout is needed. Dev, build and deploy run a runtime's agent in a box only when `agentcore.json` has `"projectType": "box"` and the runtime has `"box": { "version": ... }`. `create` writes both, and 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" } } } diff --git a/src/core/project/backends/boxRelease.test.ts b/src/core/project/backends/boxRelease.test.ts index 4a5db242b..a66c228b2 100644 --- a/src/core/project/backends/boxRelease.test.ts +++ b/src/core/project/backends/boxRelease.test.ts @@ -9,6 +9,7 @@ import { InvalidEnvironmentError } from "../../../errors/errors"; import { type ProcessRunner, runProcess } from "../../../io/exec"; import { gte } from "semver"; import { + BOX_INSTALL_HINT, BOX_MINIMUM_VERSION, BOX_RELEASE, BOX_RELEASE_PAGE, @@ -227,4 +228,16 @@ describe("the pinned releases", () => { `https://github.com/mquang-amazon/box-releases/releases/tag/v${BOX_RELEASE.version}`, ); }); + + test("the install hint names the pinned release, and the first release for a machine it has no build for", () => { + // 0.1.11-mquang.preview.9 has only the Linux arm64 build; 0.1.11-linux-preview.7 has macOS too. + expect(BOX_INSTALL_HINT).toBe( + "Install box: download the build for your machine from " + + `https://github.com/mquang-amazon/box-releases/releases/tag/v${BOX_RELEASE.version}, unpack it ` + + "into a folder (tar -xzf -C ), and add that folder to your PATH. When that " + + "release has no build for your machine, use box 0.1.11-linux-preview.7 " + + "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7) or a " + + "later release that has one.", + ); + }); }); diff --git a/src/core/project/backends/boxRelease.ts b/src/core/project/backends/boxRelease.ts index d7b78fda6..aefb54e93 100644 --- a/src/core/project/backends/boxRelease.ts +++ b/src/core/project/backends/boxRelease.ts @@ -44,6 +44,18 @@ 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}`; +/** + * The GitHub release page of {@link BOX_MINIMUM_VERSION}, which has a macOS build. A local box runs + * only `agentcore dev` and the profile checks of build, so a box of this release or a later one + * does, also when the pinned release has only the Linux arm64 build that ships to AgentCore Runtime. + */ +export const BOX_MINIMUM_RELEASE_PAGE = `https://github.com/${BOX_RELEASE.repo}/releases/tag/v${BOX_MINIMUM_VERSION}`; + +/** What to install when the pinned release has no build for the machine. */ +export const BOX_OTHER_MACHINE_HINT = + `When that release has no build for your machine, use box ${BOX_MINIMUM_VERSION} ` + + `(${BOX_MINIMUM_RELEASE_PAGE}) or a later release that has one.`; + /** Where a release's asset downloads from: the public GitHub release, no token needed. */ export function boxReleaseAssetUrl( release: Pick, @@ -61,11 +73,12 @@ export const BOX_BINARIES = [ /** * How to install the `box` that `agentcore dev` runs a CodeZip box agent with, which create and - * dev ask for when it is not on PATH. The release has a build for each machine it supports. + * dev ask for when it is not on PATH. */ 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 folder (tar -xzf -C ), and add that folder to your PATH. " + + BOX_OTHER_MACHINE_HINT; /** A Linux arm64 box for AgentCore Runtime. */ export type BoxLinuxBuild = { diff --git a/src/core/project/boxProfileResolver.test.ts b/src/core/project/boxProfileResolver.test.ts index bec507c16..db877f739 100644 --- a/src/core/project/boxProfileResolver.test.ts +++ b/src/core/project/boxProfileResolver.test.ts @@ -97,7 +97,11 @@ const SHOWN_POLICY = boxReachRules("mcp", "docs", ["docs.example.com"]); /** 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.`; +const INSTALL = + `Install box ${BOX_RELEASE.version} (https://github.com/mquang-amazon/box-releases/releases/tag/v${BOX_RELEASE.version}), then retry. ` + + "When that release has no build for your machine, use box 0.1.11-linux-preview.7 " + + "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.7) or a later " + + "release that has one."; /** * `box profile show open --format json --full` for a profile with the routes `auth` and `github` diff --git a/src/core/project/boxProfileResolver.ts b/src/core/project/boxProfileResolver.ts index ec902cfaa..25ccbfbe1 100644 --- a/src/core/project/boxProfileResolver.ts +++ b/src/core/project/boxProfileResolver.ts @@ -9,7 +9,12 @@ import { z } from "zod"; import { InvalidEnvironmentError } from "../../errors/errors"; import { ProcessFailedError, streamProcess, type ProcessStreamer } from "../../io"; import { resolveExecutable } from "../../io/exec"; -import { BOX_MINIMUM_VERSION, BOX_RELEASE, BOX_RELEASE_PAGE } from "./backends/boxRelease"; +import { + BOX_MINIMUM_VERSION, + BOX_OTHER_MACHINE_HINT, + BOX_RELEASE, + BOX_RELEASE_PAGE, +} from "./backends/boxRelease"; /** A pack of the profile, at the version Box resolves it to. */ export interface BoxPack { @@ -46,7 +51,7 @@ export interface BoxProfileResolver { } /** 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.`; +const INSTALL_BOX = `Install box ${BOX_RELEASE.version} (${BOX_RELEASE_PAGE}), then retry. ${BOX_OTHER_MACHINE_HINT}`; /** 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/; diff --git a/src/core/project/templates/boxProfile.ts b/src/core/project/templates/boxProfile.ts index 1ec3b8563..f52a692bb 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -85,7 +85,7 @@ const ABSOLUTE_PATH_PATTERN = "(/[.]{0,2}[A-Za-z0-9_+-][A-Za-z0-9_.+-]*)+"; /** * 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.7). When the pin moves, check the tools of + * that `boxRelease.json` pins (0.1.11-mquang.preview.9). When the pin moves, check the tools of * @box/base: box refuses a CodeZip box profile if a tool it misses gets the project write grant. */ const BOX_BASE_PROJECT_WRITE_TOOLS = ["uname"]; From 71864dd28b8eb9cdc08ad0b60e36127a75d4936e Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:27:13 -0800 Subject: [PATCH 45/51] test(box): Make the write of agentcore.json fail for each user, root too The test "a failed write of agentcore.json gives no notice of the default log target" made agentcore.json and its folder read-only. On the Linux runner of CI the tests run as root, root writes through the mode bits, and the write was successful. The test also accepted each error. The test gives the manager a ReadWriteJson that refuses the write of agentcore.json and writes each other file. It must get that error, and no warning before it. Tests: the test passes as root in a Linux container and as a usual user on macOS. When `defaultLogTargetNotices` moves before the write in `addResource`, the test fails. --- src/core/project/manager.box.test.ts | 48 +++++++++++++++------------- 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/src/core/project/manager.box.test.ts b/src/core/project/manager.box.test.ts index 1b713a0d6..95dd18b77 100644 --- a/src/core/project/manager.box.test.ts +++ b/src/core/project/manager.box.test.ts @@ -4,6 +4,7 @@ import { tmpdir } from "node:os"; import { dirname, join } from "node:path"; import { existsSync } from "node:fs"; import { InputValidationError, ResourceNotFoundError } from "../../errors/errors"; +import { FsReadWriteJson, type ReadWriteJson } from "../../io"; import type { AddResourceInput, Project } from "../../handlers/project/types"; import { resolveRuntimeTemplateShortcut } from "../../handlers/project/shortcuts"; import { createSilentLogger, TestIdentityClient } from "../../testing"; @@ -32,13 +33,14 @@ afterEach(async () => { ); }); -function subject(): FsProjectManager { +function subject(json?: ReadWriteJson): FsProjectManager { return new FsProjectManager({ logger: createSilentLogger(), identity: new TestIdentityClient(), enableTransactionSearch: async () => {}, runner: async () => {}, checkTool: async () => {}, + ...(json && { json }), }); } @@ -560,30 +562,30 @@ describe("gateway targets in a Box project", () => { }); test("a failed write of agentcore.json gives no notice of the default log target", async () => { - const manager = subject(); - const project = await createdProject(manager); - const agentcore = join(project.rootPath, "agentcore"); - const specFile = join(agentcore, "agentcore.json"); - await chmod(specFile, 0o444); - await chmod(agentcore, 0o555); + const project = await createdProject(subject()); + const specFile = join(project.rootPath, "agentcore", "agentcore.json"); + // The write of agentcore.json fails for each user, root too; each other file is written. + const files = new FsReadWriteJson({ logger: createSilentLogger() }); + const json: ReadWriteJson = { + read: (path, schema) => files.read(path, schema), + write: async (path, data) => { + if (path === specFile) throw new Error(`the test refuses the write of ${path}`); + return files.write(path, data); + }, + }; + const generator = subject(json).addResource(project, { + resourceType: "runtime", + resourceConfig: { name: "search", language: "Python", protocol: "HTTP" }, + } as never); const events: unknown[] = []; - try { - const generator = manager.addResource(project, { - resourceType: "runtime", - resourceConfig: { name: "search", language: "Python", protocol: "HTTP" }, - } as never); - await expect( - (async () => { - for (let next = await generator.next(); !next.done; next = await generator.next()) { - events.push(next.value); - } - })(), - ).rejects.toThrow(); - } finally { - await chmod(agentcore, 0o755); - await chmod(specFile, 0o644); - } + await expect( + (async () => { + for (let next = await generator.next(); !next.done; next = await generator.next()) { + events.push(next.value); + } + })(), + ).rejects.toThrow(`the test refuses the write of ${specFile}`); expect(events.some((event) => (event as { type?: string }).type === "warning")).toBe(false); }); From 5172252f7101ec015f552582d82df708275c28b3 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:30:46 -0800 Subject: [PATCH 46/51] docs(box): Put the doc of assertNotBoxProject on its function again defaultLogTargetNotices went in between the doc of assertNotBoxProject and the function. It comes before that doc in this commit. The review of Leo on [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this. No behavior changes. --- src/core/project/manager.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/core/project/manager.tsx b/src/core/project/manager.tsx index b227de1e4..739919f6a 100644 --- a/src/core/project/manager.tsx +++ b/src/core/project/manager.tsx @@ -2392,10 +2392,6 @@ function ingressPort(text: string): string | undefined { return /^\s*listen\s*=\s*"[^"]*:(\d+)"/m.exec(text)?.[1]; } -/** - * Refuses to export a harness as a runtime into a Box project. Every runtime of a Box project runs - * in a box, and the exported harness runs its agent the usual way. - */ /** * The notice of the default log target (defaultLogTargetNotice) for each runtime of `runtimes` that * runs in a box in `spec`, and that does not turn observability off. @@ -2412,6 +2408,10 @@ function defaultLogTargetNotices( })); } +/** + * Refuses to export a harness as a runtime into a Box project. Every runtime of a Box project runs + * in a box, and the exported harness runs its agent the usual way. + */ function assertNotBoxProject(spec: z.infer, what: string): void { if (!isBoxProject(spec)) return; throw new ProjectStateError( From cc139a755dec7d32c5346e076491ccf5a8dc0495 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:30:47 -0800 Subject: [PATCH 47/51] fix(box): Give no workload_port warning when the local ingress sets no workload_port When the first `[[agent.ingress]]` of the local profile had no `workload_port` and the agent kept the command of the template, the additions rule said "workload_port is undefined". The user wrote nothing that changes, so the rule gives no warning for it. The review of Leo on [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this. Tests: additions.test.ts "gives no workload_port warning when the local first ingress sets none and the agent keeps the template command". --- .../project/runtimeProfile/rules/additions.test.ts | 10 ++++++++++ src/core/project/runtimeProfile/rules/additions.ts | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index de4437158..5e5445d7e 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -678,6 +678,16 @@ describe("the additions rule", () => { expect(moved.warnings).toEqual([]); }); + test("gives no workload_port warning when the local first ingress sets none and the agent keeps the template command", () => { + const local = createdProfile(CODEZIP); + agentOf(local).ingress = [{ listen: "127.0.0.1:8080" }]; + + const { table, warnings } = apply(local, contextOf(CODEZIP)); + + expect(agentOf(table).ingress).toEqual([{ listen: "0.0.0.0:8080", workload_port: 8081 }]); + expect(warnings).toEqual([]); + }); + test("gives the template's ingress its Runtime ingress, and puts each other on 0.0.0.0", () => { const local = createdProfile(CODEZIP); agentOf(local).ingress.push({ listen: "127.0.0.1:9100", workload_port: 9101 }); diff --git a/src/core/project/runtimeProfile/rules/additions.ts b/src/core/project/runtimeProfile/rules/additions.ts index 572a92b71..085f5042b 100644 --- a/src/core/project/runtimeProfile/rules/additions.ts +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -389,7 +389,7 @@ const PORT_ENV: Readonly> = { * variable of the template: the Runtime form of the template starts the agent on the same port as * the local form. Else it forwards to its own `workload_port`, where the agent of the user listens * under dev too. Each other ingress listens on `0.0.0.0` on its own port. A warning names each port - * that changes. + * of the local profile that changes. */ function runtimeIngress( ingress: unknown, @@ -414,7 +414,8 @@ function runtimeIngress( `profile listens on ${listen}.`, ); } - if (workload !== entry.workload_port) { + // A workload_port that the local profile does not set is no change of the user's. + if (entry.workload_port !== undefined && workload !== entry.workload_port) { warnings.push( `[[agent.ingress]] workload_port is ${String(entry.workload_port)} in ` + `${context.profileFile}, but the agent keeps the command and the port of the template, ` + From ed0e4b03608e6ea85c4289f8a4235ea7d21d28c4 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:30:48 -0800 Subject: [PATCH 48/51] fix(box): Name the route after the entry from the first host of the entry that has a target routeKey took the first host of the entry, also when that host had no target, for example a host that the policy denies. Then each route of the entry got the name of its target, and the collision with an entry of a pack, such as `[egress.anthropic]` of `@box/anthropic`, came back. The rule takes the first host of the entry that has a target. The review of Leo on [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) found this. Tests: gateway.test.ts "names the route of the first host of an entry that has a target after the entry, when an earlier host has none". The test fails when the rule takes a host with no target. --- .../project/runtimeProfile/rules/gateway.test.ts | 16 ++++++++++++++++ src/core/project/runtimeProfile/rules/gateway.ts | 4 +++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index 68cdb2eba..0397a6679 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -241,6 +241,22 @@ describe("the gateway rule", () => { ); }); + test("names the route of the first host of an entry that has a target after the entry, when an earlier host has none", () => { + const { table } = gateway( + 'packs = ["@box/base", "@box/anthropic"]\n' + + '[egress.anthropic]\ndestinations = ["denied.anthropic.com", "api.anthropic.com"]\n', + [ + host("denied.anthropic.com", entry("anthropic", "denied.anthropic.com")), + host("api.anthropic.com", entry("anthropic", "api.anthropic.com"), "egress-anthropic-api"), + ], + ); + + // A route of another name to api.anthropic.com would collide with the entry of the pack. + const egress = table.egress as Record; + expect(Object.keys(egress)).toEqual(["anthropic"]); + expect(egress.anthropic!.destinations).toEqual(["api.anthropic.com"]); + }); + test("names a route after its target when a target of the entry's name serves another host", () => { const { table } = gateway( '[egress.orders]\ndestinations = ["api.example.com"]\n', diff --git a/src/core/project/runtimeProfile/rules/gateway.ts b/src/core/project/runtimeProfile/rules/gateway.ts index 9082f0bfb..321e267b6 100644 --- a/src/core/project/runtimeProfile/rules/gateway.ts +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -163,7 +163,9 @@ function routeKey( const name = entries[0]!; // The first host of the entry: a pack's own entry of that name merges with it, and the profile's // destinations replace the pack's, so no host of the pack's entry keeps a second route. - const first = context.hosts.find((host) => entriesOf(host).includes(name)); + const first = context.hosts.find( + (host) => host.target !== undefined && entriesOf(host).includes(name), + ); if (first?.target !== route.target) return route.target; if (name !== route.target && routes.some(({ target }) => target === name)) return route.target; return name; From f9227970ec461a9594fa7971a91272fefa81aaa9 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:30:48 -0800 Subject: [PATCH 49/51] test(box): Stage no Runtime [mcp] server for an HTTP MCP server whose key build cannot find Only the `[egress]` side of withoutUnsentRoutes had a test. A new test builds a project with an HTTP `[mcp.tools]` server with an `env://` key that is not set, and examines that the staged Runtime profile has no `[mcp]` table. The doc of `BoxNetwork.runtimeProfile` says that the model can name a route that the staged file does not have. The review of Leo on [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) asked for the two. Tests: manager.boxNetwork.test.ts "stages no Runtime [mcp] server for an HTTP MCP server whose key build cannot find". The test fails when the writer removes only `[egress]` routes. --- src/core/project/boxNetwork/network.ts | 3 ++- src/core/project/manager.boxNetwork.test.ts | 26 +++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/src/core/project/boxNetwork/network.ts b/src/core/project/boxNetwork/network.ts index d0771ace2..74dec491e 100644 --- a/src/core/project/boxNetwork/network.ts +++ b/src/core/project/boxNetwork/network.ts @@ -124,7 +124,8 @@ export interface BoxNetwork { /** * The AgentCore Runtime profile that build derives from the local profile (`deriveRuntimeProfile` * in runtimeProfile/derive.ts), which the runtime profile writer stages; absent when build has no - * profile text. + * profile text. It can name a route that the staged file does not have: the writer removes each + * route to a target that build does not write (withoutUnsentRoutes in boxNetworkWriters.ts). */ readonly runtimeProfile?: TomlTable; /** The comment lines above {@link runtimeProfile} in the staged file. */ diff --git a/src/core/project/manager.boxNetwork.test.ts b/src/core/project/manager.boxNetwork.test.ts index 45f2a6af5..8916890df 100644 --- a/src/core/project/manager.boxNetwork.test.ts +++ b/src/core/project/manager.boxNetwork.test.ts @@ -393,6 +393,32 @@ describe("build writes the Box network of the box profile", () => { }); }); + test("stages no Runtime [mcp] server for an HTTP MCP server whose key build cannot find", async () => { + const { manager, root, box } = await strandsProject(); + const tools = { + type: "http", + destinations: ["tools.example.com"], + secret: { ref: "env://TOOLS_TOKEN" }, + }; + await editProfile(root, { + tables: + '\n[mcp.tools]\ntype = "http"\ndestinations = ["tools.example.com"]\n' + + 'secret.ref = "env://TOOLS_TOKEN"\n', + }); + box.answer = boxShowOf({ egress: { bedrock: BEDROCK }, mcp: { tools } }); + + const { steps } = await build(manager, root); + + expect(await targetNames(root)).toEqual(["bedrock", "agentcore"]); + expect(steps).toContain( + `not adding gateway target 'egress-tools' of '${GATEWAY}' for tools.example.com: it sends ` + + "the key of env://TOOLS_TOKEN, and agentcore.json has no API key credential 'tools' " + + "to hold it", + ); + // With no target, the Runtime profile has no [mcp.tools] server, as it has no route above. + expect((await runtimeProfile(root)).mcp).toBeUndefined(); + }); + test("routes a host through the target the gateway holds for it, and keeps every user target", async () => { const { manager, root, box } = await strandsProject({ env: { GITHUB_TOKEN: "ghp_123" } }); await editProfile(root, { tables: GITHUB_ROUTE }); From eb8685bdc5bb8360113e543c5314e9f8d7461255 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:38:21 -0800 Subject: [PATCH 50/51] refactor(box): Derive the Runtime paths from the code folder that dev starts box in [aws/agentcore-cli#2865](https://github.com/aws/agentcore-cli/pull/2865) makes `boxStartFolder` read `build` and `codeLocation` from agentcore.json, not the header line of the profile. Thus dev starts box in the code folder of each CodeZip runtime, also for a profile that names the code folder `${{ workspace }}/`. The path model of this branch had a condition for such a profile, of the earlier layout. A Box project is only for new projects, so Varun on [aws/agentcore-cli#2866](https://github.com/aws/agentcore-cli/pull/2866) told us to remove that condition. - `runtimePaths(runtime)` names the local code folder `${{ workspace }}` for each CodeZip runtime, and has no start folder parameter. - The profile source of the Box network model and the context of the derivation have no `startFolder`. - The rule tests use the profiles of the code-folder layout. The test of a path of the project that is not in the code folder goes, because `${{ workspace }}` is the code folder. Tests: derive.test.ts "moves a CodeZip runtime's code folder, ${{ workspace }}, and Python to the inputs of @box/agentcore-codezip", and the tests of the four rules, on the code-folder layout. --- src/core/project/boxNetwork/network.ts | 1 - src/core/project/boxNetwork/profileParser.ts | 2 - src/core/project/boxNetworkSource.ts | 14 ++----- src/core/project/runtimeProfile/context.ts | 19 +++------ .../project/runtimeProfile/derive.test.ts | 22 ++++------ .../runtimeProfile/rules/additions.test.ts | 2 - .../runtimeProfile/rules/gateway.test.ts | 1 - .../runtimeProfile/rules/paths.test.ts | 40 +++++++++---------- .../runtimeProfile/rules/refusals.test.ts | 31 +++++--------- src/core/project/runtimeProfile/types.ts | 2 +- 10 files changed, 46 insertions(+), 88 deletions(-) diff --git a/src/core/project/boxNetwork/network.ts b/src/core/project/boxNetwork/network.ts index 74dec491e..534d8ba54 100644 --- a/src/core/project/boxNetwork/network.ts +++ b/src/core/project/boxNetwork/network.ts @@ -209,7 +209,6 @@ export function buildBoxNetwork( hosts: targets.hosts, telemetry: telemetry?.telemetry ?? [], places: source.places, - startFolder: source.startFolder, }); const derived = source && context && deriveRuntimeProfile(source.table, context); failures.push( diff --git a/src/core/project/boxNetwork/profileParser.ts b/src/core/project/boxNetwork/profileParser.ts index 3184ba659..8b8576d73 100644 --- a/src/core/project/boxNetwork/profileParser.ts +++ b/src/core/project/boxNetwork/profileParser.ts @@ -37,8 +37,6 @@ export interface ParsedProfile { readonly source?: { readonly table: Readonly; readonly places: ReadonlyMap; - /** The folder, from the project root, that box starts in for the profile (boxStartFolder). */ - readonly startFolder: string; }; } diff --git a/src/core/project/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 7e57d57dd..d16c8cbe0 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -220,7 +220,7 @@ async function readResolvedPolicy( ? await resolver.resolve(projectRoot, profileFile, startFolder) : await resolveCopy(projectRoot, agentName, resolver, forRegion, files.texts, startFolder); const profile = parseResolvedProfile(resolved, named.ok ? named.files : [], profileFile); - const source = profileSource(text, profileFile, startFolder); + const source = profileSource(text, profileFile); const policy = parseResolvedPolicy( { ...profile.profile, places, ...(source && { source }) }, resolved.policy, @@ -241,17 +241,9 @@ async function readResolvedPolicy( * The box profile `text` at `profileFile` as a TOML table, with where it sets each key, or * `undefined` when it is not TOML; the profile parser stops build for that. */ -function profileSource( - text: string, - profileFile: string, - startFolder: string, -): ParsedProfileSource | undefined { +function profileSource(text: string, profileFile: string): ParsedProfileSource | undefined { try { - return { - table: parseToml(text) as TomlTable, - places: profileKeyPlaces(text, profileFile), - startFolder, - }; + return { table: parseToml(text) as TomlTable, places: profileKeyPlaces(text, profileFile) }; } catch { return undefined; } diff --git a/src/core/project/runtimeProfile/context.ts b/src/core/project/runtimeProfile/context.ts index 8d3a96f7e..9b7a21cf7 100644 --- a/src/core/project/runtimeProfile/context.ts +++ b/src/core/project/runtimeProfile/context.ts @@ -20,11 +20,11 @@ const HOME = "${{ home }}"; /** * Where the paths of the local profile of `runtime` are on AgentCore Runtime. A container image runs * the profile in /app, its workspace, under `agentcore dev` and on the Runtime alike, so each path - * stays. A CodeZip runtime runs it in the project folder under `agentcore dev`. + * stays. Under `agentcore dev`, box starts a CodeZip runtime in its code folder (boxStartFolder), + * so `${{ workspace }}` is the code folder. */ export function runtimePaths( runtime: Pick, - startFolder = "", ): RuntimePaths { if (runtime.build !== "CodeZip") { return { @@ -42,15 +42,10 @@ export function runtimePaths( .normalize(runtime.codeLocation.replace(/\\/g, "/")) .replace(/^\.\/|\/+$/g, ""); const root = folder === "." || folder === ""; - // `${{ workspace }}` is the folder box starts in: the code folder for a profile that create or - // add runtime writes now, and the project root for one written before. - const start = posix.normalize(startFolder || ".").replace(/^\.\/|\/+$/g, ""); - const fromStart = posix.relative(start === "." ? "" : start, root ? "" : folder); - const localCode = fromStart === "" ? WORKSPACE : `${WORKSPACE}/${fromStart}`; return { build: "CodeZip", - localCode, - localVenv: `${localCode}/.venv`, + localCode: WORKSPACE, + localVenv: `${WORKSPACE}/.venv`, localPythons: `${HOME}/.local/share/uv/python`, runtimeCode: RUNTIME_INPUTS.codeDir, runtimePython: RUNTIME_INPUTS.pythonPath, @@ -125,14 +120,12 @@ export function runtimeProfileContext( input: Omit & { /** Where the local profile sets each key: {@link profileKeyPlaces}. */ readonly places: ReadonlyMap; - /** The folder, from the project root, that box starts in for the local profile. */ - readonly startFolder?: string; }, ): RuntimeProfileContext { - const { places, startFolder, ...rest } = input; + const { places, ...rest } = input; return { ...rest, - paths: runtimePaths(input.runtime, startFolder), + paths: runtimePaths(input.runtime), template: runtimeTemplate(input.spec.name, input.runtime, input.region), placeOf: (key) => { for (let depth = key.length; depth > 0; depth--) { diff --git a/src/core/project/runtimeProfile/derive.test.ts b/src/core/project/runtimeProfile/derive.test.ts index e62f5866e..dff787616 100644 --- a/src/core/project/runtimeProfile/derive.test.ts +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -72,29 +72,21 @@ describe("deriveRuntimeProfile", () => { }); describe("runtimePaths", () => { - test("moves a CodeZip runtime's code and Python to the inputs of @box/agentcore-codezip", () => { + test("moves a CodeZip runtime's code folder, ${{ workspace }}, and Python to the inputs of @box/agentcore-codezip", () => { + // dev starts box in the code folder of a CodeZip runtime (boxStartFolder). expect(runtimePaths(CODEZIP)).toEqual({ build: "CodeZip", - localCode: "${{ workspace }}/app/agent", - localVenv: "${{ workspace }}/app/agent/.venv", + localCode: "${{ workspace }}", + localVenv: "${{ workspace }}/.venv", localPythons: "${{ home }}/.local/share/uv/python", runtimeCode: "${{ inputs.code.dir }}", runtimePython: "${{ inputs.python.path }}", runtimePythonPrefix: "${{ inputs.python.prefix }}", shownCode: "app/agent/", }); - expect( - runtimePaths({ ...CODEZIP, codeLocation: "./app/agent/" } as ProjectRuntime).localCode, - ).toBe("${{ workspace }}/app/agent"); - }); - - test("names the code folder ${{ workspace }} when box starts in it, as for a profile create writes now", () => { - expect(runtimePaths(CODEZIP, "app/agent")).toMatchObject({ - localCode: "${{ workspace }}", - localVenv: "${{ workspace }}/.venv", - shownCode: "app/agent/", - }); - expect(runtimePaths(CODEZIP, "app").localCode).toBe("${{ workspace }}/agent"); + expect(runtimePaths({ ...CODEZIP, codeLocation: "./app/agent/" } as ProjectRuntime)).toEqual( + runtimePaths(CODEZIP), + ); }); test("keeps each path of a container image, which runs in /app under dev and on the Runtime", () => { diff --git a/src/core/project/runtimeProfile/rules/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts index 5e5445d7e..1b3dc8202 100644 --- a/src/core/project/runtimeProfile/rules/additions.test.ts +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -85,8 +85,6 @@ function contextOf( hosts: [], telemetry: options.telemetry ?? [], places: new Map(), - // box starts a CodeZip profile that create writes in the code folder of the runtime. - startFolder: runtime.build === "CodeZip" ? runtime.codeLocation : "", }); } diff --git a/src/core/project/runtimeProfile/rules/gateway.test.ts b/src/core/project/runtimeProfile/rules/gateway.test.ts index 0397a6679..585b2e30d 100644 --- a/src/core/project/runtimeProfile/rules/gateway.test.ts +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -583,7 +583,6 @@ describe("the gateway rule and the Runtime renderer it replaced", () => { source: { table: parse(text) as TomlTable, places: profileKeyPlaces(text, PROFILE), - startFolder: "", }, }, `${policy}${boxNetworkRules(egress, mcp)}`, diff --git a/src/core/project/runtimeProfile/rules/paths.test.ts b/src/core/project/runtimeProfile/rules/paths.test.ts index 90ae8ed5b..075d6e1c3 100644 --- a/src/core/project/runtimeProfile/rules/paths.test.ts +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -21,10 +21,9 @@ const CONTAINER = { ...CODEZIP, build: "Container", entrypoint: "main.py" } as P const PROFILE = ".box/agent/local/profile.toml"; /** - * The context of the local profile `text`. box starts in `startFolder`: the code folder for a - * profile that create writes now, and the project root for the profiles of these tests. + * The context of the local profile `text`. dev starts box in the code folder, `${{ workspace }}`. */ -const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP, startFolder = "") => +const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => runtimeProfileContext({ spec: { name: "demo", runtimes: [runtime] } as unknown as ProjectSpec, runtime, @@ -34,7 +33,6 @@ const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP, startFolder hosts: [], telemetry: [], places: profileKeyPlaces(text, PROFILE), - startFolder, }); /** The table of the paths rule for the local profile `text`. */ @@ -47,7 +45,7 @@ const moved = (text: string, runtime: ProjectRuntime = CODEZIP) => { const toml = (...lines: string[]) => lines.join("\n"); -const APP = "${{ workspace }}/app/agent"; +const APP = "${{ workspace }}"; const CODE = "${{ inputs.code.dir }}"; const PYTHON = "${{ inputs.python.path }}"; const PREFIX = "${{ inputs.python.prefix }}"; @@ -58,14 +56,14 @@ const LEAVES = toml( 'packs = ["@box/base"]', "", "[agent]", - 'command = ["${{ workspace }}/app/agent/run"]', + 'command = ["${{ workspace }}/run"]', "", "[mcp.notes]", 'type = "stdio"', `command = ["${APP}/.venv/bin/python3.15", "${APP}/notes_server.py", "--root=${APP}/notes"]`, `workspace = "${APP}"`, "argument_wildcards = true", - `env = { NOTES_DIR = "\${{workspace}}/app/agent/notes", LEVEL = "debug" }`, + `env = { NOTES_DIR = "\${{workspace}}/notes", LEVEL = "debug" }`, "", "[mcp.notes.filesystem]", `read = ["${APP}", { path = "${APP}/.venv", optional = true }, { path = "\${{ home }}/.local/share/uv/python", optional = true }]`, @@ -107,11 +105,11 @@ describe("the paths rule", () => { test("keeps the code folder in the PYTHONPATH of [agent] and of a leaf on the Runtime Python, one time", () => { const text = [ "[agent.env]", - 'PYTHONPATH = "${{ workspace }}/app/agent/lib"', + 'PYTHONPATH = "${{ workspace }}/lib"', "[mcp.notes]", 'type = "stdio"', - 'command = ["${{ workspace }}/app/agent/.venv/bin/python3.15", "-m", "notes"]', - 'env = { PYTHONPATH = "/opt/lib:${{ workspace }}/app/agent:${{ workspace }}/app/agent/.venv" }', + 'command = ["${{ workspace }}/.venv/bin/python3.15", "-m", "notes"]', + 'env = { PYTHONPATH = "/opt/lib:${{ workspace }}:${{ workspace }}/.venv" }', ].join("\n"); const { profile } = deriveRuntimeProfile(parse(text) as TomlTable, contextOf(text)); @@ -128,9 +126,9 @@ describe("the paths rule", () => { test("leaves out a deny entry on the venv or in it, with a warning, and keeps deny_write on the venv", () => { const text = [ "[agent.filesystem]", - 'read = ["${{ workspace }}/app/agent"]', - 'deny = ["${{ workspace }}/app/agent/.venv", { path = "${{workspace}}/app/agent/.venv/bin" }]', - 'deny_write = ["${{ workspace }}/app/agent/.venv"]', + 'read = ["${{ workspace }}"]', + 'deny = ["${{ workspace }}/.venv", { path = "${{workspace}}/.venv/bin" }]', + 'deny_write = ["${{ workspace }}/.venv"]', ].join("\n"); // The paths rule alone: the additions rule removes the deny_write of the template. @@ -141,7 +139,7 @@ describe("the paths rule", () => { expect(filesystem).not.toHaveProperty("deny"); expect(filesystem.deny_write).toEqual(["${{ inputs.code.dir }}"]); expect(warnings).toEqual( - ["${{ workspace }}/app/agent/.venv", "${{workspace}}/app/agent/.venv/bin"].map( + ["${{ workspace }}/.venv", "${{workspace}}/.venv/bin"].map( (path) => `[agent.filesystem] deny names ${JSON.stringify(path)}, in the venv. On AgentCore ` + "Runtime the venv is the code folder, ${{ inputs.code.dir }}, so the entry would keep " + @@ -153,8 +151,8 @@ describe("the paths rule", () => { test("leaves out a deny entry and an optional grant that are not on the Runtime, with a warning", () => { const text = [ "[agent.filesystem]", - 'read = ["${{ workspace }}/app/agent", { path = "${{ home }}/.aws", optional = true }]', - 'deny = ["${{ home }}/.ssh", "${{ workspace }}/app/agent/secrets"]', + 'read = ["${{ workspace }}", { path = "${{ home }}/.aws", optional = true }]', + 'deny = ["${{ home }}/.ssh", "${{ workspace }}/secrets"]', ].join("\n"); const { profile, problems, warnings } = deriveRuntimeProfile( @@ -192,7 +190,7 @@ describe("the paths rule", () => { test("moves the venv's Python, the venv, the uv Pythons, and the code folder in [agent]", () => { const table = moved( toml( - 'agent-args = ["--config", "${{ workspace }}/app/agent/agent.json"]', + 'agent-args = ["--config", "${{ workspace }}/agent.json"]', "[agent]", `command = ["${APP}/.venv/bin/python", "-m", "main"]`, `workspace = "${APP}"`, @@ -317,14 +315,14 @@ describe("the paths rule", () => { 'bedrock.region = "us-west-2"', "[egress.files]", 'destinations = ["files.example.com"]', - 'secret.ref = "file://${{ workspace }}/app/agent/.files-token"', + 'secret.ref = "file://${{ workspace }}/.files-token"', "[mcp.docs]", 'type = "http"', 'destinations = ["docs.example.com"]', - 'secret.ref = "file://${{ workspace }}/app/agent/.docs-token"', + 'secret.ref = "file://${{ workspace }}/.docs-token"', "[telemetry.local]", 'kind = "file"', - 'path = "${{ workspace }}/app/agent/telemetry.jsonl"', + 'path = "${{ workspace }}/telemetry.jsonl"', "[agent]", 'command = ["/usr/bin/env", "--flag", "${{ inputs.code.dir }}/x", "https://example.com/a:b"]', "[[agent.ingress]]", @@ -352,7 +350,7 @@ describe("the paths rule", () => { test.each(["HTTP", "A2A", "MCP", "AGUI"])( "moves each path of the profile that create writes for a %s runtime to the Runtime's inputs", (protocol) => { - const context = contextOf("", { ...CODEZIP, protocol } as ProjectRuntime, "app/agent"); + const context = contextOf("", { ...CODEZIP, protocol } as ProjectRuntime); const text = serializeRuntimeProfile(apply(context.template.local, context).table); diff --git a/src/core/project/runtimeProfile/rules/refusals.test.ts b/src/core/project/runtimeProfile/rules/refusals.test.ts index cd4a03d5c..ed1720f94 100644 --- a/src/core/project/runtimeProfile/rules/refusals.test.ts +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -21,11 +21,10 @@ const CONTAINER = { ...CODEZIP, build: "Container", entrypoint: "main.py" } as P const PROFILE = ".box/agent/local/profile.toml"; /** - * The context of the local profile `text`, with the CloudWatch targets that box takes from it. box - * starts in `startFolder`: the code folder for a profile that create writes now, and the project - * root for the profiles of these tests. + * The context of the local profile `text`, with the CloudWatch targets that box takes from it. dev + * starts box in the code folder, `${{ workspace }}`. */ -const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP, startFolder = "") => +const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP) => runtimeProfileContext({ spec: { name: "demo", runtimes: [runtime] } as unknown as ProjectSpec, runtime, @@ -36,7 +35,6 @@ const contextOf = (text: string, runtime: ProjectRuntime = CODEZIP, startFolder telemetry: withDeployRegion(cloudWatchTelemetry(parse(text) as TomlTable), "us-west-2", PROFILE) .telemetry, places: profileKeyPlaces(text, PROFILE), - startFolder, }); /** The problems of the refusals rule for the local profile `text`. */ @@ -49,7 +47,7 @@ const toml = (...lines: string[]) => lines.join("\n"); const lineOf = (text: string, start: string) => `${PROFILE}:${text.split("\n").findIndex((line) => line.startsWith(start)) + 1}:1`; -const APP = "${{ workspace }}/app/agent"; +const APP = "${{ workspace }}"; /** A local profile that can go to a CodeZip Runtime: each path moves, and each program is there. */ const WORKS = toml( @@ -99,14 +97,6 @@ describe("the refusals rule", () => { ); test.each([ - [ - "a path of the project outside the code folder", - ["mcp", "notes", "command"], - `command = ["${APP}/.venv/bin/python3.15", "\${{ workspace }}/tools/notes.py"]`, - '[mcp.notes] command names "${{ workspace }}/tools/notes.py", which is not in app/agent/. ' + - "The zip of a CodeZip deploy contains only that folder. Move the file into app/agent/, " + - "or remove the path.", - ], [ "a path of the home folder", ["mcp", "notes", "env", "NOTES_DIR"], @@ -133,8 +123,8 @@ describe("the refusals rule", () => { [ "a folder of the project whose name starts as the code folder's does", ["mcp", "notes", "command"], - 'command = ["${{ workspace }}/app/agent-tools/notes-server"]', - '[mcp.notes] command names "${{ workspace }}/app/agent-tools/notes-server", which is not in ' + + 'command = ["${{ workspace }}-tools/notes-server"]', + '[mcp.notes] command names "${{ workspace }}-tools/notes-server", which is not in ' + "app/agent/. The zip of a CodeZip deploy contains only that folder. Move the file into " + "app/agent/, or remove the path.", ], @@ -360,9 +350,9 @@ describe("the refusals rule", () => { }); test.each([ - ["mcp", 'type = "stdio"\ncommand = ["${{ workspace }}/app/agent/notes-server"]'], - ["tool", 'command = ["${{ workspace }}/app/agent/notes-server"]'], - ["agent", 'command = ["${{ workspace }}/app/agent/notes-server"]'], + ["mcp", 'type = "stdio"\ncommand = ["${{ workspace }}/notes-server"]'], + ["tool", 'command = ["${{ workspace }}/notes-server"]'], + ["agent", 'command = ["${{ workspace }}/notes-server"]'], ])( "stops for contain_egress = false in [%s], for CodeZip and a container (RUNTIME_EGRESS_NOT_CONTAINED)", (group, body) => { @@ -450,8 +440,7 @@ describe("the refusals rule", () => { "finds no problem in each profile that create writes for a %s runtime", (protocol) => { for (const build of [CODEZIP, CONTAINER]) { - const start = build.build === "CodeZip" ? "app/agent" : ""; - const context = contextOf("", { ...build, protocol } as ProjectRuntime, start); + const context = contextOf("", { ...build, protocol } as ProjectRuntime); expect(apply(context.template.local, context).problems).toEqual([]); } diff --git a/src/core/project/runtimeProfile/types.ts b/src/core/project/runtimeProfile/types.ts index 1b3d4604d..628d1520f 100644 --- a/src/core/project/runtimeProfile/types.ts +++ b/src/core/project/runtimeProfile/types.ts @@ -38,7 +38,7 @@ export const RUNTIME_INPUTS = { */ export interface RuntimePaths { readonly build: "CodeZip" | "Container"; - /** The code folder, as the local profile names it: `${{ workspace }}/`. */ + /** The code folder, as the local profile names it: `${{ workspace }}`, where dev starts box. */ readonly localCode: string; /** The venv of the code folder, as the local profile names it. */ readonly localVenv: string; From d6330f6d488ad2eed7345580a11455075127ed21 Mon Sep 17 00:00:00 2001 From: Sai Abhishek Date: Thu, 19 Nov 2026 22:46:45 -0800 Subject: [PATCH 51/51] test(box): Examine that the zip of a CodeZip runtime stages no ffi folder A mutation that copies a folder to `.box-dist/ffi` made no test fail. The staging test of boxCodeZip.test.ts examines that `.box-dist` has no `ffi` folder. The test fails with that mutation. --- src/core/project/backends/boxCodeZip.test.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/project/backends/boxCodeZip.test.ts b/src/core/project/backends/boxCodeZip.test.ts index bd476d08e..36f99bc4d 100644 --- a/src/core/project/backends/boxCodeZip.test.ts +++ b/src/core/project/backends/boxCodeZip.test.ts @@ -93,6 +93,8 @@ describe("stageBoxCodeZip", () => { expect(await readFile(join(dist, "resources", "shared", "base", "pack.toml"), "utf8")).toBe( "[pack]\n", ); + // box 0.1.11-mquang.preview.9 runs the Runtime's Python with no ffi shim. + expect(existsSync(join(dist, "ffi"))).toBe(false); // The Runtime profile is the one build derived from the local profile. const { runtimeProfile, runtimeProfileHeader } = model([]); expect(await readFile(join(dist, "profile.toml"), "utf8")).toBe(