Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
c6bb00b
fix(box): Keep a host reachable when two path tests of one permit hol…
Nov 20, 2026
acd1419
fix(box): Accept a field that an action test keeps from the action
Nov 20, 2026
daeec2a
fix(box): Name a connection permit that limits the address among the …
Nov 20, 2026
ec299b7
fix(box): Refuse a rule that names a port out of the range 1 to 65535
Nov 20, 2026
f93f4e7
fix(box): Name the right folder in the uv sync hint, and remove the c…
Nov 20, 2026
ddd1408
fix(box): Give a Runtime route a free name when a rule of the policy …
Nov 20, 2026
47acc2f
fix(box): Take one API key credential for its own variable and one ot…
Nov 20, 2026
d0f9523
fix(box): Warn for a host that gets no gateway target, and give a mod…
Nov 20, 2026
662b2ea
refactor(box): Refuse two box runtimes in one folder in the schema, a…
Nov 20, 2026
8942a80
fix(box): Own only the gateway targets that build recorded, and keep …
Nov 20, 2026
c065a0a
test(box): Compare the warning host exactly, for the CodeQL URL check
Nov 20, 2026
2d3ef4a
test(box): Test pathTest and findPath directly, for the review commen…
Nov 20, 2026
40116bd
fix(box): Warn for each egress- target that the one-time migration ke…
Nov 20, 2026
0628b15
docs(box): Say to commit agentcore/box-gateway-targets.json, for the …
Nov 20, 2026
4170b54
fix(box): Read each condition after a temporal or guardrails conditio…
Nov 20, 2026
460c7c9
fix(box): Write an empty record entry for each new Box gateway in cre…
Nov 20, 2026
a8116af
fix(box): Plan the credential of each route and variable that the run…
Nov 20, 2026
36cae3b
fix(box): Say to build again for the variable of a credential that th…
Nov 20, 2026
8b47d0d
refactor(box): Run the credential planner once, and read the record a…
Nov 20, 2026
54e25ad
refactor(box): Replace the two entity casts with one type predicate, …
Nov 20, 2026
065825a
docs(box): Say when to edit agentcore/box-gateway-targets.json, for t…
Nov 20, 2026
8550a46
Merge remote-tracking branch 'upstream/box-integration' into sa/revie…
Nov 20, 2026
808e9c4
test(box): Test a guardrails condition beside the temporal one, for t…
Nov 21, 2026
df61acb
test(box): Drop the unused column of the rotated key test, for the re…
Nov 21, 2026
25a3faa
test(box): Compare the whole host or host:port of a warning, for the …
Nov 21, 2026
33ca203
Merge remote-tracking branch 'upstream/box-integration' into sa/revie…
Nov 21, 2026
854efbd
refactor(box): Keep the targets build owns in one function, for the C…
Nov 21, 2026
adad22d
fix(box): Drop the record entry of each Box gateway that remove runti…
Nov 21, 2026
298dac8
docs(box): Say that build provisions a model-provider key from the sh…
Nov 21, 2026
006f4ba
fix(box): Give equal path patterns one machine, for the Chorus nit on…
Nov 21, 2026
e6b17cb
Merge remote-tracking branch 'upstream/box-integration' into sa/revie…
Nov 21, 2026
f43a55a
fix(box): Keep the record and agentcore.json the same when either wri…
Nov 21, 2026
6596b31
fix(box): Change the record in commitSpec, after remove all removes i…
Nov 21, 2026
eb8673a
test(box): Make the record write fail through an injected writer on e…
Nov 21, 2026
3286a82
fix(box): Write the record of build's targets with the gateway edits …
Nov 23, 2026
b7c3f5b
Merge remote-tracking branch 'upstream/box-integration' into sa/revie…
Nov 23, 2026
9180136
docs(box): Say how the record of build's targets and the reserved tar…
Nov 23, 2026
eddef5f
Merge remote-tracking branch 'upstream/box-integration' into sa/revie…
Nov 23, 2026
cf76c2c
Merge box-integration into sa/review-fixes-host-map
Nov 24, 2026
4d165b2
fix(box): Put the target of each gateway of the project in managedTar…
Nov 24, 2026
da17faf
test(box): Build, remove a called gateway, and build again, for Tejas…
Nov 24, 2026
0e554e8
fix(box): Keep the record entry of each Box gateway that has no model…
Nov 24, 2026
017b5a4
fix(box): Keep each route and variable of a network for the credentia…
Nov 24, 2026
4417bd3
fix(box): Read and patch agentcore.json before build writes the recor…
Nov 24, 2026
a4b249d
Merge remote-tracking branch 'upstream/box-integration' into sa/revie…
Nov 24, 2026
1f30525
test(remove): Keep a target of the user that the record leaves out wh…
Nov 24, 2026
a78f8eb
docs(box): Say in the JSDoc of the egress- prefix that the record dec…
Nov 24, 2026
4f23dab
docs(remove): Say that a target of the user that names a removed gate…
Nov 24, 2026
4857ff9
fix(build): Warn when a second variable of one credential holds a dif…
Nov 24, 2026
bd61b5c
test(build): Keep the record when the patched agentcore.json fails th…
Nov 24, 2026
9ab3362
docs(remove): Remove the stale line comment above the JSDoc of commit…
Nov 24, 2026
1a51a44
docs(build): Move the model-provider sentence from boxRouteKeyHeldEls…
Nov 24, 2026
0692c03
fix(build): Write the record of the gateway targets through a tempora…
Nov 24, 2026
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
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,10 @@ flags: for templates that take a model provider (`agent-python-strands` and its
variant, `a2a-python-strands`, `agui-python-strands`, `agent-typescript-strands`) the wizard asks
for the provider (Amazon Bedrock, Anthropic, OpenAI, an OpenAI-compatible endpoint, Gemini, or
LiteLLM, which is Python-only), the model id, and an API-key file. The API key is kept in
`agentcore/.env.local` and provisioned as an AgentCore Identity credential on deploy.
`agentcore/.env.local` and provisioned as an AgentCore Identity credential on deploy. For a Box
template created with no API key, build reads the provider's key (such as `OPENAI_API_KEY`) from
your shell or `agentcore/.env.local`, adds a credential such as `openai`, and deploy provisions
that key in AgentCore Identity.

