@aws/agentcore 1.0.0-preview.3 → 1.0.0-preview.30
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.
- package/README.md +193 -33
- package/dist/agent-inspector/index.css +1 -1
- package/dist/agent-inspector/index.js +99 -84
- package/dist/assets/README.md +6 -2
- package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +3344 -366
- package/dist/assets/__tests__/__snapshots__/dockerfile-render.test.ts.snap +6 -2
- package/dist/assets/__tests__/assets.snapshot.test.ts +10 -24
- package/dist/assets/__tests__/googleadk-observability.test.ts +23 -0
- package/dist/assets/__tests__/googleadk-session-eviction.test.ts +87 -0
- package/dist/assets/__tests__/input-validation.test.ts +44 -0
- package/dist/assets/__tests__/summarization-namespace.test.ts +43 -0
- package/dist/assets/agents/AGENTS.md +91 -14
- package/dist/assets/cdk/bin/cdk.ts +109 -24
- package/dist/assets/cdk/lib/cdk-stack.ts +227 -19
- package/dist/assets/cdk/package.json +9 -9
- package/dist/assets/cdk/test/cdk.test.ts +4 -0
- package/dist/assets/container/python/Dockerfile +7 -1
- package/dist/assets/container/typescript/Dockerfile +25 -0
- package/dist/assets/container/typescript/dockerignore.template +24 -0
- package/dist/assets/datasets/predefined-v1.jsonl +3 -0
- package/dist/assets/datasets/simulated-v1.jsonl +3 -0
- package/dist/assets/evaluators/autoevals-lambda/execution-role-policy.json +15 -0
- package/dist/assets/evaluators/autoevals-lambda/lambda_function.py +37 -0
- package/dist/assets/evaluators/autoevals-lambda/pyproject.toml +22 -0
- package/dist/assets/evaluators/deepeval-lambda/execution-role-policy.json +15 -0
- package/dist/assets/evaluators/deepeval-lambda/lambda_function.py +29 -0
- package/dist/assets/evaluators/deepeval-lambda/pyproject.toml +19 -0
- package/dist/assets/mcp/python/pyproject.toml +1 -1
- package/dist/assets/python/a2a/googleadk/base/main.py +32 -18
- package/dist/assets/python/a2a/googleadk/base/pyproject.toml +6 -4
- package/dist/assets/python/a2a/langchain_langgraph/base/main.py +35 -21
- package/dist/assets/python/a2a/langchain_langgraph/base/pyproject.toml +4 -3
- package/dist/assets/python/a2a/strands/base/main.py +23 -17
- package/dist/assets/python/a2a/strands/base/pyproject.toml +3 -3
- package/dist/assets/python/a2a/strands/capabilities/memory/session.py +4 -1
- package/dist/assets/python/agui/googleadk/base/main.py +62 -2
- package/dist/assets/python/agui/googleadk/base/pyproject.toml +6 -5
- package/dist/assets/python/agui/langchain_langgraph/base/main.py +56 -0
- package/dist/assets/python/agui/langchain_langgraph/base/pyproject.toml +3 -2
- package/dist/assets/python/agui/strands/base/main.py +63 -1
- package/dist/assets/python/agui/strands/base/pyproject.toml +2 -2
- package/dist/assets/python/agui/strands/capabilities/memory/session.py +4 -1
- package/dist/assets/python/http/autogen/base/README.md +7 -1
- package/dist/assets/python/http/autogen/base/main.py +62 -29
- package/dist/assets/python/http/autogen/base/pyproject.toml +1 -1
- package/dist/assets/python/http/googleadk/base/README.md +7 -1
- package/dist/assets/python/http/googleadk/base/main.py +71 -24
- package/dist/assets/python/http/googleadk/base/mcp_client/client.py +7 -7
- package/dist/assets/python/http/googleadk/base/pyproject.toml +5 -3
- package/dist/assets/python/http/langchain_langgraph/base/README.md +7 -1
- package/dist/assets/python/http/langchain_langgraph/base/main.py +119 -24
- package/dist/assets/python/http/langchain_langgraph/base/mcp_client/client.py +10 -8
- package/dist/assets/python/http/langchain_langgraph/base/pyproject.toml +5 -4
- package/dist/assets/python/http/openaiagents/base/README.md +7 -1
- package/dist/assets/python/http/openaiagents/base/main.py +63 -32
- package/dist/assets/python/http/openaiagents/base/mcp_client/client.py +4 -4
- package/dist/assets/python/http/openaiagents/base/pyproject.toml +3 -3
- package/dist/assets/python/http/strands/base/README.md +8 -1
- package/dist/assets/python/http/strands/base/main.py +607 -47
- package/dist/assets/python/http/strands/base/mcp_client/client.py +49 -6
- package/dist/assets/python/http/strands/base/model/load.py +119 -3
- package/dist/assets/python/http/strands/base/model/mantle_compat.py +21 -0
- package/dist/assets/python/http/strands/base/pyproject.toml +11 -5
- package/dist/assets/python/http/strands/base/skills/fetcher.py +279 -0
- package/dist/assets/python/http/strands/capabilities/execution-limits/hooks/execution_limits.py +54 -0
- package/dist/assets/python/http/strands/capabilities/memory/session.py +4 -1
- package/dist/assets/python/http/strands/capabilities/payments/__init__.py +4 -0
- package/dist/assets/python/http/strands/capabilities/payments/payments.py +142 -0
- package/dist/assets/python/mcp/standalone/base/main.py +58 -0
- package/dist/assets/python/mcp/standalone/base/pyproject.toml +1 -1
- package/dist/assets/typescript/http/strands/base/README.md +42 -0
- package/dist/assets/typescript/http/strands/base/gitignore.template +22 -0
- package/dist/assets/typescript/http/strands/base/main.ts +149 -0
- package/dist/assets/typescript/http/strands/base/mcp_client/client.ts +11 -0
- package/dist/assets/typescript/http/strands/base/model/load.ts +102 -0
- package/dist/assets/typescript/http/strands/base/package.json +38 -0
- package/dist/assets/typescript/http/strands/base/tsconfig.json +19 -0
- package/dist/assets/typescript/http/strands/capabilities/memory/memory.ts +52 -0
- package/dist/assets/typescript/http/vercelai/base/README.md +42 -0
- package/dist/assets/typescript/http/vercelai/base/gitignore.template +22 -0
- package/dist/assets/typescript/http/vercelai/base/main.ts +70 -0
- package/dist/assets/typescript/http/vercelai/base/model/load.ts +121 -0
- package/dist/assets/typescript/http/vercelai/base/package.json +35 -0
- package/dist/assets/typescript/http/vercelai/base/tsconfig.json +19 -0
- package/dist/cli/index.mjs +1743 -627
- package/dist/lib/constants.d.ts +8 -4
- package/dist/lib/constants.d.ts.map +1 -1
- package/dist/lib/constants.js +13 -7
- package/dist/lib/constants.js.map +1 -1
- package/dist/lib/dependency-management/index.d.ts +5 -0
- package/dist/lib/dependency-management/index.d.ts.map +1 -0
- package/dist/lib/dependency-management/index.js +8 -0
- package/dist/lib/dependency-management/index.js.map +1 -0
- package/dist/lib/dependency-management/messages.d.ts +30 -0
- package/dist/lib/dependency-management/messages.d.ts.map +1 -0
- package/dist/lib/dependency-management/messages.js +86 -0
- package/dist/lib/dependency-management/messages.js.map +1 -0
- package/dist/lib/dependency-management/plan.d.ts +25 -0
- package/dist/lib/dependency-management/plan.d.ts.map +1 -0
- package/dist/lib/dependency-management/plan.js +67 -0
- package/dist/lib/dependency-management/plan.js.map +1 -0
- package/dist/lib/dependency-management/semver.d.ts +21 -0
- package/dist/lib/dependency-management/semver.d.ts.map +1 -0
- package/dist/lib/dependency-management/semver.js +51 -0
- package/dist/lib/dependency-management/semver.js.map +1 -0
- package/dist/lib/dependency-management/sync.d.ts +26 -0
- package/dist/lib/dependency-management/sync.d.ts.map +1 -0
- package/dist/lib/dependency-management/sync.js +141 -0
- package/dist/lib/dependency-management/sync.js.map +1 -0
- package/dist/lib/dependency-management/types.d.ts +85 -0
- package/dist/lib/dependency-management/types.d.ts.map +1 -0
- package/dist/lib/dependency-management/types.js +3 -0
- package/dist/lib/dependency-management/types.js.map +1 -0
- package/dist/lib/errors/index.d.ts +1 -1
- package/dist/lib/errors/index.d.ts.map +1 -1
- package/dist/lib/errors/index.js +1 -1
- package/dist/lib/errors/index.js.map +1 -1
- package/dist/lib/errors/types.d.ts +274 -0
- package/dist/lib/errors/types.d.ts.map +1 -0
- package/dist/lib/errors/types.js +423 -0
- package/dist/lib/errors/types.js.map +1 -0
- package/dist/lib/errors/zod.d.ts +8 -0
- package/dist/lib/errors/zod.d.ts.map +1 -0
- package/dist/lib/errors/{config.js → zod.js} +8 -81
- package/dist/lib/errors/zod.js.map +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/index.d.ts.map +1 -1
- package/dist/lib/index.js +4 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/packaging/build-args.d.ts +6 -0
- package/dist/lib/packaging/build-args.d.ts.map +1 -1
- package/dist/lib/packaging/build-args.js +11 -2
- package/dist/lib/packaging/build-args.js.map +1 -1
- package/dist/lib/packaging/build-context-dockerignore.d.ts +23 -0
- package/dist/lib/packaging/build-context-dockerignore.d.ts.map +1 -0
- package/dist/lib/packaging/build-context-dockerignore.js +63 -0
- package/dist/lib/packaging/build-context-dockerignore.js.map +1 -0
- package/dist/lib/packaging/build-context.d.ts +21 -0
- package/dist/lib/packaging/build-context.d.ts.map +1 -0
- package/dist/lib/packaging/build-context.js +21 -0
- package/dist/lib/packaging/build-context.js.map +1 -0
- package/dist/lib/packaging/container.d.ts.map +1 -1
- package/dist/lib/packaging/container.js +20 -9
- package/dist/lib/packaging/container.js.map +1 -1
- package/dist/lib/packaging/helpers.d.ts +16 -0
- package/dist/lib/packaging/helpers.d.ts.map +1 -1
- package/dist/lib/packaging/helpers.js +127 -29
- package/dist/lib/packaging/helpers.js.map +1 -1
- package/dist/lib/packaging/index.d.ts +2 -1
- package/dist/lib/packaging/index.d.ts.map +1 -1
- package/dist/lib/packaging/index.js +9 -20
- package/dist/lib/packaging/index.js.map +1 -1
- package/dist/lib/packaging/node.d.ts +2 -2
- package/dist/lib/packaging/node.d.ts.map +1 -1
- package/dist/lib/packaging/node.js +83 -38
- package/dist/lib/packaging/node.js.map +1 -1
- package/dist/lib/packaging/python.js +12 -12
- package/dist/lib/packaging/python.js.map +1 -1
- package/dist/lib/result.d.ts +57 -0
- package/dist/lib/result.d.ts.map +1 -0
- package/dist/lib/result.js +62 -0
- package/dist/lib/result.js.map +1 -0
- package/dist/lib/schemas/io/config-io.d.ts +14 -0
- package/dist/lib/schemas/io/config-io.d.ts.map +1 -1
- package/dist/lib/schemas/io/config-io.js +89 -5
- package/dist/lib/schemas/io/config-io.js.map +1 -1
- package/dist/lib/schemas/io/global-config.d.ts +41 -0
- package/dist/lib/schemas/io/global-config.d.ts.map +1 -0
- package/dist/lib/schemas/io/global-config.js +119 -0
- package/dist/lib/schemas/io/global-config.js.map +1 -0
- package/dist/lib/schemas/io/index.d.ts +1 -2
- package/dist/lib/schemas/io/index.d.ts.map +1 -1
- package/dist/lib/schemas/io/index.js +1 -4
- package/dist/lib/schemas/io/index.js.map +1 -1
- package/dist/lib/schemas/io/path-resolver.d.ts +0 -6
- package/dist/lib/schemas/io/path-resolver.d.ts.map +1 -1
- package/dist/lib/schemas/io/path-resolver.js +3 -13
- package/dist/lib/schemas/io/path-resolver.js.map +1 -1
- package/dist/lib/secrets/cipher.d.ts +12 -0
- package/dist/lib/secrets/cipher.d.ts.map +1 -0
- package/dist/lib/secrets/cipher.js +54 -0
- package/dist/lib/secrets/cipher.js.map +1 -0
- package/dist/lib/secrets/index.d.ts +4 -0
- package/dist/lib/secrets/index.d.ts.map +1 -0
- package/dist/lib/secrets/index.js +15 -0
- package/dist/lib/secrets/index.js.map +1 -0
- package/dist/lib/secrets/key-provider.d.ts +16 -0
- package/dist/lib/secrets/key-provider.d.ts.map +1 -0
- package/dist/lib/secrets/key-provider.js +191 -0
- package/dist/lib/secrets/key-provider.js.map +1 -0
- package/dist/lib/secrets/sensitive-keys.d.ts +21 -0
- package/dist/lib/secrets/sensitive-keys.d.ts.map +1 -0
- package/dist/lib/secrets/sensitive-keys.js +67 -0
- package/dist/lib/secrets/sensitive-keys.js.map +1 -0
- package/dist/lib/time-constants.d.ts +5 -0
- package/dist/lib/time-constants.d.ts.map +1 -0
- package/dist/lib/time-constants.js +8 -0
- package/dist/lib/time-constants.js.map +1 -0
- package/dist/lib/utils/env.d.ts +8 -2
- package/dist/lib/utils/env.d.ts.map +1 -1
- package/dist/lib/utils/env.js +65 -17
- package/dist/lib/utils/env.js.map +1 -1
- package/dist/lib/utils/index.d.ts +3 -2
- package/dist/lib/utils/index.d.ts.map +1 -1
- package/dist/lib/utils/index.js +6 -1
- package/dist/lib/utils/index.js.map +1 -1
- package/dist/lib/utils/polling.d.ts +31 -0
- package/dist/lib/utils/polling.d.ts.map +1 -0
- package/dist/lib/utils/polling.js +61 -0
- package/dist/lib/utils/polling.js.map +1 -0
- package/dist/lib/utils/subprocess.d.ts +4 -1
- package/dist/lib/utils/subprocess.d.ts.map +1 -1
- package/dist/lib/utils/subprocess.js +11 -57
- package/dist/lib/utils/subprocess.js.map +1 -1
- package/dist/lib/utils/zod.d.ts +16 -0
- package/dist/lib/utils/zod.d.ts.map +1 -1
- package/dist/lib/utils/zod.js +45 -0
- package/dist/lib/utils/zod.js.map +1 -1
- package/dist/schema/constants.d.ts +56 -2
- package/dist/schema/constants.d.ts.map +1 -1
- package/dist/schema/constants.js +82 -7
- package/dist/schema/constants.js.map +1 -1
- package/dist/schema/schemas/agent-env.d.ts +187 -7
- package/dist/schema/schemas/agent-env.d.ts.map +1 -1
- package/dist/schema/schemas/agent-env.js +323 -27
- package/dist/schema/schemas/agent-env.js.map +1 -1
- package/dist/schema/schemas/agentcore-project.d.ts +519 -12
- package/dist/schema/schemas/agentcore-project.d.ts.map +1 -1
- package/dist/schema/schemas/agentcore-project.js +342 -13
- package/dist/schema/schemas/agentcore-project.js.map +1 -1
- package/dist/schema/schemas/auth.d.ts +174 -0
- package/dist/schema/schemas/auth.d.ts.map +1 -1
- package/dist/schema/schemas/auth.js +127 -3
- package/dist/schema/schemas/auth.js.map +1 -1
- package/dist/schema/schemas/aws-targets.d.ts +18 -0
- package/dist/schema/schemas/aws-targets.d.ts.map +1 -1
- package/dist/schema/schemas/aws-targets.js +6 -0
- package/dist/schema/schemas/aws-targets.js.map +1 -1
- package/dist/schema/schemas/connections.d.ts +185 -0
- package/dist/schema/schemas/connections.d.ts.map +1 -0
- package/dist/schema/schemas/connections.js +176 -0
- package/dist/schema/schemas/connections.js.map +1 -0
- package/dist/schema/schemas/deployed-state.d.ts +392 -5
- package/dist/schema/schemas/deployed-state.d.ts.map +1 -1
- package/dist/schema/schemas/deployed-state.js +112 -2
- package/dist/schema/schemas/deployed-state.js.map +1 -1
- package/dist/schema/schemas/index.d.ts +3 -0
- package/dist/schema/schemas/index.d.ts.map +1 -1
- package/dist/schema/schemas/index.js +5 -0
- package/dist/schema/schemas/index.js.map +1 -1
- package/dist/schema/schemas/mcp-defs.d.ts +2 -1
- package/dist/schema/schemas/mcp-defs.d.ts.map +1 -1
- package/dist/schema/schemas/mcp-defs.js +3 -2
- package/dist/schema/schemas/mcp-defs.js.map +1 -1
- package/dist/schema/schemas/mcp.d.ts +197 -0
- package/dist/schema/schemas/mcp.d.ts.map +1 -1
- package/dist/schema/schemas/mcp.js +334 -5
- package/dist/schema/schemas/mcp.js.map +1 -1
- package/dist/schema/schemas/primitives/ab-test.d.ts +135 -0
- package/dist/schema/schemas/primitives/ab-test.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/ab-test.js +95 -0
- package/dist/schema/schemas/primitives/ab-test.js.map +1 -0
- package/dist/schema/schemas/primitives/capacity-provider.d.ts +237 -0
- package/dist/schema/schemas/primitives/capacity-provider.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/capacity-provider.js +220 -0
- package/dist/schema/schemas/primitives/capacity-provider.js.map +1 -0
- package/dist/schema/schemas/primitives/config-bundle.d.ts +32 -0
- package/dist/schema/schemas/primitives/config-bundle.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/config-bundle.js +41 -0
- package/dist/schema/schemas/primitives/config-bundle.js.map +1 -0
- package/dist/schema/schemas/primitives/dataset.d.ts +48 -0
- package/dist/schema/schemas/primitives/dataset.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/dataset.js +58 -0
- package/dist/schema/schemas/primitives/dataset.js.map +1 -0
- package/dist/schema/schemas/primitives/evaluator.d.ts +22 -0
- package/dist/schema/schemas/primitives/evaluator.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/evaluator.js +28 -3
- package/dist/schema/schemas/primitives/evaluator.js.map +1 -1
- package/dist/schema/schemas/primitives/harness.d.ts +377 -19
- package/dist/schema/schemas/primitives/harness.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/harness.js +379 -24
- package/dist/schema/schemas/primitives/harness.js.map +1 -1
- package/dist/schema/schemas/primitives/index.d.ts +17 -9
- package/dist/schema/schemas/primitives/index.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/index.js +62 -1
- package/dist/schema/schemas/primitives/index.js.map +1 -1
- package/dist/schema/schemas/primitives/knowledge-base.d.ts +104 -0
- package/dist/schema/schemas/primitives/knowledge-base.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/knowledge-base.js +99 -0
- package/dist/schema/schemas/primitives/knowledge-base.js.map +1 -0
- package/dist/schema/schemas/primitives/memory.d.ts +22 -4
- package/dist/schema/schemas/primitives/memory.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/memory.js +57 -16
- package/dist/schema/schemas/primitives/memory.js.map +1 -1
- package/dist/schema/schemas/primitives/online-eval-config.d.ts +21 -2
- package/dist/schema/schemas/primitives/online-eval-config.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/online-eval-config.js +45 -5
- package/dist/schema/schemas/primitives/online-eval-config.js.map +1 -1
- package/dist/schema/schemas/primitives/payment.d.ts +86 -0
- package/dist/schema/schemas/primitives/payment.d.ts.map +1 -0
- package/dist/schema/schemas/primitives/payment.js +88 -0
- package/dist/schema/schemas/primitives/payment.js.map +1 -0
- package/dist/schema/schemas/primitives/policy.d.ts +26 -0
- package/dist/schema/schemas/primitives/policy.d.ts.map +1 -1
- package/dist/schema/schemas/primitives/policy.js +5 -1
- package/dist/schema/schemas/primitives/policy.js.map +1 -1
- package/npm-shrinkwrap.json +16874 -0
- package/package.json +49 -21
- package/scripts/bump-version.ts +4 -4
- package/scripts/bundle.mjs +70 -41
- package/scripts/extract-cli-model.mjs +269 -0
- package/scripts/extract-cli-model.test.mjs +43 -0
- package/scripts/render_adoc.py +350 -0
- package/scripts/run-e2e-dev.sh +56 -0
- package/scripts/run-e2e-local.sh +145 -0
- package/scripts/safe-junit-reporter.ts +7 -0
- package/scripts/sanitize-test-artifacts.ts +65 -0
- package/scripts/sync-vended-cdk.ts +49 -0
- package/scripts/test_render_adoc.py +38 -0
- package/dist/lib/errors/config.d.ts +0 -49
- package/dist/lib/errors/config.d.ts.map +0 -1
- package/dist/lib/errors/config.js.map +0 -1
- package/dist/lib/packaging/errors.d.ts +0 -16
- package/dist/lib/packaging/errors.d.ts.map +0 -1
- package/dist/lib/packaging/errors.js +0 -36
- package/dist/lib/packaging/errors.js.map +0 -1
- package/dist/lib/schemas/io/cli-config.d.ts +0 -12
- package/dist/lib/schemas/io/cli-config.d.ts.map +0 -1
- package/dist/lib/schemas/io/cli-config.js +0 -35
- package/dist/lib/schemas/io/cli-config.js.map +0 -1
|
@@ -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;
|
|
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"}
|
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ContainerPackager = void 0;
|
|
4
4
|
const constants_1 = require("../constants");
|
|
5
|
+
const types_1 = require("../errors/types");
|
|
5
6
|
const build_args_1 = require("./build-args");
|
|
6
|
-
const
|
|
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");
|
|
@@ -29,15 +31,22 @@ function detectContainerRuntimeSync() {
|
|
|
29
31
|
class ContainerPackager {
|
|
30
32
|
pack(spec, options = {}) {
|
|
31
33
|
if (spec.build !== 'Container') {
|
|
32
|
-
return Promise.reject(new
|
|
34
|
+
return Promise.reject(new types_1.PackagingError('ContainerPackager only supports Container build type.'));
|
|
33
35
|
}
|
|
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
|
-
|
|
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
|
-
return Promise.reject(new
|
|
43
|
+
return Promise.reject(new types_1.PackagingError(`${spec.dockerfile ?? constants_1.DOCKERFILE_NAME} not found at ${dockerfilePath}. Container agents require a Dockerfile.`));
|
|
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);
|
|
41
50
|
}
|
|
42
51
|
// Detect container runtime
|
|
43
52
|
const runtime = detectContainerRuntimeSync();
|
|
@@ -49,13 +58,15 @@ class ContainerPackager {
|
|
|
49
58
|
stagingPath: codeLocation,
|
|
50
59
|
});
|
|
51
60
|
}
|
|
52
|
-
// Build locally
|
|
53
|
-
|
|
54
|
-
const
|
|
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) {
|
|
58
|
-
return Promise.reject(new
|
|
69
|
+
return Promise.reject(new types_1.PackagingError(`Container build failed:\n${buildResult.stderr?.toString()}`));
|
|
59
70
|
}
|
|
60
71
|
// Validate size (1GB limit)
|
|
61
72
|
const inspectResult = (0, child_process_1.spawnSync)(runtime, ['image', 'inspect', imageName, '--format', '{{.Size}}'], {
|
|
@@ -64,7 +75,7 @@ class ContainerPackager {
|
|
|
64
75
|
const sizeBytes = parseInt(inspectResult.stdout?.toString().trim() ?? '0', 10);
|
|
65
76
|
if (sizeBytes > constants_1.ONE_GB) {
|
|
66
77
|
const sizeMb = (sizeBytes / (1024 * 1024)).toFixed(2);
|
|
67
|
-
return Promise.reject(new
|
|
78
|
+
return Promise.reject(new types_1.PackagingError(`Container image exceeds 1GB limit (${sizeMb}MB). ` +
|
|
68
79
|
'Optimize your Dockerfile: use multi-stage builds, minimize dependencies, add .dockerignore.'));
|
|
69
80
|
}
|
|
70
81
|
return Promise.resolve({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/lib/packaging/container.ts"],"names":[],"mappings":";;;AACA,
|
|
1
|
+
{"version":3,"file":"container.js","sourceRoot":"","sources":["../../../src/lib/packaging/container.ts"],"names":[],"mappings":"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"}
|
|
@@ -33,6 +33,22 @@ export declare function runCommand(command: string, args: string[], cwd?: string
|
|
|
33
33
|
export declare function createZipFromDir(sourceDir: string, outputZip: string): Promise<void>;
|
|
34
34
|
export declare function enforceZipSizeLimit(zipPath: string): Promise<number>;
|
|
35
35
|
export declare function resolveProjectPathsSync(options?: PackageOptions, agentName?: string): ResolvedPaths;
|
|
36
|
+
/**
|
|
37
|
+
* Resolve filesystem paths for a Node.js/TypeScript agent project during packaging.
|
|
38
|
+
*
|
|
39
|
+
* Locates the nearest package.json (equivalent of pyproject.toml for Python agents),
|
|
40
|
+
* then derives:
|
|
41
|
+
* - projectRoot: directory containing package.json
|
|
42
|
+
* - srcDir: source directory (defaults to projectRoot)
|
|
43
|
+
* - artifactDir: where CDK config and build outputs live (agentcore/ directory)
|
|
44
|
+
* - buildDir/stagingDir: per-agent temp directories used during CodeZip packaging
|
|
45
|
+
*
|
|
46
|
+
* Note: `pyprojectPath` in the return type is reused from the Python ResolvedPaths
|
|
47
|
+
* interface — for Node projects it points to package.json.
|
|
48
|
+
*/
|
|
49
|
+
export declare function resolveNodeProjectPaths(options?: PackageOptions, agentName?: string): Promise<ResolvedPaths>;
|
|
50
|
+
/** Synchronous version of resolveNodeProjectPaths — used in contexts where async is not available. */
|
|
51
|
+
export declare function resolveNodeProjectPathsSync(options?: PackageOptions, agentName?: string): ResolvedPaths;
|
|
36
52
|
export declare function ensureDirCleanSync(dir: string): void;
|
|
37
53
|
export declare function copySourceTreeSync(srcDir: string, destination: string): void;
|
|
38
54
|
export declare function ensureBinaryAvailableSync(binary: string, installHint?: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAwBxD;;GAEG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAEvE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAErE;AAED,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/lib/packaging/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAKnD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAwBxD;;GAEG;AACH,wBAAgB,eAAe,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAEvE;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,cAAc,EAAE,cAAc,GAAG,OAAO,CAErE;AAED,UAAU,aAAa;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAgDD,eAAO,MAAM,kBAAkB,QAAoB,CAAC;AAEpD;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,CAUvF;AA8BD,wBAAsB,mBAAmB,CAAC,OAAO,GAAE,cAAmB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC,CA+BlH;AAED,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/D;AAqBD,wBAAsB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKvF;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAc/F;AAED,wBAAsB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAE7F;AAED,wBAAsB,gBAAgB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAO1F;AAqBD,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAM1E;AAsBD,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,cAAmB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CA8BvG;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,uBAAuB,CAC3C,OAAO,GAAE,cAAmB,EAC5B,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,aAAa,CAAC,CA0BxB;AAED,sGAAsG;AACtG,wBAAgB,2BAA2B,CAAC,OAAO,GAAE,cAAmB,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,aAAa,CA0B3G;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAGpD;AAmBD,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAK5E;AAED,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAcpF;AAqBD,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI,CAO/E;AAED,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAM/D;AAmED;;;;;;GAMG;AACH,wBAAsB,4BAA4B,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAiCpF;AAgCD;;GAEG;AACH,wBAAgB,gCAAgC,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAiCzE"}
|
|
@@ -12,6 +12,8 @@ exports.runCommand = runCommand;
|
|
|
12
12
|
exports.createZipFromDir = createZipFromDir;
|
|
13
13
|
exports.enforceZipSizeLimit = enforceZipSizeLimit;
|
|
14
14
|
exports.resolveProjectPathsSync = resolveProjectPathsSync;
|
|
15
|
+
exports.resolveNodeProjectPaths = resolveNodeProjectPaths;
|
|
16
|
+
exports.resolveNodeProjectPathsSync = resolveNodeProjectPathsSync;
|
|
15
17
|
exports.ensureDirCleanSync = ensureDirCleanSync;
|
|
16
18
|
exports.copySourceTreeSync = copySourceTreeSync;
|
|
17
19
|
exports.ensureBinaryAvailableSync = ensureBinaryAvailableSync;
|
|
@@ -20,9 +22,9 @@ exports.enforceZipSizeLimitSync = enforceZipSizeLimitSync;
|
|
|
20
22
|
exports.convertWindowsScriptsToLinux = convertWindowsScriptsToLinux;
|
|
21
23
|
exports.convertWindowsScriptsToLinuxSync = convertWindowsScriptsToLinuxSync;
|
|
22
24
|
const constants_1 = require("../constants");
|
|
25
|
+
const types_1 = require("../errors/types");
|
|
23
26
|
const platform_1 = require("../utils/platform");
|
|
24
27
|
const subprocess_1 = require("../utils/subprocess");
|
|
25
|
-
const errors_1 = require("./errors");
|
|
26
28
|
const fflate_1 = require("fflate");
|
|
27
29
|
const fs_1 = require("fs");
|
|
28
30
|
const promises_1 = require("fs/promises");
|
|
@@ -44,6 +46,52 @@ function isNodeRuntime(runtimeVersion) {
|
|
|
44
46
|
return runtimeVersion.startsWith('NODE_');
|
|
45
47
|
}
|
|
46
48
|
const EXCLUDED_ENTRIES = new Set(['.git', '.venv', '__pycache__', '.pytest_cache', '.DS_Store', 'node_modules']);
|
|
49
|
+
/**
|
|
50
|
+
* True for any .env / .env.local / .env.* file — per-environment secret files
|
|
51
|
+
* customers expect to stay local. Excluded at every packaging stage and depth.
|
|
52
|
+
*/
|
|
53
|
+
function isEnvSecretEntry(entryName) {
|
|
54
|
+
// .env.* (e.g. .env.production, .env.development) is the same family.
|
|
55
|
+
return entryName === '.env' || entryName === '.env.local' || entryName.startsWith('.env.');
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Decide whether a directory entry should be skipped at the COPY stage (when
|
|
59
|
+
* staging the source tree into the artifact dir). Excludes:
|
|
60
|
+
* - the build-tooling artefacts in EXCLUDED_ENTRIES (.git / .venv / etc.)
|
|
61
|
+
* - the project agentcore/ config directory ONLY when it sits at the
|
|
62
|
+
* root of the package source (an in-tree dependency that ships its own
|
|
63
|
+
* agentcore/ sub-module — see issue #843 — must still be packaged).
|
|
64
|
+
* - any .env / .env.local / .env.* file at any depth.
|
|
65
|
+
*
|
|
66
|
+
* The .env bucket closes a footgun where a project with `--code-location .`
|
|
67
|
+
* (BYO at project root) would otherwise have `agentcore/.env.local` staged
|
|
68
|
+
* — but is depth-aware to avoid breaking legitimate dependency code.
|
|
69
|
+
*/
|
|
70
|
+
function shouldExcludeEntry(entryName, source, rootDir) {
|
|
71
|
+
if (EXCLUDED_ENTRIES.has(entryName))
|
|
72
|
+
return true;
|
|
73
|
+
if (entryName === constants_1.CONFIG_DIR && (0, path_1.resolve)(source) === (0, path_1.resolve)(rootDir))
|
|
74
|
+
return true;
|
|
75
|
+
if (isEnvSecretEntry(entryName))
|
|
76
|
+
return true;
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Decide whether a directory entry should be skipped at the ZIP stage. The zip
|
|
81
|
+
* runs against the staging directory (not the project root), where the
|
|
82
|
+
* project's own agentcore/ config dir is already absent — so a top-level
|
|
83
|
+
* `agentcore/` here is a real Python package (e.g. an installed dependency)
|
|
84
|
+
* and MUST be included (issue #1408 / PR #1424). Unlike the copy stage, we
|
|
85
|
+
* therefore do NOT skip CONFIG_DIR; we only drop build artefacts and .env
|
|
86
|
+
* secret files.
|
|
87
|
+
*/
|
|
88
|
+
function isZipExcludedEntry(entryName) {
|
|
89
|
+
if (EXCLUDED_ENTRIES.has(entryName))
|
|
90
|
+
return true;
|
|
91
|
+
if (isEnvSecretEntry(entryName))
|
|
92
|
+
return true;
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
47
95
|
exports.MAX_ZIP_SIZE_BYTES = 250 * 1024 * 1024;
|
|
48
96
|
/**
|
|
49
97
|
* Resolve CodeLocation path relative to repository root
|
|
@@ -94,7 +142,7 @@ async function resolveProjectPaths(options = {}, agentName) {
|
|
|
94
142
|
? (0, path_1.resolve)(options.pyprojectPath)
|
|
95
143
|
: await findUp('pyproject.toml', startDir);
|
|
96
144
|
if (!candidatePyproject || !(await pathExists(candidatePyproject))) {
|
|
97
|
-
throw new
|
|
145
|
+
throw new types_1.MissingProjectFileError(options.pyprojectPath ?? (0, path_1.join)(startDir, 'pyproject.toml'));
|
|
98
146
|
}
|
|
99
147
|
const pyprojectPath = candidatePyproject;
|
|
100
148
|
const projectRoot = options.projectRoot ? (0, path_1.resolve)(options.projectRoot) : (0, path_1.dirname)(pyprojectPath);
|
|
@@ -125,10 +173,7 @@ async function copyEntry(source, destination, rootDir) {
|
|
|
125
173
|
await (0, promises_1.mkdir)(destination, { recursive: true });
|
|
126
174
|
const entries = await (0, promises_1.readdir)(source);
|
|
127
175
|
for (const entry of entries) {
|
|
128
|
-
if (
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
if (entry === constants_1.CONFIG_DIR && (0, path_1.resolve)(source) === (0, path_1.resolve)(rootDir)) {
|
|
176
|
+
if (shouldExcludeEntry(entry, source, rootDir)) {
|
|
132
177
|
continue;
|
|
133
178
|
}
|
|
134
179
|
await copyEntry((0, path_1.join)(source, entry), (0, path_1.join)(destination, entry), rootDir);
|
|
@@ -141,7 +186,7 @@ async function copyEntry(source, destination, rootDir) {
|
|
|
141
186
|
}
|
|
142
187
|
async function copySourceTree(srcDir, destination) {
|
|
143
188
|
if (!(await pathExists(srcDir))) {
|
|
144
|
-
throw new
|
|
189
|
+
throw new types_1.MissingProjectFileError(srcDir);
|
|
145
190
|
}
|
|
146
191
|
await copyEntry(srcDir, destination, srcDir);
|
|
147
192
|
}
|
|
@@ -156,7 +201,7 @@ async function ensureBinaryAvailable(binary, installHint) {
|
|
|
156
201
|
return;
|
|
157
202
|
}
|
|
158
203
|
}
|
|
159
|
-
throw new
|
|
204
|
+
throw new types_1.MissingDependencyError(binary, installHint);
|
|
160
205
|
}
|
|
161
206
|
async function runCommand(command, args, cwd) {
|
|
162
207
|
await (0, subprocess_1.runSubprocess)(command, args, { cwd });
|
|
@@ -164,22 +209,20 @@ async function runCommand(command, args, cwd) {
|
|
|
164
209
|
async function createZipFromDir(sourceDir, outputZip) {
|
|
165
210
|
await (0, promises_1.rm)(outputZip, { force: true });
|
|
166
211
|
await (0, promises_1.mkdir)((0, path_1.dirname)(outputZip), { recursive: true });
|
|
167
|
-
const files = await collectFiles(sourceDir
|
|
212
|
+
const files = await collectFiles(sourceDir);
|
|
168
213
|
const zipped = (0, fflate_1.zipSync)(files);
|
|
169
214
|
await (0, promises_1.writeFile)(outputZip, zipped);
|
|
170
215
|
}
|
|
171
|
-
async function collectFiles(directory,
|
|
216
|
+
async function collectFiles(directory, basePath = '') {
|
|
172
217
|
const result = {};
|
|
173
218
|
const entries = await (0, promises_1.readdir)(directory, { withFileTypes: true });
|
|
174
219
|
for (const entry of entries) {
|
|
175
|
-
if (
|
|
176
|
-
continue;
|
|
177
|
-
if (entry.name === constants_1.CONFIG_DIR && (0, path_1.resolve)(directory) === (0, path_1.resolve)(rootDir))
|
|
220
|
+
if (isZipExcludedEntry(entry.name))
|
|
178
221
|
continue;
|
|
179
222
|
const fullPath = (0, path_1.join)(directory, entry.name);
|
|
180
223
|
const zipPath = basePath ? `${basePath}/${entry.name}` : entry.name;
|
|
181
224
|
if (entry.isDirectory()) {
|
|
182
|
-
Object.assign(result, await collectFiles(fullPath,
|
|
225
|
+
Object.assign(result, await collectFiles(fullPath, zipPath));
|
|
183
226
|
}
|
|
184
227
|
else if (entry.isFile()) {
|
|
185
228
|
result[zipPath] = [await (0, promises_1.readFile)(fullPath), { level: 6 }];
|
|
@@ -190,7 +233,7 @@ async function collectFiles(directory, rootDir, basePath = '') {
|
|
|
190
233
|
async function enforceZipSizeLimit(zipPath) {
|
|
191
234
|
const { size } = await (0, promises_1.stat)(zipPath);
|
|
192
235
|
if (size > exports.MAX_ZIP_SIZE_BYTES) {
|
|
193
|
-
throw new
|
|
236
|
+
throw new types_1.ArtifactSizeError(exports.MAX_ZIP_SIZE_BYTES, size);
|
|
194
237
|
}
|
|
195
238
|
return size;
|
|
196
239
|
}
|
|
@@ -217,7 +260,7 @@ function resolveProjectPathsSync(options = {}, agentName) {
|
|
|
217
260
|
? (0, path_1.resolve)(options.pyprojectPath)
|
|
218
261
|
: findUpSync('pyproject.toml', startDir);
|
|
219
262
|
if (!candidatePyproject || !pathExistsSync(candidatePyproject)) {
|
|
220
|
-
throw new
|
|
263
|
+
throw new types_1.MissingProjectFileError(options.pyprojectPath ?? (0, path_1.join)(startDir, 'pyproject.toml'));
|
|
221
264
|
}
|
|
222
265
|
const pyprojectPath = candidatePyproject;
|
|
223
266
|
const projectRoot = options.projectRoot ? (0, path_1.resolve)(options.projectRoot) : (0, path_1.dirname)(pyprojectPath);
|
|
@@ -238,6 +281,66 @@ function resolveProjectPathsSync(options = {}, agentName) {
|
|
|
238
281
|
artifactsDir,
|
|
239
282
|
};
|
|
240
283
|
}
|
|
284
|
+
/**
|
|
285
|
+
* Resolve filesystem paths for a Node.js/TypeScript agent project during packaging.
|
|
286
|
+
*
|
|
287
|
+
* Locates the nearest package.json (equivalent of pyproject.toml for Python agents),
|
|
288
|
+
* then derives:
|
|
289
|
+
* - projectRoot: directory containing package.json
|
|
290
|
+
* - srcDir: source directory (defaults to projectRoot)
|
|
291
|
+
* - artifactDir: where CDK config and build outputs live (agentcore/ directory)
|
|
292
|
+
* - buildDir/stagingDir: per-agent temp directories used during CodeZip packaging
|
|
293
|
+
*
|
|
294
|
+
* Note: `pyprojectPath` in the return type is reused from the Python ResolvedPaths
|
|
295
|
+
* interface — for Node projects it points to package.json.
|
|
296
|
+
*/
|
|
297
|
+
async function resolveNodeProjectPaths(options = {}, agentName) {
|
|
298
|
+
const startDir = options.projectRoot ? (0, path_1.resolve)(options.projectRoot) : process.cwd();
|
|
299
|
+
const candidatePackageJson = await findUp('package.json', startDir);
|
|
300
|
+
if (!candidatePackageJson || !(await pathExists(candidatePackageJson))) {
|
|
301
|
+
throw new types_1.MissingProjectFileError((0, path_1.join)(startDir, 'package.json'));
|
|
302
|
+
}
|
|
303
|
+
const projectRoot = options.projectRoot ? (0, path_1.resolve)(options.projectRoot) : (0, path_1.dirname)(candidatePackageJson);
|
|
304
|
+
const srcDir = (0, path_1.resolve)(projectRoot, options.srcDir ?? '.');
|
|
305
|
+
const artifactDir = (0, path_1.resolve)(options.artifactDir ?? (0, path_1.join)(projectRoot, constants_1.CONFIG_DIR));
|
|
306
|
+
const name = agentName ?? 'default';
|
|
307
|
+
const buildDir = (0, path_1.join)(artifactDir, name);
|
|
308
|
+
const stagingDir = (0, path_1.join)(buildDir, 'staging');
|
|
309
|
+
const artifactsDir = artifactDir;
|
|
310
|
+
return {
|
|
311
|
+
projectRoot,
|
|
312
|
+
srcDir,
|
|
313
|
+
pyprojectPath: candidatePackageJson,
|
|
314
|
+
artifactDir,
|
|
315
|
+
buildDir,
|
|
316
|
+
stagingDir,
|
|
317
|
+
artifactsDir,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
/** Synchronous version of resolveNodeProjectPaths — used in contexts where async is not available. */
|
|
321
|
+
function resolveNodeProjectPathsSync(options = {}, agentName) {
|
|
322
|
+
const startDir = options.projectRoot ? (0, path_1.resolve)(options.projectRoot) : process.cwd();
|
|
323
|
+
const candidatePackageJson = findUpSync('package.json', startDir);
|
|
324
|
+
if (!candidatePackageJson || !pathExistsSync(candidatePackageJson)) {
|
|
325
|
+
throw new types_1.MissingProjectFileError((0, path_1.join)(startDir, 'package.json'));
|
|
326
|
+
}
|
|
327
|
+
const projectRoot = options.projectRoot ? (0, path_1.resolve)(options.projectRoot) : (0, path_1.dirname)(candidatePackageJson);
|
|
328
|
+
const srcDir = (0, path_1.resolve)(projectRoot, options.srcDir ?? '.');
|
|
329
|
+
const artifactDir = (0, path_1.resolve)(options.artifactDir ?? (0, path_1.join)(projectRoot, constants_1.CONFIG_DIR));
|
|
330
|
+
const name = agentName ?? 'default';
|
|
331
|
+
const buildDir = (0, path_1.join)(artifactDir, name);
|
|
332
|
+
const stagingDir = (0, path_1.join)(buildDir, 'staging');
|
|
333
|
+
const artifactsDir = artifactDir;
|
|
334
|
+
return {
|
|
335
|
+
projectRoot,
|
|
336
|
+
srcDir,
|
|
337
|
+
pyprojectPath: candidatePackageJson,
|
|
338
|
+
artifactDir,
|
|
339
|
+
buildDir,
|
|
340
|
+
stagingDir,
|
|
341
|
+
artifactsDir,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
241
344
|
function ensureDirCleanSync(dir) {
|
|
242
345
|
(0, fs_1.rmSync)(dir, { recursive: true, force: true });
|
|
243
346
|
(0, fs_1.mkdirSync)(dir, { recursive: true });
|
|
@@ -248,10 +351,7 @@ function copyEntrySync(source, destination, rootDir) {
|
|
|
248
351
|
(0, fs_1.mkdirSync)(destination, { recursive: true });
|
|
249
352
|
const entries = (0, fs_1.readdirSync)(source);
|
|
250
353
|
for (const entry of entries) {
|
|
251
|
-
if (
|
|
252
|
-
continue;
|
|
253
|
-
}
|
|
254
|
-
if (entry === constants_1.CONFIG_DIR && (0, path_1.resolve)(source) === (0, path_1.resolve)(rootDir)) {
|
|
354
|
+
if (shouldExcludeEntry(entry, source, rootDir)) {
|
|
255
355
|
continue;
|
|
256
356
|
}
|
|
257
357
|
copyEntrySync((0, path_1.join)(source, entry), (0, path_1.join)(destination, entry), rootDir);
|
|
@@ -262,7 +362,7 @@ function copyEntrySync(source, destination, rootDir) {
|
|
|
262
362
|
}
|
|
263
363
|
function copySourceTreeSync(srcDir, destination) {
|
|
264
364
|
if (!pathExistsSync(srcDir)) {
|
|
265
|
-
throw new
|
|
365
|
+
throw new types_1.MissingProjectFileError(srcDir);
|
|
266
366
|
}
|
|
267
367
|
copyEntrySync(srcDir, destination, srcDir);
|
|
268
368
|
}
|
|
@@ -277,20 +377,18 @@ function ensureBinaryAvailableSync(binary, installHint) {
|
|
|
277
377
|
return;
|
|
278
378
|
}
|
|
279
379
|
}
|
|
280
|
-
throw new
|
|
380
|
+
throw new types_1.MissingDependencyError(binary, installHint);
|
|
281
381
|
}
|
|
282
|
-
function collectFilesSync(directory,
|
|
382
|
+
function collectFilesSync(directory, basePath = '') {
|
|
283
383
|
const result = {};
|
|
284
384
|
const entries = (0, fs_1.readdirSync)(directory, { withFileTypes: true });
|
|
285
385
|
for (const entry of entries) {
|
|
286
|
-
if (
|
|
287
|
-
continue;
|
|
288
|
-
if (entry.name === constants_1.CONFIG_DIR && (0, path_1.resolve)(directory) === (0, path_1.resolve)(rootDir))
|
|
386
|
+
if (isZipExcludedEntry(entry.name))
|
|
289
387
|
continue;
|
|
290
388
|
const fullPath = (0, path_1.join)(directory, entry.name);
|
|
291
389
|
const zipPath = basePath ? `${basePath}/${entry.name}` : entry.name;
|
|
292
390
|
if (entry.isDirectory()) {
|
|
293
|
-
Object.assign(result, collectFilesSync(fullPath,
|
|
391
|
+
Object.assign(result, collectFilesSync(fullPath, zipPath));
|
|
294
392
|
}
|
|
295
393
|
else if (entry.isFile()) {
|
|
296
394
|
result[zipPath] = [(0, fs_1.readFileSync)(fullPath), { level: 6 }];
|
|
@@ -301,14 +399,14 @@ function collectFilesSync(directory, rootDir, basePath = '') {
|
|
|
301
399
|
function createZipFromDirSync(sourceDir, outputZip) {
|
|
302
400
|
(0, fs_1.rmSync)(outputZip, { force: true });
|
|
303
401
|
(0, fs_1.mkdirSync)((0, path_1.dirname)(outputZip), { recursive: true });
|
|
304
|
-
const files = collectFilesSync(sourceDir
|
|
402
|
+
const files = collectFilesSync(sourceDir);
|
|
305
403
|
const zipped = (0, fflate_1.zipSync)(files);
|
|
306
404
|
(0, fs_1.writeFileSync)(outputZip, zipped);
|
|
307
405
|
}
|
|
308
406
|
function enforceZipSizeLimitSync(zipPath) {
|
|
309
407
|
const { size } = (0, fs_1.statSync)(zipPath);
|
|
310
408
|
if (size > exports.MAX_ZIP_SIZE_BYTES) {
|
|
311
|
-
throw new
|
|
409
|
+
throw new types_1.ArtifactSizeError(exports.MAX_ZIP_SIZE_BYTES, size);
|
|
312
410
|
}
|
|
313
411
|
return size;
|
|
314
412
|
}
|