@google/adk 2.3.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/a2a_remote_agent.js +17 -2
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/cjs/a2a/agent_card.js +5 -81
- package/dist/cjs/a2a/agent_to_a2a.js +7 -0
- package/dist/cjs/a2a/event_converter_utils.js +10 -3
- package/dist/cjs/agents/agent_engine_client.js +399 -0
- package/dist/cjs/agents/base_agent.js +127 -68
- package/dist/cjs/agents/functions.js +64 -59
- package/dist/cjs/agents/instructions.js +8 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +124 -101
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/cjs/agents/processors/content_processor_utils.js +72 -17
- package/dist/cjs/agents/processors/content_request_processor.js +51 -2
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +13 -3
- package/dist/cjs/artifacts/file_artifact_service.js +1 -1
- package/dist/cjs/cli/cli_eval.js +884 -17
- package/dist/cjs/cli/utils/cleanup.js +84 -0
- package/dist/cjs/cli/utils/envs.js +33 -2
- package/dist/cjs/cli/utils/evals.js +75 -8
- package/dist/cjs/cli/utils/logs.js +134 -15
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +171 -38
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +59 -32
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +34 -12
- package/dist/cjs/models/google_llm.js +33 -2
- package/dist/cjs/models/interactions_utils.js +3 -0
- package/dist/cjs/plugins/base_plugin.js +54 -40
- package/dist/cjs/plugins/plugin_manager.js +27 -0
- package/dist/cjs/runner/runner.js +306 -189
- package/dist/cjs/sessions/base_session_service.js +15 -12
- package/dist/cjs/sessions/database_session_service.js +232 -38
- package/dist/cjs/sessions/db/operations.js +70 -1
- package/dist/cjs/sessions/db/schema.js +4 -0
- package/dist/cjs/sessions/in_memory_session_service.js +2 -2
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/sessions/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +76 -41
- package/dist/cjs/telemetry/api/instrumentation.js +632 -0
- package/dist/cjs/telemetry/api/internal/common/accumulators.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/attributes.js +131 -0
- package/dist/cjs/telemetry/api/internal/common/config.js +159 -0
- package/dist/cjs/telemetry/api/internal/common/error.js +98 -0
- package/dist/cjs/telemetry/api/internal/common/finish_reason.js +63 -0
- package/dist/cjs/telemetry/api/internal/common/genai_messages.js +217 -0
- package/dist/cjs/telemetry/api/internal/common/http_exchange.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/provider_name.js +87 -0
- package/dist/cjs/telemetry/api/internal/common/redaction.js +148 -0
- package/dist/cjs/telemetry/api/internal/common/serialization.js +58 -0
- package/dist/cjs/telemetry/api/internal/common/token_usage.js +118 -0
- package/dist/cjs/telemetry/api/internal/logs/inference.js +50 -0
- package/dist/cjs/telemetry/api/internal/logs/logger.js +46 -0
- package/dist/cjs/telemetry/api/internal/logs/mcp.js +141 -0
- package/dist/cjs/telemetry/api/internal/metrics/agent.js +128 -0
- package/dist/cjs/telemetry/api/internal/metrics/inference_start_hook.js +56 -0
- package/dist/cjs/telemetry/api/internal/metrics/meters.js +189 -0
- package/dist/cjs/telemetry/api/internal/metrics/tool.js +147 -0
- package/dist/cjs/telemetry/api/internal/metrics/workflow.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/agent.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/compaction.js +78 -0
- package/dist/cjs/telemetry/api/internal/trace/inference.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/live.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/node.js +73 -0
- package/dist/cjs/telemetry/api/internal/trace/propagation.js +67 -0
- package/dist/cjs/telemetry/api/internal/trace/tool.js +122 -0
- package/dist/cjs/telemetry/api/internal/trace/tracer.js +77 -0
- package/dist/cjs/telemetry/api/internal/trace/workflow.js +77 -0
- package/dist/cjs/telemetry/export/agent_engine.js +90 -0
- package/dist/cjs/telemetry/export/agent_runtime.js +73 -0
- package/dist/cjs/telemetry/export/google_cloud.js +763 -0
- package/dist/cjs/telemetry/export/request_driven_metric_reader.js +303 -0
- package/dist/cjs/telemetry/{setup.js → export/setup.js} +72 -6
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +18 -23
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +109 -43
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +222 -114
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +175 -0
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/computer_use/base_computer.js +125 -0
- package/dist/cjs/tools/computer_use/computer_use_actions.js +502 -0
- package/dist/cjs/tools/computer_use/computer_use_tool.js +244 -0
- package/dist/cjs/tools/computer_use/computer_use_toolset.js +360 -0
- package/dist/cjs/tools/function_tool.js +15 -5
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +174 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +5 -3
- package/dist/cjs/tools/google_api_tool/index.js +20 -23
- package/dist/cjs/tools/load_artifacts_tool.js +27 -11
- package/dist/cjs/tools/load_memory_tool.js +14 -15
- package/dist/cjs/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/cjs/tools/mcp/mcp_tool.js +7 -3
- package/dist/cjs/tools/mcp/mcp_toolset.js +19 -20
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/cjs/tools/skill/load_skill_tool.js +3 -0
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/cjs/tools/toolbox_toolset.js +193 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +17 -2
- package/dist/cjs/utils/env_aware_utils.js +13 -7
- package/dist/cjs/utils/error_utils.js +40 -2
- package/dist/cjs/utils/failover_utils.js +11 -10
- package/dist/cjs/utils/gemini_schema_util.js +145 -14
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/logger_node.js +4 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/index.js +2 -0
- package/dist/cjs/workflow/node_runner.js +24 -80
- package/dist/cjs/workflow/nodes/parallel_worker.js +18 -7
- package/dist/cjs/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/cjs/workflow/utils/retry_utils.js +2 -2
- package/dist/cjs/workflow/workflow.js +12 -12
- package/dist/esm/a2a/a2a_remote_agent.js +23 -3
- package/dist/esm/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/esm/a2a/agent_card.js +5 -83
- package/dist/esm/a2a/agent_to_a2a.js +7 -0
- package/dist/esm/a2a/event_converter_utils.js +10 -3
- package/dist/esm/agents/agent_engine_client.js +382 -0
- package/dist/esm/agents/base_agent.js +127 -72
- package/dist/esm/agents/functions.js +69 -63
- package/dist/esm/agents/instructions.js +8 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +130 -106
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/esm/agents/processors/content_processor_utils.js +72 -17
- package/dist/esm/agents/processors/content_request_processor.js +51 -2
- package/dist/esm/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +13 -3
- package/dist/esm/artifacts/file_artifact_service.js +1 -1
- package/dist/esm/cli/cli_eval.js +880 -17
- package/dist/esm/cli/utils/cleanup.js +56 -0
- package/dist/esm/cli/utils/envs.js +33 -2
- package/dist/esm/cli/utils/evals.js +74 -8
- package/dist/esm/cli/utils/logs.js +132 -13
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +171 -38
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +59 -19
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +36 -10
- package/dist/esm/models/google_llm.js +33 -2
- package/dist/esm/models/interactions_utils.js +3 -0
- package/dist/esm/plugins/base_plugin.js +54 -40
- package/dist/esm/plugins/plugin_manager.js +27 -0
- package/dist/esm/runner/runner.js +310 -192
- package/dist/esm/sessions/base_session_service.js +13 -11
- package/dist/esm/sessions/database_session_service.js +231 -38
- package/dist/esm/sessions/db/operations.js +70 -1
- package/dist/esm/sessions/db/schema.js +4 -0
- package/dist/esm/sessions/in_memory_session_service.js +2 -2
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/sessions/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +76 -41
- package/dist/esm/telemetry/api/instrumentation.js +655 -0
- package/dist/esm/telemetry/api/internal/common/accumulators.js +139 -0
- package/dist/esm/telemetry/api/internal/common/attributes.js +94 -0
- package/dist/esm/telemetry/api/internal/common/config.js +128 -0
- package/dist/esm/telemetry/api/internal/common/error.js +69 -0
- package/dist/esm/telemetry/api/internal/common/finish_reason.js +35 -0
- package/dist/esm/telemetry/api/internal/common/genai_messages.js +188 -0
- package/dist/esm/telemetry/api/internal/common/http_exchange.js +142 -0
- package/dist/esm/telemetry/api/internal/common/provider_name.js +59 -0
- package/dist/esm/telemetry/api/internal/common/redaction.js +121 -0
- package/dist/esm/telemetry/api/internal/common/serialization.js +30 -0
- package/dist/esm/telemetry/api/internal/common/token_usage.js +85 -0
- package/dist/esm/telemetry/api/internal/logs/inference.js +23 -0
- package/dist/esm/telemetry/api/internal/logs/logger.js +19 -0
- package/dist/esm/telemetry/api/internal/logs/mcp.js +113 -0
- package/dist/esm/telemetry/api/internal/metrics/agent.js +107 -0
- package/dist/esm/telemetry/api/internal/metrics/inference_start_hook.js +29 -0
- package/dist/esm/telemetry/api/internal/metrics/meters.js +165 -0
- package/dist/esm/telemetry/api/internal/metrics/tool.js +119 -0
- package/dist/esm/telemetry/api/internal/metrics/workflow.js +112 -0
- package/dist/esm/telemetry/api/internal/trace/agent.js +25 -0
- package/dist/esm/telemetry/api/internal/trace/compaction.js +50 -0
- package/dist/esm/telemetry/api/internal/trace/inference.js +107 -0
- package/dist/esm/telemetry/api/internal/trace/live.js +28 -0
- package/dist/esm/telemetry/api/internal/trace/node.js +44 -0
- package/dist/esm/telemetry/api/internal/trace/propagation.js +39 -0
- package/dist/esm/telemetry/api/internal/trace/tool.js +96 -0
- package/dist/esm/telemetry/api/internal/trace/tracer.js +52 -0
- package/dist/esm/telemetry/api/internal/trace/workflow.js +54 -0
- package/dist/esm/telemetry/export/agent_engine.js +67 -0
- package/dist/esm/telemetry/export/agent_runtime.js +46 -0
- package/dist/esm/telemetry/export/google_cloud.js +733 -0
- package/dist/esm/telemetry/export/request_driven_metric_reader.js +276 -0
- package/dist/esm/telemetry/export/setup.js +160 -0
- package/dist/esm/tools/agent_tool.js +9 -1
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +17 -22
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +114 -44
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +226 -115
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +34 -14
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +149 -0
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/computer_use/base_computer.js +99 -0
- package/dist/esm/tools/computer_use/computer_use_actions.js +477 -0
- package/dist/esm/tools/computer_use/computer_use_tool.js +217 -0
- package/dist/esm/tools/computer_use/computer_use_toolset.js +344 -0
- package/dist/esm/tools/function_tool.js +15 -5
- package/dist/esm/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +147 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +5 -3
- package/dist/esm/tools/google_api_tool/index.js +18 -20
- package/dist/esm/tools/load_artifacts_tool.js +25 -10
- package/dist/esm/tools/load_memory_tool.js +14 -15
- package/dist/esm/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/esm/tools/mcp/mcp_tool.js +7 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +19 -20
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -4
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +57 -10
- package/dist/esm/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/esm/tools/skill/load_skill_tool.js +3 -0
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/esm/tools/toolbox_toolset.js +167 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +17 -2
- package/dist/esm/utils/env_aware_utils.js +12 -7
- package/dist/esm/utils/error_utils.js +37 -1
- package/dist/esm/utils/failover_utils.js +11 -10
- package/dist/esm/utils/gemini_schema_util.js +144 -14
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/logger_node.js +4 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/esm/workflow/index.js +2 -1
- package/dist/esm/workflow/node_runner.js +26 -80
- package/dist/esm/workflow/nodes/parallel_worker.js +16 -6
- package/dist/esm/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/esm/workflow/utils/retry_utils.js +2 -2
- package/dist/esm/workflow/workflow.js +12 -12
- package/dist/types/a2a/a2a_remote_agent.d.ts +6 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +3 -2
- package/dist/types/agents/agent_engine_client.d.ts +155 -0
- package/dist/types/agents/base_agent.d.ts +14 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +12 -10
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/agents/run_config.d.ts +14 -0
- package/dist/types/cli/cli_eval.d.ts +172 -9
- package/dist/types/cli/utils/cleanup.d.ts +18 -0
- package/dist/types/cli/utils/envs.d.ts +13 -3
- package/dist/types/cli/utils/evals.d.ts +64 -1
- package/dist/types/cli/utils/logs.d.ts +20 -3
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +62 -9
- package/dist/types/common.d.ts +21 -18
- package/dist/types/context/compaction_utils.d.ts +13 -1
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/events/event.d.ts +3 -0
- package/dist/types/features/feature_registry.d.ts +1 -0
- package/dist/types/index.d.ts +11 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -31
- package/dist/types/plugins/plugin_manager.d.ts +13 -0
- package/dist/types/runner/runner.d.ts +11 -0
- package/dist/types/sessions/base_session_service.d.ts +5 -2
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/telemetry/api/instrumentation.d.ts +259 -0
- package/dist/types/telemetry/api/internal/common/accumulators.d.ts +91 -0
- package/dist/types/telemetry/api/internal/common/attributes.d.ts +90 -0
- package/dist/types/telemetry/api/internal/common/config.d.ts +61 -0
- package/dist/types/telemetry/api/internal/common/error.d.ts +29 -0
- package/dist/types/telemetry/api/internal/common/finish_reason.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/genai_messages.d.ts +26 -0
- package/dist/types/telemetry/api/internal/common/http_exchange.d.ts +50 -0
- package/dist/types/telemetry/api/internal/common/provider_name.d.ts +16 -0
- package/dist/types/telemetry/api/internal/common/redaction.d.ts +14 -0
- package/dist/types/telemetry/api/internal/common/serialization.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/token_usage.d.ts +47 -0
- package/dist/types/telemetry/api/internal/logs/inference.d.ts +15 -0
- package/dist/types/telemetry/api/internal/logs/logger.d.ts +13 -0
- package/dist/types/telemetry/api/internal/logs/mcp.d.ts +31 -0
- package/dist/types/telemetry/api/internal/metrics/agent.d.ts +28 -0
- package/dist/types/telemetry/api/internal/metrics/inference_start_hook.d.ts +12 -0
- package/dist/types/telemetry/api/internal/metrics/meters.d.ts +57 -0
- package/dist/types/telemetry/api/internal/metrics/tool.d.ts +44 -0
- package/dist/types/telemetry/api/internal/metrics/workflow.d.ts +32 -0
- package/dist/types/telemetry/api/internal/trace/agent.d.ts +14 -0
- package/dist/types/telemetry/api/internal/trace/compaction.d.ts +20 -0
- package/dist/types/telemetry/api/internal/trace/inference.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/live.d.ts +21 -0
- package/dist/types/telemetry/api/internal/trace/node.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/propagation.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/tool.d.ts +57 -0
- package/dist/types/telemetry/api/internal/trace/tracer.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/workflow.d.ts +21 -0
- package/dist/types/telemetry/export/agent_engine.d.ts +23 -0
- package/dist/types/telemetry/export/agent_runtime.d.ts +40 -0
- package/dist/types/telemetry/export/google_cloud.d.ts +189 -0
- package/dist/types/telemetry/export/request_driven_metric_reader.d.ts +144 -0
- package/dist/types/telemetry/{setup.d.ts → export/setup.d.ts} +3 -0
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +14 -21
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +32 -9
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +35 -12
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +3 -3
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +7 -6
- package/dist/types/tools/computer_use/base_computer.d.ts +281 -0
- package/dist/types/tools/computer_use/computer_use_actions.d.ts +53 -0
- package/dist/types/tools/computer_use/computer_use_tool.d.ts +108 -0
- package/dist/types/tools/computer_use/computer_use_toolset.d.ts +132 -0
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +10 -3
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +57 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +5 -4
- package/dist/types/tools/google_api_tool/index.d.ts +4 -5
- package/dist/types/tools/load_artifacts_tool.d.ts +18 -1
- package/dist/types/tools/load_memory_tool.d.ts +32 -4
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +16 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +8 -8
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +15 -3
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/toolbox_toolset.d.ts +154 -0
- package/dist/types/utils/async_queue.d.ts +14 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/env_aware_utils.d.ts +11 -0
- package/dist/types/utils/error_utils.d.ts +4 -0
- package/dist/types/utils/gemini_schema_util.d.ts +29 -0
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- package/dist/types/utils/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/utils/ssrf_guard.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/workflow/index.d.ts +1 -1
- package/dist/types/workflow/nodes/parallel_worker.d.ts +8 -1
- package/dist/web/index_web.js +94 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +43 -38
- package/dist/cjs/agents/remote_agent.js +0 -187
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -350
- package/dist/cjs/tools/crewai_tool.js +0 -132
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +0 -226
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +0 -58
- package/dist/cjs/tools/langchain_tool.js +0 -172
- package/dist/cjs/tools/toolbox_tool.js +0 -108
- package/dist/esm/agents/remote_agent.js +0 -164
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -89
- package/dist/esm/telemetry/tracing.js +0 -315
- package/dist/esm/tools/crewai_tool.js +0 -107
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +0 -188
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +0 -24
- package/dist/esm/tools/langchain_tool.js +0 -148
- package/dist/esm/tools/toolbox_tool.js +0 -80
- package/dist/types/agents/remote_agent.d.ts +0 -68
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -129
- package/dist/types/tools/crewai_tool.d.ts +0 -85
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +0 -78
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +0 -33
- package/dist/types/tools/langchain_tool.d.ts +0 -103
- package/dist/types/tools/toolbox_tool.d.ts +0 -73
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { resolveErrorType } from "./error.js";
|
|
11
|
+
const MAX_BODY_LENGTH = 1e3;
|
|
12
|
+
const TRUNCATED_SUFFIX = "... [truncated]";
|
|
13
|
+
const SSE_BODY = "<SSE stream>";
|
|
14
|
+
const REDACTED_HEADER_VALUE = "<redacted>";
|
|
15
|
+
const REDACTED_QUERY_VALUE = "REDACTED";
|
|
16
|
+
const CREDENTIAL_HEADERS = /* @__PURE__ */ new Set([
|
|
17
|
+
"api-key",
|
|
18
|
+
"authorization",
|
|
19
|
+
"cookie",
|
|
20
|
+
"proxy-authorization",
|
|
21
|
+
"set-cookie",
|
|
22
|
+
"x-api-key",
|
|
23
|
+
"x-goog-api-key"
|
|
24
|
+
]);
|
|
25
|
+
function captureHttpExchange({
|
|
26
|
+
url,
|
|
27
|
+
init,
|
|
28
|
+
response,
|
|
29
|
+
captureBodies
|
|
30
|
+
}) {
|
|
31
|
+
var _a, _b;
|
|
32
|
+
const requestUrl = new URL(url);
|
|
33
|
+
const isEventStream = ((_a = response.headers.get("content-type")) != null ? _a : "").toLowerCase().includes("text/event-stream");
|
|
34
|
+
const responseCopy = captureBodies && !isEventStream ? response.clone() : void 0;
|
|
35
|
+
const requestBody = captureBodies ? readRequestBody(init == null ? void 0 : init.body) : void 0;
|
|
36
|
+
const exchange = {
|
|
37
|
+
method: ((_b = init == null ? void 0 : init.method) != null ? _b : "GET").toUpperCase(),
|
|
38
|
+
url: sanitizeUrl(requestUrl),
|
|
39
|
+
serverAddress: requestUrl.hostname.replace(/^\[(.*)\]$/, "$1"),
|
|
40
|
+
...requestUrl.port ? { serverPort: Number(requestUrl.port) } : {},
|
|
41
|
+
querySessionId: firstNonEmpty(
|
|
42
|
+
requestUrl.searchParams.getAll("sessionId"),
|
|
43
|
+
requestUrl.searchParams.getAll("session_id")
|
|
44
|
+
),
|
|
45
|
+
statusCode: response.status,
|
|
46
|
+
requestHeaders: redactHeaders(new Headers(init == null ? void 0 : init.headers)),
|
|
47
|
+
responseHeaders: redactHeaders(response.headers),
|
|
48
|
+
...requestBody === void 0 ? {} : { requestBody }
|
|
49
|
+
};
|
|
50
|
+
return withResponseBody(exchange, {
|
|
51
|
+
captureBodies,
|
|
52
|
+
isEventStream,
|
|
53
|
+
responseCopy
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
__name(captureHttpExchange, "captureHttpExchange");
|
|
57
|
+
async function withResponseBody(exchange, {
|
|
58
|
+
captureBodies,
|
|
59
|
+
isEventStream,
|
|
60
|
+
responseCopy
|
|
61
|
+
}) {
|
|
62
|
+
if (isEventStream) {
|
|
63
|
+
return { ...exchange, responseBody: SSE_BODY };
|
|
64
|
+
}
|
|
65
|
+
if (!captureBodies || responseCopy === void 0) {
|
|
66
|
+
return exchange;
|
|
67
|
+
}
|
|
68
|
+
try {
|
|
69
|
+
return { ...exchange, responseBody: truncate(await responseCopy.text()) };
|
|
70
|
+
} catch (error) {
|
|
71
|
+
return {
|
|
72
|
+
...exchange,
|
|
73
|
+
responseBody: `<failed to read body: ${resolveErrorType(error)}>`
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
__name(withResponseBody, "withResponseBody");
|
|
78
|
+
function readRequestBody(body) {
|
|
79
|
+
if (typeof body === "string") {
|
|
80
|
+
return truncate(body);
|
|
81
|
+
}
|
|
82
|
+
if (body instanceof URLSearchParams) {
|
|
83
|
+
return truncate(body.toString());
|
|
84
|
+
}
|
|
85
|
+
if (body instanceof ArrayBuffer || ArrayBuffer.isView(body)) {
|
|
86
|
+
return truncate(new TextDecoder().decode(body));
|
|
87
|
+
}
|
|
88
|
+
return void 0;
|
|
89
|
+
}
|
|
90
|
+
__name(readRequestBody, "readRequestBody");
|
|
91
|
+
function truncate(text) {
|
|
92
|
+
if (text.length <= MAX_BODY_LENGTH) {
|
|
93
|
+
return text;
|
|
94
|
+
}
|
|
95
|
+
let end = 0;
|
|
96
|
+
let count = 0;
|
|
97
|
+
for (const character of text) {
|
|
98
|
+
if (count === MAX_BODY_LENGTH) {
|
|
99
|
+
return text.slice(0, end) + TRUNCATED_SUFFIX;
|
|
100
|
+
}
|
|
101
|
+
end += character.length;
|
|
102
|
+
count++;
|
|
103
|
+
}
|
|
104
|
+
return text;
|
|
105
|
+
}
|
|
106
|
+
__name(truncate, "truncate");
|
|
107
|
+
function sanitizeUrl(url) {
|
|
108
|
+
const sanitized = new URL(url);
|
|
109
|
+
sanitized.username = "";
|
|
110
|
+
sanitized.password = "";
|
|
111
|
+
if (sanitized.search) {
|
|
112
|
+
const keys = /* @__PURE__ */ new Set();
|
|
113
|
+
for (const [key, value] of sanitized.searchParams) {
|
|
114
|
+
if (value) {
|
|
115
|
+
keys.add(key);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
sanitized.search = new URLSearchParams(
|
|
119
|
+
Array.from(keys, (key) => [key, REDACTED_QUERY_VALUE])
|
|
120
|
+
).toString();
|
|
121
|
+
}
|
|
122
|
+
return sanitized.href;
|
|
123
|
+
}
|
|
124
|
+
__name(sanitizeUrl, "sanitizeUrl");
|
|
125
|
+
function redactHeaders(headers) {
|
|
126
|
+
const redacted = /* @__PURE__ */ new Map();
|
|
127
|
+
headers.forEach((value, name) => {
|
|
128
|
+
redacted.set(
|
|
129
|
+
name,
|
|
130
|
+
CREDENTIAL_HEADERS.has(name) ? REDACTED_HEADER_VALUE : value
|
|
131
|
+
);
|
|
132
|
+
});
|
|
133
|
+
return redacted;
|
|
134
|
+
}
|
|
135
|
+
__name(redactHeaders, "redactHeaders");
|
|
136
|
+
function firstNonEmpty(...candidates) {
|
|
137
|
+
return candidates.flat().find((value) => value !== "");
|
|
138
|
+
}
|
|
139
|
+
__name(firstNonEmpty, "firstNonEmpty");
|
|
140
|
+
export {
|
|
141
|
+
captureHttpExchange
|
|
142
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { isEnterpriseModeEnabled } from "../../../../utils/env_aware_utils.js";
|
|
11
|
+
import { extractModelName, isGeminiModel } from "../../../../utils/model_name.js";
|
|
12
|
+
const ANTHROPIC_MODEL_PATTERN = /^claude[-.]/i;
|
|
13
|
+
const RESOURCE_COLLECTION_SEGMENTS = /* @__PURE__ */ new Set([
|
|
14
|
+
"endpoints",
|
|
15
|
+
"locations",
|
|
16
|
+
"models",
|
|
17
|
+
"projects",
|
|
18
|
+
"publishers",
|
|
19
|
+
"tunedmodels"
|
|
20
|
+
]);
|
|
21
|
+
const PROVIDER_NAME_BY_SYSTEM_NAME = {
|
|
22
|
+
gemini: "gcp.gemini",
|
|
23
|
+
vertex_ai: "gcp.vertex_ai"
|
|
24
|
+
};
|
|
25
|
+
function guessGeminiSystemName() {
|
|
26
|
+
return isEnterpriseModeEnabled() ? "vertex_ai" : "gemini";
|
|
27
|
+
}
|
|
28
|
+
__name(guessGeminiSystemName, "guessGeminiSystemName");
|
|
29
|
+
function systemNameFromModel(model) {
|
|
30
|
+
if (!model) {
|
|
31
|
+
return void 0;
|
|
32
|
+
}
|
|
33
|
+
if (isGeminiModel(model)) {
|
|
34
|
+
return guessGeminiSystemName();
|
|
35
|
+
}
|
|
36
|
+
const modelName = extractModelName(model);
|
|
37
|
+
if (ANTHROPIC_MODEL_PATTERN.test(modelName)) {
|
|
38
|
+
return "anthropic";
|
|
39
|
+
}
|
|
40
|
+
const separator = modelName.indexOf("/");
|
|
41
|
+
if (separator > 0) {
|
|
42
|
+
const provider = modelName.slice(0, separator).toLowerCase();
|
|
43
|
+
if (!RESOURCE_COLLECTION_SEGMENTS.has(provider)) {
|
|
44
|
+
return provider;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return void 0;
|
|
48
|
+
}
|
|
49
|
+
__name(systemNameFromModel, "systemNameFromModel");
|
|
50
|
+
function resolveProviderName(model) {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
const systemName = (_a = systemNameFromModel(model)) != null ? _a : guessGeminiSystemName();
|
|
53
|
+
return (_b = PROVIDER_NAME_BY_SYSTEM_NAME[systemName]) != null ? _b : systemName;
|
|
54
|
+
}
|
|
55
|
+
__name(resolveProviderName, "resolveProviderName");
|
|
56
|
+
export {
|
|
57
|
+
guessGeminiSystemName,
|
|
58
|
+
resolveProviderName
|
|
59
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { REQUEST_CREDENTIAL_FUNCTION_CALL_NAME } from "../../../../agents/framework_function_calls.js";
|
|
11
|
+
import { AuthCredentialTypes } from "../../../../auth/auth_credential.js";
|
|
12
|
+
const CREDENTIAL_SECRET_KEYS = /* @__PURE__ */ new Set([
|
|
13
|
+
"password",
|
|
14
|
+
"token",
|
|
15
|
+
"additionalHeaders",
|
|
16
|
+
"additional_headers",
|
|
17
|
+
"clientSecret",
|
|
18
|
+
"client_secret",
|
|
19
|
+
"authResponseUri",
|
|
20
|
+
"auth_response_uri",
|
|
21
|
+
"authCode",
|
|
22
|
+
"auth_code",
|
|
23
|
+
"accessToken",
|
|
24
|
+
"access_token",
|
|
25
|
+
"refreshToken",
|
|
26
|
+
"refresh_token",
|
|
27
|
+
"idToken",
|
|
28
|
+
"id_token",
|
|
29
|
+
"codeVerifier",
|
|
30
|
+
"code_verifier",
|
|
31
|
+
"privateKeyId",
|
|
32
|
+
"private_key_id",
|
|
33
|
+
"privateKey",
|
|
34
|
+
"private_key",
|
|
35
|
+
"apiKey",
|
|
36
|
+
"api_key"
|
|
37
|
+
]);
|
|
38
|
+
const CREDENTIAL_CARRIER_KEYS = /* @__PURE__ */ new Set([
|
|
39
|
+
"requestedAuthConfigs",
|
|
40
|
+
"requested_auth_configs",
|
|
41
|
+
"rawAuthCredential",
|
|
42
|
+
"raw_auth_credential",
|
|
43
|
+
"exchangedAuthCredential",
|
|
44
|
+
"exchanged_auth_credential"
|
|
45
|
+
]);
|
|
46
|
+
const AUTH_TYPE_VALUES = new Set(
|
|
47
|
+
Object.entries(AuthCredentialTypes).flatMap(([name, value]) => [
|
|
48
|
+
value,
|
|
49
|
+
name,
|
|
50
|
+
name.toLowerCase()
|
|
51
|
+
])
|
|
52
|
+
);
|
|
53
|
+
function isRecord(value) {
|
|
54
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
55
|
+
}
|
|
56
|
+
__name(isRecord, "isRecord");
|
|
57
|
+
function redactAuthConfigSecrets(value) {
|
|
58
|
+
if (Array.isArray(value)) {
|
|
59
|
+
return value.map(redactAuthConfigSecrets);
|
|
60
|
+
}
|
|
61
|
+
if (!isRecord(value)) {
|
|
62
|
+
return value;
|
|
63
|
+
}
|
|
64
|
+
return Object.fromEntries(
|
|
65
|
+
Object.entries(value).filter(([key]) => !CREDENTIAL_SECRET_KEYS.has(key)).map(([key, item]) => [key, redactAuthConfigSecrets(item)])
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
__name(redactAuthConfigSecrets, "redactAuthConfigSecrets");
|
|
69
|
+
function isAuthCredential(value) {
|
|
70
|
+
return ["authType", "auth_type"].some((key) => {
|
|
71
|
+
const authType = value[key];
|
|
72
|
+
return typeof authType === "string" && AUTH_TYPE_VALUES.has(authType);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
__name(isAuthCredential, "isAuthCredential");
|
|
76
|
+
function redactCredentialRequest(value) {
|
|
77
|
+
return Object.fromEntries(
|
|
78
|
+
Object.entries(value).map(([key, item]) => {
|
|
79
|
+
if (key === "args" && isRecord(item)) {
|
|
80
|
+
return [
|
|
81
|
+
key,
|
|
82
|
+
Object.fromEntries(
|
|
83
|
+
Object.entries(item).map(([argKey, arg]) => [
|
|
84
|
+
argKey,
|
|
85
|
+
argKey === "authConfig" || argKey === "auth_config" ? redactAuthConfigSecrets(arg) : arg
|
|
86
|
+
])
|
|
87
|
+
)
|
|
88
|
+
];
|
|
89
|
+
}
|
|
90
|
+
if (key === "response") {
|
|
91
|
+
return [key, redactAuthConfigSecrets(item)];
|
|
92
|
+
}
|
|
93
|
+
return [key, redactCredentialSecrets(item)];
|
|
94
|
+
})
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
__name(redactCredentialRequest, "redactCredentialRequest");
|
|
98
|
+
function redactCredentialSecrets(value) {
|
|
99
|
+
if (Array.isArray(value)) {
|
|
100
|
+
return value.map(redactCredentialSecrets);
|
|
101
|
+
}
|
|
102
|
+
if (!isRecord(value)) {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
if (isAuthCredential(value)) {
|
|
106
|
+
return redactAuthConfigSecrets(value);
|
|
107
|
+
}
|
|
108
|
+
if (value["name"] === REQUEST_CREDENTIAL_FUNCTION_CALL_NAME) {
|
|
109
|
+
return redactCredentialRequest(value);
|
|
110
|
+
}
|
|
111
|
+
return Object.fromEntries(
|
|
112
|
+
Object.entries(value).map(([key, item]) => [
|
|
113
|
+
key,
|
|
114
|
+
CREDENTIAL_CARRIER_KEYS.has(key) ? redactAuthConfigSecrets(item) : redactCredentialSecrets(item)
|
|
115
|
+
])
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
__name(redactCredentialSecrets, "redactCredentialSecrets");
|
|
119
|
+
export {
|
|
120
|
+
redactCredentialSecrets
|
|
121
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { getEnvVar } from "../../../../utils/env_aware_utils.js";
|
|
11
|
+
function safeJsonSerialize(obj) {
|
|
12
|
+
try {
|
|
13
|
+
return JSON.stringify(
|
|
14
|
+
obj,
|
|
15
|
+
(_key, value) => typeof value === "bigint" ? "<not serializable>" : value
|
|
16
|
+
);
|
|
17
|
+
} catch (_e) {
|
|
18
|
+
return "<not serializable>";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
__name(safeJsonSerialize, "safeJsonSerialize");
|
|
22
|
+
function shouldAddRequestResponseToSpans() {
|
|
23
|
+
const envValue = getEnvVar("ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS") || "true";
|
|
24
|
+
return envValue === "true" || envValue === "1";
|
|
25
|
+
}
|
|
26
|
+
__name(shouldAddRequestResponseToSpans, "shouldAddRequestResponseToSpans");
|
|
27
|
+
export {
|
|
28
|
+
safeJsonSerialize,
|
|
29
|
+
shouldAddRequestResponseToSpans
|
|
30
|
+
};
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { GenAiAttr } from "./attributes.js";
|
|
11
|
+
const INPUT_TOKENS_MEANING = "Input (prompt) tokens, summing the prompt itself and the results of server-side tool calls. Prompt tokens served from a cache are part of the prompt count, so they are included here too.";
|
|
12
|
+
const OUTPUT_TOKENS_MEANING = "Output (completion) tokens, summing candidate and reasoning tokens. The tokens a model spends emitting a tool call are candidate tokens, so they count here.";
|
|
13
|
+
const TOTAL_TOKENS_MEANING = "Input plus output tokens, derived from those two rather than taken from the model-reported total.";
|
|
14
|
+
const CACHE_READ_INPUT_TOKENS_MEANING = "Input tokens served from a provider-managed cache.";
|
|
15
|
+
const REASONING_OUTPUT_TOKENS_MEANING = "Output tokens spent on reasoning (chain-of-thought / extended thinking).";
|
|
16
|
+
const TOOL_INPUT_TOKENS_MEANING = "Input tokens from server-side tool results the model fed back to itself within one request, such as code execution or search grounding. Zero for client-side function tools, whose responses arrive as ordinary content on the next request and bill as plain prompt tokens.";
|
|
17
|
+
function sumOrUndefined(a, b) {
|
|
18
|
+
return a === void 0 && b === void 0 ? void 0 : (a != null ? a : 0) + (b != null ? b : 0);
|
|
19
|
+
}
|
|
20
|
+
__name(sumOrUndefined, "sumOrUndefined");
|
|
21
|
+
const _TokenUsage = class _TokenUsage {
|
|
22
|
+
constructor(usage) {
|
|
23
|
+
if (!usage) {
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
this.input = sumOrUndefined(
|
|
27
|
+
usage.promptTokenCount,
|
|
28
|
+
usage.toolUsePromptTokenCount
|
|
29
|
+
);
|
|
30
|
+
this.output = sumOrUndefined(
|
|
31
|
+
usage.candidatesTokenCount,
|
|
32
|
+
usage.thoughtsTokenCount
|
|
33
|
+
);
|
|
34
|
+
this.cacheRead = usage.cachedContentTokenCount;
|
|
35
|
+
this.reasoning = usage.thoughtsTokenCount;
|
|
36
|
+
this.toolInput = usage.toolUsePromptTokenCount;
|
|
37
|
+
}
|
|
38
|
+
/** Folds another call's usage into these totals, bucket by bucket. */
|
|
39
|
+
add(other) {
|
|
40
|
+
this.input = sumOrUndefined(this.input, other.input);
|
|
41
|
+
this.output = sumOrUndefined(this.output, other.output);
|
|
42
|
+
this.cacheRead = sumOrUndefined(this.cacheRead, other.cacheRead);
|
|
43
|
+
this.reasoning = sumOrUndefined(this.reasoning, other.reasoning);
|
|
44
|
+
this.toolInput = sumOrUndefined(this.toolInput, other.toolInput);
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Input plus output tokens, derived from those two rather than taken from
|
|
48
|
+
* the model-reported total.
|
|
49
|
+
*/
|
|
50
|
+
totalTokenUsage() {
|
|
51
|
+
var _a, _b;
|
|
52
|
+
return ((_a = this.input) != null ? _a : 0) + ((_b = this.output) != null ? _b : 0);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Returns the GenAI token usage attributes for the reported buckets,
|
|
56
|
+
* omitting `undefined` buckets and preserving `0`.
|
|
57
|
+
*/
|
|
58
|
+
asAttributes() {
|
|
59
|
+
const attributes = {};
|
|
60
|
+
if (this.input !== void 0) {
|
|
61
|
+
attributes[GenAiAttr.USAGE_INPUT_TOKENS] = this.input;
|
|
62
|
+
}
|
|
63
|
+
if (this.output !== void 0) {
|
|
64
|
+
attributes[GenAiAttr.USAGE_OUTPUT_TOKENS] = this.output;
|
|
65
|
+
}
|
|
66
|
+
if (this.cacheRead !== void 0) {
|
|
67
|
+
attributes[GenAiAttr.USAGE_CACHE_READ_INPUT_TOKENS] = this.cacheRead;
|
|
68
|
+
}
|
|
69
|
+
if (this.reasoning !== void 0) {
|
|
70
|
+
attributes[GenAiAttr.USAGE_REASONING_OUTPUT_TOKENS] = this.reasoning;
|
|
71
|
+
}
|
|
72
|
+
return attributes;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
__name(_TokenUsage, "TokenUsage");
|
|
76
|
+
let TokenUsage = _TokenUsage;
|
|
77
|
+
export {
|
|
78
|
+
CACHE_READ_INPUT_TOKENS_MEANING,
|
|
79
|
+
INPUT_TOKENS_MEANING,
|
|
80
|
+
OUTPUT_TOKENS_MEANING,
|
|
81
|
+
REASONING_OUTPUT_TOKENS_MEANING,
|
|
82
|
+
TOOL_INPUT_TOKENS_MEANING,
|
|
83
|
+
TOTAL_TOKENS_MEANING,
|
|
84
|
+
TokenUsage
|
|
85
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { context, trace } from "@opentelemetry/api";
|
|
11
|
+
import { getTelemetryLogger } from "./logger.js";
|
|
12
|
+
const INFERENCE_OPERATION_DETAILS_EVENT = "gen_ai.client.inference.operation.details";
|
|
13
|
+
function emitInferenceOperationDetails(span, attributes) {
|
|
14
|
+
getTelemetryLogger().emit({
|
|
15
|
+
eventName: INFERENCE_OPERATION_DETAILS_EVENT,
|
|
16
|
+
attributes,
|
|
17
|
+
context: trace.setSpan(context.active(), span)
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
__name(emitInferenceOperationDetails, "emitInferenceOperationDetails");
|
|
21
|
+
export {
|
|
22
|
+
emitInferenceOperationDetails
|
|
23
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { logs } from "@opentelemetry/api-logs";
|
|
11
|
+
import { version } from "../../../../version.js";
|
|
12
|
+
import { GEN_AI_SYSTEM_VALUE, SCHEMA_URL } from "../common/attributes.js";
|
|
13
|
+
function getTelemetryLogger() {
|
|
14
|
+
return logs.getLogger(GEN_AI_SYSTEM_VALUE, version, { schemaUrl: SCHEMA_URL });
|
|
15
|
+
}
|
|
16
|
+
__name(getTelemetryLogger, "getTelemetryLogger");
|
|
17
|
+
export {
|
|
18
|
+
getTelemetryLogger
|
|
19
|
+
};
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
+
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
/**
|
|
6
|
+
* @license
|
|
7
|
+
* Copyright 2026 Google LLC
|
|
8
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
*/
|
|
10
|
+
import { SeverityNumber } from "@opentelemetry/api-logs";
|
|
11
|
+
import { getEnvVar } from "../../../../utils/env_aware_utils.js";
|
|
12
|
+
import { logger } from "../../../../utils/logger.js";
|
|
13
|
+
import { ERROR_TYPE_ATTR, HttpAttr, McpAttr } from "../common/attributes.js";
|
|
14
|
+
import { isTruthyEnv } from "../common/config.js";
|
|
15
|
+
import { captureHttpExchange } from "../common/http_exchange.js";
|
|
16
|
+
import { getTelemetryLogger } from "./logger.js";
|
|
17
|
+
const MCP_HTTP_RESPONSE_END_EVENT = "adk.experimental.mcp.http.client.response.end";
|
|
18
|
+
const CAPTURE_BODIES_ENV = "ADK_CAPTURE_MCP_HTTP_BODIES";
|
|
19
|
+
const CAPTURE_REQUEST_HEADERS_ENV = "OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_REQUEST";
|
|
20
|
+
const CAPTURE_RESPONSE_HEADERS_ENV = "OTEL_INSTRUMENTATION_HTTP_CAPTURE_HEADERS_CLIENT_RESPONSE";
|
|
21
|
+
const ELIDED_BODY = "<elided>";
|
|
22
|
+
function readHeaderPatterns(envName) {
|
|
23
|
+
var _a;
|
|
24
|
+
const patterns = [];
|
|
25
|
+
for (const entry of ((_a = getEnvVar(envName)) != null ? _a : "").split(",")) {
|
|
26
|
+
const pattern = entry.trim();
|
|
27
|
+
if (!pattern) {
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
patterns.push(new RegExp(`^(?:${pattern})$`, "i"));
|
|
32
|
+
} catch {
|
|
33
|
+
logger.warn(`Ignoring malformed header pattern in ${envName}.`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return patterns;
|
|
37
|
+
}
|
|
38
|
+
__name(readHeaderPatterns, "readHeaderPatterns");
|
|
39
|
+
function readMcpHttpExchangeSettings() {
|
|
40
|
+
return {
|
|
41
|
+
captureBodies: isTruthyEnv(CAPTURE_BODIES_ENV),
|
|
42
|
+
requestHeaderPatterns: readHeaderPatterns(CAPTURE_REQUEST_HEADERS_ENV),
|
|
43
|
+
responseHeaderPatterns: readHeaderPatterns(CAPTURE_RESPONSE_HEADERS_ENV)
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
__name(readMcpHttpExchangeSettings, "readMcpHttpExchangeSettings");
|
|
47
|
+
function headerAttributes(headers, patterns, prefix) {
|
|
48
|
+
const attributes = {};
|
|
49
|
+
for (const [name, value] of headers) {
|
|
50
|
+
if (patterns.some((pattern) => pattern.test(name))) {
|
|
51
|
+
attributes[`${prefix}${name}`] = [value];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return attributes;
|
|
55
|
+
}
|
|
56
|
+
__name(headerAttributes, "headerAttributes");
|
|
57
|
+
async function reportMcpHttpExchange({
|
|
58
|
+
url,
|
|
59
|
+
init,
|
|
60
|
+
response,
|
|
61
|
+
settings,
|
|
62
|
+
context
|
|
63
|
+
}) {
|
|
64
|
+
const exchange = await captureHttpExchange({
|
|
65
|
+
url,
|
|
66
|
+
init,
|
|
67
|
+
response,
|
|
68
|
+
captureBodies: settings.captureBodies
|
|
69
|
+
});
|
|
70
|
+
const sessionId = exchange.querySessionId || exchange.responseHeaders.get("mcp-session-id") || exchange.requestHeaders.get("mcp-session-id");
|
|
71
|
+
const protocolVersion = exchange.responseHeaders.get("mcp-protocol-version") || exchange.requestHeaders.get("mcp-protocol-version");
|
|
72
|
+
const attributes = {
|
|
73
|
+
[HttpAttr.REQUEST_METHOD]: exchange.method,
|
|
74
|
+
[HttpAttr.URL_FULL]: exchange.url,
|
|
75
|
+
[HttpAttr.RESPONSE_STATUS_CODE]: exchange.statusCode,
|
|
76
|
+
...exchange.serverAddress ? { [HttpAttr.SERVER_ADDRESS]: exchange.serverAddress } : {},
|
|
77
|
+
...exchange.serverPort === void 0 ? {} : { [HttpAttr.SERVER_PORT]: exchange.serverPort },
|
|
78
|
+
...sessionId ? { [McpAttr.SESSION_ID]: sessionId } : {},
|
|
79
|
+
...protocolVersion ? { [McpAttr.PROTOCOL_VERSION]: protocolVersion } : {},
|
|
80
|
+
// HTTP semantic conventions name a failed response by its status code.
|
|
81
|
+
...exchange.statusCode >= 400 ? { [ERROR_TYPE_ATTR]: String(exchange.statusCode) } : {},
|
|
82
|
+
...headerAttributes(
|
|
83
|
+
exchange.requestHeaders,
|
|
84
|
+
settings.requestHeaderPatterns,
|
|
85
|
+
HttpAttr.REQUEST_HEADER_PREFIX
|
|
86
|
+
),
|
|
87
|
+
...headerAttributes(
|
|
88
|
+
exchange.responseHeaders,
|
|
89
|
+
settings.responseHeaderPatterns,
|
|
90
|
+
HttpAttr.RESPONSE_HEADER_PREFIX
|
|
91
|
+
)
|
|
92
|
+
};
|
|
93
|
+
const body = settings.captureBodies ? {
|
|
94
|
+
...exchange.requestBody === void 0 ? {} : { [HttpAttr.REQUEST_BODY_CONTENT]: exchange.requestBody },
|
|
95
|
+
...exchange.responseBody === void 0 ? {} : { [HttpAttr.RESPONSE_BODY_CONTENT]: exchange.responseBody }
|
|
96
|
+
} : {
|
|
97
|
+
[HttpAttr.REQUEST_BODY_CONTENT]: ELIDED_BODY,
|
|
98
|
+
[HttpAttr.RESPONSE_BODY_CONTENT]: ELIDED_BODY
|
|
99
|
+
};
|
|
100
|
+
getTelemetryLogger().emit({
|
|
101
|
+
eventName: MCP_HTTP_RESPONSE_END_EVENT,
|
|
102
|
+
severityNumber: SeverityNumber.DEBUG,
|
|
103
|
+
severityText: "DEBUG",
|
|
104
|
+
body,
|
|
105
|
+
attributes,
|
|
106
|
+
context
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
__name(reportMcpHttpExchange, "reportMcpHttpExchange");
|
|
110
|
+
export {
|
|
111
|
+
readMcpHttpExchangeSettings,
|
|
112
|
+
reportMcpHttpExchange
|
|
113
|
+
};
|