@google/adk 2.4.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 +282 -55
- package/dist/cjs/agents/base_agent.js +111 -68
- package/dist/cjs/agents/functions.js +62 -85
- package/dist/cjs/agents/instructions.js +7 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +105 -95
- package/dist/cjs/agents/processors/content_processor_utils.js +42 -15
- package/dist/cjs/agents/processors/content_request_processor.js +28 -11
- 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 +2 -1
- 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 +128 -9
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +158 -36
- package/dist/cjs/common.js +50 -12
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +29 -14
- 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 +45 -21
- 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 +1 -4
- package/dist/cjs/sessions/database_session_service.js +191 -19
- 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/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +29 -28
- 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 -5
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +22 -34
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +60 -20
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +14 -23
- 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_toolset.js +3 -2
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/cjs/tools/load_artifacts_tool.js +15 -5
- package/dist/cjs/tools/load_memory_tool.js +2 -5
- 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 +18 -6
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +45 -14
- 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 +47 -28
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +9 -11
- 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 +10 -9
- package/dist/cjs/utils/gemini_schema_util.js +125 -12
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- 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 +293 -55
- package/dist/esm/agents/base_agent.js +111 -72
- package/dist/esm/agents/functions.js +67 -89
- package/dist/esm/agents/instructions.js +7 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +111 -100
- package/dist/esm/agents/processors/content_processor_utils.js +42 -15
- package/dist/esm/agents/processors/content_request_processor.js +28 -11
- 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 +2 -1
- 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 +128 -9
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +158 -36
- package/dist/esm/common.js +49 -6
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +27 -15
- 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 +45 -21
- 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 +1 -4
- package/dist/esm/sessions/database_session_service.js +191 -19
- 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/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +29 -28
- 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/application_integration_tool/application_integration_toolset.js +23 -35
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +64 -21
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +14 -23
- 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_toolset.js +3 -2
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/esm/tools/load_artifacts_tool.js +15 -5
- package/dist/esm/tools/load_memory_tool.js +2 -5
- 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 +18 -6
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +45 -14
- 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 +47 -28
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +9 -11
- 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 +10 -9
- package/dist/esm/utils/gemini_schema_util.js +124 -11
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- 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 +121 -3
- package/dist/types/agents/base_agent.d.ts +2 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +9 -9
- 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 +19 -2
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +49 -8
- package/dist/types/common.d.ts +16 -9
- package/dist/types/context/compaction_utils.d.ts +13 -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 +9 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -21
- 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 +0 -2
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- 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/application_integration_tool/clients/connections_client.d.ts +13 -4
- package/dist/types/tools/base_toolset.d.ts +1 -1
- 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_toolset.d.ts +2 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +5 -1
- package/dist/types/tools/load_memory_tool.d.ts +13 -7
- 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/operation_parser.d.ts +7 -3
- package/dist/types/tools/toolbox_toolset.d.ts +15 -20
- package/dist/types/utils/async_queue.d.ts +14 -0
- 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 +27 -6
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- 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 +86 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +13 -15
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -393
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -88
- package/dist/esm/telemetry/tracing.js +0 -361
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -143
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
AuthCredentialTypes
|
|
13
13
|
} from "../../../auth/auth_credential.js";
|
|
14
14
|
import { camelCaseKeys } from "../../../utils/case_utils.js";
|
|
15
|
+
import { formatError } from "../../../utils/error_utils.js";
|
|
15
16
|
const INTERNAL_AUTH_PREFIX = "_auth_prefix_vaf_";
|
|
16
17
|
const API_KEY_LOCATIONS = ["header", "query", "cookie"];
|
|
17
18
|
const OPENID_FETCH_TIMEOUT_MS = 1e4;
|
|
@@ -165,7 +166,7 @@ function tokenToSchemeCredential(tokenType, location, name, credentialValue) {
|
|
|
165
166
|
throw new Error(`Invalid security scheme type: ${tokenType}`);
|
|
166
167
|
}
|
|
167
168
|
__name(tokenToSchemeCredential, "tokenToSchemeCredential");
|
|
168
|
-
function
|
|
169
|
+
function serviceAccountRecordToSchemeCredential(config, scopes) {
|
|
169
170
|
const authCredential = {
|
|
170
171
|
authType: AuthCredentialTypes.SERVICE_ACCOUNT,
|
|
171
172
|
serviceAccount: {
|
|
@@ -179,7 +180,7 @@ function serviceAccountDictToSchemeCredential(config, scopes) {
|
|
|
179
180
|
};
|
|
180
181
|
return [bearerJwtScheme(), authCredential];
|
|
181
182
|
}
|
|
182
|
-
__name(
|
|
183
|
+
__name(serviceAccountRecordToSchemeCredential, "serviceAccountRecordToSchemeCredential");
|
|
183
184
|
function serviceAccountSchemeCredential(config) {
|
|
184
185
|
const authCredential = {
|
|
185
186
|
authType: AuthCredentialTypes.SERVICE_ACCOUNT,
|
|
@@ -188,9 +189,9 @@ function serviceAccountSchemeCredential(config) {
|
|
|
188
189
|
return [bearerJwtScheme(), authCredential];
|
|
189
190
|
}
|
|
190
191
|
__name(serviceAccountSchemeCredential, "serviceAccountSchemeCredential");
|
|
191
|
-
function
|
|
192
|
+
function openidRecordToSchemeCredential(configRecord, scopes, credentialRecord) {
|
|
192
193
|
const parsedConfig = OpenIdConnectConfigSchema.safeParse(
|
|
193
|
-
camelCaseKeys(
|
|
194
|
+
camelCaseKeys(configRecord)
|
|
194
195
|
);
|
|
195
196
|
if (!parsedConfig.success) {
|
|
196
197
|
throw new Error(
|
|
@@ -198,33 +199,33 @@ function openidDictToSchemeCredential(configDict, scopes, credentialDict) {
|
|
|
198
199
|
);
|
|
199
200
|
}
|
|
200
201
|
const openidScheme = { ...parsedConfig.data, scopes };
|
|
201
|
-
const values = Object.values(
|
|
202
|
+
const values = Object.values(credentialRecord);
|
|
202
203
|
if (values.length === 1) {
|
|
203
204
|
const wrapped = JsonObjectSchema.safeParse(values[0]);
|
|
204
205
|
if (wrapped.success && "client_id" in wrapped.data && "client_secret" in wrapped.data) {
|
|
205
|
-
|
|
206
|
+
credentialRecord = wrapped.data;
|
|
206
207
|
}
|
|
207
208
|
}
|
|
208
209
|
const missingFields = REQUIRED_CREDENTIAL_FIELDS.filter(
|
|
209
|
-
(field) => !(field in
|
|
210
|
+
(field) => !(field in credentialRecord)
|
|
210
211
|
);
|
|
211
212
|
if (missingFields.length > 0) {
|
|
212
213
|
throw new Error(
|
|
213
|
-
`Missing required fields in
|
|
214
|
+
`Missing required fields in credentialRecord: ${missingFields.join(", ")}`
|
|
214
215
|
);
|
|
215
216
|
}
|
|
216
217
|
const authCredential = {
|
|
217
218
|
authType: AuthCredentialTypes.OPEN_ID_CONNECT,
|
|
218
219
|
oauth2: {
|
|
219
|
-
clientId: String(
|
|
220
|
-
clientSecret: String(
|
|
221
|
-
redirectUri: "redirect_uri" in
|
|
220
|
+
clientId: String(credentialRecord["client_id"]),
|
|
221
|
+
clientSecret: String(credentialRecord["client_secret"]),
|
|
222
|
+
redirectUri: "redirect_uri" in credentialRecord ? String(credentialRecord["redirect_uri"]) : void 0
|
|
222
223
|
}
|
|
223
224
|
};
|
|
224
225
|
return [openidScheme, authCredential];
|
|
225
226
|
}
|
|
226
|
-
__name(
|
|
227
|
-
async function openidUrlToSchemeCredential(openidUrl, scopes,
|
|
227
|
+
__name(openidRecordToSchemeCredential, "openidRecordToSchemeCredential");
|
|
228
|
+
async function openidUrlToSchemeCredential(openidUrl, scopes, credentialRecord) {
|
|
228
229
|
let response;
|
|
229
230
|
try {
|
|
230
231
|
response = await fetch(openidUrl, {
|
|
@@ -235,21 +236,21 @@ async function openidUrlToSchemeCredential(openidUrl, scopes, credentialDict) {
|
|
|
235
236
|
}
|
|
236
237
|
} catch (e) {
|
|
237
238
|
throw new Error(
|
|
238
|
-
`Failed to fetch OpenID configuration from ${openidUrl}: ${
|
|
239
|
+
`Failed to fetch OpenID configuration from ${openidUrl}: ${formatError(e)}`
|
|
239
240
|
);
|
|
240
241
|
}
|
|
241
|
-
let
|
|
242
|
+
let configRecord;
|
|
242
243
|
try {
|
|
243
|
-
|
|
244
|
+
configRecord = JsonObjectSchema.parse(await response.json());
|
|
244
245
|
} catch (e) {
|
|
245
246
|
throw new Error(
|
|
246
|
-
`Invalid JSON response from OpenID configuration endpoint ${openidUrl}: ${
|
|
247
|
+
`Invalid JSON response from OpenID configuration endpoint ${openidUrl}: ${formatError(e)}`
|
|
247
248
|
);
|
|
248
249
|
}
|
|
249
|
-
return
|
|
250
|
-
{ ...
|
|
250
|
+
return openidRecordToSchemeCredential(
|
|
251
|
+
{ ...configRecord, openIdConnectUrl: openidUrl },
|
|
251
252
|
scopes,
|
|
252
|
-
|
|
253
|
+
credentialRecord
|
|
253
254
|
);
|
|
254
255
|
}
|
|
255
256
|
__name(openidUrlToSchemeCredential, "openidUrlToSchemeCredential");
|
|
@@ -300,9 +301,9 @@ function parseSecurityScheme(schema, data) {
|
|
|
300
301
|
return result.data;
|
|
301
302
|
}
|
|
302
303
|
__name(parseSecurityScheme, "parseSecurityScheme");
|
|
303
|
-
function
|
|
304
|
+
function recordToAuthScheme(data) {
|
|
304
305
|
if (!("type" in data)) {
|
|
305
|
-
throw new Error("Missing 'type' field in security scheme
|
|
306
|
+
throw new Error("Missing 'type' field in security scheme object.");
|
|
306
307
|
}
|
|
307
308
|
const securityType = data["type"];
|
|
308
309
|
switch (securityType) {
|
|
@@ -318,17 +319,17 @@ function dictToAuthScheme(data) {
|
|
|
318
319
|
throw new Error(`Invalid security scheme type: ${securityType}`);
|
|
319
320
|
}
|
|
320
321
|
}
|
|
321
|
-
__name(
|
|
322
|
+
__name(recordToAuthScheme, "recordToAuthScheme");
|
|
322
323
|
export {
|
|
323
324
|
INTERNAL_AUTH_PREFIX,
|
|
324
325
|
applyCredential,
|
|
325
326
|
createApiKeyScheme,
|
|
326
327
|
createBearerScheme,
|
|
327
328
|
credentialToParam,
|
|
328
|
-
|
|
329
|
-
openidDictToSchemeCredential,
|
|
329
|
+
openidRecordToSchemeCredential,
|
|
330
330
|
openidUrlToSchemeCredential,
|
|
331
|
-
|
|
331
|
+
recordToAuthScheme,
|
|
332
|
+
serviceAccountRecordToSchemeCredential,
|
|
332
333
|
serviceAccountSchemeCredential,
|
|
333
334
|
tokenToSchemeCredential
|
|
334
335
|
};
|
|
@@ -24,7 +24,7 @@ import { experimental } from "../../../../utils/experimental.js";
|
|
|
24
24
|
function checkSchemeCredentialType(authScheme, authCredential) {
|
|
25
25
|
if (!authCredential) {
|
|
26
26
|
throw new Error(
|
|
27
|
-
"
|
|
27
|
+
"authCredential is empty. Please create AuthCredential using OAuth2Auth."
|
|
28
28
|
);
|
|
29
29
|
}
|
|
30
30
|
if (authScheme.type !== AuthSchemeType.OPEN_ID_CONNECT && authScheme.type !== AuthSchemeType.OAUTH2) {
|
|
@@ -34,7 +34,7 @@ function checkSchemeCredentialType(authScheme, authCredential) {
|
|
|
34
34
|
}
|
|
35
35
|
if (!authCredential.oauth2 && !authCredential.http) {
|
|
36
36
|
throw new Error(
|
|
37
|
-
"
|
|
37
|
+
"authCredential is not configured with oauth2. Please create AuthCredential and set OAuth2Auth."
|
|
38
38
|
);
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -176,22 +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");
|
|
179
189
|
function serializeQueryValue(value) {
|
|
180
190
|
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
181
191
|
}
|
|
182
192
|
__name(serializeQueryValue, "serializeQueryValue");
|
|
183
|
-
function
|
|
193
|
+
function appendParamValue(target, name, value) {
|
|
184
194
|
if (!Array.isArray(value)) {
|
|
185
|
-
|
|
195
|
+
target.append(name, serializeQueryValue(value));
|
|
186
196
|
return;
|
|
187
197
|
}
|
|
188
198
|
for (const item of value) {
|
|
189
199
|
if (item !== void 0 && item !== null) {
|
|
190
|
-
|
|
200
|
+
target.append(name, serializeQueryValue(item));
|
|
191
201
|
}
|
|
192
202
|
}
|
|
193
203
|
}
|
|
194
|
-
__name(
|
|
204
|
+
__name(appendParamValue, "appendParamValue");
|
|
195
205
|
function prepareRequestParams(endpoint, parameters, args) {
|
|
196
206
|
const headers = {};
|
|
197
207
|
const queryParams = new URLSearchParams();
|
|
@@ -206,18 +216,24 @@ function prepareRequestParams(endpoint, parameters, args) {
|
|
|
206
216
|
const originalName = param.originalName;
|
|
207
217
|
const location = param.paramLocation;
|
|
208
218
|
if (location === "path") {
|
|
209
|
-
|
|
210
|
-
originalName
|
|
211
|
-
|
|
212
|
-
|
|
219
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
220
|
+
pathParams[originalName] = encodePathParamValue(
|
|
221
|
+
originalName,
|
|
222
|
+
toParamString(argValue)
|
|
223
|
+
);
|
|
224
|
+
}
|
|
213
225
|
} else if (location === "query") {
|
|
214
226
|
if (argValue !== void 0 && argValue !== null && argValue !== "") {
|
|
215
|
-
|
|
227
|
+
appendParamValue(queryParams, originalName, argValue);
|
|
216
228
|
}
|
|
217
229
|
} else if (location === "header") {
|
|
218
|
-
|
|
230
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
231
|
+
headers[originalName] = toParamString(argValue);
|
|
232
|
+
}
|
|
219
233
|
} else if (location === "cookie") {
|
|
220
|
-
|
|
234
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
235
|
+
cookies[originalName] = toParamString(argValue);
|
|
236
|
+
}
|
|
221
237
|
} else if (location === "body") {
|
|
222
238
|
if (originalName === "body" || originalName === "array" || originalName === "") {
|
|
223
239
|
body = argValue;
|
|
@@ -251,6 +267,18 @@ function isRawBody(value) {
|
|
|
251
267
|
return typeof value === "string" || ArrayBuffer.isView(value) || value instanceof ArrayBuffer || value instanceof Blob;
|
|
252
268
|
}
|
|
253
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");
|
|
254
282
|
function prepareRequestBody(requestBody, body, bodyData, headers) {
|
|
255
283
|
const finalData = body !== void 0 ? body : Object.keys(bodyData).length > 0 ? bodyData : void 0;
|
|
256
284
|
if (requestBody && "content" in requestBody) {
|
|
@@ -261,13 +289,16 @@ function prepareRequestBody(requestBody, body, bodyData, headers) {
|
|
|
261
289
|
headers["Content-Type"] = mimeType;
|
|
262
290
|
return typeof finalData === "string" ? finalData : JSON.stringify(finalData);
|
|
263
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
|
+
}
|
|
264
297
|
return new URLSearchParams(finalData);
|
|
265
298
|
} else if (mimeType === "multipart/form-data") {
|
|
266
299
|
const formData = new FormData();
|
|
267
300
|
if (typeof finalData === "object" && finalData !== null) {
|
|
268
|
-
|
|
269
|
-
formData.append(key, String(value));
|
|
270
|
-
}
|
|
301
|
+
appendFormFields(formData, finalData);
|
|
271
302
|
}
|
|
272
303
|
return formData;
|
|
273
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
|
|
@@ -38,26 +38,43 @@ function isToolOptionsObject(value) {
|
|
|
38
38
|
return typeof value === "object" && value !== null && "execute" in value && typeof value.execute === "function";
|
|
39
39
|
}
|
|
40
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");
|
|
41
59
|
function wrapLoadedTool(rawTool, prefix) {
|
|
42
60
|
var _a2;
|
|
43
61
|
if (isBaseTool(rawTool)) {
|
|
44
|
-
|
|
62
|
+
const name = prefix ? `${prefix}_${rawTool.name}` : rawTool.name;
|
|
63
|
+
if (name === rawTool.name) {
|
|
45
64
|
return rawTool;
|
|
46
65
|
}
|
|
47
|
-
return
|
|
48
|
-
Object.create(Object.getPrototypeOf(rawTool)),
|
|
49
|
-
rawTool,
|
|
50
|
-
{ name: `${prefix}_${rawTool.name}` }
|
|
51
|
-
);
|
|
66
|
+
return wrapPrefixedBaseTool(rawTool, name);
|
|
52
67
|
}
|
|
53
68
|
if (typeof rawTool === "function") {
|
|
54
69
|
const fn = rawTool;
|
|
55
|
-
const baseName = fn.name || "toolbox_tool";
|
|
70
|
+
const baseName = typeof fn.getName === "function" ? fn.getName() : fn.toolName || (fn.name && fn.name !== "callable" ? fn.name : void 0) || "toolbox_tool";
|
|
56
71
|
const name = prefix ? `${prefix}_${baseName}` : baseName;
|
|
57
|
-
const description = (_a2 = fn.description) != null ? _a2 : "";
|
|
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;
|
|
58
74
|
return new FunctionTool({
|
|
59
75
|
name,
|
|
60
76
|
description,
|
|
77
|
+
parameters,
|
|
61
78
|
execute: fn
|
|
62
79
|
});
|
|
63
80
|
}
|
|
@@ -78,53 +95,55 @@ function wrapLoadedTool(rawTool, prefix) {
|
|
|
78
95
|
__name(wrapLoadedTool, "wrapLoadedTool");
|
|
79
96
|
const _ToolboxToolset = class _ToolboxToolset extends (_b = BaseToolset, _a = TOOLBOX_TOOLSET_SIGNATURE_SYMBOL, _b) {
|
|
80
97
|
constructor(serverUrlOrOptions, extraOptions) {
|
|
81
|
-
var _a2, _b2, _c, _d;
|
|
98
|
+
var _a2, _b2, _c, _d, _e;
|
|
82
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
|
+
}
|
|
83
104
|
if ((!options.toolNames || options.toolNames.length === 0) && !options.toolsetName) {
|
|
84
105
|
throw new Error("toolNames and toolsetName cannot both be undefined.");
|
|
85
106
|
}
|
|
86
|
-
super((
|
|
107
|
+
super((_b2 = options.toolFilter) != null ? _b2 : [], options.prefix);
|
|
87
108
|
/** A unique symbol to identify ADK ToolboxToolset class. */
|
|
88
109
|
this[_a] = true;
|
|
89
110
|
this.serverUrl = options.serverUrl;
|
|
90
111
|
this.toolsetName = options.toolsetName;
|
|
91
112
|
this.toolNames = options.toolNames;
|
|
92
|
-
this.authTokenGetters = (
|
|
93
|
-
this.boundParams = (
|
|
94
|
-
this.toolboxClient = (
|
|
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 : "");
|
|
95
116
|
}
|
|
96
117
|
/**
|
|
97
118
|
* Loads the configured toolset and/or individual tools from the Toolbox
|
|
98
119
|
* client and returns the selected {@link BaseTool} instances.
|
|
99
120
|
*/
|
|
100
121
|
async getTools(context) {
|
|
101
|
-
var _a2, _b2
|
|
102
|
-
const loadOptions = {
|
|
103
|
-
authTokenGetters: this.authTokenGetters,
|
|
104
|
-
boundParams: this.boundParams
|
|
105
|
-
};
|
|
122
|
+
var _a2, _b2;
|
|
106
123
|
const tools = [];
|
|
107
124
|
if (this.toolsetName) {
|
|
108
|
-
const loader = (
|
|
125
|
+
const loader = (_a2 = this.toolboxClient.loadToolset) == null ? void 0 : _a2.bind(this.toolboxClient);
|
|
109
126
|
if (!loader) {
|
|
110
|
-
throw new Error(
|
|
111
|
-
"ToolboxClient does not implement loadToolset or load_toolset."
|
|
112
|
-
);
|
|
127
|
+
throw new Error("ToolboxClient does not implement loadToolset.");
|
|
113
128
|
}
|
|
114
|
-
const loadedToolset = await loader(
|
|
129
|
+
const loadedToolset = await loader(
|
|
130
|
+
this.toolsetName,
|
|
131
|
+
this.authTokenGetters,
|
|
132
|
+
this.boundParams
|
|
133
|
+
);
|
|
115
134
|
for (const rawTool of loadedToolset) {
|
|
116
135
|
tools.push(wrapLoadedTool(rawTool, this.prefix));
|
|
117
136
|
}
|
|
118
137
|
}
|
|
119
138
|
if (this.toolNames && this.toolNames.length > 0) {
|
|
120
|
-
const loader = (
|
|
139
|
+
const loader = (_b2 = this.toolboxClient.loadTool) == null ? void 0 : _b2.bind(this.toolboxClient);
|
|
121
140
|
if (!loader) {
|
|
122
|
-
throw new Error(
|
|
123
|
-
"ToolboxClient does not implement loadTool or load_tool."
|
|
124
|
-
);
|
|
141
|
+
throw new Error("ToolboxClient does not implement loadTool.");
|
|
125
142
|
}
|
|
126
143
|
const loadedSingleTools = await Promise.all(
|
|
127
|
-
this.toolNames.map(
|
|
144
|
+
this.toolNames.map(
|
|
145
|
+
(toolName) => loader(toolName, this.authTokenGetters, this.boundParams)
|
|
146
|
+
)
|
|
128
147
|
);
|
|
129
148
|
for (const rawTool of loadedSingleTools) {
|
|
130
149
|
tools.push(wrapLoadedTool(rawTool, this.prefix));
|
|
@@ -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);
|
|
@@ -116,19 +116,17 @@ function mergeTrackingHeaders(headers) {
|
|
|
116
116
|
otherHeaders.append(name, value);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
119
|
-
const
|
|
119
|
+
const mergedEntries = /* @__PURE__ */ new Map();
|
|
120
120
|
otherHeaders.forEach((value, name) => {
|
|
121
|
-
|
|
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
|
+
);
|
|
122
128
|
});
|
|
123
|
-
const merged = Object.fromEntries(
|
|
124
|
-
normalizedEntries.map(([name, value]) => {
|
|
125
|
-
var _a2;
|
|
126
|
-
return [
|
|
127
|
-
(_a2 = originalNames.get(name)) != null ? _a2 : name,
|
|
128
|
-
value
|
|
129
|
-
];
|
|
130
|
-
})
|
|
131
|
-
);
|
|
129
|
+
const merged = Object.fromEntries(mergedEntries);
|
|
132
130
|
for (const [name, trackingValue] of Object.entries(getTrackingHeaders())) {
|
|
133
131
|
const tokens = trackingValue.split(" ");
|
|
134
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,
|