@aws/agentcore 1.0.0-preview.9 → 1.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1218 -145
- package/dist/assets/agent-inspector/index.css.asset +1 -0
- package/dist/assets/agent-inspector/index.js.asset +289 -0
- package/dist/assets/cdk/README.md +43 -17
- package/dist/assets/cdk/bin/cdk.ts +22 -123
- package/dist/assets/cdk/lib/cdk-stack.ts +18 -69
- package/dist/assets/cdk/package.json +6 -13
- package/dist/assets/cdk/tsconfig.json +1 -1
- package/dist/assets/evaluators/python-lambda/README.md +32 -0
- package/dist/assets/evaluators/python-lambda/pyproject.toml +1 -1
- package/dist/assets/templates/a2a-python-strands/README.md +31 -0
- package/dist/assets/templates/a2a-python-strands/main.py +100 -0
- package/dist/assets/templates/a2a-python-strands/memory/session.py +35 -0
- package/dist/assets/templates/a2a-python-strands/model/load.py +6 -0
- package/dist/assets/templates/a2a-python-strands/pyproject.toml +20 -0
- package/dist/assets/templates/agent-python-langchain/README.md +56 -0
- package/dist/assets/{python/a2a/googleadk/base → templates/agent-python-langchain}/gitignore.template +1 -1
- package/dist/assets/templates/agent-python-langchain/main.py +50 -0
- package/dist/assets/templates/agent-python-langchain/model/load.py +9 -0
- package/dist/assets/templates/agent-python-langchain/pyproject.toml +21 -0
- package/dist/assets/templates/agent-python-minimal/README.md +31 -0
- package/dist/assets/templates/agent-python-minimal/main.py +13 -0
- package/dist/assets/templates/agent-python-minimal/pyproject.toml +18 -0
- package/dist/assets/{container/python/Dockerfile → templates/agent-python-strands/Dockerfile.template} +3 -1
- package/dist/assets/templates/agent-python-strands/README.md +60 -0
- package/dist/assets/{python/a2a/langchain_langgraph/base → templates/agent-python-strands}/gitignore.template +1 -1
- package/dist/assets/templates/agent-python-strands/main.py +65 -0
- package/dist/assets/templates/agent-python-strands/memory/__init__.py +0 -0
- package/dist/assets/templates/agent-python-strands/memory/session.py +31 -0
- package/dist/assets/{python/http/strands/base → templates/agent-python-strands}/model/load.py +49 -3
- package/dist/assets/templates/agent-python-strands/parse.py +41 -0
- package/dist/assets/templates/agent-python-strands/pyproject.toml +24 -0
- package/dist/assets/templates/agent-typescript-strands/README.md +50 -0
- package/dist/assets/templates/agent-typescript-strands/gitignore.template +22 -0
- package/dist/assets/templates/agent-typescript-strands/main.ts +77 -0
- package/dist/assets/templates/agent-typescript-strands/memory/memory.ts +33 -0
- package/dist/assets/templates/agent-typescript-strands/model/load.ts +5 -0
- package/dist/assets/templates/agent-typescript-strands/package.json.template +28 -0
- package/dist/assets/templates/agent-typescript-strands/tsconfig.json +19 -0
- package/dist/assets/templates/agent-typescript-vercel/README.md +22 -0
- package/dist/assets/templates/agent-typescript-vercel/gitignore.template +22 -0
- package/dist/assets/templates/agent-typescript-vercel/main.ts +35 -0
- package/dist/assets/templates/agent-typescript-vercel/package.json.template +24 -0
- package/dist/assets/templates/agent-typescript-vercel/tsconfig.json +19 -0
- package/dist/assets/templates/agui-python-strands/README.md +39 -0
- package/dist/assets/{python/a2a/strands/base → templates/agui-python-strands}/gitignore.template +1 -1
- package/dist/assets/{python/agui/strands/base → templates/agui-python-strands}/main.py +11 -14
- package/dist/assets/templates/agui-python-strands/memory/__init__.py +0 -0
- package/dist/assets/templates/agui-python-strands/memory/session.py +35 -0
- package/dist/assets/templates/agui-python-strands/model/load.py +6 -0
- package/dist/assets/templates/agui-python-strands/pyproject.toml +22 -0
- package/dist/assets/{python/http/strands/base → templates/export-harness-python}/README.md +15 -8
- package/dist/assets/templates/export-harness-python/gitignore.template +41 -0
- package/dist/assets/templates/export-harness-python/main.py +584 -0
- package/dist/assets/templates/export-harness-python/mcp_client/client.py +63 -0
- package/dist/assets/templates/export-harness-python/memory/__init__.py +0 -0
- package/dist/assets/templates/export-harness-python/memory/session.py +47 -0
- package/dist/assets/templates/export-harness-python/model/load.py +249 -0
- package/dist/assets/templates/export-harness-python/model/mantle_compat.py +21 -0
- package/dist/assets/templates/export-harness-python/pyproject.toml +22 -0
- package/dist/assets/templates/export-harness-python/skills/fetcher.py +279 -0
- package/dist/assets/templates/harness/harness.yaml +157 -0
- package/dist/assets/templates/mcp-python-fastmcp/README.md +32 -0
- package/dist/assets/templates/mcp-python-fastmcp/gitignore.template +41 -0
- package/dist/assets/templates/mcp-python-fastmcp/main.py +83 -0
- package/dist/assets/{python/mcp/standalone/base → templates/mcp-python-fastmcp}/pyproject.toml +3 -2
- package/dist/assets/templates/shared/env.local.template +11 -0
- package/dist/assets/templates/shared/gitignore.template +19 -0
- package/dist/index.js +4 -27
- package/dist/main.js +1582 -0
- package/package.json +76 -148
- package/LICENSE +0 -175
- package/dist/agent-inspector/index.css +0 -1
- package/dist/agent-inspector/index.js +0 -279
- package/dist/assets/README.md +0 -104
- package/dist/assets/__tests__/__snapshots__/assets.snapshot.test.ts.snap +0 -5673
- package/dist/assets/__tests__/__snapshots__/dockerfile-render.test.ts.snap +0 -77
- package/dist/assets/__tests__/assets.snapshot.test.ts +0 -125
- package/dist/assets/__tests__/dockerfile-render.test.ts +0 -24
- package/dist/assets/agents/AGENTS.md +0 -141
- package/dist/assets/cdk/.prettierrc +0 -8
- package/dist/assets/cdk/jest.config.js +0 -9
- package/dist/assets/cdk/npmignore.template +0 -6
- package/dist/assets/cdk/test/cdk.test.ts +0 -28
- package/dist/assets/harness/invoke.py.template +0 -74
- package/dist/assets/mcp/python/README.md +0 -27
- package/dist/assets/mcp/python/pyproject.toml +0 -22
- package/dist/assets/mcp/python/server.py +0 -117
- package/dist/assets/mcp/python-lambda/README.md +0 -22
- package/dist/assets/mcp/python-lambda/handler.py +0 -144
- package/dist/assets/mcp/python-lambda/pyproject.toml +0 -15
- package/dist/assets/python/a2a/googleadk/base/README.md +0 -22
- package/dist/assets/python/a2a/googleadk/base/main.py +0 -110
- package/dist/assets/python/a2a/googleadk/base/model/load.py +0 -41
- package/dist/assets/python/a2a/googleadk/base/pyproject.toml +0 -20
- package/dist/assets/python/a2a/langchain_langgraph/base/README.md +0 -22
- package/dist/assets/python/a2a/langchain_langgraph/base/main.py +0 -130
- package/dist/assets/python/a2a/langchain_langgraph/base/model/load.py +0 -123
- package/dist/assets/python/a2a/langchain_langgraph/base/pyproject.toml +0 -25
- package/dist/assets/python/a2a/strands/base/README.md +0 -22
- package/dist/assets/python/a2a/strands/base/main.py +0 -107
- package/dist/assets/python/a2a/strands/base/model/load.py +0 -123
- package/dist/assets/python/a2a/strands/base/pyproject.toml +0 -23
- package/dist/assets/python/a2a/strands/capabilities/memory/session.py +0 -43
- package/dist/assets/python/agui/googleadk/base/README.md +0 -30
- package/dist/assets/python/agui/googleadk/base/gitignore.template +0 -41
- package/dist/assets/python/agui/googleadk/base/main.py +0 -31
- package/dist/assets/python/agui/googleadk/base/model/load.py +0 -41
- package/dist/assets/python/agui/googleadk/base/pyproject.toml +0 -24
- package/dist/assets/python/agui/langchain_langgraph/base/README.md +0 -22
- package/dist/assets/python/agui/langchain_langgraph/base/gitignore.template +0 -41
- package/dist/assets/python/agui/langchain_langgraph/base/main.py +0 -74
- package/dist/assets/python/agui/langchain_langgraph/base/model/load.py +0 -123
- package/dist/assets/python/agui/langchain_langgraph/base/pyproject.toml +0 -30
- package/dist/assets/python/agui/strands/base/README.md +0 -22
- package/dist/assets/python/agui/strands/base/gitignore.template +0 -41
- package/dist/assets/python/agui/strands/base/model/__init__.py +0 -1
- package/dist/assets/python/agui/strands/base/model/load.py +0 -123
- package/dist/assets/python/agui/strands/base/pyproject.toml +0 -27
- package/dist/assets/python/agui/strands/capabilities/memory/__init__.py +0 -1
- package/dist/assets/python/agui/strands/capabilities/memory/session.py +0 -43
- package/dist/assets/python/http/autogen/base/README.md +0 -39
- package/dist/assets/python/http/autogen/base/gitignore.template +0 -41
- package/dist/assets/python/http/autogen/base/main.py +0 -112
- package/dist/assets/python/http/autogen/base/mcp_client/__init__.py +0 -1
- package/dist/assets/python/http/autogen/base/mcp_client/client.py +0 -28
- package/dist/assets/python/http/autogen/base/model/__init__.py +0 -1
- package/dist/assets/python/http/autogen/base/model/load.py +0 -136
- package/dist/assets/python/http/autogen/base/pyproject.toml +0 -34
- package/dist/assets/python/http/googleadk/base/README.md +0 -39
- package/dist/assets/python/http/googleadk/base/gitignore.template +0 -41
- package/dist/assets/python/http/googleadk/base/main.py +0 -160
- package/dist/assets/python/http/googleadk/base/mcp_client/__init__.py +0 -1
- package/dist/assets/python/http/googleadk/base/mcp_client/client.py +0 -75
- package/dist/assets/python/http/googleadk/base/model/__init__.py +0 -1
- package/dist/assets/python/http/googleadk/base/model/load.py +0 -41
- package/dist/assets/python/http/googleadk/base/pyproject.toml +0 -22
- package/dist/assets/python/http/langchain_langgraph/base/README.md +0 -39
- package/dist/assets/python/http/langchain_langgraph/base/gitignore.template +0 -41
- package/dist/assets/python/http/langchain_langgraph/base/main.py +0 -176
- package/dist/assets/python/http/langchain_langgraph/base/mcp_client/__init__.py +0 -1
- package/dist/assets/python/http/langchain_langgraph/base/mcp_client/client.py +0 -77
- package/dist/assets/python/http/langchain_langgraph/base/model/__init__.py +0 -1
- package/dist/assets/python/http/langchain_langgraph/base/model/load.py +0 -123
- package/dist/assets/python/http/langchain_langgraph/base/pyproject.toml +0 -37
- package/dist/assets/python/http/openaiagents/base/README.md +0 -39
- package/dist/assets/python/http/openaiagents/base/gitignore.template +0 -41
- package/dist/assets/python/http/openaiagents/base/main.py +0 -169
- package/dist/assets/python/http/openaiagents/base/mcp_client/__init__.py +0 -1
- package/dist/assets/python/http/openaiagents/base/mcp_client/client.py +0 -74
- package/dist/assets/python/http/openaiagents/base/model/__init__.py +0 -1
- package/dist/assets/python/http/openaiagents/base/model/load.py +0 -37
- package/dist/assets/python/http/openaiagents/base/pyproject.toml +0 -21
- package/dist/assets/python/http/strands/base/main.py +0 -217
- package/dist/assets/python/http/strands/base/mcp_client/__init__.py +0 -1
- package/dist/assets/python/http/strands/base/mcp_client/client.py +0 -73
- package/dist/assets/python/http/strands/base/model/__init__.py +0 -1
- package/dist/assets/python/http/strands/base/pyproject.toml +0 -25
- package/dist/assets/python/http/strands/capabilities/memory/__init__.py +0 -1
- package/dist/assets/python/http/strands/capabilities/memory/session.py +0 -44
- package/dist/assets/python/mcp/standalone/base/README.md +0 -36
- package/dist/assets/python/mcp/standalone/base/gitignore.template +0 -41
- package/dist/assets/python/mcp/standalone/base/main.py +0 -25
- package/dist/cli/index.mjs +0 -1718
- package/dist/index.d.ts +0 -9
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/constants.d.ts +0 -37
- package/dist/lib/constants.d.ts.map +0 -1
- package/dist/lib/constants.js +0 -69
- package/dist/lib/constants.js.map +0 -1
- package/dist/lib/errors/config.d.ts +0 -49
- package/dist/lib/errors/config.d.ts.map +0 -1
- package/dist/lib/errors/config.js +0 -170
- package/dist/lib/errors/config.js.map +0 -1
- package/dist/lib/errors/index.d.ts +0 -2
- package/dist/lib/errors/index.d.ts.map +0 -1
- package/dist/lib/errors/index.js +0 -18
- package/dist/lib/errors/index.js.map +0 -1
- package/dist/lib/index.d.ts +0 -7
- package/dist/lib/index.d.ts.map +0 -1
- package/dist/lib/index.js +0 -44
- package/dist/lib/index.js.map +0 -1
- package/dist/lib/packaging/build-args.d.ts +0 -6
- package/dist/lib/packaging/build-args.d.ts.map +0 -1
- package/dist/lib/packaging/build-args.js +0 -18
- package/dist/lib/packaging/build-args.js.map +0 -1
- package/dist/lib/packaging/container.d.ts +0 -10
- package/dist/lib/packaging/container.d.ts.map +0 -1
- package/dist/lib/packaging/container.js +0 -78
- package/dist/lib/packaging/container.js.map +0 -1
- package/dist/lib/packaging/errors.d.ts +0 -16
- package/dist/lib/packaging/errors.d.ts.map +0 -1
- package/dist/lib/packaging/errors.js +0 -36
- package/dist/lib/packaging/errors.js.map +0 -1
- package/dist/lib/packaging/helpers.d.ts +0 -54
- package/dist/lib/packaging/helpers.d.ts.map +0 -1
- package/dist/lib/packaging/helpers.js +0 -463
- package/dist/lib/packaging/helpers.js.map +0 -1
- package/dist/lib/packaging/index.d.ts +0 -40
- package/dist/lib/packaging/index.d.ts.map +0 -1
- package/dist/lib/packaging/index.js +0 -98
- package/dist/lib/packaging/index.js.map +0 -1
- package/dist/lib/packaging/node.d.ts +0 -22
- package/dist/lib/packaging/node.d.ts.map +0 -1
- package/dist/lib/packaging/node.js +0 -109
- package/dist/lib/packaging/node.js.map +0 -1
- package/dist/lib/packaging/python.d.ts +0 -23
- package/dist/lib/packaging/python.d.ts.map +0 -1
- package/dist/lib/packaging/python.js +0 -165
- package/dist/lib/packaging/python.js.map +0 -1
- package/dist/lib/packaging/types/index.d.ts +0 -2
- package/dist/lib/packaging/types/index.d.ts.map +0 -1
- package/dist/lib/packaging/types/index.js +0 -3
- package/dist/lib/packaging/types/index.js.map +0 -1
- package/dist/lib/packaging/types/packaging.d.ts +0 -57
- package/dist/lib/packaging/types/packaging.d.ts.map +0 -1
- package/dist/lib/packaging/types/packaging.js +0 -3
- package/dist/lib/packaging/types/packaging.js.map +0 -1
- package/dist/lib/packaging/uv.d.ts +0 -7
- package/dist/lib/packaging/uv.d.ts.map +0 -1
- package/dist/lib/packaging/uv.js +0 -40
- package/dist/lib/packaging/uv.js.map +0 -1
- package/dist/lib/schemas/io/config-io.d.ts +0 -119
- package/dist/lib/schemas/io/config-io.d.ts.map +0 -1
- package/dist/lib/schemas/io/config-io.js +0 -323
- package/dist/lib/schemas/io/config-io.js.map +0 -1
- package/dist/lib/schemas/io/global-config.d.ts +0 -33
- package/dist/lib/schemas/io/global-config.d.ts.map +0 -1
- package/dist/lib/schemas/io/global-config.js +0 -89
- package/dist/lib/schemas/io/global-config.js.map +0 -1
- package/dist/lib/schemas/io/index.d.ts +0 -3
- package/dist/lib/schemas/io/index.d.ts.map +0 -1
- package/dist/lib/schemas/io/index.js +0 -18
- package/dist/lib/schemas/io/index.js.map +0 -1
- package/dist/lib/schemas/io/path-resolver.d.ts +0 -119
- package/dist/lib/schemas/io/path-resolver.d.ts.map +0 -1
- package/dist/lib/schemas/io/path-resolver.js +0 -207
- package/dist/lib/schemas/io/path-resolver.js.map +0 -1
- package/dist/lib/utils/aws-account.d.ts +0 -7
- package/dist/lib/utils/aws-account.d.ts.map +0 -1
- package/dist/lib/utils/aws-account.js +0 -24
- package/dist/lib/utils/aws-account.js.map +0 -1
- package/dist/lib/utils/credentials.d.ts +0 -86
- package/dist/lib/utils/credentials.d.ts.map +0 -1
- package/dist/lib/utils/credentials.js +0 -153
- package/dist/lib/utils/credentials.js.map +0 -1
- package/dist/lib/utils/env.d.ts +0 -22
- package/dist/lib/utils/env.d.ts.map +0 -1
- package/dist/lib/utils/env.js +0 -65
- package/dist/lib/utils/env.js.map +0 -1
- package/dist/lib/utils/index.d.ts +0 -9
- package/dist/lib/utils/index.d.ts.map +0 -1
- package/dist/lib/utils/index.js +0 -27
- package/dist/lib/utils/index.js.map +0 -1
- package/dist/lib/utils/json-rpc.d.ts +0 -3
- package/dist/lib/utils/json-rpc.d.ts.map +0 -1
- package/dist/lib/utils/json-rpc.js +0 -27
- package/dist/lib/utils/json-rpc.js.map +0 -1
- package/dist/lib/utils/platform.d.ts +0 -63
- package/dist/lib/utils/platform.d.ts.map +0 -1
- package/dist/lib/utils/platform.js +0 -88
- package/dist/lib/utils/platform.js.map +0 -1
- package/dist/lib/utils/subprocess.d.ts +0 -29
- package/dist/lib/utils/subprocess.d.ts.map +0 -1
- package/dist/lib/utils/subprocess.js +0 -116
- package/dist/lib/utils/subprocess.js.map +0 -1
- package/dist/lib/utils/time-parser.d.ts +0 -11
- package/dist/lib/utils/time-parser.d.ts.map +0 -1
- package/dist/lib/utils/time-parser.js +0 -47
- package/dist/lib/utils/time-parser.js.map +0 -1
- package/dist/lib/utils/zod.d.ts +0 -14
- package/dist/lib/utils/zod.d.ts.map +0 -1
- package/dist/lib/utils/zod.js +0 -32
- package/dist/lib/utils/zod.js.map +0 -1
- package/dist/schema/constants.d.ts +0 -119
- package/dist/schema/constants.d.ts.map +0 -1
- package/dist/schema/constants.js +0 -170
- package/dist/schema/constants.js.map +0 -1
- package/dist/schema/index.d.ts +0 -4
- package/dist/schema/index.d.ts.map +0 -1
- package/dist/schema/index.js +0 -21
- package/dist/schema/index.js.map +0 -1
- package/dist/schema/schemas/agent-env.d.ts +0 -186
- package/dist/schema/schemas/agent-env.d.ts.map +0 -1
- package/dist/schema/schemas/agent-env.js +0 -240
- package/dist/schema/schemas/agent-env.js.map +0 -1
- package/dist/schema/schemas/agentcore-project.d.ts +0 -838
- package/dist/schema/schemas/agentcore-project.d.ts.map +0 -1
- package/dist/schema/schemas/agentcore-project.js +0 -335
- package/dist/schema/schemas/agentcore-project.js.map +0 -1
- package/dist/schema/schemas/auth.d.ts +0 -140
- package/dist/schema/schemas/auth.d.ts.map +0 -1
- package/dist/schema/schemas/auth.js +0 -114
- package/dist/schema/schemas/auth.js.map +0 -1
- package/dist/schema/schemas/aws-targets.d.ts +0 -71
- package/dist/schema/schemas/aws-targets.d.ts.map +0 -1
- package/dist/schema/schemas/aws-targets.js +0 -57
- package/dist/schema/schemas/aws-targets.js.map +0 -1
- package/dist/schema/schemas/deployed-state.d.ts +0 -725
- package/dist/schema/schemas/deployed-state.d.ts.map +0 -1
- package/dist/schema/schemas/deployed-state.js +0 -218
- package/dist/schema/schemas/deployed-state.js.map +0 -1
- package/dist/schema/schemas/index.d.ts +0 -9
- package/dist/schema/schemas/index.d.ts.map +0 -1
- package/dist/schema/schemas/index.js +0 -26
- package/dist/schema/schemas/index.js.map +0 -1
- package/dist/schema/schemas/mcp-defs.d.ts +0 -52
- package/dist/schema/schemas/mcp-defs.d.ts.map +0 -1
- package/dist/schema/schemas/mcp-defs.js +0 -50
- package/dist/schema/schemas/mcp-defs.js.map +0 -1
- package/dist/schema/schemas/mcp.d.ts +0 -820
- package/dist/schema/schemas/mcp.d.ts.map +0 -1
- package/dist/schema/schemas/mcp.js +0 -564
- package/dist/schema/schemas/mcp.js.map +0 -1
- package/dist/schema/schemas/primitives/ab-test.d.ts +0 -141
- package/dist/schema/schemas/primitives/ab-test.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/ab-test.js +0 -97
- package/dist/schema/schemas/primitives/ab-test.js.map +0 -1
- package/dist/schema/schemas/primitives/config-bundle.d.ts +0 -31
- package/dist/schema/schemas/primitives/config-bundle.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/config-bundle.js +0 -38
- package/dist/schema/schemas/primitives/config-bundle.js.map +0 -1
- package/dist/schema/schemas/primitives/evaluator.d.ts +0 -102
- package/dist/schema/schemas/primitives/evaluator.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/evaluator.js +0 -84
- package/dist/schema/schemas/primitives/evaluator.js.map +0 -1
- package/dist/schema/schemas/primitives/harness.d.ts +0 -363
- package/dist/schema/schemas/primitives/harness.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/harness.js +0 -261
- package/dist/schema/schemas/primitives/harness.js.map +0 -1
- package/dist/schema/schemas/primitives/http-gateway.d.ts +0 -21
- package/dist/schema/schemas/primitives/http-gateway.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/http-gateway.js +0 -34
- package/dist/schema/schemas/primitives/http-gateway.js.map +0 -1
- package/dist/schema/schemas/primitives/index.d.ts +0 -15
- package/dist/schema/schemas/primitives/index.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/index.js +0 -61
- package/dist/schema/schemas/primitives/index.js.map +0 -1
- package/dist/schema/schemas/primitives/memory.d.ts +0 -51
- package/dist/schema/schemas/primitives/memory.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/memory.js +0 -73
- package/dist/schema/schemas/primitives/memory.js.map +0 -1
- package/dist/schema/schemas/primitives/online-eval-config.d.ts +0 -14
- package/dist/schema/schemas/primitives/online-eval-config.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/online-eval-config.js +0 -30
- package/dist/schema/schemas/primitives/online-eval-config.js.map +0 -1
- package/dist/schema/schemas/primitives/policy.d.ts +0 -49
- package/dist/schema/schemas/primitives/policy.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/policy.js +0 -62
- package/dist/schema/schemas/primitives/policy.js.map +0 -1
- package/dist/schema/schemas/primitives/tags.d.ts +0 -6
- package/dist/schema/schemas/primitives/tags.d.ts.map +0 -1
- package/dist/schema/schemas/primitives/tags.js +0 -27
- package/dist/schema/schemas/primitives/tags.js.map +0 -1
- package/dist/schema/schemas/zod-util.d.ts +0 -10
- package/dist/schema/schemas/zod-util.d.ts.map +0 -1
- package/dist/schema/schemas/zod-util.js +0 -23
- package/dist/schema/schemas/zod-util.js.map +0 -1
- package/dist/schema/types/index.d.ts +0 -2
- package/dist/schema/types/index.d.ts.map +0 -1
- package/dist/schema/types/index.js +0 -18
- package/dist/schema/types/index.js.map +0 -1
- package/dist/schema/types/path.d.ts +0 -27
- package/dist/schema/types/path.d.ts.map +0 -1
- package/dist/schema/types/path.js +0 -13
- package/dist/schema/types/path.js.map +0 -1
- package/scripts/bump-version.ts +0 -393
- package/scripts/bundle.mjs +0 -219
- package/scripts/check-old-cli.lib.mjs +0 -102
- package/scripts/check-old-cli.mjs +0 -10
- package/scripts/copy-assets.mjs +0 -64
- package/scripts/generate-schema.mjs +0 -40
- package/scripts/run-e2e-local.sh +0 -112
- package/scripts/start-tui-harness.sh +0 -90
- /package/dist/{agent-inspector/favicon.svg → assets/agent-inspector/favicon.svg.asset} +0 -0
- /package/dist/{agent-inspector/index.html → assets/agent-inspector/index.html.asset} +0 -0
- /package/dist/assets/{python/http/strands/base → templates/a2a-python-strands}/gitignore.template +0 -0
- /package/dist/assets/{typescript/.gitkeep → templates/a2a-python-strands/memory/__init__.py} +0 -0
- /package/dist/assets/{python/a2a/googleadk/base → templates/a2a-python-strands}/model/__init__.py +0 -0
- /package/dist/assets/{python/a2a/langchain_langgraph/base → templates/agent-python-langchain}/model/__init__.py +0 -0
- /package/dist/assets/{container/python → templates/agent-python-strands}/dockerignore.template +0 -0
- /package/dist/assets/{python/a2a/strands/base → templates/agent-python-strands}/model/__init__.py +0 -0
- /package/dist/assets/{python/a2a/strands/capabilities/memory → templates/agui-python-strands/model}/__init__.py +0 -0
- /package/dist/assets/{python/agui/googleadk/base/model → templates/export-harness-python/mcp_client}/__init__.py +0 -0
- /package/dist/assets/{python/agui/langchain_langgraph/base → templates/export-harness-python}/model/__init__.py +0 -0
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
from typing import Any
|
|
2
|
+
from collections import OrderedDict
|
|
3
|
+
{{#if inlineFunctionTools}}
|
|
4
|
+
import json
|
|
5
|
+
|
|
6
|
+
from strands.tools.tools import PythonAgentTool
|
|
7
|
+
from strands.types.tools import ToolResult, ToolUse
|
|
8
|
+
{{/if}}
|
|
9
|
+
from strands import Agent, tool
|
|
10
|
+
{{#if hasSkillsFetcher}}
|
|
11
|
+
from strands import AgentSkills
|
|
12
|
+
{{#if hasFetchedSkills}}
|
|
13
|
+
from skills.fetcher import resolve_s3_skills, resolve_git_skills
|
|
14
|
+
{{/if}}
|
|
15
|
+
{{#if (some gitSkills "credentialArn")}}
|
|
16
|
+
from bedrock_agentcore.services.identity import IdentityClient
|
|
17
|
+
{{/if}}
|
|
18
|
+
{{/if}}
|
|
19
|
+
import asyncio
|
|
20
|
+
{{#if timeoutSeconds}}
|
|
21
|
+
import threading
|
|
22
|
+
{{/if}}
|
|
23
|
+
{{#if hasShell}}
|
|
24
|
+
import subprocess
|
|
25
|
+
{{/if}}
|
|
26
|
+
{{#if hasFileOperations}}
|
|
27
|
+
import os
|
|
28
|
+
{{/if}}
|
|
29
|
+
{{#if truncationStrategy}}
|
|
30
|
+
{{#if (eq truncationStrategy "sliding_window")}}
|
|
31
|
+
from strands.agent.conversation_manager import SlidingWindowConversationManager
|
|
32
|
+
{{/if}}
|
|
33
|
+
{{#if (eq truncationStrategy "summarization")}}
|
|
34
|
+
from strands.agent.conversation_manager.summarizing_conversation_manager import SummarizingConversationManager
|
|
35
|
+
{{/if}}
|
|
36
|
+
{{else}}
|
|
37
|
+
from strands.agent.conversation_manager.null_conversation_manager import NullConversationManager
|
|
38
|
+
{{/if}}
|
|
39
|
+
from bedrock_agentcore.runtime import BedrockAgentCoreApp
|
|
40
|
+
from model.load import load_model
|
|
41
|
+
{{#if remoteMcpTools}}
|
|
42
|
+
from mcp_client.client import get_all_remote_mcp_clients
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#unless remoteMcpTools}}
|
|
45
|
+
{{#unless isExportHarness}}
|
|
46
|
+
from mcp_client.client import get_streamable_http_mcp_client
|
|
47
|
+
{{/unless}}
|
|
48
|
+
{{/unless}}
|
|
49
|
+
{{#if hasMemory}}
|
|
50
|
+
from memory.session import get_memory_session_manager
|
|
51
|
+
{{/if}}
|
|
52
|
+
{{#unless hasFileOperations}}
|
|
53
|
+
{{#if (or needsOs (some gitSkills "credentialArn"))}}
|
|
54
|
+
import os
|
|
55
|
+
{{/if}}
|
|
56
|
+
{{/unless}}
|
|
57
|
+
|
|
58
|
+
app = BedrockAgentCoreApp()
|
|
59
|
+
log = app.logger
|
|
60
|
+
|
|
61
|
+
{{#if remoteMcpTools}}
|
|
62
|
+
# Define MCP clients for all configured MCP servers (gateways and/or remote MCP)
|
|
63
|
+
mcp_clients = []
|
|
64
|
+
{{#if remoteMcpTools}}
|
|
65
|
+
mcp_clients += get_all_remote_mcp_clients()
|
|
66
|
+
{{/if}}
|
|
67
|
+
{{else}}
|
|
68
|
+
{{#unless isExportHarness}}
|
|
69
|
+
# Define a Streamable HTTP MCP Client
|
|
70
|
+
mcp_clients = [get_streamable_http_mcp_client()]
|
|
71
|
+
{{/unless}}
|
|
72
|
+
{{/if}}
|
|
73
|
+
|
|
74
|
+
{{#if systemPromptText}}
|
|
75
|
+
DEFAULT_SYSTEM_PROMPT = """{{escapePyStr systemPromptText}}"""
|
|
76
|
+
{{else}}
|
|
77
|
+
DEFAULT_SYSTEM_PROMPT = """
|
|
78
|
+
You are a helpful assistant. Use tools when appropriate.
|
|
79
|
+
{{#if needsOs}}{{#unless isExportHarness}}
|
|
80
|
+
You have access to the following mounted filesystems. Use file_read, file_write, and list_files with full absolute paths:
|
|
81
|
+
{{#if sessionStorageMountPath}}- {{sessionStorageMountPath}}: ephemeral session storage (lost when session ends)
|
|
82
|
+
{{/if}}{{#each efsMounts}}- {{mountPath}}: EFS persistent storage (persists across sessions and agent restarts)
|
|
83
|
+
{{/each}}{{#each s3Mounts}}- {{mountPath}}: S3 Files persistent storage (durable, backed by S3)
|
|
84
|
+
{{/each}}{{/unless}}{{/if}}
|
|
85
|
+
"""
|
|
86
|
+
{{/if}}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# Define a collection of tools used by the model
|
|
90
|
+
tools = []
|
|
91
|
+
|
|
92
|
+
{{#if inlineFunctionTools}}
|
|
93
|
+
# Inline function tools — stop the agent loop so the tool call streams back to the caller
|
|
94
|
+
def _make_inline_tool(name: str, spec: dict) -> PythonAgentTool:
|
|
95
|
+
def _handler(tool: ToolUse, **kwargs: Any) -> ToolResult:
|
|
96
|
+
kwargs.get("request_state", {})["stop_event_loop"] = True
|
|
97
|
+
return {"toolUseId": tool["toolUseId"], "status": "success", "content": [{"text": " "}]}
|
|
98
|
+
_handler.__name__ = name
|
|
99
|
+
return PythonAgentTool(tool_name=name, tool_spec=spec, tool_func=_handler)
|
|
100
|
+
|
|
101
|
+
{{#each inlineFunctionTools}}
|
|
102
|
+
_INLINE_SPEC_{{snakeCase name}} = {
|
|
103
|
+
"name": "{{name}}",
|
|
104
|
+
"description": {{safeJson description}},
|
|
105
|
+
"inputSchema": {"json": json.loads({{pyJsonStr inputSchema}}) },
|
|
106
|
+
}
|
|
107
|
+
tools.append(_make_inline_tool("{{name}}", _INLINE_SPEC_{{snakeCase name}}))
|
|
108
|
+
{{/each}}
|
|
109
|
+
|
|
110
|
+
_INLINE_FUNCTION_NAMES = { {{#each inlineFunctionTools}}"{{name}}"{{#unless @last}}, {{/unless}}{{/each}} }
|
|
111
|
+
|
|
112
|
+
{{else}}
|
|
113
|
+
_INLINE_FUNCTION_NAMES = set()
|
|
114
|
+
|
|
115
|
+
{{#unless isExportHarness}}
|
|
116
|
+
# Define a simple function tool
|
|
117
|
+
@tool
|
|
118
|
+
def add_numbers(a: int, b: int) -> int:
|
|
119
|
+
"""Return the sum of two numbers"""
|
|
120
|
+
return a+b
|
|
121
|
+
tools.append(add_numbers)
|
|
122
|
+
|
|
123
|
+
{{/unless}}
|
|
124
|
+
{{/if}}
|
|
125
|
+
{{#if hasShell}}
|
|
126
|
+
@tool
|
|
127
|
+
def shell(command: str, timeout: int = 300) -> dict:
|
|
128
|
+
"""Execute a bash command and return the results.
|
|
129
|
+
|
|
130
|
+
Args:
|
|
131
|
+
command: The bash command to execute
|
|
132
|
+
timeout: Timeout in seconds (default: 300)
|
|
133
|
+
|
|
134
|
+
Returns:
|
|
135
|
+
Dict with stdout, stderr, and exit_code
|
|
136
|
+
"""
|
|
137
|
+
result = subprocess.run(
|
|
138
|
+
command, shell=True, capture_output=True, text=True, timeout=timeout
|
|
139
|
+
)
|
|
140
|
+
return {"stdout": result.stdout, "stderr": result.stderr, "exit_code": result.returncode}
|
|
141
|
+
|
|
142
|
+
tools.append(shell)
|
|
143
|
+
{{/if}}
|
|
144
|
+
{{#if hasFileOperations}}
|
|
145
|
+
@tool
|
|
146
|
+
def file_operations(
|
|
147
|
+
command: str,
|
|
148
|
+
path: str,
|
|
149
|
+
old_str: str = None,
|
|
150
|
+
new_str: str = None,
|
|
151
|
+
file_text: str = None,
|
|
152
|
+
insert_line: int = None,
|
|
153
|
+
view_range: list = None,
|
|
154
|
+
) -> str:
|
|
155
|
+
"""Text editor tool for viewing and modifying files.
|
|
156
|
+
|
|
157
|
+
Args:
|
|
158
|
+
command: The command to execute ("view", "str_replace", "create", "insert")
|
|
159
|
+
path: Path to the file or directory
|
|
160
|
+
old_str: Text to replace (for str_replace command)
|
|
161
|
+
new_str: Replacement text (for str_replace and insert commands)
|
|
162
|
+
file_text: Content for new file (for create command)
|
|
163
|
+
insert_line: Line number to insert after (for insert command)
|
|
164
|
+
view_range: [start_line, end_line] for viewing specific lines (for view command)
|
|
165
|
+
|
|
166
|
+
Returns:
|
|
167
|
+
Result of the operation
|
|
168
|
+
"""
|
|
169
|
+
try:
|
|
170
|
+
if command == "view":
|
|
171
|
+
if not os.path.exists(path):
|
|
172
|
+
return f"Error: Path '{path}' does not exist"
|
|
173
|
+
if os.path.isdir(path):
|
|
174
|
+
return "\n".join(os.listdir(path))
|
|
175
|
+
with open(path) as f:
|
|
176
|
+
lines = f.read().splitlines()
|
|
177
|
+
if view_range:
|
|
178
|
+
start, end = view_range
|
|
179
|
+
start_idx = max(0, start - 1)
|
|
180
|
+
end_idx = len(lines) if end == -1 else min(len(lines), end)
|
|
181
|
+
lines = lines[start_idx:end_idx]
|
|
182
|
+
start_num = start_idx + 1
|
|
183
|
+
else:
|
|
184
|
+
start_num = 1
|
|
185
|
+
return "\n".join(f"{start_num + i}: {line}" for i, line in enumerate(lines))
|
|
186
|
+
elif command == "str_replace":
|
|
187
|
+
if old_str is None or new_str is None:
|
|
188
|
+
return "Error: str_replace requires both old_str and new_str parameters"
|
|
189
|
+
if not os.path.exists(path):
|
|
190
|
+
return f"Error: File '{path}' does not exist"
|
|
191
|
+
content = open(path).read()
|
|
192
|
+
if old_str not in content:
|
|
193
|
+
return "Error: Text not found in file"
|
|
194
|
+
count = content.count(old_str)
|
|
195
|
+
if count > 1:
|
|
196
|
+
return f"Error: Text appears {count} times in file. Please be more specific."
|
|
197
|
+
open(path, "w").write(content.replace(old_str, new_str, 1))
|
|
198
|
+
return f"Successfully replaced text in '{path}'"
|
|
199
|
+
elif command == "create":
|
|
200
|
+
if file_text is None:
|
|
201
|
+
return "Error: create requires file_text parameter"
|
|
202
|
+
os.makedirs(os.path.dirname(os.path.abspath(path)), exist_ok=True)
|
|
203
|
+
open(path, "w").write(file_text)
|
|
204
|
+
return f"Successfully created file '{path}'"
|
|
205
|
+
elif command == "insert":
|
|
206
|
+
if new_str is None or insert_line is None:
|
|
207
|
+
return "Error: insert requires both new_str and insert_line parameters"
|
|
208
|
+
if not os.path.exists(path):
|
|
209
|
+
return f"Error: File '{path}' does not exist"
|
|
210
|
+
lines = open(path).read().splitlines(True)
|
|
211
|
+
if insert_line == 0:
|
|
212
|
+
lines.insert(0, new_str + "\n")
|
|
213
|
+
elif insert_line >= len(lines):
|
|
214
|
+
lines.append(new_str + "\n")
|
|
215
|
+
else:
|
|
216
|
+
lines.insert(insert_line, new_str + "\n")
|
|
217
|
+
open(path, "w").write("".join(lines))
|
|
218
|
+
return f"Successfully inserted text in '{path}' at line {insert_line + 1}"
|
|
219
|
+
else:
|
|
220
|
+
return f"Error: Unknown command '{command}'"
|
|
221
|
+
except Exception as e:
|
|
222
|
+
return f"Error: {e}"
|
|
223
|
+
|
|
224
|
+
tools.append(file_operations)
|
|
225
|
+
{{/if}}
|
|
226
|
+
{{#if needsOs}}{{#unless isExportHarness}}
|
|
227
|
+
_MOUNT_PATHS = [
|
|
228
|
+
{{#if sessionStorageMountPath}}"{{sessionStorageMountPath}}",{{/if}}
|
|
229
|
+
{{#each efsMounts}}"{{mountPath}}",{{/each}}
|
|
230
|
+
{{#each s3Mounts}}"{{mountPath}}",{{/each}}
|
|
231
|
+
]
|
|
232
|
+
|
|
233
|
+
def _safe_resolve(path: str) -> str:
|
|
234
|
+
resolved = os.path.realpath(path)
|
|
235
|
+
if not any(resolved == os.path.realpath(m) or resolved.startswith(os.path.realpath(m) + os.sep) for m in _MOUNT_PATHS):
|
|
236
|
+
raise ValueError(f"Path '{path}' is not within any configured mount ({', '.join(_MOUNT_PATHS)})")
|
|
237
|
+
return resolved
|
|
238
|
+
|
|
239
|
+
@tool
|
|
240
|
+
def file_read(path: str) -> str:
|
|
241
|
+
"""Read a file from a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
242
|
+
try:
|
|
243
|
+
full_path = _safe_resolve(path)
|
|
244
|
+
with open(full_path) as f:
|
|
245
|
+
return f.read()
|
|
246
|
+
except ValueError as e:
|
|
247
|
+
return str(e)
|
|
248
|
+
except OSError as e:
|
|
249
|
+
return f"Error reading '{path}': {e.strerror}"
|
|
250
|
+
|
|
251
|
+
@tool
|
|
252
|
+
def file_write(path: str, content: str) -> str:
|
|
253
|
+
"""Write a file to a mounted filesystem. Use the absolute path (e.g. /mnt/tools/data.txt)."""
|
|
254
|
+
try:
|
|
255
|
+
full_path = _safe_resolve(path)
|
|
256
|
+
parent = os.path.dirname(full_path)
|
|
257
|
+
if parent:
|
|
258
|
+
os.makedirs(parent, exist_ok=True)
|
|
259
|
+
with open(full_path, "w") as f:
|
|
260
|
+
f.write(content)
|
|
261
|
+
return f"Written to {path}"
|
|
262
|
+
except ValueError as e:
|
|
263
|
+
return str(e)
|
|
264
|
+
except OSError as e:
|
|
265
|
+
return f"Error writing '{path}': {e.strerror}"
|
|
266
|
+
|
|
267
|
+
@tool
|
|
268
|
+
def list_files(path: str) -> str:
|
|
269
|
+
"""List files in a mounted filesystem directory. Use the absolute path (e.g. /mnt/tools)."""
|
|
270
|
+
try:
|
|
271
|
+
full_path = _safe_resolve(path)
|
|
272
|
+
entries = os.listdir(full_path)
|
|
273
|
+
return "\n".join(entries) if entries else "(empty directory)"
|
|
274
|
+
except ValueError as e:
|
|
275
|
+
return str(e)
|
|
276
|
+
except OSError as e:
|
|
277
|
+
return f"Error listing '{path}': {e.strerror}"
|
|
278
|
+
|
|
279
|
+
tools.extend([file_read, file_write, list_files])
|
|
280
|
+
{{/unless}}{{/if}}
|
|
281
|
+
|
|
282
|
+
{{#if remoteMcpTools}}
|
|
283
|
+
# Add MCP clients to tools
|
|
284
|
+
for mcp_client in mcp_clients:
|
|
285
|
+
if mcp_client:
|
|
286
|
+
tools.append(mcp_client)
|
|
287
|
+
{{else}}
|
|
288
|
+
{{#unless isExportHarness}}
|
|
289
|
+
# Add MCP client to tools if available
|
|
290
|
+
for mcp_client in mcp_clients:
|
|
291
|
+
if mcp_client:
|
|
292
|
+
tools.append(mcp_client)
|
|
293
|
+
{{/unless}}
|
|
294
|
+
{{/if}}
|
|
295
|
+
|
|
296
|
+
|
|
297
|
+
def _make_conversation_manager():
|
|
298
|
+
{{#if truncationStrategy}}
|
|
299
|
+
{{#if (eq truncationStrategy "sliding_window")}}
|
|
300
|
+
{{#if truncationConfig}}
|
|
301
|
+
return SlidingWindowConversationManager(**{{safeJson truncationConfig}}, per_turn=True)
|
|
302
|
+
{{else}}
|
|
303
|
+
return SlidingWindowConversationManager(per_turn=True)
|
|
304
|
+
{{/if}}
|
|
305
|
+
{{else}}
|
|
306
|
+
{{#if truncationConfig}}
|
|
307
|
+
return SummarizingConversationManager(**{{safeJson truncationConfig}})
|
|
308
|
+
{{else}}
|
|
309
|
+
return SummarizingConversationManager()
|
|
310
|
+
{{/if}}
|
|
311
|
+
{{/if}}
|
|
312
|
+
{{else}}
|
|
313
|
+
return NullConversationManager()
|
|
314
|
+
{{/if}}
|
|
315
|
+
|
|
316
|
+
{{#if hasMemory}}
|
|
317
|
+
def agent_factory():
|
|
318
|
+
cache = {}
|
|
319
|
+
def get_or_create_agent(session_id, user_id{{#if hasSkillsFetcher}}, skill_plugins=None{{/if}}):
|
|
320
|
+
{{#if actorId}}
|
|
321
|
+
_actor_id = "{{actorId}}"
|
|
322
|
+
{{else}}
|
|
323
|
+
_actor_id = user_id
|
|
324
|
+
{{/if}}
|
|
325
|
+
key = f"{session_id}/{_actor_id}"
|
|
326
|
+
if key not in cache:
|
|
327
|
+
cache[key] = Agent(
|
|
328
|
+
model=load_model(),
|
|
329
|
+
session_manager=get_memory_session_manager(session_id, _actor_id),
|
|
330
|
+
conversation_manager=_make_conversation_manager(),
|
|
331
|
+
system_prompt=DEFAULT_SYSTEM_PROMPT,
|
|
332
|
+
tools=tools,
|
|
333
|
+
{{#if hasSkillsFetcher}}
|
|
334
|
+
plugins=skill_plugins or None,
|
|
335
|
+
{{/if}}
|
|
336
|
+
hooks=[
|
|
337
|
+
],
|
|
338
|
+
)
|
|
339
|
+
return cache[key]
|
|
340
|
+
return get_or_create_agent
|
|
341
|
+
get_or_create_agent = agent_factory()
|
|
342
|
+
{{else}}
|
|
343
|
+
# Reuses one Agent per session_id so each session keeps its own in-process
|
|
344
|
+
# conversation history (best-effort; resets on cold start). The cache is bounded
|
|
345
|
+
# to 128 sessions with LRU eviction (least-recently-used is dropped and its
|
|
346
|
+
# history reset) so a single process serving many sessions cannot leak history
|
|
347
|
+
# between them or grow without limit. For durable history, attach a session manager.
|
|
348
|
+
def agent_factory():
|
|
349
|
+
cache = OrderedDict()
|
|
350
|
+
def get_or_create_agent(session_id{{#if hasSkillsFetcher}}, skill_plugins=None{{/if}}):
|
|
351
|
+
if session_id in cache:
|
|
352
|
+
cache.move_to_end(session_id)
|
|
353
|
+
return cache[session_id]
|
|
354
|
+
if len(cache) >= 128:
|
|
355
|
+
cache.popitem(last=False)
|
|
356
|
+
cache[session_id] = Agent(
|
|
357
|
+
model=load_model(),
|
|
358
|
+
system_prompt=DEFAULT_SYSTEM_PROMPT,
|
|
359
|
+
tools=tools,
|
|
360
|
+
conversation_manager=_make_conversation_manager(),
|
|
361
|
+
{{#if hasSkillsFetcher}}
|
|
362
|
+
plugins=skill_plugins or None,
|
|
363
|
+
{{/if}}
|
|
364
|
+
hooks=[
|
|
365
|
+
],
|
|
366
|
+
)
|
|
367
|
+
return cache[session_id]
|
|
368
|
+
return get_or_create_agent
|
|
369
|
+
get_or_create_agent = agent_factory()
|
|
370
|
+
{{/if}}
|
|
371
|
+
|
|
372
|
+
|
|
373
|
+
def strip_trailing_tool_use(messages: Any) -> list[dict]:
|
|
374
|
+
"""Strip toolUse blocks from the tail until the last message has none."""
|
|
375
|
+
if not isinstance(messages, list):
|
|
376
|
+
raise ValueError("messages must be a list")
|
|
377
|
+
|
|
378
|
+
messages = list(messages)
|
|
379
|
+
while messages:
|
|
380
|
+
last = messages[-1]
|
|
381
|
+
if not isinstance(last, dict):
|
|
382
|
+
raise ValueError("each message must be an object")
|
|
383
|
+
original_content = last.get("content", [])
|
|
384
|
+
if not isinstance(original_content, list) or not all(isinstance(block, dict) for block in original_content):
|
|
385
|
+
raise ValueError("each message content value must be a list of content blocks")
|
|
386
|
+
|
|
387
|
+
content = [block for block in original_content if "toolUse" not in block]
|
|
388
|
+
if len(content) == len(original_content):
|
|
389
|
+
break
|
|
390
|
+
if content:
|
|
391
|
+
messages[-1] = {**last, "content": content}
|
|
392
|
+
break
|
|
393
|
+
messages.pop()
|
|
394
|
+
|
|
395
|
+
return messages
|
|
396
|
+
|
|
397
|
+
|
|
398
|
+
def _extract_prompt(payload: dict):
|
|
399
|
+
"""Accept validated harness messages, tool results, or a plain prompt string."""
|
|
400
|
+
if not isinstance(payload, dict):
|
|
401
|
+
raise ValueError("payload must be a JSON object")
|
|
402
|
+
if "messages" in payload:
|
|
403
|
+
return strip_trailing_tool_use(payload["messages"])
|
|
404
|
+
if "tool_results" in payload:
|
|
405
|
+
tool_results = payload["tool_results"]
|
|
406
|
+
if not isinstance(tool_results, list) or not all(
|
|
407
|
+
isinstance(tool_result, dict) and isinstance(tool_result.get("toolUseId"), str)
|
|
408
|
+
for tool_result in tool_results
|
|
409
|
+
):
|
|
410
|
+
raise ValueError("tool_results must contain objects with a toolUseId string")
|
|
411
|
+
return [{"role": "user", "content": [{"toolResult": {
|
|
412
|
+
"toolUseId": tr["toolUseId"],
|
|
413
|
+
"status": tr.get("status", "success"),
|
|
414
|
+
"content": tr.get("content", []),
|
|
415
|
+
}} for tr in tool_results]}]
|
|
416
|
+
prompt = payload.get("prompt", "")
|
|
417
|
+
if not isinstance(prompt, str):
|
|
418
|
+
raise ValueError("prompt must be a string")
|
|
419
|
+
return prompt
|
|
420
|
+
|
|
421
|
+
|
|
422
|
+
def _has_inline_function_call(messages) -> bool:
|
|
423
|
+
"""Return True if messages contains an assistant toolUse for an inline function tool."""
|
|
424
|
+
if not _INLINE_FUNCTION_NAMES or not isinstance(messages, list):
|
|
425
|
+
return False
|
|
426
|
+
for msg in messages:
|
|
427
|
+
if msg.get("role") == "assistant":
|
|
428
|
+
for block in msg.get("content", []):
|
|
429
|
+
if isinstance(block, dict) and block.get("toolUse", {}).get("name") in _INLINE_FUNCTION_NAMES:
|
|
430
|
+
return True
|
|
431
|
+
return False
|
|
432
|
+
|
|
433
|
+
|
|
434
|
+
def _is_inline_function_call(event: dict) -> bool:
|
|
435
|
+
"""Check if a contentBlockStart event is for an inline function tool."""
|
|
436
|
+
if not _INLINE_FUNCTION_NAMES:
|
|
437
|
+
return False
|
|
438
|
+
cbs = event.get("contentBlockStart", {})
|
|
439
|
+
start = cbs.get("start", {})
|
|
440
|
+
tool_use = start.get("toolUse") if isinstance(start, dict) else None
|
|
441
|
+
return tool_use is not None and tool_use.get("name") in _INLINE_FUNCTION_NAMES
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
@app.entrypoint
|
|
446
|
+
async def invoke(payload, context):
|
|
447
|
+
log.info("Invoking Agent.....")
|
|
448
|
+
|
|
449
|
+
{{#if hasSkillsFetcher}}
|
|
450
|
+
skill_paths = []
|
|
451
|
+
{{#if s3Skills}}
|
|
452
|
+
s3_skill_sources = [{{#each s3Skills}}{{safeJson this}}{{#unless @last}}, {{/unless}}{{/each}}]
|
|
453
|
+
skill_paths.extend(await asyncio.to_thread(resolve_s3_skills, s3_skill_sources, None))
|
|
454
|
+
{{/if}}
|
|
455
|
+
{{#if gitSkills}}
|
|
456
|
+
git_skill_sources = [
|
|
457
|
+
{{#each gitSkills}}
|
|
458
|
+
dict(url={{safeJson this.url}}{{#if this.path}}, path={{safeJson this.path}}{{/if}}{{#if this.credentialArn}}, credentialArn={{safeJson this.credentialArn}}{{#if this.username}}, username={{safeJson this.username}}{{/if}}{{/if}}),
|
|
459
|
+
{{/each}}
|
|
460
|
+
]
|
|
461
|
+
{{#if (some gitSkills "credentialArn")}}
|
|
462
|
+
_git_identity_client = IdentityClient(os.environ.get("AWS_REGION", os.environ.get("AWS_DEFAULT_REGION", "us-east-1")))
|
|
463
|
+
{{else}}
|
|
464
|
+
_git_identity_client = None
|
|
465
|
+
{{/if}}
|
|
466
|
+
skill_paths.extend(await asyncio.to_thread(resolve_git_skills, git_skill_sources, _git_identity_client))
|
|
467
|
+
{{/if}}
|
|
468
|
+
_skill_plugins = [AgentSkills(skills=skill_paths)] if skill_paths else []
|
|
469
|
+
{{/if}}
|
|
470
|
+
|
|
471
|
+
{{#if hasMemory}}
|
|
472
|
+
session_id = getattr(context, 'session_id', 'default-session')
|
|
473
|
+
{{#if actorId}}
|
|
474
|
+
user_id = "{{actorId}}"
|
|
475
|
+
{{else}}
|
|
476
|
+
user_id = getattr(context, 'user_id', 'default-user')
|
|
477
|
+
{{/if}}
|
|
478
|
+
agent = get_or_create_agent(session_id, user_id{{#if hasSkillsFetcher}}, _skill_plugins{{/if}})
|
|
479
|
+
{{else}}
|
|
480
|
+
session_id = getattr(context, 'session_id', 'default-session')
|
|
481
|
+
agent = get_or_create_agent(session_id{{#if hasSkillsFetcher}}, _skill_plugins{{/if}})
|
|
482
|
+
{{/if}}
|
|
483
|
+
|
|
484
|
+
prompt = _extract_prompt(payload)
|
|
485
|
+
|
|
486
|
+
{{#if inlineFunctionTools}}
|
|
487
|
+
# If Turn 2 carries the harness-style assistant(toolUse)+user(toolResult) pair,
|
|
488
|
+
# strip the placeholder turn Strands stored during Turn 1 so the real toolResult
|
|
489
|
+
# is injected cleanly — same protocol as the harness runtime.
|
|
490
|
+
if _has_inline_function_call(prompt):
|
|
491
|
+
msgs = agent.messages
|
|
492
|
+
if len(msgs) >= 2 and any("toolResult" in b for b in msgs[-1].get("content", [])):
|
|
493
|
+
del msgs[-2:]
|
|
494
|
+
{{/if}}
|
|
495
|
+
|
|
496
|
+
{{#if hasExecutionLimits}}
|
|
497
|
+
limits = {
|
|
498
|
+
{{#if maxIterations}}"turns": {{maxIterations}},{{/if}}
|
|
499
|
+
{{#if maxTokens}}"output_tokens": {{maxTokens}},{{/if}}
|
|
500
|
+
} or None
|
|
501
|
+
cancel_signal = {{#if timeoutSeconds}}threading.Event(){{else}}None{{/if}}
|
|
502
|
+
timeout_fired = False
|
|
503
|
+
watchdog_task = None
|
|
504
|
+
{{#if timeoutSeconds}}
|
|
505
|
+
if cancel_signal is not None:
|
|
506
|
+
async def _timeout_watchdog():
|
|
507
|
+
nonlocal timeout_fired
|
|
508
|
+
await asyncio.sleep({{timeoutSeconds}})
|
|
509
|
+
timeout_fired = True
|
|
510
|
+
cancel_signal.set()
|
|
511
|
+
watchdog_task = asyncio.create_task(_timeout_watchdog())
|
|
512
|
+
{{/if}}
|
|
513
|
+
|
|
514
|
+
try:
|
|
515
|
+
stop_reason = None
|
|
516
|
+
{{#if inlineFunctionTools}}
|
|
517
|
+
hit_inline_function = False
|
|
518
|
+
{{/if}}
|
|
519
|
+
async for event in agent.stream_async(
|
|
520
|
+
prompt,
|
|
521
|
+
limits=limits,
|
|
522
|
+
cancel_signal=cancel_signal,
|
|
523
|
+
):
|
|
524
|
+
if isinstance(event, dict) and "result" in event:
|
|
525
|
+
stop_reason = getattr(event["result"], "stop_reason", None)
|
|
526
|
+
continue
|
|
527
|
+
if not isinstance(event, dict) or "event" not in event:
|
|
528
|
+
continue
|
|
529
|
+
cbs = event["event"].get("contentBlockStart")
|
|
530
|
+
if cbs is not None and not cbs.get("start"):
|
|
531
|
+
continue
|
|
532
|
+
{{#if inlineFunctionTools}}
|
|
533
|
+
if not hit_inline_function:
|
|
534
|
+
hit_inline_function = _is_inline_function_call(event["event"])
|
|
535
|
+
{{/if}}
|
|
536
|
+
yield event
|
|
537
|
+
{{#if inlineFunctionTools}}
|
|
538
|
+
if hit_inline_function and "messageStop" in event["event"]:
|
|
539
|
+
return
|
|
540
|
+
{{/if}}
|
|
541
|
+
|
|
542
|
+
if timeout_fired:
|
|
543
|
+
yield {"event": {"messageStop": {"stopReason": "timeout_exceeded"}}}
|
|
544
|
+
{{#if maxIterations}}
|
|
545
|
+
elif stop_reason == "limit_turns":
|
|
546
|
+
yield {"event": {"messageStop": {"stopReason": "Max iterations exceeded: {{maxIterations}}"}}}
|
|
547
|
+
{{/if}}
|
|
548
|
+
{{#if maxTokens}}
|
|
549
|
+
elif stop_reason == "limit_output_tokens":
|
|
550
|
+
yield {"event": {"messageStop": {"stopReason": "Max output tokens exceeded: {{maxTokens}}"}}}
|
|
551
|
+
{{/if}}
|
|
552
|
+
finally:
|
|
553
|
+
if watchdog_task is not None:
|
|
554
|
+
watchdog_task.cancel()
|
|
555
|
+
try:
|
|
556
|
+
await watchdog_task
|
|
557
|
+
except asyncio.CancelledError:
|
|
558
|
+
pass
|
|
559
|
+
{{else}}
|
|
560
|
+
{{#if inlineFunctionTools}}
|
|
561
|
+
hit_inline_function = False
|
|
562
|
+
{{/if}}
|
|
563
|
+
async for event in agent.stream_async(
|
|
564
|
+
prompt,
|
|
565
|
+
):
|
|
566
|
+
if not isinstance(event, dict) or "event" not in event:
|
|
567
|
+
continue
|
|
568
|
+
cbs = event["event"].get("contentBlockStart")
|
|
569
|
+
if cbs is not None and not cbs.get("start"):
|
|
570
|
+
continue
|
|
571
|
+
{{#if inlineFunctionTools}}
|
|
572
|
+
if not hit_inline_function:
|
|
573
|
+
hit_inline_function = _is_inline_function_call(event["event"])
|
|
574
|
+
{{/if}}
|
|
575
|
+
yield event
|
|
576
|
+
{{#if inlineFunctionTools}}
|
|
577
|
+
if hit_inline_function and "messageStop" in event["event"]:
|
|
578
|
+
return
|
|
579
|
+
{{/if}}
|
|
580
|
+
{{/if}}
|
|
581
|
+
|
|
582
|
+
|
|
583
|
+
if __name__ == "__main__":
|
|
584
|
+
app.run()
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
from mcp.client.streamable_http import streamablehttp_client
|
|
4
|
+
from strands.tools.mcp.mcp_client import MCPClient
|
|
5
|
+
|
|
6
|
+
logger = logging.getLogger(__name__)
|
|
7
|
+
|
|
8
|
+
{{#if remoteMcpTools}}
|
|
9
|
+
{{#if (some remoteMcpTools "headerCredentials")}}
|
|
10
|
+
from bedrock_agentcore.identity.auth import requires_api_key
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#each remoteMcpTools}}
|
|
13
|
+
{{#if headerCredentials}}
|
|
14
|
+
{{#each headerCredentials}}
|
|
15
|
+
@requires_api_key(provider_name="{{credentialName}}")
|
|
16
|
+
def _get_{{pythonName}}_key(api_key: str) -> str:
|
|
17
|
+
"""Fetch {{headerKey}} credential for {{../name}} from AgentCore Identity."""
|
|
18
|
+
return api_key
|
|
19
|
+
|
|
20
|
+
{{/each}}
|
|
21
|
+
{{/if}}
|
|
22
|
+
def get_{{pythonName}}_mcp_client() -> MCPClient | None:
|
|
23
|
+
"""Returns an MCP Client for the {{name}} remote MCP server."""
|
|
24
|
+
url = {{safeJson url}}
|
|
25
|
+
{{#if headerCredentials}}
|
|
26
|
+
def transport():
|
|
27
|
+
if os.getenv("LOCAL_DEV") == "1":
|
|
28
|
+
headers = { {{#each headerCredentials}}{{safeJson headerKey}}: os.environ.get("{{envVarName}}", ""){{#unless @last}}, {{/unless}}{{/each}} }
|
|
29
|
+
else:
|
|
30
|
+
headers = { {{#each headerCredentials}}{{safeJson headerKey}}: _get_{{pythonName}}_key(){{#unless @last}}, {{/unless}}{{/each}} }
|
|
31
|
+
return streamablehttp_client(url, headers=headers)
|
|
32
|
+
|
|
33
|
+
return MCPClient(transport)
|
|
34
|
+
{{else}}
|
|
35
|
+
return MCPClient(lambda: streamablehttp_client(url))
|
|
36
|
+
{{/if}}
|
|
37
|
+
|
|
38
|
+
{{/each}}
|
|
39
|
+
def get_all_remote_mcp_clients() -> list[MCPClient]:
|
|
40
|
+
"""Returns all configured remote MCP clients."""
|
|
41
|
+
clients = [{{#each remoteMcpTools}}get_{{pythonName}}_mcp_client(){{#unless @last}}, {{/unless}}{{/each}}]
|
|
42
|
+
return [c for c in clients if c is not None]
|
|
43
|
+
{{/if}}
|
|
44
|
+
{{#unless remoteMcpTools}}
|
|
45
|
+
{{#if isVpc}}
|
|
46
|
+
# VPC mode: external MCP endpoints are not reachable without a NAT gateway.
|
|
47
|
+
# Add an AgentCore Gateway with `agentcore add gateway`, or configure your own endpoint below.
|
|
48
|
+
|
|
49
|
+
def get_streamable_http_mcp_client() -> MCPClient | None:
|
|
50
|
+
"""No MCP server configured. Add a gateway with `agentcore add gateway`."""
|
|
51
|
+
return None
|
|
52
|
+
{{else}}
|
|
53
|
+
{{#unless isExportHarness}}
|
|
54
|
+
# ExaAI provides information about code through web searches, crawling and code context searches through their platform. Requires no authentication
|
|
55
|
+
EXAMPLE_MCP_ENDPOINT = "https://mcp.exa.ai/mcp"
|
|
56
|
+
|
|
57
|
+
def get_streamable_http_mcp_client() -> MCPClient:
|
|
58
|
+
"""Returns an MCP Client compatible with Strands"""
|
|
59
|
+
# to use an MCP server that supports bearer authentication, add headers={"Authorization": f"Bearer {access_token}"}
|
|
60
|
+
return MCPClient(lambda: streamablehttp_client(EXAMPLE_MCP_ENDPOINT))
|
|
61
|
+
{{/unless}}
|
|
62
|
+
{{/if}}
|
|
63
|
+
{{/unless}}
|
|
File without changes
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import uuid
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from bedrock_agentcore.memory.integrations.strands.config import AgentCoreMemoryConfig{{#if memoryStrategies.length}}, RetrievalConfig{{/if}}
|
|
6
|
+
from bedrock_agentcore.memory.integrations.strands.session_manager import AgentCoreMemorySessionManager
|
|
7
|
+
|
|
8
|
+
MEMORY_ID = os.getenv("{{memoryEnvVarName}}")
|
|
9
|
+
REGION = os.getenv("AWS_REGION")
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def get_memory_session_manager(
|
|
13
|
+
session_id: Optional[str], actor_id: str
|
|
14
|
+
) -> Optional[AgentCoreMemorySessionManager]:
|
|
15
|
+
if not MEMORY_ID:
|
|
16
|
+
return None
|
|
17
|
+
|
|
18
|
+
session_id = session_id or uuid.uuid4().hex
|
|
19
|
+
|
|
20
|
+
{{#if memoryStrategies.length}}
|
|
21
|
+
retrieval_config = {
|
|
22
|
+
{{#if (includes memoryStrategies "SEMANTIC")}}
|
|
23
|
+
f"/users/{actor_id}/facts": RetrievalConfig(top_k={{#if memoryRetrievalTopK}}{{memoryRetrievalTopK}}{{else}}3{{/if}}, relevance_score={{#if memoryRetrievalRelevanceScore}}{{memoryRetrievalRelevanceScore}}{{else}}0.5{{/if}}),
|
|
24
|
+
{{/if}}
|
|
25
|
+
{{#if (includes memoryStrategies "USER_PREFERENCE")}}
|
|
26
|
+
f"/users/{actor_id}/preferences": RetrievalConfig(top_k={{#if memoryRetrievalTopK}}{{memoryRetrievalTopK}}{{else}}3{{/if}}, relevance_score={{#if memoryRetrievalRelevanceScore}}{{memoryRetrievalRelevanceScore}}{{else}}0.5{{/if}}),
|
|
27
|
+
{{/if}}
|
|
28
|
+
{{#if (includes memoryStrategies "EPISODIC")}}
|
|
29
|
+
f"/episodes/{actor_id}/{session_id}": RetrievalConfig(top_k={{#if memoryRetrievalTopK}}{{memoryRetrievalTopK}}{{else}}5{{/if}}, relevance_score={{#if memoryRetrievalRelevanceScore}}{{memoryRetrievalRelevanceScore}}{{else}}0.5{{/if}}),
|
|
30
|
+
{{/if}}
|
|
31
|
+
{{#if (includes memoryStrategies "SUMMARIZATION")}}
|
|
32
|
+
f"/summaries/{actor_id}": RetrievalConfig(top_k={{#if memoryRetrievalTopK}}{{memoryRetrievalTopK}}{{else}}3{{/if}}, relevance_score={{#if memoryRetrievalRelevanceScore}}{{memoryRetrievalRelevanceScore}}{{else}}0.5{{/if}}),
|
|
33
|
+
{{/if}}
|
|
34
|
+
}
|
|
35
|
+
{{/if}}
|
|
36
|
+
|
|
37
|
+
return AgentCoreMemorySessionManager(
|
|
38
|
+
AgentCoreMemoryConfig(
|
|
39
|
+
memory_id=MEMORY_ID,
|
|
40
|
+
session_id=session_id,
|
|
41
|
+
actor_id=actor_id,
|
|
42
|
+
{{#if memoryStrategies.length}}
|
|
43
|
+
retrieval_config=retrieval_config,
|
|
44
|
+
{{/if}}
|
|
45
|
+
),
|
|
46
|
+
REGION,
|
|
47
|
+
)
|