Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ jobs:
run: |
PIN=src/core/project/backends/boxRelease.json
REPO=$(jq -er .box.repo "$PIN")
VER=$(jq -er .box.version "$PIN")
# A build may name its own release, for a release whose build of this machine is broken.
VER=$(jq -er ".box.${BUILD}.version // .box.version" "$PIN")
ASSET=$(jq -er ".box.${BUILD}.asset" "$PIN")
SHA=$(jq -er ".box.${BUILD}.sha256" "$PIN")
# macOS's sha256sum passes a malformed checksum line, so check the hash's shape first.
Expand Down
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,11 @@ to a Box project, and refuses a TypeScript runtime and a Bedrock Agent import th
`agentcore export harness` refuses a Box project. Each box runtime needs its
`"box": { "version": ... }` in `agentcore.json`, which create and add runtime write, and its local
box profile; build and deploy stop without them. Build derives the AgentCore Runtime profile of
each runtime from its local profile. box comes from the public GitHub release `v0.1.11-preview.10` of
[mquang-amazon/box-releases](https://github.com/mquang-amazon/box-releases). No token or account
is needed to download it. Use that release's build for your machine for `agentcore dev` and the
profile checks of `build`: an older box cannot read the profiles that this CLI writes.
each runtime from its local profile. box comes from the `box-cli` archives of the public GitHub
release `v0.3.0` of [strands-agents/box](https://github.com/strands-agents/box/releases). No token
or account is needed to download it. Use that release's build for your machine for `agentcore dev`
and the profile checks of `build`: an older box cannot read the profiles that this CLI writes. On
macOS, use the build of `v0.3.0-preview.1` instead: the macOS build of `v0.3.0` does not run.

`src/core/project/backends/boxRelease.json` pins the Linux build of box that ships to AgentCore
Runtime, with its repository, version and SHA-256. It also pins the macOS arm64 build, which the e2e
Expand Down Expand Up @@ -260,7 +261,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-preview.10`. The
The CodeBuild log of the deploy shows `/tmp/box.tar.gz: OK` and `box 0.3.0`. 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.
Expand All @@ -283,7 +284,7 @@ private VPC with no internet path. It writes `"containment": "PRIVATE_VPC"` on t
- `ExpiredTokenException` from `aws` or `deploy`: your AWS credentials expired. Refresh them and
run the command again.
- `curl: (22) The requested URL returned error: 404` in the CodeBuild log, or a deploy error that
names the release URL: the pinned version is not published in `mquang-amazon/box-releases`.
names the release URL: the pinned version is not published in `strands-agents/box`.
- `SHA-256 ... not the pinned` or `sha256sum: WARNING: 1 computed checksum did NOT match`: the
release asset changed after it was pinned. Nothing was installed.
- `box run` exits with an error in the runtime log: box refused its profile, and the agent does
Expand Down
81 changes: 45 additions & 36 deletions docs/box-local-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ A Box project ships box inside its deploy artifact, so the agent runs in a box o
Each box runtime names its box release in `agentcore.json` with `"box": { "version": "<version>" }`,
which `agentcore create` writes and build keeps at the pinned release. `agentcore build` and
`agentcore deploy` download the pinned release's Linux build from
[mquang-amazon/box-releases](https://github.com/mquang-amazon/box-releases) once into
[strands-agents/box](https://github.com/strands-agents/box/releases) once into
`~/.agentcore/box/`, check its SHA-256s, and stage it into the zip, for a CodeZip runtime. For a
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
Expand All @@ -32,18 +32,20 @@ only for the box templates. The runtime's entry point and Dockerfile never decid
Every box runtime runs the box version the CLI pins in `src/core/project/backends/boxRelease.json`.
Build and deploy set each runtime's `box.version` to it, and say so when it named another; container
`dev` stages the pinned box whatever `box.version` says. To try an unreleased box build, publish it
as a GitHub pre-release with the release's file names (the `aarch64-apple-darwin` and
`aarch64-unknown-linux-gnu` archives and `SHA256SUMS.txt`), for example in a fork of
[mquang-amazon/box-releases](https://github.com/mquang-amazon/box-releases), then run
`bun scripts/bump-box-release.ts --box <version> --box-repo <owner/repo>` in your CLI checkout.
as a GitHub pre-release with the release's file names (the `box-cli-v<version>-aarch64-apple-darwin`
and `box-cli-v<version>-aarch64-unknown-linux-gnu` archives and `SHA256SUMS.txt`), for example in a
fork of [strands-agents/box](https://github.com/strands-agents/box), then run
`bun scripts/bump-box-release.ts --box <version> --box-repo <owner/repo>` in your CLI checkout. Add
`--darwin-box <version>` to take the macOS build from another release of the same repository.

## Prerequisites

- A local checkout of the CLI and of `@aws/agentcore-cdk`. The L3 checkout must have
[aws/agentcore-l3-cdk-constructs#470](https://github.com/aws/agentcore-l3-cdk-constructs/pull/470),
as its `box-integration` branch does. The Box gateway that `create` writes has
`enableApplicationLogs`, and an older L3 refuses it at synth with a `ConfigValidationError`.
- `box` `0.1.11-preview.10` on your `PATH`, the release the CLI pins. Use that release: the box
- `box` `0.3.0` on your `PATH` (`0.3.0-preview.1` on macOS), the release the CLI pins. Use that
Comment thread
mquang-amazon marked this conversation as resolved.
Resolved
Comment thread
mquang-amazon marked this conversation as resolved.
Resolved
release: the box
features and the profiles that the CLI writes change together, so an older box can refuse the
profiles. The CLI does not check the version of the box on your `PATH` yet. Build, deploy and dev
run it to read the box profile with `box profile show --format json --full`, and CodeZip dev runs
Expand All @@ -55,40 +57,43 @@ as a GitHub pre-release with the release's file names (the `aarch64-apple-darwin
## Install box

box ships as a release archive per machine on
[mquang-amazon/box-releases](https://github.com/mquang-amazon/box-releases). There are builds for
macOS on an Apple chip (`aarch64-apple-darwin`) and Linux arm64 (`aarch64-unknown-linux-gnu`); there
is no x86 build yet. Each archive unpacks flat: `box`, its two helpers, `release.json`, and
`resources/` (box's packs, which it finds beside itself).
[strands-agents/box](https://github.com/strands-agents/box/releases). The CLI uses the `box-cli-v<version>-*` archives, with builds
for macOS on an Apple chip (`aarch64-apple-darwin`), Linux arm64 (`aarch64-unknown-linux-gnu`) and
Linux x86_64 (`x86_64-unknown-linux-gnu`). The release's `box-v<version>-*` archives hold box
without its packs; do not use them. Each `box-cli` archive unpacks flat: `box`, its two helpers,
`release.json`, and `resources/` (box's packs, which it finds beside itself).

Download the archive for your machine, check it, and unpack it into a versioned folder.

macOS on an Apple chip:
macOS on an Apple chip, from `v0.3.0-preview.1`: the macOS build of `v0.3.0` does not run.

```
mkdir -p ~/.local/share/box/0.1.11-preview.10 && cd ~/.local/share/box/0.1.11-preview.10
curl -fSLO https://github.com/mquang-amazon/box-releases/releases/download/v0.1.11-preview.10/box-v0.1.11-preview.10-aarch64-apple-darwin.tar.gz
curl -fSLO https://github.com/mquang-amazon/box-releases/releases/download/v0.1.11-preview.10/SHA256SUMS.txt
grep aarch64-apple-darwin SHA256SUMS.txt | shasum -a 256 -c -
tar -xzf box-v0.1.11-preview.10-aarch64-apple-darwin.tar.gz
mkdir -p ~/.local/share/box/0.3.0-preview.1 && cd ~/.local/share/box/0.3.0-preview.1
curl -fSLO https://github.com/strands-agents/box/releases/download/v0.3.0-preview.1/box-cli-v0.3.0-preview.1-aarch64-apple-darwin.tar.gz
curl -fSLO https://github.com/strands-agents/box/releases/download/v0.3.0-preview.1/SHA256SUMS.txt
grep box-cli-v0.3.0-preview.1-aarch64-apple-darwin SHA256SUMS.txt | shasum -a 256 -c -
tar -xzf box-cli-v0.3.0-preview.1-aarch64-apple-darwin.tar.gz
```

Linux arm64:

```
mkdir -p ~/.local/share/box/0.1.11-preview.10 && cd ~/.local/share/box/0.1.11-preview.10
curl -fSLO https://github.com/mquang-amazon/box-releases/releases/download/v0.1.11-preview.10/box-v0.1.11-preview.10-aarch64-unknown-linux-gnu.tar.gz
curl -fSLO https://github.com/mquang-amazon/box-releases/releases/download/v0.1.11-preview.10/SHA256SUMS.txt
grep aarch64-unknown-linux-gnu SHA256SUMS.txt | sha256sum -c -
tar -xzf box-v0.1.11-preview.10-aarch64-unknown-linux-gnu.tar.gz
mkdir -p ~/.local/share/box/0.3.0 && cd ~/.local/share/box/0.3.0
curl -fSLO https://github.com/strands-agents/box/releases/download/v0.3.0/box-cli-v0.3.0-aarch64-unknown-linux-gnu.tar.gz
curl -fSLO https://github.com/strands-agents/box/releases/download/v0.3.0/SHA256SUMS.txt
grep box-cli-v0.3.0-aarch64-unknown-linux-gnu SHA256SUMS.txt | sha256sum -c -
tar -xzf box-cli-v0.3.0-aarch64-unknown-linux-gnu.tar.gz
```

The check must print `OK`.

Put the folder first on your `PATH`, for this shell and for new ones (use `~/.bashrc` for bash):
Put the folder first on your `PATH`, for this shell and for new ones (use `~/.bashrc` for bash).
`BOX_VERSION` is the folder you unpacked into: `0.3.0-preview.1` on macOS, `0.3.0` on Linux.

```
export PATH="$HOME/.local/share/box/0.1.11-preview.10:$PATH"
grep -q 'share/box/0.1.11-preview.10' ~/.zshrc || echo 'export PATH="$HOME/.local/share/box/0.1.11-preview.10:$PATH"' >> ~/.zshrc
BOX_VERSION=0.3.0-preview.1
Comment thread
mquang-amazon marked this conversation as resolved.
Resolved
export PATH="$HOME/.local/share/box/$BOX_VERSION:$PATH"
grep -q "share/box/$BOX_VERSION" ~/.zshrc || echo "export PATH=\"\$HOME/.local/share/box/$BOX_VERSION:\$PATH\"" >> ~/.zshrc
```

The `grep -q ... ||` adds the line only once, so running it again does not repeat it. When you move
Expand All @@ -103,11 +108,11 @@ box --version

- `which box` must name the folder you unpacked into. An older `box` earlier on your `PATH` (a
source build, or Box Core's `box` in `/usr/local/bin`) wins otherwise.
- `box --version` should print the pinned `box 0.1.11-preview.10` (from
- `box --version` should print the pinned `box 0.3.0`, or `box 0.3.0-preview.1` on macOS (from
`src/core/project/backends/boxRelease.json`). An older box can refuse the profiles that the CLI
writes.
- On macOS, if Gatekeeper refuses to run `box`, clear the download flag with
`xattr -dr com.apple.quarantine "$HOME/.local/share/box/0.1.11-preview.10"`.
`xattr -dr com.apple.quarantine "$HOME/.local/share/box/0.3.0-preview.1"`.

To move to a newer release, unpack it into its own folder the same way and change the `PATH` line to
that folder.
Expand Down Expand Up @@ -150,13 +155,16 @@ bun install

## 1. Get AWS credentials

Deploy creates real resources, so it needs write access. This example uses `ada` with an Isengard
dev account; use whatever grants credentials for your dev account.
Deploy creates real resources, so it needs write access to a development AWS account. Sign in
with IAM Identity Center, or configure access keys, in the profile you deploy with:

```
ada credentials update --account <your-dev-account> --provider isengard --role Admin
aws configure sso --profile <your-dev-profile>
export AWS_PROFILE=<your-dev-profile>
```

`aws configure` works too, for access keys.

## 2. Build and pack the local L3 constructs

`npm pack` makes a tarball you install into the generated CDK app. This is more reliable than a
Expand Down Expand Up @@ -204,7 +212,7 @@ Runtime profile, its policy files, and box in the `.box-dist/` folder of the cod
build context, and write a copy of the profile, the generated packs, and the policy files into
`.box/<runtime>/aws/` for you to read.

Box `0.1.11-linux-preview.7` names its packs `@box/base`, `@box/bedrock`, and `@box/agentcore`. A
The pinned box names its packs `@box/base`, `@box/bedrock`, and `@box/agentcore`. A
profile that names a pack `box/<name>` fails: box refuses it and names the `@box/<name>` pack.

- **Gateway targets.** Each host or `host:port` that an `[egress]` entry, an `[mcp]` server with
Expand Down Expand Up @@ -311,11 +319,12 @@ the usual way, and stops on one that has `box.version` with

The box release has these builds:

| Machine | Build | CodeZip dev | Container dev |
| ------------------- | ------------------------------------------ | ----------- | ------------- |
| macOS, Apple chip | `box-v<version>-aarch64-apple-darwin` | yes | yes |
| Linux, arm64 | `box-v<version>-aarch64-unknown-linux-gnu` | yes | yes |
| Linux or macOS, x86 | none | no | no |
| Machine | Build | CodeZip dev | Container dev |
| ----------------- | ---------------------------------------------- | ----------- | ------------- |
| macOS, Apple chip | `box-cli-v<version>-aarch64-apple-darwin` | yes | yes |
| Linux, arm64 | `box-cli-v<version>-aarch64-unknown-linux-gnu` | yes | yes |
| Linux, x86_64 | `box-cli-v<version>-x86_64-unknown-linux-gnu` | untested | no |
| macOS, Intel | none | no | no |

- The **container** image always uses the Linux arm64 build, because AgentCore Runtime is arm64. It
runs on an Apple chip Mac through Finch or Docker, and on an arm64 Linux host. An x86 host would
Expand Down Expand Up @@ -631,7 +640,7 @@ These outlive the stack. Delete them too:
often has no agent venv yet, and box then names `.venv/bin/python` under a write grant. The error
then says to run `uv sync` in the agent's folder (`app/<agent>`).
- **Build cannot download box.** The error names the release URL. Check your network; a 404 means
the pinned version is not published in `mquang-amazon/box-releases`.
the pinned version is not published in `strands-agents/box`.
- **`create` fails with `ENOENT while resolving package '@opentelemetry/core'`.** The CLI's
dependencies are not installed, so `bun` fell back to its global cache. Run `bun install` in the
CLI checkout (see "Install the CLI's dependencies").
Expand Down
38 changes: 28 additions & 10 deletions scripts/bump-box-release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@
installs on its macOS runner. 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 <version> [--box-repo <owner/repo>]
bun scripts/bump-box-release.ts --box <version> [--darwin-box <version>] [--box-repo <owner/repo>]

--darwin-box pins the macOS build of another release of the same repository, for a release whose
macOS build is broken. Without it, macOS comes from the --box release.
**/

import { join, resolve } from "node:path";
Expand All @@ -27,6 +30,7 @@ const { values } = parseArgs({
args: Bun.argv.slice(2),
options: {
box: { type: "string" },
"darwin-box": { type: "string" },
"box-repo": { type: "string" },
},
});
Expand All @@ -48,18 +52,32 @@ async function checksums(repo: string, version: string): Promise<Map<string, str
return sums;
}

const pinned = await Bun.file(FILE).json();
const repo = values["box-repo"] ?? pinned.box.repo;
const version = values.box;
const sums = await checksums(repo, version);
/** The pinned archive of `target`, which the release must list. */
function pin(target: string): { target: string; asset: string; sha256: string } {
const asset = `box-v${version}-${target}.tar.gz`;
const sha256 = sums.get(asset);
/** The pinned archive of `target` in release `version`, which the release must list. */
async function pin(
repo: string,
version: string,
target: string,
): Promise<{ target: string; asset: string; sha256: string }> {
// The box CLI archive, which holds box, its helpers, its packs and release.json. A release's
// `box-v<version>-*` archives hold only box and its helpers, with no packs.
const asset = `box-cli-v${version}-${target}.tar.gz`;
const sha256 = (await checksums(repo, version)).get(asset);
if (!sha256) throw new Error(`${repo} v${version} lists no ${asset}`);
return { target, asset, sha256 };
}

const pinned = await Bun.file(FILE).json();
const repo = values["box-repo"] ?? pinned.box.repo;
const version = values.box;
const darwinVersion = values["darwin-box"] ?? version;
console.log(`box: ${pinned.box.repo} ${pinned.box.version} → ${repo} ${version}`);
const box = { repo, version, linux: pin(LINUX_TARGET), darwin: pin(DARWIN_TARGET) };
if (darwinVersion !== version) console.log(`box macOS: ${darwinVersion}`);
const darwin = await pin(repo, darwinVersion, DARWIN_TARGET);
const box = {
repo,
version,
linux: await pin(repo, version, LINUX_TARGET),
darwin: darwinVersion === version ? darwin : { version: darwinVersion, ...darwin },
};

await Bun.write(FILE, `${JSON.stringify({ box }, null, 2)}\n`);
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Build stopped: 10 problems in the Box profile and agentcore.json. Build wrote no
.box/agent_python_strands/local/policy.dw:7:1 This rule allows requests to every host, and each gateway target needs one fixed host. Add a condition that names each host, for example context.input.host == "api.example.com".
.box/agent_python_strands/local/profile.toml:3:1 The rule "pack_mirrors", which a pack in `packs` adds, allows each host that matches "*.mirror.example.com", and each gateway target needs one fixed host. Name each host in the rule, for example context.input.host == "api.example.com".
.box/agent_python_strands/local/profile.toml:3:1 [egress.legacy], which a pack in `packs` adds, reads its secret from credsd://prod, and the gateway cannot read credsd. Use an env:// secret, which build stores as an API key credential.
.box/agent_python_strands/local/profile.toml:50:1 [egress.signed] signs requests to api.example.com with aws://default, and the gateway signs only for Bedrock, AgentCore, and Lambda function URL hosts. Use an env:// secret for this host, or remove the secret.
.box/agent_python_strands/local/profile.toml:54:1 [egress.wide] has the wildcard destination "*.wide.example.com", and each gateway target needs one fixed host. Name each host in `destinations`.
.box/agent_python_strands/local/profile.toml:58:1 [mcp.docs] has the destination "docs.example.com/mcp", and the gateway route of an MCP server takes a host with no path. Remove /mcp from the destination. The agent's MCP client keeps the path in its URL.
.box/agent_python_strands/local/profile.toml:47:1 [egress.signed] signs requests to api.example.com with aws://default, and the gateway signs only for Bedrock, AgentCore, and Lambda function URL hosts. Use an env:// secret for this host, or remove the secret.
.box/agent_python_strands/local/profile.toml:51:1 [egress.wide] has the wildcard destination "*.wide.example.com", and each gateway target needs one fixed host. Name each host in `destinations`.
.box/agent_python_strands/local/profile.toml:55:1 [mcp.docs] has the destination "docs.example.com/mcp", and the gateway route of an MCP server takes a host with no path. Remove /mcp from the destination. The agent's MCP client keeps the path in its URL.
agentcore/agentcore.json The gateway target 'gh' for api.github.com sends the API key credential 'github' in the header Authorization with the prefix Bearer, and [egress.github] sends no credential. Make the two the same, in agentcore.json or in .box/agent_python_strands/local/profile.toml.
Loading
Loading