@aws/nx-plugin 1.0.0-rc.2 → 1.0.0-rc.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.
- package/LICENSE-THIRD-PARTY +3552 -4179
- package/README.md +8 -8
- package/executors.json +9 -0
- package/generators.json +100 -1
- package/package.json +16 -12
- package/sdk/agentcore-gateway.d.ts +6 -0
- package/sdk/agentcore-gateway.js +11 -0
- package/sdk/agentcore-gateway.js.map +1 -0
- package/sdk/license.d.ts +8 -0
- package/sdk/license.js +14 -0
- package/sdk/license.js.map +1 -0
- package/sdk/py.d.ts +6 -6
- package/sdk/py.js +7 -7
- package/sdk/py.js.map +1 -1
- package/sdk/ts.d.ts +18 -14
- package/sdk/ts.js +38 -32
- package/sdk/ts.js.map +1 -1
- package/src/agentcore-gateway/attach-upstream.d.ts +33 -0
- package/src/agentcore-gateway/attach-upstream.js +41 -0
- package/src/agentcore-gateway/attach-upstream.js.map +1 -0
- package/src/agentcore-gateway/files/cedar/policies/README.md +52 -0
- package/src/agentcore-gateway/files/cedar/policies/permit-all.cedar +11 -0
- package/src/agentcore-gateway/files/project/serve-local.ts.template +134 -0
- package/src/agentcore-gateway/gateway-connection/generator.d.ts +21 -0
- package/src/agentcore-gateway/gateway-connection/generator.js +102 -0
- package/src/agentcore-gateway/gateway-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/gateway-connection/schema.d.ts +12 -0
- package/src/agentcore-gateway/gateway-connection/schema.json +26 -0
- package/src/agentcore-gateway/generator.d.ts +25 -0
- package/src/agentcore-gateway/generator.js +129 -0
- package/src/agentcore-gateway/generator.js.map +1 -0
- package/src/agentcore-gateway/mcp-connection/generator.d.ts +19 -0
- package/src/agentcore-gateway/mcp-connection/generator.js +63 -0
- package/src/agentcore-gateway/mcp-connection/generator.js.map +1 -0
- package/src/agentcore-gateway/mcp-connection/schema.d.ts +12 -0
- package/src/agentcore-gateway/mcp-connection/schema.json +26 -0
- package/src/agentcore-gateway/schema.d.ts +16 -0
- package/src/agentcore-gateway/schema.json +65 -0
- package/src/connection/agent-runtime-config.d.ts +1 -1
- package/src/connection/agent-runtime-config.js.map +1 -1
- package/src/connection/agent-serve-local.d.ts +2 -2
- package/src/connection/agent-serve-local.js +1 -1
- package/src/connection/agent-serve-local.js.map +1 -1
- package/src/connection/generator.d.ts +5 -5
- package/src/connection/generator.js +93 -37
- package/src/connection/generator.js.map +1 -1
- package/src/connection/serve-local.d.ts +1 -1
- package/src/connection/serve-local.js +1 -1
- package/src/connection/serve-local.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +47 -58
- package/src/infra/app/generator.d.ts +3 -3
- package/src/infra/app/generator.js +19 -17
- package/src/infra/app/generator.js.map +1 -1
- package/src/license/__snapshots__/config.spec.ts.snap +23 -0
- package/src/license/config-types.d.ts +18 -1
- package/src/license/config-types.js +4 -0
- package/src/license/config-types.js.map +1 -1
- package/src/license/config.d.ts +65 -7
- package/src/license/config.js +315 -7
- package/src/license/config.js.map +1 -1
- package/src/license/dependency-check/check.d.ts +16 -0
- package/src/license/dependency-check/check.js +111 -0
- package/src/license/dependency-check/check.js.map +1 -0
- package/src/license/dependency-check/collectors/collector.d.ts +21 -0
- package/src/license/dependency-check/collectors/collector.js +76 -0
- package/src/license/dependency-check/collectors/collector.js.map +1 -0
- package/src/license/dependency-check/collectors/npm-collector.d.ts +10 -0
- package/src/license/dependency-check/collectors/npm-collector.js +75 -0
- package/src/license/dependency-check/collectors/npm-collector.js.map +1 -0
- package/src/license/dependency-check/collectors/python-collector.d.ts +23 -0
- package/src/license/dependency-check/collectors/python-collector.js +121 -0
- package/src/license/dependency-check/collectors/python-collector.js.map +1 -0
- package/src/license/dependency-check/evaluator.d.ts +9 -0
- package/src/license/dependency-check/evaluator.js +122 -0
- package/src/license/dependency-check/evaluator.js.map +1 -0
- package/src/license/dependency-check/executor-schema.json +6 -0
- package/src/license/dependency-check/executor.d.ts +9 -0
- package/src/license/dependency-check/executor.js +43 -0
- package/src/license/dependency-check/executor.js.map +1 -0
- package/src/license/dependency-check/pre-approved.d.ts +6 -0
- package/src/license/dependency-check/pre-approved.js +1280 -0
- package/src/license/dependency-check/pre-approved.js.map +1 -0
- package/src/license/dependency-check/types.d.ts +45 -0
- package/src/license/dependency-check/types.js +7 -0
- package/src/license/dependency-check/types.js.map +1 -0
- package/src/license/generator.d.ts +3 -3
- package/src/license/generator.js +102 -14
- package/src/license/generator.js.map +1 -1
- package/src/license/index.d.ts +8 -0
- package/src/license/index.js +13 -0
- package/src/license/index.js.map +1 -0
- package/src/license/known-exceptions.d.ts +6 -0
- package/src/license/known-exceptions.js +26 -0
- package/src/license/known-exceptions.js.map +1 -0
- package/src/license/schema.d.ts +5 -0
- package/src/license/schema.json +6 -0
- package/src/license/sync/generator.d.ts +2 -2
- package/src/license/sync/generator.js +15 -15
- package/src/license/sync/generator.js.map +1 -1
- package/src/license/sync/project-file-sync.d.ts +3 -3
- package/src/license/sync/project-file-sync.js.map +1 -1
- package/src/mcp-server/generator-info.d.ts +5 -1
- package/src/mcp-server/generator-info.js +7 -7
- package/src/mcp-server/generator-info.js.map +1 -1
- package/src/mcp-server/guide-pipeline.d.ts +1 -1
- package/src/mcp-server/guide-pipeline.js +2 -2
- package/src/mcp-server/guide-pipeline.js.map +1 -1
- package/src/mcp-server/mdx-ast.js +4 -0
- package/src/mcp-server/mdx-ast.js.map +1 -1
- package/src/mcp-server/schema-registry.d.ts +9 -3
- package/src/mcp-server/schema-registry.js +22 -6
- package/src/mcp-server/schema-registry.js.map +1 -1
- package/src/mcp-server/server.js +3 -3
- package/src/mcp-server/server.js.map +1 -1
- package/src/mcp-server/tools/create-workspace-command.d.ts +1 -1
- package/src/mcp-server/tools/create-workspace-command.js +4 -4
- package/src/mcp-server/tools/create-workspace-command.js.map +1 -1
- package/src/mcp-server/tools/general-guidance.d.ts +2 -2
- package/src/mcp-server/tools/general-guidance.js +2 -2
- package/src/mcp-server/tools/general-guidance.js.map +1 -1
- package/src/mcp-server/tools/generator-guide.d.ts +2 -2
- package/src/mcp-server/tools/generator-guide.js.map +1 -1
- package/src/mcp-server/tools/list-generators.d.ts +2 -2
- package/src/mcp-server/tools/list-generators.js +1 -1
- package/src/mcp-server/tools/list-generators.js.map +1 -1
- package/src/open-api/ts-client/__snapshots__/generator.reserved-keywords.spec.ts.snap +1 -1
- package/src/open-api/ts-client/generator.d.ts +3 -3
- package/src/open-api/ts-client/generator.js +2 -2
- package/src/open-api/ts-client/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.d.ts +3 -3
- package/src/open-api/ts-hooks/generator.js +2 -2
- package/src/open-api/ts-hooks/generator.js.map +1 -1
- package/src/open-api/ts-hooks/generator.spec.tsx +14 -14
- package/src/open-api/ts-metadata/generator.d.ts +3 -3
- package/src/open-api/ts-metadata/generator.js +1 -1
- package/src/open-api/ts-metadata/generator.js.map +1 -1
- package/src/open-api/utils/codegen-data/languages.d.ts +5 -1
- package/src/open-api/utils/codegen-data/languages.js +4 -4
- package/src/open-api/utils/codegen-data/languages.js.map +1 -1
- package/src/open-api/utils/codegen-data.d.ts +6 -2
- package/src/open-api/utils/codegen-data.js +6 -6
- package/src/open-api/utils/codegen-data.js.map +1 -1
- package/src/open-api/utils/normalise.d.ts +5 -1
- package/src/open-api/utils/normalise.js +5 -5
- package/src/open-api/utils/normalise.js.map +1 -1
- package/src/open-api/utils/parse.d.ts +2 -2
- package/src/open-api/utils/parse.js +4 -0
- package/src/open-api/utils/parse.js.map +1 -1
- package/src/open-api/utils/refs.d.ts +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +131 -13
- package/src/preset/generator.d.ts +4 -4
- package/src/preset/generator.js +21 -14
- package/src/preset/generator.js.map +1 -1
- package/src/preset/schema.d.ts +3 -1
- package/src/preset/schema.json +5 -0
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +659 -21
- package/src/py/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +201 -0
- package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client_strands.py.template +30 -0
- package/src/py/agent/a2a-connection/generator.d.ts +3 -3
- package/src/py/agent/a2a-connection/generator.js +11 -10
- package/src/py/agent/a2a-connection/generator.js.map +1 -1
- package/src/py/agent/files/common/agent.py.template +2 -0
- package/src/py/agent/files/http/init.py.template +7 -25
- package/src/py/agent/files/http/main.py.template +2 -3
- package/src/py/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +197 -0
- package/src/py/agent/gateway-connection/files/agent-connection/app/__gatewaySnakeCase___client_strands.py.template +35 -0
- package/src/py/agent/gateway-connection/generator.d.ts +10 -0
- package/src/py/agent/gateway-connection/generator.js +106 -0
- package/src/py/agent/gateway-connection/generator.js.map +1 -0
- package/src/py/agent/gateway-connection/schema.d.ts +12 -0
- package/src/py/agent/gateway-connection/schema.json +26 -0
- package/src/py/agent/generator.d.ts +3 -3
- package/src/py/agent/generator.js +47 -38
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +167 -81
- package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client_strands.py.template +30 -0
- package/src/py/agent/mcp-connection/generator.d.ts +3 -3
- package/src/py/agent/mcp-connection/generator.js +11 -81
- package/src/py/agent/mcp-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/__snapshots__/generator.spec.ts.snap +8 -17
- package/src/py/agent/react-connection/generator.d.ts +3 -3
- package/src/py/agent/react-connection/generator.js +4 -4
- package/src/py/agent/react-connection/generator.js.map +1 -1
- package/src/py/agent/react-connection/serve-local.d.ts +2 -2
- package/src/py/agent/react-connection/serve-local.js.map +1 -1
- package/src/py/api/generator.d.ts +3 -3
- package/src/py/api/generator.js.map +1 -1
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +1486 -0
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +45 -0
- package/src/py/dynamodb/agent-connection/generator.d.ts +10 -0
- package/src/py/dynamodb/agent-connection/generator.js +39 -0
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -0
- package/src/py/dynamodb/agent-connection/schema.d.ts +14 -0
- package/src/py/dynamodb/agent-connection/schema.json +22 -0
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +23 -0
- package/src/py/dynamodb/fast-api-connection/generator.d.ts +10 -0
- package/src/py/dynamodb/fast-api-connection/generator.js +37 -0
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -0
- package/src/py/dynamodb/fast-api-connection/schema.d.ts +12 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +18 -0
- package/src/py/dynamodb/files/__name__/__init__.py.template +6 -0
- package/src/py/dynamodb/files/__name__/client.py.template +39 -0
- package/src/py/dynamodb/files/__name__/entities/__init__.py.template +4 -0
- package/src/py/dynamodb/files/__name__/entities/base.py.template +63 -0
- package/src/py/dynamodb/files/__name__/entities/example.py.template +64 -0
- package/src/py/dynamodb/files/config.json.template +24 -0
- package/src/py/dynamodb/generator.d.ts +10 -0
- package/src/py/dynamodb/generator.js +106 -0
- package/src/py/dynamodb/generator.js.map +1 -0
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +45 -0
- package/src/py/dynamodb/mcp-server-connection/generator.d.ts +10 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js +39 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -0
- package/src/py/dynamodb/mcp-server-connection/schema.d.ts +14 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +22 -0
- package/src/py/dynamodb/schema.d.ts +15 -0
- package/src/py/dynamodb/schema.json +70 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +167 -39
- package/src/py/fast-api/files/app/__name__/init.py.template +5 -22
- package/src/py/fast-api/files/app/__name__/main.py.template +4 -1
- package/src/py/fast-api/generator.d.ts +3 -3
- package/src/py/fast-api/generator.js +23 -17
- package/src/py/fast-api/generator.js.map +1 -1
- package/src/py/fast-api/react/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/py/fast-api/react/generator.d.ts +3 -3
- package/src/py/fast-api/react/generator.js +2 -2
- package/src/py/fast-api/react/generator.js.map +1 -1
- package/src/py/fast-api/react/open-api.d.ts +1 -1
- package/src/py/fast-api/react/open-api.js +5 -2
- package/src/py/fast-api/react/open-api.js.map +1 -1
- package/src/py/lambda-function/generator.d.ts +3 -3
- package/src/py/lambda-function/generator.js +11 -11
- package/src/py/lambda-function/generator.js.map +1 -1
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +83 -13
- package/src/py/mcp-server/generator.d.ts +3 -3
- package/src/py/mcp-server/generator.js +33 -26
- package/src/py/mcp-server/generator.js.map +1 -1
- package/src/py/project/generator.d.ts +3 -3
- package/src/py/project/generator.js +96 -70
- package/src/py/project/generator.js.map +1 -1
- package/src/smithy/project/__snapshots__/generator.spec.ts.snap +19 -16
- package/src/smithy/project/files/build.Dockerfile.template +1 -0
- package/src/smithy/project/files/src/operations/echo.smithy.template +1 -0
- package/src/smithy/project/generator.d.ts +3 -3
- package/src/smithy/project/generator.js +30 -28
- package/src/smithy/project/generator.js.map +1 -1
- package/src/smithy/react-connection/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/smithy/react-connection/generator.d.ts +3 -3
- package/src/smithy/react-connection/generator.js +3 -3
- package/src/smithy/react-connection/generator.js.map +1 -1
- package/src/smithy/ts/api/__snapshots__/generator.spec.ts.snap +14 -34
- package/src/smithy/ts/api/generator.d.ts +3 -3
- package/src/smithy/ts/api/generator.js +18 -12
- package/src/smithy/ts/api/generator.js.map +1 -1
- package/src/terraform/project/files/application/src/main.tf.template +6 -1
- package/src/terraform/project/generator.d.ts +3 -3
- package/src/terraform/project/generator.js +13 -8
- package/src/terraform/project/generator.js.map +1 -1
- package/src/trpc/backend/__snapshots__/generator.spec.ts.snap +163 -18
- package/src/trpc/backend/files/src/procedures/echo.ts.template +1 -1
- package/src/trpc/backend/files/src/schema/echo.ts.template +2 -2
- package/src/trpc/backend/generator.d.ts +3 -3
- package/src/trpc/backend/generator.js +11 -10
- package/src/trpc/backend/generator.js.map +1 -1
- package/src/trpc/backend/schema.d.ts +2 -2
- package/src/trpc/react/__snapshots__/generator.spec.ts.snap +3 -3
- package/src/trpc/react/files/src/components/__apiNameClassName__ClientProvider.tsx.template +3 -3
- package/src/trpc/react/generator.d.ts +3 -3
- package/src/trpc/react/generator.js +5 -5
- package/src/trpc/react/generator.js.map +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +652 -14
- package/src/ts/agent/a2a-connection/__snapshots__/generator.spec.ts.snap +256 -0
- package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client-strands.ts.template +23 -0
- package/src/ts/agent/a2a-connection/generator.d.ts +3 -3
- package/src/ts/agent/a2a-connection/generator.js +8 -8
- package/src/ts/agent/a2a-connection/generator.js.map +1 -1
- package/src/ts/agent/files/common/agent.ts.template +6 -2
- package/src/ts/agent/files/http/router.ts.template +1 -1
- package/src/ts/agent/gateway-connection/__snapshots__/generator.spec.ts.snap +220 -0
- package/src/ts/agent/gateway-connection/files/agent-connection/app/__gatewayKebabCase__-client-strands.ts.template +30 -0
- package/src/ts/agent/gateway-connection/generator.d.ts +10 -0
- package/src/ts/agent/gateway-connection/generator.js +106 -0
- package/src/ts/agent/gateway-connection/generator.js.map +1 -0
- package/src/ts/agent/gateway-connection/schema.d.ts +12 -0
- package/src/ts/agent/gateway-connection/schema.json +26 -0
- package/src/ts/agent/generator.d.ts +3 -3
- package/src/ts/agent/generator.js +44 -32
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/agent/mcp-connection/__snapshots__/generator.spec.ts.snap +191 -110
- package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client-strands.ts.template +22 -0
- package/src/ts/agent/mcp-connection/generator.d.ts +3 -3
- package/src/ts/agent/mcp-connection/generator.js +9 -21
- package/src/ts/agent/mcp-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/generator.d.ts +3 -3
- package/src/ts/agent/react-connection/generator.js +9 -9
- package/src/ts/agent/react-connection/generator.js.map +1 -1
- package/src/ts/agent/react-connection/serve-local.d.ts +2 -2
- package/src/ts/api/generator.d.ts +3 -3
- package/src/ts/api/generator.js +4 -4
- package/src/ts/api/generator.js.map +1 -1
- package/src/ts/api/schema.d.ts +2 -1
- package/src/ts/astro-docs/__snapshots__/generator.spec.ts.snap +7 -8
- package/src/ts/astro-docs/generator.d.ts +3 -3
- package/src/ts/astro-docs/generator.js +14 -11
- package/src/ts/astro-docs/generator.js.map +1 -1
- package/src/ts/docs/generator.d.ts +3 -3
- package/src/ts/docs/generator.js.map +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +1352 -0
- package/src/ts/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +45 -0
- package/src/ts/dynamodb/agent-connection/generator.d.ts +10 -0
- package/src/ts/dynamodb/agent-connection/generator.js +32 -0
- package/src/ts/dynamodb/agent-connection/generator.js.map +1 -0
- package/src/ts/dynamodb/agent-connection/schema.d.ts +14 -0
- package/src/ts/dynamodb/agent-connection/schema.json +22 -0
- package/src/ts/dynamodb/files/config.json.template +24 -0
- package/src/ts/dynamodb/files/src/client.ts.template +61 -0
- package/src/ts/dynamodb/files/src/entities/example.ts.template +47 -0
- package/src/ts/dynamodb/files/src/entities/index.ts.template +1 -0
- package/src/ts/dynamodb/files/src/index.ts.template +2 -0
- package/src/ts/dynamodb/generator.d.ts +10 -0
- package/src/ts/dynamodb/generator.js +111 -0
- package/src/ts/dynamodb/generator.js.map +1 -0
- package/src/ts/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +45 -0
- package/src/ts/dynamodb/mcp-server-connection/generator.d.ts +10 -0
- package/src/ts/dynamodb/mcp-server-connection/generator.js +32 -0
- package/src/ts/dynamodb/mcp-server-connection/generator.js.map +1 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.d.ts +14 -0
- package/src/ts/dynamodb/mcp-server-connection/schema.json +22 -0
- package/src/ts/dynamodb/schema.d.ts +15 -0
- package/src/ts/dynamodb/schema.json +70 -0
- package/src/ts/dynamodb/smithy-connection/__snapshots__/generator.spec.ts.snap +23 -0
- package/src/ts/dynamodb/smithy-connection/generator.d.ts +10 -0
- package/src/ts/dynamodb/smithy-connection/generator.js +30 -0
- package/src/ts/dynamodb/smithy-connection/generator.js.map +1 -0
- package/src/ts/dynamodb/smithy-connection/schema.d.ts +12 -0
- package/src/ts/dynamodb/smithy-connection/schema.json +18 -0
- package/src/ts/dynamodb/trpc-connection/__snapshots__/generator.spec.ts.snap +23 -0
- package/src/ts/dynamodb/trpc-connection/generator.d.ts +10 -0
- package/src/ts/dynamodb/trpc-connection/generator.js +30 -0
- package/src/ts/dynamodb/trpc-connection/generator.js.map +1 -0
- package/src/ts/dynamodb/trpc-connection/schema.d.ts +12 -0
- package/src/ts/dynamodb/trpc-connection/schema.json +18 -0
- package/src/ts/lambda-function/generator.d.ts +3 -3
- package/src/ts/lambda-function/generator.js +8 -8
- package/src/ts/lambda-function/generator.js.map +1 -1
- package/src/ts/lib/__snapshots__/generator.spec.ts.snap +32 -65
- package/src/ts/lib/__snapshots__/vitest.spec.ts.snap +24 -0
- package/src/ts/lib/biome.d.ts +7 -0
- package/src/ts/lib/biome.js +58 -0
- package/src/ts/lib/biome.js.map +1 -0
- package/src/ts/lib/generator.d.ts +3 -3
- package/src/ts/lib/generator.js +27 -29
- package/src/ts/lib/generator.js.map +1 -1
- package/src/ts/lib/grit/vitest-pass-with-no-tests.grit +1 -4
- package/src/ts/lib/ts-project-utils.d.ts +12 -2
- package/src/ts/lib/ts-project-utils.js +30 -10
- package/src/ts/lib/ts-project-utils.js.map +1 -1
- package/src/ts/lib/vitest.d.ts +2 -2
- package/src/ts/lib/vitest.js +1 -1
- package/src/ts/lib/vitest.js.map +1 -1
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +82 -12
- package/src/ts/mcp-server/generator.d.ts +3 -3
- package/src/ts/mcp-server/generator.js +34 -12
- package/src/ts/mcp-server/generator.js.map +1 -1
- package/src/ts/nx-generator/__snapshots__/generator.spec.ts.snap +19 -14
- package/src/ts/nx-generator/generator.d.ts +2 -2
- package/src/ts/nx-generator/generator.js +52 -19
- package/src/ts/nx-generator/generator.js.map +1 -1
- package/src/ts/nx-plugin/generator.d.ts +3 -3
- package/src/ts/nx-plugin/generator.js +10 -9
- package/src/ts/nx-plugin/generator.js.map +1 -1
- package/src/ts/nx-plugin/utils.d.ts +1 -1
- package/src/ts/nx-plugin/utils.js +10 -4
- package/src/ts/nx-plugin/utils.js.map +1 -1
- package/src/ts/rdb/__snapshots__/generator.spec.ts.snap +252 -388
- package/src/ts/rdb/agent-connection/generator.d.ts +3 -3
- package/src/ts/rdb/agent-connection/generator.js +4 -4
- package/src/ts/rdb/agent-connection/generator.js.map +1 -1
- package/src/ts/rdb/files/config.json.template +14 -0
- package/src/ts/rdb/files/prisma.config.ts.template +5 -4
- package/src/ts/rdb/files/src/index.ts.template +0 -1
- package/src/ts/rdb/files/src/prisma.ts.template +26 -21
- package/src/ts/rdb/generator.d.ts +3 -7
- package/src/ts/rdb/generator.js +52 -41
- package/src/ts/rdb/generator.js.map +1 -1
- package/src/ts/rdb/mcp-server-connection/generator.d.ts +3 -3
- package/src/ts/rdb/mcp-server-connection/generator.js +4 -4
- package/src/ts/rdb/mcp-server-connection/generator.js.map +1 -1
- package/src/ts/rdb/smithy-connection/generator.d.ts +3 -3
- package/src/ts/rdb/smithy-connection/generator.js +4 -4
- package/src/ts/rdb/smithy-connection/generator.js.map +1 -1
- package/src/ts/rdb/trpc-connection/generator.d.ts +3 -3
- package/src/ts/rdb/trpc-connection/generator.js +3 -3
- package/src/ts/rdb/trpc-connection/generator.js.map +1 -1
- package/src/ts/rdb/utils.d.ts +1 -1
- package/src/ts/react-website/agui/files/common/src/hooks/useAgui__agentNameClassName__.tsx.template +1 -16
- package/src/ts/react-website/agui/generator.d.ts +1 -1
- package/src/ts/react-website/agui/generator.js +4 -5
- package/src/ts/react-website/agui/generator.js.map +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +530 -367
- package/src/ts/react-website/app/generator.d.ts +3 -3
- package/src/ts/react-website/app/generator.js +21 -17
- package/src/ts/react-website/app/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +1 -7
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +9 -3
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.ux-provider.spec.ts.snap +0 -20
- package/src/ts/react-website/cognito-auth/generator.d.ts +3 -3
- package/src/ts/react-website/cognito-auth/generator.js +10 -13
- package/src/ts/react-website/cognito-auth/generator.js.map +1 -1
- package/src/ts/react-website/cognito-auth/grit/cloudscape-auth-menu.grit +8 -6
- package/src/ts/react-website/cognito-auth/grit/cognito-auth-wrapper.grit +1 -1
- package/src/ts/react-website/cognito-auth/grit/none-auth-menu.grit +1 -0
- package/src/ts/react-website/cognito-auth/grit/shadcn-auth-menu.grit +3 -1
- package/src/ts/react-website/cognito-auth/grit/shadcn-state-declarations.grit +3 -1
- package/src/ts/react-website/cognito-auth/utils.d.ts +1 -1
- package/src/ts/react-website/cognito-auth/utils.js +1 -1
- package/src/ts/react-website/cognito-auth/utils.js.map +1 -1
- package/src/ts/react-website/runtime-config/generator.d.ts +3 -3
- package/src/ts/react-website/runtime-config/generator.js +4 -4
- package/src/ts/react-website/runtime-config/generator.js.map +1 -1
- package/src/ts/sync/generator.d.ts +3 -3
- package/src/ts/sync/generator.js +2 -2
- package/src/ts/sync/generator.js.map +1 -1
- package/src/ts/website/app/generator.d.ts +3 -3
- package/src/ts/website/app/generator.js +1 -1
- package/src/ts/website/app/generator.js.map +1 -1
- package/src/ts/website/auth/generator.d.ts +3 -3
- package/src/ts/website/auth/generator.js +1 -1
- package/src/ts/website/auth/generator.js.map +1 -1
- package/src/utils/agent-chat/agent-chat.d.ts +31 -0
- package/src/utils/agent-chat/agent-chat.js +30 -0
- package/src/utils/agent-chat/agent-chat.js.map +1 -0
- package/src/utils/agent-chat/files/a2a/chat.ts.template +33 -0
- package/src/utils/agent-chat/files/ag-ui/chat.ts.template +17 -0
- package/src/utils/agent-chat/files/common/agentcore.ts.template +81 -0
- package/src/utils/agent-chat/files/http-py/chat.ts.template +43 -0
- package/src/utils/agent-chat/files/http-ts/chat.ts.template +54 -0
- package/src/utils/agent-connection/agent-connection.d.ts +67 -24
- package/src/utils/agent-connection/agent-connection.js +236 -44
- package/src/utils/agent-connection/agent-connection.js.map +1 -1
- package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client-config.ts.template +93 -0
- package/src/utils/agent-connection/files/core-auth/agentcore-endpoints.ts.template +37 -0
- package/src/utils/agent-connection/files/core-auth/agentcore-fetch.ts.template +54 -0
- package/src/utils/agent-connection/files/core-gateway/agentcore-gateway-mcp-transport.ts.template +41 -0
- package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-transport.ts.template +70 -0
- package/src/utils/agent-connection/files/core-runtime-config/runtime-config.ts.template +22 -32
- package/src/utils/agent-connection/files/core-shared/agentcore-transport.ts.template +39 -0
- package/src/utils/agent-connection/files/core-strands/a2a/agentcore-a2a-client-strands.ts.template +61 -0
- package/src/utils/agent-connection/files/core-strands/base/model-errors-strands.ts.template +36 -0
- package/src/utils/agent-connection/files/core-strands/gateway/agentcore-gateway-mcp-client-strands.ts.template +26 -0
- package/src/utils/agent-connection/files/core-strands/mcp/agentcore-mcp-client-strands.ts.template +27 -0
- package/src/utils/agent-connection/files/py-core-a2a/agentcore_a2a_client_config.py.template +43 -0
- package/src/utils/agent-connection/files/py-core-auth/agentcore_endpoints.py.template +47 -0
- package/src/utils/agent-connection/files/py-core-auth/auth/session.py.template +51 -0
- package/src/utils/agent-connection/files/py-core-gateway/agentcore_gateway_mcp_transport.py.template +28 -0
- package/src/utils/agent-connection/files/py-core-mcp/agentcore_mcp_transport.py.template +34 -0
- package/src/utils/agent-connection/files/py-core-runtime-config/runtime_config.py.template +5 -18
- package/src/utils/agent-connection/files/py-core-shared/agentcore_transport.py.template +40 -0
- package/src/utils/agent-connection/files/py-core-strands/a2a/agentcore_a2a_client_strands.py.template +66 -0
- package/src/utils/agent-connection/files/py-core-strands/base/model_errors_strands.py.template +40 -0
- package/src/utils/agent-connection/files/py-core-strands/gateway/agentcore_gateway_mcp_client_strands.py.template +22 -0
- package/src/utils/agent-connection/files/py-core-strands/mcp/agentcore_mcp_client_strands.py.template +30 -0
- package/src/utils/agent-core-constructs/agent-core-constructs.d.ts +11 -3
- package/src/utils/agent-core-constructs/agent-core-constructs.js +57 -12
- package/src/utils/agent-core-constructs/agent-core-constructs.js.map +1 -1
- package/src/utils/agent-core-constructs/files/cdk/app/agent-core/__nameKebabCase__/__nameKebabCase__.ts.template +4 -0
- package/src/utils/agent-core-constructs/files/cdk/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.ts.template +40 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/agentcore-gateway.ts.template +375 -0
- package/src/utils/agent-core-constructs/files/cdk/core/agentcore-gateway/readiness-probe/index.js.template +55 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/__nameKebabCase__.tf.template +335 -0
- package/src/utils/agent-core-constructs/files/terraform/app/agentcore-gateway/__nameKebabCase__/render-cedar.cjs.template +13 -0
- package/src/utils/agent-core-constructs/files/terraform/core/agent-core/runtime.tf.template +77 -9
- package/src/utils/agent-core-constructs/files/terraform/core/agentcore-gateway/gateway.tf.template +14 -0
- package/src/utils/api-constructs/api-constructs.d.ts +2 -2
- package/src/utils/api-constructs/api-constructs.js +1 -1
- package/src/utils/api-constructs/api-constructs.js.map +1 -1
- package/src/utils/api-constructs/files/cdk/app/apis/rest/__apiNameKebabCase__.ts.template +3 -0
- package/src/utils/api-constructs/files/cdk/core/api/http/http-api.ts.template +9 -0
- package/src/utils/api-constructs/files/cdk/core/api/rest/rest-api.ts.template +23 -1
- package/src/utils/api-constructs/files/cdk/core/api/utils/utils.ts.template +61 -7
- package/src/utils/api-constructs/files/terraform/app/apis/rest/__apiNameKebabCase__/__apiNameKebabCase__.tf.template +3 -0
- package/src/utils/api-constructs/open-api-metadata.d.ts +2 -2
- package/src/utils/api-constructs/open-api-metadata.js.map +1 -1
- package/src/utils/ast/website.d.ts +5 -1
- package/src/utils/ast/website.js +3 -3
- package/src/utils/ast/website.js.map +1 -1
- package/src/utils/ast.d.ts +33 -1
- package/src/utils/ast.js +89 -4
- package/src/utils/ast.js.map +1 -1
- package/src/utils/bundle/bundle.d.ts +1 -1
- package/src/utils/bundle/bundle.js +2 -2
- package/src/utils/bundle/bundle.js.map +1 -1
- package/src/utils/config/index.d.ts +5 -5
- package/src/utils/config/utils.d.ts +13 -3
- package/src/utils/config/utils.js +37 -5
- package/src/utils/config/utils.js.map +1 -1
- package/src/utils/connection/open-api/files/components/__apiNameClassName__Provider.tsx.template +1 -1
- package/src/utils/connection/open-api/react.d.ts +1 -1
- package/src/utils/connection/open-api/react.js +4 -4
- package/src/utils/connection/open-api/react.js.map +1 -1
- package/src/utils/containers.d.ts +1 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.d.ts +18 -0
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js +49 -0
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -0
- package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +43 -0
- package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +105 -0
- package/src/utils/dynamodb-constructs/files/terraform/app/dynamodb/__nameKebabCase__/__nameKebabCase__.tf.template +62 -0
- package/src/utils/dynamodb-constructs/files/terraform/core/dynamodb/dynamodb.tf.template +155 -0
- package/src/utils/files/common/scripts/src/dynamodb/create-local-table.ts.template +195 -0
- package/src/utils/files/common/scripts/src/dynamodb/pull-image.ts.template +13 -0
- package/src/utils/files/common/scripts/src/dynamodb/start-container.ts.template +91 -0
- package/src/utils/files/common/scripts/src/rdb/pull-image.ts.template +16 -0
- package/src/utils/files/common/scripts/src/rdb/start-container.ts.template +102 -0
- package/src/utils/files/common/scripts/src/rdb/wait-for-db.ts.template +59 -0
- package/src/utils/files/terraform/src/core/runtime-config/appconfig-deployment/appconfig-deployment.tf.template +9 -3
- package/src/utils/files/terraform/src/core/runtime-config/read/read.tf.template +7 -2
- package/src/utils/format.d.ts +45 -2
- package/src/utils/format.js +167 -46
- package/src/utils/format.js.map +1 -1
- package/src/utils/fs.d.ts +1 -1
- package/src/utils/fs.js.map +1 -1
- package/src/utils/function-constructs/function-constructs.d.ts +2 -2
- package/src/utils/function-constructs/function-constructs.js +1 -1
- package/src/utils/function-constructs/function-constructs.js.map +1 -1
- package/src/utils/generators.d.ts +4 -0
- package/src/utils/generators.js +4 -4
- package/src/utils/generators.js.map +1 -1
- package/src/utils/git.d.ts +1 -1
- package/src/utils/git.js.map +1 -1
- package/src/utils/iac.d.ts +1 -1
- package/src/utils/iac.js.map +1 -1
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +1 -5
- package/src/utils/identity-constructs/files/terraform/core/user-identity/add-callback-url/add-callback-url.tf.template +9 -3
- package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +2 -4
- package/src/utils/identity-constructs/identity-constructs.d.ts +2 -2
- package/src/utils/identity-constructs/identity-constructs.js +1 -1
- package/src/utils/identity-constructs/identity-constructs.js.map +1 -1
- package/src/utils/js.d.ts +4 -0
- package/src/utils/js.js +4 -4
- package/src/utils/js.js.map +1 -1
- package/src/utils/mcp.d.ts +25 -0
- package/src/utils/mcp.js +81 -0
- package/src/utils/mcp.js.map +1 -0
- package/src/utils/metrics.d.ts +9 -3
- package/src/utils/metrics.js +58 -28
- package/src/utils/metrics.js.map +1 -1
- package/src/utils/npm-scope.d.ts +1 -1
- package/src/utils/npm-scope.js.map +1 -1
- package/src/utils/nx.d.ts +7 -2
- package/src/utils/nx.js +46 -14
- package/src/utils/nx.js.map +1 -1
- package/src/utils/nxlv-python.d.ts +1 -1
- package/src/utils/paths.d.ts +1 -1
- package/src/utils/pnpm-workspace.d.ts +1 -1
- package/src/utils/pnpm-workspace.js.map +1 -1
- package/src/utils/port.d.ts +31 -3
- package/src/utils/port.js +74 -4
- package/src/utils/port.js.map +1 -1
- package/src/utils/py.d.ts +2 -2
- package/src/utils/py.js +13 -6
- package/src/utils/py.js.map +1 -1
- package/src/utils/rdb-constructs/files/cdk/app/dbs/__nameKebabCase__.ts.template +12 -2
- package/src/utils/rdb-constructs/files/cdk/core/rdb/aurora.ts.template +30 -1
- package/src/utils/rdb-constructs/files/terraform/app/dbs/__nameKebabCase__/__nameKebabCase__.tf.template +38 -16
- package/src/utils/rdb-constructs/files/terraform/core/rdb/aurora/aurora.tf.template +28 -13
- package/src/utils/rdb-constructs/rdb-constructs.d.ts +5 -4
- package/src/utils/rdb-constructs/rdb-constructs.js +3 -11
- package/src/utils/rdb-constructs/rdb-constructs.js.map +1 -1
- package/src/utils/shared-constructs-constants.d.ts +1 -0
- package/src/utils/shared-constructs-constants.js +2 -1
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-constructs.d.ts +2 -2
- package/src/utils/shared-constructs.js +7 -7
- package/src/utils/shared-constructs.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +11 -0
- package/src/utils/shared-dynamodb-scripts.js +23 -0
- package/src/utils/shared-dynamodb-scripts.js.map +1 -0
- package/src/utils/shared-infra-config.d.ts +1 -1
- package/src/utils/shared-infra-config.js +1 -1
- package/src/utils/shared-infra-config.js.map +1 -1
- package/src/utils/shared-infra-scripts.d.ts +11 -0
- package/src/utils/shared-infra-scripts.js +35 -0
- package/src/utils/shared-infra-scripts.js.map +1 -0
- package/src/utils/shared-rdb-scripts.d.ts +11 -0
- package/src/utils/shared-rdb-scripts.js +20 -0
- package/src/utils/shared-rdb-scripts.js.map +1 -0
- package/src/utils/shared-scripts.d.ts +2 -5
- package/src/utils/shared-scripts.js +2 -23
- package/src/utils/shared-scripts.js.map +1 -1
- package/src/utils/shared-shadcn.d.ts +1 -1
- package/src/utils/shared-shadcn.js +1 -13
- package/src/utils/shared-shadcn.js.map +1 -1
- package/src/utils/test.d.ts +5 -1
- package/src/utils/test.js +9 -5
- package/src/utils/test.js.map +1 -1
- package/src/utils/toml.d.ts +1 -1
- package/src/utils/toml.js +4 -0
- package/src/utils/toml.js.map +1 -1
- package/src/utils/versions.d.ts +82 -83
- package/src/utils/versions.js +81 -82
- package/src/utils/versions.js.map +1 -1
- package/src/utils/website-constructs/files/cdk/core/static-website.ts.template +72 -5
- package/src/utils/website-constructs/files/terraform/core/static-website/static-website.tf.template +63 -15
- package/src/utils/website-constructs/website-constructs.d.ts +2 -2
- package/src/utils/website-constructs/website-constructs.js +1 -1
- package/src/utils/website-constructs/website-constructs.js.map +1 -1
- package/src/py/agent/a2a-connection/files/agent-connection/app/__targetAgentSnakeCase___client.py.template +0 -22
- package/src/py/agent/mcp-connection/files/agent-connection/app/__mcpServerSnakeCase___client.py.template +0 -22
- package/src/py/agent/scripts/http/chat.ts.template +0 -38
- package/src/ts/agent/a2a-connection/files/agent-connection/app/__targetAgentKebabCase__-client.ts.template +0 -19
- package/src/ts/agent/mcp-connection/files/agent-connection/app/__mcpServerKebabCase__-client.ts.template +0 -19
- package/src/ts/agent/scripts/http/chat.ts.template +0 -35
- package/src/ts/lib/eslint.d.ts +0 -14
- package/src/ts/lib/eslint.js +0 -90
- package/src/ts/lib/eslint.js.map +0 -1
- package/src/ts/lib/grit/eslint-dependency-checks-warn.grit +0 -1
- package/src/ts/rdb/files/scripts/docker-pull.ts.template +0 -15
- package/src/ts/rdb/files/scripts/docker-start.ts.template +0 -84
- package/src/ts/rdb/files/scripts/wait-for-db.ts.template +0 -55
- package/src/ts/rdb/files/src/constants.ts.template +0 -8
- package/src/utils/agent-connection/files/core-a2a/agentcore-a2a-client.ts.template +0 -123
- package/src/utils/agent-connection/files/core-mcp/agentcore-mcp-client.ts.template +0 -128
- package/src/utils/agent-connection/files/py-core-a2a/agentcore_a2a_client.py.template +0 -120
- package/src/utils/agent-connection/files/py-core-mcp/agentcore_mcp_client.py.template +0 -89
- /package/src/utils/agent-connection/files/{core-runtime-config/with-session-id.ts.template → core-strands/base/with-session-id-strands.ts.template} +0 -0
- /package/src/utils/agent-connection/files/{py-core-runtime-config/with_session_id.py.template → py-core-strands/base/with_session_id_strands.py.template} +0 -0
- /package/src/utils/files/common/scripts/src/{index.ts.template → infra/index.ts.template} +0 -0
- /package/src/utils/files/common/scripts/src/{infra-deploy.ts.template → infra/infra-deploy.ts.template} +0 -0
- /package/src/utils/files/common/scripts/src/{infra-destroy.ts.template → infra/infra-destroy.ts.template} +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/cdk-command.ts.template +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/credentials.ts.template +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/run.ts.template +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/stage-parser.ts.template +0 -0
|
@@ -1,5 +1,569 @@
|
|
|
1
1
|
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
|
2
2
|
|
|
3
|
+
exports[`ts#agent generator > chat scripts for a2a protocol > should match snapshot for chat scripts with cognito auth > agentcore.ts (a2a, cognito) 1`] = `
|
|
4
|
+
"// Resolves the deployed TestProjectAgent agent from runtime config and authenticates requests to it.
|
|
5
|
+
import { randomUUID } from 'node:crypto';
|
|
6
|
+
import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
|
|
7
|
+
|
|
8
|
+
const SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
|
|
9
|
+
|
|
10
|
+
// AgentCore session ids must be at least 33 characters.
|
|
11
|
+
export const SESSION_ID = randomUUID().replaceAll('-', '').padEnd(33, '0');
|
|
12
|
+
|
|
13
|
+
export interface RemoteAgent {
|
|
14
|
+
/** ARN of the deployed Bedrock AgentCore runtime. */
|
|
15
|
+
arn: string;
|
|
16
|
+
/** AWS region parsed from the runtime ARN. */
|
|
17
|
+
region: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Returns the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set, otherwise \`undefined\` to chat locally.
|
|
21
|
+
export const resolveRemoteAgent = async (): Promise<
|
|
22
|
+
RemoteAgent | undefined
|
|
23
|
+
> => {
|
|
24
|
+
const application = process.env.RUNTIME_CONFIG_APP_ID;
|
|
25
|
+
if (!application) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
const config = (await getAppConfig('agentcore', {
|
|
29
|
+
application,
|
|
30
|
+
environment: 'default',
|
|
31
|
+
transform: 'json',
|
|
32
|
+
})) as { agentRuntimes?: Record<string, string> };
|
|
33
|
+
const arn = config?.agentRuntimes?.['TestProjectAgent'];
|
|
34
|
+
if (!arn) {
|
|
35
|
+
throw new Error(
|
|
36
|
+
\`No deployed agent named 'TestProjectAgent' found in runtime configuration (application \${application}).\`,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
return { arn, region: arn.split(':')[3] };
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** The Cognito access token used to authenticate with the deployed agent. */
|
|
43
|
+
export const getAccessToken = (): string => {
|
|
44
|
+
const accessToken = process.env.AGENT_ACCESS_TOKEN;
|
|
45
|
+
if (!accessToken) {
|
|
46
|
+
throw new Error(
|
|
47
|
+
'AGENT_ACCESS_TOKEN is not set. Provide a Cognito access token to chat with the deployed agent.',
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
return accessToken;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
// A \`fetch\` that authenticates requests to the deployed agent and forwards the session id.
|
|
54
|
+
export const createAgentCoreFetch = (): typeof fetch => {
|
|
55
|
+
const accessToken = getAccessToken();
|
|
56
|
+
return (input, init) => {
|
|
57
|
+
const headers = new Headers(init?.headers);
|
|
58
|
+
headers.set(SESSION_HEADER, SESSION_ID);
|
|
59
|
+
headers.set('Authorization', \`Bearer \${accessToken}\`);
|
|
60
|
+
return fetch(input, { ...init, headers });
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
"
|
|
64
|
+
`;
|
|
65
|
+
|
|
66
|
+
exports[`ts#agent generator > chat scripts for a2a protocol > should match snapshot for chat scripts with cognito auth > chat.ts (a2a, cognito) 1`] = `
|
|
67
|
+
"// Chat CLI for TestProjectAgent (A2A protocol). Connects to the local
|
|
68
|
+
// \`serve-local\` server, or the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set.
|
|
69
|
+
import {
|
|
70
|
+
ClientFactory,
|
|
71
|
+
ClientFactoryOptions,
|
|
72
|
+
DefaultAgentCardResolver,
|
|
73
|
+
JsonRpcTransportFactory,
|
|
74
|
+
} from '@a2a-js/sdk/client';
|
|
75
|
+
import { A2AChatAdapter, chatLoop } from 'agent-chat-cli';
|
|
76
|
+
import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
|
|
77
|
+
|
|
78
|
+
const remote = await resolveRemoteAgent();
|
|
79
|
+
|
|
80
|
+
const url = remote
|
|
81
|
+
? \`https://bedrock-agentcore.\${remote.region}.amazonaws.com/runtimes/\${encodeURIComponent(remote.arn)}/invocations/\`
|
|
82
|
+
: process.env.URL!;
|
|
83
|
+
|
|
84
|
+
// Remote requests are authenticated via a custom fetch; locally the default client talks plain HTTP.
|
|
85
|
+
const clientFactory = remote
|
|
86
|
+
? new ClientFactory({
|
|
87
|
+
...ClientFactoryOptions.default,
|
|
88
|
+
transports: [
|
|
89
|
+
new JsonRpcTransportFactory({
|
|
90
|
+
fetchImpl: createAgentCoreFetch(),
|
|
91
|
+
}),
|
|
92
|
+
],
|
|
93
|
+
cardResolver: new DefaultAgentCardResolver({
|
|
94
|
+
fetchImpl: createAgentCoreFetch(),
|
|
95
|
+
}),
|
|
96
|
+
})
|
|
97
|
+
: undefined;
|
|
98
|
+
|
|
99
|
+
await chatLoop(new A2AChatAdapter({ clientFactory }), url);
|
|
100
|
+
"
|
|
101
|
+
`;
|
|
102
|
+
|
|
103
|
+
exports[`ts#agent generator > chat scripts for a2a protocol > should match snapshot for chat scripts with iam auth > agentcore.ts (a2a, iam) 1`] = `
|
|
104
|
+
"// Resolves the deployed TestProjectAgent agent from runtime config and authenticates requests to it.
|
|
105
|
+
import { randomUUID } from 'node:crypto';
|
|
106
|
+
import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
|
|
107
|
+
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
|
|
108
|
+
import { AwsClient } from 'aws4fetch';
|
|
109
|
+
|
|
110
|
+
const SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
|
|
111
|
+
|
|
112
|
+
// AgentCore session ids must be at least 33 characters.
|
|
113
|
+
export const SESSION_ID = randomUUID().replaceAll('-', '').padEnd(33, '0');
|
|
114
|
+
|
|
115
|
+
export interface RemoteAgent {
|
|
116
|
+
/** ARN of the deployed Bedrock AgentCore runtime. */
|
|
117
|
+
arn: string;
|
|
118
|
+
/** AWS region parsed from the runtime ARN. */
|
|
119
|
+
region: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// Returns the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set, otherwise \`undefined\` to chat locally.
|
|
123
|
+
export const resolveRemoteAgent = async (): Promise<
|
|
124
|
+
RemoteAgent | undefined
|
|
125
|
+
> => {
|
|
126
|
+
const application = process.env.RUNTIME_CONFIG_APP_ID;
|
|
127
|
+
if (!application) {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const config = (await getAppConfig('agentcore', {
|
|
131
|
+
application,
|
|
132
|
+
environment: 'default',
|
|
133
|
+
transform: 'json',
|
|
134
|
+
})) as { agentRuntimes?: Record<string, string> };
|
|
135
|
+
const arn = config?.agentRuntimes?.['TestProjectAgent'];
|
|
136
|
+
if (!arn) {
|
|
137
|
+
throw new Error(
|
|
138
|
+
\`No deployed agent named 'TestProjectAgent' found in runtime configuration (application \${application}).\`,
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
return { arn, region: arn.split(':')[3] };
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
// A \`fetch\` that authenticates requests to the deployed agent and forwards the session id.
|
|
145
|
+
export const createAgentCoreFetch = (region: string): typeof fetch => {
|
|
146
|
+
const credentialProvider = fromNodeProviderChain();
|
|
147
|
+
return async (input, init) => {
|
|
148
|
+
const headers = new Headers(init?.headers);
|
|
149
|
+
headers.set(SESSION_HEADER, SESSION_ID);
|
|
150
|
+
const client = new AwsClient({
|
|
151
|
+
...(await credentialProvider()),
|
|
152
|
+
service: 'bedrock-agentcore',
|
|
153
|
+
region,
|
|
154
|
+
});
|
|
155
|
+
return client.fetch(input, { ...init, headers });
|
|
156
|
+
};
|
|
157
|
+
};
|
|
158
|
+
"
|
|
159
|
+
`;
|
|
160
|
+
|
|
161
|
+
exports[`ts#agent generator > chat scripts for a2a protocol > should match snapshot for chat scripts with iam auth > chat.ts (a2a, iam) 1`] = `
|
|
162
|
+
"// Chat CLI for TestProjectAgent (A2A protocol). Connects to the local
|
|
163
|
+
// \`serve-local\` server, or the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set.
|
|
164
|
+
import {
|
|
165
|
+
ClientFactory,
|
|
166
|
+
ClientFactoryOptions,
|
|
167
|
+
DefaultAgentCardResolver,
|
|
168
|
+
JsonRpcTransportFactory,
|
|
169
|
+
} from '@a2a-js/sdk/client';
|
|
170
|
+
import { A2AChatAdapter, chatLoop } from 'agent-chat-cli';
|
|
171
|
+
import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
|
|
172
|
+
|
|
173
|
+
const remote = await resolveRemoteAgent();
|
|
174
|
+
|
|
175
|
+
const url = remote
|
|
176
|
+
? \`https://bedrock-agentcore.\${remote.region}.amazonaws.com/runtimes/\${encodeURIComponent(remote.arn)}/invocations/\`
|
|
177
|
+
: process.env.URL!;
|
|
178
|
+
|
|
179
|
+
// Remote requests are authenticated via a custom fetch; locally the default client talks plain HTTP.
|
|
180
|
+
const clientFactory = remote
|
|
181
|
+
? new ClientFactory({
|
|
182
|
+
...ClientFactoryOptions.default,
|
|
183
|
+
transports: [
|
|
184
|
+
new JsonRpcTransportFactory({
|
|
185
|
+
fetchImpl: createAgentCoreFetch(remote.region),
|
|
186
|
+
}),
|
|
187
|
+
],
|
|
188
|
+
cardResolver: new DefaultAgentCardResolver({
|
|
189
|
+
fetchImpl: createAgentCoreFetch(remote.region),
|
|
190
|
+
}),
|
|
191
|
+
})
|
|
192
|
+
: undefined;
|
|
193
|
+
|
|
194
|
+
await chatLoop(new A2AChatAdapter({ clientFactory }), url);
|
|
195
|
+
"
|
|
196
|
+
`;
|
|
197
|
+
|
|
198
|
+
exports[`ts#agent generator > chat scripts for ag-ui protocol > should match snapshot for chat scripts with cognito auth > agentcore.ts (ag-ui, cognito) 1`] = `
|
|
199
|
+
"// Resolves the deployed TestProjectAgent agent from runtime config and authenticates requests to it.
|
|
200
|
+
import { randomUUID } from 'node:crypto';
|
|
201
|
+
import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
|
|
202
|
+
|
|
203
|
+
const SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
|
|
204
|
+
|
|
205
|
+
// AgentCore session ids must be at least 33 characters.
|
|
206
|
+
export const SESSION_ID = randomUUID().replaceAll('-', '').padEnd(33, '0');
|
|
207
|
+
|
|
208
|
+
export interface RemoteAgent {
|
|
209
|
+
/** ARN of the deployed Bedrock AgentCore runtime. */
|
|
210
|
+
arn: string;
|
|
211
|
+
/** AWS region parsed from the runtime ARN. */
|
|
212
|
+
region: string;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
// Returns the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set, otherwise \`undefined\` to chat locally.
|
|
216
|
+
export const resolveRemoteAgent = async (): Promise<
|
|
217
|
+
RemoteAgent | undefined
|
|
218
|
+
> => {
|
|
219
|
+
const application = process.env.RUNTIME_CONFIG_APP_ID;
|
|
220
|
+
if (!application) {
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
const config = (await getAppConfig('agentcore', {
|
|
224
|
+
application,
|
|
225
|
+
environment: 'default',
|
|
226
|
+
transform: 'json',
|
|
227
|
+
})) as { agentRuntimes?: Record<string, string> };
|
|
228
|
+
const arn = config?.agentRuntimes?.['TestProjectAgent'];
|
|
229
|
+
if (!arn) {
|
|
230
|
+
throw new Error(
|
|
231
|
+
\`No deployed agent named 'TestProjectAgent' found in runtime configuration (application \${application}).\`,
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
return { arn, region: arn.split(':')[3] };
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/** The Cognito access token used to authenticate with the deployed agent. */
|
|
238
|
+
export const getAccessToken = (): string => {
|
|
239
|
+
const accessToken = process.env.AGENT_ACCESS_TOKEN;
|
|
240
|
+
if (!accessToken) {
|
|
241
|
+
throw new Error(
|
|
242
|
+
'AGENT_ACCESS_TOKEN is not set. Provide a Cognito access token to chat with the deployed agent.',
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
return accessToken;
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// A \`fetch\` that authenticates requests to the deployed agent and forwards the session id.
|
|
249
|
+
export const createAgentCoreFetch = (): typeof fetch => {
|
|
250
|
+
const accessToken = getAccessToken();
|
|
251
|
+
return (input, init) => {
|
|
252
|
+
const headers = new Headers(init?.headers);
|
|
253
|
+
headers.set(SESSION_HEADER, SESSION_ID);
|
|
254
|
+
headers.set('Authorization', \`Bearer \${accessToken}\`);
|
|
255
|
+
return fetch(input, { ...init, headers });
|
|
256
|
+
};
|
|
257
|
+
};
|
|
258
|
+
"
|
|
259
|
+
`;
|
|
260
|
+
|
|
261
|
+
exports[`ts#agent generator > chat scripts for ag-ui protocol > should match snapshot for chat scripts with cognito auth > chat.ts (ag-ui, cognito) 1`] = `
|
|
262
|
+
"// Chat CLI for TestProjectAgent (AG-UI protocol). Connects to the local
|
|
263
|
+
// \`serve-local\` server, or the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set.
|
|
264
|
+
import { AGUIChatAdapter, chatLoop } from 'agent-chat-cli';
|
|
265
|
+
import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
|
|
266
|
+
|
|
267
|
+
const remote = await resolveRemoteAgent();
|
|
268
|
+
|
|
269
|
+
const url = remote
|
|
270
|
+
? \`https://bedrock-agentcore.\${remote.region}.amazonaws.com/runtimes/\${encodeURIComponent(remote.arn)}/invocations?qualifier=DEFAULT\`
|
|
271
|
+
: process.env.URL!;
|
|
272
|
+
|
|
273
|
+
// Remote requests are authenticated via a custom fetch; locally the default agent talks plain HTTP.
|
|
274
|
+
const fetchImpl = remote ? createAgentCoreFetch() : undefined;
|
|
275
|
+
|
|
276
|
+
await chatLoop(new AGUIChatAdapter({ fetch: fetchImpl }), url);
|
|
277
|
+
"
|
|
278
|
+
`;
|
|
279
|
+
|
|
280
|
+
exports[`ts#agent generator > chat scripts for ag-ui protocol > should match snapshot for chat scripts with iam auth > agentcore.ts (ag-ui, iam) 1`] = `
|
|
281
|
+
"// Resolves the deployed TestProjectAgent agent from runtime config and authenticates requests to it.
|
|
282
|
+
import { randomUUID } from 'node:crypto';
|
|
283
|
+
import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
|
|
284
|
+
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
|
|
285
|
+
import { AwsClient } from 'aws4fetch';
|
|
286
|
+
|
|
287
|
+
const SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
|
|
288
|
+
|
|
289
|
+
// AgentCore session ids must be at least 33 characters.
|
|
290
|
+
export const SESSION_ID = randomUUID().replaceAll('-', '').padEnd(33, '0');
|
|
291
|
+
|
|
292
|
+
export interface RemoteAgent {
|
|
293
|
+
/** ARN of the deployed Bedrock AgentCore runtime. */
|
|
294
|
+
arn: string;
|
|
295
|
+
/** AWS region parsed from the runtime ARN. */
|
|
296
|
+
region: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Returns the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set, otherwise \`undefined\` to chat locally.
|
|
300
|
+
export const resolveRemoteAgent = async (): Promise<
|
|
301
|
+
RemoteAgent | undefined
|
|
302
|
+
> => {
|
|
303
|
+
const application = process.env.RUNTIME_CONFIG_APP_ID;
|
|
304
|
+
if (!application) {
|
|
305
|
+
return undefined;
|
|
306
|
+
}
|
|
307
|
+
const config = (await getAppConfig('agentcore', {
|
|
308
|
+
application,
|
|
309
|
+
environment: 'default',
|
|
310
|
+
transform: 'json',
|
|
311
|
+
})) as { agentRuntimes?: Record<string, string> };
|
|
312
|
+
const arn = config?.agentRuntimes?.['TestProjectAgent'];
|
|
313
|
+
if (!arn) {
|
|
314
|
+
throw new Error(
|
|
315
|
+
\`No deployed agent named 'TestProjectAgent' found in runtime configuration (application \${application}).\`,
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
return { arn, region: arn.split(':')[3] };
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// A \`fetch\` that authenticates requests to the deployed agent and forwards the session id.
|
|
322
|
+
export const createAgentCoreFetch = (region: string): typeof fetch => {
|
|
323
|
+
const credentialProvider = fromNodeProviderChain();
|
|
324
|
+
return async (input, init) => {
|
|
325
|
+
const headers = new Headers(init?.headers);
|
|
326
|
+
headers.set(SESSION_HEADER, SESSION_ID);
|
|
327
|
+
const client = new AwsClient({
|
|
328
|
+
...(await credentialProvider()),
|
|
329
|
+
service: 'bedrock-agentcore',
|
|
330
|
+
region,
|
|
331
|
+
});
|
|
332
|
+
return client.fetch(input, { ...init, headers });
|
|
333
|
+
};
|
|
334
|
+
};
|
|
335
|
+
"
|
|
336
|
+
`;
|
|
337
|
+
|
|
338
|
+
exports[`ts#agent generator > chat scripts for ag-ui protocol > should match snapshot for chat scripts with iam auth > chat.ts (ag-ui, iam) 1`] = `
|
|
339
|
+
"// Chat CLI for TestProjectAgent (AG-UI protocol). Connects to the local
|
|
340
|
+
// \`serve-local\` server, or the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set.
|
|
341
|
+
import { AGUIChatAdapter, chatLoop } from 'agent-chat-cli';
|
|
342
|
+
import { createAgentCoreFetch, resolveRemoteAgent } from './agentcore.js';
|
|
343
|
+
|
|
344
|
+
const remote = await resolveRemoteAgent();
|
|
345
|
+
|
|
346
|
+
const url = remote
|
|
347
|
+
? \`https://bedrock-agentcore.\${remote.region}.amazonaws.com/runtimes/\${encodeURIComponent(remote.arn)}/invocations?qualifier=DEFAULT\`
|
|
348
|
+
: process.env.URL!;
|
|
349
|
+
|
|
350
|
+
// Remote requests are authenticated via a custom fetch; locally the default agent talks plain HTTP.
|
|
351
|
+
const fetchImpl = remote ? createAgentCoreFetch(remote.region) : undefined;
|
|
352
|
+
|
|
353
|
+
await chatLoop(new AGUIChatAdapter({ fetch: fetchImpl }), url);
|
|
354
|
+
"
|
|
355
|
+
`;
|
|
356
|
+
|
|
357
|
+
exports[`ts#agent generator > chat scripts for http protocol > should match snapshot for chat scripts with cognito auth > agentcore.ts (http, cognito) 1`] = `
|
|
358
|
+
"// Resolves the deployed TestProjectAgent agent from runtime config and authenticates requests to it.
|
|
359
|
+
import { randomUUID } from 'node:crypto';
|
|
360
|
+
import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
|
|
361
|
+
|
|
362
|
+
const SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
|
|
363
|
+
|
|
364
|
+
// AgentCore session ids must be at least 33 characters.
|
|
365
|
+
export const SESSION_ID = randomUUID().replaceAll('-', '').padEnd(33, '0');
|
|
366
|
+
|
|
367
|
+
export interface RemoteAgent {
|
|
368
|
+
/** ARN of the deployed Bedrock AgentCore runtime. */
|
|
369
|
+
arn: string;
|
|
370
|
+
/** AWS region parsed from the runtime ARN. */
|
|
371
|
+
region: string;
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
// Returns the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set, otherwise \`undefined\` to chat locally.
|
|
375
|
+
export const resolveRemoteAgent = async (): Promise<
|
|
376
|
+
RemoteAgent | undefined
|
|
377
|
+
> => {
|
|
378
|
+
const application = process.env.RUNTIME_CONFIG_APP_ID;
|
|
379
|
+
if (!application) {
|
|
380
|
+
return undefined;
|
|
381
|
+
}
|
|
382
|
+
const config = (await getAppConfig('agentcore', {
|
|
383
|
+
application,
|
|
384
|
+
environment: 'default',
|
|
385
|
+
transform: 'json',
|
|
386
|
+
})) as { agentRuntimes?: Record<string, string> };
|
|
387
|
+
const arn = config?.agentRuntimes?.['TestProjectAgent'];
|
|
388
|
+
if (!arn) {
|
|
389
|
+
throw new Error(
|
|
390
|
+
\`No deployed agent named 'TestProjectAgent' found in runtime configuration (application \${application}).\`,
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
return { arn, region: arn.split(':')[3] };
|
|
394
|
+
};
|
|
395
|
+
|
|
396
|
+
/** The Cognito access token used to authenticate with the deployed agent. */
|
|
397
|
+
export const getAccessToken = (): string => {
|
|
398
|
+
const accessToken = process.env.AGENT_ACCESS_TOKEN;
|
|
399
|
+
if (!accessToken) {
|
|
400
|
+
throw new Error(
|
|
401
|
+
'AGENT_ACCESS_TOKEN is not set. Provide a Cognito access token to chat with the deployed agent.',
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
return accessToken;
|
|
405
|
+
};
|
|
406
|
+
|
|
407
|
+
// A \`fetch\` that authenticates requests to the deployed agent and forwards the session id.
|
|
408
|
+
export const createAgentCoreFetch = (): typeof fetch => {
|
|
409
|
+
const accessToken = getAccessToken();
|
|
410
|
+
return (input, init) => {
|
|
411
|
+
const headers = new Headers(init?.headers);
|
|
412
|
+
headers.set(SESSION_HEADER, SESSION_ID);
|
|
413
|
+
headers.set('Authorization', \`Bearer \${accessToken}\`);
|
|
414
|
+
return fetch(input, { ...init, headers });
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
"
|
|
418
|
+
`;
|
|
419
|
+
|
|
420
|
+
exports[`ts#agent generator > chat scripts for http protocol > should match snapshot for chat scripts with cognito auth > chat.ts (http, cognito) 1`] = `
|
|
421
|
+
"// Chat CLI for TestProjectAgent (HTTP / tRPC WebSocket). Connects to the local
|
|
422
|
+
// \`serve-local\` server, or the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set.
|
|
423
|
+
import { chatLoop, type ChatAdapter } from 'agent-chat-cli';
|
|
424
|
+
import { TestProjectAgentClient } from '../../src/agent/client.js';
|
|
425
|
+
import { resolveRemoteAgent, SESSION_ID, getAccessToken } from './agentcore.js';
|
|
426
|
+
|
|
427
|
+
const remote = await resolveRemoteAgent();
|
|
428
|
+
|
|
429
|
+
class TrpcWebSocketAdapter implements ChatAdapter {
|
|
430
|
+
private client!: ReturnType<typeof TestProjectAgentClient.local>;
|
|
431
|
+
|
|
432
|
+
async connect(url: string) {
|
|
433
|
+
this.client = remote
|
|
434
|
+
? TestProjectAgentClient.withJwtAuth({
|
|
435
|
+
agentRuntimeArn: remote.arn,
|
|
436
|
+
sessionId: SESSION_ID,
|
|
437
|
+
accessTokenProvider: async () => getAccessToken(),
|
|
438
|
+
})
|
|
439
|
+
: TestProjectAgentClient.local({ url, sessionId: SESSION_ID });
|
|
440
|
+
return { agentName: 'TestProjectAgent' };
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async *sendMessage(text: string): AsyncIterable<string> {
|
|
444
|
+
const stream = new ReadableStream<string>({
|
|
445
|
+
start: (controller) => {
|
|
446
|
+
this.client.invoke.subscribe(
|
|
447
|
+
{ message: text },
|
|
448
|
+
{
|
|
449
|
+
onData: (chunk: string) => controller.enqueue(chunk),
|
|
450
|
+
onComplete: () => controller.close(),
|
|
451
|
+
onError: (err: unknown) => controller.error(err),
|
|
452
|
+
},
|
|
453
|
+
);
|
|
454
|
+
},
|
|
455
|
+
});
|
|
456
|
+
|
|
457
|
+
yield* stream as unknown as AsyncIterable<string>;
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
await chatLoop(new TrpcWebSocketAdapter(), process.env.URL ?? '');
|
|
462
|
+
"
|
|
463
|
+
`;
|
|
464
|
+
|
|
465
|
+
exports[`ts#agent generator > chat scripts for http protocol > should match snapshot for chat scripts with iam auth > agentcore.ts (http, iam) 1`] = `
|
|
466
|
+
"// Resolves the deployed TestProjectAgent agent from runtime config and authenticates requests to it.
|
|
467
|
+
import { randomUUID } from 'node:crypto';
|
|
468
|
+
import { getAppConfig } from '@aws-lambda-powertools/parameters/appconfig';
|
|
469
|
+
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';
|
|
470
|
+
import { AwsClient } from 'aws4fetch';
|
|
471
|
+
|
|
472
|
+
const SESSION_HEADER = 'X-Amzn-Bedrock-AgentCore-Runtime-Session-Id';
|
|
473
|
+
|
|
474
|
+
// AgentCore session ids must be at least 33 characters.
|
|
475
|
+
export const SESSION_ID = randomUUID().replaceAll('-', '').padEnd(33, '0');
|
|
476
|
+
|
|
477
|
+
export interface RemoteAgent {
|
|
478
|
+
/** ARN of the deployed Bedrock AgentCore runtime. */
|
|
479
|
+
arn: string;
|
|
480
|
+
/** AWS region parsed from the runtime ARN. */
|
|
481
|
+
region: string;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
// Returns the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set, otherwise \`undefined\` to chat locally.
|
|
485
|
+
export const resolveRemoteAgent = async (): Promise<
|
|
486
|
+
RemoteAgent | undefined
|
|
487
|
+
> => {
|
|
488
|
+
const application = process.env.RUNTIME_CONFIG_APP_ID;
|
|
489
|
+
if (!application) {
|
|
490
|
+
return undefined;
|
|
491
|
+
}
|
|
492
|
+
const config = (await getAppConfig('agentcore', {
|
|
493
|
+
application,
|
|
494
|
+
environment: 'default',
|
|
495
|
+
transform: 'json',
|
|
496
|
+
})) as { agentRuntimes?: Record<string, string> };
|
|
497
|
+
const arn = config?.agentRuntimes?.['TestProjectAgent'];
|
|
498
|
+
if (!arn) {
|
|
499
|
+
throw new Error(
|
|
500
|
+
\`No deployed agent named 'TestProjectAgent' found in runtime configuration (application \${application}).\`,
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
return { arn, region: arn.split(':')[3] };
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
// A \`fetch\` that authenticates requests to the deployed agent and forwards the session id.
|
|
507
|
+
export const createAgentCoreFetch = (region: string): typeof fetch => {
|
|
508
|
+
const credentialProvider = fromNodeProviderChain();
|
|
509
|
+
return async (input, init) => {
|
|
510
|
+
const headers = new Headers(init?.headers);
|
|
511
|
+
headers.set(SESSION_HEADER, SESSION_ID);
|
|
512
|
+
const client = new AwsClient({
|
|
513
|
+
...(await credentialProvider()),
|
|
514
|
+
service: 'bedrock-agentcore',
|
|
515
|
+
region,
|
|
516
|
+
});
|
|
517
|
+
return client.fetch(input, { ...init, headers });
|
|
518
|
+
};
|
|
519
|
+
};
|
|
520
|
+
"
|
|
521
|
+
`;
|
|
522
|
+
|
|
523
|
+
exports[`ts#agent generator > chat scripts for http protocol > should match snapshot for chat scripts with iam auth > chat.ts (http, iam) 1`] = `
|
|
524
|
+
"// Chat CLI for TestProjectAgent (HTTP / tRPC WebSocket). Connects to the local
|
|
525
|
+
// \`serve-local\` server, or the deployed agent when \`RUNTIME_CONFIG_APP_ID\` is set.
|
|
526
|
+
import { chatLoop, type ChatAdapter } from 'agent-chat-cli';
|
|
527
|
+
import { TestProjectAgentClient } from '../../src/agent/client.js';
|
|
528
|
+
import { resolveRemoteAgent, SESSION_ID } from './agentcore.js';
|
|
529
|
+
|
|
530
|
+
const remote = await resolveRemoteAgent();
|
|
531
|
+
|
|
532
|
+
class TrpcWebSocketAdapter implements ChatAdapter {
|
|
533
|
+
private client!: ReturnType<typeof TestProjectAgentClient.local>;
|
|
534
|
+
|
|
535
|
+
async connect(url: string) {
|
|
536
|
+
this.client = remote
|
|
537
|
+
? TestProjectAgentClient.withIamAuth({
|
|
538
|
+
agentRuntimeArn: remote.arn,
|
|
539
|
+
sessionId: SESSION_ID,
|
|
540
|
+
})
|
|
541
|
+
: TestProjectAgentClient.local({ url, sessionId: SESSION_ID });
|
|
542
|
+
return { agentName: 'TestProjectAgent' };
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
async *sendMessage(text: string): AsyncIterable<string> {
|
|
546
|
+
const stream = new ReadableStream<string>({
|
|
547
|
+
start: (controller) => {
|
|
548
|
+
this.client.invoke.subscribe(
|
|
549
|
+
{ message: text },
|
|
550
|
+
{
|
|
551
|
+
onData: (chunk: string) => controller.enqueue(chunk),
|
|
552
|
+
onComplete: () => controller.close(),
|
|
553
|
+
onError: (err: unknown) => controller.error(err),
|
|
554
|
+
},
|
|
555
|
+
);
|
|
556
|
+
},
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
yield* stream as unknown as AsyncIterable<string>;
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
await chatLoop(new TrpcWebSocketAdapter(), process.env.URL ?? '');
|
|
564
|
+
"
|
|
565
|
+
`;
|
|
566
|
+
|
|
3
567
|
exports[`ts#agent generator > should match snapshot for BedrockAgentCoreRuntime generated constructs files > agent-Dockerfile 1`] = `
|
|
4
568
|
"FROM public.ecr.aws/docker/library/node:lts-jod
|
|
5
569
|
|
|
@@ -354,8 +918,7 @@ resource "aws_ecr_repository" "agent_core_repository" {
|
|
|
354
918
|
#checkov:skip=CKV_AWS_136:AES256 encryption is sufficient for ECR repositories
|
|
355
919
|
name = "\${lower(var.agent_runtime_name)}_repository_\${random_id.unique_suffix.hex}"
|
|
356
920
|
|
|
357
|
-
|
|
358
|
-
image_tag_mutability = "MUTABLE"
|
|
921
|
+
image_tag_mutability = "IMMUTABLE"
|
|
359
922
|
force_delete = true
|
|
360
923
|
|
|
361
924
|
image_scanning_configuration {
|
|
@@ -529,25 +1092,37 @@ data "external" "docker_digest" {
|
|
|
529
1092
|
program = ["sh", "-c", "echo '{\\"digest\\":\\"'$(docker inspect \${var.docker_image_tag} --format '{{.Id}}')'\\"}' "]
|
|
530
1093
|
}
|
|
531
1094
|
|
|
1095
|
+
locals {
|
|
1096
|
+
# Content-based, immutable image tag derived from the local image digest
|
|
1097
|
+
image_tag = replace(data.external.docker_digest.result.digest, "sha256:", "")
|
|
1098
|
+
}
|
|
1099
|
+
|
|
532
1100
|
# Null resource for container image publish
|
|
533
1101
|
resource "null_resource" "docker_publish" {
|
|
534
1102
|
triggers = {
|
|
535
1103
|
docker_digest = data.external.docker_digest.result.digest
|
|
536
1104
|
repository_url = aws_ecr_repository.agent_core_repository.repository_url
|
|
537
1105
|
docker_image_tag = var.docker_image_tag
|
|
1106
|
+
image_tag = local.image_tag
|
|
538
1107
|
}
|
|
539
1108
|
|
|
540
1109
|
provisioner "local-exec" {
|
|
541
1110
|
command = <<-EOT
|
|
542
1111
|
# Get ECR login token
|
|
543
|
-
aws ecr get-login-password --region
|
|
1112
|
+
aws ecr get-login-password --region "$AWS_REGION" | docker login --username AWS --password-stdin "$REPOSITORY_URL"
|
|
544
1113
|
|
|
545
|
-
# Tag the image
|
|
546
|
-
docker tag
|
|
1114
|
+
# Tag the image with the immutable content-based tag
|
|
1115
|
+
docker tag "$DOCKER_IMAGE_TAG" "$REPOSITORY_URL:$IMAGE_TAG"
|
|
547
1116
|
|
|
548
1117
|
# Push the image
|
|
549
|
-
docker push
|
|
1118
|
+
docker push "$REPOSITORY_URL:$IMAGE_TAG"
|
|
550
1119
|
EOT
|
|
1120
|
+
environment = {
|
|
1121
|
+
AWS_REGION = local.aws_region
|
|
1122
|
+
REPOSITORY_URL = self.triggers.repository_url
|
|
1123
|
+
DOCKER_IMAGE_TAG = self.triggers.docker_image_tag
|
|
1124
|
+
IMAGE_TAG = self.triggers.image_tag
|
|
1125
|
+
}
|
|
551
1126
|
}
|
|
552
1127
|
|
|
553
1128
|
depends_on = [aws_ecr_repository_policy.agent_core_ecr_policy]
|
|
@@ -561,7 +1136,7 @@ resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
|
|
|
561
1136
|
|
|
562
1137
|
agent_runtime_artifact {
|
|
563
1138
|
container_configuration {
|
|
564
|
-
container_uri = "\${aws_ecr_repository.agent_core_repository.repository_url}
|
|
1139
|
+
container_uri = "\${aws_ecr_repository.agent_core_repository.repository_url}:\${local.image_tag}"
|
|
565
1140
|
}
|
|
566
1141
|
}
|
|
567
1142
|
|
|
@@ -594,6 +1169,63 @@ resource "aws_bedrockagentcore_agent_runtime" "agent_runtime" {
|
|
|
594
1169
|
]
|
|
595
1170
|
}
|
|
596
1171
|
|
|
1172
|
+
# MCP consumers (e.g. gateway targets, which fetch tools at creation) can race
|
|
1173
|
+
# the runtime's first cold start, so probe it until it serves MCP. The ARN
|
|
1174
|
+
# output is routed through this resource so consumers wait for readiness.
|
|
1175
|
+
resource "null_resource" "runtime_ready" {
|
|
1176
|
+
count = var.server_protocol == "MCP" ? 1 : 0
|
|
1177
|
+
|
|
1178
|
+
triggers = {
|
|
1179
|
+
runtime_arn = aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_arn
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
provisioner "local-exec" {
|
|
1183
|
+
command = <<-EOT
|
|
1184
|
+
uv run --with boto3 python -c "
|
|
1185
|
+
import boto3
|
|
1186
|
+
import json
|
|
1187
|
+
import os
|
|
1188
|
+
import time
|
|
1189
|
+
import uuid
|
|
1190
|
+
|
|
1191
|
+
runtime_arn = os.environ['RUNTIME_ARN']
|
|
1192
|
+
client = boto3.client('bedrock-agentcore')
|
|
1193
|
+
initialize_request = json.dumps({
|
|
1194
|
+
'jsonrpc': '2.0',
|
|
1195
|
+
'id': 1,
|
|
1196
|
+
'method': 'initialize',
|
|
1197
|
+
'params': {
|
|
1198
|
+
'protocolVersion': '2025-03-26',
|
|
1199
|
+
'capabilities': {},
|
|
1200
|
+
'clientInfo': {'name': 'readiness-probe', 'version': '1.0'},
|
|
1201
|
+
},
|
|
1202
|
+
})
|
|
1203
|
+
|
|
1204
|
+
deadline = time.time() + 3 * 60
|
|
1205
|
+
while True:
|
|
1206
|
+
try:
|
|
1207
|
+
client.invoke_agent_runtime(
|
|
1208
|
+
agentRuntimeArn=runtime_arn,
|
|
1209
|
+
runtimeSessionId=f'readiness-probe-{uuid.uuid4()}',
|
|
1210
|
+
contentType='application/json',
|
|
1211
|
+
accept='application/json, text/event-stream',
|
|
1212
|
+
payload=initialize_request,
|
|
1213
|
+
)
|
|
1214
|
+
break
|
|
1215
|
+
except Exception:
|
|
1216
|
+
if time.time() >= deadline:
|
|
1217
|
+
raise
|
|
1218
|
+
time.sleep(5)
|
|
1219
|
+
|
|
1220
|
+
print(f'Runtime {runtime_arn} is serving MCP')
|
|
1221
|
+
"
|
|
1222
|
+
EOT
|
|
1223
|
+
environment = {
|
|
1224
|
+
RUNTIME_ARN = self.triggers.runtime_arn
|
|
1225
|
+
}
|
|
1226
|
+
}
|
|
1227
|
+
}
|
|
1228
|
+
|
|
597
1229
|
# Outputs
|
|
598
1230
|
output "agent_core_runtime_role_arn" {
|
|
599
1231
|
description = "ARN of the Agent Core Runtime IAM role"
|
|
@@ -611,8 +1243,8 @@ output "agent_runtime_name" {
|
|
|
611
1243
|
}
|
|
612
1244
|
|
|
613
1245
|
output "agent_core_runtime_arn" {
|
|
614
|
-
description = "ARN of the Bedrock Agent Core runtime"
|
|
615
|
-
value = aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_arn
|
|
1246
|
+
description = "ARN of the Bedrock Agent Core runtime. For MCP runtimes the value flows through the readiness probe, so consumers wait until the runtime serves MCP."
|
|
1247
|
+
value = var.server_protocol == "MCP" ? null_resource.runtime_ready[0].triggers.runtime_arn : aws_bedrockagentcore_agent_runtime.agent_runtime.agent_runtime_arn
|
|
616
1248
|
}
|
|
617
1249
|
|
|
618
1250
|
output "agent_runtime_id" {
|
|
@@ -629,6 +1261,7 @@ output "agent_runtime_version" {
|
|
|
629
1261
|
|
|
630
1262
|
exports[`ts#agent generator > should match snapshot for generated files > agent-agent.ts 1`] = `
|
|
631
1263
|
"import { Agent, tool } from '@strands-agents/sdk';
|
|
1264
|
+
import { logModelErrors } from ':proj/agent-connection';
|
|
632
1265
|
import { z } from 'zod';
|
|
633
1266
|
|
|
634
1267
|
const multiply = tool({
|
|
@@ -641,13 +1274,16 @@ const multiply = tool({
|
|
|
641
1274
|
callback: ({ a, b }) => a * b,
|
|
642
1275
|
});
|
|
643
1276
|
|
|
644
|
-
export const getAgent = async () =>
|
|
645
|
-
new Agent({
|
|
1277
|
+
export const getAgent = async () => {
|
|
1278
|
+
const agent = new Agent({
|
|
646
1279
|
systemPrompt: \`You are a mathematical wizard.
|
|
647
1280
|
Use your tools for mathematical tasks.
|
|
648
1281
|
Refer to tools as your 'spellbook'.\`,
|
|
649
1282
|
tools: [multiply],
|
|
650
1283
|
});
|
|
1284
|
+
logModelErrors(agent);
|
|
1285
|
+
return agent;
|
|
1286
|
+
};
|
|
651
1287
|
"
|
|
652
1288
|
`;
|
|
653
1289
|
|
|
@@ -728,7 +1364,8 @@ export interface AgentCoreTrpcClientOptions {
|
|
|
728
1364
|
sessionId?: string;
|
|
729
1365
|
}
|
|
730
1366
|
|
|
731
|
-
export interface AgentCoreTrpcClientIamOptions
|
|
1367
|
+
export interface AgentCoreTrpcClientIamOptions
|
|
1368
|
+
extends AgentCoreTrpcClientOptions {
|
|
732
1369
|
/**
|
|
733
1370
|
* Optional AWS credential provider. If not provided, uses the default
|
|
734
1371
|
* credential provider chain from the AWS SDK.
|
|
@@ -736,7 +1373,8 @@ export interface AgentCoreTrpcClientIamOptions extends AgentCoreTrpcClientOption
|
|
|
736
1373
|
credentialProvider?: ReturnType<typeof fromNodeProviderChain>;
|
|
737
1374
|
}
|
|
738
1375
|
|
|
739
|
-
export interface AgentCoreTrpcClientJwtOptions
|
|
1376
|
+
export interface AgentCoreTrpcClientJwtOptions
|
|
1377
|
+
extends AgentCoreTrpcClientOptions {
|
|
740
1378
|
/**
|
|
741
1379
|
* A function which returns the JWT access token used to authenticate
|
|
742
1380
|
*/
|
|
@@ -937,7 +1575,7 @@ const agent = withSessionId(getAgent);
|
|
|
937
1575
|
|
|
938
1576
|
export const appRouter = router({
|
|
939
1577
|
invoke: publicProcedure
|
|
940
|
-
.input(z.object({ message: z.string() }))
|
|
1578
|
+
.input(z.object({ message: z.string().max(100000) }))
|
|
941
1579
|
.output(
|
|
942
1580
|
zAsyncIterable({
|
|
943
1581
|
yield: z.string(),
|