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
37 changes: 26 additions & 11 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,9 @@ jobs:
aws-region: ${{ vars.E2E_REGION || 'us-east-1' }}
unset-current-credentials: true
# box ships only arm64 builds, so only the macOS (Apple silicon) and Linux arm64 runners can run
# the Box tests. They skip on a runner with no box on PATH. macOS is left out for now: its pinned
# box build is killed as soon as it starts (`Killed: 9` on `box --version`), so on macOS the Box
# tests skip and the rest of the suite still runs.
# the Box tests. They skip on a runner with no box on PATH.
- name: Install box
if: matrix.name == 'Linux-arm64'
if: matrix.name == 'macOS' || matrix.name == 'Linux-arm64'
env:
# The build's key in boxRelease.json, which pins its archive and SHA-256.
BUILD: ${{ matrix.name == 'macOS' && 'darwin' || 'linux' }}
Expand All @@ -165,10 +163,27 @@ jobs:
SUM=$(command -v sha256sum || echo "shasum -a 256")
echo "${SHA} ${WORK}/${ASSET}" | $SUM -c -
# box reads its packs from resources/ beside it, so keep the release together.
sudo mkdir -p /opt/box
sudo tar --no-same-owner -xzf "${WORK}/${ASSET}" -C /opt/box
sudo ln -sf /opt/box/box /usr/local/bin/box
box --version
if [[ "$BUILD" == darwin ]]; then
# On macOS, unpack as the runner user into a folder it owns, as a developer does. The
# folder must not be named `box`: macOS reads a folder `box` that holds an executable
# `box` as a bundle, finds the signature invalid (`invalid Info.plist`), and kills box at
# launch (Killed: 9). That is what happened under /opt/box.
DIR="${RUNNER_TEMP}/box-${VER}"
mkdir -p "$DIR"
tar -xzf "${WORK}/${ASSET}" -C "$DIR"
echo "$DIR" >> "$GITHUB_PATH"
# If macOS refuses box, say why before running it.
codesign --verify --strict --verbose=2 "$DIR/box" || codesign -dv --verbose=4 "$DIR/box" || true
if ! "$DIR/box" --version; then
log show --last 2m --predicate 'eventMessage CONTAINS "box"' --style compact 2>/dev/null | tail -40 || true
exit 1
fi
else
sudo mkdir -p /opt/box
sudo tar --no-same-owner -xzf "${WORK}/${ASSET}" -C /opt/box
sudo ln -sf /opt/box/box /usr/local/bin/box
box --version
fi
# Ubuntu 24.04 lets AppArmor stop an unprivileged process from making a user namespace, which
# `box run` needs for its sandbox. The runner is a throwaway VM.
- name: Allow user namespaces for box
Expand All @@ -179,7 +194,7 @@ jobs:
# repository is private and this job's GITHUB_TOKEN reads only this one, so the token comes
# from the repository's GitHub App, scoped to the L3 repository and read-only.
- name: Generate a read token for the L3 constructs
if: matrix.name == 'Linux-arm64'
if: matrix.name == 'macOS' || matrix.name == 'Linux-arm64'
id: l3-token
uses: actions/create-github-app-token@64ab729a6294000f5aa4a4bc0b73d1f32bc45510 # v3.3.0
with:
Expand All @@ -189,7 +204,7 @@ jobs:
repositories: agentcore-l3-cdk-constructs
permission-contents: read
- name: Check out the L3 constructs
if: matrix.name == 'Linux-arm64'
if: matrix.name == 'macOS' || matrix.name == 'Linux-arm64'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
repository: aws/agentcore-l3-cdk-constructs
Expand All @@ -201,7 +216,7 @@ jobs:
# Packed onto the runner only: nothing is published. The Box tests install it into each Box
# project's agentcore/cdk (AGENTCORE_E2E_BOX_CDK in e2eTest/project/templates.test.ts).
- name: Pack the L3 constructs for the Box tests
if: matrix.name == 'Linux-arm64'
if: matrix.name == 'macOS' || matrix.name == 'Linux-arm64'
working-directory: .l3-cdk
run: |
npm ci --no-audit --no-fund
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ box profile; build and deploy stop without them. Build derives the AgentCore Run
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.
and the profile checks of `build`: an older box cannot read the profiles that this CLI writes.

