diff --git a/README.md b/README.md index d9cec7fb3..18605dc28 100644 --- a/README.md +++ b/README.md @@ -197,30 +197,32 @@ 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.6` 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-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 two releases on their own, each with its -repository, version and SHA-256s: - -- `box`: the Linux build that ships to AgentCore Runtime. -- `ffi`: the Python ffi shim a CodeZip agent needs in a box, by Python version. It can come from - another repository or version than box. - -`bun scripts/bump-box-release.ts --box ` (or `--ffi `, with `--box-repo` or -`--ffi-repo` to move repository) rewrites the file from the release's `SHA256SUMS.txt`. +`src/core/project/backends/boxRelease.json` pins the Linux build of box that ships to AgentCore +Runtime, with its repository, version and SHA-256. `bun scripts/bump-box-release.ts --box ` +(with `--box-repo` to move repository) rewrites the file from the release's `SHA256SUMS.txt`. How each command uses it: - A CodeZip agent's zip carries box. `build` and `deploy` download box once with `curl` into - `~/.agentcore/box/` and the ffi shim into `~/.agentcore/box-ffi/`, check each against its pinned - SHA-256, and stage box, its packs and the shim into the runtime's `.box-dist/`. + `~/.agentcore/box/`, check it against its pinned SHA-256, and stage box and its packs into the + runtime's `.box-dist/`. - A container agent's image downloads box while it builds. `dev`, `build` and `deploy` stage the release that `box.version` names, with its checksum, as `box-release.env` beside the Dockerfile (`.box-dist/`, or `.box-dev/` under `dev`), and the Dockerfile downloads that release with `curl`, @@ -234,8 +236,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 @@ -254,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.6`. The +The CodeBuild log of the deploy shows `/tmp/box.tar.gz: OK` and `box 0.1.11-mquang.preview.9`. The second answer should say teal, and the runtime log shows `running profile ...` with no `ERROR`, `blocked by egress control` or `AccessDenied` line. For a CodeZip agent, use `--template agent-python-strands-box` and skip the container settings. diff --git a/docs/box-local-testing.md b/docs/box-local-testing.md index c97d0b4f9..7c657034a 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 @@ -109,13 +111,16 @@ 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 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 @@ -130,9 +135,47 @@ 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.** 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 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.]`; + - the `@box/agentcore` packs, the project name, and the build region come in, and each CloudWatch + 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 + 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. 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/assets/templates/agent-python-strands-box/Dockerfile.template b/src/assets/templates/agent-python-strands-box/Dockerfile.template index d74924b8b..a46f803d6 100644 --- a/src/assets/templates/agent-python-strands-box/Dockerfile.template +++ b/src/assets/templates/agent-python-strands-box/Dockerfile.template @@ -41,12 +41,12 @@ 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 -# 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. +# 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. +# 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/assets/templates/box-codezip/start.py b/src/assets/templates/box-codezip/start.py index 03e0bbaea..8944f53ac 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 json @@ -26,8 +26,10 @@ 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) +# 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 staged_policies(path): """The policy files the staged profile's `policies` names. @@ -53,25 +55,46 @@ def staged_policies(path): return [] -# 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) -policies = staged_policies(staged_profile) -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) +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(): + 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) + for policy in staged_policies(staged_profile): + 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, + }, + ) + -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, - }, -) +if __name__ == "__main__": + main() diff --git a/src/core/dev/box.test.ts b/src/core/dev/box.test.ts index 1c7848ba0..7acbb9bcc 100644 --- a/src/core/dev/box.test.ts +++ b/src/core/dev/box.test.ts @@ -36,6 +36,15 @@ 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", "bin"), { recursive: true }); + await writeFile(join(projectRoot, "app", name, ".venv", "bin", "python"), ""); +} + /** A project named `Demo` that holds the agent's box profile in .box/agent/local when `profiled`. */ async function scene( profiled: boolean, @@ -104,6 +113,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); @@ -152,6 +169,24 @@ 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(calls.map(({ options }) => options.cwd)).toEqual([ + join(projectRoot, "app", "second"), + join(projectRoot, "app", "agent"), + ]); + expect(fallbackRuns).toEqual([]); + }); + test("starts box in the runtime's folder for a profile create writes, whatever it says", async () => { // So the agent's workspace, and the project grant, are app/agent and nothing else of the // project: not agentcore/.env.local, which holds the model's key. The folder comes from @@ -391,9 +426,40 @@ 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 .venv", true], ["has the empty .venv that create --skip-install leaves", false], diff --git a/src/core/dev/container.test.ts b/src/core/dev/container.test.ts index 0d7af58ef..0cbecf178 100644 --- a/src/core/dev/container.test.ts +++ b/src/core/dev/container.test.ts @@ -862,6 +862,19 @@ 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("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/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/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 40df9b144..36f99bc4d 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 { BOX_DIST_GITIGNORE, stageBoxCodeZip } from "./boxCodeZip"; import type { BoxLinuxBuild } from "./boxRelease"; @@ -34,58 +36,51 @@ const BINARIES = ["box", "strands-box-sock-alias", "strands-box-contain-trampoli /** * A Linux box build laid out as the release cache holds it, and as deploy resolves it: box, its - * helpers and its packs in one folder, and optionally the Python 3.14 shim under ffi/. + * helpers and its packs in one folder. */ -async function linuxBuild(options: { ffi?: boolean } = {}): Promise { +async function linuxBuild(): Promise { const root = await temp("box-build-"); for (const binary of BINARIES) await writeFile(join(root, binary), `#!${binary}\n`); await mkdir(join(root, "resources", "shared", "base"), { recursive: true }); await writeFile(join(root, "resources", "shared", "base", "pack.toml"), "[pack]\n"); - const ffi = join(root, "ffi", "PYTHON_3_14"); - if (options.ffi) { - await mkdir(ffi, { recursive: true }); - await writeFile(join(ffi, "libffi.so.8"), "ffi"); - } - return { - binaries: root, - resources: join(root, "resources"), - ffi: options.ffi ? { PYTHON_3_14: ffi } : {}, - }; + return { binaries: root, resources: join(root, "resources") }; } -async function project(entrypoint: string, runtimeVersion = "PYTHON_3_14"): Promise { +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; } describe("stageBoxCodeZip", () => { - test("stages box, its packs, the shim, and the Runtime profile into the code folder", async () => { - const build = await linuxBuild({ ffi: true }); + test("stages box, its packs, and the Runtime profile into the code folder", async () => { + const build = await linuxBuild(); const demo = await project("start.py"); - expect(await stageBoxCodeZip(demo, [], async () => build)).toEqual(["agent"]); + expect(await stageBoxCodeZip(demo, [model([])], async () => build)).toEqual(["agent"]); const dist = join(demo.rootPath, "app", "agent", ".box-dist"); for (const binary of BINARIES) { @@ -98,10 +93,12 @@ describe("stageBoxCodeZip", () => { expect(await readFile(join(dist, "resources", "shared", "base", "pack.toml"), "utf8")).toBe( "[pack]\n", ); - expect(await readFile(join(dist, "ffi", "libffi.so.8"), "utf8")).toBe("ffi"); - // The Runtime profile is rendered from agentcore.json. + // 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( - 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. @@ -111,17 +108,25 @@ 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"), + ); + } // A template's own .gitignore may not list .box-dist/, so the folder ignores itself. expect(await readFile(join(dist, ".gitignore"), "utf8")).toBe(BOX_DIST_GITIGNORE); }); 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)[] = []; - await stageBoxCodeZip(demo, [], async (version) => { + await stageBoxCodeZip(demo, [model([])], async (version) => { versions.push(version); return build; }); @@ -129,17 +134,6 @@ describe("stageBoxCodeZip", () => { expect(versions).toEqual(["2.0.0"]); }); - test("ships no shim to a runtime whose Python it was not built for", async () => { - const build = await linuxBuild({ ffi: true }); - const demo = await project("start.py", "PYTHON_3_13"); - - await stageBoxCodeZip(demo, [], async () => build); - - const dist = join(demo.rootPath, "app", "agent", ".box-dist"); - expect(await Bun.file(join(dist, "box")).exists()).toBe(true); - expect(await Bun.file(join(dist, "ffi", "libffi.so.8")).exists()).toBe(false); - }); - test.each([ ["a user's own start.py, with no box.version", false, "box"], ["a box runtime outside a Box project", true, undefined], @@ -151,7 +145,7 @@ describe("stageBoxCodeZip", () => { const asked: (string | undefined)[] = []; expect( - await stageBoxCodeZip(demo, [], async (version) => { + await stageBoxCodeZip(demo, [model([])], async (version) => { asked.push(version); return linuxBuild(); }), @@ -167,7 +161,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); @@ -179,7 +173,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, @@ -200,9 +194,39 @@ 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 () => { + 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(parse(profile) as TomlTable).toEqual(runtimeProfileOf([file], name)); + 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 () => { @@ -216,17 +240,32 @@ 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, with the Runtime + * profile build derived from its local profile. + */ +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: [], 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/boxCodeZip.ts b/src/core/project/backends/boxCodeZip.ts index d12171acc..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, @@ -38,7 +37,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, { @@ -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/boxContainer.test.ts b/src/core/project/backends/boxContainer.test.ts index cebdc9c34..2bb9f1a03 100644 --- a/src/core/project/backends/boxContainer.test.ts +++ b/src/core/project/backends/boxContainer.test.ts @@ -6,11 +6,12 @@ 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"; -/** 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[] = []; @@ -75,21 +76,30 @@ 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` + `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. + 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 () => { @@ -99,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()); }); @@ -109,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([]); }); @@ -117,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); }); @@ -153,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", @@ -162,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/boxRelease.json b/src/core/project/backends/boxRelease.json index 0b2c71386..654733e45 100644 --- a/src/core/project/backends/boxRelease.json +++ b/src/core/project/backends/boxRelease.json @@ -1,21 +1,11 @@ { "box": { "repo": "mquang-amazon/box-releases", - "version": "0.1.11-linux-preview.6", + "version": "0.1.11-mquang.preview.9", "linux": { "target": "aarch64-unknown-linux-gnu", - "asset": "box-v0.1.11-linux-preview.6-aarch64-unknown-linux-gnu.tar.gz", - "sha256": "cef02792ec43bd03179246ab4306697a29e7fc831d371c21a3d3b191859936da" - } - }, - "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" - } + "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 e3b78364b..ace180ea3 100644 --- a/src/core/project/backends/boxRelease.test.ts +++ b/src/core/project/backends/boxRelease.test.ts @@ -7,11 +7,13 @@ import { tmpdir } from "node:os"; import { join } from "node:path"; import { InvalidEnvironmentError } from "../../../errors/errors"; import { type ProcessRunner, runProcess } from "../../../io/exec"; +import { gte } from "semver"; import { + BOX_INSTALL_HINT, + BOX_MINIMUM_VERSION, BOX_RELEASE, - FFI_RELEASE, + BOX_RELEASE_PAGE, type BoxRelease, - type FfiRelease, boxReleaseFor, publishInstall, resolveBoxLinuxBuild, @@ -33,7 +35,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) { @@ -59,9 +60,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, @@ -71,21 +69,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. @@ -98,68 +82,46 @@ 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("keeps the release another process installed while this one downloaded it", async () => { // Concurrent builds and deploys share the cache: each downloads into its own work folder, and // one may finish while another is still downloading. The loser keeps the winner's folder, so a // command already copying out of it does not lose files under it. - const { release, ffi, runner } = await fakeRelease(); + const { release, runner } = await fakeRelease(); const winner = await resolveBoxLinuxBuild( {}, - { runner, home: await temp("box-home-"), release, ffi }, + { runner, home: await temp("box-home-"), release }, ); const home = await temp("box-home-"); const root = join(home, ".agentcore", "box", `${VERSION}-aarch64-unknown-linux-gnu`); @@ -172,7 +134,7 @@ describe("resolveBoxLinuxBuild from the box release", () => { return runner(command, options); }; - const build = await resolveBoxLinuxBuild({}, { runner: racing, home, release, ffi }); + const build = await resolveBoxLinuxBuild({}, { runner: racing, home, release }); expect(build.binaries).toBe(root); expect(installedMeanwhile).toBeDefined(); @@ -187,9 +149,9 @@ describe("resolveBoxLinuxBuild from the box release", () => { const root = join(home, ".agentcore", "box", `${VERSION}-aarch64-unknown-linux-gnu`); await mkdir(root, { recursive: true }); await writeFile(join(root, "box"), "partial"); - const { release, ffi, runner } = await fakeRelease(); + const { release, runner } = await fakeRelease(); - const build = await resolveBoxLinuxBuild({}, { runner, home, release, ffi }); + const build = await resolveBoxLinuxBuild({}, { runner, home, release }); expect(build.binaries).toBe(root); expect(await readFile(join(root, "box"), "utf8")).toBe("#!box\n"); @@ -198,21 +160,21 @@ describe("resolveBoxLinuxBuild from the box release", () => { 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/); @@ -344,8 +306,27 @@ describe("publishInstall", () => { }); describe("the pinned releases", () => { - 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"); + 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("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 c55475a8a..b4e5c73e7 100644 --- a/src/core/project/backends/boxRelease.ts +++ b/src/core/project/backends/boxRelease.ts @@ -7,7 +7,6 @@ import { readFileSync, renameSync, rmSync, - writeFileSync, } from "node:fs"; import { homedir } from "node:os"; import { join } from "node:path"; @@ -34,28 +33,36 @@ 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 + * 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}`; + +/** + * 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( @@ -74,21 +81,19 @@ 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 ` + - `https://github.com/${BOX_RELEASE.repo}/releases/tag/v${BOX_RELEASE.version}, unpack it into ` + - "a folder (tar -xzf -C ), and add that folder to your PATH."; + `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. " + + BOX_OTHER_MACHINE_HINT; -/** 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. */ @@ -111,8 +116,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. */ @@ -120,55 +123,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. */ @@ -263,46 +238,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); - const installed = () => isFile(marker) && readFileSync(marker, "utf8").trim() === asset.sha256; - if (installed()) 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`); - mkdirSync(join(root, ".."), { recursive: true }); - publishInstall(payload, root, installed); - } finally { - rmSync(work, { recursive: true, force: true }); - } - return root; -} - /** * Moves the checked `payload` into the cache folder `root`, where another process may be * installing the same release at the same time: several concurrent build or deploy commands each @@ -358,8 +293,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/backends/boxStartPy.test.ts b/src/core/project/backends/boxStartPy.test.ts index 85445a263..f77c251b7 100644 --- a/src/core/project/backends/boxStartPy.test.ts +++ b/src/core/project/backends/boxStartPy.test.ts @@ -2,8 +2,7 @@ import { afterEach, describe, expect, test } from "bun:test"; import { mkdtemp, rm, writeFile } from "node:fs/promises"; import { tmpdir } from "node:os"; import { join } from "node:path"; -import type { ProjectSpec } from "../../../projectSchemas/project"; -import { renderRuntimeBoxProfile } from "../templates/boxProfile"; +import { serializeRuntimeProfile } from "../runtimeProfile/serialize"; /** The CodeZip box agent's entry point, which runs on the Runtime's Python. */ const START_PY = join( @@ -64,35 +63,23 @@ async function run(profile: string) { }; } -const SPEC = { - name: "V3Demo", - runtimes: [ - { - name: "agent", - build: "CodeZip", - entrypoint: "start.py", - codeLocation: "app/agent", - protocol: "HTTP", - modelProvider: "Bedrock", - }, - ], - agentCoreGateways: [], -} as unknown as ProjectSpec; +/** A Runtime profile as the runtime profile writer writes it, with a header comment. */ +const runtimeProfile = (policies?: string[]) => + serializeRuntimeProfile( + { packs: ["@box/base"], ...(policies && { policies }), profile: { name: "V3Demo" } }, + ["Runs the agent of the AgentCore project 'V3Demo' in a box."], + ); describe.skipIf(PYTHON === undefined)("start.py with no tomllib, as on Python 3.10", () => { - test("reads the policies of a Runtime profile deploy renders", async () => { - const profile = renderRuntimeBoxProfile(SPEC, SPEC.runtimes[0]!, { - policyFiles: ["policy.dw", "rules/extra.dw"], - }); - - const result = await run(profile); + test("reads the policies of a Runtime profile that the runtime profile writer writes", async () => { + const result = await run(runtimeProfile(["policy.dw", "rules/extra.dw"])); expect(result.exitCode).toBe(0); expect(JSON.parse(result.stdout)).toEqual(["policy.dw", "rules/extra.dw"]); }); test("reads no policies from a profile that names none", async () => { - const result = await run(renderRuntimeBoxProfile(SPEC, SPEC.runtimes[0]!)); + const result = await run(runtimeProfile()); expect(result.exitCode).toBe(0); expect(JSON.parse(result.stdout)).toEqual([]); diff --git a/src/core/project/backends/cdk.test.ts b/src/core/project/backends/cdk.test.ts index edd9813b9..d405690c4 100644 --- a/src/core/project/backends/cdk.test.ts +++ b/src/core/project/backends/cdk.test.ts @@ -380,7 +380,22 @@ 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 = [ + { + 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 })); expect(events).toContainEqual({ type: "warning", message: OTEL_WARNING } as ProjectEvent); }); 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/network.ts b/src/core/project/boxNetwork/network.ts index 1f97ebc12..534d8ba54 100644 --- a/src/core/project/boxNetwork/network.ts +++ b/src/core/project/boxNetwork/network.ts @@ -23,6 +23,10 @@ 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 { runtimeProfileHeader } from "../runtimeProfile/rules/additions"; +import type { TomlTable } from "../runtimeProfile/types"; import { withDeployRegion, type CloudWatchTelemetry } from "./telemetry"; import { outboundAuthWords, sameOutboundAuth, targetOutboundAuth } from "./projectSpec"; import { @@ -117,6 +121,15 @@ 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), which the runtime profile writer stages; absent when build has no + * 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. */ + readonly runtimeProfileHeader?: readonly string[]; /** * The IAM actions that the gateway's `additionalPolicies` files grant its role, except the * policy files that build writes. @@ -184,6 +197,23 @@ export function buildBoxNetwork( const telemetry = parsed.profile.telemetry && withDeployRegion(parsed.profile.telemetry, project.region, parsed.profile.path); + const source = parsed.profile.source; + const context = + source && + 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 ?? [], + places: source.places, + }); + const derived = source && context && deriveRuntimeProfile(source.table, context); + failures.push( + ...(derived?.problems ?? []).map(({ code, reason, place }) => ({ code, reason, place })), + ); return { runtime: project.runtime.name, gateway: project.gateway, @@ -192,6 +222,11 @@ export function buildBoxNetwork( envRoutes: envRoutesOf(targets.hosts), policyFiles: parsed.profile.policyFiles, ...(telemetry && { telemetry: telemetry.telemetry }), + ...(derived && + context && { + runtimeProfile: derived.profile, + runtimeProfileHeader: runtimeProfileHeader(context, derived.profile), + }), grantedActions: project.grantedActions, warnings: [ ...hostWarnings(targets.hosts), @@ -203,6 +238,7 @@ export function buildBoxNetwork( ); }), ...(telemetry?.warnings ?? []), + ...(derived?.warnings ?? []), ], failures, }; 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/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 37a0c4399..07d4e13a5 100644 --- a/src/core/project/boxNetworkSource.test.ts +++ b/src/core/project/boxNetworkSource.test.ts @@ -2,11 +2,13 @@ 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"; import { boxShowOf, FakeBoxProfileResolver } from "./boxProfileResolver-test-support"; +import { telemetryPolicyWriter } from "./boxNetworkWriters"; +import { boxTelemetryPolicyFile } from "./boxTelemetry"; const directories: string[] = []; afterEach(async () => { @@ -54,6 +56,24 @@ 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 { + ...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 }), @@ -77,6 +97,55 @@ 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("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 = { @@ -96,6 +165,113 @@ 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"); + await quietProfile(root); + 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", + ".box/quiet/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("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) => ({ + 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("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( @@ -127,13 +303,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([]); }); @@ -249,6 +438,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 as string[]).some((host) => host === "api.example.com"), + ); + expect(routes.map(([name, route]) => [name, route.destinations])).toEqual([ + ["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/boxNetworkSource.ts b/src/core/project/boxNetworkSource.ts index 6ad367b6b..d16c8cbe0 100644 --- a/src/core/project/boxNetworkSource.ts +++ b/src/core/project/boxNetworkSource.ts @@ -15,6 +15,7 @@ import type { PolicyFileCopy } from "./backends/boxContainer"; import { DEFAULT_EGRESS_BEDROCK_REGION } from "../../handlers/project/shortcuts"; import { addBoxGatewayTargets, BOX_BEDROCK_POLICY_FILE, BOX_MEMORY_POLICY_FILE } from "./boxMemory"; import { + BOX_BEDROCK_PACK, boxLocalDir, boxLocalProfileFile, boxLocalProfilePath, @@ -34,6 +35,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 => ({ @@ -45,7 +48,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. + * runtime resolves nothing. Throws, naming the file, for a box runtime with no local box profile. */ export async function readBoxNetworks( spec: ProjectSpec, @@ -55,11 +58,13 @@ export async function readBoxNetworks( ): Promise { const runtimes = spec.runtimes.filter((runtime) => runtimeRunsInBox(spec, runtime)); if (runtimes.length === 0) return []; + 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); 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); @@ -80,11 +85,80 @@ 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; } +/** + * 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; + +/** + * 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 @@ -126,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( @@ -135,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; @@ -145,7 +220,12 @@ 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 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: [ @@ -157,15 +237,59 @@ 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 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); @@ -179,7 +303,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 { @@ -276,7 +400,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/boxNetworkWriters.test.ts b/src/core/project/boxNetworkWriters.test.ts index 75fa678b7..d63c5a501 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,12 +469,23 @@ 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("stages only the box/agentcore pack for a container", () => { + 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', + ); + }); + + 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 56ba98b2f..cd8b28324 100644 --- a/src/core/project/boxNetworkWriters.ts +++ b/src/core/project/boxNetworkWriters.ts @@ -38,10 +38,14 @@ import { AGENTCORE_PACK_PATH, boxAwsDir, boxLocalDir, + boxLocalProfileFile, renderAgentCoreCodeZipPack, renderAgentCorePack, - renderRuntimeBoxProfile, } 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. */ export type BoxNetworkOutput = @@ -366,8 +370,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"; } @@ -398,9 +402,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, spec) }, { path: `${dist}/${AGENTCORE_PACK_PATH}`, text: renderAgentCorePack(spec) }, ...(kind === "codezip" ? [ @@ -420,6 +423,64 @@ 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, + 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 ` + + `for it: it derives that profile from ${boxLocalProfileFile(runtime)}, and found no ` + + "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( + 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. */ export const BOX_NETWORK_WRITERS: readonly BoxNetworkWriter[] = [ credentialsWriter, 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 d5d14c58e..db877f739 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"; @@ -19,7 +20,7 @@ const SHOWN = String.raw`{ "profile": ".box/profile.toml", "packs": [ { - "name": "box/base", + "name": "@box/base", "version": "1" } ], @@ -95,15 +96,19 @@ const SHOWN_POLICY = boxReachRules("route", "keyed", ["k.example.com:8443"]) + boxReachRules("mcp", "docs", ["docs.example.com"]); -const PINNED = - "box 0.1.11-linux-preview.6 or a later release " + - "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.6)"; +/** The last sentence of each error that says to install another box: the pinned release. */ +const INSTALL = + `Install box ${BOX_RELEASE.version} (https://github.com/mquang-amazon/box-releases/releases/tag/v${BOX_RELEASE.version}), then retry. ` + + "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` * 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 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( @@ -133,7 +138,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 +156,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 +195,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] }] }, @@ -205,8 +210,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, ), ); }); @@ -315,6 +319,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([ @@ -349,11 +372,7 @@ describe("BoxCliProfileResolver", () => { ".box/profile.toml", ), ).rejects.toThrow( - new InvalidEnvironmentError( - "Box is not installed or not on PATH. Install box 0.1.11-linux-preview.6 " + - "(https://github.com/mquang-amazon/box-releases/releases/tag/v0.1.11-linux-preview.6), " + - "then retry.", - ), + new InvalidEnvironmentError(`Box is not installed or not on PATH. ${INSTALL}`), ); }); @@ -388,8 +407,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, ); }, ); @@ -436,7 +455,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/boxProfileResolver.ts b/src/core/project/boxProfileResolver.ts index 49e29b520..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_RELEASE } 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 { @@ -45,11 +50,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. ${BOX_OTHER_MACHINE_HINT}`; -/** 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 +116,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 +163,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 +184,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 }, ); diff --git a/src/core/project/manager.box.test.ts b/src/core/project/manager.box.test.ts index efad70656..e61f0fce1 100644 --- a/src/core/project/manager.box.test.ts +++ b/src/core/project/manager.box.test.ts @@ -4,12 +4,14 @@ 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"; import { BOX_RELEASE } from "./backends/boxRelease"; import { FsProjectManager } from "./manager"; import { newProjectSpec } from "./templates/project"; +import { defaultLogTargetNotice } from "./runtimeProfile/rules/additions"; import { boxStartFolder } from "./templates/boxProfile"; import { boxGatewaySpec, ProjectSpecSchema } from "../../projectSchemas/project"; @@ -31,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 }), }); } @@ -349,6 +352,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", @@ -546,6 +561,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 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[] = []; + + 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); + }); + 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.boxNetwork.test.ts b/src/core/project/manager.boxNetwork.test.ts index b7eb05b54..8916890df 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__"); @@ -30,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" }, @@ -40,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 { @@ -280,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; - expect(Object.keys(egress)).toEqual([ - "egress-github", - "egress-httpbin-org", - "bedrock", + // 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-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"), @@ -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 () => { @@ -387,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 }); @@ -402,7 +434,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 () => { @@ -441,7 +473,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 () => { @@ -766,8 +802,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([ @@ -786,7 +821,7 @@ describe("build reads the box profile as box resolves it", () => { const profile = await text(root, PROFILE); await writeFile( path(root, PROFILE), - profile.replace('"box/bedrock"]', '"box/bedrock", "team/search"]'), + profile.replace('"@box/bedrock"]', '"@box/bedrock", "team/search"]'), ); // `box profile show --format json --full` resolves team/search to this route, with its secret. box.answer = shows({ @@ -865,7 +900,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..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), + }); }, ); @@ -882,7 +887,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/manager.tsx b/src/core/project/manager.tsx index 922d96f0e..739919f6a 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, @@ -1642,10 +1653,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, @@ -2168,8 +2180,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, @@ -2379,6 +2392,22 @@ function ingressPort(text: string): string | undefined { return /^\s*listen\s*=\s*"[^"]*:(\d+)"/m.exec(text)?.[1]; } +/** + * 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)), + })); +} + /** * 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. 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..f8f75af16 --- /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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "A2A_PORT": "9001", + "AGENTCORE_RUNTIME_URL": "${{ inputs.runtime.url }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 }}", + "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 new file mode 100644 index 000000000..9b7a21cf7 --- /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, runtimeAgentTemplate } 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. Under `agentcore dev`, box starts a CodeZip runtime in its code folder (boxStartFolder), + * so `${{ workspace }}` is the code folder. + */ +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 === ""; + return { + build: "CodeZip", + localCode: WORKSPACE, + localVenv: `${WORKSPACE}/.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 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, +): { 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 agent = runtimeAgentTemplate(input); + return { + local: parseToml(renderBoxProfile(projectName, input, region) ?? "") as TomlTable, + runtime: agent ? { agent } : {}, + }; +} + +/** + * 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), + 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..dff787616 --- /dev/null +++ b/src/core/project/runtimeProfile/derive.test.ts @@ -0,0 +1,177 @@ +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 } from "./derive"; +import { keyLabel } from "./projectPaths"; +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: [], + 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.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: ["${{ workspace }}/app/agent/run"] }, + }; + + 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 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 }}", + 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)).toEqual( + runtimePaths(CODEZIP), + ); + }); + + 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 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(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 }}/.venv/bin/python"); + expect(agent.env).not.toHaveProperty("LOCAL_DEV"); + }); +}); + +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); + }); + + 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/runtimeProfile/derive.ts b/src/core/project/runtimeProfile/derive.ts new file mode 100644 index 000000000..d0d4581c1 --- /dev/null +++ b/src/core/project/runtimeProfile/derive.ts @@ -0,0 +1,55 @@ +/** + * 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. + */ +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 }; +} diff --git a/src/core/project/runtimeProfile/projectPaths.ts b/src/core/project/runtimeProfile/projectPaths.ts new file mode 100644 index 000000000..edbdd3b6f --- /dev/null +++ b/src/core/project/runtimeProfile/projectPaths.ts @@ -0,0 +1,270 @@ +/** + * 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 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", +]); + +/** 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]!; + 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; + 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_.+-])"; + +/** 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_.+/-])"; + +/** + * 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) && isHttpServer(entry) + ? 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.]`. */ +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" && isHttpServer(table))) 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 `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 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/additions.test.ts b/src/core/project/runtimeProfile/rules/additions.test.ts new file mode 100644 index 000000000..1b3dc8202 --- /dev/null +++ b/src/core/project/runtimeProfile/rules/additions.test.ts @@ -0,0 +1,947 @@ +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"; +import type { ProjectRuntime } from "../../../../projectSchemas/runtime"; +import { cloudWatchTelemetry, withDeployRegion, type CloudWatchTelemetry } from "../../boxNetwork"; +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"; +import type { TomlTable } from "../types"; +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. */ +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(runtime.name), targets }], + } as unknown as ProjectSpec; +} + +function contextOf( + runtime: ProjectRuntime, + options: { + memories?: readonly string[]; + telemetry?: readonly CloudWatchTelemetry[]; + } = {}, +) { + 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 ?? [], + 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)!) 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 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 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, + "logs and traces": CLOUDWATCH, + "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. 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"), +) as { + templates: Record; + boxTemplates: Record; + gateway: Record; +}; + +/** The tables that the additions rule owns, which the old renderer wrote. */ +const OWNED = [ + "packs", + "policies", + "profile", + "project", + "options", + "agent", + "tool", + "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 = ( + [ + ["CodeZip", "HTTP"], + ["CodeZip", "MCP"], + ["CodeZip", "A2A"], + ["CodeZip", "AGUI"], + ["Container", "HTTP"], + ["Container", "MCP"], + ] as const + ).flatMap(([build, protocol]) => + ["Bedrock", "OpenAI"].flatMap((provider) => + [[], ["agentMemory"]].flatMap((memories) => + Object.keys(TELEMETRY_CASES).map((telemetry) => ({ + build, + protocol, + provider, + memories, + telemetry, + })), + ), + ), + ); + + test.each(cases)( + "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); + 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 { profile, problems } = deriveRuntimeProfile( + local, + contextOf(runtime, { memories, telemetry }), + ); + + 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] ?? undefined]); + }, + ); +}); + +/** 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", () => { + 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 (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)!) 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 { profile, problems } = deriveRuntimeProfile( + local, + contextOf(runtime, { memories, telemetry }), + ); + + expect(problems).toEqual([]); + expect(profile).toEqual( + OLD_RENDERER.boxTemplates[ + `${template} provider=${provider} memories=${memories.length} telemetry=${telemetryCase}` + ]!, + ); + }, + ); +}); + +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("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"]; + + 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("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" } }; + + 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, which the paths rule then moves", () => { + const runtimeCommand = (app: string, python: string) => [ + python, + "-m", + "uvicorn", + "main:app", + "--app-dir", + app, + "--host", + "127.0.0.1", + "--port", + "8081", + ]; + const local = createdProfile(CODEZIP); + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).command).toEqual( + runtimeCommand("${{ workspace }}", "${{ workspace }}/.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", () => { + const local = createdProfile(CODEZIP); + agentOf(local).command = [ + "${{ workspace }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--reload", + "--reload-dir", + "${{ workspace }}", + "--reload-dir=${{ workspace }}/lib", + "--log-level", + "debug", + ]; + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).command).toEqual([ + "${{ workspace }}/.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 }}", + 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" }; + + const result = agentOf(apply(local, contextOf(CONTAINER)).table).env; + + expect(result.PORT).toBe("9999"); + 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); + + 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("keeps a PYTHONPATH of the user as it is, on CodeZip and on a container", () => { + const env = { PYTHONPATH: "${{ workspace }}/app/agent/lib" }; + + for (const runtime of [CODEZIP, CONTAINER]) { + expect(agentOf(apply({ agent: { env } }, contextOf(runtime)).table).env.PYTHONPATH).toBe( + "${{ workspace }}/app/agent/lib", + ); + } + }); + + 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); + (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 }}", + }); + }); + }); + + 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 }}/data", "/usr/lib64"); + filesystem.deny_write.push("${{ workspace }}/secrets"); + filesystem.write = ["/tmp/agent"]; + + expect(agentOf(apply(local, contextOf(CODEZIP)).table).filesystem).toEqual({ + read: [ + "${{ workspace }}", + "${{ home }}/.local/share/uv/python", + "/usr/lib64", + "/lib64", + "${{ workspace }}/data", + ], + exec: ["${{ workspace }}", "${{ home }}/.local/share/uv/python"], + deny_write: ["${{ workspace }}/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", + "${{ inputs.code.dir }}/data", + ], + exec: ["${{ inputs.code.dir }}", "${{ inputs.python.prefix }}"], + deny_write: ["${{ inputs.code.dir }}/secrets"], + write: ["/tmp/agent"], + }); + }); + + 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 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 }}", "/usr/lib64", "/lib64"], + exec: ["${{ workspace }}", "${{ home }}/.local/share/uv/python"], + }); + }); + + 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).filesystem).toEqual({ + read: ["/usr/lib64", "/lib64"], + exec: ["${{ workspace }}"], + }); + }); + + 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("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 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 }); + + 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, { telemetry: acceptedTelemetry(local) })).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("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 = [ + { + 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 = [ + { 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://" } }, + agentcore: DEFAULT_TARGET, + }); + }); + + 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 }, + }; + + 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", () => { + 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://" }, + }, + }); + }); + }); + + 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, { telemetry: acceptedTelemetry(local) })).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.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"] } }; + + 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, + }); + }); + + 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 local = { telemetry: { agentcore: target } }; + const telemetry = tableOf( + apply(local, contextOf(CODEZIP, { telemetry: acceptedTelemetry(local) })).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 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 " + + "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); + }); + }); + + test("keeps the policies list as the local profile names it", () => { + const local = { policies: ["./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", () => { + 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 new file mode 100644 index 000000000..085f5042b --- /dev/null +++ b/src/core/project/runtimeProfile/rules/additions.ts @@ -0,0 +1,533 @@ +/** + * Rule 3 of the derivation: what only AgentCore Runtime needs, and the Runtime value of each + * 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 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 | + * | `[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. + */ +import { + AGENTCORE_CODEZIP_PACK_NAME, + AGENTCORE_PACK_NAME, + BOX_BEDROCK_PACK, + boxIngressPort, + boxWorkloadPort, + RUNTIME_LOGS_HEADERS_ENV, +} 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, + type RuleResult, + type RuntimeProfileContext, + 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"; + +/** 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. + */ +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 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. + */ +function runtimeRegionEnv(bedrock: boolean): Record { + const region = RUNTIME_INPUTS.awsRegion; + 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. + */ +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, + profile: Readonly = {}, +): 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.", + ...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.`, + ), + ]; +} + +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 }; + // 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; + 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, warnings); + 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, + warnings: string[], +): 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, + warnings, + ); + const filesystem = runtimeFilesystem( + local.filesystem, + tableOf(templateLocal.filesystem), + tableOf(templateRuntime.filesystem), + ); + if (filesystem !== undefined) result.filesystem = filesystem; + if (local.ingress !== undefined) { + 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; +} + +/** + * `[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 result: TomlTable = {}; + for (const [name, entry] of Object.entries(tool)) { + if (!Object.hasOwn(templateLocal, name) || !sameValue(entry, templateLocal[name])) { + result[name] = entry; + } + } + 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; + 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, an + * agent with no `PYTHONPATH` gets the code folder, where the Runtime installs the dependencies. + */ +function runtimeEnv( + env: unknown, + templateLocal: TomlTable, + templateRuntime: TomlTable, + bedrock: boolean, + context: RuntimeProfileContext, + warnings: string[], +): 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)) { + // 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 || 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" && result.PYTHONPATH === undefined) { + result.PYTHONPATH = context.paths.runtimeCode; + } + return result; +} + +/** + * `[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, + 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 runtimeGrants = listOf(templateRuntime[name]); + const kept = runtimeGrants.filter( + (grant) => !includesPath(localGrants, grant) || includesPath(grants, grant), + ); + const users = grants.filter( + (grant, index) => + !includesPath(localGrants, grant) && + !includesPath(kept, grant) && + !includesPath(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; +} + +/** 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))); + +/** 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. 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 + * of the local profile that changes. + */ +function runtimeIngress( + ingress: unknown, + agentKeepsTemplatePort: boolean, + context: RuntimeProfileContext, + warnings: string[], +): unknown { + 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}.`, + ); + } + // 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, ` + + `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:`. */ +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 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, unless the envVars of the + * runtime turn observability off ({@link OBSERVABILITY_OFF_ENV}). + */ +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)) { + 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 }), + 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 }, + }; + } + const logs = Object.entries(result).some( + ([name, entry]) => + isTable(entry) && (entry.kind ?? resolved.get(name)?.kind) === "cloudwatch_logs", + ); + if (!logs && !observabilityOff(context.runtime)) { + const name = Object.hasOwn(result, "agentcore") ? "agentcore_default" : "agentcore"; + result[name] = structuredClone(DEFAULT_TELEMETRY_TARGET); + } + return result; +} + +/** `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 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); +} 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..585b2e30d --- /dev/null +++ b/src/core/project/runtimeProfile/rules/gateway.test.ts @@ -0,0 +1,709 @@ +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 { readFileSync } from "node:fs"; +import { join } from "node:path"; +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: [], + 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`: 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 = "${{ 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", () => { + 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' + + // 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.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 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 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', + [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'; + + 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( + // 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"), + ).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. + */ +/** + * 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 }) }; +} + +/** + * 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 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]) => [ + { "egress-github": "github", "egress-models-api-one-example-com": "models" }[key] ?? key, + route, + ]), + ); + +describe("the gateway rule and the Runtime renderer it replaced", () => { + const TEXT = [ + 'packs = ["@box/base", "@box/bedrock"]', + 'policies = ["policy.dw"]', + "", + "[agent]", + 'command = ["${{ workspace }}/app/agent/run"]', + "", + "[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 = ["${{ workspace }}/app/agent/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: ["/project/app/agent/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, "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: [], + places: profileKeyPlaces(text, PROFILE), + }), + ); + return { network, written, 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, derived } = bothProfiles(project(TARGETS, ["agentMemory"])); + const old = rendered("first build"); + + expect(network.failures).toEqual([]); + expect(derived.problems).toEqual([]); + expect(Object.keys(old.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(old.mcp))).toEqual(["docs"]); + 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(withEntryKeys(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, 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(withEntryKeys(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 { 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((old.egress as TomlTable)["tools.v2"]).toEqual(quoted["tools.v2"]); + 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", () => { + 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 old = rendered("rejected entries"); + const { network, 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(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 new file mode 100644 index 000000000..321e267b6 --- /dev/null +++ b/src/core/project/runtimeProfile/rules/gateway.ts @@ -0,0 +1,237 @@ +/** + * 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 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 | + * | --- | --- | + * | `[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 | + * | 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 { isHttpServer, isTable } from "../projectPaths"; +import { + RUNTIME_AWS_SIGNER, + RUNTIME_INPUTS, + type RuleResult, + type RuntimeProfileContext, + type TomlTable, +} from "../types"; + +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; +} + +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[routeKey(route, routes, context)] = egressRoute(entry, route); + 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); + 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); + } else { + egress[routeKey(route, routes, context)] = egressRoute({}, route); + } + } + + // 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; + 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 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. + */ +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]!; + // 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) => 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; +} + +/** 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"); +} + +/** + * 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): TomlTable { + const { destinations: _destinations, secret: _secret, backends: _backends, ...kept } = entry; + return { destinations: [route.host], ...kept, backends: [gatewayBackend(route)] }; +} + +/** + * 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): 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)], + }; +} + +/** + * 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: RUNTIME_INPUTS.awsRegion }, + }, + }; +} 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..075d6e1c3 --- /dev/null +++ b/src/core/project/runtimeProfile/rules/paths.test.ts @@ -0,0 +1,372 @@ +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"; + +/** + * The context of the local profile `text`. dev starts box in the code folder, `${{ workspace }}`. + */ +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: [], + 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 }}"; +const CODE = "${{ inputs.code.dir }}"; +const PYTHON = "${{ inputs.python.path }}"; +const PREFIX = "${{ inputs.python.prefix }}"; +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( + 'packs = ["@box/base"]', + "", + "[agent]", + '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}}/notes", LEVEL = "debug" }`, + "", + "[mcp.notes.filesystem]", + `read = ["${APP}", { path = "${APP}/.venv", optional = true }, { path = "\${{ home }}/.local/share/uv/python", optional = true }]`, + "", + "[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 }], + }, + network: { contain_egress: true }, + }, + lister: { + command: [`${CODE}/bin/lister`, "--all"], + "native-filesystem-policy": false, + filesystem: { read: [`${CODE}/data`] }, + }, +}; + +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 }}/lib"', + "[mcp.notes]", + 'type = "stdio"', + '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)); + + // 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 }}/lib:${{ inputs.code.dir }}", + ); + expect((((profile.mcp as TomlTable).notes as TomlTable).env as TomlTable).PYTHONPATH).toBe( + "/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]", + '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. + 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 }}/.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 " + + "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]", + 'read = ["${{ workspace }}", { path = "${{ home }}/.aws", optional = true }]', + 'deny = ["${{ home }}/.ssh", "${{ workspace }}/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. + 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 }}/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("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]", + `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}/src:${CODE}` }, + }, + }, + tool: { lister: { command: [`${CODE}/bin/lister`] } }, + }); + }); + + 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 = "${PREFIX}/lib:${APP}/src:${APP}"`, + "[mcp.notes]", + 'type = "stdio"', + `command = ["${APP}/.venv/bin/python3.15", "-m", "notes"]`, + `env = { PYTHONPATH = "${PREFIX}/lib:${APP}/lib:${APP}" }`, + ); + + expect(moved(text)).toEqual({ + agent: { + command: [PYTHON, "-m", "main"], + env: { PYTHONPATH: `${PREFIX}/lib:${CODE}/src:${CODE}` }, + }, + mcp: { + notes: { + type: "stdio", + command: [PYTHON, "-m", "notes"], + env: { PYTHONPATH: `${PREFIX}/lib:${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 }}/.files-token"', + "[mcp.docs]", + 'type = "http"', + 'destinations = ["docs.example.com"]', + 'secret.ref = "file://${{ workspace }}/.docs-token"', + "[telemetry.local]", + 'kind = "file"', + 'path = "${{ workspace }}/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 new file mode 100644 index 000000000..8593ea27e --- /dev/null +++ b/src/core/project/runtimeProfile/rules/paths.ts @@ -0,0 +1,137 @@ +/** + * 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, 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. + */ +import { + grantPath, + isDroppableGrant, + isTable, + keyLabel, + mapProjectPaths, + moveProjectPath, + pathProblem, + processTables, + programOf, + runtimePythonPath, + withOneGrantForEachPath, +} from "../projectPaths"; +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(withoutVenvDeny(table, paths, warnings), (value) => { + const result = moveProjectPath(value, paths); + return typeof result === "string" ? result : value; + }); + for (const { key, table: process, leaf } of processTables(moved)) { + if (isTable(process.filesystem)) { + process.filesystem = withOneGrantForEachPath( + withoutLostGrants(process.filesystem, key, paths, warnings), + ); + } + // 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; + if (own === undefined) { + if (leaf) process.env = { ...env, PYTHONPATH: runtimePythonPath(paths) }; + } else if (typeof own === "string") { + process.env = { ...env, PYTHONPATH: withRuntimePythonPath(own, paths) }; + } + } + 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. + */ +function withRuntimePythonPath(own: string, paths: RuntimePaths): string { + const entries = [...new Set(own.split(":").filter((entry) => entry !== ""))]; + return [...entries, ...(entries.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 + * `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 + * 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; + } + const kept = 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; + }); + // A list that build empties goes. + if (kept.length > 0 || grants.length === 0) result[list] = kept; + } + return result; +} 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..ed1720f94 --- /dev/null +++ b/src/core/project/runtimeProfile/rules/refusals.test.ts @@ -0,0 +1,459 @@ +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"; +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"; + +/** + * 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) => + 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: withDeployRegion(cloudWatchTelemetry(parse(text) as TomlTable), "us-west-2", PROFILE) + .telemetry, + 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 }}"; + +/** 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 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 }}-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.", + ], + ])("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"]', + ); + + // 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`], + ["tool.lister.filesystem.write", `${PROFILE}:10:1`], + ["tool.lister.filesystem.write", `${PROFILE}:10:1`], + ]); + }); + + test.each([ + ["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 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( + 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 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.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([]); + }, + ); + + 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"], + ]); + }); + + 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 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 = { + 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"'); + + 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 }}/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) => { + 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"', + "", + // 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([ + { + 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 new file mode 100644 index 000000000..95a343bee --- /dev/null +++ b/src/core/project/runtimeProfile/rules/refusals.ts @@ -0,0 +1,237 @@ +/** + * 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`, `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 | + * | 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. 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 { + grantPath, + isDroppableGrant, + isRuntimeProgram, + isTable, + keyLabel, + mapProjectPaths, + moveProjectPath, + pathProblem, + processTables, + programOf, + type PathProblem, +} from "../projectPaths"; +import type { + RuleResult, + RuntimeProfileContext, + RuntimeProfileProblem, + RuntimeProfileProblemCode, + TomlTable, +} from "../types"; + +/** 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", + "cloudwatch_traces", +]); + +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) }); + + 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)) { + // 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; + } + // 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; + 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}.`, + }; + const moved = (value: string) => { + const result = moveProjectPath(value, paths); + return typeof result === "string" ? undefined : result.problem; + }; + mapProjectPaths(table, (value, key) => { + // 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 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 [ + ["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 + // 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 { + table: structuredClone(table) as TomlTable, + problems: inProfileOrder(problems), + warnings, + }; +} + +/** 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 ( + `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 identical problem 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); +} 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..628d1520f --- /dev/null +++ b/src/core/project/runtimeProfile/types.ts @@ -0,0 +1,120 @@ +/** + * 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 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). */ + 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 }}`, where dev starts box. */ + 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[]; + 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 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. */ + "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]; + +/** 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; diff --git a/src/core/project/templates/boxProfile.test.ts b/src/core/project/templates/boxProfile.test.ts index e6951250a..b4f65b42a 100644 --- a/src/core/project/templates/boxProfile.test.ts +++ b/src/core/project/templates/boxProfile.test.ts @@ -1,17 +1,11 @@ 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, boxStartFolder, @@ -19,7 +13,7 @@ import { renderAgentCoreCodeZipPack, renderAgentCorePack, renderBoxProfile, - renderRuntimeBoxProfile, + runtimeAgentTemplate, startsInBoxOnCodeZip, } from "./boxProfile"; @@ -69,8 +63,8 @@ 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"], - profile: { name: "V3Demo" }, + packs: ["@box/base", "@box/bedrock"], + profile: { name: "V3Demo-agent" }, project: { access: "write" }, options: { bedrock: { region: "us-west-2" } }, agent: { @@ -84,8 +78,9 @@ describe("renderBoxProfile", () => { }); }); - test("names itself after the project, and the folder `agentcore dev` starts box in", () => { - expect(profile("agent-python-minimal-box").profile).toEqual({ name: "V3Demo" }); + test("names itself after the project and the runtime, and the folder `agentcore dev` starts box in", () => { + // box keeps one profile of each name on a machine, and each runtime has its own local profile. + expect(profile("agent-python-minimal-box").profile).toEqual({ name: "V3Demo-agent" }); const text = renderBoxProfile("V3Demo", STRANDS)!; expect(text).toContain("runs `box run ../../.box/agent/local/profile.toml` there"); }); @@ -123,7 +118,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" } }); @@ -158,7 +153,7 @@ describe("renderBoxProfile", () => { test("gives the MCP server no route, because it calls no model", () => { const mcp = profile("mcp-python-fastmcp-box"); - expect(mcp.packs).toEqual(["box/base"]); + expect(mcp.packs).toEqual(["@box/base"]); expect(mcp.options).toBeUndefined(); expect(mcp.egress).toBeUndefined(); }); @@ -221,7 +216,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 }); }, @@ -229,7 +224,7 @@ describe("renderBoxProfile", () => { test("routes a LiteLLM agent on a bedrock/ model through Bedrock", () => { const { packs, egress } = profile("agent-python-strands-box", { modelProvider: "LiteLLM" }); - expect(packs).toEqual(["box/base", "box/bedrock"]); + expect(packs).toEqual(["@box/base", "@box/bedrock"]); expect(egress).toEqual({ bedrock: { secret: { ref: "aws://default" } } }); }); @@ -332,552 +327,57 @@ 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 }}/.venv/bin/python", + "-m", + "uvicorn", + "main:app", + "--app-dir", + "${{ workspace }}", + "--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("gives an A2A agent card the Runtime's own URL, not the local ingress port", () => { - const spec = { - name: "V3Demo", - runtimes: [{ name: "agent", build: "CodeZip", protocol: "A2A", modelProvider: "Bedrock" }], - agentCoreGateways: [], - } as unknown as ProjectSpec; - const profile = parse(renderRuntimeBoxProfile(spec, spec.runtimes[0]!)) as Record; - - // serve_a2a gives AGENTCORE_RUNTIME_URL precedence, so localhost here would send clients that - // read the card back to themselves. - expect(profile.agent.env.AGENTCORE_RUNTIME_URL).toBe("${{ inputs.runtime.url }}"); - }); - - 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-box"), - "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", - 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 }], + env: { PORT: "8081", PYTHONUTF8: "1", PYTHONUNBUFFERED: "1" }, + filesystem: { + read: ["${{ workspace }}", "${{ home }}/.local/share/uv/python", "/usr/lib64", "/lib64"], + exec: ["${{ workspace }}", "${{ home }}/.local/share/uv/python"], }, + ingress: [{ listen: "0.0.0.0:8080", workload_port: 8081 }], }); }); - test.each(["agent-python-strands-box-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-box"); - 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-box", { - 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(), + test("gives the container template's [agent] on the Runtime, which keeps the image's paths", () => { + const agent = runtimeAgentTemplate(template("agent-python-strands-box-container"))!; + const local = profile("agent-python-strands-box-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(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, - ]); - - 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"), - }); - }); - - 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", - }), - ); - - 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({}); + 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("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("gives no [agent] for a template that is not a box template", () => { + expect(runtimeAgentTemplate(resolveRuntimeTemplateShortcut("agent-python-strands"))).toBe( + undefined, ); }); - - 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"]); - }); }); describe("startsInBoxOnCodeZip", () => { @@ -907,9 +407,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", () => { @@ -943,6 +443,20 @@ 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.log_group).toEqual({ + description: "The runtime's own CloudWatch Logs log group.", + from: "env:OTEL_EXPORTER_OTLP_LOGS_HEADERS", + key: "x-aws-log-group", + }); + expect(inputs.runtime.log_stream).toEqual({ + description: "The runtime's own CloudWatch Logs log stream.", + from: "env:OTEL_EXPORTER_OTLP_LOGS_HEADERS", + key: "x-aws-log-stream", + }); + }); + test("declares the A2A card URL input from the Runtime's AGENTCORE_RUNTIME_URL", () => { const { inputs } = pack([]); expect(inputs.runtime.url.from).toBe("env:AGENTCORE_RUNTIME_URL"); @@ -968,8 +482,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 5746bd2b6..9116c1746 100644 --- a/src/core/project/templates/boxProfile.ts +++ b/src/core/project/templates/boxProfile.ts @@ -1,5 +1,4 @@ import { join, posix } from "node:path"; -import { InputValidationError } from "../../../errors/errors"; import { DEFAULT_EGRESS_BEDROCK_REGION, callsBedrockModel, @@ -10,7 +9,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"; @@ -47,12 +45,24 @@ 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. + */ +export const RUNTIME_LOGS_HEADERS_ENV = "OTEL_EXPORTER_OTLP_LOGS_HEADERS"; + +/** The pack of box that each box profile imports. */ +const BOX_BASE_PACK = "@box/base"; + +/** The pack of box that routes the Bedrock model calls, with its `[options] bedrock.region`. */ +export const BOX_BEDROCK_PACK = "@box/bedrock"; + /** {@link renderAgentCorePack}. */ -export const AGENTCORE_PACK_NAME = "box/agentcore"; +export const AGENTCORE_PACK_NAME = "@box/agentcore"; export const AGENTCORE_PACK_PATH = "resources/packs/agentcore/pack.toml"; /** {@link renderAgentCoreCodeZipPack}. */ -export const AGENTCORE_CODEZIP_PACK_NAME = "box/agentcore-codezip"; +export const AGENTCORE_CODEZIP_PACK_NAME = "@box/agentcore-codezip"; export const AGENTCORE_CODEZIP_PACK_PATH = "resources/packs/agentcore-codezip/pack.toml"; /** @@ -63,7 +73,7 @@ export const AGENTCORE_CODEZIP_PACK_PATH = "resources/packs/agentcore-codezip/pa const GATEWAY_URL_PATTERN = "https://[a-z0-9][-a-z0-9.]*[.]amazonaws[.]com(/[A-Za-z0-9_-][A-Za-z0-9_.-]*)*"; -/** As box/bedrock bounds `bedrock.region`. */ +/** As @box/bedrock bounds `bedrock.region`. */ const AWS_REGION_PATTERN = "[a-z]{2}(-[a-z]+)?-(central|north|south|east|west)+-[0-9]+"; /** @@ -73,37 +83,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 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 - * `boxRelease.json` pins (0.1.11-linux-preview.6). When the pin moves, check box/base's tools: box - * refuses a CodeZip box profile if a tool it misses gets the project write grant. + * 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-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"]; @@ -158,6 +141,11 @@ 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. */ +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)); @@ -171,6 +159,15 @@ export function hasBoxProfile(runtime: ScaffoldRuntimeInput): boolean { return startsInBoxOnCodeZip(runtime) || isBoxedContainer(runtime); } +/** + * The code folder of a CodeZip box template in its local profile: `agentcore dev` starts box in + * the folder of the runtime, so the profile names it as `${{ workspace }}`. + */ +const CODEZIP_START_FOLDER = "${{ workspace }}"; + +/** The URL an A2A agent card advertises on the Runtime, from an input of @box/agentcore. */ +const RUNTIME_URL = "${{ inputs.runtime.url }}"; + /** * The folder, from the project root, that box starts a run or a resolution of `runtime`'s local * profile in: the runtime's own code folder for a CodeZip runtime, from agentcore.json, so the @@ -357,6 +354,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 @@ -367,11 +370,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. */ @@ -379,13 +380,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`)], }; } @@ -395,88 +396,51 @@ function codeZipRunner(protocol: Protocol, appDir: string, workloadPort: number) * /usr/local. `agentcore dev` sets LOCAL_DEV and reloads it on edits. */ function containerRunner(workloadPort: number, dev: boolean): Runner { - const appDir = "${{ workspace }}"; + const appDir = CODEZIP_START_FOLDER; const { command, env } = serve("HTTP", appDir, workloadPort, dev); return { command, 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, - "${{ inputs.runtime.url }}", - ); +function runtimeCodeZipRunner(protocol: Protocol, appDir: string, workloadPort: number): Runner { + // An A2A agent card advertises the URL of the Runtime, which @box/agentcore reads. + const { command, env } = serve(protocol, appDir, workloadPort, false, undefined, RUNTIME_URL); 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; @@ -488,7 +452,6 @@ export function renderBoxProfile( const appDir = "${{ workspace }}"; 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 @@ -496,298 +459,102 @@ 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, appDir, 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)), - }; + 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\` for ${codeFolder}: ` + - `\`agentcore dev\` runs \`box run ${posix.relative(codeFolder, boxLocalProfileFile(runtime.runtimeName))}\` ` + - "there, so the agent can reach no other folder of the project."; - 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\` for ${codeFolder}: ` + + `\`agentcore dev\` runs \`box run ${posix.relative(codeFolder, boxLocalProfileFile(runtime.runtimeName))}\` ` + + "there, so the agent can reach no other folder of the project."; + 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. +# 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_PACK, ...(bedrock ? [BOX_BEDROCK_PACK] : [])]); 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(projectName)} +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)}`; -} - -/** 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 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. - */ -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 }}" -`; +${toolDenyWrite}${bedrockRoute}${keyedRoute}`; } /** - * 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. + * 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 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, CODEZIP_START_FOLDER, 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 }], + }; } /** @@ -839,12 +606,14 @@ 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 - * 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 ?? []; @@ -883,6 +652,18 @@ description = "The AWS region the runtime runs in." from = "env:AWS_REGION" 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" + # The URL an A2A agent card advertises. Outside a box, serve_a2a reads AGENTCORE_RUNTIME_URL itself # and otherwise names the contract port; the agent in the box gets the same value through this. [inputs.runtime.url] @@ -893,7 +674,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 @@ -945,9 +726,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 { diff --git a/src/core/project/templates/boxStartPy.test.ts b/src/core/project/templates/boxStartPy.test.ts new file mode 100644 index 000000000..a831d3f84 --- /dev/null +++ b/src/core/project/templates/boxStartPy.test.ts @@ -0,0 +1,163 @@ +import { afterEach, describe, expect, test } from "bun:test"; +import { spawnSync } from "node:child_process"; +import { + chmodSync, + mkdirSync, + mkdtempSync, + 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; + +/** 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)) + 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", + // 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)))", + START_PY, + executable, + ], + { encoding: "utf8" }, + ); + expect(out.stderr).toBe(""); + return out.stdout.trim(); +} + +/** + * 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"]); + + expect(boxPython(join(bin, "python3.12"))).toBe(join(bin, "python3.12")); + }); + + 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(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"]]); + + // 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(skipped)("keeps an aliased name when nothing else names that Python", () => { + const bin = binFolder(["python3"]); + + expect(boxPython(join(bin, "python3"))).toBe(join(bin, "python3")); + }); +}); diff --git a/src/core/project/templates/project.ts b/src/core/project/templates/project.ts index 4c6a5cde8..e5467e67c 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}`),