@google/adk 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/a2a_remote_agent.js +17 -2
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/cjs/a2a/agent_card.js +5 -81
- package/dist/cjs/a2a/agent_to_a2a.js +7 -0
- package/dist/cjs/a2a/event_converter_utils.js +10 -3
- package/dist/cjs/agents/agent_engine_client.js +399 -0
- package/dist/cjs/agents/base_agent.js +127 -68
- package/dist/cjs/agents/functions.js +64 -59
- package/dist/cjs/agents/instructions.js +8 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +124 -101
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/cjs/agents/processors/content_processor_utils.js +72 -17
- package/dist/cjs/agents/processors/content_request_processor.js +51 -2
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +13 -3
- package/dist/cjs/artifacts/file_artifact_service.js +1 -1
- package/dist/cjs/cli/cli_eval.js +884 -17
- package/dist/cjs/cli/utils/cleanup.js +84 -0
- package/dist/cjs/cli/utils/envs.js +33 -2
- package/dist/cjs/cli/utils/evals.js +75 -8
- package/dist/cjs/cli/utils/logs.js +134 -15
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +171 -38
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +59 -32
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +34 -12
- package/dist/cjs/models/google_llm.js +33 -2
- package/dist/cjs/models/interactions_utils.js +3 -0
- package/dist/cjs/plugins/base_plugin.js +54 -40
- package/dist/cjs/plugins/plugin_manager.js +27 -0
- package/dist/cjs/runner/runner.js +306 -189
- package/dist/cjs/sessions/base_session_service.js +15 -12
- package/dist/cjs/sessions/database_session_service.js +232 -38
- package/dist/cjs/sessions/db/operations.js +70 -1
- package/dist/cjs/sessions/db/schema.js +4 -0
- package/dist/cjs/sessions/in_memory_session_service.js +2 -2
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +76 -41
- package/dist/cjs/telemetry/api/instrumentation.js +632 -0
- package/dist/cjs/telemetry/api/internal/common/accumulators.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/attributes.js +131 -0
- package/dist/cjs/telemetry/api/internal/common/config.js +159 -0
- package/dist/cjs/telemetry/api/internal/common/error.js +98 -0
- package/dist/cjs/telemetry/api/internal/common/finish_reason.js +63 -0
- package/dist/cjs/telemetry/api/internal/common/genai_messages.js +217 -0
- package/dist/cjs/telemetry/api/internal/common/http_exchange.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/provider_name.js +87 -0
- package/dist/cjs/telemetry/api/internal/common/redaction.js +148 -0
- package/dist/cjs/telemetry/api/internal/common/serialization.js +58 -0
- package/dist/cjs/telemetry/api/internal/common/token_usage.js +118 -0
- package/dist/cjs/telemetry/api/internal/logs/inference.js +50 -0
- package/dist/cjs/telemetry/api/internal/logs/logger.js +46 -0
- package/dist/cjs/telemetry/api/internal/logs/mcp.js +141 -0
- package/dist/cjs/telemetry/api/internal/metrics/agent.js +128 -0
- package/dist/cjs/telemetry/api/internal/metrics/inference_start_hook.js +56 -0
- package/dist/cjs/telemetry/api/internal/metrics/meters.js +189 -0
- package/dist/cjs/telemetry/api/internal/metrics/tool.js +147 -0
- package/dist/cjs/telemetry/api/internal/metrics/workflow.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/agent.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/compaction.js +78 -0
- package/dist/cjs/telemetry/api/internal/trace/inference.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/live.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/node.js +73 -0
- package/dist/cjs/telemetry/api/internal/trace/propagation.js +67 -0
- package/dist/cjs/telemetry/api/internal/trace/tool.js +122 -0
- package/dist/cjs/telemetry/api/internal/trace/tracer.js +77 -0
- package/dist/cjs/telemetry/api/internal/trace/workflow.js +77 -0
- package/dist/cjs/telemetry/export/agent_engine.js +90 -0
- package/dist/cjs/telemetry/export/agent_runtime.js +73 -0
- package/dist/cjs/telemetry/export/google_cloud.js +763 -0
- package/dist/cjs/telemetry/export/request_driven_metric_reader.js +303 -0
- package/dist/cjs/telemetry/{setup.js → export/setup.js} +72 -6
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +18 -23
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +109 -43
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +222 -114
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +175 -0
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/computer_use/base_computer.js +125 -0
- package/dist/cjs/tools/computer_use/computer_use_actions.js +502 -0
- package/dist/cjs/tools/computer_use/computer_use_tool.js +244 -0
- package/dist/cjs/tools/computer_use/computer_use_toolset.js +360 -0
- package/dist/cjs/tools/function_tool.js +15 -5
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +174 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +5 -3
- package/dist/cjs/tools/google_api_tool/index.js +20 -23
- package/dist/cjs/tools/load_artifacts_tool.js +27 -11
- package/dist/cjs/tools/load_memory_tool.js +14 -15
- package/dist/cjs/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/cjs/tools/mcp/mcp_tool.js +7 -3
- package/dist/cjs/tools/mcp/mcp_toolset.js +19 -20
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/cjs/tools/skill/load_skill_tool.js +3 -0
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/cjs/tools/toolbox_toolset.js +193 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +17 -2
- package/dist/cjs/utils/env_aware_utils.js +13 -7
- package/dist/cjs/utils/error_utils.js +40 -2
- package/dist/cjs/utils/failover_utils.js +11 -10
- package/dist/cjs/utils/gemini_schema_util.js +145 -14
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/logger_node.js +4 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/index.js +2 -0
- package/dist/cjs/workflow/node_runner.js +24 -80
- package/dist/cjs/workflow/nodes/parallel_worker.js +18 -7
- package/dist/cjs/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/cjs/workflow/utils/retry_utils.js +2 -2
- package/dist/cjs/workflow/workflow.js +12 -12
- package/dist/esm/a2a/a2a_remote_agent.js +23 -3
- package/dist/esm/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/esm/a2a/agent_card.js +5 -83
- package/dist/esm/a2a/agent_to_a2a.js +7 -0
- package/dist/esm/a2a/event_converter_utils.js +10 -3
- package/dist/esm/agents/agent_engine_client.js +382 -0
- package/dist/esm/agents/base_agent.js +127 -72
- package/dist/esm/agents/functions.js +69 -63
- package/dist/esm/agents/instructions.js +8 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +130 -106
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/esm/agents/processors/content_processor_utils.js +72 -17
- package/dist/esm/agents/processors/content_request_processor.js +51 -2
- package/dist/esm/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +13 -3
- package/dist/esm/artifacts/file_artifact_service.js +1 -1
- package/dist/esm/cli/cli_eval.js +880 -17
- package/dist/esm/cli/utils/cleanup.js +56 -0
- package/dist/esm/cli/utils/envs.js +33 -2
- package/dist/esm/cli/utils/evals.js +74 -8
- package/dist/esm/cli/utils/logs.js +132 -13
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +171 -38
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +59 -19
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +36 -10
- package/dist/esm/models/google_llm.js +33 -2
- package/dist/esm/models/interactions_utils.js +3 -0
- package/dist/esm/plugins/base_plugin.js +54 -40
- package/dist/esm/plugins/plugin_manager.js +27 -0
- package/dist/esm/runner/runner.js +310 -192
- package/dist/esm/sessions/base_session_service.js +13 -11
- package/dist/esm/sessions/database_session_service.js +231 -38
- package/dist/esm/sessions/db/operations.js +70 -1
- package/dist/esm/sessions/db/schema.js +4 -0
- package/dist/esm/sessions/in_memory_session_service.js +2 -2
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +76 -41
- package/dist/esm/telemetry/api/instrumentation.js +655 -0
- package/dist/esm/telemetry/api/internal/common/accumulators.js +139 -0
- package/dist/esm/telemetry/api/internal/common/attributes.js +94 -0
- package/dist/esm/telemetry/api/internal/common/config.js +128 -0
- package/dist/esm/telemetry/api/internal/common/error.js +69 -0
- package/dist/esm/telemetry/api/internal/common/finish_reason.js +35 -0
- package/dist/esm/telemetry/api/internal/common/genai_messages.js +188 -0
- package/dist/esm/telemetry/api/internal/common/http_exchange.js +142 -0
- package/dist/esm/telemetry/api/internal/common/provider_name.js +59 -0
- package/dist/esm/telemetry/api/internal/common/redaction.js +121 -0
- package/dist/esm/telemetry/api/internal/common/serialization.js +30 -0
- package/dist/esm/telemetry/api/internal/common/token_usage.js +85 -0
- package/dist/esm/telemetry/api/internal/logs/inference.js +23 -0
- package/dist/esm/telemetry/api/internal/logs/logger.js +19 -0
- package/dist/esm/telemetry/api/internal/logs/mcp.js +113 -0
- package/dist/esm/telemetry/api/internal/metrics/agent.js +107 -0
- package/dist/esm/telemetry/api/internal/metrics/inference_start_hook.js +29 -0
- package/dist/esm/telemetry/api/internal/metrics/meters.js +165 -0
- package/dist/esm/telemetry/api/internal/metrics/tool.js +119 -0
- package/dist/esm/telemetry/api/internal/metrics/workflow.js +112 -0
- package/dist/esm/telemetry/api/internal/trace/agent.js +25 -0
- package/dist/esm/telemetry/api/internal/trace/compaction.js +50 -0
- package/dist/esm/telemetry/api/internal/trace/inference.js +107 -0
- package/dist/esm/telemetry/api/internal/trace/live.js +28 -0
- package/dist/esm/telemetry/api/internal/trace/node.js +44 -0
- package/dist/esm/telemetry/api/internal/trace/propagation.js +39 -0
- package/dist/esm/telemetry/api/internal/trace/tool.js +96 -0
- package/dist/esm/telemetry/api/internal/trace/tracer.js +52 -0
- package/dist/esm/telemetry/api/internal/trace/workflow.js +54 -0
- package/dist/esm/telemetry/export/agent_engine.js +67 -0
- package/dist/esm/telemetry/export/agent_runtime.js +46 -0
- package/dist/esm/telemetry/export/google_cloud.js +733 -0
- package/dist/esm/telemetry/export/request_driven_metric_reader.js +276 -0
- package/dist/esm/telemetry/export/setup.js +160 -0
- package/dist/esm/tools/agent_tool.js +9 -1
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +17 -22
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +114 -44
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +226 -115
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +149 -0
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/computer_use/base_computer.js +99 -0
- package/dist/esm/tools/computer_use/computer_use_actions.js +477 -0
- package/dist/esm/tools/computer_use/computer_use_tool.js +217 -0
- package/dist/esm/tools/computer_use/computer_use_toolset.js +344 -0
- package/dist/esm/tools/function_tool.js +15 -5
- package/dist/esm/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +147 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +5 -3
- package/dist/esm/tools/google_api_tool/index.js +18 -20
- package/dist/esm/tools/load_artifacts_tool.js +25 -10
- package/dist/esm/tools/load_memory_tool.js +14 -15
- package/dist/esm/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/esm/tools/mcp/mcp_tool.js +7 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +19 -20
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/esm/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/esm/tools/skill/load_skill_tool.js +3 -0
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/esm/tools/toolbox_toolset.js +167 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +17 -2
- package/dist/esm/utils/env_aware_utils.js +12 -7
- package/dist/esm/utils/error_utils.js +37 -1
- package/dist/esm/utils/failover_utils.js +11 -10
- package/dist/esm/utils/gemini_schema_util.js +144 -14
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/logger_node.js +4 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/workflow/index.js +2 -1
- package/dist/esm/workflow/node_runner.js +26 -80
- package/dist/esm/workflow/nodes/parallel_worker.js +16 -6
- package/dist/esm/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/esm/workflow/utils/retry_utils.js +2 -2
- package/dist/esm/workflow/workflow.js +12 -12
- package/dist/types/a2a/a2a_remote_agent.d.ts +6 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +3 -2
- package/dist/types/agents/agent_engine_client.d.ts +155 -0
- package/dist/types/agents/base_agent.d.ts +14 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +12 -10
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/agents/run_config.d.ts +14 -0
- package/dist/types/cli/cli_eval.d.ts +172 -9
- package/dist/types/cli/utils/cleanup.d.ts +18 -0
- package/dist/types/cli/utils/envs.d.ts +13 -3
- package/dist/types/cli/utils/evals.d.ts +64 -1
- package/dist/types/cli/utils/logs.d.ts +20 -3
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +62 -9
- package/dist/types/common.d.ts +21 -18
- package/dist/types/context/compaction_utils.d.ts +13 -1
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/events/event.d.ts +3 -0
- package/dist/types/features/feature_registry.d.ts +1 -0
- package/dist/types/index.d.ts +11 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -31
- package/dist/types/plugins/plugin_manager.d.ts +13 -0
- package/dist/types/runner/runner.d.ts +11 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -2
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/telemetry/api/instrumentation.d.ts +259 -0
- package/dist/types/telemetry/api/internal/common/accumulators.d.ts +91 -0
- package/dist/types/telemetry/api/internal/common/attributes.d.ts +90 -0
- package/dist/types/telemetry/api/internal/common/config.d.ts +61 -0
- package/dist/types/telemetry/api/internal/common/error.d.ts +29 -0
- package/dist/types/telemetry/api/internal/common/finish_reason.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/genai_messages.d.ts +26 -0
- package/dist/types/telemetry/api/internal/common/http_exchange.d.ts +50 -0
- package/dist/types/telemetry/api/internal/common/provider_name.d.ts +16 -0
- package/dist/types/telemetry/api/internal/common/redaction.d.ts +14 -0
- package/dist/types/telemetry/api/internal/common/serialization.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/token_usage.d.ts +47 -0
- package/dist/types/telemetry/api/internal/logs/inference.d.ts +15 -0
- package/dist/types/telemetry/api/internal/logs/logger.d.ts +13 -0
- package/dist/types/telemetry/api/internal/logs/mcp.d.ts +31 -0
- package/dist/types/telemetry/api/internal/metrics/agent.d.ts +28 -0
- package/dist/types/telemetry/api/internal/metrics/inference_start_hook.d.ts +12 -0
- package/dist/types/telemetry/api/internal/metrics/meters.d.ts +57 -0
- package/dist/types/telemetry/api/internal/metrics/tool.d.ts +44 -0
- package/dist/types/telemetry/api/internal/metrics/workflow.d.ts +32 -0
- package/dist/types/telemetry/api/internal/trace/agent.d.ts +14 -0
- package/dist/types/telemetry/api/internal/trace/compaction.d.ts +20 -0
- package/dist/types/telemetry/api/internal/trace/inference.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/live.d.ts +21 -0
- package/dist/types/telemetry/api/internal/trace/node.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/propagation.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/tool.d.ts +57 -0
- package/dist/types/telemetry/api/internal/trace/tracer.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/workflow.d.ts +21 -0
- package/dist/types/telemetry/export/agent_engine.d.ts +23 -0
- package/dist/types/telemetry/export/agent_runtime.d.ts +40 -0
- package/dist/types/telemetry/export/google_cloud.d.ts +189 -0
- package/dist/types/telemetry/export/request_driven_metric_reader.d.ts +144 -0
- package/dist/types/telemetry/{setup.d.ts → export/setup.d.ts} +3 -0
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +14 -21
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +32 -9
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +35 -12
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +3 -3
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +7 -6
- package/dist/types/tools/computer_use/base_computer.d.ts +281 -0
- package/dist/types/tools/computer_use/computer_use_actions.d.ts +53 -0
- package/dist/types/tools/computer_use/computer_use_tool.d.ts +108 -0
- package/dist/types/tools/computer_use/computer_use_toolset.d.ts +132 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +10 -3
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +57 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +5 -4
- package/dist/types/tools/google_api_tool/index.d.ts +4 -5
- package/dist/types/tools/load_artifacts_tool.d.ts +18 -1
- package/dist/types/tools/load_memory_tool.d.ts +32 -4
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +16 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +8 -8
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +15 -3
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/toolbox_toolset.d.ts +154 -0
- package/dist/types/utils/async_queue.d.ts +14 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/env_aware_utils.d.ts +11 -0
- package/dist/types/utils/error_utils.d.ts +4 -0
- package/dist/types/utils/gemini_schema_util.d.ts +29 -0
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- package/dist/types/utils/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/utils/ssrf_guard.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/workflow/index.d.ts +1 -1
- package/dist/types/workflow/nodes/parallel_worker.d.ts +8 -1
- package/dist/web/index_web.js +94 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +43 -38
- package/dist/cjs/agents/remote_agent.js +0 -187
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -350
- package/dist/cjs/tools/crewai_tool.js +0 -132
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +0 -226
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +0 -58
- package/dist/cjs/tools/langchain_tool.js +0 -172
- package/dist/cjs/tools/toolbox_tool.js +0 -108
- package/dist/esm/agents/remote_agent.js +0 -164
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -89
- package/dist/esm/telemetry/tracing.js +0 -315
- package/dist/esm/tools/crewai_tool.js +0 -107
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +0 -188
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +0 -24
- package/dist/esm/tools/langchain_tool.js +0 -148
- package/dist/esm/tools/toolbox_tool.js +0 -80
- package/dist/types/agents/remote_agent.d.ts +0 -68
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -129
- package/dist/types/tools/crewai_tool.d.ts +0 -85
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +0 -78
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +0 -33
- package/dist/types/tools/langchain_tool.d.ts +0 -103
- package/dist/types/tools/toolbox_tool.d.ts +0 -73
|
@@ -16,7 +16,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
16
16
|
* Copyright 2026 Google LLC
|
|
17
17
|
* SPDX-License-Identifier: Apache-2.0
|
|
18
18
|
*/
|
|
19
|
-
import yaml from "js-yaml";
|
|
19
|
+
import * as yaml from "js-yaml";
|
|
20
20
|
import { experimental } from "../../utils/experimental.js";
|
|
21
21
|
import { logger } from "../../utils/logger.js";
|
|
22
22
|
import { BaseToolset } from "../base_toolset.js";
|
|
@@ -40,7 +40,8 @@ let OpenAPIToolset = class extends BaseToolset {
|
|
|
40
40
|
throw new Error("Either specDict or specStr must be provided.");
|
|
41
41
|
}
|
|
42
42
|
const parser = new OpenApiSpecParser({
|
|
43
|
-
preservePropertyNames: options.preservePropertyNames
|
|
43
|
+
preservePropertyNames: options.preservePropertyNames,
|
|
44
|
+
unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
|
|
44
45
|
});
|
|
45
46
|
const parsedOperations = parser.parse(spec);
|
|
46
47
|
for (const op of parsedOperations) {
|
|
@@ -61,7 +62,8 @@ let OpenAPIToolset = class extends BaseToolset {
|
|
|
61
62
|
{
|
|
62
63
|
preservePropertyNames: options.preservePropertyNames,
|
|
63
64
|
headerProvider: options.headerProvider,
|
|
64
|
-
credentialKey: options.credentialKey
|
|
65
|
+
credentialKey: options.credentialKey,
|
|
66
|
+
unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
|
|
65
67
|
}
|
|
66
68
|
);
|
|
67
69
|
this.tools.push(tool);
|
|
@@ -76,15 +78,7 @@ let OpenAPIToolset = class extends BaseToolset {
|
|
|
76
78
|
}
|
|
77
79
|
}
|
|
78
80
|
async getTools(context) {
|
|
79
|
-
return this.tools.filter((tool) =>
|
|
80
|
-
if (Array.isArray(this.toolFilter) && this.toolFilter.length > 0) {
|
|
81
|
-
return this.toolFilter.includes(tool.name);
|
|
82
|
-
}
|
|
83
|
-
if (context) {
|
|
84
|
-
return this.isToolSelected(tool, context);
|
|
85
|
-
}
|
|
86
|
-
return true;
|
|
87
|
-
});
|
|
81
|
+
return this.tools.filter((tool) => this.isToolSelected(tool, context));
|
|
88
82
|
}
|
|
89
83
|
getTool(toolName) {
|
|
90
84
|
return this.tools.find((tool) => tool.name === toolName);
|
|
@@ -176,6 +176,32 @@ function encodePathParamValue(name, value) {
|
|
|
176
176
|
return encodeURIComponent(value);
|
|
177
177
|
}
|
|
178
178
|
__name(encodePathParamValue, "encodePathParamValue");
|
|
179
|
+
function toParamString(value) {
|
|
180
|
+
if (Array.isArray(value)) {
|
|
181
|
+
return value.filter((item) => item !== void 0 && item !== null).map(toParamString).join(",");
|
|
182
|
+
}
|
|
183
|
+
if (typeof value === "object" && value !== null) {
|
|
184
|
+
return Object.entries(value).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${k},${toParamString(v)}`).join(",");
|
|
185
|
+
}
|
|
186
|
+
return String(value);
|
|
187
|
+
}
|
|
188
|
+
__name(toParamString, "toParamString");
|
|
189
|
+
function serializeQueryValue(value) {
|
|
190
|
+
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
191
|
+
}
|
|
192
|
+
__name(serializeQueryValue, "serializeQueryValue");
|
|
193
|
+
function appendParamValue(target, name, value) {
|
|
194
|
+
if (!Array.isArray(value)) {
|
|
195
|
+
target.append(name, serializeQueryValue(value));
|
|
196
|
+
return;
|
|
197
|
+
}
|
|
198
|
+
for (const item of value) {
|
|
199
|
+
if (item !== void 0 && item !== null) {
|
|
200
|
+
target.append(name, serializeQueryValue(item));
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
__name(appendParamValue, "appendParamValue");
|
|
179
205
|
function prepareRequestParams(endpoint, parameters, args) {
|
|
180
206
|
const headers = {};
|
|
181
207
|
const queryParams = new URLSearchParams();
|
|
@@ -190,18 +216,24 @@ function prepareRequestParams(endpoint, parameters, args) {
|
|
|
190
216
|
const originalName = param.originalName;
|
|
191
217
|
const location = param.paramLocation;
|
|
192
218
|
if (location === "path") {
|
|
193
|
-
|
|
194
|
-
originalName
|
|
195
|
-
|
|
196
|
-
|
|
219
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
220
|
+
pathParams[originalName] = encodePathParamValue(
|
|
221
|
+
originalName,
|
|
222
|
+
toParamString(argValue)
|
|
223
|
+
);
|
|
224
|
+
}
|
|
197
225
|
} else if (location === "query") {
|
|
198
226
|
if (argValue !== void 0 && argValue !== null && argValue !== "") {
|
|
199
|
-
queryParams
|
|
227
|
+
appendParamValue(queryParams, originalName, argValue);
|
|
200
228
|
}
|
|
201
229
|
} else if (location === "header") {
|
|
202
|
-
|
|
230
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
231
|
+
headers[originalName] = toParamString(argValue);
|
|
232
|
+
}
|
|
203
233
|
} else if (location === "cookie") {
|
|
204
|
-
|
|
234
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
235
|
+
cookies[originalName] = toParamString(argValue);
|
|
236
|
+
}
|
|
205
237
|
} else if (location === "body") {
|
|
206
238
|
if (originalName === "body" || originalName === "array" || originalName === "") {
|
|
207
239
|
body = argValue;
|
|
@@ -235,6 +267,18 @@ function isRawBody(value) {
|
|
|
235
267
|
return typeof value === "string" || ArrayBuffer.isView(value) || value instanceof ArrayBuffer || value instanceof Blob;
|
|
236
268
|
}
|
|
237
269
|
__name(isRawBody, "isRawBody");
|
|
270
|
+
function isFormFields(value) {
|
|
271
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
272
|
+
}
|
|
273
|
+
__name(isFormFields, "isFormFields");
|
|
274
|
+
function appendFormFields(target, fields) {
|
|
275
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
276
|
+
if (value !== void 0 && value !== null) {
|
|
277
|
+
appendParamValue(target, name, value);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
__name(appendFormFields, "appendFormFields");
|
|
238
282
|
function prepareRequestBody(requestBody, body, bodyData, headers) {
|
|
239
283
|
const finalData = body !== void 0 ? body : Object.keys(bodyData).length > 0 ? bodyData : void 0;
|
|
240
284
|
if (requestBody && "content" in requestBody) {
|
|
@@ -245,13 +289,16 @@ function prepareRequestBody(requestBody, body, bodyData, headers) {
|
|
|
245
289
|
headers["Content-Type"] = mimeType;
|
|
246
290
|
return typeof finalData === "string" ? finalData : JSON.stringify(finalData);
|
|
247
291
|
} else if (mimeType === "application/x-www-form-urlencoded") {
|
|
292
|
+
if (isFormFields(finalData)) {
|
|
293
|
+
const formParams = new URLSearchParams();
|
|
294
|
+
appendFormFields(formParams, finalData);
|
|
295
|
+
return formParams;
|
|
296
|
+
}
|
|
248
297
|
return new URLSearchParams(finalData);
|
|
249
298
|
} else if (mimeType === "multipart/form-data") {
|
|
250
299
|
const formData = new FormData();
|
|
251
300
|
if (typeof finalData === "object" && finalData !== null) {
|
|
252
|
-
|
|
253
|
-
formData.append(key, String(value));
|
|
254
|
-
}
|
|
301
|
+
appendFormFields(formData, finalData);
|
|
255
302
|
}
|
|
256
303
|
return formData;
|
|
257
304
|
} else if (mimeType === "application/octet-stream") {
|
|
@@ -18,6 +18,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
18
18
|
*/
|
|
19
19
|
import { Type } from "@google/genai";
|
|
20
20
|
import path from "node:path";
|
|
21
|
+
import { recordSkillActivity } from "../../telemetry/api/instrumentation.js";
|
|
21
22
|
import { experimental } from "../../utils/experimental.js";
|
|
22
23
|
import { guessMimeType } from "../../utils/file_utils.js";
|
|
23
24
|
import {
|
|
@@ -72,6 +73,11 @@ let LoadSkillResourceTool = class extends BaseTool {
|
|
|
72
73
|
};
|
|
73
74
|
}
|
|
74
75
|
resourcePath = path.posix.normalize(resourcePath);
|
|
76
|
+
const skillActivity = recordSkillActivity({
|
|
77
|
+
kind: "resource",
|
|
78
|
+
skillName,
|
|
79
|
+
resourcePath
|
|
80
|
+
});
|
|
75
81
|
let skill;
|
|
76
82
|
try {
|
|
77
83
|
skill = await this.toolset.getOrFetchSkill(
|
|
@@ -90,6 +96,7 @@ let LoadSkillResourceTool = class extends BaseTool {
|
|
|
90
96
|
error_code: "SKILL_NOT_FOUND"
|
|
91
97
|
};
|
|
92
98
|
}
|
|
99
|
+
skillActivity.recordSkill(skill);
|
|
93
100
|
let content;
|
|
94
101
|
const skillResources = skill.resources || {};
|
|
95
102
|
if (resourcePath.startsWith("references/")) {
|
|
@@ -18,6 +18,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
18
18
|
*/
|
|
19
19
|
import { Type } from "@google/genai";
|
|
20
20
|
import { requireAgent } from "../../agents/invocation_context.js";
|
|
21
|
+
import { recordSkillActivity } from "../../telemetry/api/instrumentation.js";
|
|
21
22
|
import { experimental } from "../../utils/experimental.js";
|
|
22
23
|
import { BaseTool } from "../base_tool.js";
|
|
23
24
|
let LoadSkillTool = class extends BaseTool {
|
|
@@ -55,6 +56,7 @@ let LoadSkillTool = class extends BaseTool {
|
|
|
55
56
|
error_code: "MISSING_SKILL_NAME"
|
|
56
57
|
};
|
|
57
58
|
}
|
|
59
|
+
const skillActivity = recordSkillActivity({ kind: "load", skillName });
|
|
58
60
|
let skill;
|
|
59
61
|
try {
|
|
60
62
|
skill = await this.toolset.getOrFetchSkill(
|
|
@@ -73,6 +75,7 @@ let LoadSkillTool = class extends BaseTool {
|
|
|
73
75
|
error_code: "SKILL_NOT_FOUND"
|
|
74
76
|
};
|
|
75
77
|
}
|
|
78
|
+
skillActivity.recordSkill(skill);
|
|
76
79
|
const agentName = requireAgent(toolContext.invocationContext).name;
|
|
77
80
|
const stateKey = `_adk_activated_skill_${agentName}`;
|
|
78
81
|
const currentActivated = toolContext.state.get(stateKey) || [];
|
|
@@ -22,6 +22,7 @@ import { isLlmAgent } from "../../agents/llm_agent.js";
|
|
|
22
22
|
import {
|
|
23
23
|
CodeExecutionLanguage
|
|
24
24
|
} from "../../code_executors/code_execution_utils.js";
|
|
25
|
+
import { recordSkillActivity } from "../../telemetry/api/instrumentation.js";
|
|
25
26
|
import { experimental } from "../../utils/experimental.js";
|
|
26
27
|
import {
|
|
27
28
|
getMimeTypeAndEncoding,
|
|
@@ -81,6 +82,11 @@ let RunSkillScriptTool = class extends BaseTool {
|
|
|
81
82
|
errorCode: "MISSING_SCRIPT_PATH"
|
|
82
83
|
};
|
|
83
84
|
}
|
|
85
|
+
const skillActivity = recordSkillActivity({
|
|
86
|
+
kind: "script",
|
|
87
|
+
skillName,
|
|
88
|
+
scriptPath
|
|
89
|
+
});
|
|
84
90
|
let skill;
|
|
85
91
|
try {
|
|
86
92
|
skill = await this.toolset.getOrFetchSkill(
|
|
@@ -99,9 +105,11 @@ let RunSkillScriptTool = class extends BaseTool {
|
|
|
99
105
|
errorCode: "SKILL_NOT_FOUND"
|
|
100
106
|
};
|
|
101
107
|
}
|
|
102
|
-
|
|
108
|
+
skillActivity.recordSkill(skill);
|
|
109
|
+
let relScriptPath = scriptPath.startsWith("scripts/") ? scriptPath.substring("scripts/".length) : scriptPath;
|
|
103
110
|
let script = (_b = (_a = skill.resources) == null ? void 0 : _a.scripts) == null ? void 0 : _b[relScriptPath];
|
|
104
111
|
if (!script) {
|
|
112
|
+
relScriptPath = scriptPath;
|
|
105
113
|
script = (_d = (_c = skill.resources) == null ? void 0 : _c.scripts) == null ? void 0 : _d[scriptPath];
|
|
106
114
|
}
|
|
107
115
|
if (!script) {
|
|
@@ -128,7 +136,9 @@ let RunSkillScriptTool = class extends BaseTool {
|
|
|
128
136
|
const result = await codeExecutor.executeCode({
|
|
129
137
|
invocationContext: toolContext.invocationContext,
|
|
130
138
|
codeExecutionInput: {
|
|
131
|
-
|
|
139
|
+
// Scripts are always written under scripts/ (see
|
|
140
|
+
// getSkillResourceFiles), with or without the prefix in script_path.
|
|
141
|
+
code: buildWrapperCode(`scripts/${relScriptPath}`, language),
|
|
132
142
|
inputFiles: getSkillResourceFiles(skill),
|
|
133
143
|
language,
|
|
134
144
|
args: scriptArgs
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
var _a, _b;
|
|
11
|
+
import { isBaseTool } from "./base_tool.js";
|
|
12
|
+
import { BaseToolset } from "./base_toolset.js";
|
|
13
|
+
import {
|
|
14
|
+
FunctionTool
|
|
15
|
+
} from "./function_tool.js";
|
|
16
|
+
const TOOLBOX_TOOLSET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
17
|
+
"google.adk.toolboxToolset"
|
|
18
|
+
);
|
|
19
|
+
function isToolboxToolset(obj) {
|
|
20
|
+
return typeof obj === "object" && obj !== null && TOOLBOX_TOOLSET_SIGNATURE_SYMBOL in obj && obj[TOOLBOX_TOOLSET_SIGNATURE_SYMBOL] === true;
|
|
21
|
+
}
|
|
22
|
+
__name(isToolboxToolset, "isToolboxToolset");
|
|
23
|
+
function createUnconfiguredToolboxToolsetClient(serverUrl) {
|
|
24
|
+
const throwMissingClient = /* @__PURE__ */ __name(() => {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`ToolboxToolset requires a ToolboxToolsetClientLike instance (for endpoint "${serverUrl}"). Pass {serverUrl, client} to the ToolboxToolset constructor.`
|
|
27
|
+
);
|
|
28
|
+
}, "throwMissingClient");
|
|
29
|
+
return {
|
|
30
|
+
loadTool: throwMissingClient,
|
|
31
|
+
loadToolset: throwMissingClient,
|
|
32
|
+
close: /* @__PURE__ */ __name(() => {
|
|
33
|
+
}, "close")
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
__name(createUnconfiguredToolboxToolsetClient, "createUnconfiguredToolboxToolsetClient");
|
|
37
|
+
function isToolOptionsObject(value) {
|
|
38
|
+
return typeof value === "object" && value !== null && "execute" in value && typeof value.execute === "function";
|
|
39
|
+
}
|
|
40
|
+
__name(isToolOptionsObject, "isToolOptionsObject");
|
|
41
|
+
function wrapPrefixedBaseTool(rawTool, name) {
|
|
42
|
+
return new Proxy(rawTool, {
|
|
43
|
+
get(target, prop, receiver) {
|
|
44
|
+
if (prop === "name") {
|
|
45
|
+
return name;
|
|
46
|
+
}
|
|
47
|
+
if (prop === "_getDeclaration") {
|
|
48
|
+
return () => {
|
|
49
|
+
const declaration = target._getDeclaration();
|
|
50
|
+
return declaration ? { ...declaration, name } : void 0;
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const value = Reflect.get(target, prop, receiver);
|
|
54
|
+
return typeof value === "function" ? value.bind(target) : value;
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
__name(wrapPrefixedBaseTool, "wrapPrefixedBaseTool");
|
|
59
|
+
function wrapLoadedTool(rawTool, prefix) {
|
|
60
|
+
var _a2;
|
|
61
|
+
if (isBaseTool(rawTool)) {
|
|
62
|
+
const name = prefix ? `${prefix}_${rawTool.name}` : rawTool.name;
|
|
63
|
+
if (name === rawTool.name) {
|
|
64
|
+
return rawTool;
|
|
65
|
+
}
|
|
66
|
+
return wrapPrefixedBaseTool(rawTool, name);
|
|
67
|
+
}
|
|
68
|
+
if (typeof rawTool === "function") {
|
|
69
|
+
const fn = rawTool;
|
|
70
|
+
const baseName = typeof fn.getName === "function" ? fn.getName() : fn.toolName || (fn.name && fn.name !== "callable" ? fn.name : void 0) || "toolbox_tool";
|
|
71
|
+
const name = prefix ? `${prefix}_${baseName}` : baseName;
|
|
72
|
+
const description = typeof fn.getDescription === "function" ? fn.getDescription() : (_a2 = fn.description) != null ? _a2 : "";
|
|
73
|
+
const parameters = typeof fn.getParamSchema === "function" ? fn.getParamSchema() : fn.parameters;
|
|
74
|
+
return new FunctionTool({
|
|
75
|
+
name,
|
|
76
|
+
description,
|
|
77
|
+
parameters,
|
|
78
|
+
execute: fn
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
if (isToolOptionsObject(rawTool)) {
|
|
82
|
+
const baseTool = new FunctionTool(rawTool);
|
|
83
|
+
if (!prefix) {
|
|
84
|
+
return baseTool;
|
|
85
|
+
}
|
|
86
|
+
return new FunctionTool({
|
|
87
|
+
...rawTool,
|
|
88
|
+
name: `${prefix}_${baseTool.name}`
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
throw new TypeError(
|
|
92
|
+
"Unsupported Toolbox tool shape: expected a BaseTool, ToolOptions object, or function."
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
__name(wrapLoadedTool, "wrapLoadedTool");
|
|
96
|
+
const _ToolboxToolset = class _ToolboxToolset extends (_b = BaseToolset, _a = TOOLBOX_TOOLSET_SIGNATURE_SYMBOL, _b) {
|
|
97
|
+
constructor(serverUrlOrOptions, extraOptions) {
|
|
98
|
+
var _a2, _b2, _c, _d, _e;
|
|
99
|
+
const options = typeof serverUrlOrOptions === "string" ? { serverUrl: serverUrlOrOptions, ...extraOptions } : serverUrlOrOptions;
|
|
100
|
+
const normalizedServerUrl = (_a2 = options.serverUrl) == null ? void 0 : _a2.trim();
|
|
101
|
+
if (!options.client && !normalizedServerUrl) {
|
|
102
|
+
throw new Error("Either client or a non-empty serverUrl is required.");
|
|
103
|
+
}
|
|
104
|
+
if ((!options.toolNames || options.toolNames.length === 0) && !options.toolsetName) {
|
|
105
|
+
throw new Error("toolNames and toolsetName cannot both be undefined.");
|
|
106
|
+
}
|
|
107
|
+
super((_b2 = options.toolFilter) != null ? _b2 : [], options.prefix);
|
|
108
|
+
/** A unique symbol to identify ADK ToolboxToolset class. */
|
|
109
|
+
this[_a] = true;
|
|
110
|
+
this.serverUrl = options.serverUrl;
|
|
111
|
+
this.toolsetName = options.toolsetName;
|
|
112
|
+
this.toolNames = options.toolNames;
|
|
113
|
+
this.authTokenGetters = (_c = options.authTokenGetters) != null ? _c : {};
|
|
114
|
+
this.boundParams = (_d = options.boundParams) != null ? _d : {};
|
|
115
|
+
this.toolboxClient = (_e = options.client) != null ? _e : createUnconfiguredToolboxToolsetClient(normalizedServerUrl != null ? normalizedServerUrl : "");
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Loads the configured toolset and/or individual tools from the Toolbox
|
|
119
|
+
* client and returns the selected {@link BaseTool} instances.
|
|
120
|
+
*/
|
|
121
|
+
async getTools(context) {
|
|
122
|
+
var _a2, _b2;
|
|
123
|
+
const tools = [];
|
|
124
|
+
if (this.toolsetName) {
|
|
125
|
+
const loader = (_a2 = this.toolboxClient.loadToolset) == null ? void 0 : _a2.bind(this.toolboxClient);
|
|
126
|
+
if (!loader) {
|
|
127
|
+
throw new Error("ToolboxClient does not implement loadToolset.");
|
|
128
|
+
}
|
|
129
|
+
const loadedToolset = await loader(
|
|
130
|
+
this.toolsetName,
|
|
131
|
+
this.authTokenGetters,
|
|
132
|
+
this.boundParams
|
|
133
|
+
);
|
|
134
|
+
for (const rawTool of loadedToolset) {
|
|
135
|
+
tools.push(wrapLoadedTool(rawTool, this.prefix));
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (this.toolNames && this.toolNames.length > 0) {
|
|
139
|
+
const loader = (_b2 = this.toolboxClient.loadTool) == null ? void 0 : _b2.bind(this.toolboxClient);
|
|
140
|
+
if (!loader) {
|
|
141
|
+
throw new Error("ToolboxClient does not implement loadTool.");
|
|
142
|
+
}
|
|
143
|
+
const loadedSingleTools = await Promise.all(
|
|
144
|
+
this.toolNames.map(
|
|
145
|
+
(toolName) => loader(toolName, this.authTokenGetters, this.boundParams)
|
|
146
|
+
)
|
|
147
|
+
);
|
|
148
|
+
for (const rawTool of loadedSingleTools) {
|
|
149
|
+
tools.push(wrapLoadedTool(rawTool, this.prefix));
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
return tools.filter((tool) => this.isToolSelected(tool, context));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Closes the underlying Toolbox client.
|
|
156
|
+
*/
|
|
157
|
+
async close() {
|
|
158
|
+
var _a2, _b2;
|
|
159
|
+
await ((_b2 = (_a2 = this.toolboxClient).close) == null ? void 0 : _b2.call(_a2));
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
__name(_ToolboxToolset, "ToolboxToolset");
|
|
163
|
+
let ToolboxToolset = _ToolboxToolset;
|
|
164
|
+
export {
|
|
165
|
+
ToolboxToolset,
|
|
166
|
+
isToolboxToolset
|
|
167
|
+
};
|
|
@@ -41,20 +41,7 @@ const _WebMCPToolset = class _WebMCPToolset extends BaseToolset {
|
|
|
41
41
|
document: this.doc
|
|
42
42
|
})
|
|
43
43
|
);
|
|
44
|
-
|
|
45
|
-
if (!filter || Array.isArray(filter) && filter.length === 0) {
|
|
46
|
-
return tools;
|
|
47
|
-
}
|
|
48
|
-
if (Array.isArray(filter)) {
|
|
49
|
-
return tools.filter((tool) => filter.includes(tool.name));
|
|
50
|
-
}
|
|
51
|
-
if (context) {
|
|
52
|
-
return tools.filter((tool) => filter(tool, context));
|
|
53
|
-
}
|
|
54
|
-
logger.warn(
|
|
55
|
-
"WebMCPToolset: a ToolPredicate toolFilter was provided but getTools() was called without a ReadonlyContext. The filter will not be applied."
|
|
56
|
-
);
|
|
57
|
-
return tools;
|
|
44
|
+
return tools.filter((tool) => this.isToolSelected(tool, context));
|
|
58
45
|
}
|
|
59
46
|
/**
|
|
60
47
|
* Subscribes to the WebMCP `toolchange` event, which fires when the page
|
|
@@ -26,14 +26,43 @@ const _AsyncQueue = class _AsyncQueue {
|
|
|
26
26
|
* immediately; otherwise the value is buffered. No-op once closed/failed.
|
|
27
27
|
*/
|
|
28
28
|
push(value) {
|
|
29
|
-
|
|
29
|
+
this.enqueue(value);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Enqueues a value like {@link push}, and resolves once the consumer has
|
|
33
|
+
* finished with it: when it asks for the next item, or when the queue closes
|
|
34
|
+
* or fails. Resolves at once if the queue is already closed.
|
|
35
|
+
*/
|
|
36
|
+
pushAndWait(value) {
|
|
37
|
+
return new Promise((resolve) => this.enqueue(value, resolve));
|
|
38
|
+
}
|
|
39
|
+
enqueue(value, ack) {
|
|
40
|
+
if (this.closed) {
|
|
41
|
+
ack == null ? void 0 : ack();
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
30
44
|
const resolver = this.resolvers.shift();
|
|
31
45
|
if (resolver) {
|
|
46
|
+
this.deliveredAck = ack;
|
|
32
47
|
resolver.resolve({ value, done: false });
|
|
33
48
|
} else {
|
|
34
|
-
this.queue.push(value);
|
|
49
|
+
this.queue.push({ value, ack });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/** Releases every producer still waiting in {@link pushAndWait}. */
|
|
53
|
+
releaseAll() {
|
|
54
|
+
var _a;
|
|
55
|
+
this.releaseDelivered();
|
|
56
|
+
for (const item of this.queue) {
|
|
57
|
+
(_a = item.ack) == null ? void 0 : _a.call(item);
|
|
58
|
+
item.ack = void 0;
|
|
35
59
|
}
|
|
36
60
|
}
|
|
61
|
+
releaseDelivered() {
|
|
62
|
+
const ack = this.deliveredAck;
|
|
63
|
+
this.deliveredAck = void 0;
|
|
64
|
+
ack == null ? void 0 : ack();
|
|
65
|
+
}
|
|
37
66
|
/**
|
|
38
67
|
* Signals that production failed. Buffered items are still delivered first;
|
|
39
68
|
* once the buffer drains, the consumer's next `next()` rejects with `error`.
|
|
@@ -43,6 +72,7 @@ const _AsyncQueue = class _AsyncQueue {
|
|
|
43
72
|
if (this.failure) return;
|
|
44
73
|
this.failure = { error };
|
|
45
74
|
this.closed = true;
|
|
75
|
+
this.releaseAll();
|
|
46
76
|
while (this.resolvers.length > 0) {
|
|
47
77
|
this.resolvers.shift().reject(error);
|
|
48
78
|
}
|
|
@@ -58,6 +88,7 @@ const _AsyncQueue = class _AsyncQueue {
|
|
|
58
88
|
close() {
|
|
59
89
|
if (this.closed) return;
|
|
60
90
|
this.closed = true;
|
|
91
|
+
this.releaseAll();
|
|
61
92
|
while (this.resolvers.length > 0) {
|
|
62
93
|
this.resolvers.shift().resolve({ value: void 0, done: true });
|
|
63
94
|
}
|
|
@@ -65,8 +96,11 @@ const _AsyncQueue = class _AsyncQueue {
|
|
|
65
96
|
[Symbol.asyncIterator]() {
|
|
66
97
|
return {
|
|
67
98
|
next: /* @__PURE__ */ __name(() => {
|
|
99
|
+
this.releaseDelivered();
|
|
68
100
|
if (this.queue.length > 0) {
|
|
69
|
-
|
|
101
|
+
const item = this.queue.shift();
|
|
102
|
+
this.deliveredAck = item.ack;
|
|
103
|
+
return Promise.resolve({ value: item.value, done: false });
|
|
70
104
|
}
|
|
71
105
|
if (this.failure) {
|
|
72
106
|
return Promise.reject(this.failure.error);
|
|
@@ -99,7 +99,8 @@ function headerEntries(headers) {
|
|
|
99
99
|
__name(headerEntries, "headerEntries");
|
|
100
100
|
function mergeTrackingHeaders(headers) {
|
|
101
101
|
var _a, _b;
|
|
102
|
-
const
|
|
102
|
+
const otherHeaders = new Headers();
|
|
103
|
+
const originalNames = /* @__PURE__ */ new Map();
|
|
103
104
|
const callerValues = /* @__PURE__ */ new Map();
|
|
104
105
|
for (const [name, value] of headerEntries(headers)) {
|
|
105
106
|
const lowerName = name.toLowerCase();
|
|
@@ -109,9 +110,23 @@ function mergeTrackingHeaders(headers) {
|
|
|
109
110
|
value
|
|
110
111
|
]);
|
|
111
112
|
} else {
|
|
112
|
-
|
|
113
|
+
if (!originalNames.has(lowerName)) {
|
|
114
|
+
originalNames.set(lowerName, name);
|
|
115
|
+
}
|
|
116
|
+
otherHeaders.append(name, value);
|
|
113
117
|
}
|
|
114
118
|
}
|
|
119
|
+
const mergedEntries = /* @__PURE__ */ new Map();
|
|
120
|
+
otherHeaders.forEach((value, name) => {
|
|
121
|
+
var _a2;
|
|
122
|
+
const key = (_a2 = originalNames.get(name)) != null ? _a2 : name;
|
|
123
|
+
const existing = mergedEntries.get(key);
|
|
124
|
+
mergedEntries.set(
|
|
125
|
+
key,
|
|
126
|
+
existing !== void 0 ? `${existing}, ${value}` : value
|
|
127
|
+
);
|
|
128
|
+
});
|
|
129
|
+
const merged = Object.fromEntries(mergedEntries);
|
|
115
130
|
for (const [name, trackingValue] of Object.entries(getTrackingHeaders())) {
|
|
116
131
|
const tokens = trackingValue.split(" ");
|
|
117
132
|
for (const value of (_b = callerValues.get(name)) != null ? _b : []) {
|
|
@@ -65,11 +65,16 @@ function isBase64Encoded(data) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
__name(isBase64Encoded, "isBase64Encoded");
|
|
68
|
-
function
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
function getEnvVar(envVar) {
|
|
69
|
+
var _a;
|
|
70
|
+
if (typeof process === "undefined") {
|
|
71
|
+
return void 0;
|
|
71
72
|
}
|
|
72
|
-
|
|
73
|
+
return (_a = process.env) == null ? void 0 : _a[envVar];
|
|
74
|
+
}
|
|
75
|
+
__name(getEnvVar, "getEnvVar");
|
|
76
|
+
function getBooleanEnvVar(envVar) {
|
|
77
|
+
const envVarValue = (getEnvVar(envVar) || "").toLowerCase();
|
|
73
78
|
return ["true", "1"].includes(envVarValue);
|
|
74
79
|
}
|
|
75
80
|
__name(getBooleanEnvVar, "getBooleanEnvVar");
|
|
@@ -83,9 +88,8 @@ function warnDeprecatedEnterpriseModeEnvVar(message) {
|
|
|
83
88
|
}
|
|
84
89
|
__name(warnDeprecatedEnterpriseModeEnvVar, "warnDeprecatedEnterpriseModeEnvVar");
|
|
85
90
|
function isEnterpriseModeEnabled() {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
if (((_b = process.env) == null ? void 0 : _b[ENTERPRISE_MODE_ENV_VAR]) !== void 0) {
|
|
91
|
+
const deprecatedIsSet = getEnvVar(DEPRECATED_ENTERPRISE_MODE_ENV_VAR) !== void 0;
|
|
92
|
+
if (getEnvVar(ENTERPRISE_MODE_ENV_VAR) !== void 0) {
|
|
89
93
|
if (deprecatedIsSet) {
|
|
90
94
|
warnDeprecatedEnterpriseModeEnvVar(
|
|
91
95
|
`${DEPRECATED_ENTERPRISE_MODE_ENV_VAR} is set but ignored because ${ENTERPRISE_MODE_ENV_VAR} takes precedence. ${DEPRECATED_ENTERPRISE_MODE_ENV_VAR} is deprecated, please use ${ENTERPRISE_MODE_ENV_VAR} instead.`
|
|
@@ -106,6 +110,7 @@ export {
|
|
|
106
110
|
base64Decode,
|
|
107
111
|
base64Encode,
|
|
108
112
|
getBooleanEnvVar,
|
|
113
|
+
getEnvVar,
|
|
109
114
|
isBase64Encoded,
|
|
110
115
|
isBrowser,
|
|
111
116
|
isEnterpriseModeEnabled,
|
|
@@ -16,6 +16,40 @@ function asRecord(value) {
|
|
|
16
16
|
return value !== null && typeof value === "object" ? value : void 0;
|
|
17
17
|
}
|
|
18
18
|
__name(asRecord, "asRecord");
|
|
19
|
+
function toError(error) {
|
|
20
|
+
return error instanceof Error ? error : new Error("Execution threw a non-Error value.", { cause: error });
|
|
21
|
+
}
|
|
22
|
+
__name(toError, "toError");
|
|
23
|
+
function isInvocationCancellation(error, signal) {
|
|
24
|
+
if (!(signal == null ? void 0 : signal.aborted)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
const seen = /* @__PURE__ */ new Set();
|
|
28
|
+
for (let depth = 0; depth < 32 && !seen.has(error); depth++) {
|
|
29
|
+
if (Object.is(error, signal.reason)) {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
seen.add(error);
|
|
33
|
+
const record = asRecord(error);
|
|
34
|
+
if (!record) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const name = record["name"];
|
|
39
|
+
if (name === "AbortError" || name === "InvocationAbortedError") {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
if (!("cause" in record)) {
|
|
43
|
+
return false;
|
|
44
|
+
}
|
|
45
|
+
error = record["cause"];
|
|
46
|
+
} catch {
|
|
47
|
+
return false;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
__name(isInvocationCancellation, "isInvocationCancellation");
|
|
19
53
|
function firstString(...values) {
|
|
20
54
|
for (const value of values) {
|
|
21
55
|
if (typeof value === "string") {
|
|
@@ -96,5 +130,7 @@ function formatError(err) {
|
|
|
96
130
|
__name(formatError, "formatError");
|
|
97
131
|
export {
|
|
98
132
|
formatError,
|
|
99
|
-
getErrorMessage
|
|
133
|
+
getErrorMessage,
|
|
134
|
+
isInvocationCancellation,
|
|
135
|
+
toError
|
|
100
136
|
};
|
|
@@ -15,15 +15,12 @@ async function* runWithRouting(items, context, router, runFn) {
|
|
|
15
15
|
}
|
|
16
16
|
let selectedKey = initialKey;
|
|
17
17
|
logger.debug(`Router selected initial key: ${selectedKey}`);
|
|
18
|
-
let selectedItem = items
|
|
19
|
-
if (!selectedItem) {
|
|
20
|
-
throw new Error(`Item not found for key: ${selectedKey}`);
|
|
21
|
-
}
|
|
18
|
+
let selectedItem = getSelectedItem(items, selectedKey);
|
|
22
19
|
const triedKeys = /* @__PURE__ */ new Set([selectedKey]);
|
|
23
20
|
while (true) {
|
|
24
|
-
const generatorOrPromise = runFn(selectedItem);
|
|
25
21
|
let firstYielded = false;
|
|
26
22
|
try {
|
|
23
|
+
const generatorOrPromise = runFn(selectedItem);
|
|
27
24
|
if (isAsyncGenerator(generatorOrPromise)) {
|
|
28
25
|
for await (const result2 of generatorOrPromise) {
|
|
29
26
|
yield result2;
|
|
@@ -48,10 +45,7 @@ async function* runWithRouting(items, context, router, runFn) {
|
|
|
48
45
|
throw error;
|
|
49
46
|
}
|
|
50
47
|
selectedKey = nextKey;
|
|
51
|
-
selectedItem = items
|
|
52
|
-
if (!selectedItem) {
|
|
53
|
-
throw new Error(`Item not found for key: ${selectedKey}`);
|
|
54
|
-
}
|
|
48
|
+
selectedItem = getSelectedItem(items, selectedKey);
|
|
55
49
|
triedKeys.add(selectedKey);
|
|
56
50
|
} else {
|
|
57
51
|
throw error;
|
|
@@ -60,8 +54,15 @@ async function* runWithRouting(items, context, router, runFn) {
|
|
|
60
54
|
}
|
|
61
55
|
}
|
|
62
56
|
__name(runWithRouting, "runWithRouting");
|
|
57
|
+
function getSelectedItem(items, key) {
|
|
58
|
+
if (!Object.hasOwn(items, key) || items[key] === void 0) {
|
|
59
|
+
throw new Error(`Item not found for key: ${key}`);
|
|
60
|
+
}
|
|
61
|
+
return items[key];
|
|
62
|
+
}
|
|
63
|
+
__name(getSelectedItem, "getSelectedItem");
|
|
63
64
|
function isAsyncGenerator(obj) {
|
|
64
|
-
return typeof obj === "object" && typeof obj[Symbol.asyncIterator] === "function";
|
|
65
|
+
return typeof obj === "object" && obj !== null && typeof obj[Symbol.asyncIterator] === "function";
|
|
65
66
|
}
|
|
66
67
|
__name(isAsyncGenerator, "isAsyncGenerator");
|
|
67
68
|
export {
|