`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
Comment thread
mquang-amazon marked this conversation as resolved.
Resolved
Expand Down
27 changes: 14 additions & 13 deletions docs/box-local-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ fork of [strands-agents/box](https://github.com/strands-agents/box), then run
[aws/agentcore-l3-cdk-constructs#481](https://github.com/aws/agentcore-l3-cdk-constructs/pull/481): it gives the
runtime's role its Memory grant, and a `PRIVATE_VPC` runtime the AgentCore endpoint of its private VPC. Without it,
the box cannot reach Memory.
- `box` `0.3.0` on your `PATH` (`0.3.0-preview.1` on macOS), the release the CLI pins. Use that
release: the box
- `box` `0.3.0` on your `PATH`, the release the CLI pins. Use that 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 @@ -68,16 +67,18 @@ Linux x86_64 (`x86_64-unknown-linux-gnu`). The release's `box-v<version>-*` arch
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.
Download the archive for your machine, check it, and unpack it into a versioned folder. On macOS, do
not unpack it into a folder named `box`: macOS reads a folder `box` that holds the executable `box` as
a bundle, reports its signature as invalid (`invalid Info.plist`), and kills box at launch.

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

```
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
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-apple-darwin.tar.gz
curl -fSLO https://github.com/strands-agents/box/releases/download/v0.3.0/SHA256SUMS.txt
grep box-cli-v0.3.0-aarch64-apple-darwin SHA256SUMS.txt | shasum -a 256 -c -
tar -xzf box-cli-v0.3.0-aarch64-apple-darwin.tar.gz
```

Linux arm64:
Expand All @@ -93,10 +94,10 @@ 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).
`BOX_VERSION` is the folder you unpacked into: `0.3.0-preview.1` on macOS, `0.3.0` on Linux.
`BOX_VERSION` is the folder you unpacked into, `0.3.0`.

```
BOX_VERSION=0.3.0-preview.1
BOX_VERSION=0.3.0
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
```
Expand All @@ -113,11 +114,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.3.0`, or `box 0.3.0-preview.1` on macOS (from
- `box --version` should print the pinned `box 0.3.0` (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.3.0-preview.1"`.
`xattr -dr com.apple.quarantine "$HOME/.local/share/box/0.3.0"`.

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
15 changes: 7 additions & 8 deletions e2eTest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,19 +26,18 @@ The `box` tests cover the Strands Box templates, which run their agent in a box.
invoke each one on AgentCore Runtime, and run `agentcore dev` with one local invoke for each. They
are optional and need a `box` on your PATH: `create` checks for one for a CodeZip box template, and
`build` and `deploy` run `box profile show` for every Box template, the container one too. Without
one, they skip. box ships only arm64 builds, so in CI only the Linux arm64 runner
(`ubuntu-24.04-arm`) has one: it installs the box that `src/core/project/backends/boxRelease.json`
pins. The macOS runner (Apple silicon) is left out for now, because the pinned macOS box build is
killed as soon as it starts (`Killed: 9`), so there the Box tests skip. `create` also installs the agent's dependencies
one, they skip. box ships only arm64 builds, so in CI only the macOS runner (Apple silicon) and the
Linux arm64 runner (`ubuntu-24.04-arm`) have one: each installs the box that
`src/core/project/backends/boxRelease.json` pins. `create` also installs the agent's dependencies
and the CDK app's, which `dev` and `deploy` use, so the tests don't pass `--skip-install`.

The tests that deploy also need `AGENTCORE_E2E_BOX_CDK`: the pinned `@aws/agentcore-cdk` release
cannot deploy a Box project yet. Set it to an `@aws/agentcore-cdk` version or a `file:` tarball
that can, for example one packed from the `box-integration` branch of
[agentcore-l3-cdk-constructs](https://github.com/aws/agentcore-l3-cdk-constructs) with
`npm run build && npm pack --ignore-scripts`. The tests install it in the `agentcore/cdk` of each
Box project that deploys. Without it, they skip. In CI, the Linux arm64 runner sets it to a
tarball they build from agentcore-l3-cdk-constructs at the workflow's `l3Ref` input (default
Box project that deploys. Without it, they skip. In CI, the macOS and Linux arm64 runners set it to
a tarball they build from agentcore-l3-cdk-constructs at the workflow's `l3Ref` input (default
`box-integration`), checked out with a read-only token from the repository's GitHub App. Remove
those steps once a released `@aws/agentcore-cdk` deploys Box projects and the pin is bumped. CI
also skips `agent_python_langchain_box` in the deploy tests: its AgentCore Runtime logs hold
Expand All @@ -64,8 +63,8 @@ The `box-egress` tests check that box lets the agent reach the host its profile
on AgentCore Runtime, where the allowed host's calls go through the runtime's Box gateway. The
second deploys, so it also needs `AGENTCORE_E2E_BOX_CDK`. They reach public hosts, so the network
can make them fail: the dev test retries twice, and the deployed one retries only its invoke.
`--tagsFilter='box'` leaves them out. A full run includes them; in CI they run on the Linux arm64
runner:
`--tagsFilter='box'` leaves them out. A full run includes them; in CI they run on the macOS and Linux
arm64 runners:

```sh
bun run test:e2e -- --tagsFilter='box-egress'
Expand Down
5 changes: 2 additions & 3 deletions src/core/project/backends/boxRelease.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@
"sha256": "9c7c01b22374b0041823429ba068745829ac3800db7c43b762f1836b54b40658"
},
"darwin": {
"version": "0.3.0-preview.1",
"target": "aarch64-apple-darwin",
"asset": "box-cli-v0.3.0-preview.1-aarch64-apple-darwin.tar.gz",
"sha256": "eaf085e443d0a1f6c9e5566194e786274c5bf30d6f7681923221f5680317bb77"
"asset": "box-cli-v0.3.0-aarch64-apple-darwin.tar.gz",
"sha256": "bc077119fe6b9c4ff84dffea4f895bd23531d7eda36c965aa5503131c69aaa70"
Comment thread
mquang-amazon marked this conversation as resolved.
Resolved
}
}
}
9 changes: 3 additions & 6 deletions src/core/project/backends/boxRelease.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -268,16 +268,13 @@ describe("the pinned releases", () => {
);
});

test("the install hint names the box-cli archive of the pinned release, and the macOS release", () => {
// The macOS build of 0.3.0 does not run, so macOS gets the darwin pin's release.
test("the install hint names the box-cli archive of the pinned release", () => {
// macOS and Linux come from the same release, so the hint names no other macOS release.
expect(BOX_INSTALL_HINT).toBe(
"Install box: download box-cli-v0.3.0-<target>.tar.gz for your machine from " +
"https://github.com/strands-agents/box/releases/tag/v0.3.0 (not a box-v0.3.0-* archive, " +
"which has no packs), unpack it into a folder (tar -xzf <archive> -C <folder>), and add " +
"that folder to your PATH. On macOS, use " +
"box-cli-v0.3.0-preview.1-aarch64-apple-darwin.tar.gz from " +
"https://github.com/strands-agents/box/releases/tag/v0.3.0-preview.1 instead: the macOS " +
"build of 0.3.0 does not run.",
"that folder to your PATH.",
);
});
});
6 changes: 1 addition & 5 deletions src/core/project/boxProfileResolver.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,7 @@ const SHOWN_POLICY =
boxReachRules("mcp", "docs", ["docs.example.com"]);

/** The last sentence of each error that says to install another box: the pinned release. */
const INSTALL =
`Install box ${BOX_RELEASE.version} (https://github.com/strands-agents/box/releases/tag/v${BOX_RELEASE.version}), then retry. ` +
"On macOS, use box-cli-v0.3.0-preview.1-aarch64-apple-darwin.tar.gz from " +
"https://github.com/strands-agents/box/releases/tag/v0.3.0-preview.1 instead: the macOS build " +
"of 0.3.0 does not run.";
const INSTALL = `Install box ${BOX_RELEASE.version} (https://github.com/strands-agents/box/releases/tag/v${BOX_RELEASE.version}), then retry.`;

/**
* `box profile show open --format json --full` for a profile with the routes `auth` and `github`
Expand Down
2 changes: 1 addition & 1 deletion src/core/project/templates/boxProfile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const ABSOLUTE_PATH_PATTERN = "(/[.]{0,2}[A-Za-z0-9_+-][A-Za-z0-9_.+-]*)+";
/**
* The tools of @box/base that get the project's write grant: box gives each one its own grant,
* so each lists the agent's `deny_write` folders as well. Taken from @box/base in the box release
* that `boxRelease.json` pins (0.3.0, and 0.3.0-preview.1 for macOS), which has no tools: it
* that `boxRelease.json` pins (0.3.0), which has no tools: it
* dropped `uname`, and refuses a
* `[tool.uname]` table with no `command`. 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.
Expand Down
Loading