@aws/agentcore 1.0.0-preview.20 → 1.0.0-preview.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +1 -1
  2. package/dist/assets/python/http/strands/base/model/load.py +1 -1
  3. package/dist/cli/index.mjs +545 -519
  4. package/dist/lib/constants.d.ts +8 -4
  5. package/dist/lib/constants.d.ts.map +1 -1
  6. package/dist/lib/constants.js +13 -7
  7. package/dist/lib/constants.js.map +1 -1
  8. package/dist/lib/packaging/build-args.d.ts +6 -0
  9. package/dist/lib/packaging/build-args.d.ts.map +1 -1
  10. package/dist/lib/packaging/build-args.js +9 -0
  11. package/dist/lib/packaging/build-args.js.map +1 -1
  12. package/dist/lib/packaging/build-context-dockerignore.d.ts +23 -0
  13. package/dist/lib/packaging/build-context-dockerignore.d.ts.map +1 -0
  14. package/dist/lib/packaging/build-context-dockerignore.js +63 -0
  15. package/dist/lib/packaging/build-context-dockerignore.js.map +1 -0
  16. package/dist/lib/packaging/build-context.d.ts +21 -0
  17. package/dist/lib/packaging/build-context.d.ts.map +1 -0
  18. package/dist/lib/packaging/build-context.js +21 -0
  19. package/dist/lib/packaging/build-context.js.map +1 -0
  20. package/dist/lib/packaging/container.d.ts.map +1 -1
  21. package/dist/lib/packaging/container.js +15 -4
  22. package/dist/lib/packaging/container.js.map +1 -1
  23. package/dist/lib/packaging/index.d.ts +2 -0
  24. package/dist/lib/packaging/index.d.ts.map +1 -1
  25. package/dist/lib/packaging/index.js +5 -1
  26. package/dist/lib/packaging/index.js.map +1 -1
  27. package/dist/schema/schemas/agent-env.d.ts +22 -0
  28. package/dist/schema/schemas/agent-env.d.ts.map +1 -1
  29. package/dist/schema/schemas/agent-env.js +117 -15
  30. package/dist/schema/schemas/agent-env.js.map +1 -1
  31. package/dist/schema/schemas/agentcore-project.d.ts +4 -0
  32. package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
  33. package/dist/schema/schemas/aws-targets.d.ts +12 -0
  34. package/dist/schema/schemas/aws-targets.d.ts.map +1 -1
  35. package/dist/schema/schemas/aws-targets.js +4 -0
  36. package/dist/schema/schemas/aws-targets.js.map +1 -1
  37. package/dist/schema/schemas/mcp.d.ts +2 -0
  38. package/dist/schema/schemas/mcp.d.ts.map +1 -1
  39. package/dist/schema/schemas/mcp.js +1 -0
  40. package/dist/schema/schemas/mcp.js.map +1 -1
  41. package/npm-shrinkwrap.json +2 -2
  42. package/package.json +1 -1
  43. package/scripts/extract-cli-model.mjs +228 -0
  44. package/scripts/render_adoc.py +274 -0
@@ -29,9 +29,13 @@ export declare const CONTAINER_INTERNAL_PORT = 8080;
29
29
  export type ContainerRuntime = 'docker' | 'podman' | 'finch';
30
30
  export declare const CONTAINER_RUNTIMES: ContainerRuntime[];
31
31
  /**
32
- * Get the Dockerfile path for a given code location.
33
- * @param codeLocation - Directory containing the Dockerfile
34
- * @param dockerfile - Custom Dockerfile name (default: 'Dockerfile')
32
+ * Resolve the Dockerfile path against the Docker build context.
33
+ * @param buildContext - The build context directory (`buildContextPath` when set, else `codeLocation`)
34
+ * @param dockerfile - Dockerfile name or relative subpath within the context (default: 'Dockerfile')
35
+ *
36
+ * `dockerfile` may be a filename ('Dockerfile') or a forward-slash relative subpath
37
+ * ('docker/Dockerfile'); absolute paths, backslashes, and `..` traversal are rejected so it can
38
+ * never escape the build context.
35
39
  */
36
- export declare function getDockerfilePath(codeLocation: string, dockerfile?: string): string;
40
+ export declare function getDockerfilePath(buildContext: string, dockerfile?: string): string;
37
41
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":"AAGA,cAAc,WAAW,CAAC;AAG1B,eAAO,MAAM,UAAU,cAAc,CAAC;AAGtC,eAAO,MAAM,OAAO,QAAQ,CAAC;AAC7B,eAAO,MAAM,cAA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B,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,eAAO,MAAM,eAAe,gGACmE,CAAC;AAChG,eAAO,MAAM,gBAAgB,wEAAwE,CAAC;AACtG,eAAO,MAAM,uBAAuB,0BAA0B,CAAC;AAG/D,eAAO,MAAM,MAAM,QAAqB,CAAC;AACzC,eAAO,MAAM,eAAe,eAAe,CAAC;AAC5C,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,2DAA2D;AAC3D,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,QAAQ,GAAG,OAAO,CAAC;AAC7D,eAAO,MAAM,kBAAkB,EAAE,gBAAgB,EAAkC,CAAC;AAEpF;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CASnF"}
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  exports.CONTAINER_RUNTIMES = exports.CONTAINER_INTERNAL_PORT = exports.DOCKERFILE_NAME = exports.ONE_GB = exports.DEFAULT_PYTHON_PLATFORM = exports.NPM_INSTALL_HINT = exports.UV_INSTALL_HINT = exports.ENV_FILE = exports.CONFIG_FILES = exports.CLI_LOGS_DIR = exports.CLI_SYSTEM_DIR = exports.HARNESS_DIR = exports.MCP_APP_SUBDIR = exports.APP_DIR = exports.CONFIG_DIR = void 0;
18
18
  exports.getArtifactZipName = getArtifactZipName;
19
19
  exports.getDockerfilePath = getDockerfilePath;
20
+ const schema_1 = require("../schema");
20
21
  const path_1 = require("path");
21
22
  // Re-export all schema constants from schema
22
23
  __exportStar(require("../schema"), exports);
