@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
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Cedar policies for <%= nameClassName %>
|
|
2
|
+
|
|
3
|
+
Every `.cedar` file in this directory is deployed as a separate `Policy`
|
|
4
|
+
resource attached to this gateway's `PolicyEngine`. The engine runs in
|
|
5
|
+
`ENFORCE` mode, so policies are evaluated and decisions are enforced at
|
|
6
|
+
runtime.
|
|
7
|
+
|
|
8
|
+
## Default policy
|
|
9
|
+
|
|
10
|
+
`permit-all.cedar` permits any IAM caller from the deploying AWS account.
|
|
11
|
+
It is scoped to your account because AgentCore's policy validator rejects
|
|
12
|
+
truly unrestricted permits (`permit (principal, action, resource)`) as
|
|
13
|
+
"Overly Permissive".
|
|
14
|
+
|
|
15
|
+
**If you delete this file without adding replacement `permit` policies, the
|
|
16
|
+
gateway will deny every request** — Cedar uses a default-deny evaluation
|
|
17
|
+
model, so every request requires at least one matching `permit` to be
|
|
18
|
+
allowed.
|
|
19
|
+
|
|
20
|
+
## Template variables
|
|
21
|
+
|
|
22
|
+
Policies are [EJS](https://ejs.co/) templates rendered at synth/plan time
|
|
23
|
+
with the following variables in scope:
|
|
24
|
+
|
|
25
|
+
- `<%%= gatewayArn %>` — this gateway's ARN
|
|
26
|
+
- `<%%= accountId %>` — the AWS account this gateway is deployed into
|
|
27
|
+
|
|
28
|
+
Add your own variables (e.g. an agent's role name) where the policies are
|
|
29
|
+
rendered:
|
|
30
|
+
|
|
31
|
+
- CDK: the `cedarPolicyVariables` prop in
|
|
32
|
+
`packages/common/constructs/src/app/gateways/<name>/<name>.ts`
|
|
33
|
+
- Terraform: the `query` of the `rendered_policies` data source in
|
|
34
|
+
`packages/common/terraform/src/app/gateways/<name>/<name>.tf`
|
|
35
|
+
|
|
36
|
+
## Adding a new policy
|
|
37
|
+
|
|
38
|
+
1. Create `policies/<my-policy>.cedar` alongside the existing files.
|
|
39
|
+
2. Write Cedar rules — see the **Writing Policies** section of the
|
|
40
|
+
[AgentCore Gateway guide](https://awslabs.github.io/nx-plugin-for-aws/guides/agentcore-gateway/)
|
|
41
|
+
for valid patterns and validator gotchas.
|
|
42
|
+
3. Re-synth / plan your infrastructure to deploy the new policy.
|
|
43
|
+
|
|
44
|
+
Policy names are derived from file names: `my-policy.cedar` becomes the
|
|
45
|
+
policy `MyPolicy` (plus a unique suffix, since policy names must be unique
|
|
46
|
+
account-wide). Keep file names unique within this directory.
|
|
47
|
+
|
|
48
|
+
## Further reading
|
|
49
|
+
|
|
50
|
+
- [Cedar policy language reference](https://docs.cedarpolicy.com/)
|
|
51
|
+
- [AgentCore policy semantics](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/policy-understanding-cedar.html)
|
|
52
|
+
- [AgentCore common policy patterns](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/policy-common-patterns.html)
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Default policy: permit any IAM caller from the deploying AWS account.
|
|
2
|
+
// The PolicyEngine runs in ENFORCE mode (default-deny) — deleting this file
|
|
3
|
+
// without a replacement permit denies every call. See policies/README.md.
|
|
4
|
+
|
|
5
|
+
permit (
|
|
6
|
+
principal is AgentCore::IamEntity,
|
|
7
|
+
action,
|
|
8
|
+
resource == AgentCore::Gateway::"<%%= gatewayArn %>"
|
|
9
|
+
) when {
|
|
10
|
+
principal.id like "arn:aws:*::<%%= accountId %>:*"
|
|
11
|
+
};
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
|
|
2
|
+
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
|
|
3
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
+
import { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
5
|
+
import {
|
|
6
|
+
CallToolRequestSchema,
|
|
7
|
+
ListToolsRequestSchema,
|
|
8
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
9
|
+
import express from 'express';
|
|
10
|
+
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
11
|
+
|
|
12
|
+
const PORT = parseInt(process.env.PORT || '<%- port %>');
|
|
13
|
+
const PREFIX_SEPARATOR = '___';
|
|
14
|
+
const SESSION_HEADER = 'x-amzn-bedrock-agentcore-runtime-session-id';
|
|
15
|
+
|
|
16
|
+
interface AttachedMcpServer {
|
|
17
|
+
name: string;
|
|
18
|
+
url: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Upstream MCP endpoints attached to this gateway (MCP servers and other
|
|
22
|
+
// gateways), maintained by the `agentcore-gateway#mcp-connection` and
|
|
23
|
+
// `agentcore-gateway#gateway-connection` generators.
|
|
24
|
+
const ATTACHED_MCP_SERVERS: AttachedMcpServer[] = [<% attachedMcpServers.forEach((s) => { %>
|
|
25
|
+
{ name: '<%- s.name %>', url: 'http://localhost:<%- s.port %>/mcp' },<% }); %>
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
// Forwards the inbound request's AgentCore session header to upstream calls
|
|
29
|
+
const sessionContext = new AsyncLocalStorage<string | undefined>();
|
|
30
|
+
|
|
31
|
+
const createUpstreamClient = async (url: string): Promise<Client> => {
|
|
32
|
+
const fetchWithSession: typeof fetch = async (input, init) => {
|
|
33
|
+
const headers = new Headers(init?.headers);
|
|
34
|
+
const sessionId = sessionContext.getStore();
|
|
35
|
+
if (sessionId) headers.set(SESSION_HEADER, sessionId);
|
|
36
|
+
return fetch(input, { ...init, headers });
|
|
37
|
+
};
|
|
38
|
+
const client = new Client({ name: '<%- nameKebabCase %>', version: '1.0.0' });
|
|
39
|
+
await client.connect(
|
|
40
|
+
new StreamableHTTPClientTransport(new URL(url), {
|
|
41
|
+
fetch: fetchWithSession,
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
return client;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Local gateway for <%- nameClassName %>: a single MCP endpoint aggregating
|
|
49
|
+
* every attached MCP server, with tools exposed as `<target>___<tool>` to
|
|
50
|
+
* match the deployed AgentCore Gateway. Unlike the real gateway, Cedar
|
|
51
|
+
* policies are not evaluated and there is no semantic tool search.
|
|
52
|
+
*/
|
|
53
|
+
const createServer = async (): Promise<Server> => {
|
|
54
|
+
const server = new Server(
|
|
55
|
+
{ name: '<%- nameKebabCase %>', version: '1.0.0' },
|
|
56
|
+
{ capabilities: { tools: {} } },
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
60
|
+
const lists = await Promise.all(
|
|
61
|
+
ATTACHED_MCP_SERVERS.map(async (s) => {
|
|
62
|
+
const client = await createUpstreamClient(s.url);
|
|
63
|
+
try {
|
|
64
|
+
const { tools } = await client.listTools();
|
|
65
|
+
return tools.map((t) => ({
|
|
66
|
+
...t,
|
|
67
|
+
name: `${s.name}${PREFIX_SEPARATOR}${t.name}`,
|
|
68
|
+
}));
|
|
69
|
+
} finally {
|
|
70
|
+
await client.close();
|
|
71
|
+
}
|
|
72
|
+
}),
|
|
73
|
+
);
|
|
74
|
+
return { tools: lists.flat() };
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
78
|
+
const name = request.params.name;
|
|
79
|
+
const upstream = ATTACHED_MCP_SERVERS.find((s) =>
|
|
80
|
+
name.startsWith(`${s.name}${PREFIX_SEPARATOR}`),
|
|
81
|
+
);
|
|
82
|
+
if (!upstream) {
|
|
83
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
84
|
+
}
|
|
85
|
+
const client = await createUpstreamClient(upstream.url);
|
|
86
|
+
try {
|
|
87
|
+
return await client.callTool({
|
|
88
|
+
...request.params,
|
|
89
|
+
name: name.slice(upstream.name.length + PREFIX_SEPARATOR.length),
|
|
90
|
+
});
|
|
91
|
+
} finally {
|
|
92
|
+
await client.close();
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return server;
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const app = express();
|
|
100
|
+
app.use(express.json());
|
|
101
|
+
|
|
102
|
+
app.post('/mcp', async (req, res) => {
|
|
103
|
+
const sessionId = req.headers[SESSION_HEADER];
|
|
104
|
+
await sessionContext.run(
|
|
105
|
+
typeof sessionId === 'string' ? sessionId : undefined,
|
|
106
|
+
async () => {
|
|
107
|
+
try {
|
|
108
|
+
const server = await createServer();
|
|
109
|
+
const transport = new StreamableHTTPServerTransport({
|
|
110
|
+
sessionIdGenerator: undefined,
|
|
111
|
+
});
|
|
112
|
+
res.on('close', () => {
|
|
113
|
+
transport.close();
|
|
114
|
+
server.close();
|
|
115
|
+
});
|
|
116
|
+
await server.connect(transport);
|
|
117
|
+
await transport.handleRequest(req, res, req.body);
|
|
118
|
+
} catch (error) {
|
|
119
|
+
console.error('Error handling MCP request:', error);
|
|
120
|
+
if (!res.headersSent) {
|
|
121
|
+
res.status(500).json({
|
|
122
|
+
jsonrpc: '2.0',
|
|
123
|
+
error: { code: -32603, message: 'Internal server error' },
|
|
124
|
+
id: null,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
app.listen(PORT, () => {
|
|
133
|
+
console.log(`<%- nameKebabCase %>: local gateway listening on port ${PORT}`);
|
|
134
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
|
+
import type { AgentcoreGatewayGatewayConnectionGeneratorSchema } from './schema';
|
|
8
|
+
export declare const AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
/**
|
|
10
|
+
* Connect an AgentCore Gateway to another AgentCore Gateway.
|
|
11
|
+
*
|
|
12
|
+
* Chains the source gateway's serve-local target to the target gateway's
|
|
13
|
+
* serve-local target, and registers the target gateway in the source
|
|
14
|
+
* gateway's local serve-local.ts so the local gateway aggregates its tools
|
|
15
|
+
* (already prefixed by the target gateway) under
|
|
16
|
+
* `<targetGateway>___<targetName>___<toolName>`. Users must still call
|
|
17
|
+
* `gateway.addGateway(...)` in their application stack to create the
|
|
18
|
+
* actual CDK/Terraform resource.
|
|
19
|
+
*/
|
|
20
|
+
export declare const agentcoreGatewayGatewayConnectionGenerator: (tree: Tree, options: AgentcoreGatewayGatewayConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
21
|
+
export default agentcoreGatewayGatewayConnectionGenerator;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentcoreGatewayGatewayConnectionGenerator = exports.AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const format_1 = require("../../utils/format");
|
|
10
|
+
const metrics_1 = require("../../utils/metrics");
|
|
11
|
+
const names_1 = require("../../utils/names");
|
|
12
|
+
const nx_1 = require("../../utils/nx");
|
|
13
|
+
const attach_upstream_1 = require("../attach-upstream");
|
|
14
|
+
const generator_1 = require("../generator");
|
|
15
|
+
exports.AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
16
|
+
/**
|
|
17
|
+
* Connect an AgentCore Gateway to another AgentCore Gateway.
|
|
18
|
+
*
|
|
19
|
+
* Chains the source gateway's serve-local target to the target gateway's
|
|
20
|
+
* serve-local target, and registers the target gateway in the source
|
|
21
|
+
* gateway's local serve-local.ts so the local gateway aggregates its tools
|
|
22
|
+
* (already prefixed by the target gateway) under
|
|
23
|
+
* `<targetGateway>___<targetName>___<toolName>`. Users must still call
|
|
24
|
+
* `gateway.addGateway(...)` in their application stack to create the
|
|
25
|
+
* actual CDK/Terraform resource.
|
|
26
|
+
*/
|
|
27
|
+
const agentcoreGatewayGatewayConnectionGenerator = async (tree, options) => {
|
|
28
|
+
const sourceProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.sourceProject);
|
|
29
|
+
const targetProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.targetProject);
|
|
30
|
+
const sourceGateway = (0, generator_1.readAgentCoreGatewayMetadata)(sourceProject);
|
|
31
|
+
const targetGateway = (0, generator_1.readAgentCoreGatewayMetadata)(targetProject);
|
|
32
|
+
if (sourceProject.name === targetProject.name) {
|
|
33
|
+
throw new Error(`Cannot connect gateway '${sourceGateway.name}' to itself.`);
|
|
34
|
+
}
|
|
35
|
+
for (const gateway of [sourceGateway, targetGateway]) {
|
|
36
|
+
if (gateway.protocol !== 'mcp') {
|
|
37
|
+
throw new Error(`Gateway '${gateway.name}' has protocol='${gateway.protocol}'. Gateway->Gateway connections are only supported between MCP-protocol gateways.`);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// The source gateway invokes the target signing with its own IAM role, so
|
|
41
|
+
// only the target's inbound auth must be IAM. The source's inbound auth (how
|
|
42
|
+
// its own callers reach it) is irrelevant to this hop.
|
|
43
|
+
if (targetGateway.auth !== 'iam') {
|
|
44
|
+
throw new Error(`Gateway '${targetGateway.name}' uses auth='${targetGateway.auth}'. Gateway->Gateway connections currently require the target gateway to use IAM authentication.`);
|
|
45
|
+
}
|
|
46
|
+
assertNoCycle(tree, sourceProject.name, targetProject.name);
|
|
47
|
+
const sourceServeLocalTargetName = `${(0, names_1.kebabCase)(sourceGateway.rc)}-serve-local`;
|
|
48
|
+
// The target name must match the deployed Gateway target (`gatewayName` on
|
|
49
|
+
// the gateway construct, the project's class name in kebab-case) so
|
|
50
|
+
// `<targetGateway>___<target>___<tool>` resolves identically locally and
|
|
51
|
+
// deployed.
|
|
52
|
+
const targetGatewayKebabCase = (0, names_1.kebabCase)(targetGateway.rc);
|
|
53
|
+
await (0, attach_upstream_1.attachUpstreamToLocalGateway)(tree, sourceProject, sourceServeLocalTargetName, {
|
|
54
|
+
targetName: targetGatewayKebabCase,
|
|
55
|
+
port: targetGateway.port,
|
|
56
|
+
upstreamProjectName: targetProject.name,
|
|
57
|
+
upstreamServeLocalTargetName: `${targetGatewayKebabCase}-serve-local`,
|
|
58
|
+
});
|
|
59
|
+
await (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
60
|
+
exports.AGENTCORE_GATEWAY_GATEWAY_CONNECTION_GENERATOR_INFO,
|
|
61
|
+
]);
|
|
62
|
+
await (0, format_1.formatFilesInSubtree)(tree);
|
|
63
|
+
return () => {
|
|
64
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
exports.agentcoreGatewayGatewayConnectionGenerator = agentcoreGatewayGatewayConnectionGenerator;
|
|
68
|
+
/**
|
|
69
|
+
* Reject connections that would make the local gateway graph cyclic — a
|
|
70
|
+
* cycle would recurse infinitely on tools/list both locally and deployed.
|
|
71
|
+
*
|
|
72
|
+
* Walks gateway serve-local dependsOn edges from the target gateway; the
|
|
73
|
+
* source gateway must not be reachable.
|
|
74
|
+
*/
|
|
75
|
+
const assertNoCycle = (tree, sourceProjectName, targetProjectName) => {
|
|
76
|
+
const visited = new Set();
|
|
77
|
+
const stack = [targetProjectName];
|
|
78
|
+
while (stack.length > 0) {
|
|
79
|
+
const current = stack.pop();
|
|
80
|
+
if (current === sourceProjectName) {
|
|
81
|
+
throw new Error(`Connecting '${sourceProjectName}' to '${targetProjectName}' would create a cycle: '${targetProjectName}' already routes to '${sourceProjectName}'.`);
|
|
82
|
+
}
|
|
83
|
+
if (visited.has(current)) {
|
|
84
|
+
continue;
|
|
85
|
+
}
|
|
86
|
+
visited.add(current);
|
|
87
|
+
const project = (0, nx_1.readProjectConfigurationUnqualified)(tree, current);
|
|
88
|
+
if (project.metadata?.generator !==
|
|
89
|
+
generator_1.AGENTCORE_GATEWAY_GENERATOR_INFO.id) {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
const gateway = (0, generator_1.readAgentCoreGatewayMetadata)(project);
|
|
93
|
+
const serveLocal = project.targets?.[`${(0, names_1.kebabCase)(gateway.rc)}-serve-local`];
|
|
94
|
+
for (const dep of serveLocal?.dependsOn ?? []) {
|
|
95
|
+
if (typeof dep !== 'string') {
|
|
96
|
+
stack.push(...(dep.projects ?? []));
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.default = exports.agentcoreGatewayGatewayConnectionGenerator;
|
|
102
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/agentcore-gateway/gateway-connection/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAIoB;AACpB,+CAA0D;AAC1D,iDAAsE;AACtE,6CAA8C;AAC9C,uCAIwB;AACxB,wDAAkE;AAClE,4CAGsB;AAGT,QAAA,mDAAmD,GAC9D,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B;;;;;;;;;;GAUG;AACI,MAAM,0CAA0C,GAAG,KAAK,EAC7D,IAAU,EACV,OAAyD,EAC7B,EAAE;IAC9B,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IAEF,MAAM,aAAa,GAAG,IAAA,wCAA4B,EAAC,aAAa,CAAC,CAAC;IAClE,MAAM,aAAa,GAAG,IAAA,wCAA4B,EAAC,aAAa,CAAC,CAAC;IAElE,IAAI,aAAa,CAAC,IAAI,KAAK,aAAa,CAAC,IAAI,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,2BAA2B,aAAa,CAAC,IAAI,cAAc,CAC5D,CAAC;IACJ,CAAC;IAED,KAAK,MAAM,OAAO,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,EAAE,CAAC;QACrD,IAAI,OAAO,CAAC,QAAQ,KAAK,KAAK,EAAE,CAAC;YAC/B,MAAM,IAAI,KAAK,CACb,YAAY,OAAO,CAAC,IAAI,mBAAmB,OAAO,CAAC,QAAQ,mFAAmF,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Metadata } from '../../utils/nx';
|
|
6
|
+
|
|
7
|
+
export interface AgentcoreGatewayGatewayConnectionGeneratorSchema {
|
|
8
|
+
sourceProject: string;
|
|
9
|
+
targetProject: string;
|
|
10
|
+
sourceComponent?: ComponentMetadata;
|
|
11
|
+
targetComponent?: ComponentMetadata;
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "agentcore-gateway#gateway-connection",
|
|
4
|
+
"title": "agentcore-gateway#gateway-connection",
|
|
5
|
+
"description": "Connect an AgentCore Gateway to another AgentCore Gateway",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"sourceProject": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The gateway project to add the target gateway to"
|
|
11
|
+
},
|
|
12
|
+
"targetProject": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The gateway project to register as a target"
|
|
15
|
+
},
|
|
16
|
+
"sourceComponent": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The gateway component in the source project"
|
|
19
|
+
},
|
|
20
|
+
"targetComponent": {
|
|
21
|
+
"type": "string",
|
|
22
|
+
"description": "The gateway component in the target project"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": ["sourceProject", "targetProject"]
|
|
26
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type GeneratorCallback, type ProjectConfiguration, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type NxGeneratorInfo } from '../utils/nx';
|
|
7
|
+
import type { AgentcoreGatewayGeneratorSchema } from './schema';
|
|
8
|
+
export declare const AGENTCORE_GATEWAY_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
export declare const agentcoreGatewayGenerator: (tree: Tree, options: AgentcoreGatewayGeneratorSchema) => Promise<GeneratorCallback>;
|
|
10
|
+
/**
|
|
11
|
+
* Gateway details stored in the gateway project's metadata.
|
|
12
|
+
*/
|
|
13
|
+
export interface AgentCoreGatewayMetadata {
|
|
14
|
+
name: string;
|
|
15
|
+
rc: string;
|
|
16
|
+
protocol: string;
|
|
17
|
+
auth: string;
|
|
18
|
+
port: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Read a gateway project's metadata, validating it was generated by the
|
|
22
|
+
* agentcore-gateway generator.
|
|
23
|
+
*/
|
|
24
|
+
export declare const readAgentCoreGatewayMetadata: (project: ProjectConfiguration) => AgentCoreGatewayMetadata;
|
|
25
|
+
export default agentcoreGatewayGenerator;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readAgentCoreGatewayMetadata = exports.agentcoreGatewayGenerator = exports.AGENTCORE_GATEWAY_GENERATOR_INFO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const agent_core_constructs_1 = require("../utils/agent-core-constructs/agent-core-constructs");
|
|
10
|
+
const format_1 = require("../utils/format");
|
|
11
|
+
const iac_1 = require("../utils/iac");
|
|
12
|
+
const metrics_1 = require("../utils/metrics");
|
|
13
|
+
const names_1 = require("../utils/names");
|
|
14
|
+
const npm_scope_1 = require("../utils/npm-scope");
|
|
15
|
+
const nx_1 = require("../utils/nx");
|
|
16
|
+
const port_1 = require("../utils/port");
|
|
17
|
+
const shared_constructs_1 = require("../utils/shared-constructs");
|
|
18
|
+
const versions_1 = require("../utils/versions");
|
|
19
|
+
exports.AGENTCORE_GATEWAY_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
20
|
+
const agentcoreGatewayGenerator = async (tree, options) => {
|
|
21
|
+
const name = (0, names_1.kebabCase)(options.name);
|
|
22
|
+
const nameClassName = (0, names_1.toClassName)(name);
|
|
23
|
+
const parentDir = options.directory ?? 'packages';
|
|
24
|
+
const subDir = options.subDirectory ?? name;
|
|
25
|
+
const projectRoot = (0, devkit_1.joinPathFragments)(parentDir, subDir);
|
|
26
|
+
const fullyQualifiedName = `${(0, npm_scope_1.getNpmScopePrefix)(tree)}${name}`;
|
|
27
|
+
// Protocol / auth are fixed to mcp / iam in v1 — the enums accept only
|
|
28
|
+
// these values, but we still persist the resolved value in metadata so
|
|
29
|
+
// that connection generators can read it uniformly (and future additions
|
|
30
|
+
// are non-breaking).
|
|
31
|
+
const protocol = options.protocol ?? 'mcp';
|
|
32
|
+
const auth = options.auth ?? 'iam';
|
|
33
|
+
const cedarPolicy = options.cedarPolicy ?? true;
|
|
34
|
+
const infra = options.infra ?? 'agentcore';
|
|
35
|
+
// serve-local.ts is the local gateway: a continuous MCP aggregator chaining
|
|
36
|
+
// onto attached MCP servers' serve-local targets (added by the
|
|
37
|
+
// mcp-connection generator), so a single `nx run <agent>:<agent>-serve-local`
|
|
38
|
+
// boots the gateway and every attached MCP server together.
|
|
39
|
+
//
|
|
40
|
+
// `serve` exists for parity with other generators; the deployed Gateway is
|
|
41
|
+
// a managed AWS resource, so `serve`-mode agents talk to it via runtime
|
|
42
|
+
// config and the local gateway sits idle.
|
|
43
|
+
const localGatewayTarget = (port) => ({
|
|
44
|
+
executor: 'nx:run-commands',
|
|
45
|
+
continuous: true,
|
|
46
|
+
options: {
|
|
47
|
+
command: 'tsx serve-local.ts',
|
|
48
|
+
cwd: '{projectRoot}',
|
|
49
|
+
env: { PORT: `${port}` },
|
|
50
|
+
},
|
|
51
|
+
dependsOn: [],
|
|
52
|
+
});
|
|
53
|
+
let project;
|
|
54
|
+
if ((0, nx_1.projectExists)(tree, fullyQualifiedName)) {
|
|
55
|
+
project = (0, nx_1.readProjectConfigurationUnqualified)(tree, fullyQualifiedName);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
(0, devkit_1.addProjectConfiguration)(tree, fullyQualifiedName, {
|
|
59
|
+
name: fullyQualifiedName,
|
|
60
|
+
root: projectRoot,
|
|
61
|
+
projectType: 'library',
|
|
62
|
+
sourceRoot: projectRoot,
|
|
63
|
+
tags: [],
|
|
64
|
+
targets: {},
|
|
65
|
+
metadata: {
|
|
66
|
+
generator: exports.AGENTCORE_GATEWAY_GENERATOR_INFO.id,
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
project = (0, nx_1.readProjectConfigurationUnqualified)(tree, fullyQualifiedName);
|
|
70
|
+
}
|
|
71
|
+
const port = (0, port_1.assignPort)(tree, project, 8100);
|
|
72
|
+
// Re-run: keep existing targets (their dependsOn may have been populated
|
|
73
|
+
// by the mcp-connection generator), just ensure both exist.
|
|
74
|
+
project.targets ??= {};
|
|
75
|
+
project.targets[`${name}-serve`] ??= localGatewayTarget(port);
|
|
76
|
+
project.targets[`${name}-serve-local`] ??= localGatewayTarget(port);
|
|
77
|
+
(0, devkit_1.updateProjectConfiguration)(tree, project.name, project);
|
|
78
|
+
// Scaffold the gateway project: serve-local.ts (+ Cedar policies if requested)
|
|
79
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'project'), projectRoot, { nameClassName, nameKebabCase: name, port, attachedMcpServers: [] }, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
80
|
+
if (cedarPolicy) {
|
|
81
|
+
(0, devkit_1.generateFiles)(tree, (0, devkit_1.joinPathFragments)(__dirname, 'files', 'cedar'), projectRoot, { nameClassName }, { overwriteStrategy: devkit_1.OverwriteStrategy.KeepExisting });
|
|
82
|
+
}
|
|
83
|
+
(0, nx_1.addGeneratorMetadata)(tree, fullyQualifiedName, exports.AGENTCORE_GATEWAY_GENERATOR_INFO, {
|
|
84
|
+
name,
|
|
85
|
+
rc: nameClassName,
|
|
86
|
+
protocol,
|
|
87
|
+
auth,
|
|
88
|
+
port,
|
|
89
|
+
});
|
|
90
|
+
// serve-local.ts dependencies (+ ejs for Cedar policy rendering in the
|
|
91
|
+
// shared gateway construct)
|
|
92
|
+
(0, devkit_1.addDependenciesToPackageJson)(tree, (0, versions_1.withVersions)(['@modelcontextprotocol/sdk', 'express']), (0, versions_1.withVersions)(['tsx', '@types/express', 'ejs', '@types/ejs']));
|
|
93
|
+
// Wire up infra (CDK or Terraform); re-running with infra=agentcore adds
|
|
94
|
+
// the infrastructure to a previously infra-less gateway.
|
|
95
|
+
if (infra === 'agentcore') {
|
|
96
|
+
const iac = await (0, iac_1.resolveIac)(tree, options.iac);
|
|
97
|
+
await (0, shared_constructs_1.sharedConstructsGenerator)(tree, { iac });
|
|
98
|
+
await (0, agent_core_constructs_1.addAgentCoreGatewayInfra)(tree, {
|
|
99
|
+
gatewayNameClassName: nameClassName,
|
|
100
|
+
gatewayNameKebabCase: name,
|
|
101
|
+
projectName: fullyQualifiedName,
|
|
102
|
+
projectDirectory: projectRoot,
|
|
103
|
+
cedarPolicy,
|
|
104
|
+
iac,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
await (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
108
|
+
exports.AGENTCORE_GATEWAY_GENERATOR_INFO,
|
|
109
|
+
]);
|
|
110
|
+
await (0, format_1.formatFilesInSubtree)(tree);
|
|
111
|
+
return () => {
|
|
112
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.agentcoreGatewayGenerator = agentcoreGatewayGenerator;
|
|
116
|
+
/**
|
|
117
|
+
* Read a gateway project's metadata, validating it was generated by the
|
|
118
|
+
* agentcore-gateway generator.
|
|
119
|
+
*/
|
|
120
|
+
const readAgentCoreGatewayMetadata = (project) => {
|
|
121
|
+
const metadata = project.metadata;
|
|
122
|
+
if (metadata?.generator !== exports.AGENTCORE_GATEWAY_GENERATOR_INFO.id) {
|
|
123
|
+
throw new Error(`Project '${project.name}' was not generated by the '${exports.AGENTCORE_GATEWAY_GENERATOR_INFO.id}' generator.`);
|
|
124
|
+
}
|
|
125
|
+
return metadata;
|
|
126
|
+
};
|
|
127
|
+
exports.readAgentCoreGatewayMetadata = readAgentCoreGatewayMetadata;
|
|
128
|
+
exports.default = exports.agentcoreGatewayGenerator;
|
|
129
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../packages/nx-plugin/src/agentcore-gateway/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAWoB;AACpB,gGAAgG;AAChG,4CAAuD;AACvD,sCAA0C;AAC1C,8CAAmE;AACnE,0CAAwD;AACxD,kDAAuD;AACvD,oCAMqB;AACrB,wCAA2C;AAC3C,kEAAuE;AACvE,gDAAiD;AAGpC,QAAA,gCAAgC,GAC3C,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,yBAAyB,GAAG,KAAK,EAC5C,IAAU,EACV,OAAwC,EACZ,EAAE;IAC9B,MAAM,IAAI,GAAG,IAAA,iBAAS,EAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrC,MAAM,aAAa,GAAG,IAAA,mBAAW,EAAC,IAAI,CAAC,CAAC;IACxC,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,UAAU,CAAC;IAClD,MAAM,MAAM,GAAG,OAAO,CAAC,YAAY,IAAI,IAAI,CAAC;IAC5C,MAAM,WAAW,GAAG,IAAA,0BAAiB,EAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IACzD,MAAM,kBAAkB,GAAG,GAAG,IAAA,6BAAiB,EAAC,IAAI,CAAC,GAAG,IAAI,EAAE,CAAC;IAE/D,uEAAuE;IACvE,uEAAuE;IACvE,yEA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
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { type GeneratorCallback, type Tree } from '@nx/devkit';
|
|
6
|
+
import { type NxGeneratorInfo } from '../../utils/nx';
|
|
7
|
+
import type { AgentcoreGatewayMcpConnectionGeneratorSchema } from './schema';
|
|
8
|
+
export declare const AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO: NxGeneratorInfo;
|
|
9
|
+
/**
|
|
10
|
+
* Connect an AgentCore Gateway to an MCP server.
|
|
11
|
+
*
|
|
12
|
+
* Chains the gateway's serve-local target to the MCP server's serve-local
|
|
13
|
+
* target, and registers the server in the gateway's local serve-local.ts so
|
|
14
|
+
* the local gateway aggregates its tools. Users must still call
|
|
15
|
+
* `gateway.addMcpServer(...)` in their application stack to create the
|
|
16
|
+
* actual CDK/Terraform resource.
|
|
17
|
+
*/
|
|
18
|
+
export declare const agentcoreGatewayMcpConnectionGenerator: (tree: Tree, options: AgentcoreGatewayMcpConnectionGeneratorSchema) => Promise<GeneratorCallback>;
|
|
19
|
+
export default agentcoreGatewayMcpConnectionGenerator;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.agentcoreGatewayMcpConnectionGenerator = exports.AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const format_1 = require("../../utils/format");
|
|
10
|
+
const metrics_1 = require("../../utils/metrics");
|
|
11
|
+
const names_1 = require("../../utils/names");
|
|
12
|
+
const nx_1 = require("../../utils/nx");
|
|
13
|
+
const attach_upstream_1 = require("../attach-upstream");
|
|
14
|
+
const generator_1 = require("../generator");
|
|
15
|
+
exports.AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
16
|
+
/**
|
|
17
|
+
* Connect an AgentCore Gateway to an MCP server.
|
|
18
|
+
*
|
|
19
|
+
* Chains the gateway's serve-local target to the MCP server's serve-local
|
|
20
|
+
* target, and registers the server in the gateway's local serve-local.ts so
|
|
21
|
+
* the local gateway aggregates its tools. Users must still call
|
|
22
|
+
* `gateway.addMcpServer(...)` in their application stack to create the
|
|
23
|
+
* actual CDK/Terraform resource.
|
|
24
|
+
*/
|
|
25
|
+
const agentcoreGatewayMcpConnectionGenerator = async (tree, options) => {
|
|
26
|
+
const sourceProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.sourceProject);
|
|
27
|
+
const targetProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.targetProject);
|
|
28
|
+
const gateway = (0, generator_1.readAgentCoreGatewayMetadata)(sourceProject);
|
|
29
|
+
const mcpComponent = options.targetComponent;
|
|
30
|
+
if (!mcpComponent) {
|
|
31
|
+
throw new Error(`Target project '${options.targetProject}' has no MCP server component metadata. Did you run the 'ts#mcp-server' or 'py#mcp-server' generator?`);
|
|
32
|
+
}
|
|
33
|
+
if (gateway.protocol !== 'mcp') {
|
|
34
|
+
throw new Error(`Gateway '${gateway.name}' has protocol='${gateway.protocol}'. MCP server targets can only be attached to MCP-protocol gateways.`);
|
|
35
|
+
}
|
|
36
|
+
if (mcpComponent.auth && mcpComponent.auth !== 'iam') {
|
|
37
|
+
throw new Error(`MCP server '${mcpComponent.name}' uses auth='${mcpComponent.auth}'. Gateway->MCP connections currently require the MCP server to use IAM authentication.`);
|
|
38
|
+
}
|
|
39
|
+
const gatewayServeLocalTargetName = `${(0, names_1.kebabCase)(gateway.rc)}-serve-local`;
|
|
40
|
+
// The target name must match what the deployed Gateway uses
|
|
41
|
+
// (`mcpServerName` on the MCP construct, derived from the project's class
|
|
42
|
+
// name) so `<target>___<tool>` resolves identically locally and deployed.
|
|
43
|
+
// Component-level `name` would clash whenever two MCP server projects
|
|
44
|
+
// both default to `mcp-server`.
|
|
45
|
+
const mcpTargetName = (0, names_1.kebabCase)(mcpComponent.rc);
|
|
46
|
+
const mcpComponentName = mcpComponent.name ?? 'mcp-server';
|
|
47
|
+
await (0, attach_upstream_1.attachUpstreamToLocalGateway)(tree, sourceProject, gatewayServeLocalTargetName, {
|
|
48
|
+
targetName: mcpTargetName,
|
|
49
|
+
port: mcpComponent.port ?? 8000,
|
|
50
|
+
upstreamProjectName: targetProject.name,
|
|
51
|
+
upstreamServeLocalTargetName: `${mcpComponentName}-serve-local`,
|
|
52
|
+
});
|
|
53
|
+
await (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
54
|
+
exports.AGENTCORE_GATEWAY_MCP_CONNECTION_GENERATOR_INFO,
|
|
55
|
+
]);
|
|
56
|
+
await (0, format_1.formatFilesInSubtree)(tree);
|
|
57
|
+
return () => {
|
|
58
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
exports.agentcoreGatewayMcpConnectionGenerator = agentcoreGatewayMcpConnectionGenerator;
|
|
62
|
+
exports.default = exports.agentcoreGatewayMcpConnectionGenerator;
|
|
63
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../packages/nx-plugin/src/agentcore-gateway/mcp-connection/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAIoB;AACpB,+CAA0D;AAC1D,iDAAsE;AACtE,6CAA8C;AAC9C,uCAIwB;AACxB,wDAAkE;AAClE,4CAA4D;AAG/C,QAAA,+CAA+C,GAC1D,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAE/B;;;;;;;;GAQG;AACI,MAAM,sCAAsC,GAAG,KA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AC,IAA2B,IAAI,IAAI;QACvD,mBAAmB,EAAE,aAAa,CAAC,IAAI;QACvC,4BAA4B,EAAE,GAAG,gBAAgB,cAAc;KAChE,CACF,CAAC;IAEF,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE;QAC1C,uDAA+C;KAChD,CAAC,CAAC;IAEH,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IAEjC,OAAO,GAAG,EAAE;QACV,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC;AACJ,CAAC,CAAC;AAhEW,QAAA,sCAAsC,0CAgEjD;AAEF,kBAAe,8CAAsC,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import type { ComponentMetadata } from '../../utils/nx';
|
|
6
|
+
|
|
7
|
+
export interface AgentcoreGatewayMcpConnectionGeneratorSchema {
|
|
8
|
+
sourceProject: string;
|
|
9
|
+
targetProject: string;
|
|
10
|
+
sourceComponent?: ComponentMetadata;
|
|
11
|
+
targetComponent?: ComponentMetadata;
|
|
12
|
+
}
|