agentcore-cli 0.31.1__py3-none-any.whl
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.
- agentcore/__init__.py +1 -0
- agentcore/agent_inspector/NOTICE +9 -0
- agentcore/agent_inspector/favicon.svg +60 -0
- agentcore/agent_inspector/index.css +1 -0
- agentcore/agent_inspector/index.html +14 -0
- agentcore/agent_inspector/index.js +289 -0
- agentcore/assets/AGENTS.md +60 -0
- agentcore/assets/README.md +108 -0
- agentcore/assets/agents/AGENTS.md +218 -0
- agentcore/assets/cdk/.prettierrc +8 -0
- agentcore/assets/cdk/README.md +26 -0
- agentcore/assets/cdk/bin/cdk.ts +216 -0
- agentcore/assets/cdk/cdk.json +88 -0
- agentcore/assets/cdk/gitignore.template +9 -0
- agentcore/assets/cdk/jest.config.js +9 -0
- agentcore/assets/cdk/lib/cdk-stack.ts +291 -0
- agentcore/assets/cdk/npmignore.template +6 -0
- agentcore/assets/cdk/package.json +30 -0
- agentcore/assets/cdk/test/cdk.test.ts +31 -0
- agentcore/assets/cdk/tsconfig.json +28 -0
- agentcore/assets/container/python/Dockerfile +47 -0
- agentcore/assets/container/python/dockerignore.template +27 -0
- agentcore/assets/container/typescript/Dockerfile +25 -0
- agentcore/assets/container/typescript/dockerignore.template +24 -0
- agentcore/assets/datasets/predefined-v1.jsonl +3 -0
- agentcore/assets/datasets/simulated-v1.jsonl +3 -0
- agentcore/assets/evaluators/autoevals-lambda/execution-role-policy.json +15 -0
- agentcore/assets/evaluators/autoevals-lambda/lambda_function.py +37 -0
- agentcore/assets/evaluators/autoevals-lambda/pyproject.toml +22 -0
- agentcore/assets/evaluators/deepeval-lambda/execution-role-policy.json +15 -0
- agentcore/assets/evaluators/deepeval-lambda/lambda_function.py +29 -0
- agentcore/assets/evaluators/deepeval-lambda/pyproject.toml +19 -0
- agentcore/assets/evaluators/python-lambda/execution-role-policy.json +10 -0
- agentcore/assets/evaluators/python-lambda/lambda_function.py +19 -0
- agentcore/assets/evaluators/python-lambda/pyproject.toml +15 -0
- agentcore/assets/harness/invoke.py.template +74 -0
- agentcore/assets/mcp/python/README.md +27 -0
- agentcore/assets/mcp/python/pyproject.toml +22 -0
- agentcore/assets/mcp/python/server.py +117 -0
- agentcore/assets/mcp/python-lambda/README.md +22 -0
- agentcore/assets/mcp/python-lambda/handler.py +144 -0
- agentcore/assets/mcp/python-lambda/pyproject.toml +15 -0
- agentcore/assets/python/a2a/googleadk/base/README.md +22 -0
- agentcore/assets/python/a2a/googleadk/base/gitignore.template +41 -0
- agentcore/assets/python/a2a/googleadk/base/main.py +124 -0
- agentcore/assets/python/a2a/googleadk/base/model/__init__.py +1 -0
- agentcore/assets/python/a2a/googleadk/base/model/load.py +41 -0
- agentcore/assets/python/a2a/googleadk/base/pyproject.toml +22 -0
- agentcore/assets/python/a2a/langchain_langgraph/base/README.md +22 -0
- agentcore/assets/python/a2a/langchain_langgraph/base/gitignore.template +41 -0
- agentcore/assets/python/a2a/langchain_langgraph/base/main.py +144 -0
- agentcore/assets/python/a2a/langchain_langgraph/base/model/__init__.py +1 -0
- agentcore/assets/python/a2a/langchain_langgraph/base/model/load.py +123 -0
- agentcore/assets/python/a2a/langchain_langgraph/base/pyproject.toml +26 -0
- agentcore/assets/python/a2a/strands/base/README.md +22 -0
- agentcore/assets/python/a2a/strands/base/gitignore.template +41 -0
- agentcore/assets/python/a2a/strands/base/main.py +113 -0
- agentcore/assets/python/a2a/strands/base/model/__init__.py +1 -0
- agentcore/assets/python/a2a/strands/base/model/load.py +123 -0
- agentcore/assets/python/a2a/strands/base/pyproject.toml +23 -0
- agentcore/assets/python/a2a/strands/capabilities/memory/__init__.py +1 -0
- agentcore/assets/python/a2a/strands/capabilities/memory/session.py +46 -0
- agentcore/assets/python/agui/googleadk/base/README.md +30 -0
- agentcore/assets/python/agui/googleadk/base/gitignore.template +41 -0
- agentcore/assets/python/agui/googleadk/base/main.py +91 -0
- agentcore/assets/python/agui/googleadk/base/model/__init__.py +1 -0
- agentcore/assets/python/agui/googleadk/base/model/load.py +41 -0
- agentcore/assets/python/agui/googleadk/base/pyproject.toml +25 -0
- agentcore/assets/python/agui/langchain_langgraph/base/README.md +22 -0
- agentcore/assets/python/agui/langchain_langgraph/base/gitignore.template +41 -0
- agentcore/assets/python/agui/langchain_langgraph/base/main.py +130 -0
- agentcore/assets/python/agui/langchain_langgraph/base/model/__init__.py +1 -0
- agentcore/assets/python/agui/langchain_langgraph/base/model/load.py +123 -0
- agentcore/assets/python/agui/langchain_langgraph/base/pyproject.toml +31 -0
- agentcore/assets/python/agui/strands/base/README.md +22 -0
- agentcore/assets/python/agui/strands/base/gitignore.template +41 -0
- agentcore/assets/python/agui/strands/base/main.py +105 -0
- agentcore/assets/python/agui/strands/base/model/__init__.py +1 -0
- agentcore/assets/python/agui/strands/base/model/load.py +123 -0
- agentcore/assets/python/agui/strands/base/pyproject.toml +27 -0
- agentcore/assets/python/agui/strands/capabilities/memory/__init__.py +1 -0
- agentcore/assets/python/agui/strands/capabilities/memory/session.py +46 -0
- agentcore/assets/python/http/autogen/base/README.md +45 -0
- agentcore/assets/python/http/autogen/base/gitignore.template +41 -0
- agentcore/assets/python/http/autogen/base/main.py +145 -0
- agentcore/assets/python/http/autogen/base/mcp_client/__init__.py +1 -0
- agentcore/assets/python/http/autogen/base/mcp_client/client.py +28 -0
- agentcore/assets/python/http/autogen/base/model/__init__.py +1 -0
- agentcore/assets/python/http/autogen/base/model/load.py +136 -0
- agentcore/assets/python/http/autogen/base/pyproject.toml +34 -0
- agentcore/assets/python/http/bma/base/Dockerfile +41 -0
- agentcore/assets/python/http/bma/base/README.md +178 -0
- agentcore/assets/python/http/bma/base/client.py +200 -0
- agentcore/assets/python/http/bma/base/lifecycle/server.py +641 -0
- agentcore/assets/python/http/bma/base/otel/collector.yaml +69 -0
- agentcore/assets/python/http/bma/base/plugins/acr-report/.codex-plugin/plugin.json +6 -0
- agentcore/assets/python/http/bma/base/plugins/acr-report/skills/acr-report/SKILL.md +16 -0
- agentcore/assets/python/http/bma/base/policies/bma-acr-policy.json +11 -0
- agentcore/assets/python/http/bma/base/policies/bma-session-policy.json +35 -0
- agentcore/assets/python/http/bma/base/policies/bma-session-trust.json +20 -0
- agentcore/assets/python/http/bma/base/pyproject.toml +21 -0
- agentcore/assets/python/http/googleadk/base/README.md +45 -0
- agentcore/assets/python/http/googleadk/base/gitignore.template +41 -0
- agentcore/assets/python/http/googleadk/base/main.py +207 -0
- agentcore/assets/python/http/googleadk/base/mcp_client/__init__.py +1 -0
- agentcore/assets/python/http/googleadk/base/mcp_client/client.py +75 -0
- agentcore/assets/python/http/googleadk/base/model/__init__.py +1 -0
- agentcore/assets/python/http/googleadk/base/model/load.py +41 -0
- agentcore/assets/python/http/googleadk/base/pyproject.toml +24 -0
- agentcore/assets/python/http/langchain_langgraph/base/README.md +45 -0
- agentcore/assets/python/http/langchain_langgraph/base/gitignore.template +41 -0
- agentcore/assets/python/http/langchain_langgraph/base/main.py +227 -0
- agentcore/assets/python/http/langchain_langgraph/base/mcp_client/__init__.py +1 -0
- agentcore/assets/python/http/langchain_langgraph/base/mcp_client/client.py +79 -0
- agentcore/assets/python/http/langchain_langgraph/base/model/__init__.py +1 -0
- agentcore/assets/python/http/langchain_langgraph/base/model/load.py +123 -0
- agentcore/assets/python/http/langchain_langgraph/base/pyproject.toml +38 -0
- agentcore/assets/python/http/openaiagents/base/README.md +45 -0
- agentcore/assets/python/http/openaiagents/base/gitignore.template +41 -0
- agentcore/assets/python/http/openaiagents/base/main.py +200 -0
- agentcore/assets/python/http/openaiagents/base/mcp_client/__init__.py +1 -0
- agentcore/assets/python/http/openaiagents/base/mcp_client/client.py +74 -0
- agentcore/assets/python/http/openaiagents/base/model/__init__.py +1 -0
- agentcore/assets/python/http/openaiagents/base/model/load.py +37 -0
- agentcore/assets/python/http/openaiagents/base/pyproject.toml +21 -0
- agentcore/assets/python/http/strands/base/README.md +46 -0
- agentcore/assets/python/http/strands/base/gitignore.template +41 -0
- agentcore/assets/python/http/strands/base/main.py +714 -0
- agentcore/assets/python/http/strands/base/mcp_client/__init__.py +1 -0
- agentcore/assets/python/http/strands/base/mcp_client/client.py +116 -0
- agentcore/assets/python/http/strands/base/model/__init__.py +1 -0
- agentcore/assets/python/http/strands/base/model/load.py +239 -0
- agentcore/assets/python/http/strands/base/model/mantle_compat.py +21 -0
- agentcore/assets/python/http/strands/base/pyproject.toml +31 -0
- agentcore/assets/python/http/strands/base/skills/fetcher.py +279 -0
- agentcore/assets/python/http/strands/capabilities/execution-limits/hooks/execution_limits.py +54 -0
- agentcore/assets/python/http/strands/capabilities/memory/__init__.py +1 -0
- agentcore/assets/python/http/strands/capabilities/memory/session.py +47 -0
- agentcore/assets/python/http/strands/capabilities/payments/__init__.py +4 -0
- agentcore/assets/python/http/strands/capabilities/payments/payments.py +142 -0
- agentcore/assets/python/mcp/standalone/base/README.md +36 -0
- agentcore/assets/python/mcp/standalone/base/gitignore.template +41 -0
- agentcore/assets/python/mcp/standalone/base/main.py +83 -0
- agentcore/assets/python/mcp/standalone/base/pyproject.toml +16 -0
- agentcore/assets/typescript/.gitkeep +0 -0
- agentcore/assets/typescript/http/strands/base/README.md +42 -0
- agentcore/assets/typescript/http/strands/base/gitignore.template +22 -0
- agentcore/assets/typescript/http/strands/base/main.ts +149 -0
- agentcore/assets/typescript/http/strands/base/mcp_client/client.ts +11 -0
- agentcore/assets/typescript/http/strands/base/model/load.ts +102 -0
- agentcore/assets/typescript/http/strands/base/package.json +38 -0
- agentcore/assets/typescript/http/strands/base/tsconfig.json +19 -0
- agentcore/assets/typescript/http/strands/capabilities/memory/memory.ts +52 -0
- agentcore/assets/typescript/http/vercelai/base/README.md +42 -0
- agentcore/assets/typescript/http/vercelai/base/gitignore.template +22 -0
- agentcore/assets/typescript/http/vercelai/base/main.ts +70 -0
- agentcore/assets/typescript/http/vercelai/base/model/load.ts +121 -0
- agentcore/assets/typescript/http/vercelai/base/package.json +35 -0
- agentcore/assets/typescript/http/vercelai/base/tsconfig.json +19 -0
- agentcore/aws/__init__.py +263 -0
- agentcore/aws/_aws_errors.py +72 -0
- agentcore/aws/_http.py +176 -0
- agentcore/aws/_util.py +37 -0
- agentcore/aws/account.py +165 -0
- agentcore/aws/agentcore.py +971 -0
- agentcore/aws/agentcore_ab_tests.py +230 -0
- agentcore/aws/agentcore_batch_evaluation.py +227 -0
- agentcore/aws/agentcore_config_bundles.py +220 -0
- agentcore/aws/agentcore_control.py +994 -0
- agentcore/aws/agentcore_datasets.py +222 -0
- agentcore/aws/agentcore_harness.py +330 -0
- agentcore/aws/agentcore_payments.py +430 -0
- agentcore/aws/agentcore_recommendation.py +140 -0
- agentcore/aws/agui_parser.py +131 -0
- agentcore/aws/agui_types.py +342 -0
- agentcore/aws/api_client.py +87 -0
- agentcore/aws/arn.py +18 -0
- agentcore/aws/aws_context.py +23 -0
- agentcore/aws/bedrock.py +44 -0
- agentcore/aws/bedrock_agent.py +129 -0
- agentcore/aws/bedrock_import.py +252 -0
- agentcore/aws/bedrock_import_types.py +111 -0
- agentcore/aws/cloudwatch.py +136 -0
- agentcore/aws/connect_shell.py +266 -0
- agentcore/aws/iam.py +41 -0
- agentcore/aws/partition.py +58 -0
- agentcore/aws/policy_generation.py +116 -0
- agentcore/aws/region.py +54 -0
- agentcore/aws/retry.py +27 -0
- agentcore/aws/shell_framer.py +136 -0
- agentcore/aws/stage_endpoint.py +39 -0
- agentcore/aws/target_region.py +54 -0
- agentcore/aws/transaction_search.py +97 -0
- agentcore/cdk/__init__.py +10 -0
- agentcore/cdk/constants.py +13 -0
- agentcore/cdk/local_cdk_project.py +48 -0
- agentcore/cdk/toolkit.py +706 -0
- agentcore/cli/__init__.py +0 -0
- agentcore/cli/commands/__init__.py +0 -0
- agentcore/cli/commands/_jobs_common.py +39 -0
- agentcore/cli/commands/_run_wizards.py +639 -0
- agentcore/cli/commands/add/__init__.py +37 -0
- agentcore/cli/commands/add/_commander.py +52 -0
- agentcore/cli/commands/add/_common.py +47 -0
- agentcore/cli/commands/add/agent_wizard.py +528 -0
- agentcore/cli/commands/add/auth_options.py +154 -0
- agentcore/cli/commands/add/skill_action.py +105 -0
- agentcore/cli/commands/add/skill_command.py +87 -0
- agentcore/cli/commands/add/tool_action.py +160 -0
- agentcore/cli/commands/add/tool_command.py +117 -0
- agentcore/cli/commands/add/validate.py +333 -0
- agentcore/cli/commands/capacity_provider/__init__.py +86 -0
- agentcore/cli/commands/capacity_provider/action.py +114 -0
- agentcore/cli/commands/capacity_provider/constants.py +22 -0
- agentcore/cli/commands/config.py +91 -0
- agentcore/cli/commands/config_bundle.py +251 -0
- agentcore/cli/commands/create/__init__.py +643 -0
- agentcore/cli/commands/create/action.py +406 -0
- agentcore/cli/commands/create/dependencies.py +91 -0
- agentcore/cli/commands/create/harness_validate.py +82 -0
- agentcore/cli/commands/create/validate.py +195 -0
- agentcore/cli/commands/create/wizard.py +127 -0
- agentcore/cli/commands/dataset.py +119 -0
- agentcore/cli/commands/deploy/__init__.py +31 -0
- agentcore/cli/commands/deploy/_guards.py +25 -0
- agentcore/cli/commands/deploy/actions.py +840 -0
- agentcore/cli/commands/deploy/command.py +349 -0
- agentcore/cli/commands/deploy/progress.py +115 -0
- agentcore/cli/commands/deploy/types.py +68 -0
- agentcore/cli/commands/deploy/utils.py +43 -0
- agentcore/cli/commands/deploy/validate.py +21 -0
- agentcore/cli/commands/dev/__init__.py +5 -0
- agentcore/cli/commands/dev/_deps.py +50 -0
- agentcore/cli/commands/dev/browser_mode.py +270 -0
- agentcore/cli/commands/dev/command.py +450 -0
- agentcore/cli/commands/dev/terminal_mode.py +379 -0
- agentcore/cli/commands/exec/__init__.py +29 -0
- agentcore/cli/commands/exec/action.py +442 -0
- agentcore/cli/commands/exec/command.py +206 -0
- agentcore/cli/commands/exec/types.py +35 -0
- agentcore/cli/commands/export/__init__.py +114 -0
- agentcore/cli/commands/export/constants.py +21 -0
- agentcore/cli/commands/export/fetch_harness_spec.py +234 -0
- agentcore/cli/commands/export/harness_action.py +385 -0
- agentcore/cli/commands/export/harness_mapper.py +868 -0
- agentcore/cli/commands/export/harness_resolver.py +95 -0
- agentcore/cli/commands/export/types.py +90 -0
- agentcore/cli/commands/export/wizard.py +97 -0
- agentcore/cli/commands/feedback/__init__.py +69 -0
- agentcore/cli/commands/feedback/action.py +30 -0
- agentcore/cli/commands/feedback/consent_prompt.py +35 -0
- agentcore/cli/commands/feedback/wizard.py +49 -0
- agentcore/cli/commands/fetch/__init__.py +69 -0
- agentcore/cli/commands/fetch/action.py +62 -0
- agentcore/cli/commands/help.py +65 -0
- agentcore/cli/commands/import_/__init__.py +167 -0
- agentcore/cli/commands/import_/_js.py +72 -0
- agentcore/cli/commands/import_/actions.py +457 -0
- agentcore/cli/commands/import_/constants.py +45 -0
- agentcore/cli/commands/import_/import_evaluator.py +140 -0
- agentcore/cli/commands/import_/import_gateway.py +520 -0
- agentcore/cli/commands/import_/import_memory.py +128 -0
- agentcore/cli/commands/import_/import_online_eval.py +165 -0
- agentcore/cli/commands/import_/import_pipeline.py +145 -0
- agentcore/cli/commands/import_/import_runtime.py +214 -0
- agentcore/cli/commands/import_/import_utils.py +410 -0
- agentcore/cli/commands/import_/phase1_update.py +110 -0
- agentcore/cli/commands/import_/phase2_import.py +206 -0
- agentcore/cli/commands/import_/resource_import.py +228 -0
- agentcore/cli/commands/import_/template_utils.py +148 -0
- agentcore/cli/commands/import_/types.py +150 -0
- agentcore/cli/commands/import_/yaml_parser.py +265 -0
- agentcore/cli/commands/init.py +196 -0
- agentcore/cli/commands/invoke/__init__.py +32 -0
- agentcore/cli/commands/invoke/_deps.py +73 -0
- agentcore/cli/commands/invoke/action.py +840 -0
- agentcore/cli/commands/invoke/command.py +490 -0
- agentcore/cli/commands/invoke/constants.py +40 -0
- agentcore/cli/commands/invoke/guards.py +23 -0
- agentcore/cli/commands/invoke/interactive.py +604 -0
- agentcore/cli/commands/invoke/resolve.py +149 -0
- agentcore/cli/commands/invoke/resolve_prompt.py +60 -0
- agentcore/cli/commands/invoke/types.py +61 -0
- agentcore/cli/commands/invoke/validate.py +33 -0
- agentcore/cli/commands/job_actions.py +239 -0
- agentcore/cli/commands/job_history.py +380 -0
- agentcore/cli/commands/logs/__init__.py +53 -0
- agentcore/cli/commands/logs/action.py +159 -0
- agentcore/cli/commands/logs/filter_pattern.py +17 -0
- agentcore/cli/commands/logs/guards.py +51 -0
- agentcore/cli/commands/logs_evals.py +42 -0
- agentcore/cli/commands/package.py +118 -0
- agentcore/cli/commands/remove/__init__.py +172 -0
- agentcore/cli/commands/remove/skill_command.py +131 -0
- agentcore/cli/commands/remove/tool_command.py +59 -0
- agentcore/cli/commands/run.py +808 -0
- agentcore/cli/commands/run_ingest.py +97 -0
- agentcore/cli/commands/shared/__init__.py +0 -0
- agentcore/cli/commands/shared/arn_utils.py +9 -0
- agentcore/cli/commands/shared/filesystem_utils.py +421 -0
- agentcore/cli/commands/shared/header_utils.py +87 -0
- agentcore/cli/commands/shared/indexed_key_parser.py +76 -0
- agentcore/cli/commands/shared/lifecycle_utils.py +72 -0
- agentcore/cli/commands/shared/region_utils.py +20 -0
- agentcore/cli/commands/shared/vpc_utils.py +99 -0
- agentcore/cli/commands/status/__init__.py +30 -0
- agentcore/cli/commands/status/_guards.py +25 -0
- agentcore/cli/commands/status/action.py +741 -0
- agentcore/cli/commands/status/command.py +321 -0
- agentcore/cli/commands/status/constants.py +36 -0
- agentcore/cli/commands/status/format_knowledge_base.py +111 -0
- agentcore/cli/commands/telemetry.py +79 -0
- agentcore/cli/commands/traces/__init__.py +155 -0
- agentcore/cli/commands/traces/action.py +123 -0
- agentcore/cli/commands/update/__init__.py +63 -0
- agentcore/cli/commands/update/action.py +164 -0
- agentcore/cli/commands/validate.py +165 -0
- agentcore/cli/constants.py +96 -0
- agentcore/cli/errors.py +118 -0
- agentcore/cli/external_requirements/__init__.py +67 -0
- agentcore/cli/external_requirements/checks.py +280 -0
- agentcore/cli/external_requirements/detect.py +55 -0
- agentcore/cli/external_requirements/versions.py +57 -0
- agentcore/cli/groups.py +23 -0
- agentcore/cli/interactive.py +85 -0
- agentcore/cli/main.py +137 -0
- agentcore/cli/naming.py +11 -0
- agentcore/cli/notices.py +42 -0
- agentcore/cli/project.py +34 -0
- agentcore/cli/run_command.py +27 -0
- agentcore/cli/tree.py +135 -0
- agentcore/cli/update_notifier.py +123 -0
- agentcore/cli/variadic.py +50 -0
- agentcore/cloudformation/__init__.py +84 -0
- agentcore/cloudformation/bootstrap.py +64 -0
- agentcore/cloudformation/logical_ids.py +37 -0
- agentcore/cloudformation/outputs.py +566 -0
- agentcore/cloudformation/stack_discovery.py +75 -0
- agentcore/cloudformation/stack_events.py +107 -0
- agentcore/cloudformation/stack_status.py +98 -0
- agentcore/cloudformation/types.py +44 -0
- agentcore/lib/__init__.py +68 -0
- agentcore/lib/constants.py +77 -0
- agentcore/lib/dependency_management/__init__.py +23 -0
- agentcore/lib/dependency_management/messages.py +92 -0
- agentcore/lib/dependency_management/plan.py +98 -0
- agentcore/lib/dependency_management/semver.py +137 -0
- agentcore/lib/dependency_management/sync.py +139 -0
- agentcore/lib/dependency_management/types.py +56 -0
- agentcore/lib/errors/__init__.py +5 -0
- agentcore/lib/errors/types.py +352 -0
- agentcore/lib/errors/validation.py +121 -0
- agentcore/lib/packaging/__init__.py +81 -0
- agentcore/lib/packaging/build_args.py +23 -0
- agentcore/lib/packaging/build_context.py +26 -0
- agentcore/lib/packaging/build_context_dockerignore.py +45 -0
- agentcore/lib/packaging/container.py +95 -0
- agentcore/lib/packaging/helpers.py +289 -0
- agentcore/lib/packaging/node.py +153 -0
- agentcore/lib/packaging/python.py +135 -0
- agentcore/lib/packaging/types.py +69 -0
- agentcore/lib/packaging/uv.py +45 -0
- agentcore/lib/result.py +104 -0
- agentcore/lib/schemas/__init__.py +1 -0
- agentcore/lib/schemas/io/__init__.py +27 -0
- agentcore/lib/schemas/io/config_io.py +458 -0
- agentcore/lib/schemas/io/global_config.py +239 -0
- agentcore/lib/schemas/io/path_resolver.py +132 -0
- agentcore/lib/secrets/__init__.py +18 -0
- agentcore/lib/secrets/cipher.py +70 -0
- agentcore/lib/secrets/key_provider.py +163 -0
- agentcore/lib/secrets/sensitive_keys.py +55 -0
- agentcore/lib/time_constants.py +4 -0
- agentcore/lib/utils/__init__.py +47 -0
- agentcore/lib/utils/aws_account.py +15 -0
- agentcore/lib/utils/credentials.py +68 -0
- agentcore/lib/utils/dotenv.py +32 -0
- agentcore/lib/utils/env.py +105 -0
- agentcore/lib/utils/json_format.py +29 -0
- agentcore/lib/utils/json_rpc.py +22 -0
- agentcore/lib/utils/platform.py +33 -0
- agentcore/lib/utils/polling.py +86 -0
- agentcore/lib/utils/subprocess.py +135 -0
- agentcore/lib/utils/time_parser.py +48 -0
- agentcore/lib/utils/validation.py +106 -0
- agentcore/logging/__init__.py +10 -0
- agentcore/logging/_common.py +77 -0
- agentcore/logging/cdk_io_host.py +36 -0
- agentcore/logging/create_logger.py +107 -0
- agentcore/logging/dev_logger.py +63 -0
- agentcore/logging/exec_logger.py +159 -0
- agentcore/logging/invoke_logger.py +154 -0
- agentcore/logging/remove_logger.py +95 -0
- agentcore/operations/__init__.py +0 -0
- agentcore/operations/agent/__init__.py +0 -0
- agentcore/operations/agent/config_bundle_defaults.py +31 -0
- agentcore/operations/agent/generate/__init__.py +28 -0
- agentcore/operations/agent/generate/schema_mapper.py +319 -0
- agentcore/operations/agent/generate/types.py +172 -0
- agentcore/operations/agent/generate/write_agent_to_project.py +67 -0
- agentcore/operations/agent/import_/__init__.py +31 -0
- agentcore/operations/agent/import_/base_translator.py +449 -0
- agentcore/operations/agent/import_/constants.py +23 -0
- agentcore/operations/agent/import_/execute.py +127 -0
- agentcore/operations/agent/import_/langgraph_translator.py +294 -0
- agentcore/operations/agent/import_/pyproject_generator.py +73 -0
- agentcore/operations/agent/import_/strands_translator.py +289 -0
- agentcore/operations/config_bundle/__init__.py +1 -0
- agentcore/operations/config_bundle/bundle_name_variants.py +9 -0
- agentcore/operations/config_bundle/diff_versions.py +52 -0
- agentcore/operations/config_bundle/resolve_bundle.py +65 -0
- agentcore/operations/connectors/__init__.py +3 -0
- agentcore/operations/connectors/translators.py +63 -0
- agentcore/operations/dataset/__init__.py +21 -0
- agentcore/operations/dataset/delete.py +7 -0
- agentcore/operations/dataset/publish.py +16 -0
- agentcore/operations/dataset/pull.py +21 -0
- agentcore/operations/dataset/push.py +201 -0
- agentcore/operations/dataset/resolve_dataset.py +65 -0
- agentcore/operations/dataset/status.py +18 -0
- agentcore/operations/dataset/wait.py +25 -0
- agentcore/operations/deploy/__init__.py +152 -0
- agentcore/operations/deploy/backfill_vpc_id.py +90 -0
- agentcore/operations/deploy/change_detection.py +84 -0
- agentcore/operations/deploy/constants.py +58 -0
- agentcore/operations/deploy/dependency_sync.py +105 -0
- agentcore/operations/deploy/ensure_target.py +30 -0
- agentcore/operations/deploy/gateway_status.py +44 -0
- agentcore/operations/deploy/managed_memory_notice.py +36 -0
- agentcore/operations/deploy/payment_connector_authorization.py +106 -0
- agentcore/operations/deploy/post_deploy_datasets.py +96 -0
- agentcore/operations/deploy/post_deploy_knowledge_bases.py +104 -0
- agentcore/operations/deploy/post_deploy_observability.py +28 -0
- agentcore/operations/deploy/post_deploy_online_evals.py +60 -0
- agentcore/operations/deploy/pre_deploy_identity.py +505 -0
- agentcore/operations/deploy/preflight.py +385 -0
- agentcore/operations/deploy/region_override.py +45 -0
- agentcore/operations/deploy/teardown.py +153 -0
- agentcore/operations/dev/__init__.py +61 -0
- agentcore/operations/dev/_http.py +79 -0
- agentcore/operations/dev/_server.py +165 -0
- agentcore/operations/dev/codezip_dev_server.py +151 -0
- agentcore/operations/dev/config.py +128 -0
- agentcore/operations/dev/constants.py +9 -0
- agentcore/operations/dev/container_dev_server.py +237 -0
- agentcore/operations/dev/container_runtime.py +37 -0
- agentcore/operations/dev/dev_server.py +244 -0
- agentcore/operations/dev/gateway_env.py +25 -0
- agentcore/operations/dev/invoke.py +214 -0
- agentcore/operations/dev/invoke_a2a.py +204 -0
- agentcore/operations/dev/invoke_agui.py +88 -0
- agentcore/operations/dev/invoke_mcp.py +145 -0
- agentcore/operations/dev/invoke_types.py +30 -0
- agentcore/operations/dev/load_dev_env.py +26 -0
- agentcore/operations/dev/memory_env.py +19 -0
- agentcore/operations/dev/otel/__init__.py +5 -0
- agentcore/operations/dev/otel/collector.py +234 -0
- agentcore/operations/dev/otel/transforms.py +331 -0
- agentcore/operations/dev/payment_env.py +50 -0
- agentcore/operations/dev/server.py +28 -0
- agentcore/operations/dev/sse_transform.py +30 -0
- agentcore/operations/dev/utils.py +152 -0
- agentcore/operations/dev/web_ui/__init__.py +31 -0
- agentcore/operations/dev/web_ui/constants.py +25 -0
- agentcore/operations/dev/web_ui/handlers/__init__.py +36 -0
- agentcore/operations/dev/web_ui/handlers/_common.py +36 -0
- agentcore/operations/dev/web_ui/handlers/_deployed.py +37 -0
- agentcore/operations/dev/web_ui/handlers/a2a_proxy.py +37 -0
- agentcore/operations/dev/web_ui/handlers/cloudwatch_traces.py +71 -0
- agentcore/operations/dev/web_ui/handlers/harness_invocation.py +89 -0
- agentcore/operations/dev/web_ui/handlers/harness_utils.py +95 -0
- agentcore/operations/dev/web_ui/handlers/invocations.py +327 -0
- agentcore/operations/dev/web_ui/handlers/mcp_proxy.py +119 -0
- agentcore/operations/dev/web_ui/handlers/memory.py +84 -0
- agentcore/operations/dev/web_ui/handlers/resources.py +351 -0
- agentcore/operations/dev/web_ui/handlers/start.py +182 -0
- agentcore/operations/dev/web_ui/handlers/status.py +25 -0
- agentcore/operations/dev/web_ui/handlers/traces.py +50 -0
- agentcore/operations/dev/web_ui/run_web_ui.py +60 -0
- agentcore/operations/dev/web_ui/web_server.py +297 -0
- agentcore/operations/eval/__init__.py +8 -0
- agentcore/operations/eval/list_eval_runs.py +18 -0
- agentcore/operations/eval/logs_eval.py +119 -0
- agentcore/operations/eval/pause_resume.py +90 -0
- agentcore/operations/eval/run_eval.py +354 -0
- agentcore/operations/eval/shared/__init__.py +0 -0
- agentcore/operations/eval/shared/dataset_loader.py +68 -0
- agentcore/operations/eval/shared/dataset_session_provider.py +122 -0
- agentcore/operations/eval/shared/evaluator_runner.py +89 -0
- agentcore/operations/eval/shared/scenario_executor.py +71 -0
- agentcore/operations/eval/shared/span_collector.py +255 -0
- agentcore/operations/eval/storage.py +67 -0
- agentcore/operations/feedback/__init__.py +21 -0
- agentcore/operations/feedback/aperture_client.py +98 -0
- agentcore/operations/feedback/build_payload.py +97 -0
- agentcore/operations/feedback/constants.py +26 -0
- agentcore/operations/feedback/submit_feedback.py +150 -0
- agentcore/operations/fetch_access/__init__.py +36 -0
- agentcore/operations/fetch_access/_target.py +17 -0
- agentcore/operations/fetch_access/fetch_gateway_token.py +75 -0
- agentcore/operations/fetch_access/fetch_harness_token.py +72 -0
- agentcore/operations/fetch_access/fetch_runtime_token.py +76 -0
- agentcore/operations/fetch_access/list_agents.py +18 -0
- agentcore/operations/fetch_access/list_gateways.py +26 -0
- agentcore/operations/fetch_access/list_harnesses.py +23 -0
- agentcore/operations/fetch_access/oauth_token.py +162 -0
- agentcore/operations/fetch_access/types.py +34 -0
- agentcore/operations/harness/__init__.py +1 -0
- agentcore/operations/harness/orphan.py +84 -0
- agentcore/operations/harness/skill_utils.py +56 -0
- agentcore/operations/identity/__init__.py +33 -0
- agentcore/operations/identity/api_key_credential_provider.py +68 -0
- agentcore/operations/identity/oauth2_credential_provider.py +95 -0
- agentcore/operations/ingest/__init__.py +184 -0
- agentcore/operations/init/__init__.py +3 -0
- agentcore/operations/init/files.py +59 -0
- agentcore/operations/insights/__init__.py +21 -0
- agentcore/operations/insights/insights_storage.py +67 -0
- agentcore/operations/insights/run_insights.py +148 -0
- agentcore/operations/invoke/__init__.py +5 -0
- agentcore/operations/invoke/resolve_agent_context.py +85 -0
- agentcore/operations/jobs/__init__.py +38 -0
- agentcore/operations/jobs/ab_test/__init__.py +0 -0
- agentcore/operations/jobs/ab_test/build_options.py +126 -0
- agentcore/operations/jobs/ab_test/format.py +121 -0
- agentcore/operations/jobs/ab_test/handler.py +412 -0
- agentcore/operations/jobs/ab_test/promote.py +142 -0
- agentcore/operations/jobs/ab_test/resolve.py +221 -0
- agentcore/operations/jobs/batch_evaluation/__init__.py +0 -0
- agentcore/operations/jobs/batch_evaluation/build_source.py +68 -0
- agentcore/operations/jobs/batch_evaluation/dataset_phase1.py +95 -0
- agentcore/operations/jobs/batch_evaluation/format.py +58 -0
- agentcore/operations/jobs/batch_evaluation/handler.py +203 -0
- agentcore/operations/jobs/insights/__init__.py +0 -0
- agentcore/operations/jobs/insights/format.py +65 -0
- agentcore/operations/jobs/insights/handler.py +178 -0
- agentcore/operations/jobs/recommendation/__init__.py +0 -0
- agentcore/operations/jobs/recommendation/apply_to_bundle.py +76 -0
- agentcore/operations/jobs/recommendation/build_config.py +271 -0
- agentcore/operations/jobs/recommendation/fetch_session_spans.py +93 -0
- agentcore/operations/jobs/recommendation/format.py +77 -0
- agentcore/operations/jobs/recommendation/handler.py +331 -0
- agentcore/operations/jobs/shared/__init__.py +0 -0
- agentcore/operations/jobs/shared/constants.py +85 -0
- agentcore/operations/jobs/shared/engine.py +187 -0
- agentcore/operations/jobs/shared/format.py +104 -0
- agentcore/operations/jobs/shared/region.py +34 -0
- agentcore/operations/jobs/shared/resolve_agent_state.py +30 -0
- agentcore/operations/jobs/shared/storage.py +117 -0
- agentcore/operations/jobs/shared/wait.py +30 -0
- agentcore/operations/knowledge_base/__init__.py +33 -0
- agentcore/operations/knowledge_base/connector_config.py +105 -0
- agentcore/operations/knowledge_base/hydrate_data_sources.py +59 -0
- agentcore/operations/mcp/__init__.py +4 -0
- agentcore/operations/memory/__init__.py +13 -0
- agentcore/operations/memory/_records.py +72 -0
- agentcore/operations/memory/list_memory_records.py +45 -0
- agentcore/operations/memory/retrieve_memory_records.py +52 -0
- agentcore/operations/node/__init__.py +15 -0
- agentcore/operations/node/setup.py +36 -0
- agentcore/operations/python/__init__.py +17 -0
- agentcore/operations/python/setup.py +47 -0
- agentcore/operations/resolve_agent.py +159 -0
- agentcore/operations/session/__init__.py +86 -0
- agentcore/operations/traces/__init__.py +29 -0
- agentcore/operations/traces/get_trace.py +202 -0
- agentcore/operations/traces/insights_query.py +74 -0
- agentcore/operations/traces/list_traces.py +46 -0
- agentcore/operations/traces/trace_url.py +25 -0
- agentcore/operations/traces/types.py +55 -0
- agentcore/primitives/__init__.py +0 -0
- agentcore/primitives/_gateway_target_wizard.py +293 -0
- agentcore/primitives/_gateway_validation.py +442 -0
- agentcore/primitives/_harness_cli.py +557 -0
- agentcore/primitives/_harness_validation.py +163 -0
- agentcore/primitives/_harness_wizard.py +726 -0
- agentcore/primitives/_knowledge_base_wizard.py +259 -0
- agentcore/primitives/_payment_wizard.py +331 -0
- agentcore/primitives/_policy_form.py +160 -0
- agentcore/primitives/agent.py +817 -0
- agentcore/primitives/auth_utils.py +77 -0
- agentcore/primitives/base.py +178 -0
- agentcore/primitives/capacity_provider.py +501 -0
- agentcore/primitives/config_bundle.py +329 -0
- agentcore/primitives/credential.py +387 -0
- agentcore/primitives/credential_utils.py +45 -0
- agentcore/primitives/dataset.py +211 -0
- agentcore/primitives/deployed_gateways.py +34 -0
- agentcore/primitives/evaluator.py +909 -0
- agentcore/primitives/gateway.py +496 -0
- agentcore/primitives/gateway_target.py +988 -0
- agentcore/primitives/harness.py +706 -0
- agentcore/primitives/knowledge_base.py +477 -0
- agentcore/primitives/memory.py +387 -0
- agentcore/primitives/online_eval_config.py +365 -0
- agentcore/primitives/online_insights.py +275 -0
- agentcore/primitives/payment_connector.py +427 -0
- agentcore/primitives/payment_eligible.py +20 -0
- agentcore/primitives/payment_manager.py +605 -0
- agentcore/primitives/payment_validation.py +68 -0
- agentcore/primitives/policy.py +622 -0
- agentcore/primitives/policy_engine.py +358 -0
- agentcore/primitives/registry.py +56 -0
- agentcore/primitives/runtime_endpoint.py +361 -0
- agentcore/primitives/secret_flag_warning.py +17 -0
- agentcore/schema/__init__.py +14 -0
- agentcore/schema/_zod.py +395 -0
- agentcore/schema/constants.py +306 -0
- agentcore/schema/schemas/__init__.py +40 -0
- agentcore/schema/schemas/agent_env.py +545 -0
- agentcore/schema/schemas/agentcore_project.py +530 -0
- agentcore/schema/schemas/auth.py +286 -0
- agentcore/schema/schemas/aws_targets.py +72 -0
- agentcore/schema/schemas/connections.py +187 -0
- agentcore/schema/schemas/deployed_state.py +322 -0
- agentcore/schema/schemas/mcp.py +650 -0
- agentcore/schema/schemas/mcp_defs.py +54 -0
- agentcore/schema/schemas/primitives/__init__.py +52 -0
- agentcore/schema/schemas/primitives/ab_test.py +162 -0
- agentcore/schema/schemas/primitives/capacity_provider.py +214 -0
- agentcore/schema/schemas/primitives/config_bundle.py +48 -0
- agentcore/schema/schemas/primitives/dataset.py +55 -0
- agentcore/schema/schemas/primitives/evaluator.py +171 -0
- agentcore/schema/schemas/primitives/harness.py +710 -0
- agentcore/schema/schemas/primitives/knowledge_base.py +90 -0
- agentcore/schema/schemas/primitives/memory.py +113 -0
- agentcore/schema/schemas/primitives/online_eval_config.py +77 -0
- agentcore/schema/schemas/primitives/payment.py +114 -0
- agentcore/schema/schemas/primitives/policy.py +83 -0
- agentcore/schema/schemas/primitives/tags.py +50 -0
- agentcore/schema/schemas/zod_util.py +5 -0
- agentcore/schema/types/__init__.py +3 -0
- agentcore/schema/types/path.py +16 -0
- agentcore/templates/__init__.py +115 -0
- agentcore/templates/_handlebars.py +782 -0
- agentcore/templates/_js.py +164 -0
- agentcore/templates/base_renderer.py +107 -0
- agentcore/templates/cdk_renderer.py +129 -0
- agentcore/templates/evaluator_renderer.py +39 -0
- agentcore/templates/gateway_target_renderer.py +69 -0
- agentcore/templates/llm_context/README.md +16 -0
- agentcore/templates/llm_context/agentcore.ts +685 -0
- agentcore/templates/llm_context/aws-targets.ts +51 -0
- agentcore/templates/profiles.py +151 -0
- agentcore/templates/render.py +92 -0
- agentcore/templates/renderers.py +83 -0
- agentcore/templates/schema_assets.py +23 -0
- agentcore/templates/template_root.py +28 -0
- agentcore/templates/types.py +192 -0
- agentcore_cli-0.31.1.dist-info/METADATA +84 -0
- agentcore_cli-0.31.1.dist-info/RECORD +655 -0
- agentcore_cli-0.31.1.dist-info/WHEEL +4 -0
- agentcore_cli-0.31.1.dist-info/entry_points.txt +2 -0
- agentcore_cli-0.31.1.dist-info/licenses/LICENSE +175 -0
- agentcore_cli-0.31.1.dist-info/licenses/NOTICE +88 -0
|
@@ -0,0 +1,988 @@
|
|
|
1
|
+
"""Gateway target add/remove (port of src/cli/primitives/GatewayTargetPrimitive.ts).
|
|
2
|
+
|
|
3
|
+
Target types: scaffolded MCP tools (Python, Lambda or AgentCore Runtime host), existing MCP server
|
|
4
|
+
endpoints, API Gateway REST APIs, OpenAPI / Smithy schemas, Lambda function ARNs, HTTP runtimes,
|
|
5
|
+
connectors (bedrock-knowledge-bases, web-search) and passthrough endpoints.
|
|
6
|
+
|
|
7
|
+
The project spec is handled as its camelCase JSON form and validated on write by ``ConfigIO``.
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from __future__ import annotations
|
|
11
|
+
|
|
12
|
+
import json
|
|
13
|
+
import os
|
|
14
|
+
import shutil
|
|
15
|
+
from dataclasses import dataclass, field
|
|
16
|
+
from typing import Any
|
|
17
|
+
|
|
18
|
+
import typer
|
|
19
|
+
from pydantic import ValidationError as PydanticValidationError
|
|
20
|
+
|
|
21
|
+
from agentcore.cli import interactive
|
|
22
|
+
from agentcore.cli.errors import get_error_message
|
|
23
|
+
from agentcore.cli.run_command import run_cli_command
|
|
24
|
+
from agentcore.lib.constants import APP_DIR, MCP_APP_SUBDIR
|
|
25
|
+
from agentcore.lib.errors.types import ResourceNotFoundError, ValidationError, to_error
|
|
26
|
+
from agentcore.lib.result import Err, Ok, serialize_result
|
|
27
|
+
from agentcore.lib.schemas.io.config_io import to_jsonable
|
|
28
|
+
from agentcore.lib.schemas.io.path_resolver import find_config_root, require_config_root
|
|
29
|
+
from agentcore.lib.utils.json_format import to_json_string
|
|
30
|
+
from agentcore.operations.connectors import translate_connector
|
|
31
|
+
from agentcore.primitives._gateway_validation import validate_add_gateway_target_options
|
|
32
|
+
from agentcore.primitives.base import (
|
|
33
|
+
PASSTHROUGH_PROTOCOL_TYPES,
|
|
34
|
+
SOURCE_CODE_NOTE,
|
|
35
|
+
BasePrimitive,
|
|
36
|
+
RemovableResource,
|
|
37
|
+
RemovalPreview,
|
|
38
|
+
SchemaChange,
|
|
39
|
+
emit_json,
|
|
40
|
+
)
|
|
41
|
+
from agentcore.schema import CONNECTOR_ID_VALUES, DEFAULT_PYTHON_VERSION, AgentCoreCliMcpDefs, ToolDefinition
|
|
42
|
+
from agentcore.templates import get_template_tool_definitions, render_gateway_target_template
|
|
43
|
+
|
|
44
|
+
MCP_DEFS_FILE = "mcp-defs.json"
|
|
45
|
+
DEFAULT_NODE_VERSION = "NODE_20"
|
|
46
|
+
DEFAULT_HANDLER = "handler.lambda_handler"
|
|
47
|
+
|
|
48
|
+
TYPE_DESCRIPTION = (
|
|
49
|
+
"Target type (required): mcp-server, api-gateway, open-api-schema, smithy-model, lambda-function-arn, "
|
|
50
|
+
"http-runtime, connector, passthrough [non-interactive]"
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
HELP_EPILOG = """\b
|
|
54
|
+
Target types and their options:
|
|
55
|
+
|
|
56
|
+
http-runtime — Route to an AgentCore runtime
|
|
57
|
+
--runtime <name> Runtime from your project
|
|
58
|
+
--runtime-endpoint <name> Endpoint / version alias (optional)
|
|
59
|
+
|
|
60
|
+
mcp-server — Connect to an MCP-compatible server
|
|
61
|
+
--endpoint <url> Server endpoint URL
|
|
62
|
+
--host <host> Lambda or AgentCoreRuntime
|
|
63
|
+
--language <lang> Python, TypeScript, or Other
|
|
64
|
+
|
|
65
|
+
api-gateway — Connect to an Amazon API Gateway REST API
|
|
66
|
+
--rest-api-id <id> REST API ID
|
|
67
|
+
--stage <stage> Deployment stage
|
|
68
|
+
|
|
69
|
+
open-api-schema / smithy-model — Auto-derive tools from a schema
|
|
70
|
+
--schema <path> Schema file path or S3 URI
|
|
71
|
+
--schema-s3-account <id> S3 bucket owner account ID
|
|
72
|
+
|
|
73
|
+
lambda-function-arn — Connect to an AWS Lambda function
|
|
74
|
+
--lambda-arn <arn> Lambda function ARN
|
|
75
|
+
--tool-schema-file <path> Tool schema JSON file
|
|
76
|
+
|
|
77
|
+
connector — Wire a managed AWS connector (bedrock-knowledge-bases, web-search)
|
|
78
|
+
--connector <id> bedrock-knowledge-bases or web-search
|
|
79
|
+
--knowledge-base-id <id> Project KB name or 10-char external KB id (for KB connectors)
|
|
80
|
+
--exclude-domains <list> Comma-separated domains to exclude (for web-search connector)
|
|
81
|
+
|
|
82
|
+
passthrough — Route to an external HTTPS endpoint
|
|
83
|
+
--passthrough-endpoint <url> HTTPS endpoint URL
|
|
84
|
+
--stickiness-identifier <expr> Session routing expression (optional)
|
|
85
|
+
--stickiness-timeout <seconds> Sticky session timeout in seconds (optional)
|
|
86
|
+
|
|
87
|
+
Auth (--outbound-auth <type>, --credential-name <name>) — valid types per target:
|
|
88
|
+
mcp-server oauth or none
|
|
89
|
+
lambda-function-arn oauth or none
|
|
90
|
+
http-runtime oauth or none
|
|
91
|
+
open-api-schema oauth or api-key (required)
|
|
92
|
+
api-gateway api-key or none
|
|
93
|
+
smithy-model none (uses gateway IAM role)
|
|
94
|
+
passthrough gateway-iam-role, oauth, or jwt-passthrough
|
|
95
|
+
"""
|
|
96
|
+
|
|
97
|
+
OUTBOUND_AUTH_MAP = {
|
|
98
|
+
"oauth": "OAUTH",
|
|
99
|
+
"api-key": "API_KEY",
|
|
100
|
+
"api_key": "API_KEY",
|
|
101
|
+
"none": "NONE",
|
|
102
|
+
"gateway_iam_role": "GATEWAY_IAM_ROLE",
|
|
103
|
+
"gateway-iam-role": "GATEWAY_IAM_ROLE",
|
|
104
|
+
"jwt_passthrough": "JWT_PASSTHROUGH",
|
|
105
|
+
"jwt-passthrough": "JWT_PASSTHROUGH",
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
@dataclass
|
|
110
|
+
class AddGatewayTargetOptions:
|
|
111
|
+
name: str
|
|
112
|
+
language: str = "Python"
|
|
113
|
+
description: str | None = None
|
|
114
|
+
gateway: str | None = None
|
|
115
|
+
host: str | None = None
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
@dataclass
|
|
119
|
+
class GatewayTargetWizardState:
|
|
120
|
+
name: str
|
|
121
|
+
description: str
|
|
122
|
+
source_path: str
|
|
123
|
+
language: str
|
|
124
|
+
host: str
|
|
125
|
+
tool_definition: dict[str, Any]
|
|
126
|
+
gateway: str | None = None
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
@dataclass
|
|
130
|
+
class RemovableGatewayTarget(RemovableResource):
|
|
131
|
+
gateway_name: str = ""
|
|
132
|
+
extra: dict[str, Any] = field(default_factory=dict)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def _mcp_fields(project: dict[str, Any]) -> dict[str, Any]:
|
|
136
|
+
spec = {"agentCoreGateways": project.get("agentCoreGateways", [])}
|
|
137
|
+
for key in ("mcpRuntimeTools", "unassignedTargets"):
|
|
138
|
+
if key in project:
|
|
139
|
+
spec[key] = project[key]
|
|
140
|
+
return spec
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _csv(value: str | None) -> list[str] | None:
|
|
144
|
+
return [s.strip() for s in value.split(",")] if value is not None else None
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def _outbound_auth(auth_type: str | None, credential_name: str | None) -> dict[str, Any] | None:
|
|
148
|
+
"""``{type, credentialName}`` as upstream's object spread (credentialName dropped when undefined)."""
|
|
149
|
+
if not auth_type:
|
|
150
|
+
return None
|
|
151
|
+
auth: dict[str, Any] = {"type": OUTBOUND_AUTH_MAP.get(auth_type.lower(), "NONE")}
|
|
152
|
+
if credential_name is not None:
|
|
153
|
+
auth["credentialName"] = credential_name
|
|
154
|
+
return auth
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
class GatewayTargetPrimitive(BasePrimitive):
|
|
158
|
+
kind = "gateway-target"
|
|
159
|
+
label = "Gateway Target"
|
|
160
|
+
|
|
161
|
+
def _project(self) -> dict[str, Any]:
|
|
162
|
+
return to_jsonable(self.read_project_spec())
|
|
163
|
+
|
|
164
|
+
def _read_mcp_defs_or_empty(self) -> dict[str, Any]:
|
|
165
|
+
if self.config_io.config_exists("mcpDefs"):
|
|
166
|
+
return to_jsonable(self.config_io.read_mcp_defs())
|
|
167
|
+
return {"tools": {}}
|
|
168
|
+
|
|
169
|
+
# --- add (scaffolded tool) ----------------------------------------------------------
|
|
170
|
+
|
|
171
|
+
def add(self, options: AddGatewayTargetOptions) -> Ok[dict[str, Any]] | Err[Exception]:
|
|
172
|
+
try:
|
|
173
|
+
config = self._build_gateway_target_config(options)
|
|
174
|
+
result = self._create_tool_from_wizard(config)
|
|
175
|
+
return Ok({"toolName": result["toolName"], "sourcePath": result["projectPath"]})
|
|
176
|
+
except Exception as exc: # noqa: BLE001
|
|
177
|
+
return Err(to_error(exc))
|
|
178
|
+
|
|
179
|
+
@staticmethod
|
|
180
|
+
def _build_gateway_target_config(options: AddGatewayTargetOptions) -> GatewayTargetWizardState:
|
|
181
|
+
source_path = f"{APP_DIR}/{MCP_APP_SUBDIR}/{options.name}"
|
|
182
|
+
description = options.description if options.description is not None else f"Tool for {options.name}"
|
|
183
|
+
return GatewayTargetWizardState(
|
|
184
|
+
name=options.name,
|
|
185
|
+
description=description,
|
|
186
|
+
source_path=source_path,
|
|
187
|
+
language=options.language,
|
|
188
|
+
host=options.host or "AgentCoreRuntime",
|
|
189
|
+
tool_definition={"name": options.name, "description": description, "inputSchema": {"type": "object"}},
|
|
190
|
+
gateway=options.gateway,
|
|
191
|
+
)
|
|
192
|
+
|
|
193
|
+
def _create_tool_from_wizard(self, config: GatewayTargetWizardState) -> dict[str, str]:
|
|
194
|
+
if config.language not in ("Python", "TypeScript", "Other"):
|
|
195
|
+
raise ValueError(f'Gateway targets for language "{config.language}" are not yet supported.')
|
|
196
|
+
|
|
197
|
+
project = self._project()
|
|
198
|
+
if config.host == "Lambda":
|
|
199
|
+
tool_defs = [to_jsonable(t) for t in get_template_tool_definitions(config.name, "Lambda")]
|
|
200
|
+
else:
|
|
201
|
+
tool_defs = [config.tool_definition]
|
|
202
|
+
for tool_def in tool_defs:
|
|
203
|
+
try:
|
|
204
|
+
ToolDefinition.model_validate(tool_def)
|
|
205
|
+
except PydanticValidationError as exc:
|
|
206
|
+
from agentcore.primitives.knowledge_base import zod_error_message
|
|
207
|
+
|
|
208
|
+
raise ValueError(zod_error_message(exc)) from None
|
|
209
|
+
|
|
210
|
+
if not config.gateway:
|
|
211
|
+
raise ValueError("Gateway name is required for gateway targets.")
|
|
212
|
+
gateway = self._find_gateway(project, config.gateway)
|
|
213
|
+
self._check_target_name(gateway, config.name)
|
|
214
|
+
for tool_def in tool_defs:
|
|
215
|
+
for existing in gateway["targets"]:
|
|
216
|
+
if any(t["name"] == tool_def["name"] for t in existing.get("toolDefinitions") or []):
|
|
217
|
+
raise ValueError(f'Tool "{tool_def["name"]}" already exists in gateway "{gateway["name"]}".')
|
|
218
|
+
|
|
219
|
+
if config.language == "Other":
|
|
220
|
+
raise ValueError('Language "Other" is not yet supported for gateway targets. Use Python or TypeScript.')
|
|
221
|
+
|
|
222
|
+
if config.host == "Lambda":
|
|
223
|
+
compute: dict[str, Any] = {
|
|
224
|
+
"host": "Lambda",
|
|
225
|
+
"implementation": {"path": config.source_path, "language": config.language, "handler": DEFAULT_HANDLER},
|
|
226
|
+
}
|
|
227
|
+
if config.language == "Python":
|
|
228
|
+
compute["pythonVersion"] = DEFAULT_PYTHON_VERSION
|
|
229
|
+
else:
|
|
230
|
+
compute["nodeVersion"] = DEFAULT_NODE_VERSION
|
|
231
|
+
else:
|
|
232
|
+
compute = {
|
|
233
|
+
"host": "AgentCoreRuntime",
|
|
234
|
+
"implementation": {"path": config.source_path, "language": "Python", "handler": "server.py:main"},
|
|
235
|
+
"runtime": {
|
|
236
|
+
"artifact": "CodeZip",
|
|
237
|
+
"pythonVersion": DEFAULT_PYTHON_VERSION,
|
|
238
|
+
"name": config.name,
|
|
239
|
+
"entrypoint": "server.py:main",
|
|
240
|
+
"codeLocation": config.source_path,
|
|
241
|
+
"networkMode": "PUBLIC",
|
|
242
|
+
},
|
|
243
|
+
}
|
|
244
|
+
gateway["targets"].append(
|
|
245
|
+
{
|
|
246
|
+
"name": config.name,
|
|
247
|
+
"targetType": "mcpServer" if config.host == "AgentCoreRuntime" else "lambda",
|
|
248
|
+
"toolDefinitions": tool_defs,
|
|
249
|
+
"compute": compute,
|
|
250
|
+
}
|
|
251
|
+
)
|
|
252
|
+
self.write_project_spec(project)
|
|
253
|
+
|
|
254
|
+
mcp_defs_path = os.path.join(require_config_root(), MCP_DEFS_FILE)
|
|
255
|
+
try:
|
|
256
|
+
mcp_defs = self._read_mcp_defs_file(mcp_defs_path)
|
|
257
|
+
for tool_def in tool_defs:
|
|
258
|
+
if tool_def["name"] in mcp_defs["tools"]:
|
|
259
|
+
raise ValueError(f'Tool definition "{tool_def["name"]}" already exists in mcp-defs.json.')
|
|
260
|
+
mcp_defs["tools"][tool_def["name"]] = tool_def
|
|
261
|
+
os.makedirs(require_config_root(), exist_ok=True)
|
|
262
|
+
with open(mcp_defs_path, "w", encoding="utf-8") as fh:
|
|
263
|
+
fh.write(to_json_string(mcp_defs, 2))
|
|
264
|
+
except Exception as exc: # noqa: BLE001
|
|
265
|
+
raise ValueError(f"MCP saved, but failed to update mcp-defs.json: {exc}") from None
|
|
266
|
+
|
|
267
|
+
project_root = os.path.dirname(require_config_root())
|
|
268
|
+
render_gateway_target_template(
|
|
269
|
+
config.name, os.path.join(project_root, config.source_path), config.language, config.host
|
|
270
|
+
)
|
|
271
|
+
return {"mcpDefsPath": mcp_defs_path, "toolName": config.name, "projectPath": config.source_path}
|
|
272
|
+
|
|
273
|
+
@staticmethod
|
|
274
|
+
def _read_mcp_defs_file(path: str) -> dict[str, Any]:
|
|
275
|
+
if not os.path.exists(path):
|
|
276
|
+
return {"tools": {}}
|
|
277
|
+
with open(path, encoding="utf-8") as fh:
|
|
278
|
+
parsed = json.load(fh)
|
|
279
|
+
try:
|
|
280
|
+
return to_jsonable(AgentCoreCliMcpDefs.model_validate(parsed))
|
|
281
|
+
except PydanticValidationError:
|
|
282
|
+
raise ValueError("Invalid mcp-defs.json. Fix it before adding a new gateway target.") from None
|
|
283
|
+
|
|
284
|
+
# --- add (registered, no code generation) -------------------------------------------
|
|
285
|
+
|
|
286
|
+
@staticmethod
|
|
287
|
+
def _find_gateway(project: dict[str, Any], name: str) -> dict[str, Any]:
|
|
288
|
+
gateway = next((g for g in project.get("agentCoreGateways", []) if g["name"] == name), None)
|
|
289
|
+
if gateway is None:
|
|
290
|
+
raise ValueError(f'Gateway "{name}" not found.')
|
|
291
|
+
gateway.setdefault("targets", [])
|
|
292
|
+
return gateway
|
|
293
|
+
|
|
294
|
+
@staticmethod
|
|
295
|
+
def _check_target_name(gateway: dict[str, Any], name: str) -> None:
|
|
296
|
+
if any(t["name"] == name for t in gateway["targets"]):
|
|
297
|
+
raise ValueError(f'Target "{name}" already exists in gateway "{gateway["name"]}".')
|
|
298
|
+
|
|
299
|
+
def _append_target(self, gateway_name: str, target: dict[str, Any], require_gateway_msg: bool = False) -> str:
|
|
300
|
+
project = self._project()
|
|
301
|
+
gateway = self._find_gateway(project, gateway_name)
|
|
302
|
+
self._check_target_name(gateway, target["name"])
|
|
303
|
+
gateway["targets"].append(target)
|
|
304
|
+
self.write_project_spec(project)
|
|
305
|
+
return target["name"]
|
|
306
|
+
|
|
307
|
+
def create_external_gateway_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
308
|
+
"""Register an existing MCP server endpoint (``McpServerTargetConfig`` as camelCase dict)."""
|
|
309
|
+
target: dict[str, Any] = {
|
|
310
|
+
"name": config["name"],
|
|
311
|
+
"targetType": "mcpServer",
|
|
312
|
+
"endpoint": config["endpoint"],
|
|
313
|
+
"toolDefinitions": [config["toolDefinition"]],
|
|
314
|
+
}
|
|
315
|
+
if config.get("outboundAuth"):
|
|
316
|
+
target["outboundAuth"] = config["outboundAuth"]
|
|
317
|
+
if not config.get("gateway"):
|
|
318
|
+
raise ValueError(
|
|
319
|
+
"Gateway is required. A gateway target must be attached to a gateway. Create a gateway first with "
|
|
320
|
+
"'agentcore add gateway'."
|
|
321
|
+
)
|
|
322
|
+
return {"toolName": self._append_target(config["gateway"], target), "projectPath": ""}
|
|
323
|
+
|
|
324
|
+
def create_api_gateway_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
325
|
+
target: dict[str, Any] = {
|
|
326
|
+
"name": config["name"],
|
|
327
|
+
"targetType": "apiGateway",
|
|
328
|
+
"apiGateway": {
|
|
329
|
+
"restApiId": config["restApiId"],
|
|
330
|
+
"stage": config["stage"],
|
|
331
|
+
"apiGatewayToolConfiguration": {
|
|
332
|
+
"toolFilters": config.get("toolFilters") or [{"filterPath": "/*", "methods": ["GET"]}]
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
}
|
|
336
|
+
if config.get("outboundAuth"):
|
|
337
|
+
target["outboundAuth"] = config["outboundAuth"]
|
|
338
|
+
return {"toolName": self._append_target(config["gateway"], target)}
|
|
339
|
+
|
|
340
|
+
def create_schema_based_gateway_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
341
|
+
target: dict[str, Any] = {
|
|
342
|
+
"name": config["name"],
|
|
343
|
+
"targetType": config["targetType"],
|
|
344
|
+
"schemaSource": config["schemaSource"],
|
|
345
|
+
}
|
|
346
|
+
if config.get("outboundAuth"):
|
|
347
|
+
target["outboundAuth"] = config["outboundAuth"]
|
|
348
|
+
return {"toolName": self._append_target(config["gateway"], target)}
|
|
349
|
+
|
|
350
|
+
def create_lambda_function_arn_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
351
|
+
target = {
|
|
352
|
+
"name": config["name"],
|
|
353
|
+
"targetType": "lambdaFunctionArn",
|
|
354
|
+
"lambdaFunctionArn": {"lambdaArn": config["lambdaArn"], "toolSchemaFile": config["toolSchemaFile"]},
|
|
355
|
+
}
|
|
356
|
+
return {"toolName": self._append_target(config["gateway"], target)}
|
|
357
|
+
|
|
358
|
+
def create_http_runtime_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
359
|
+
http_runtime: dict[str, Any] = {"runtime": config["runtime"]}
|
|
360
|
+
if config.get("endpoint"):
|
|
361
|
+
http_runtime["runtimeEndpoint"] = config["endpoint"]
|
|
362
|
+
target: dict[str, Any] = {"name": config["name"], "targetType": "httpRuntime", "httpRuntime": http_runtime}
|
|
363
|
+
auth = config.get("outboundAuth")
|
|
364
|
+
if auth and auth.get("type") != "NONE":
|
|
365
|
+
out: dict[str, Any] = {"type": auth["type"], "credentialName": auth.get("credentialName")}
|
|
366
|
+
if auth.get("scopes"):
|
|
367
|
+
out["scopes"] = auth["scopes"]
|
|
368
|
+
target["outboundAuth"] = {k: v for k, v in out.items() if v is not None}
|
|
369
|
+
return {"toolName": self._append_target(config["gateway"], target)}
|
|
370
|
+
|
|
371
|
+
def create_connector_gateway_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
372
|
+
"""bedrock-knowledge-bases connector: ``knowledgeBaseId`` is a project KB name or a literal KB id."""
|
|
373
|
+
target = {
|
|
374
|
+
"name": config["name"],
|
|
375
|
+
"targetType": "connector",
|
|
376
|
+
"connectorId": "bedrock-knowledge-bases",
|
|
377
|
+
"configurations": translate_connector(
|
|
378
|
+
"bedrock-knowledge-bases", {"knowledgeBaseId": config["knowledgeBaseId"]}
|
|
379
|
+
),
|
|
380
|
+
}
|
|
381
|
+
return {"toolName": self._append_target(config["gateway"], target)}
|
|
382
|
+
|
|
383
|
+
def create_passthrough_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
384
|
+
outbound_auth: dict[str, Any] | None = None
|
|
385
|
+
auth = config.get("outboundAuth")
|
|
386
|
+
if auth and auth.get("type") != "NONE":
|
|
387
|
+
if auth["type"] == "GATEWAY_IAM_ROLE":
|
|
388
|
+
outbound_auth = {"type": "GATEWAY_IAM_ROLE", "service": auth.get("service")}
|
|
389
|
+
if auth.get("region"):
|
|
390
|
+
outbound_auth["region"] = auth["region"]
|
|
391
|
+
elif auth["type"] == "JWT_PASSTHROUGH":
|
|
392
|
+
outbound_auth = {"type": "JWT_PASSTHROUGH"}
|
|
393
|
+
else:
|
|
394
|
+
outbound_auth = {"type": auth["type"], "credentialName": auth.get("credentialName")}
|
|
395
|
+
if auth.get("scopes"):
|
|
396
|
+
outbound_auth["scopes"] = auth["scopes"]
|
|
397
|
+
outbound_auth = {k: v for k, v in outbound_auth.items() if v is not None}
|
|
398
|
+
|
|
399
|
+
passthrough: dict[str, Any] = {
|
|
400
|
+
"endpoint": config["passthroughEndpoint"],
|
|
401
|
+
"protocolType": config.get("protocolType") or "CUSTOM",
|
|
402
|
+
}
|
|
403
|
+
if config.get("stickinessIdentifier"):
|
|
404
|
+
stickiness: dict[str, Any] = {"identifier": config["stickinessIdentifier"]}
|
|
405
|
+
if config.get("stickinessTimeout"):
|
|
406
|
+
stickiness["timeout"] = config["stickinessTimeout"]
|
|
407
|
+
passthrough["stickinessConfiguration"] = stickiness
|
|
408
|
+
target: dict[str, Any] = {"name": config["name"], "targetType": "passthrough", "passthrough": passthrough}
|
|
409
|
+
if outbound_auth:
|
|
410
|
+
target["outboundAuth"] = outbound_auth
|
|
411
|
+
return {"toolName": self._append_target(config["gateway"], target)}
|
|
412
|
+
|
|
413
|
+
def create_web_search_gateway_target(self, config: dict[str, Any]) -> dict[str, str]:
|
|
414
|
+
target = {
|
|
415
|
+
"name": config["name"],
|
|
416
|
+
"targetType": "connector",
|
|
417
|
+
"connectorId": "web-search",
|
|
418
|
+
"configurations": translate_connector("web-search", {"excludeDomains": config.get("excludeDomains")}),
|
|
419
|
+
}
|
|
420
|
+
return {"toolName": self._append_target(config["gateway"], target)}
|
|
421
|
+
|
|
422
|
+
# --- remove -------------------------------------------------------------------------
|
|
423
|
+
|
|
424
|
+
def get_removable(self) -> list[RemovableResource]:
|
|
425
|
+
try:
|
|
426
|
+
return [
|
|
427
|
+
RemovableGatewayTarget(
|
|
428
|
+
t["name"], gateway_name=g["name"], extra={"type": "gateway-target", "gatewayName": g["name"]}
|
|
429
|
+
)
|
|
430
|
+
for g in self._project().get("agentCoreGateways", [])
|
|
431
|
+
for t in g.get("targets", [])
|
|
432
|
+
]
|
|
433
|
+
except Exception: # noqa: BLE001
|
|
434
|
+
return []
|
|
435
|
+
|
|
436
|
+
def get_existing_tool_names(self) -> list[str]:
|
|
437
|
+
try:
|
|
438
|
+
return [
|
|
439
|
+
d["name"]
|
|
440
|
+
for g in self._project().get("agentCoreGateways", [])
|
|
441
|
+
for t in g.get("targets", [])
|
|
442
|
+
for d in t.get("toolDefinitions") or []
|
|
443
|
+
]
|
|
444
|
+
except Exception: # noqa: BLE001
|
|
445
|
+
return []
|
|
446
|
+
|
|
447
|
+
@staticmethod
|
|
448
|
+
def _compute_removed_tool_mcp_spec(mcp_spec: dict[str, Any], tool: RemovableGatewayTarget) -> dict[str, Any]:
|
|
449
|
+
return {
|
|
450
|
+
**mcp_spec,
|
|
451
|
+
"agentCoreGateways": [
|
|
452
|
+
g
|
|
453
|
+
if g["name"] != tool.gateway_name
|
|
454
|
+
else {**g, "targets": [t for t in g["targets"] if t["name"] != tool.name]}
|
|
455
|
+
for g in mcp_spec["agentCoreGateways"]
|
|
456
|
+
],
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
@staticmethod
|
|
460
|
+
def _compute_removed_tool_mcp_defs(
|
|
461
|
+
mcp_spec: dict[str, Any], mcp_defs: dict[str, Any], tool: RemovableGatewayTarget
|
|
462
|
+
) -> dict[str, Any]:
|
|
463
|
+
gateway = next((g for g in mcp_spec["agentCoreGateways"] if g["name"] == tool.gateway_name), None)
|
|
464
|
+
target = next((t for t in (gateway or {}).get("targets", []) if t["name"] == tool.name), None)
|
|
465
|
+
names = [d["name"] for d in (target or {}).get("toolDefinitions") or []]
|
|
466
|
+
tools = {k: v for k, v in mcp_defs.get("tools", {}).items() if k not in names}
|
|
467
|
+
return {**mcp_defs, "tools": tools}
|
|
468
|
+
|
|
469
|
+
@staticmethod
|
|
470
|
+
def _tool_path(target: dict[str, Any]) -> str | None:
|
|
471
|
+
implementation = (target.get("compute") or {}).get("implementation") or {}
|
|
472
|
+
return implementation.get("path")
|
|
473
|
+
|
|
474
|
+
def _find(self, name: str) -> RemovableGatewayTarget | None:
|
|
475
|
+
return next((t for t in self.get_removable() if t.name == name), None) # type: ignore[return-value]
|
|
476
|
+
|
|
477
|
+
def remove(self, name: str) -> Ok[None] | Err[Exception]:
|
|
478
|
+
tool = self._find(name)
|
|
479
|
+
if tool is None:
|
|
480
|
+
return Err(ResourceNotFoundError(f'Gateway target "{name}" not found.'))
|
|
481
|
+
return self.remove_gateway_target(tool)
|
|
482
|
+
|
|
483
|
+
def remove_gateway_target(self, tool: RemovableGatewayTarget) -> Ok[None] | Err[Exception]:
|
|
484
|
+
try:
|
|
485
|
+
project = self._project()
|
|
486
|
+
mcp_spec = _mcp_fields(project)
|
|
487
|
+
mcp_defs = self._read_mcp_defs_or_empty()
|
|
488
|
+
project_root = self.config_io.get_project_root()
|
|
489
|
+
|
|
490
|
+
gateway = next((g for g in mcp_spec["agentCoreGateways"] if g["name"] == tool.gateway_name), None)
|
|
491
|
+
if gateway is None:
|
|
492
|
+
return Err(ResourceNotFoundError(f'Gateway "{tool.gateway_name}" not found.'))
|
|
493
|
+
target = next((t for t in gateway["targets"] if t["name"] == tool.name), None)
|
|
494
|
+
if target is None:
|
|
495
|
+
return Err(ResourceNotFoundError(f'Target "{tool.name}" not found in gateway "{tool.gateway_name}".'))
|
|
496
|
+
tool_path = self._tool_path(target)
|
|
497
|
+
|
|
498
|
+
new_defs = self._compute_removed_tool_mcp_defs(mcp_spec, mcp_defs, tool)
|
|
499
|
+
self.write_project_spec({**project, **self._compute_removed_tool_mcp_spec(mcp_spec, tool)})
|
|
500
|
+
self.config_io.write_mcp_defs(new_defs)
|
|
501
|
+
|
|
502
|
+
if tool_path:
|
|
503
|
+
tool_dir = os.path.join(project_root, tool_path)
|
|
504
|
+
if os.path.exists(tool_dir):
|
|
505
|
+
shutil.rmtree(tool_dir, ignore_errors=True)
|
|
506
|
+
return Ok(None)
|
|
507
|
+
except Exception as exc: # noqa: BLE001
|
|
508
|
+
return Err(to_error(exc))
|
|
509
|
+
|
|
510
|
+
def preview_remove(self, name: str) -> RemovalPreview:
|
|
511
|
+
tool = self._find(name)
|
|
512
|
+
if tool is None:
|
|
513
|
+
raise Exception(f'Gateway target "{name}" not found.')
|
|
514
|
+
return self.preview_remove_gateway_target(tool)
|
|
515
|
+
|
|
516
|
+
def preview_remove_gateway_target(self, tool: RemovableGatewayTarget) -> RemovalPreview:
|
|
517
|
+
project = self._project()
|
|
518
|
+
mcp_spec = _mcp_fields(project)
|
|
519
|
+
mcp_defs = self._read_mcp_defs_or_empty()
|
|
520
|
+
project_root = self.config_io.get_project_root()
|
|
521
|
+
|
|
522
|
+
gateway = next((g for g in mcp_spec["agentCoreGateways"] if g["name"] == tool.gateway_name), None)
|
|
523
|
+
if gateway is None:
|
|
524
|
+
raise Exception(f'Gateway "{tool.gateway_name}" not found.')
|
|
525
|
+
target = next((t for t in gateway["targets"] if t["name"] == tool.name), None)
|
|
526
|
+
if target is None:
|
|
527
|
+
raise Exception(f'Target "{tool.name}" not found in gateway "{tool.gateway_name}".')
|
|
528
|
+
|
|
529
|
+
summary = [f"Removing gateway target: {tool.name} (from {tool.gateway_name})"]
|
|
530
|
+
directories: list[str] = []
|
|
531
|
+
tool_path = self._tool_path(target)
|
|
532
|
+
if tool_path:
|
|
533
|
+
tool_dir = os.path.join(project_root, tool_path)
|
|
534
|
+
if os.path.exists(tool_dir):
|
|
535
|
+
directories.append(tool_dir)
|
|
536
|
+
summary.append(f"Deleting directory: {tool_path}")
|
|
537
|
+
for tool_def in target.get("toolDefinitions") or []:
|
|
538
|
+
if tool_def["name"] in mcp_defs.get("tools", {}):
|
|
539
|
+
summary.append(f"Removing tool definition: {tool_def['name']}")
|
|
540
|
+
|
|
541
|
+
changes = [
|
|
542
|
+
SchemaChange(
|
|
543
|
+
"agentcore/agentcore.json", project, {**project, **self._compute_removed_tool_mcp_spec(mcp_spec, tool)}
|
|
544
|
+
)
|
|
545
|
+
]
|
|
546
|
+
after_defs = self._compute_removed_tool_mcp_defs(mcp_spec, mcp_defs, tool)
|
|
547
|
+
if json.dumps(mcp_defs) != json.dumps(after_defs):
|
|
548
|
+
changes.append(SchemaChange("agentcore/mcp-defs.json", mcp_defs, after_defs))
|
|
549
|
+
return RemovalPreview(summary, directories, changes)
|
|
550
|
+
|
|
551
|
+
# --- CLI ----------------------------------------------------------------------------
|
|
552
|
+
|
|
553
|
+
def register_commands(self, add_app: typer.Typer, remove_app: typer.Typer) -> None: # noqa: C901
|
|
554
|
+
@add_app.command(
|
|
555
|
+
"gateway-target",
|
|
556
|
+
help="Add a target to a gateway for routing requests to backends",
|
|
557
|
+
epilog=HELP_EPILOG,
|
|
558
|
+
)
|
|
559
|
+
def add_command( # noqa: PLR0913
|
|
560
|
+
name: str | None = typer.Option(None, "--name", help="Target name [non-interactive]"),
|
|
561
|
+
description: str | None = typer.Option(None, "--description", help="Target description [non-interactive]"),
|
|
562
|
+
gateway: str | None = typer.Option(
|
|
563
|
+
None, "--gateway", help="Gateway to attach this target to [non-interactive]"
|
|
564
|
+
),
|
|
565
|
+
type_: str | None = typer.Option(None, "--type", help=TYPE_DESCRIPTION),
|
|
566
|
+
connector: str | None = typer.Option(
|
|
567
|
+
None,
|
|
568
|
+
"--connector",
|
|
569
|
+
help="Connector id (for connector type): bedrock-knowledge-bases or web-search [non-interactive]",
|
|
570
|
+
),
|
|
571
|
+
knowledge_base_id: list[str] = typer.Option(
|
|
572
|
+
[],
|
|
573
|
+
"--knowledge-base-id",
|
|
574
|
+
help=(
|
|
575
|
+
"KB reference for connector type — either a project KB name (entry in knowledgeBases[]) or a "
|
|
576
|
+
"10-char Bedrock KB id for an external KB. [non-interactive]"
|
|
577
|
+
),
|
|
578
|
+
),
|
|
579
|
+
exclude_domains: list[str] = typer.Option(
|
|
580
|
+
[],
|
|
581
|
+
"--exclude-domains",
|
|
582
|
+
help="Comma-separated domains to exclude from results (for --connector web-search) [non-interactive]",
|
|
583
|
+
),
|
|
584
|
+
endpoint: str | None = typer.Option(
|
|
585
|
+
None, "--endpoint", help="Server endpoint URL (for mcp-server type) [non-interactive]"
|
|
586
|
+
),
|
|
587
|
+
language: str | None = typer.Option(
|
|
588
|
+
None, "--language", help="Language of target code: Python, TypeScript, Other [non-interactive]"
|
|
589
|
+
),
|
|
590
|
+
host: str | None = typer.Option(
|
|
591
|
+
None, "--host", help="Where to run the target: Lambda or AgentCoreRuntime [non-interactive]"
|
|
592
|
+
),
|
|
593
|
+
outbound_auth: str | None = typer.Option(
|
|
594
|
+
None,
|
|
595
|
+
"--outbound-auth",
|
|
596
|
+
help='Outbound auth type; valid values depend on --type (see "Auth" below) [non-interactive]',
|
|
597
|
+
),
|
|
598
|
+
credential_name: str | None = typer.Option(
|
|
599
|
+
None, "--credential-name", help="Existing credential name for outbound auth [non-interactive]"
|
|
600
|
+
),
|
|
601
|
+
oauth_client_id: str | None = typer.Option(
|
|
602
|
+
None,
|
|
603
|
+
"--oauth-client-id",
|
|
604
|
+
help="OAuth client ID — creates credential inline (for oauth auth) [non-interactive]",
|
|
605
|
+
),
|
|
606
|
+
oauth_client_secret: str | None = typer.Option(
|
|
607
|
+
None,
|
|
608
|
+
"--oauth-client-secret",
|
|
609
|
+
help="OAuth client secret — creates credential inline (for oauth auth) [non-interactive]",
|
|
610
|
+
),
|
|
611
|
+
oauth_discovery_url: str | None = typer.Option(
|
|
612
|
+
None,
|
|
613
|
+
"--oauth-discovery-url",
|
|
614
|
+
help="OAuth discovery URL — creates credential inline (for oauth auth) [non-interactive]",
|
|
615
|
+
),
|
|
616
|
+
oauth_scopes: str | None = typer.Option(
|
|
617
|
+
None, "--oauth-scopes", help="OAuth scopes, comma-separated (for oauth auth) [non-interactive]"
|
|
618
|
+
),
|
|
619
|
+
rest_api_id: str | None = typer.Option(
|
|
620
|
+
None, "--rest-api-id", help="REST API ID (for api-gateway type) [non-interactive]"
|
|
621
|
+
),
|
|
622
|
+
stage: str | None = typer.Option(
|
|
623
|
+
None, "--stage", help="Deployment stage (for api-gateway type) [non-interactive]"
|
|
624
|
+
),
|
|
625
|
+
tool_filter_path: str | None = typer.Option(
|
|
626
|
+
None, "--tool-filter-path", help="Tool filter path pattern, e.g. /pets/* [non-interactive]"
|
|
627
|
+
),
|
|
628
|
+
tool_filter_methods: str | None = typer.Option(
|
|
629
|
+
None, "--tool-filter-methods", help="Comma-separated HTTP methods, e.g. GET,POST [non-interactive]"
|
|
630
|
+
),
|
|
631
|
+
schema: str | None = typer.Option(
|
|
632
|
+
None,
|
|
633
|
+
"--schema",
|
|
634
|
+
help="Schema file path or S3 URI (for open-api-schema / smithy-model type) [non-interactive]",
|
|
635
|
+
),
|
|
636
|
+
schema_s3_account: str | None = typer.Option(
|
|
637
|
+
None,
|
|
638
|
+
"--schema-s3-account",
|
|
639
|
+
help="S3 bucket owner account ID for cross-account access (for schema on S3) [non-interactive]",
|
|
640
|
+
),
|
|
641
|
+
lambda_arn: str | None = typer.Option(
|
|
642
|
+
None, "--lambda-arn", help="Lambda function ARN (for lambda-function-arn type) [non-interactive]"
|
|
643
|
+
),
|
|
644
|
+
tool_schema_file: str | None = typer.Option(
|
|
645
|
+
None,
|
|
646
|
+
"--tool-schema-file",
|
|
647
|
+
help="Tool schema JSON file path (for lambda-function-arn type) [non-interactive]",
|
|
648
|
+
),
|
|
649
|
+
runtime: str | None = typer.Option(
|
|
650
|
+
None, "--runtime", help="Runtime from your project (for http-runtime type) [non-interactive]"
|
|
651
|
+
),
|
|
652
|
+
runtime_endpoint: str | None = typer.Option(
|
|
653
|
+
None,
|
|
654
|
+
"--runtime-endpoint",
|
|
655
|
+
help="Runtime endpoint / version alias (for http-runtime type) [non-interactive]",
|
|
656
|
+
),
|
|
657
|
+
passthrough_endpoint: str | None = typer.Option(
|
|
658
|
+
None, "--passthrough-endpoint", help="HTTPS endpoint URL for passthrough targets [non-interactive]"
|
|
659
|
+
),
|
|
660
|
+
passthrough_protocol: str | None = typer.Option(
|
|
661
|
+
None,
|
|
662
|
+
"--passthrough-protocol",
|
|
663
|
+
help="Passthrough protocol: MCP | A2A | INFERENCE | CUSTOM (default: CUSTOM) [non-interactive]",
|
|
664
|
+
),
|
|
665
|
+
stickiness_identifier: str | None = typer.Option(
|
|
666
|
+
None,
|
|
667
|
+
"--stickiness-identifier",
|
|
668
|
+
help="Session routing expression for passthrough targets [non-interactive]",
|
|
669
|
+
),
|
|
670
|
+
stickiness_timeout: str | None = typer.Option(
|
|
671
|
+
None,
|
|
672
|
+
"--stickiness-timeout",
|
|
673
|
+
help="Sticky session timeout in seconds (1-86400) [non-interactive]",
|
|
674
|
+
),
|
|
675
|
+
signing_service: str | None = typer.Option(
|
|
676
|
+
None,
|
|
677
|
+
"--signing-service",
|
|
678
|
+
help="SigV4 signing service name for passthrough GATEWAY_IAM_ROLE auth [non-interactive]",
|
|
679
|
+
),
|
|
680
|
+
signing_region: str | None = typer.Option(
|
|
681
|
+
None,
|
|
682
|
+
"--signing-region",
|
|
683
|
+
help="SigV4 signing region for passthrough (defaults to project region) [non-interactive]",
|
|
684
|
+
),
|
|
685
|
+
as_json: bool = typer.Option(False, "--json", help="Output as JSON [non-interactive]"),
|
|
686
|
+
) -> None:
|
|
687
|
+
if not find_config_root():
|
|
688
|
+
typer.echo("No agentcore project found. Run `agentcore create` first.", err=True)
|
|
689
|
+
raise typer.Exit(1)
|
|
690
|
+
|
|
691
|
+
o: dict[str, Any] = {
|
|
692
|
+
"name": name,
|
|
693
|
+
"description": description,
|
|
694
|
+
"gateway": gateway,
|
|
695
|
+
"type": type_,
|
|
696
|
+
"connector": connector,
|
|
697
|
+
"knowledgeBaseId": list(knowledge_base_id or []),
|
|
698
|
+
"excludeDomains": exclude_domains[0] if exclude_domains else None,
|
|
699
|
+
"endpoint": endpoint,
|
|
700
|
+
"language": language,
|
|
701
|
+
"host": host,
|
|
702
|
+
"outboundAuthType": outbound_auth,
|
|
703
|
+
"credentialName": credential_name,
|
|
704
|
+
"oauthClientId": oauth_client_id,
|
|
705
|
+
"oauthClientSecret": oauth_client_secret,
|
|
706
|
+
"oauthDiscoveryUrl": oauth_discovery_url,
|
|
707
|
+
"oauthScopes": oauth_scopes,
|
|
708
|
+
"restApiId": rest_api_id,
|
|
709
|
+
"stage": stage,
|
|
710
|
+
"toolFilterPath": tool_filter_path,
|
|
711
|
+
"toolFilterMethods": tool_filter_methods,
|
|
712
|
+
"schema": schema,
|
|
713
|
+
"schemaS3Account": schema_s3_account,
|
|
714
|
+
"lambdaArn": lambda_arn,
|
|
715
|
+
"toolSchemaFile": tool_schema_file,
|
|
716
|
+
"runtime": runtime,
|
|
717
|
+
"runtimeEndpoint": runtime_endpoint,
|
|
718
|
+
"passthroughEndpoint": passthrough_endpoint,
|
|
719
|
+
"passthroughProtocol": passthrough_protocol,
|
|
720
|
+
"stickinessIdentifier": stickiness_identifier,
|
|
721
|
+
"stickinessTimeout": stickiness_timeout,
|
|
722
|
+
"signingService": signing_service,
|
|
723
|
+
"signingRegion": signing_region,
|
|
724
|
+
}
|
|
725
|
+
user_passed_any_flag = (
|
|
726
|
+
as_json or any(v not in (None, False, []) for v in o.values()) or bool(exclude_domains)
|
|
727
|
+
)
|
|
728
|
+
if not user_passed_any_flag:
|
|
729
|
+
try:
|
|
730
|
+
interactive.require_tty()
|
|
731
|
+
self.add_interactive()
|
|
732
|
+
except typer.Exit:
|
|
733
|
+
raise
|
|
734
|
+
except Exception as exc: # noqa: BLE001
|
|
735
|
+
typer.echo(get_error_message(exc), err=True)
|
|
736
|
+
raise typer.Exit(1) from None
|
|
737
|
+
raise typer.Exit(0)
|
|
738
|
+
|
|
739
|
+
run_cli_command(as_json, lambda: self._run_add(o, exclude_domains, as_json))
|
|
740
|
+
|
|
741
|
+
@remove_app.command("gateway-target", help="Remove a gateway target from the project")
|
|
742
|
+
def remove_command(
|
|
743
|
+
name: str | None = typer.Option(None, "--name", help="Name of resource to remove [non-interactive]"),
|
|
744
|
+
yes: bool = typer.Option(False, "-y", "--yes", help="Skip confirmation prompt [non-interactive]"),
|
|
745
|
+
as_json: bool = typer.Option(False, "--json", help="Output as JSON [non-interactive]"),
|
|
746
|
+
) -> None:
|
|
747
|
+
self._run_remove(name, yes, as_json)
|
|
748
|
+
|
|
749
|
+
def _run_add(self, o: dict[str, Any], exclude_domains_all: list[str], as_json: bool) -> None: # noqa: C901, PLR0912, PLR0915
|
|
750
|
+
if len(exclude_domains_all) > 1:
|
|
751
|
+
raise ValidationError(
|
|
752
|
+
"--exclude-domains may only be specified once. Pass all domains as a single comma-separated value."
|
|
753
|
+
)
|
|
754
|
+
validation = validate_add_gateway_target_options(o)
|
|
755
|
+
if not validation.valid:
|
|
756
|
+
raise ValidationError(validation.error or "")
|
|
757
|
+
|
|
758
|
+
def done(tool_name: str, text: str | None = None, **extra: Any) -> None:
|
|
759
|
+
if as_json:
|
|
760
|
+
emit_json({"success": True, "toolName": tool_name, **extra})
|
|
761
|
+
else:
|
|
762
|
+
typer.echo(text or f"Added gateway target '{tool_name}'")
|
|
763
|
+
|
|
764
|
+
target_type = o["type"]
|
|
765
|
+
auth = _outbound_auth(o["outboundAuthType"], o["credentialName"])
|
|
766
|
+
|
|
767
|
+
if target_type == "apiGateway":
|
|
768
|
+
config: dict[str, Any] = {
|
|
769
|
+
"name": o["name"],
|
|
770
|
+
"gateway": o["gateway"],
|
|
771
|
+
"restApiId": o["restApiId"],
|
|
772
|
+
"stage": o["stage"],
|
|
773
|
+
}
|
|
774
|
+
if o["toolFilterPath"]:
|
|
775
|
+
config["toolFilters"] = [
|
|
776
|
+
{"filterPath": o["toolFilterPath"], "methods": _csv(o["toolFilterMethods"]) or ["GET"]}
|
|
777
|
+
]
|
|
778
|
+
if auth:
|
|
779
|
+
config["outboundAuth"] = auth
|
|
780
|
+
done(self.create_api_gateway_target(config)["toolName"])
|
|
781
|
+
return
|
|
782
|
+
|
|
783
|
+
if target_type in ("openApiSchema", "smithyModel") and o["schema"]:
|
|
784
|
+
schema = o["schema"]
|
|
785
|
+
if schema.startswith("s3://"):
|
|
786
|
+
s3: dict[str, Any] = {"uri": schema}
|
|
787
|
+
if o["schemaS3Account"]:
|
|
788
|
+
s3["bucketOwnerAccountId"] = o["schemaS3Account"]
|
|
789
|
+
schema_source: dict[str, Any] = {"s3": s3}
|
|
790
|
+
else:
|
|
791
|
+
schema_source = {"inline": {"path": schema}}
|
|
792
|
+
config = {
|
|
793
|
+
"name": o["name"],
|
|
794
|
+
"targetType": target_type,
|
|
795
|
+
"schemaSource": schema_source,
|
|
796
|
+
"gateway": o["gateway"],
|
|
797
|
+
}
|
|
798
|
+
if auth:
|
|
799
|
+
config["outboundAuth"] = auth
|
|
800
|
+
done(self.create_schema_based_gateway_target(config)["toolName"])
|
|
801
|
+
return
|
|
802
|
+
|
|
803
|
+
if target_type == "lambdaFunctionArn":
|
|
804
|
+
config = {
|
|
805
|
+
"name": o["name"],
|
|
806
|
+
"gateway": o["gateway"],
|
|
807
|
+
"lambdaArn": o["lambdaArn"],
|
|
808
|
+
"toolSchemaFile": o["toolSchemaFile"],
|
|
809
|
+
}
|
|
810
|
+
done(self.create_lambda_function_arn_target(config)["toolName"])
|
|
811
|
+
return
|
|
812
|
+
|
|
813
|
+
if target_type == "httpRuntime":
|
|
814
|
+
config = {
|
|
815
|
+
"name": o["name"],
|
|
816
|
+
"gateway": o["gateway"],
|
|
817
|
+
"runtime": o["runtime"],
|
|
818
|
+
"endpoint": o["runtimeEndpoint"] if o["runtimeEndpoint"] is not None else o["endpoint"],
|
|
819
|
+
}
|
|
820
|
+
if o["outboundAuthType"] and o["outboundAuthType"] != "NONE":
|
|
821
|
+
config["outboundAuth"] = {
|
|
822
|
+
"type": OUTBOUND_AUTH_MAP.get(o["outboundAuthType"].lower(), "NONE"),
|
|
823
|
+
"credentialName": o["credentialName"],
|
|
824
|
+
"scopes": _csv(o["oauthScopes"]),
|
|
825
|
+
}
|
|
826
|
+
done(self.create_http_runtime_target(config)["toolName"])
|
|
827
|
+
return
|
|
828
|
+
|
|
829
|
+
if target_type == "connector":
|
|
830
|
+
valid = ", ".join(CONNECTOR_ID_VALUES)
|
|
831
|
+
if not o["connector"]:
|
|
832
|
+
raise ValidationError(f"--connector is required for connector targets ({valid}).")
|
|
833
|
+
if o["connector"] not in CONNECTOR_ID_VALUES:
|
|
834
|
+
raise ValidationError(f"Unknown --connector value '{o['connector']}'. Valid: {valid}.")
|
|
835
|
+
if o["connector"] == "web-search":
|
|
836
|
+
excludes = (
|
|
837
|
+
[d.strip() for d in o["excludeDomains"].split(",") if d.strip()]
|
|
838
|
+
if isinstance(o["excludeDomains"], str)
|
|
839
|
+
else None
|
|
840
|
+
)
|
|
841
|
+
config = {"name": o["name"], "gateway": o["gateway"]}
|
|
842
|
+
if excludes:
|
|
843
|
+
config["excludeDomains"] = excludes
|
|
844
|
+
tool_name = self.create_web_search_gateway_target(config)["toolName"]
|
|
845
|
+
suffix = f" (excludeDomains={','.join(excludes)})" if excludes else ""
|
|
846
|
+
done(tool_name, f"Added web-search gateway target '{tool_name}' on '{o['gateway']}'{suffix}")
|
|
847
|
+
return
|
|
848
|
+
|
|
849
|
+
kb_refs = o["knowledgeBaseId"] or []
|
|
850
|
+
if not kb_refs:
|
|
851
|
+
raise ValidationError(f"--knowledge-base-id is required for --connector {o['connector']}.")
|
|
852
|
+
if len(kb_refs) > 1:
|
|
853
|
+
raise ValidationError(
|
|
854
|
+
"--knowledge-base-id may only be specified once for --connector bedrock-knowledge-bases."
|
|
855
|
+
)
|
|
856
|
+
resolved_name = o["name"] or f"kb-{o['gateway']}-{kb_refs[0]}".replace("_", "-")[:128]
|
|
857
|
+
config = {
|
|
858
|
+
"name": resolved_name,
|
|
859
|
+
"gateway": o["gateway"],
|
|
860
|
+
"connectorId": o["connector"],
|
|
861
|
+
"knowledgeBaseId": kb_refs[0],
|
|
862
|
+
}
|
|
863
|
+
tool_name = self.create_connector_gateway_target(config)["toolName"]
|
|
864
|
+
done(
|
|
865
|
+
tool_name,
|
|
866
|
+
f"Added connector gateway target '{tool_name}' on '{o['gateway']}' → {o['connector']} (KB {kb_refs[0]})",
|
|
867
|
+
)
|
|
868
|
+
return
|
|
869
|
+
|
|
870
|
+
if target_type == "passthrough":
|
|
871
|
+
if not o["passthroughEndpoint"]:
|
|
872
|
+
raise ValidationError("--passthrough-endpoint is required for passthrough type")
|
|
873
|
+
from agentcore.primitives._gateway_validation import js_parse_int
|
|
874
|
+
|
|
875
|
+
timeout = js_parse_int(o["stickinessTimeout"]) if o["stickinessTimeout"] else None
|
|
876
|
+
raw_protocol = o["passthroughProtocol"]
|
|
877
|
+
protocol = raw_protocol.upper() if raw_protocol is not None else "CUSTOM"
|
|
878
|
+
if protocol not in PASSTHROUGH_PROTOCOL_TYPES:
|
|
879
|
+
raise ValidationError(
|
|
880
|
+
f'Invalid --passthrough-protocol "{raw_protocol}". Must be one of: '
|
|
881
|
+
f"{', '.join(PASSTHROUGH_PROTOCOL_TYPES)}"
|
|
882
|
+
)
|
|
883
|
+
passthrough_auth: dict[str, Any] | None = None
|
|
884
|
+
if o["outboundAuthType"]:
|
|
885
|
+
mapped = OUTBOUND_AUTH_MAP.get(o["outboundAuthType"].lower(), "NONE")
|
|
886
|
+
if mapped == "GATEWAY_IAM_ROLE":
|
|
887
|
+
if not o["signingService"]:
|
|
888
|
+
raise ValidationError(
|
|
889
|
+
"--signing-service is required when --outbound-auth is GATEWAY_IAM_ROLE for passthrough "
|
|
890
|
+
"targets"
|
|
891
|
+
)
|
|
892
|
+
passthrough_auth = {"type": "GATEWAY_IAM_ROLE", "service": o["signingService"]}
|
|
893
|
+
if o["signingRegion"]:
|
|
894
|
+
passthrough_auth["region"] = o["signingRegion"]
|
|
895
|
+
elif mapped == "JWT_PASSTHROUGH":
|
|
896
|
+
passthrough_auth = {"type": "JWT_PASSTHROUGH"}
|
|
897
|
+
elif mapped != "NONE":
|
|
898
|
+
passthrough_auth = {
|
|
899
|
+
"type": mapped,
|
|
900
|
+
"credentialName": o["credentialName"],
|
|
901
|
+
"scopes": _csv(o["oauthScopes"]),
|
|
902
|
+
}
|
|
903
|
+
config = {
|
|
904
|
+
"name": o["name"],
|
|
905
|
+
"gateway": o["gateway"],
|
|
906
|
+
"passthroughEndpoint": o["passthroughEndpoint"],
|
|
907
|
+
"protocolType": protocol,
|
|
908
|
+
"stickinessIdentifier": o["stickinessIdentifier"],
|
|
909
|
+
"stickinessTimeout": timeout,
|
|
910
|
+
"outboundAuth": passthrough_auth,
|
|
911
|
+
}
|
|
912
|
+
done(self.create_passthrough_target(config)["toolName"])
|
|
913
|
+
return
|
|
914
|
+
|
|
915
|
+
if target_type == "mcpServer" and o["endpoint"]:
|
|
916
|
+
desc = o["description"] if o["description"] is not None else f"Tool for {o['name']}"
|
|
917
|
+
config = {
|
|
918
|
+
"name": o["name"],
|
|
919
|
+
"description": desc,
|
|
920
|
+
"endpoint": o["endpoint"],
|
|
921
|
+
"gateway": o["gateway"],
|
|
922
|
+
"toolDefinition": {"name": o["name"], "description": desc, "inputSchema": {"type": "object"}},
|
|
923
|
+
}
|
|
924
|
+
if auth:
|
|
925
|
+
config["outboundAuth"] = auth
|
|
926
|
+
result = self.create_external_gateway_target(config)
|
|
927
|
+
done(result["toolName"], sourcePath=result["projectPath"] or None)
|
|
928
|
+
return
|
|
929
|
+
|
|
930
|
+
result = self.add(
|
|
931
|
+
AddGatewayTargetOptions(
|
|
932
|
+
name=o["name"],
|
|
933
|
+
description=o["description"],
|
|
934
|
+
language=o["language"] or "Python",
|
|
935
|
+
gateway=o["gateway"],
|
|
936
|
+
host=o["host"],
|
|
937
|
+
)
|
|
938
|
+
)
|
|
939
|
+
if not result.success:
|
|
940
|
+
raise result.error
|
|
941
|
+
if as_json:
|
|
942
|
+
emit_json(serialize_result(result))
|
|
943
|
+
else:
|
|
944
|
+
typer.echo(f"Added gateway target '{result.value['toolName']}'")
|
|
945
|
+
if result.value["sourcePath"]:
|
|
946
|
+
typer.echo(f"Tool code: {result.value['sourcePath']}")
|
|
947
|
+
|
|
948
|
+
def _run_remove(self, name: str | None, yes: bool, as_json: bool) -> None:
|
|
949
|
+
try:
|
|
950
|
+
if not find_config_root():
|
|
951
|
+
typer.echo("No agentcore project found. Run `agentcore create` first.", err=True)
|
|
952
|
+
raise typer.Exit(1)
|
|
953
|
+
if name or yes or as_json:
|
|
954
|
+
if not name:
|
|
955
|
+
emit_json({"success": False, "error": "--name is required"})
|
|
956
|
+
raise typer.Exit(1)
|
|
957
|
+
result = self.remove(name)
|
|
958
|
+
emit_json(
|
|
959
|
+
{
|
|
960
|
+
"success": result.success,
|
|
961
|
+
"resourceType": self.kind,
|
|
962
|
+
"resourceName": name,
|
|
963
|
+
"message": f"Removed gateway target '{name}'" if result.success else None,
|
|
964
|
+
"note": SOURCE_CODE_NOTE if result.success else None,
|
|
965
|
+
"error": None if result.success else get_error_message(result.error),
|
|
966
|
+
}
|
|
967
|
+
)
|
|
968
|
+
raise typer.Exit(0 if result.success else 1)
|
|
969
|
+
interactive.require_tty()
|
|
970
|
+
self.remove_interactive()
|
|
971
|
+
except typer.Exit:
|
|
972
|
+
raise
|
|
973
|
+
except Exception as exc: # noqa: BLE001
|
|
974
|
+
if as_json:
|
|
975
|
+
emit_json({"success": False, "error": get_error_message(exc)})
|
|
976
|
+
else:
|
|
977
|
+
typer.echo(f"Error: {get_error_message(exc)}", err=True)
|
|
978
|
+
raise typer.Exit(1) from None
|
|
979
|
+
|
|
980
|
+
# --- interactive (port of tui/screens/mcp AddGatewayTargetScreen + Flow) -----------------
|
|
981
|
+
|
|
982
|
+
def add_interactive(self) -> None:
|
|
983
|
+
from agentcore.primitives._gateway_target_wizard import run_add_gateway_target_wizard
|
|
984
|
+
|
|
985
|
+
run_add_gateway_target_wizard(self)
|
|
986
|
+
|
|
987
|
+
|
|
988
|
+
PRIMITIVE = GatewayTargetPrimitive()
|