To bring your own code into a project instead, add a runtime for it:

Expand Down
56 changes: 37 additions & 19 deletions docs/box-local-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,37 +225,55 @@ profile that names a pack `box/<name>` fails: box refuses it and names the `@box
gets one passthrough target on `<runtime>-box-egress`. The target of an MCP server is
`egress-<server>`. Its `protocolType` is `CUSTOM`, thus only Box makes the decision on each
`mcp:call`. A host the gateway already has a target for keeps that target. Build owns only the
targets whose name starts with `egress-`: it adds them, changes them, and removes one when no host
needs it. It never changes another target.
targets it wrote, which it lists in `agentcore/box-gateway-targets.json`: it adds them, changes
them, and removes one when no host needs it. It never changes another target, also one whose name
starts with `egress-`. `agentcore add gateway-target` refuses the names `bedrock`, `agentcore`,
and `egress-*` on a Box gateway, so such a target comes only from an edit by hand or an older CLI.
`agentcore create` and `agentcore add runtime` write an empty entry for
each new Box gateway, so build owns none of its targets until it writes one. For a gateway that
the file does not list, which an older CLI made, build takes each `egress-` target that has the
shape it writes as its own, once, and warns for each other `egress-` target, which it keeps as
yours. Commit `agentcore/box-gateway-targets.json` with `agentcore.json`: in a clone without it,
build goes back to that `egress-` rule, and can take or give up the wrong targets. The
`.gitignore` that `agentcore create` writes does not exclude it. Build writes the file, but you
edit it in one case: when you change a target that build wrote, build stops and tells you to
remove that target's name from the file to keep the target as yours. Then build no longer records,
changes, or removes it.
- **The other gateways of the project.** A runtime without a box gets each gateway without
`boundRuntime` in `AGENTCORE_GATEWAY_<NAME>_URL`. For a box runtime, each of these gateways gets
the target `egress-gateway-<name>` on `<runtime>-box-egress`, with `passthrough.gateway` set to
the gateway's name. The L3 sets the target's endpoint to that gateway's URL, gives the Box
gateway's role `bedrock-agentcore:InvokeGateway` on that gateway only, and sets
`AGENTCORE_GATEWAY_<NAME>_URL` and `_HOST` on the runtime. A `PRIVATE_VPC` runtime gets none of
them. A `CUSTOM_JWT` gateway gets no target, and `agentcore add gateway`, and `agentcore add runtime` for a
box runtime, give one notice for it. You write nothing for them. A profile
box runtime, give one notice for it. The file
`agentcore/box-gateway-targets.json` lists these targets too. You write nothing for them. A profile
entry that signs for a gateway host with `aws://` stops build. Build writes these targets only when
the `@aws/agentcore-cdk` in `agentcore/cdk` accepts `passthrough.gateway`: it asks that library
with `node`. When the library refuses the field, build writes none of them, removes the ones it
wrote before, and gives one warning. When build cannot do the check (no `node_modules`, no `node`,
a check that takes more than 60 seconds, or one that fails), it stops and writes nothing.
- **Outbound auth.** An `aws://` secret signs with the gateway's role, an `env://` secret sends an
API key from AgentCore Identity, and an entry with no secret sends no credential.
- **Failures.** A profile Box refuses stops build and deploy with box's own error. A wildcard host,
a plain-HTTP-only host, an unsupported secret, an MCP server that names more than one host, a
path, or a port other than 443, and similar cases stop them too. The error starts with
`Build stopped:` or `Deploy stopped:` and the number of problems, then gives one line for each
problem: its `file:line:column` in your profile or policy file, what is wrong, and how to fix it.
A rule of your policy file is found by its `@id`. For a rule that Box adds, the line names the
entry that makes Box add it, such as `[egress.github]`. Nothing is written.
- **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. It also warns for a `.json` file in the gateway's
`additionalPolicies` that does not exist, cannot be read, or is not a JSON object, as it counts
none of its actions.
- **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:
- **Outbound auth.** An `aws://` secret signs with the gateway's role, an `env://` secret
sends an API key from AgentCore Identity, and an entry with no secret sends no credential.
This includes the model-provider route that `agentcore create` writes when you give it no key,
such as `[egress.openai]` with `env://OPENAI_API_KEY` (also for Anthropic and Gemini). When that
key is set in your shell or in `agentcore/.env.local`, build adds an API key credential such as
`openai`, and deploy provisions your key in AgentCore Identity.
- **Failures.** A profile Box refuses stops build and deploy with box's own error. A wildcard
host, a plain-HTTP-only host, an unsupported secret, an MCP server that names more than one
host, a path, or a port other than 443, and similar cases stop them too. The error starts with `Build stopped:` or `Deploy stopped:` and the
number of problems, then gives one line for each problem: its `file:line:column` in your
profile or policy file, what is wrong, and how to fix it. A rule of your policy file is found
by its `@id`. For a rule that Box adds, the line names the entry that makes Box add it, such as
`[egress.github]`. Nothing is written.
- **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. It also warns for a `.json` file in
the gateway's `additionalPolicies` that does not exist, cannot be read, or is not a JSON
object, as it counts none of its actions.
- **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 `<runtime>-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.<target>]`; an HTTP `[mcp.<name>]` server gets the
Expand Down
1 change: 1 addition & 0 deletions src/core/project/backends/boxCodeZip.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ function model(policyFiles: string[], runtime = "agent"): BoxNetwork {
region: "us-west-2",
hosts: [],
envRoutes: [],
managedTargets: new Set<string>(),
policyFiles,
runtimeProfile: runtimeProfileOf(policyFiles, runtime),
runtimeProfileHeader: [`Derived from .box/${runtime}/local/profile.toml.`],
Expand Down
21 changes: 5 additions & 16 deletions src/core/project/backends/boxCodeZip.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,9 @@ import { chmodSync, copyFileSync, cpSync, mkdirSync, rmSync, writeFileSync } fro
import { join, posix } from "node:path";
import type { Project } from "../../../handlers/project/types";
import type { BoxNetwork } from "../boxNetwork";
import {
boxNetworkEdits,
runtimeProfileWriter,
writeBoxNetworkFiles,
writeRenderedBoxFiles,
} from "../boxNetworkWriters";
import { BOX_CODEZIP_DIST, runtimeRunsInBox } from "../templates/boxProfile";
import { BOX_BINARIES, type BoxLinuxBuild } from "./boxRelease";
import { stagedRuntimeProfiles } from "./boxStaging";

/** The `.gitignore` staged into `.box-dist/`: build and deploy rewrite the folder every time. */
export const BOX_DIST_GITIGNORE =
Expand Down Expand Up @@ -40,17 +35,12 @@ export async function stageBoxCodeZip(
// @box/agentcore and @box/agentcore-codezip packs.
kind: "codezip" as const,
}));
const { files } = boxNetworkEdits([runtimeProfileWriter(staged)], networks, {
spec: project.spec,
projectRoot: project.rootPath,
env: {},
envLocal: {},
});
const filesOf = (dist: string) => files.filter(({ path }) => path.startsWith(`${dist}/`));
const writeProfile = stagedRuntimeProfiles(project, networks, staged);
// Every runtime ships the pinned box, which downloads once.
const build = await box();