@@ -55,15 +56,20 @@ exports.DOCKERFILE_NAME = 'Dockerfile';
55
56
  exports.CONTAINER_INTERNAL_PORT = 8080;
56
57
  exports.CONTAINER_RUNTIMES = ['docker', 'podman', 'finch'];
57
58
  /**
58
- * Get the Dockerfile path for a given code location.
59
- * @param codeLocation - Directory containing the Dockerfile
60
- * @param dockerfile - Custom Dockerfile name (default: 'Dockerfile')
59
+ * Resolve the Dockerfile path against the Docker build context.
60
+ * @param buildContext - The build context directory (`buildContextPath` when set, else `codeLocation`)
61
+ * @param dockerfile - Dockerfile name or relative subpath within the context (default: 'Dockerfile')
62
+ *
63
+ * `dockerfile` may be a filename ('Dockerfile') or a forward-slash relative subpath
64
+ * ('docker/Dockerfile'); absolute paths, backslashes, and `..` traversal are rejected so it can
65
+ * never escape the build context.
61
66
  */
62
- function getDockerfilePath(codeLocation, dockerfile) {
67
+ function getDockerfilePath(buildContext, dockerfile) {
63
68
  const name = dockerfile ?? exports.DOCKERFILE_NAME;
64
- if (name.includes('/') || name.includes('\\') || name.includes('..')) {
65
- throw new Error(`Invalid dockerfile name: must be a filename without path separators or traversal`);
69
+ if (!(0, schema_1.isValidDockerfilePath)(name)) {
70
+ throw new Error(`Invalid dockerfile path "${name}": must be a relative path within the build context (a filename or ` +
71
+ `forward-slash subpath; no leading slash, backslash, empty segments, or ".." traversal)`);
66
72
  }
67
- return (0, path_1.join)(codeLocation, name);
73
+ return (0, path_1.join)(buildContext, name);
68
74
  }
69
75
  //# sourceMappingURL=constants.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/lib/constants.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAkCA,gDAEC;AAqBD,8CAMC;AA/DD,+BAA4B;AAE5B,6CAA6C;AAC7C,4CAA0B;AAE1B,yCAAyC;AAC5B,QAAA,UAAU,GAAG,WAAW,CAAC;AAEtC,kEAAkE;AACrD,QAAA,OAAO,GAAG,KAAK,CAAC;AAChB,QAAA,cAAc,GAAG,KAAK,CAAC;AAEpC,sBAAsB;AACT,QAAA,WAAW,GAAG,WAAW,CAAC;AAEvC,8CAA8C;AACjC,QAAA,cAAc,GAAG,MAAM,CAAC;AACxB,QAAA,YAAY,GAAG,MAAM,CAAC;AAEtB,QAAA,YAAY,GAAG;IAC1B,SA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3,4 +3,10 @@
3
3
  * Returns an empty array when no custom indexes are configured.
4
4
  */
5
5
  export declare function getUvBuildArgs(): string[];
6
+ /**
7
+ * Return Docker `--build-arg KEY=VALUE` flags for an agent's `customDockerBuildArgs`.
8
+ * Returns an empty array when there are none. Shared by the local `package` and `dev` build paths
9
+ * so the flag encoding stays in one place.
10
+ */
11
+ export declare function getCustomBuildArgs(customDockerBuildArgs?: Record<string, string>): string[];
6
12
  //# sourceMappingURL=build-args.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-args.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/build-args.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAMzC"}
1
+ {"version":3,"file":"build-args.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/build-args.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAMzC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,qBAAqB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,EAAE,CAE3F"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUvBuildArgs = getUvBuildArgs;
4
+ exports.getCustomBuildArgs = getCustomBuildArgs;
4
5
  const global_config_1 = require("../schemas/io/global-config");
5
6
  /**
6
7
  * Return Docker --build-arg flags for UV index URLs configured in ~/.agentcore/config.json.
@@ -15,4 +16,12 @@ function getUvBuildArgs() {
15
16
  args.push('--build-arg', `UV_INDEX=${config.uvIndex}`);
16
17
  return args;
17
18
  }
19
+ /**
20
+ * Return Docker `--build-arg KEY=VALUE` flags for an agent's `customDockerBuildArgs`.
21
+ * Returns an empty array when there are none. Shared by the local `package` and `dev` build paths
22
+ * so the flag encoding stays in one place.
23
+ */
24
+ function getCustomBuildArgs(customDockerBuildArgs) {
25
+ return Object.entries(customDockerBuildArgs ?? {}).flatMap(([key, value]) => ['--build-arg', `${key}=${value}`]);
26
+ }
18
27
  //# sourceMappingURL=build-args.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"build-args.js","sourceRoot":"","sources":["../../../src/lib/packaging/build-args.ts"],"names":[],"mappings":";;AAMA,wCAMC;AAZD,+DAAmE;AAEnE;;;GAGG;AACH,SAAgB,cAAc;IAC5B,MAAM,MAAM,GAAG,IAAA,oCAAoB,GAAE,CAAC;IACtC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,MAAM,CAAC,cAAc;QAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,oBAAoB,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IACjG,IAAI,MAAM,CAAC,OAAO;QAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3E,OAAO,IAAI,CAAC;AACd,CAAC"}
1
+ {"version":3,"file":"build-args.js","sourceRoot":"","sources":["../../../src/lib/packaging/build-args.ts"],"names":[],"mappings":";;AAMA,wCAMC;AAOD,gDAEC;AArBD,+DAAmE;AAEnE;;;GAGG;AACH,SAAgB,cAAc;IAC5B,MAAM,MAAM,GAAG,IAAA,oCAAoB,GAAE,CAAC;IACtC,MAAM,IAAI,GAAa,EAAE,CAAC;IAC1B,IAAI,MAAM,CAAC,cAAc;QAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,oBAAoB,MAAM,CAAC,cAAc,EAAE,CAAC,CAAC;IACjG,IAAI,MAAM,CAAC,OAAO;QAAE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,YAAY,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC;IAC3E,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,SAAgB,kBAAkB,CAAC,qBAA8C;IAC/E,OAAO,MAAM,CAAC,OAAO,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,aAAa,EAAE,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC;AACnH,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Default `.dockerignore` written at a Container agent's build-context root when `buildContextPath`
3
+ * is set and none exists. Keeps secrets and build junk out of the image and out of the CodeBuild
4
+ * upload. Both local `agentcore dev`/`package` and `agentcore deploy` honor this same file, so what
5
+ * is excluded locally is exactly what is excluded on deploy.
6
+ */
7
+ export declare const BUILD_CONTEXT_DOCKERIGNORE_TEMPLATE = "# Generated by agentcore because this agent sets buildContextPath \u2014 the whole of this directory is the\n# Docker build context, so secrets/junk here would otherwise be baked into the image and uploaded to\n# CodeBuild. Patterns are listed both bare and '**/'-prefixed so nested copies (e.g.\n# app/agent-one/node_modules, app/agent-one/.env) are excluded too, not just the top level \u2014 Docker\n# matches .dockerignore patterns root-relative. Both 'agentcore dev'/'package' and 'agentcore deploy'\n# honor this file. Edit freely; to intentionally include a file listed here (e.g. a non-secret\n# .env.production), add a '!'-prefixed line for it below.\n.env\n.env.*\n**/.env\n**/.env.*\n.git\n**/.git\n.venv\n**/.venv\nnode_modules\n**/node_modules\n__pycache__\n**/__pycache__\n.pytest_cache\n**/.pytest_cache\n.DS_Store\n**/.DS_Store\nagentcore/\n";
8
+ /**
9
+ * Ensure a `.dockerignore` exists at the resolved build-context root. No-op when the directory does
10
+ * not exist or a `.dockerignore` is already present (the user's file is never overwritten). Returns
11
+ * the path when it creates one, otherwise null.
12
+ *
13
+ * Guards the DIRECTORY, not just the file: a missing/typo'd `buildContextPath` would otherwise make
14
+ * `writeFileSync` throw a raw ENOENT — crashing `agentcore dev`, bypassing `PackagingError` in
15
+ * `package`, and masking preflight's friendly "Dockerfile not found". Callers invoke this only AFTER
16
+ * validating that the Dockerfile exists, so on a failing build/deploy no stray `.dockerignore` is
17
+ * left behind.
18
+ *
19
+ * Called only when `buildContextPath` is set — that is when the context is widened beyond the agent's
20
+ * own `codeLocation` (e.g. to a monorepo root) and a stray root-level `.env`/`.git` would be swept in.
21
+ */
22
+ export declare function ensureBuildContextDockerignore(resolvedBuildContext: string): string | null;
23
+ //# sourceMappingURL=build-context-dockerignore.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-context-dockerignore.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/build-context-dockerignore.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,mCAAmC,81BAwB/C,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,wBAAgB,8BAA8B,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAU1F"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BUILD_CONTEXT_DOCKERIGNORE_TEMPLATE = void 0;
4
+ exports.ensureBuildContextDockerignore = ensureBuildContextDockerignore;
5
+ const fs_1 = require("fs");
6
+ const path_1 = require("path");
7
+ /**
8
+ * Default `.dockerignore` written at a Container agent's build-context root when `buildContextPath`
9
+ * is set and none exists. Keeps secrets and build junk out of the image and out of the CodeBuild
10
+ * upload. Both local `agentcore dev`/`package` and `agentcore deploy` honor this same file, so what
11
+ * is excluded locally is exactly what is excluded on deploy.
12
+ */
13
+ exports.BUILD_CONTEXT_DOCKERIGNORE_TEMPLATE = `# Generated by agentcore because this agent sets buildContextPath — the whole of this directory is the
14
+ # Docker build context, so secrets/junk here would otherwise be baked into the image and uploaded to
15
+ # CodeBuild. Patterns are listed both bare and '**/'-prefixed so nested copies (e.g.
16
+ # app/agent-one/node_modules, app/agent-one/.env) are excluded too, not just the top level — Docker
17
+ # matches .dockerignore patterns root-relative. Both 'agentcore dev'/'package' and 'agentcore deploy'
18
+ # honor this file. Edit freely; to intentionally include a file listed here (e.g. a non-secret
19
+ # .env.production), add a '!'-prefixed line for it below.
20
+ .env
21
+ .env.*
22
+ **/.env
23
+ **/.env.*
24
+ .git
25
+ **/.git
26
+ .venv
27
+ **/.venv
28
+ node_modules
29
+ **/node_modules
30
+ __pycache__
31
+ **/__pycache__
32
+ .pytest_cache
33
+ **/.pytest_cache
34
+ .DS_Store
35
+ **/.DS_Store
36
+ agentcore/
37
+ `;
38
+ /**
39
+ * Ensure a `.dockerignore` exists at the resolved build-context root. No-op when the directory does
40
+ * not exist or a `.dockerignore` is already present (the user's file is never overwritten). Returns
41
+ * the path when it creates one, otherwise null.
42
+ *
43
+ * Guards the DIRECTORY, not just the file: a missing/typo'd `buildContextPath` would otherwise make
44
+ * `writeFileSync` throw a raw ENOENT — crashing `agentcore dev`, bypassing `PackagingError` in
45
+ * `package`, and masking preflight's friendly "Dockerfile not found". Callers invoke this only AFTER
46
+ * validating that the Dockerfile exists, so on a failing build/deploy no stray `.dockerignore` is
47
+ * left behind.
48
+ *
49
+ * Called only when `buildContextPath` is set — that is when the context is widened beyond the agent's
50
+ * own `codeLocation` (e.g. to a monorepo root) and a stray root-level `.env`/`.git` would be swept in.
51
+ */
52
+ function ensureBuildContextDockerignore(resolvedBuildContext) {
53
+ if (!(0, fs_1.existsSync)(resolvedBuildContext)) {
54
+ return null;
55
+ }
56
+ const dockerignorePath = (0, path_1.join)(resolvedBuildContext, '.dockerignore');
57
+ if ((0, fs_1.existsSync)(dockerignorePath)) {
58
+ return null;
59
+ }
60
+ (0, fs_1.writeFileSync)(dockerignorePath, exports.BUILD_CONTEXT_DOCKERIGNORE_TEMPLATE);
61
+ return dockerignorePath;
62
+ }
63
+ //# sourceMappingURL=build-context-dockerignore.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-context-dockerignore.js","sourceRoot":"","sources":["../../../src/lib/packaging/build-context-dockerignore.ts"],"names":[],"mappings":";;;AAiDA,wEAUC;AA3DD,2BAA+C;AAC/C,+BAA4B;AAE5B;;;;;GAKG;AACU,QAAA,mCAAmC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;CAwBlD,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,SAAgB,8BAA8B,CAAC,oBAA4B;IACzE,IAAI,CAAC,IAAA,eAAU,EAAC,oBAAoB,CAAC,EAAE,CAAC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,gBAAgB,GAAG,IAAA,WAAI,EAAC,oBAAoB,EAAE,eAAe,CAAC,CAAC;IACrE,IAAI,IAAA,eAAU,EAAC,gBAAgB,CAAC,EAAE,CAAC;QACjC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAA,kBAAa,EAAC,gBAAgB,EAAE,2CAAmC,CAAC,CAAC;IACrE,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { AgentEnvSpec } from '../../schema';
2
+ /** Resolved Docker build context and Dockerfile path for a Container agent. */
3
+ export interface ResolvedBuildContext {
4
+ /** Absolute path to the Docker build context (`buildContextPath` when set, else `codeLocation`). */
5
+ buildContext: string;
6
+ /** Absolute path to the Dockerfile, resolved against the build context. */
7
+ dockerfilePath: string;
8
+ }
9
+ /**
10
+ * Resolve the Docker build context + Dockerfile path for a Container agent — the single source of
11
+ * truth shared by `package` (ContainerPackager), `deploy` preflight, and `dev`.
12
+ *
13
+ * The context is `buildContextPath` when set, otherwise `codeLocation`, resolved via
14
+ * `resolveCodeLocation` (the same resolver the deploy-side `ContainerSourceAsset` uses to upload it),
15
+ * and the Dockerfile is resolved against that context (matching the CodeBuild buildspec's `-f`).
16
+ * Collapsing this into one function keeps local `dev`/`package` and `deploy` from ever resolving the
17
+ * context differently — a divergence would otherwise let a config build from one directory locally and
18
+ * a different one on deploy.
19
+ */
20
+ export declare function resolveBuildContext(spec: Pick<AgentEnvSpec, 'codeLocation' | 'buildContextPath' | 'dockerfile'>, baseDir: string): ResolvedBuildContext;
21
+ //# sourceMappingURL=build-context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-context.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/build-context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAIjD,+EAA+E;AAC/E,MAAM,WAAW,oBAAoB;IACnC,oGAAoG;IACpG,YAAY,EAAE,MAAM,CAAC;IACrB,2EAA2E;IAC3E,cAAc,EAAE,MAAM,CAAC;CACxB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,IAAI,CAAC,YAAY,EAAE,cAAc,GAAG,kBAAkB,GAAG,YAAY,CAAC,EAC5E,OAAO,EAAE,MAAM,GACd,oBAAoB,CAGtB"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveBuildContext = resolveBuildContext;
4
+ const constants_1 = require("../constants");
5
+ const helpers_1 = require("./helpers");
6
+ /**
7
+ * Resolve the Docker build context + Dockerfile path for a Container agent — the single source of
8
+ * truth shared by `package` (ContainerPackager), `deploy` preflight, and `dev`.
9
+ *
10
+ * The context is `buildContextPath` when set, otherwise `codeLocation`, resolved via
11
+ * `resolveCodeLocation` (the same resolver the deploy-side `ContainerSourceAsset` uses to upload it),
12
+ * and the Dockerfile is resolved against that context (matching the CodeBuild buildspec's `-f`).
13
+ * Collapsing this into one function keeps local `dev`/`package` and `deploy` from ever resolving the
14
+ * context differently — a divergence would otherwise let a config build from one directory locally and
15
+ * a different one on deploy.
16
+ */
17
+ function resolveBuildContext(spec, baseDir) {
18
+ const buildContext = (0, helpers_1.resolveCodeLocation)(spec.buildContextPath ?? spec.codeLocation, baseDir);
19
+ return { buildContext, dockerfilePath: (0, constants_1.getDockerfilePath)(buildContext, spec.dockerfile) };
20
+ }
21
+ //# sourceMappingURL=build-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-context.js","sourceRoot":"","sources":["../../../src/lib/packaging/build-context.ts"],"names":[],"mappings":";;AAuBA,kDAMC;AA5BD,4CAAiD;AACjD,uCAAgD;AAUhD;;;;;;;;;;GAUG;AACH,SAAgB,mBAAmB,CACjC,IAA4E,EAC5E,OAAe;IAEf,MAAM,YAAY,GAAG,IAAA,6BAAmB,EAAC,IAAI,CAAC,gBAAgB,IAAI,IAAI,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC9F,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,IAAA,6BAAiB,EAAC,YAAY,EAAE,IAAI,CAAC,UAAU,CAAC,EAAE,CAAC;AAC5F,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAKjD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAmBzF;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;CAkEhF"}
1
+ {"version":3,"file":"container.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/container.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAOjD,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAmBzF;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,eAAe;IACvD,IAAI,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,cAAc,CAAC;CA4EhF"}
@@ -4,6 +4,8 @@ exports.ContainerPackager = void 0;
4
4
  const constants_1 = require("../constants");
5
5
  const types_1 = require("../errors/types");
6
6
  const build_args_1 = require("./build-args");
7
+ const build_context_1 = require("./build-context");
8
+ const build_context_dockerignore_1 = require("./build-context-dockerignore");
7
9
  const helpers_1 = require("./helpers");
8
10
  const child_process_1 = require("child_process");
9
11
  const fs_1 = require("fs");
@@ -34,11 +36,18 @@ class ContainerPackager {
34
36
  const agentName = options.agentName ?? spec.name;
35
37
  const configBaseDir = options.artifactDir ?? options.projectRoot ?? process.cwd();
36
38
  const codeLocation = (0, helpers_1.resolveCodeLocation)(spec.codeLocation, configBaseDir);
37
- const dockerfilePath = (0, constants_1.getDockerfilePath)(codeLocation, spec.dockerfile);
39
+ // Build context + Dockerfile via the shared resolver (identical to the deploy/CodeBuild path).
40
+ const { buildContext, dockerfilePath } = (0, build_context_1.resolveBuildContext)(spec, configBaseDir);
38
41
  // Preflight: Dockerfile must exist
39
42
  if (!(0, fs_1.existsSync)(dockerfilePath)) {
40
43
  return Promise.reject(new types_1.PackagingError(`${spec.dockerfile ?? constants_1.DOCKERFILE_NAME} not found at ${dockerfilePath}. Container agents require a Dockerfile.`));
41
44
  }
45
+ // Dockerfile validated — when buildContextPath widens the context, ensure a .dockerignore keeps
46
+ // secrets/junk out of the local image (the same file the deploy path honors). No-op if the dir is
47
+ // missing or a .dockerignore already exists, so a failing build never leaves a stray file.
48
+ if (spec.buildContextPath) {
49
+ (0, build_context_dockerignore_1.ensureBuildContextDockerignore)(buildContext);
50
+ }
42
51
  // Detect container runtime
43
52
  const runtime = detectContainerRuntimeSync();
44
53
  if (!runtime) {
@@ -49,9 +58,11 @@ class ContainerPackager {
49
58
  stagingPath: codeLocation,
50
59
  });
51
60
  }
52
- // Build locally
53
- const imageName = `agentcore-package-${agentName}`;
54
- const buildResult = (0, child_process_1.spawnSync)(runtime, ['build', '-t', imageName, '-f', dockerfilePath, ...(0, build_args_1.getUvBuildArgs)(), codeLocation], {
61
+ // Build locally. Docker image tags must be lowercase, but agent names allow uppercase
62
+ // (e.g. the default "AgentOne"), so lower-case the tag — matching the dev server.
63
+ const imageName = `agentcore-package-${agentName}`.toLowerCase();
64
+ const buildArgFlags = (0, build_args_1.getCustomBuildArgs)(spec.customDockerBuildArgs);
65
+ const buildResult = (0, child_process_1.spawnSync)(runtime, ['build', '-t', imageName, '-f', dockerfilePath, ...(0, build_args_1.getUvBuildArgs)(), ...buildArgFlags, buildContext], {
55
66
  stdio: 'pipe',
56
67
  });
57
68
  if (buildResult.status !== 0) {
@@ -1 +1 @@
1
- {"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/lib/packaging/container.ts"],"names":[],"mappings":";;;AACA,4CAA8F;AAC9F,2CAAiD;AACjD,6CAA8C;AAC9C,uCAAgD;AAEhD,iDAA0C;AAC1C,2BAAgC;AAEhC;;;GAGG;AACH,SAAS,0BAA0B;IACjC,KAAK,MAAM,OAAO,IAAI,8BAAkB,EAAE,CAAC;QACzC,MAAM,MAAM,GAAG,IAAA,yBAAS,EAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;QAChE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,MAAM,aAAa,GAAG,IAAA,yBAAS,EAAC,OAAO,EAAE,CAAC,WAAW,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YAC3E,IAAI,aAAa,CAAC,MAAM,KAAK,CAAC;gBAAE,OAAO,OAAO,CAAC;QACjD,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;GAGG;AACH,MAAa,iBAAiB;IAC5B,IAAI,CAAC,IAAkB,EAAE,UAA0B,EAAE;QACnD,IAAI,IAAI,CAAC,KAAK,KAAK,WAAW,EAAE,CAAC;YAC/B,OAAO,OAAO,CAAC,MAAM,CAAC,IAAI,sBAAc,CAAC,uDAAuD,CAAC,CAAC,CAAC;QACrG,CAAC;QAED,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC;QACjD,MAAM,aAAa,GAAG,OAAO,CAAC,WAAW,IAAI,OAAO,CAAC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MAAM,CACnB,IAAI,sBAAc,CAChB,sCAAsC,MAAM,OAAO;gBACjD,6FAA6F,CAChG,CACF,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,YAAY,EAAE,GAAG,OAAO,MAAM,SAAS,EAAE;YACzC,SAAS;YACT,WAAW,EAAE,YAAY;SAC1B,CAAC,CAAC;IACL,CAAC;CACF;AA7ED,8CA6EC"}
@@ -36,4 +36,6 @@ export declare function packRuntime(spec: AgentEnvSpec, options?: PackageOptions
36
36
  export declare function packCodeZipSync(config: CodeBundleConfig | AgentEnvSpec, options?: PackageOptions): ArtifactResult;
37
37
  export type { ArtifactResult, CodeBundleConfig, CodeZipPackager, PackageOptions, RuntimePackager, } from './types/packaging';
38
38
  export { resolveCodeLocation } from './helpers';
39
+ export { ensureBuildContextDockerignore } from './build-context-dockerignore';
40
+ export { resolveBuildContext, type ResolvedBuildContext } from './build-context';
39
41
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAOvF,OAAO,KAAK,EACV,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,cAAc,EACd,eAAe,EAChB,MAAM,mBAAmB,CAAC;AAE3B;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAM1F;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,eAAe,CAQlF;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,cAAc,EAAE,cAAc,GAAG,eAAe,CAQlF;AAED;;GAEG;AACH,wBAAgB,oBAAoB,IAAI,eAAe,CAEtD;AAED;;;;GAIG;AACH,wBAAsB,WAA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,eAAe,EACf,cAAc,EACd,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,8BAA8B,EAAE,MAAM,8BAA8B,CAAC;AAC9E,OAAO,EAAE,mBAAmB,EAAE,KAAK,oBAAoB,EAAE,MAAM,iBAAiB,CAAC"}
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveCodeLocation = void 0;
3
+ exports.resolveBuildContext = exports.ensureBuildContextDockerignore = exports.resolveCodeLocation = void 0;
4
4
  exports.validateAgentExists = validateAgentExists;
5
5
  exports.getRuntimePackager = getRuntimePackager;
6
6
  exports.getCodeZipPackager = getCodeZipPackager;
@@ -80,4 +80,8 @@ function packCodeZipSync(config, options) {
80
80
  }
81
81
  var helpers_2 = require("./helpers");
82
82
  Object.defineProperty(exports, "resolveCodeLocation", { enumerable: true, get: function () { return helpers_2.resolveCodeLocation; } });
83
+ var build_context_dockerignore_1 = require("./build-context-dockerignore");
84
+ Object.defineProperty(exports, "ensureBuildContextDockerignore", { enumerable: true, get: function () { return build_context_dockerignore_1.ensureBuildContextDockerignore; } });
85
+ var build_context_1 = require("./build-context");
86
+ Object.defineProperty(exports, "resolveBuildContext", { enumerable: true, get: function () { return build_context_1.resolveBuildContext; } });
83
87
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/packaging/index.ts"],"names":[],"mappings":";;;AAqBA,kDAMC;AAMD,gDAQC;AAMD,gDAQC;AAKD,oDAEC;AAOD,kCAGC;AAQD,0CAIC;AAnFD,yCAAsD;AACtD,2CAAiD;AACjD,2CAAgD;AAChD,uCAA2D;AAC3D,iCAAsE;AACtE,qCAA4E;AAS5E;;;;;GAKG;AACH,SAAgB,mBAAmB,CAAC,OAA6B,EAAE,SAAiB;IAClF,MAAM,KAAK,GAAG,OAA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c,CAAC,CAAC;IACpD,OAAO,QAAQ,CAAC,WAAW,CAAC,MAAsB,EAAE,OAAO,CAAC,CAAC;AAC/D,CAAC;AAUD,qCAAgD;AAAvC,8GAAA,mBAAmB,OAAA;AAC5B,2EAA8E;AAArE,4IAAA,8BAA8B,OAAA;AACvC,iDAAiF;AAAxE,oHAAA,mBAAmB,OAAA"}
@@ -24,6 +24,26 @@ export type BuildType = z.infer<typeof BuildTypeSchema>;
24
24
  * TypeScript: main.ts, main.js, or index.ts
25
25
  */
26
26
  export declare const EntrypointSchema: z.ZodType<FilePath>;
27
+ /**
28
+ * True when `p` is a safe relative Dockerfile path within the build context: allowed chars only, no
29
+ * leading slash (absolute), and no empty ('' from a leading/trailing/double slash) or '..' segments.
30
+ *
31
+ * The single source of truth shared by `DockerfilePathSchema` (config-validation time) and the runtime
32
+ * `getDockerfilePath` guard, so the two can never diverge — e.g. one accepting '.docker/Dockerfile'
33
+ * while the other rejects it, or one accepting a trailing-slash directory value like 'docker/'.
34
+ */
35
+ export declare function isValidDockerfilePath(p: string): boolean;
36
+ /**
37
+ * Build-arg names reserved by the CodeBuild build environment. On deploy each build arg becomes a
38
+ * CodeBuild environment-variable override alongside the buildspec's own control vars, so a colliding
39
+ * name would break the deploy build — a wrong image tag / ECR region, a rejected StartBuild, or a
40
+ * clobbered build-container shell. We reject the buildspec control vars, the process-critical shell
41
+ * vars, and CodeBuild's own `AWS_*` / `CODEBUILD_*` namespaces. This is a best-effort denylist (the
42
+ * shell has other sensitive vars), but it covers the realistic footguns and keeps a config that
43
+ * builds locally from failing only on deploy.
44
+ */
45
+ export declare const RESERVED_BUILD_ARG_KEYS: string[];
46
+ export declare function isReservedBuildArgKey(key: string): boolean;
27
47
  export declare const EnvVarSchema: z.ZodObject<{
28
48
  name: z.ZodString;
29
49
  value: z.ZodString;
@@ -151,6 +171,8 @@ export declare const AgentEnvSpecSchema: z.ZodObject<{
151
171
  entrypoint: z.ZodType<FilePath, unknown, z.core.$ZodTypeInternals<FilePath, unknown>>;
152
172
  codeLocation: z.ZodType<DirectoryPath, unknown, z.core.$ZodTypeInternals<DirectoryPath, unknown>>;
153
173
  dockerfile: z.ZodOptional<z.ZodString>;
174
+ buildContextPath: z.ZodOptional<z.ZodType<DirectoryPath, unknown, z.core.$ZodTypeInternals<DirectoryPath, unknown>>>;
175
+ customDockerBuildArgs: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
154
176
  runtimeVersion: z.ZodOptional<z.ZodUnion<readonly [z.ZodEnum<{
155
177
  PYTHON_3_10: "PYTHON_3_10";
156
178
  PYTHON_3_11: "PYTHON_3_11";
@@ -1 +1 @@
1
- {"version":3,"file":"agent-env.d.ts","sourceRoot":"","sources":["../../../src/schema/schemas/agent-env.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAIxD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAClE,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAO1G,eAAO,MAAM,eAAe,aAOzB,CAAC;AAEJ,eAAO,MAAM,gBAAgB,aAO1B,CAAC;AAGJ,eAAO,MAAM,iBAAiB,aAQ3B,CAAC;AAMJ,wCAAwC;AACxC,eAAO,MAAM,YAAY;;;EAAgC,CAAC;AAC1D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAMlD,eAAO,MAAM,eAAe,kCAAgC,CAAC;AAC7D,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC;AAExD,eAAO,MAAM,eAAe;;;EAAmC,CAAC;AAChE,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KA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AoE;AACpE,eAAO,MAAM,qBAAqB,KAAK,CAAC;AACxC,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,QAAQ,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,4BAA4B;;;iBAiBrC,CAAC;AACL,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAMlF;;GAEG;AACH,eAAO,MAAM,yBAAyB,aAOnC,CAAC;AAEJ,eAAO,MAAM,qBAAqB;;;iBAKhC,CAAC;AAEH,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAEpE;;;GAGG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAmM3B,CAAC;AAEL,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC"}
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AgentEnvSpecSchema = exports.RuntimeEndpointSchema = exports.RuntimeEndpointNameSchema = exports.LifecycleConfigurationSchema = exports.LIFECYCLE_TIMEOUT_MAX = exports.LIFECYCLE_TIMEOUT_MIN = exports.FilesystemConfigurationSchema = exports.MAX_S3_MOUNTS = exports.MAX_EFS_MOUNTS = exports.S3FilesAccessPointConfigSchema = exports.EfsAccessPointConfigSchema = exports.S3_FILES_ACCESS_POINT_ARN_PATTERN = exports.EFS_ACCESS_POINT_ARN_PATTERN = exports.SessionStorageSchema = exports.RequestHeaderAllowlistSchema = exports.MAX_HEADER_ALLOWLIST_SIZE = exports.HEADER_NAME_PATTERN = exports.HEADER_ALLOWLIST_PREFIX = exports.NetworkConfigSchema = exports.InstrumentationSchema = exports.EnvVarSchema = exports.EntrypointSchema = exports.BuildTypeSchema = exports.AgentTypeSchema = exports.AccessSchema = exports.GatewayNameSchema = exports.EnvVarNameSchema = exports.AgentNameSchema = void 0;
3
+ exports.AgentEnvSpecSchema = exports.RuntimeEndpointSchema = exports.RuntimeEndpointNameSchema = exports.LifecycleConfigurationSchema = exports.LIFECYCLE_TIMEOUT_MAX = exports.LIFECYCLE_TIMEOUT_MIN = exports.FilesystemConfigurationSchema = exports.MAX_S3_MOUNTS = exports.MAX_EFS_MOUNTS = exports.S3FilesAccessPointConfigSchema = exports.EfsAccessPointConfigSchema = exports.S3_FILES_ACCESS_POINT_ARN_PATTERN = exports.EFS_ACCESS_POINT_ARN_PATTERN = exports.SessionStorageSchema = exports.RequestHeaderAllowlistSchema = exports.MAX_HEADER_ALLOWLIST_SIZE = exports.HEADER_NAME_PATTERN = exports.HEADER_ALLOWLIST_PREFIX = exports.NetworkConfigSchema = exports.InstrumentationSchema = exports.EnvVarSchema = exports.RESERVED_BUILD_ARG_KEYS = exports.EntrypointSchema = exports.BuildTypeSchema = exports.AgentTypeSchema = exports.AccessSchema = exports.GatewayNameSchema = exports.EnvVarNameSchema = exports.AgentNameSchema = void 0;
4
+ exports.isValidDockerfilePath = isValidDockerfilePath;
5
+ exports.isReservedBuildArgKey = isReservedBuildArgKey;
4
6
  exports.checkAllowlistHeader = checkAllowlistHeader;
5
7
  /**
6
8
  * Agent Schema v2 - Clean, simplified model
@@ -58,6 +60,78 @@ exports.EntrypointSchema = zod_1.z
58
60
  // eslint-disable-next-line security/detect-unsafe-regex -- character class quantifiers don't cause backtracking
59
61
  /^[a-zA-Z0-9_][a-zA-Z0-9_/.-]*\.(py|ts|js)(:[a-zA-Z_][a-zA-Z0-9_]*)?$/, 'Must be a Python (.py) or TypeScript (.ts/.js) file path with optional handler (e.g., "main.py:handler" or "index.ts")');
60
62
  const DirectoryPathSchema = zod_1.z.string().min(1);
63
+ // Char-safe set only (no backslash, spaces, or shell metacharacters): on deploy the buildspec
64
+ // interpolates this unquoted as `docker build -f $DOCKERFILE_PATH`. A leading '.' is allowed so
65
+ // conventional paths like '.docker/Dockerfile' pass.
66
+ const DOCKERFILE_PATH_ALLOWED_CHARS = /^[A-Za-z0-9._/-]+$/;
67
+ /**
68
+ * True when `p` is a safe relative Dockerfile path within the build context: allowed chars only, no
69
+ * leading slash (absolute), and no empty ('' from a leading/trailing/double slash) or '..' segments.
70
+ *
71
+ * The single source of truth shared by `DockerfilePathSchema` (config-validation time) and the runtime
72
+ * `getDockerfilePath` guard, so the two can never diverge — e.g. one accepting '.docker/Dockerfile'
73
+ * while the other rejects it, or one accepting a trailing-slash directory value like 'docker/'.
74
+ */
75
+ function isValidDockerfilePath(p) {
76
+ if (!DOCKERFILE_PATH_ALLOWED_CHARS.test(p))
77
+ return false;
78
+ if (p.startsWith('/'))
79
+ return false;
80
+ return !p.split('/').some(segment => segment === '' || segment === '..');
81
+ }
82
+ /**
83
+ * Dockerfile location for Container builds, resolved relative to the Docker build context
84
+ * (`buildContextPath` when set, otherwise `codeLocation`). Accepts a filename ('Dockerfile',
85
+ * 'Dockerfile.gpu') or a forward-slash relative subpath ('docker/Dockerfile'). Absolute paths,
86
+ * trailing/double slashes, and '..' traversal are rejected so the Dockerfile can never escape or
87
+ * name the build context directory itself.
88
+ */
89
+ const DockerfilePathSchema = zod_1.z
90
+ .string()
91
+ .min(1)
92
+ .max(255)
93
+ .refine(isValidDockerfilePath, 'Must be a relative path within the build context: a filename or forward-slash subpath using only letters, digits, dot, dash, underscore, and slash; no leading slash, no ".." traversal, and no empty segments (no trailing or double slash)');
94
+ /**
95
+ * Build-arg names reserved by the CodeBuild build environment. On deploy each build arg becomes a
96
+ * CodeBuild environment-variable override alongside the buildspec's own control vars, so a colliding
97
+ * name would break the deploy build — a wrong image tag / ECR region, a rejected StartBuild, or a
98
+ * clobbered build-container shell. We reject the buildspec control vars, the process-critical shell
99
+ * vars, and CodeBuild's own `AWS_*` / `CODEBUILD_*` namespaces. This is a best-effort denylist (the
100
+ * shell has other sensitive vars), but it covers the realistic footguns and keeps a config that
101
+ * builds locally from failing only on deploy.
102
+ */
103
+ exports.RESERVED_BUILD_ARG_KEYS = [
104
+ // Buildspec control vars (mirrored in @aws/agentcore-cdk's ContainerBuildProject / build handler).
105
+ 'ECR_REGISTRY',
106
+ 'IMAGE_URI',
107
+ 'DOCKERFILE_PATH',
108
+ 'BUILD_ARG_FLAGS',
109
+ // Overriding these in the build shell would break the buildspec's own commands (command lookup,
110
+ // word-splitting, dynamic linking) or redirect the docker client off the build daemon. Kept
111
+ // deliberately narrow to the genuinely-dangerous names so common ARGs (e.g. USER, LANG) stay usable.
112
+ 'PATH',
113
+ 'HOME',
114
+ 'IFS',
115
+ 'LD_PRELOAD',
116
+ 'LD_LIBRARY_PATH',
117
+ 'DOCKER_HOST',
118
+ 'DOCKER_CONFIG',
119
+ 'DOCKER_TLS_VERIFY',
120
+ 'DOCKER_CERT_PATH',
121
+ ];
122
+ function isReservedBuildArgKey(key) {
123
+ return exports.RESERVED_BUILD_ARG_KEYS.includes(key) || key.startsWith('CODEBUILD_') || key.startsWith('AWS_');
124
+ }
125
+ /**
126
+ * Build-arg value. Bounded and control-char-free because on deploy each value becomes a CodeBuild
127
+ * `environmentVariablesOverride` PLAINTEXT entry; newlines/control chars or an over-long value can be
128
+ * rejected by StartBuild, so we reject them at schema time rather than let a local-only-valid config
129
+ * fail on deploy.
130
+ */
131
+ const BuildArgValueSchema = zod_1.z
132
+ .string()
133
+ .max(4096, 'Build arg values must be at most 4096 characters')
134
+ .refine(v => ![...v].some(ch => ch.charCodeAt(0) < 0x20 || ch.charCodeAt(0) === 0x7f), 'Build arg values must not contain control characters (including newlines)');
61
135
  exports.EnvVarSchema = zod_1.z.object({
62
136
  name: exports.EnvVarNameSchema,
63
137
  value: zod_1.z.string(),
@@ -239,13 +313,29 @@ exports.AgentEnvSpecSchema = zod_1.z
239
313
  build: exports.BuildTypeSchema,
240
314
  entrypoint: exports.EntrypointSchema,
241
315
  codeLocation: DirectoryPathSchema,
242
- /** Custom Dockerfile name for Container builds. Must be a filename, not a path. Default: 'Dockerfile' */
243
- dockerfile: zod_1.z
244
- .string()
245
- .min(1)
246
- .max(255)
247
- .regex(/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/, 'Must be a filename (no path separators or traversal)')
248
- .optional(),
316
+ /**
317
+ * Dockerfile for Container builds, resolved relative to the build context (`buildContextPath`
318
+ * when set, otherwise `codeLocation`). A filename or a relative subpath; no traversal. Default: 'Dockerfile'.
319
+ */
320
+ dockerfile: DockerfilePathSchema.optional(),
321
+ /**
322
+ * Docker build context directory for Container builds. When set, this directory (instead of
323
+ * `codeLocation`) is used as the `docker build` context and as the root the Dockerfile path is
324
+ * resolved against, so a single Dockerfile can be shared across multiple agents in a monorepo
325
+ * (e.g. so it can COPY files that live outside `codeLocation`). Container builds only.
326
+ *
327
+ * Like `codeLocation`, this is intentionally not containment-checked: the config author may point
328
+ * it at any directory (including a parent via `..` for a monorepo root). The unconditional
329
+ * secret-exclusion baseline on the deploy upload still applies to whatever directory is chosen.
330
+ */
331
+ buildContextPath: DirectoryPathSchema.optional(),
332
+ /**
333
+ * Custom build arguments passed to `docker build` as `--build-arg` flags. Keys must be valid
334
+ * environment-variable names (each arg is forwarded to the build as an env var), reusing
335
+ * `EnvVarNameSchema`. Useful for parameterising a shared Dockerfile per agent
336
+ * (e.g. `{ "AGENT_NAME": "myagent" }`). Container builds only.
337
+ */
338
+ customDockerBuildArgs: zod_1.z.record(exports.EnvVarNameSchema, BuildArgValueSchema).optional(),
249
339
  runtimeVersion: constants_1.RuntimeVersionSchema.optional(),
250
340
  /** Environment variables to set on the runtime */
251
341
  envVars: zod_1.z.array(exports.EnvVarSchema).optional(),
@@ -328,13 +418,25 @@ exports.AgentEnvSpecSchema = zod_1.z
328
418
  path: ['authorizerConfiguration'],
329
419
  });
330
420
  }
331
- // If adding more Container-specific fields, consider consolidating into a containerConfig object (see networkConfig pattern)
332
- if (data.build !== 'Container' && data.dockerfile) {
333
- ctx.addIssue({
334
- code: zod_1.z.ZodIssueCode.custom,
335
- message: 'dockerfile is only allowed for Container builds',
336
- path: ['dockerfile'],
337
- });
421
+ // Container-only fields. If adding more, extend this list (and consider consolidating into a
422
+ // containerConfig object — see the networkConfig pattern).
423
+ for (const field of ['dockerfile', 'buildContextPath', 'customDockerBuildArgs']) {
424
+ if (data.build !== 'Container' && data[field]) {
425
+ ctx.addIssue({
426
+ code: zod_1.z.ZodIssueCode.custom,
427
+ message: `${field} is only allowed for Container builds`,
428
+ path: [field],
429
+ });
430
+ }
431
+ }
432
+ for (const key of Object.keys(data.customDockerBuildArgs ?? {})) {
433
+ if (isReservedBuildArgKey(key)) {
434
+ ctx.addIssue({
435
+ code: zod_1.z.ZodIssueCode.custom,
436
+ message: `customDockerBuildArgs key "${key}" is reserved by the build environment (must not be ${exports.RESERVED_BUILD_ARG_KEYS.join(', ')}, or start with CODEBUILD_ or AWS_)`,
437
+ path: ['customDockerBuildArgs', key],
438
+ });
439
+ }
338
440
  }
339
441
  const fcs = data.filesystemConfigurations ?? [];
340
442
  if (fcs.length > 0) {