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,449 @@
|
|
|
1
|
+
"""Base translator for converting Bedrock Agent configurations into Python code
|
|
2
|
+
(port of operations/agent/import/base-translator.ts, itself a port of the starter toolkit's
|
|
3
|
+
base_bedrock_translate.py).
|
|
4
|
+
|
|
5
|
+
Generated code must stay byte-identical to upstream, so templates are built by plain string
|
|
6
|
+
concatenation and numbers/JSON are formatted the way JavaScript does.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import math
|
|
13
|
+
import re
|
|
14
|
+
from abc import ABC, abstractmethod
|
|
15
|
+
from dataclasses import dataclass, field
|
|
16
|
+
from typing import Any, Literal
|
|
17
|
+
|
|
18
|
+
from agentcore.aws.partition import arn_prefix
|
|
19
|
+
from agentcore.schema._zod import js_regex
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class TranslatorOptions:
|
|
24
|
+
agent_config: Any
|
|
25
|
+
enable_memory: bool
|
|
26
|
+
memory_option: str
|
|
27
|
+
enable_observability: bool
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@dataclass
|
|
31
|
+
class ImportedFeatures:
|
|
32
|
+
has_memory: bool = False
|
|
33
|
+
has_knowledge_bases: bool = False
|
|
34
|
+
has_action_groups: bool = False
|
|
35
|
+
has_code_interpreter: bool = False
|
|
36
|
+
has_multi_agent: bool = False
|
|
37
|
+
has_guardrails: bool = False
|
|
38
|
+
has_gateway: bool = False
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@dataclass
|
|
42
|
+
class TranslationResult:
|
|
43
|
+
main_py_content: str
|
|
44
|
+
collaborator_files: dict[str, str] = field(default_factory=dict)
|
|
45
|
+
features: ImportedFeatures = field(default_factory=ImportedFeatures)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
@dataclass(frozen=True)
|
|
49
|
+
class CollaboratorContext:
|
|
50
|
+
name: str
|
|
51
|
+
instruction: str
|
|
52
|
+
relay_history: str
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def nn(*values: Any) -> Any:
|
|
56
|
+
"""JavaScript ``a ?? b ?? c``: the first value that is not None."""
|
|
57
|
+
for value in values:
|
|
58
|
+
if value is not None:
|
|
59
|
+
return value
|
|
60
|
+
return None
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def js_num(value: Any) -> str:
|
|
64
|
+
"""Format a number like JavaScript template-literal interpolation."""
|
|
65
|
+
if isinstance(value, bool):
|
|
66
|
+
return "true" if value else "false"
|
|
67
|
+
if isinstance(value, float):
|
|
68
|
+
if math.isnan(value):
|
|
69
|
+
return "NaN"
|
|
70
|
+
if math.isinf(value):
|
|
71
|
+
return "Infinity" if value > 0 else "-Infinity"
|
|
72
|
+
if value.is_integer() and abs(value) < 1e21:
|
|
73
|
+
return str(int(value))
|
|
74
|
+
return repr(value)
|
|
75
|
+
return str(value)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def js_json(value: Any) -> str:
|
|
79
|
+
"""``JSON.stringify(value)`` (compact)."""
|
|
80
|
+
return json.dumps(value, separators=(",", ":"), ensure_ascii=False)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def arn_region(arn: str | None) -> str | None:
|
|
84
|
+
"""``arn?.split(':')[3]``."""
|
|
85
|
+
if arn is None:
|
|
86
|
+
return None
|
|
87
|
+
parts = arn.split(":")
|
|
88
|
+
return parts[3] if len(parts) > 3 else None
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
def js_replace_first(text: str, search: str, replacement: str) -> str:
|
|
92
|
+
"""``String.prototype.replace(string, string)``: first occurrence, with ``$`` patterns expanded."""
|
|
93
|
+
idx = text.find(search)
|
|
94
|
+
if idx == -1:
|
|
95
|
+
return text
|
|
96
|
+
before, after = text[:idx], text[idx + len(search) :]
|
|
97
|
+
out: list[str] = []
|
|
98
|
+
i = 0
|
|
99
|
+
while i < len(replacement):
|
|
100
|
+
ch = replacement[i]
|
|
101
|
+
if ch == "$" and i + 1 < len(replacement):
|
|
102
|
+
nxt = replacement[i + 1]
|
|
103
|
+
if nxt == "$":
|
|
104
|
+
out.append("$")
|
|
105
|
+
i += 2
|
|
106
|
+
continue
|
|
107
|
+
if nxt == "&":
|
|
108
|
+
out.append(search)
|
|
109
|
+
i += 2
|
|
110
|
+
continue
|
|
111
|
+
if nxt == "`":
|
|
112
|
+
out.append(before)
|
|
113
|
+
i += 2
|
|
114
|
+
continue
|
|
115
|
+
if nxt == "'":
|
|
116
|
+
out.append(after)
|
|
117
|
+
i += 2
|
|
118
|
+
continue
|
|
119
|
+
out.append(ch)
|
|
120
|
+
i += 1
|
|
121
|
+
return before + "".join(out) + after
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
_NON_IDENT = re.compile(r"[^a-zA-Z0-9_]")
|
|
125
|
+
_LEADING_DIGIT = re.compile(r"^([0-9])")
|
|
126
|
+
_JS_WHITESPACE = js_regex(r"\s")
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def sanitize_py_identifier(name: str) -> str:
|
|
130
|
+
"""Sanitize a string to be a valid Python identifier."""
|
|
131
|
+
return _LEADING_DIGIT.sub(r"_\1", _NON_IDENT.sub("_", name))
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
def escape_py_double_quote(s: str) -> str:
|
|
135
|
+
"""Escape a string for use inside Python double-quoted strings."""
|
|
136
|
+
return s.replace("\\", "\\\\").replace('"', '\\"').replace("\n", "\\n")
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def escape_py_single_quote(s: str) -> str:
|
|
140
|
+
"""Escape a string for use inside Python single-quoted strings."""
|
|
141
|
+
return s.replace("\\", "\\\\").replace("'", "\\'").replace("\n", "\\n")
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def escape_py_triple_quote(s: str) -> str:
|
|
145
|
+
"""Escape a string for use inside Python triple-quoted strings."""
|
|
146
|
+
return s.replace("\\", "\\\\").replace('"""', '\\"\\"\\"')
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
class BaseBedrockTranslator(ABC):
|
|
150
|
+
"""Shared translation logic between the Strands and LangChain translators."""
|
|
151
|
+
|
|
152
|
+
escape_py_double_quote = staticmethod(escape_py_double_quote)
|
|
153
|
+
escape_py_single_quote = staticmethod(escape_py_single_quote)
|
|
154
|
+
escape_py_triple_quote = staticmethod(escape_py_triple_quote)
|
|
155
|
+
|
|
156
|
+
def __init__(
|
|
157
|
+
self,
|
|
158
|
+
config: Any,
|
|
159
|
+
options: TranslatorOptions,
|
|
160
|
+
collaborator_context: CollaboratorContext | None = None,
|
|
161
|
+
) -> None:
|
|
162
|
+
self.config = config
|
|
163
|
+
self.options = options
|
|
164
|
+
self.collaborator_context = collaborator_context
|
|
165
|
+
|
|
166
|
+
self.agent_info: dict[str, Any] = config.get("agent") or {}
|
|
167
|
+
self.action_groups: list[dict[str, Any]] = [
|
|
168
|
+
ag
|
|
169
|
+
for ag in (nn(config.get("action_groups"), []) or [])
|
|
170
|
+
if nn(ag.get("actionGroupState"), "ENABLED") == "ENABLED"
|
|
171
|
+
]
|
|
172
|
+
self.custom_action_groups = [ag for ag in self.action_groups if not ag.get("parentActionSignature")]
|
|
173
|
+
self.knowledge_bases: list[dict[str, Any]] = nn(config.get("knowledge_bases"), [])
|
|
174
|
+
self.collaborators: list[dict[str, Any]] = nn(config.get("collaborators"), [])
|
|
175
|
+
|
|
176
|
+
info = self.agent_info
|
|
177
|
+
self.model_id: str = nn(info.get("foundationModel"), "")
|
|
178
|
+
self.agent_region: str = nn(arn_region(info.get("agentArn")), "us-east-1")
|
|
179
|
+
self.instruction: str = nn(info.get("instruction"), "")
|
|
180
|
+
self.prompt_configs: list[dict[str, Any]] = nn(
|
|
181
|
+
(info.get("promptOverrideConfiguration") or {}).get("promptConfigurations"), []
|
|
182
|
+
)
|
|
183
|
+
self.enabled_prompts: list[str] = []
|
|
184
|
+
|
|
185
|
+
# Memory
|
|
186
|
+
memory_config = info.get("memoryConfiguration") or {}
|
|
187
|
+
self.memory_enabled = bool(memory_config.get("enabledMemoryTypes"))
|
|
188
|
+
self.agentcore_memory_enabled = options.enable_memory and self.memory_enabled
|
|
189
|
+
self.has_long_term_strategies = options.memory_option == "longAndShortTerm"
|
|
190
|
+
|
|
191
|
+
# Features
|
|
192
|
+
self.code_interpreter_enabled = any(
|
|
193
|
+
ag.get("actionGroupName") == "codeinterpreteraction" and ag.get("actionGroupState") == "ENABLED"
|
|
194
|
+
for ag in self.action_groups
|
|
195
|
+
)
|
|
196
|
+
self.user_input_enabled = any(
|
|
197
|
+
ag.get("actionGroupName") == "userinputaction" and ag.get("actionGroupState") == "ENABLED"
|
|
198
|
+
for ag in self.action_groups
|
|
199
|
+
)
|
|
200
|
+
self.multi_agent_enabled = (
|
|
201
|
+
nn(info.get("agentCollaboration"), "DISABLED") != "DISABLED" and len(self.collaborators) > 0
|
|
202
|
+
)
|
|
203
|
+
self.supervision_type: str = nn(info.get("agentCollaboration"), "SUPERVISOR")
|
|
204
|
+
self.observability_enabled = options.enable_observability
|
|
205
|
+
|
|
206
|
+
# Guardrails
|
|
207
|
+
self.guardrail_config: dict[str, str] = {}
|
|
208
|
+
gc = info.get("guardrailConfiguration")
|
|
209
|
+
if gc:
|
|
210
|
+
g_id = nn(gc.get("guardrailId"), gc.get("guardrailIdentifier"), "")
|
|
211
|
+
g_version = nn(gc.get("version"), gc.get("guardrailVersion"), "")
|
|
212
|
+
if g_id:
|
|
213
|
+
self.guardrail_config = {"guardrailIdentifier": g_id, "guardrailVersion": g_version}
|
|
214
|
+
|
|
215
|
+
# Collaboration context
|
|
216
|
+
self.is_collaborator = collaborator_context is not None
|
|
217
|
+
self.is_accepting_relays = (
|
|
218
|
+
collaborator_context is not None and collaborator_context.relay_history == "TO_COLLABORATOR"
|
|
219
|
+
)
|
|
220
|
+
self.collaborator_descriptions = [
|
|
221
|
+
"{'agentName': '"
|
|
222
|
+
+ escape_py_single_quote(nn((c.get("agent") or {}).get("agentName"), ""))
|
|
223
|
+
+ "', 'collaboratorName': 'invoke_"
|
|
224
|
+
+ sanitize_py_identifier(nn(c.get("collaboratorName"), ""))
|
|
225
|
+
+ "', 'collaboratorInstruction': '"
|
|
226
|
+
+ escape_py_triple_quote(nn(c.get("collaborationInstruction"), ""))
|
|
227
|
+
+ "'}"
|
|
228
|
+
for c in self.collaborators
|
|
229
|
+
]
|
|
230
|
+
self.collaborator_map = {nn(c.get("collaboratorName"), ""): c for c in self.collaborators}
|
|
231
|
+
|
|
232
|
+
agent_name = nn(info.get("agentName"), "agent")
|
|
233
|
+
self.cleaned_agent_name = _JS_WHITESPACE.sub("_", agent_name).replace("-", "_").lower()[:30]
|
|
234
|
+
|
|
235
|
+
self.tools: list[str] = []
|
|
236
|
+
|
|
237
|
+
# Base imports (common to both frameworks)
|
|
238
|
+
self.imports_code = """# ---------- NOTE: This file is auto-generated by AgentCore CLI (Import from Bedrock Agents). ----------
|
|
239
|
+
# Use this agent definition as a starting point for your custom agent implementation.
|
|
240
|
+
# Review the generated code, evaluate agent behavior, and make necessary changes before deploying.
|
|
241
|
+
# -------------------------------------------------------------------------------------------------
|
|
242
|
+
|
|
243
|
+
import json, sys, os, re, io, uuid, asyncio
|
|
244
|
+
from typing import Annotated
|
|
245
|
+
import boto3
|
|
246
|
+
|
|
247
|
+
from bedrock_agentcore.runtime import BedrockAgentCoreApp
|
|
248
|
+
"""
|
|
249
|
+
if not self.is_collaborator:
|
|
250
|
+
self.imports_code += "\napp = BedrockAgentCoreApp()\n"
|
|
251
|
+
|
|
252
|
+
self.prompts_code = ""
|
|
253
|
+
|
|
254
|
+
@abstractmethod
|
|
255
|
+
def translate(self) -> TranslationResult: ...
|
|
256
|
+
|
|
257
|
+
def generate_prompts(self) -> str:
|
|
258
|
+
"""Prompt variable assignments for enabled prompt overrides."""
|
|
259
|
+
code = ""
|
|
260
|
+
for config in self.prompt_configs:
|
|
261
|
+
prompt_type = nn(config.get("promptType"), "")
|
|
262
|
+
template = (config.get("basePromptTemplate") or {}).get("system")
|
|
263
|
+
if not template:
|
|
264
|
+
continue
|
|
265
|
+
self.enabled_prompts.append(prompt_type)
|
|
266
|
+
processed = template
|
|
267
|
+
if prompt_type == "ORCHESTRATION":
|
|
268
|
+
processed = js_replace_first(processed, "$instruction$", self.instruction)
|
|
269
|
+
code += f'\n{prompt_type}_TEMPLATE = """{escape_py_triple_quote(processed)}"""\n'
|
|
270
|
+
|
|
271
|
+
if "ORCHESTRATION" not in self.enabled_prompts:
|
|
272
|
+
code += f'\nORCHESTRATION_TEMPLATE = """{escape_py_triple_quote(self.instruction)}"""\n'
|
|
273
|
+
self.enabled_prompts.append("ORCHESTRATION")
|
|
274
|
+
return code
|
|
275
|
+
|
|
276
|
+
def generate_function_action_group_tools(self) -> str:
|
|
277
|
+
"""Function-schema action groups as @tool decorated functions."""
|
|
278
|
+
code = "\n# --- Action Group Tools ---\naction_group_tools = []\n"
|
|
279
|
+
for ag in self.custom_action_groups:
|
|
280
|
+
functions = (ag.get("functionSchema") or {}).get("functions")
|
|
281
|
+
if functions:
|
|
282
|
+
for fn in functions:
|
|
283
|
+
code += self._generate_function_tool(fn, ag.get("actionGroupName", ""))
|
|
284
|
+
return code
|
|
285
|
+
|
|
286
|
+
def _generate_function_tool(self, fn: dict[str, Any], group_name: str) -> str:
|
|
287
|
+
fn_name = _NON_IDENT.sub("_", fn["name"])
|
|
288
|
+
params = nn(fn.get("parameters"), {}) or {}
|
|
289
|
+
py_types = {"string": "str", "integer": "int", "number": "float", "boolean": "bool"}
|
|
290
|
+
param_list = ", ".join(
|
|
291
|
+
f"{name}: {py_types.get((info or {}).get('type'), 'str')}" for name, info in params.items()
|
|
292
|
+
)
|
|
293
|
+
description = nn(fn.get("description"), f"Function from action group {group_name}")
|
|
294
|
+
escaped_desc = escape_py_triple_quote(description)
|
|
295
|
+
return (
|
|
296
|
+
"\n@tool\n"
|
|
297
|
+
f"def {fn_name}({param_list}) -> str:\n"
|
|
298
|
+
f' """{escaped_desc}"""\n'
|
|
299
|
+
" # TODO: Implement the logic for this action group function.\n"
|
|
300
|
+
f' # This was imported from Bedrock Agent action group "{escape_py_double_quote(group_name)}".\n'
|
|
301
|
+
' return json.dumps({"status": "not_implemented", "function": "' + fn_name + '"})\n'
|
|
302
|
+
"\n"
|
|
303
|
+
f"action_group_tools.append({fn_name})\n"
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
def generate_memory_code(self, memory_saver: str) -> str:
|
|
307
|
+
if not self.memory_enabled:
|
|
308
|
+
return ""
|
|
309
|
+
code = "\n# --- Memory Configuration ---\n"
|
|
310
|
+
if self.agentcore_memory_enabled:
|
|
311
|
+
code += """
|
|
312
|
+
from bedrock_agentcore.memory import MemoryClient
|
|
313
|
+
|
|
314
|
+
memory_client = MemoryClient()
|
|
315
|
+
memory_id = os.environ.get("MEMORY_ID", "")
|
|
316
|
+
"""
|
|
317
|
+
code += f"checkpointer_STM = {memory_saver}()\n"
|
|
318
|
+
return code
|
|
319
|
+
|
|
320
|
+
def generate_entrypoint_code(self, platform: Literal["strands", "langchain"]) -> str:
|
|
321
|
+
code = ""
|
|
322
|
+
if not self.is_collaborator:
|
|
323
|
+
code += "\n@app.entrypoint\n"
|
|
324
|
+
|
|
325
|
+
memory_event_code = (
|
|
326
|
+
"""
|
|
327
|
+
event = memory_client.create_event(
|
|
328
|
+
memory_id=memory_id,
|
|
329
|
+
actor_id=user_id,
|
|
330
|
+
session_id=session_id,
|
|
331
|
+
messages=formatted_messages
|
|
332
|
+
)"""
|
|
333
|
+
if self.agentcore_memory_enabled
|
|
334
|
+
else ""
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
tools_used_update = (
|
|
338
|
+
"tools_used.update(list(agent_result.metrics.tool_metrics.keys()))"
|
|
339
|
+
if platform == "strands"
|
|
340
|
+
else "tools_used.update([msg.name for msg in agent_result if isinstance(msg, ToolMessage)])"
|
|
341
|
+
)
|
|
342
|
+
response_content = "str(agent_result)" if platform == "strands" else "agent_result[-1].content"
|
|
343
|
+
|
|
344
|
+
lines = ["async def invoke(payload, context):", " try:"]
|
|
345
|
+
if self.agentcore_memory_enabled:
|
|
346
|
+
lines.append(" global user_id")
|
|
347
|
+
lines.append(' user_id = user_id or payload.get("userId", uuid.uuid4().hex[:8])')
|
|
348
|
+
lines.extend(
|
|
349
|
+
[
|
|
350
|
+
' session_id = context.session_id or payload.get("sessionId", uuid.uuid4().hex[:8])',
|
|
351
|
+
"",
|
|
352
|
+
" tools_used.clear()",
|
|
353
|
+
' agent_query = payload.get("prompt", "")',
|
|
354
|
+
" if not isinstance(agent_query, str):",
|
|
355
|
+
' raise ValueError("prompt must be a string")',
|
|
356
|
+
" if not agent_query:",
|
|
357
|
+
" yield \"No query provided, please provide a 'prompt' field in the payload.\"",
|
|
358
|
+
" return",
|
|
359
|
+
"",
|
|
360
|
+
" agent_result = invoke_agent(agent_query)",
|
|
361
|
+
"",
|
|
362
|
+
" " + tools_used_update,
|
|
363
|
+
" response_content = " + response_content,
|
|
364
|
+
]
|
|
365
|
+
)
|
|
366
|
+
if memory_event_code:
|
|
367
|
+
lines.extend(
|
|
368
|
+
[
|
|
369
|
+
"",
|
|
370
|
+
' formatted_messages = [(agent_query, "USER"), (response_content if response_content else "No Response.", "ASSISTANT")]',
|
|
371
|
+
]
|
|
372
|
+
)
|
|
373
|
+
lines.append(memory_event_code)
|
|
374
|
+
lines.extend(
|
|
375
|
+
[
|
|
376
|
+
"",
|
|
377
|
+
' yield response_content if response_content else "No response."',
|
|
378
|
+
" except Exception as e:",
|
|
379
|
+
' yield f"Error: {e}"',
|
|
380
|
+
]
|
|
381
|
+
)
|
|
382
|
+
code += "\n".join(lines)
|
|
383
|
+
|
|
384
|
+
if not self.is_collaborator:
|
|
385
|
+
code += '\n\n\nif __name__ == "__main__":\n app.run()\n'
|
|
386
|
+
return code
|
|
387
|
+
|
|
388
|
+
def assemble_code(self, sections: list[str]) -> str:
|
|
389
|
+
return "\n".join(s for s in sections if s)
|
|
390
|
+
|
|
391
|
+
def generate_iam_permissions_comment(self) -> str:
|
|
392
|
+
"""Comment block listing required IAM permissions and a CDK snippet granting them."""
|
|
393
|
+
kb_arns: list[str] = []
|
|
394
|
+
for kb in self.knowledge_bases:
|
|
395
|
+
if kb.get("knowledgeBaseArn"):
|
|
396
|
+
kb_arns.append(kb["knowledgeBaseArn"])
|
|
397
|
+
elif kb.get("knowledgeBaseId"):
|
|
398
|
+
kb_arns.append(
|
|
399
|
+
f"{arn_prefix(self.agent_region)}:bedrock:{self.agent_region}:*:knowledge-base/{kb['knowledgeBaseId']}"
|
|
400
|
+
)
|
|
401
|
+
if not kb_arns:
|
|
402
|
+
return ""
|
|
403
|
+
|
|
404
|
+
arn_lines = "\n".join(f'# "{arn}",' for arn in kb_arns)
|
|
405
|
+
cdk_lines = "\n".join(f"# '{arn}'," for arn in kb_arns)
|
|
406
|
+
return (
|
|
407
|
+
"""
|
|
408
|
+
# -------------------------------------------------------------------------------------------------
|
|
409
|
+
# IMPORTANT: Additional IAM permissions required for deployment.
|
|
410
|
+
#
|
|
411
|
+
# This agent uses Bedrock Knowledge Base retrieval, which requires the
|
|
412
|
+
# "bedrock:Retrieve" permission on the following resources:
|
|
413
|
+
"""
|
|
414
|
+
+ arn_lines
|
|
415
|
+
+ """
|
|
416
|
+
#
|
|
417
|
+
# The vended CDK stack does not automatically grant these permissions.
|
|
418
|
+
# To add them, edit agentcore/cdk/lib/cdk-stack.ts:
|
|
419
|
+
#
|
|
420
|
+
# import * as iam from 'aws-cdk-lib/aws-iam';
|
|
421
|
+
#
|
|
422
|
+
# // After: this.application = new AgentCoreApplication(this, 'Application', { spec });
|
|
423
|
+
# // Use the agent name from agentcore/agentcore.json (the "name" field under "agents").
|
|
424
|
+
# const agentEnv = this.application.environments.get('<YOUR_AGENT_NAME>');
|
|
425
|
+
# if (agentEnv) {
|
|
426
|
+
# agentEnv.runtime.addToPolicy(new iam.PolicyStatement({
|
|
427
|
+
# actions: ['bedrock:Retrieve'],
|
|
428
|
+
# resources: [
|
|
429
|
+
"""
|
|
430
|
+
+ cdk_lines
|
|
431
|
+
+ """
|
|
432
|
+
# ],
|
|
433
|
+
# }));
|
|
434
|
+
# }
|
|
435
|
+
#
|
|
436
|
+
# -------------------------------------------------------------------------------------------------
|
|
437
|
+
"""
|
|
438
|
+
)
|
|
439
|
+
|
|
440
|
+
def get_features(self) -> ImportedFeatures:
|
|
441
|
+
return ImportedFeatures(
|
|
442
|
+
has_memory=self.memory_enabled,
|
|
443
|
+
has_knowledge_bases=len(self.knowledge_bases) > 0,
|
|
444
|
+
has_action_groups=len(self.custom_action_groups) > 0,
|
|
445
|
+
has_code_interpreter=self.code_interpreter_enabled,
|
|
446
|
+
has_multi_agent=self.multi_agent_enabled,
|
|
447
|
+
has_guardrails=len(self.guardrail_config) > 0,
|
|
448
|
+
has_gateway=False,
|
|
449
|
+
)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Constants for the Bedrock Agent import feature (port of operations/agent/import/constants.ts)."""
|
|
2
|
+
|
|
3
|
+
from typing import Final
|
|
4
|
+
|
|
5
|
+
from agentcore.operations.agent.generate.types import Option
|
|
6
|
+
|
|
7
|
+
BEDROCK_REGIONS: Final = (
|
|
8
|
+
Option("us-east-1", "US East (N. Virginia)"),
|
|
9
|
+
Option("us-west-2", "US West (Oregon)"),
|
|
10
|
+
Option("eu-west-1", "Europe (Ireland)"),
|
|
11
|
+
Option("eu-central-1", "Europe (Frankfurt)"),
|
|
12
|
+
Option("ap-southeast-1", "Asia Pacific (Singapore)"),
|
|
13
|
+
Option("ap-northeast-1", "Asia Pacific (Tokyo)"),
|
|
14
|
+
Option("ap-south-1", "Asia Pacific (Mumbai)"),
|
|
15
|
+
Option("ca-central-1", "Canada (Central)"),
|
|
16
|
+
Option("sa-east-1", "South America (Sao Paulo)"),
|
|
17
|
+
Option("us-gov-west-1", "GovCloud (US West)"),
|
|
18
|
+
)
|
|
19
|
+
|
|
20
|
+
IMPORT_FRAMEWORK_OPTIONS: Final = (
|
|
21
|
+
Option("Strands", "Strands Agents SDK", "AWS native agent framework"),
|
|
22
|
+
Option("LangChain_LangGraph", "LangChain + LangGraph", "Popular open-source frameworks"),
|
|
23
|
+
)
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"""Bedrock Agent import entry point (port of operations/agent/import/index.ts executeImportAgent).
|
|
2
|
+
|
|
3
|
+
Shared by the interactive `add agent` flow and the non-interactive CLI (AgentPrimitive / create).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from __future__ import annotations
|
|
7
|
+
|
|
8
|
+
import os
|
|
9
|
+
from dataclasses import dataclass
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from agentcore.lib import APP_DIR, ConfigIO
|
|
13
|
+
from agentcore.lib.errors.types import to_error
|
|
14
|
+
from agentcore.lib.result import Err, Ok
|
|
15
|
+
from agentcore.operations.agent.import_.base_translator import TranslatorOptions
|
|
16
|
+
from agentcore.operations.agent.import_.langgraph_translator import LangGraphTranslator
|
|
17
|
+
from agentcore.operations.agent.import_.pyproject_generator import generate_pyproject_toml
|
|
18
|
+
from agentcore.operations.agent.import_.strands_translator import StrandsTranslator
|
|
19
|
+
from agentcore.primitives.auth_utils import JwtConfigOptions, create_managed_oauth_credential
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class ExecuteImportAgentParams:
|
|
24
|
+
name: str
|
|
25
|
+
framework: str
|
|
26
|
+
memory: str
|
|
27
|
+
bedrock_region: str
|
|
28
|
+
bedrock_agent_id: str
|
|
29
|
+
bedrock_alias_id: str
|
|
30
|
+
config_base_dir: str
|
|
31
|
+
authorizer_type: str | None = None
|
|
32
|
+
jwt_config: JwtConfigOptions | None = None
|
|
33
|
+
idle_timeout: int | None = None
|
|
34
|
+
max_lifetime: int | None = None
|
|
35
|
+
session_storage_mount_path: str | None = None
|
|
36
|
+
efs_access_points: list[dict[str, Any]] | None = None
|
|
37
|
+
s3_access_points: list[dict[str, Any]] | None = None
|
|
38
|
+
# Attach the imported runtime to a capacity provider (camelCase dict: capacityProviderName/Arn).
|
|
39
|
+
capacity_provider_configuration: dict[str, Any] | None = None
|
|
40
|
+
# Capacity-provider volume mounts (camelCase dicts: volumeName, mountPath).
|
|
41
|
+
capacity_provider_volumes: list[dict[str, Any]] | None = None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def _write(path: str, content: str) -> None:
|
|
45
|
+
with open(path, "w", encoding="utf-8", newline="") as fh:
|
|
46
|
+
fh.write(content)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def execute_import_agent(params: ExecuteImportAgentParams) -> Ok[dict[str, str]] | Err[BaseException]:
|
|
50
|
+
# Imported lazily: these modules import this package's siblings / are written concurrently.
|
|
51
|
+
from agentcore.aws.bedrock_import import get_bedrock_agent_config
|
|
52
|
+
from agentcore.operations.agent.generate import write_agent_to_project
|
|
53
|
+
from agentcore.operations.agent.generate.types import GenerateConfig
|
|
54
|
+
from agentcore.operations.python import setup_python_project
|
|
55
|
+
|
|
56
|
+
project_root = os.path.dirname(params.config_base_dir)
|
|
57
|
+
agent_path = os.path.join(project_root, APP_DIR, params.name)
|
|
58
|
+
|
|
59
|
+
try:
|
|
60
|
+
# 1. Fetch Bedrock Agent configuration
|
|
61
|
+
agent_config = get_bedrock_agent_config(params.bedrock_region, params.bedrock_agent_id, params.bedrock_alias_id)
|
|
62
|
+
|
|
63
|
+
# 2. Translate to framework-specific Python code
|
|
64
|
+
options = TranslatorOptions(
|
|
65
|
+
agent_config=agent_config,
|
|
66
|
+
enable_memory=params.memory != "none",
|
|
67
|
+
memory_option=params.memory,
|
|
68
|
+
enable_observability=True,
|
|
69
|
+
)
|
|
70
|
+
translator = (
|
|
71
|
+
StrandsTranslator(agent_config, options)
|
|
72
|
+
if params.framework == "Strands"
|
|
73
|
+
else LangGraphTranslator(agent_config, options)
|
|
74
|
+
)
|
|
75
|
+
result = translator.translate()
|
|
76
|
+
|
|
77
|
+
# 3. Write generated code to project
|
|
78
|
+
os.makedirs(agent_path, exist_ok=True)
|
|
79
|
+
_write(os.path.join(agent_path, "main.py"), result.main_py_content)
|
|
80
|
+
for file_name, content in result.collaborator_files.items():
|
|
81
|
+
_write(os.path.join(agent_path, file_name), content)
|
|
82
|
+
|
|
83
|
+
# 4. Generate pyproject.toml
|
|
84
|
+
_write(
|
|
85
|
+
os.path.join(agent_path, "pyproject.toml"),
|
|
86
|
+
generate_pyproject_toml(params.name, params.framework, result.features),
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
# 5. Write agent to project config
|
|
90
|
+
generate_config = GenerateConfig(
|
|
91
|
+
project_name=params.name,
|
|
92
|
+
build_type="CodeZip",
|
|
93
|
+
sdk=params.framework,
|
|
94
|
+
model_provider="Bedrock",
|
|
95
|
+
memory=params.memory,
|
|
96
|
+
language="Python",
|
|
97
|
+
protocol="HTTP",
|
|
98
|
+
authorizer_type=params.authorizer_type,
|
|
99
|
+
jwt_config=params.jwt_config,
|
|
100
|
+
idle_runtime_session_timeout=params.idle_timeout,
|
|
101
|
+
max_lifetime=params.max_lifetime,
|
|
102
|
+
session_storage_mount_path=params.session_storage_mount_path,
|
|
103
|
+
efs_access_points=params.efs_access_points,
|
|
104
|
+
s3_access_points=params.s3_access_points,
|
|
105
|
+
capacity_provider_configuration=params.capacity_provider_configuration,
|
|
106
|
+
capacity_provider_volumes=params.capacity_provider_volumes,
|
|
107
|
+
)
|
|
108
|
+
write_agent_to_project(generate_config, config_base_dir=params.config_base_dir)
|
|
109
|
+
|
|
110
|
+
# 5b. Auto-create OAuth credential for CUSTOM_JWT inbound auth
|
|
111
|
+
jwt = params.jwt_config
|
|
112
|
+
if params.authorizer_type == "CUSTOM_JWT" and jwt and jwt.client_id and jwt.client_secret:
|
|
113
|
+
config_io = ConfigIO(base_dir=params.config_base_dir)
|
|
114
|
+
create_managed_oauth_credential(
|
|
115
|
+
params.name,
|
|
116
|
+
jwt,
|
|
117
|
+
config_io.write_project_spec,
|
|
118
|
+
config_io.read_project_spec,
|
|
119
|
+
params.config_base_dir,
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
# 6. Set up Python environment
|
|
123
|
+
setup_python_project(agent_path)
|
|
124
|
+
|
|
125
|
+
return Ok({"agentName": params.name, "agentPath": agent_path})
|
|
126
|
+
except Exception as exc: # noqa: BLE001 - surfaced as a Result, as upstream
|
|
127
|
+
return Err(to_error(exc))
|