@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
|
@@ -51,7 +51,7 @@ function normalizeMimeType(mimeType) {
|
|
|
51
51
|
if (!mimeType) {
|
|
52
52
|
return void 0;
|
|
53
53
|
}
|
|
54
|
-
return mimeType.split(";")[0].trim();
|
|
54
|
+
return mimeType.split(";")[0].trim().toLowerCase();
|
|
55
55
|
}
|
|
56
56
|
__name(normalizeMimeType, "normalizeMimeType");
|
|
57
57
|
function isInlineMimeTypeSupported(mimeType) {
|
|
@@ -69,23 +69,33 @@ function base64ByteLength(data) {
|
|
|
69
69
|
return Math.floor(digits * 3 / 4);
|
|
70
70
|
}
|
|
71
71
|
__name(base64ByteLength, "base64ByteLength");
|
|
72
|
-
function asSafePartForLlm(artifact, artifactName) {
|
|
72
|
+
function asSafePartForLlm(artifact, artifactName, options) {
|
|
73
|
+
if ((options == null ? void 0 : options.inlineMediaAsPlaceholder) && !artifact.inlineData && artifact.fileData) {
|
|
74
|
+
const fileUri = artifact.fileData.fileUri || "unknown";
|
|
75
|
+
const mimeType2 = normalizeMimeType(artifact.fileData.mimeType) || "application/octet-stream";
|
|
76
|
+
return {
|
|
77
|
+
text: `[Artifact: ${artifactName}, uri: ${fileUri}, type: ${mimeType2}.]`
|
|
78
|
+
};
|
|
79
|
+
}
|
|
73
80
|
const inlineData = artifact.inlineData;
|
|
74
81
|
if (!inlineData) {
|
|
75
82
|
return artifact;
|
|
76
83
|
}
|
|
77
|
-
if (isInlineMimeTypeSupported(inlineData.mimeType)) {
|
|
84
|
+
if (!(options == null ? void 0 : options.inlineMediaAsPlaceholder) && isInlineMimeTypeSupported(inlineData.mimeType)) {
|
|
78
85
|
return artifact;
|
|
79
86
|
}
|
|
80
87
|
const mimeType = normalizeMimeType(inlineData.mimeType) || "application/octet-stream";
|
|
88
|
+
const isTextLike = mimeType.startsWith("text/") || TEXT_LIKE_MIME_TYPES.has(mimeType);
|
|
81
89
|
const data = inlineData.data;
|
|
82
|
-
if (!data) {
|
|
90
|
+
if (data === void 0 || data === null || !isTextLike && data === "") {
|
|
83
91
|
return {
|
|
84
92
|
text: `[Artifact: ${artifactName}, type: ${mimeType}. No inline data was provided.]`
|
|
85
93
|
};
|
|
86
94
|
}
|
|
87
|
-
const isTextLike = mimeType.startsWith("text/") || TEXT_LIKE_MIME_TYPES.has(mimeType);
|
|
88
95
|
if (isTextLike) {
|
|
96
|
+
if (data === "") {
|
|
97
|
+
return { text: "" };
|
|
98
|
+
}
|
|
89
99
|
try {
|
|
90
100
|
return { text: (0, import_env_aware_utils.base64Decode)(data.replace(/-/g, "+").replace(/_/g, "/")) };
|
|
91
101
|
} catch {
|
|
@@ -42,7 +42,7 @@ const _LoadMemoryTool = class _LoadMemoryTool extends import_base_tool.BaseTool
|
|
|
42
42
|
var _a;
|
|
43
43
|
super({
|
|
44
44
|
name: "load_memory",
|
|
45
|
-
description: "Loads the memory for the current user
|
|
45
|
+
description: "Loads the memory for the current user."
|
|
46
46
|
});
|
|
47
47
|
this.textOnlyContent = (_a = options.textOnlyContent) != null ? _a : false;
|
|
48
48
|
}
|
|
@@ -62,10 +62,7 @@ const _LoadMemoryTool = class _LoadMemoryTool extends import_base_tool.BaseTool
|
|
|
62
62
|
}
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
|
-
async runAsync({
|
|
66
|
-
args,
|
|
67
|
-
toolContext
|
|
68
|
-
}) {
|
|
65
|
+
async runAsync({ args, toolContext }) {
|
|
69
66
|
const query = args["query"];
|
|
70
67
|
if (!toolContext.invocationContext.memoryService) {
|
|
71
68
|
throw new Error("Memory service is not initialized.");
|
|
@@ -38,6 +38,7 @@ __export(mcp_session_manager_exports, {
|
|
|
38
38
|
MCPSessionManager: () => MCPSessionManager
|
|
39
39
|
});
|
|
40
40
|
module.exports = __toCommonJS(mcp_session_manager_exports);
|
|
41
|
+
var import_instrumentation = require("../../telemetry/api/instrumentation.js");
|
|
41
42
|
var import_client_labels = require("../../utils/client_labels.js");
|
|
42
43
|
var import_error_utils = require("../../utils/error_utils.js");
|
|
43
44
|
var import_logger = require("../../utils/logger.js");
|
|
@@ -63,7 +64,8 @@ function buildTransportOptions(params) {
|
|
|
63
64
|
requestInit: {
|
|
64
65
|
...transportOptions == null ? void 0 : transportOptions.requestInit,
|
|
65
66
|
headers: (0, import_client_labels.mergeTrackingHeaders)(callerHeaders)
|
|
66
|
-
}
|
|
67
|
+
},
|
|
68
|
+
fetch: (0, import_instrumentation.instrumentMcpFetch)(transportOptions == null ? void 0 : transportOptions.fetch)
|
|
67
69
|
};
|
|
68
70
|
}
|
|
69
71
|
__name(buildTransportOptions, "buildTransportOptions");
|
|
@@ -75,7 +77,8 @@ function buildSseTransportOptions(params) {
|
|
|
75
77
|
requestInit: {
|
|
76
78
|
...transportOptions == null ? void 0 : transportOptions.requestInit,
|
|
77
79
|
headers: (0, import_client_labels.mergeTrackingHeaders)(callerHeaders)
|
|
78
|
-
}
|
|
80
|
+
},
|
|
81
|
+
fetch: (0, import_instrumentation.instrumentMcpFetch)(transportOptions == null ? void 0 : transportOptions.fetch)
|
|
79
82
|
};
|
|
80
83
|
}
|
|
81
84
|
__name(buildSseTransportOptions, "buildSseTransportOptions");
|
|
@@ -84,6 +87,23 @@ const _MCPSessionManager = class _MCPSessionManager {
|
|
|
84
87
|
this.activeSessions = /* @__PURE__ */ new Set();
|
|
85
88
|
this.connectionParams = connectionParams;
|
|
86
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Builds per-request options for MCP client operations.
|
|
92
|
+
*
|
|
93
|
+
* For a stdio connection with a configured `timeout`, the timeout is
|
|
94
|
+
* converted from seconds to milliseconds. Otherwise the MCP SDK applies its
|
|
95
|
+
* own default request timeout.
|
|
96
|
+
*
|
|
97
|
+
* @param signal Optional abort signal to attach to the request.
|
|
98
|
+
* @return The request options for the MCP SDK client.
|
|
99
|
+
*/
|
|
100
|
+
getRequestOptions(signal) {
|
|
101
|
+
const options = signal !== void 0 ? { signal } : {};
|
|
102
|
+
if (this.connectionParams.type === "StdioConnectionParams" && this.connectionParams.timeout !== void 0) {
|
|
103
|
+
options.timeout = this.connectionParams.timeout * 1e3;
|
|
104
|
+
}
|
|
105
|
+
return options;
|
|
106
|
+
}
|
|
87
107
|
async createSession() {
|
|
88
108
|
const { Client } = await (0, import_optional_peer.loadOptionalPeer)(
|
|
89
109
|
MCP_SDK,
|
|
@@ -101,7 +121,7 @@ const _MCPSessionManager = class _MCPSessionManager {
|
|
|
101
121
|
this.connectionParams.serverParams
|
|
102
122
|
);
|
|
103
123
|
transport.onerror = logTransportError;
|
|
104
|
-
await client.connect(transport);
|
|
124
|
+
await client.connect(transport, this.getRequestOptions());
|
|
105
125
|
break;
|
|
106
126
|
}
|
|
107
127
|
case "StreamableHTTPConnectionParams": {
|
|
@@ -57,9 +57,13 @@ const _MCPTool = class _MCPTool extends import_base_tool.BaseTool {
|
|
|
57
57
|
try {
|
|
58
58
|
const callRequest = {};
|
|
59
59
|
callRequest.params = { name: this.originalName, arguments: request.args };
|
|
60
|
-
const result = await session.callTool(
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
const result = await session.callTool(
|
|
61
|
+
callRequest.params,
|
|
62
|
+
void 0,
|
|
63
|
+
this.mcpSessionManager.getRequestOptions(
|
|
64
|
+
request.toolContext.abortSignal
|
|
65
|
+
)
|
|
66
|
+
);
|
|
63
67
|
return result;
|
|
64
68
|
} finally {
|
|
65
69
|
await this.mcpSessionManager.closeSession(session);
|
|
@@ -46,7 +46,10 @@ const _MCPToolset = class _MCPToolset extends import_base_toolset.BaseToolset {
|
|
|
46
46
|
const session = await this.mcpSessionManager.createSession();
|
|
47
47
|
let listResult;
|
|
48
48
|
try {
|
|
49
|
-
listResult = await session.listTools(
|
|
49
|
+
listResult = await session.listTools(
|
|
50
|
+
void 0,
|
|
51
|
+
this.mcpSessionManager.getRequestOptions()
|
|
52
|
+
);
|
|
50
53
|
} finally {
|
|
51
54
|
await this.mcpSessionManager.closeSession(session);
|
|
52
55
|
}
|
|
@@ -71,7 +74,10 @@ const _MCPToolset = class _MCPToolset extends import_base_toolset.BaseToolset {
|
|
|
71
74
|
async listResources() {
|
|
72
75
|
const session = await this.mcpSessionManager.createSession();
|
|
73
76
|
try {
|
|
74
|
-
const result = await session.listResources(
|
|
77
|
+
const result = await session.listResources(
|
|
78
|
+
void 0,
|
|
79
|
+
this.mcpSessionManager.getRequestOptions()
|
|
80
|
+
);
|
|
75
81
|
return result.resources.map((resource) => resource.name);
|
|
76
82
|
} finally {
|
|
77
83
|
await this.mcpSessionManager.closeSession(session);
|
|
@@ -88,7 +94,10 @@ const _MCPToolset = class _MCPToolset extends import_base_toolset.BaseToolset {
|
|
|
88
94
|
const session = await this.mcpSessionManager.createSession();
|
|
89
95
|
let result;
|
|
90
96
|
try {
|
|
91
|
-
result = await session.listResources(
|
|
97
|
+
result = await session.listResources(
|
|
98
|
+
void 0,
|
|
99
|
+
this.mcpSessionManager.getRequestOptions()
|
|
100
|
+
);
|
|
92
101
|
} finally {
|
|
93
102
|
await this.mcpSessionManager.closeSession(session);
|
|
94
103
|
}
|
|
@@ -118,9 +127,12 @@ const _MCPToolset = class _MCPToolset extends import_base_toolset.BaseToolset {
|
|
|
118
127
|
}
|
|
119
128
|
const session = await this.mcpSessionManager.createSession();
|
|
120
129
|
try {
|
|
121
|
-
const result = await session.readResource(
|
|
122
|
-
|
|
123
|
-
|
|
130
|
+
const result = await session.readResource(
|
|
131
|
+
{
|
|
132
|
+
uri: resourceInfo.uri
|
|
133
|
+
},
|
|
134
|
+
this.mcpSessionManager.getRequestOptions()
|
|
135
|
+
);
|
|
124
136
|
return result.contents;
|
|
125
137
|
} finally {
|
|
126
138
|
await this.mcpSessionManager.closeSession(session);
|
|
@@ -30,10 +30,10 @@ __export(auth_helpers_exports, {
|
|
|
30
30
|
createApiKeyScheme: () => createApiKeyScheme,
|
|
31
31
|
createBearerScheme: () => createBearerScheme,
|
|
32
32
|
credentialToParam: () => credentialToParam,
|
|
33
|
-
|
|
34
|
-
openidDictToSchemeCredential: () => openidDictToSchemeCredential,
|
|
33
|
+
openidRecordToSchemeCredential: () => openidRecordToSchemeCredential,
|
|
35
34
|
openidUrlToSchemeCredential: () => openidUrlToSchemeCredential,
|
|
36
|
-
|
|
35
|
+
recordToAuthScheme: () => recordToAuthScheme,
|
|
36
|
+
serviceAccountRecordToSchemeCredential: () => serviceAccountRecordToSchemeCredential,
|
|
37
37
|
serviceAccountSchemeCredential: () => serviceAccountSchemeCredential,
|
|
38
38
|
tokenToSchemeCredential: () => tokenToSchemeCredential
|
|
39
39
|
});
|
|
@@ -41,6 +41,7 @@ module.exports = __toCommonJS(auth_helpers_exports);
|
|
|
41
41
|
var import_zod = require("zod");
|
|
42
42
|
var import_auth_credential = require("../../../auth/auth_credential.js");
|
|
43
43
|
var import_case_utils = require("../../../utils/case_utils.js");
|
|
44
|
+
var import_error_utils = require("../../../utils/error_utils.js");
|
|
44
45
|
/**
|
|
45
46
|
* @license
|
|
46
47
|
* Copyright 2026 Google LLC
|
|
@@ -199,7 +200,7 @@ function tokenToSchemeCredential(tokenType, location, name, credentialValue) {
|
|
|
199
200
|
throw new Error(`Invalid security scheme type: ${tokenType}`);
|
|
200
201
|
}
|
|
201
202
|
__name(tokenToSchemeCredential, "tokenToSchemeCredential");
|
|
202
|
-
function
|
|
203
|
+
function serviceAccountRecordToSchemeCredential(config, scopes) {
|
|
203
204
|
const authCredential = {
|
|
204
205
|
authType: import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT,
|
|
205
206
|
serviceAccount: {
|
|
@@ -213,7 +214,7 @@ function serviceAccountDictToSchemeCredential(config, scopes) {
|
|
|
213
214
|
};
|
|
214
215
|
return [bearerJwtScheme(), authCredential];
|
|
215
216
|
}
|
|
216
|
-
__name(
|
|
217
|
+
__name(serviceAccountRecordToSchemeCredential, "serviceAccountRecordToSchemeCredential");
|
|
217
218
|
function serviceAccountSchemeCredential(config) {
|
|
218
219
|
const authCredential = {
|
|
219
220
|
authType: import_auth_credential.AuthCredentialTypes.SERVICE_ACCOUNT,
|
|
@@ -222,9 +223,9 @@ function serviceAccountSchemeCredential(config) {
|
|
|
222
223
|
return [bearerJwtScheme(), authCredential];
|
|
223
224
|
}
|
|
224
225
|
__name(serviceAccountSchemeCredential, "serviceAccountSchemeCredential");
|
|
225
|
-
function
|
|
226
|
+
function openidRecordToSchemeCredential(configRecord, scopes, credentialRecord) {
|
|
226
227
|
const parsedConfig = OpenIdConnectConfigSchema.safeParse(
|
|
227
|
-
(0, import_case_utils.camelCaseKeys)(
|
|
228
|
+
(0, import_case_utils.camelCaseKeys)(configRecord)
|
|
228
229
|
);
|
|
229
230
|
if (!parsedConfig.success) {
|
|
230
231
|
throw new Error(
|
|
@@ -232,33 +233,33 @@ function openidDictToSchemeCredential(configDict, scopes, credentialDict) {
|
|
|
232
233
|
);
|
|
233
234
|
}
|
|
234
235
|
const openidScheme = { ...parsedConfig.data, scopes };
|
|
235
|
-
const values = Object.values(
|
|
236
|
+
const values = Object.values(credentialRecord);
|
|
236
237
|
if (values.length === 1) {
|
|
237
238
|
const wrapped = JsonObjectSchema.safeParse(values[0]);
|
|
238
239
|
if (wrapped.success && "client_id" in wrapped.data && "client_secret" in wrapped.data) {
|
|
239
|
-
|
|
240
|
+
credentialRecord = wrapped.data;
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
const missingFields = REQUIRED_CREDENTIAL_FIELDS.filter(
|
|
243
|
-
(field) => !(field in
|
|
244
|
+
(field) => !(field in credentialRecord)
|
|
244
245
|
);
|
|
245
246
|
if (missingFields.length > 0) {
|
|
246
247
|
throw new Error(
|
|
247
|
-
`Missing required fields in
|
|
248
|
+
`Missing required fields in credentialRecord: ${missingFields.join(", ")}`
|
|
248
249
|
);
|
|
249
250
|
}
|
|
250
251
|
const authCredential = {
|
|
251
252
|
authType: import_auth_credential.AuthCredentialTypes.OPEN_ID_CONNECT,
|
|
252
253
|
oauth2: {
|
|
253
|
-
clientId: String(
|
|
254
|
-
clientSecret: String(
|
|
255
|
-
redirectUri: "redirect_uri" in
|
|
254
|
+
clientId: String(credentialRecord["client_id"]),
|
|
255
|
+
clientSecret: String(credentialRecord["client_secret"]),
|
|
256
|
+
redirectUri: "redirect_uri" in credentialRecord ? String(credentialRecord["redirect_uri"]) : void 0
|
|
256
257
|
}
|
|
257
258
|
};
|
|
258
259
|
return [openidScheme, authCredential];
|
|
259
260
|
}
|
|
260
|
-
__name(
|
|
261
|
-
async function openidUrlToSchemeCredential(openidUrl, scopes,
|
|
261
|
+
__name(openidRecordToSchemeCredential, "openidRecordToSchemeCredential");
|
|
262
|
+
async function openidUrlToSchemeCredential(openidUrl, scopes, credentialRecord) {
|
|
262
263
|
let response;
|
|
263
264
|
try {
|
|
264
265
|
response = await fetch(openidUrl, {
|
|
@@ -269,21 +270,21 @@ async function openidUrlToSchemeCredential(openidUrl, scopes, credentialDict) {
|
|
|
269
270
|
}
|
|
270
271
|
} catch (e) {
|
|
271
272
|
throw new Error(
|
|
272
|
-
`Failed to fetch OpenID configuration from ${openidUrl}: ${
|
|
273
|
+
`Failed to fetch OpenID configuration from ${openidUrl}: ${(0, import_error_utils.formatError)(e)}`
|
|
273
274
|
);
|
|
274
275
|
}
|
|
275
|
-
let
|
|
276
|
+
let configRecord;
|
|
276
277
|
try {
|
|
277
|
-
|
|
278
|
+
configRecord = JsonObjectSchema.parse(await response.json());
|
|
278
279
|
} catch (e) {
|
|
279
280
|
throw new Error(
|
|
280
|
-
`Invalid JSON response from OpenID configuration endpoint ${openidUrl}: ${
|
|
281
|
+
`Invalid JSON response from OpenID configuration endpoint ${openidUrl}: ${(0, import_error_utils.formatError)(e)}`
|
|
281
282
|
);
|
|
282
283
|
}
|
|
283
|
-
return
|
|
284
|
-
{ ...
|
|
284
|
+
return openidRecordToSchemeCredential(
|
|
285
|
+
{ ...configRecord, openIdConnectUrl: openidUrl },
|
|
285
286
|
scopes,
|
|
286
|
-
|
|
287
|
+
credentialRecord
|
|
287
288
|
);
|
|
288
289
|
}
|
|
289
290
|
__name(openidUrlToSchemeCredential, "openidUrlToSchemeCredential");
|
|
@@ -334,9 +335,9 @@ function parseSecurityScheme(schema, data) {
|
|
|
334
335
|
return result.data;
|
|
335
336
|
}
|
|
336
337
|
__name(parseSecurityScheme, "parseSecurityScheme");
|
|
337
|
-
function
|
|
338
|
+
function recordToAuthScheme(data) {
|
|
338
339
|
if (!("type" in data)) {
|
|
339
|
-
throw new Error("Missing 'type' field in security scheme
|
|
340
|
+
throw new Error("Missing 'type' field in security scheme object.");
|
|
340
341
|
}
|
|
341
342
|
const securityType = data["type"];
|
|
342
343
|
switch (securityType) {
|
|
@@ -352,7 +353,7 @@ function dictToAuthScheme(data) {
|
|
|
352
353
|
throw new Error(`Invalid security scheme type: ${securityType}`);
|
|
353
354
|
}
|
|
354
355
|
}
|
|
355
|
-
__name(
|
|
356
|
+
__name(recordToAuthScheme, "recordToAuthScheme");
|
|
356
357
|
// Annotate the CommonJS export names for ESM import in node:
|
|
357
358
|
0 && (module.exports = {
|
|
358
359
|
INTERNAL_AUTH_PREFIX,
|
|
@@ -360,10 +361,10 @@ __name(dictToAuthScheme, "dictToAuthScheme");
|
|
|
360
361
|
createApiKeyScheme,
|
|
361
362
|
createBearerScheme,
|
|
362
363
|
credentialToParam,
|
|
363
|
-
|
|
364
|
-
openidDictToSchemeCredential,
|
|
364
|
+
openidRecordToSchemeCredential,
|
|
365
365
|
openidUrlToSchemeCredential,
|
|
366
|
-
|
|
366
|
+
recordToAuthScheme,
|
|
367
|
+
serviceAccountRecordToSchemeCredential,
|
|
367
368
|
serviceAccountSchemeCredential,
|
|
368
369
|
tokenToSchemeCredential
|
|
369
370
|
});
|
|
@@ -50,7 +50,7 @@ var import_experimental = require("../../../../utils/experimental.js");
|
|
|
50
50
|
function checkSchemeCredentialType(authScheme, authCredential) {
|
|
51
51
|
if (!authCredential) {
|
|
52
52
|
throw new Error(
|
|
53
|
-
"
|
|
53
|
+
"authCredential is empty. Please create AuthCredential using OAuth2Auth."
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
if (authScheme.type !== import_auth_schemes.AuthSchemeType.OPEN_ID_CONNECT && authScheme.type !== import_auth_schemes.AuthSchemeType.OAUTH2) {
|
|
@@ -60,7 +60,7 @@ function checkSchemeCredentialType(authScheme, authCredential) {
|
|
|
60
60
|
}
|
|
61
61
|
if (!authCredential.oauth2 && !authCredential.http) {
|
|
62
62
|
throw new Error(
|
|
63
|
-
"
|
|
63
|
+
"authCredential is not configured with oauth2. Please create AuthCredential and set OAuth2Auth."
|
|
64
64
|
);
|
|
65
65
|
}
|
|
66
66
|
}
|
|
@@ -203,22 +203,32 @@ function encodePathParamValue(name, value) {
|
|
|
203
203
|
return encodeURIComponent(value);
|
|
204
204
|
}
|
|
205
205
|
__name(encodePathParamValue, "encodePathParamValue");
|
|
206
|
+
function toParamString(value) {
|
|
207
|
+
if (Array.isArray(value)) {
|
|
208
|
+
return value.filter((item) => item !== void 0 && item !== null).map(toParamString).join(",");
|
|
209
|
+
}
|
|
210
|
+
if (typeof value === "object" && value !== null) {
|
|
211
|
+
return Object.entries(value).filter(([, v]) => v !== void 0 && v !== null).map(([k, v]) => `${k},${toParamString(v)}`).join(",");
|
|
212
|
+
}
|
|
213
|
+
return String(value);
|
|
214
|
+
}
|
|
215
|
+
__name(toParamString, "toParamString");
|
|
206
216
|
function serializeQueryValue(value) {
|
|
207
217
|
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
208
218
|
}
|
|
209
219
|
__name(serializeQueryValue, "serializeQueryValue");
|
|
210
|
-
function
|
|
220
|
+
function appendParamValue(target, name, value) {
|
|
211
221
|
if (!Array.isArray(value)) {
|
|
212
|
-
|
|
222
|
+
target.append(name, serializeQueryValue(value));
|
|
213
223
|
return;
|
|
214
224
|
}
|
|
215
225
|
for (const item of value) {
|
|
216
226
|
if (item !== void 0 && item !== null) {
|
|
217
|
-
|
|
227
|
+
target.append(name, serializeQueryValue(item));
|
|
218
228
|
}
|
|
219
229
|
}
|
|
220
230
|
}
|
|
221
|
-
__name(
|
|
231
|
+
__name(appendParamValue, "appendParamValue");
|
|
222
232
|
function prepareRequestParams(endpoint, parameters, args) {
|
|
223
233
|
const headers = {};
|
|
224
234
|
const queryParams = new URLSearchParams();
|
|
@@ -233,18 +243,24 @@ function prepareRequestParams(endpoint, parameters, args) {
|
|
|
233
243
|
const originalName = param.originalName;
|
|
234
244
|
const location = param.paramLocation;
|
|
235
245
|
if (location === "path") {
|
|
236
|
-
|
|
237
|
-
originalName
|
|
238
|
-
|
|
239
|
-
|
|
246
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
247
|
+
pathParams[originalName] = encodePathParamValue(
|
|
248
|
+
originalName,
|
|
249
|
+
toParamString(argValue)
|
|
250
|
+
);
|
|
251
|
+
}
|
|
240
252
|
} else if (location === "query") {
|
|
241
253
|
if (argValue !== void 0 && argValue !== null && argValue !== "") {
|
|
242
|
-
|
|
254
|
+
appendParamValue(queryParams, originalName, argValue);
|
|
243
255
|
}
|
|
244
256
|
} else if (location === "header") {
|
|
245
|
-
|
|
257
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
258
|
+
headers[originalName] = toParamString(argValue);
|
|
259
|
+
}
|
|
246
260
|
} else if (location === "cookie") {
|
|
247
|
-
|
|
261
|
+
if (argValue !== void 0 && argValue !== null) {
|
|
262
|
+
cookies[originalName] = toParamString(argValue);
|
|
263
|
+
}
|
|
248
264
|
} else if (location === "body") {
|
|
249
265
|
if (originalName === "body" || originalName === "array" || originalName === "") {
|
|
250
266
|
body = argValue;
|
|
@@ -278,6 +294,18 @@ function isRawBody(value) {
|
|
|
278
294
|
return typeof value === "string" || ArrayBuffer.isView(value) || value instanceof ArrayBuffer || value instanceof Blob;
|
|
279
295
|
}
|
|
280
296
|
__name(isRawBody, "isRawBody");
|
|
297
|
+
function isFormFields(value) {
|
|
298
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
299
|
+
}
|
|
300
|
+
__name(isFormFields, "isFormFields");
|
|
301
|
+
function appendFormFields(target, fields) {
|
|
302
|
+
for (const [name, value] of Object.entries(fields)) {
|
|
303
|
+
if (value !== void 0 && value !== null) {
|
|
304
|
+
appendParamValue(target, name, value);
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
__name(appendFormFields, "appendFormFields");
|
|
281
309
|
function prepareRequestBody(requestBody, body, bodyData, headers) {
|
|
282
310
|
const finalData = body !== void 0 ? body : Object.keys(bodyData).length > 0 ? bodyData : void 0;
|
|
283
311
|
if (requestBody && "content" in requestBody) {
|
|
@@ -288,13 +316,16 @@ function prepareRequestBody(requestBody, body, bodyData, headers) {
|
|
|
288
316
|
headers["Content-Type"] = mimeType;
|
|
289
317
|
return typeof finalData === "string" ? finalData : JSON.stringify(finalData);
|
|
290
318
|
} else if (mimeType === "application/x-www-form-urlencoded") {
|
|
319
|
+
if (isFormFields(finalData)) {
|
|
320
|
+
const formParams = new URLSearchParams();
|
|
321
|
+
appendFormFields(formParams, finalData);
|
|
322
|
+
return formParams;
|
|
323
|
+
}
|
|
291
324
|
return new URLSearchParams(finalData);
|
|
292
325
|
} else if (mimeType === "multipart/form-data") {
|
|
293
326
|
const formData = new FormData();
|
|
294
327
|
if (typeof finalData === "object" && finalData !== null) {
|
|
295
|
-
|
|
296
|
-
formData.append(key, String(value));
|
|
297
|
-
}
|
|
328
|
+
appendFormFields(formData, finalData);
|
|
298
329
|
}
|
|
299
330
|
return formData;
|
|
300
331
|
} else if (mimeType === "application/octet-stream") {
|
|
@@ -48,6 +48,7 @@ __export(load_skill_resource_tool_exports, {
|
|
|
48
48
|
module.exports = __toCommonJS(load_skill_resource_tool_exports);
|
|
49
49
|
var import_genai = require("@google/genai");
|
|
50
50
|
var import_node_path = __toESM(require("node:path"), 1);
|
|
51
|
+
var import_instrumentation = require("../../telemetry/api/instrumentation.js");
|
|
51
52
|
var import_experimental = require("../../utils/experimental.js");
|
|
52
53
|
var import_file_utils = require("../../utils/file_utils.js");
|
|
53
54
|
var import_base_tool = require("../base_tool.js");
|
|
@@ -105,6 +106,11 @@ let LoadSkillResourceTool = class extends import_base_tool.BaseTool {
|
|
|
105
106
|
};
|
|
106
107
|
}
|
|
107
108
|
resourcePath = import_node_path.default.posix.normalize(resourcePath);
|
|
109
|
+
const skillActivity = (0, import_instrumentation.recordSkillActivity)({
|
|
110
|
+
kind: "resource",
|
|
111
|
+
skillName,
|
|
112
|
+
resourcePath
|
|
113
|
+
});
|
|
108
114
|
let skill;
|
|
109
115
|
try {
|
|
110
116
|
skill = await this.toolset.getOrFetchSkill(
|
|
@@ -123,6 +129,7 @@ let LoadSkillResourceTool = class extends import_base_tool.BaseTool {
|
|
|
123
129
|
error_code: "SKILL_NOT_FOUND"
|
|
124
130
|
};
|
|
125
131
|
}
|
|
132
|
+
skillActivity.recordSkill(skill);
|
|
126
133
|
let content;
|
|
127
134
|
const skillResources = skill.resources || {};
|
|
128
135
|
if (resourcePath.startsWith("references/")) {
|
|
@@ -38,6 +38,7 @@ __export(load_skill_tool_exports, {
|
|
|
38
38
|
module.exports = __toCommonJS(load_skill_tool_exports);
|
|
39
39
|
var import_genai = require("@google/genai");
|
|
40
40
|
var import_invocation_context = require("../../agents/invocation_context.js");
|
|
41
|
+
var import_instrumentation = require("../../telemetry/api/instrumentation.js");
|
|
41
42
|
var import_experimental = require("../../utils/experimental.js");
|
|
42
43
|
var import_base_tool = require("../base_tool.js");
|
|
43
44
|
/**
|
|
@@ -80,6 +81,7 @@ let LoadSkillTool = class extends import_base_tool.BaseTool {
|
|
|
80
81
|
error_code: "MISSING_SKILL_NAME"
|
|
81
82
|
};
|
|
82
83
|
}
|
|
84
|
+
const skillActivity = (0, import_instrumentation.recordSkillActivity)({ kind: "load", skillName });
|
|
83
85
|
let skill;
|
|
84
86
|
try {
|
|
85
87
|
skill = await this.toolset.getOrFetchSkill(
|
|
@@ -98,6 +100,7 @@ let LoadSkillTool = class extends import_base_tool.BaseTool {
|
|
|
98
100
|
error_code: "SKILL_NOT_FOUND"
|
|
99
101
|
};
|
|
100
102
|
}
|
|
103
|
+
skillActivity.recordSkill(skill);
|
|
101
104
|
const agentName = (0, import_invocation_context.requireAgent)(toolContext.invocationContext).name;
|
|
102
105
|
const stateKey = `_adk_activated_skill_${agentName}`;
|
|
103
106
|
const currentActivated = toolContext.state.get(stateKey) || [];
|
|
@@ -51,6 +51,7 @@ var import_genai = require("@google/genai");
|
|
|
51
51
|
var path = __toESM(require("node:path"), 1);
|
|
52
52
|
var import_llm_agent = require("../../agents/llm_agent.js");
|
|
53
53
|
var import_code_execution_utils = require("../../code_executors/code_execution_utils.js");
|
|
54
|
+
var import_instrumentation = require("../../telemetry/api/instrumentation.js");
|
|
54
55
|
var import_experimental = require("../../utils/experimental.js");
|
|
55
56
|
var import_file_extension_utils = require("../../utils/file_extension_utils.js");
|
|
56
57
|
var import_file_utils = require("../../utils/file_utils.js");
|
|
@@ -112,6 +113,11 @@ let RunSkillScriptTool = class extends import_base_tool.BaseTool {
|
|
|
112
113
|
errorCode: "MISSING_SCRIPT_PATH"
|
|
113
114
|
};
|
|
114
115
|
}
|
|
116
|
+
const skillActivity = (0, import_instrumentation.recordSkillActivity)({
|
|
117
|
+
kind: "script",
|
|
118
|
+
skillName,
|
|
119
|
+
scriptPath
|
|
120
|
+
});
|
|
115
121
|
let skill;
|
|
116
122
|
try {
|
|
117
123
|
skill = await this.toolset.getOrFetchSkill(
|
|
@@ -130,9 +136,11 @@ let RunSkillScriptTool = class extends import_base_tool.BaseTool {
|
|
|
130
136
|
errorCode: "SKILL_NOT_FOUND"
|
|
131
137
|
};
|
|
132
138
|
}
|
|
133
|
-
|
|
139
|
+
skillActivity.recordSkill(skill);
|
|
140
|
+
let relScriptPath = scriptPath.startsWith("scripts/") ? scriptPath.substring("scripts/".length) : scriptPath;
|
|
134
141
|
let script = (_b = (_a = skill.resources) == null ? void 0 : _a.scripts) == null ? void 0 : _b[relScriptPath];
|
|
135
142
|
if (!script) {
|
|
143
|
+
relScriptPath = scriptPath;
|
|
136
144
|
script = (_d = (_c = skill.resources) == null ? void 0 : _c.scripts) == null ? void 0 : _d[scriptPath];
|
|
137
145
|
}
|
|
138
146
|
if (!script) {
|
|
@@ -159,7 +167,9 @@ let RunSkillScriptTool = class extends import_base_tool.BaseTool {
|
|
|
159
167
|
const result = await codeExecutor.executeCode({
|
|
160
168
|
invocationContext: toolContext.invocationContext,
|
|
161
169
|
codeExecutionInput: {
|
|
162
|
-
|
|
170
|
+
// Scripts are always written under scripts/ (see
|
|
171
|
+
// getSkillResourceFiles), with or without the prefix in script_path.
|
|
172
|
+
code: buildWrapperCode(`scripts/${relScriptPath}`, language),
|
|
163
173
|
inputFiles: getSkillResourceFiles(skill),
|
|
164
174
|
language,
|
|
165
175
|
args: scriptArgs
|