for (const { runtime, dist } of staged) {
for (const stage of staged) {
const { dist } = stage;
const folder = join(project.rootPath, ...dist.split("/"));
rmSync(folder, { recursive: true, force: true });
mkdirSync(folder, { recursive: true });
Expand All @@ -62,8 +52,7 @@ export async function stageBoxCodeZip(
chmodSync(join(folder, binary), 0o755);
}
cpSync(build.resources, join(folder, "resources"), { recursive: true });
writeBoxNetworkFiles(project.rootPath, filesOf(dist));
writeRenderedBoxFiles(project.rootPath, runtime, dist, filesOf(dist));
writeProfile(stage);
}
return runtimes.map((runtime) => runtime.name);
}
1 change: 1 addition & 0 deletions src/core/project/backends/boxContainer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ function model(policyFiles: string[]): BoxNetwork {
region: "us-west-2",
hosts: [],
envRoutes: [],
managedTargets: new Set<string>(),
policyFiles,
runtimeProfile: {
packs: ["@box/base", "@box/agentcore"],
Expand Down
24 changes: 5 additions & 19 deletions src/core/project/backends/boxContainer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@ import { dirname, join, posix } from "node:path";
import type { Project } from "../../../handlers/project/types";
import type { ProjectRuntime } from "../../../projectSchemas/runtime";
import type { BoxNetwork } from "../boxNetwork";
import {
boxNetworkEdits,
runtimeProfileWriter,
writeBoxNetworkFiles,
writeRenderedBoxFiles,
} from "../boxNetworkWriters";
import { isFile } from "../runtimeBuild";
import { runtimeRunsInBox } from "../templates/boxProfile";
import { BOX_RELEASE, type BoxRelease } from "./boxRelease";
import { assertImageCopiesPolicyFiles } from "./boxStaging";
import { assertImageCopiesPolicyFiles, stagedRuntimeProfiles } from "./boxStaging";

/** The folder a box image's Dockerfile copies its box profile and policy files from. */
export const BOX_IMAGE_DIST = ".box-dist";
Expand Down Expand Up @@ -128,13 +122,7 @@ export async function stageBoxContainers(
dist: posix.join(runtime.buildContextPath ?? runtime.codeLocation, BOX_IMAGE_DIST),
kind: "container" as const,
}));
const { files } = boxNetworkEdits([runtimeProfileWriter(staged)], networks, {
spec: project.spec,
projectRoot: project.rootPath,
env: {},
envLocal: {},
});
const filesOf = (dist: string) => files.filter(({ path }) => path.startsWith(`${dist}/`));
const writeProfile = stagedRuntimeProfiles(project, networks, staged);
for (const runtime of runtimes) {
const policyFiles = networks.find((n) => n.runtime === runtime.name)?.policyFiles ?? [];
assertImageCopiesPolicyFiles(
Expand All @@ -143,14 +131,12 @@ export async function stageBoxContainers(
policyFiles,
);
}
for (const [index, { dist }] of staged.entries()) {
const runtime = runtimes[index]!;
const folder = join(project.rootPath, ...dist.split("/"));
for (const stage of staged) {
const folder = join(project.rootPath, ...stage.dist.split("/"));
await rm(folder, { recursive: true, force: true });
await mkdir(folder, { recursive: true });
await writeFile(join(folder, BOX_RELEASE_ENV), boxReleaseEnv(BOX_RELEASE));
writeBoxNetworkFiles(project.rootPath, filesOf(dist));
writeRenderedBoxFiles(project.rootPath, runtime.name, dist, filesOf(dist));
writeProfile(stage);
}
return runtimes.map((runtime) => runtime.name);
}
32 changes: 32 additions & 0 deletions src/core/project/backends/boxStaging.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,39 @@
import { readFileSync } from "node:fs";
import { ProjectStateError } from "../../../errors/errors";
import type { Project } from "../../../handlers/project/types";
import type { BoxNetwork } from "../boxNetwork";
import {
boxNetworkEdits,
runtimeProfileWriter,
writeBoxNetworkFiles,
writeRenderedBoxFiles,
type StagedRuntime,
} from "../boxNetworkWriters";
import { boxLocalProfileFile } from "../templates/boxProfile";

/**
* What the runtime profile writer writes from each runtime's Box network model for the runtimes of
* `staged`, with the function that writes one runtime's files into its staged folder and a copy
* into its `.box/<name>/aws/`.
*/
export function stagedRuntimeProfiles(
project: Project,
networks: readonly BoxNetwork[],
staged: readonly StagedRuntime[],
): (runtime: StagedRuntime) => void {
const { files } = boxNetworkEdits([runtimeProfileWriter(staged)], networks, {
spec: project.spec,
projectRoot: project.rootPath,
env: {},
envLocal: {},
});
return ({ runtime, dist }) => {
const own = files.filter(({ path }) => path.startsWith(`${dist}/`));
writeBoxNetworkFiles(project.rootPath, own);
writeRenderedBoxFiles(project.rootPath, runtime, dist, own);
};
}

/** A `COPY` of the whole staged folder, which takes the policy files in with the profile. */
const COPIES_WHOLE_DIST = /^\s*COPY\s+(?:--\S+\s+)*(?:\.box-dist|\$\{BOX_DIST\})\/?\s/m;

Expand Down
1 change: 1 addition & 0 deletions src/core/project/backends/cdk.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,7 @@ describe("CdkBackend.build", () => {
region: "us-west-2",
hosts: [],
envRoutes: [],
managedTargets: new Set<string>(),
policyFiles: [],
runtimeProfile,
grantedActions: [],
Expand Down
42 changes: 42 additions & 0 deletions src/core/project/boxGatewayTargets.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { afterEach, describe, expect, test } from "bun:test";
import { mkdirSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
import { join } from "node:path";
import { FS_RECORD_FILES } from "./boxGatewayTargets";

const directories: string[] = [];
afterEach(() => {
for (const directory of directories.splice(0))
rmSync(directory, { recursive: true, force: true });
});

function folder(): string {
const directory = mkdtempSync(join(tmpdir(), "agentcore-record-"));
directories.push(directory);
return directory;
}

describe("FS_RECORD_FILES", () => {
test("replaces the record with the new text and leaves no other file", () => {
const directory = folder();
const path = join(directory, "box-gateway-targets.json");
writeFileSync(path, '{"old":[]}\n');

FS_RECORD_FILES.write(path, '{"new":[]}\n');

expect(readFileSync(path, "utf8")).toBe('{"new":[]}\n');
expect(readdirSync(directory)).toEqual(["box-gateway-targets.json"]);
});

test("removes the partial file and throws when the record cannot take its name", () => {
const directory = folder();
const path = join(directory, "box-gateway-targets.json");
// A folder in the record's place, with a file in it, refuses the rename.
mkdirSync(path);
writeFileSync(join(path, "keep"), "x");

expect(() => FS_RECORD_FILES.write(path, '{"new":[]}\n')).toThrow();

expect(readdirSync(directory)).toEqual(["box-gateway-targets.json"]);
});
});
Loading
Loading