@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,632 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var instrumentation_exports = {};
|
|
27
|
+
__export(instrumentation_exports, {
|
|
28
|
+
instrumentMcpFetch: () => instrumentMcpFetch,
|
|
29
|
+
propagateTraceContext: () => propagateTraceContext,
|
|
30
|
+
recordAgentInvocation: () => recordAgentInvocation,
|
|
31
|
+
recordCompaction: () => recordCompaction,
|
|
32
|
+
recordInference: () => recordInference,
|
|
33
|
+
recordInvocation: () => recordInvocation,
|
|
34
|
+
recordMergedToolCalls: () => recordMergedToolCalls,
|
|
35
|
+
recordNodeInvocation: () => recordNodeInvocation,
|
|
36
|
+
recordSendData: () => recordSendData,
|
|
37
|
+
recordSkillActivity: () => recordSkillActivity,
|
|
38
|
+
recordToolExecution: () => recordToolExecution,
|
|
39
|
+
recordWorkflowInvocation: () => recordWorkflowInvocation,
|
|
40
|
+
runWithRemoteTraceContext: () => runWithRemoteTraceContext
|
|
41
|
+
});
|
|
42
|
+
module.exports = __toCommonJS(instrumentation_exports);
|
|
43
|
+
var import_api = require("@opentelemetry/api");
|
|
44
|
+
var import_logger = require("../../utils/logger.js");
|
|
45
|
+
var import_accumulators = require("./internal/common/accumulators.js");
|
|
46
|
+
var import_attributes = require("./internal/common/attributes.js");
|
|
47
|
+
var import_config = require("./internal/common/config.js");
|
|
48
|
+
var import_error = require("./internal/common/error.js");
|
|
49
|
+
var import_finish_reason = require("./internal/common/finish_reason.js");
|
|
50
|
+
var import_genai_messages = require("./internal/common/genai_messages.js");
|
|
51
|
+
var import_provider_name = require("./internal/common/provider_name.js");
|
|
52
|
+
var import_token_usage = require("./internal/common/token_usage.js");
|
|
53
|
+
var import_inference = require("./internal/logs/inference.js");
|
|
54
|
+
var import_mcp = require("./internal/logs/mcp.js");
|
|
55
|
+
var import_agent = require("./internal/metrics/agent.js");
|
|
56
|
+
var import_inference_start_hook = require("./internal/metrics/inference_start_hook.js");
|
|
57
|
+
var import_tool = require("./internal/metrics/tool.js");
|
|
58
|
+
var import_workflow = require("./internal/metrics/workflow.js");
|
|
59
|
+
var import_agent2 = require("./internal/trace/agent.js");
|
|
60
|
+
var import_compaction = require("./internal/trace/compaction.js");
|
|
61
|
+
var import_inference2 = require("./internal/trace/inference.js");
|
|
62
|
+
var import_live = require("./internal/trace/live.js");
|
|
63
|
+
var import_node = require("./internal/trace/node.js");
|
|
64
|
+
var import_propagation = require("./internal/trace/propagation.js");
|
|
65
|
+
var import_tool2 = require("./internal/trace/tool.js");
|
|
66
|
+
var import_tracer = require("./internal/trace/tracer.js");
|
|
67
|
+
var import_workflow2 = require("./internal/trace/workflow.js");
|
|
68
|
+
/**
|
|
69
|
+
* @license
|
|
70
|
+
* Copyright 2026 Google LLC
|
|
71
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
72
|
+
*/
|
|
73
|
+
function nowMillis() {
|
|
74
|
+
return typeof performance !== "undefined" ? performance.now() : Date.now();
|
|
75
|
+
}
|
|
76
|
+
__name(nowMillis, "nowMillis");
|
|
77
|
+
function elapsedSeconds(startMillis) {
|
|
78
|
+
return Math.max(0, (nowMillis() - startMillis) / 1e3);
|
|
79
|
+
}
|
|
80
|
+
__name(elapsedSeconds, "elapsedSeconds");
|
|
81
|
+
function streamInScope(start, createGenerator) {
|
|
82
|
+
return (async function* () {
|
|
83
|
+
const scope = start();
|
|
84
|
+
try {
|
|
85
|
+
yield* (0, import_tracer.bindOtelContextToAsyncGenerator)(
|
|
86
|
+
scope.context,
|
|
87
|
+
import_api.context.with(scope.context, createGenerator)
|
|
88
|
+
);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
scope.end(error);
|
|
91
|
+
throw error;
|
|
92
|
+
} finally {
|
|
93
|
+
scope.end();
|
|
94
|
+
}
|
|
95
|
+
})();
|
|
96
|
+
}
|
|
97
|
+
__name(streamInScope, "streamInScope");
|
|
98
|
+
function startWorkflowScope({
|
|
99
|
+
workflowName,
|
|
100
|
+
sessionId,
|
|
101
|
+
entrypoint,
|
|
102
|
+
telemetry
|
|
103
|
+
}) {
|
|
104
|
+
const startMillis = nowMillis();
|
|
105
|
+
const parentContext = import_api.context.active();
|
|
106
|
+
const { frame, context: frameContext } = (0, import_accumulators.openWorkflowFrame)({
|
|
107
|
+
workflowName,
|
|
108
|
+
config: (0, import_config.resolveTelemetryConfig)(telemetry),
|
|
109
|
+
entrypoint,
|
|
110
|
+
parentContext
|
|
111
|
+
});
|
|
112
|
+
const nested = frame.parent !== void 0;
|
|
113
|
+
const span = (0, import_workflow2.startWorkflowSpan)({
|
|
114
|
+
workflowName,
|
|
115
|
+
sessionId,
|
|
116
|
+
nested,
|
|
117
|
+
parentContext
|
|
118
|
+
});
|
|
119
|
+
const ctx = import_api.trace.setSpan(frameContext, span);
|
|
120
|
+
let ended = false;
|
|
121
|
+
return {
|
|
122
|
+
context: ctx,
|
|
123
|
+
run: /* @__PURE__ */ __name((fn) => import_api.context.with(ctx, fn), "run"),
|
|
124
|
+
end(error) {
|
|
125
|
+
if (ended) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
ended = true;
|
|
129
|
+
let errorType;
|
|
130
|
+
if (error !== void 0) {
|
|
131
|
+
errorType = (0, import_error.resolveErrorType)(error);
|
|
132
|
+
(0, import_tracer.setSpanError)(span, error);
|
|
133
|
+
}
|
|
134
|
+
span.end();
|
|
135
|
+
(0, import_workflow.recordWorkflowDuration)({
|
|
136
|
+
workflowName,
|
|
137
|
+
durationSeconds: elapsedSeconds(startMillis),
|
|
138
|
+
nested,
|
|
139
|
+
errorType
|
|
140
|
+
});
|
|
141
|
+
(0, import_workflow.recordWorkflowTotals)({
|
|
142
|
+
rootAgentName: frame.rootAgentName,
|
|
143
|
+
workflowName,
|
|
144
|
+
nested,
|
|
145
|
+
totals: frame.totals,
|
|
146
|
+
config: frame.config
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
__name(startWorkflowScope, "startWorkflowScope");
|
|
152
|
+
function recordInvocation({ entrypoint, sessionId, runConfig }, createGenerator) {
|
|
153
|
+
return streamInScope(
|
|
154
|
+
() => startWorkflowScope({
|
|
155
|
+
workflowName: entrypoint.name,
|
|
156
|
+
sessionId,
|
|
157
|
+
entrypoint,
|
|
158
|
+
telemetry: runConfig == null ? void 0 : runConfig.telemetry
|
|
159
|
+
}),
|
|
160
|
+
createGenerator
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
__name(recordInvocation, "recordInvocation");
|
|
164
|
+
function recordAgentInvocation({ agent, invocationContext }, createGenerator) {
|
|
165
|
+
return streamInScope(() => {
|
|
166
|
+
var _a, _b;
|
|
167
|
+
const startMillis = nowMillis();
|
|
168
|
+
const config = (0, import_config.resolveTelemetryConfig)(
|
|
169
|
+
(_a = invocationContext.runConfig) == null ? void 0 : _a.telemetry
|
|
170
|
+
);
|
|
171
|
+
const parentContext = import_api.context.active();
|
|
172
|
+
const { frame, context: frameContext } = (0, import_accumulators.openAgentFrame)(parentContext);
|
|
173
|
+
const span = (0, import_tracer.getTracer)().startSpan(
|
|
174
|
+
`invoke_agent ${agent.name}`,
|
|
175
|
+
{
|
|
176
|
+
attributes: (0, import_agent2.buildAgentInvocationAttributes)({
|
|
177
|
+
agent,
|
|
178
|
+
// Read defensively: telemetry must not fail a run whose context was
|
|
179
|
+
// assembled without a session.
|
|
180
|
+
sessionId: (_b = invocationContext.session) == null ? void 0 : _b.id
|
|
181
|
+
})
|
|
182
|
+
},
|
|
183
|
+
parentContext
|
|
184
|
+
);
|
|
185
|
+
const ctx = import_api.trace.setSpan(frameContext, span);
|
|
186
|
+
let ended = false;
|
|
187
|
+
return {
|
|
188
|
+
context: ctx,
|
|
189
|
+
end(error) {
|
|
190
|
+
if (ended) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
ended = true;
|
|
194
|
+
let errorType;
|
|
195
|
+
if (error !== void 0) {
|
|
196
|
+
errorType = (0, import_error.resolveErrorType)(error);
|
|
197
|
+
(0, import_tracer.setSpanError)(span, error);
|
|
198
|
+
}
|
|
199
|
+
span.end();
|
|
200
|
+
(0, import_agent.recordAgentDuration)({
|
|
201
|
+
agentName: agent.name,
|
|
202
|
+
durationSeconds: elapsedSeconds(startMillis),
|
|
203
|
+
errorType
|
|
204
|
+
});
|
|
205
|
+
(0, import_agent.recordAgentTotals)({
|
|
206
|
+
agentName: agent.name,
|
|
207
|
+
totals: frame.totals,
|
|
208
|
+
config
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
}, createGenerator);
|
|
213
|
+
}
|
|
214
|
+
__name(recordAgentInvocation, "recordAgentInvocation");
|
|
215
|
+
function startInference({
|
|
216
|
+
invocationContext,
|
|
217
|
+
llmRequest,
|
|
218
|
+
modelResponseEvent
|
|
219
|
+
}) {
|
|
220
|
+
var _a, _b, _c;
|
|
221
|
+
const config = (0, import_config.resolveTelemetryConfig)((_a = invocationContext.runConfig) == null ? void 0 : _a.telemetry);
|
|
222
|
+
const accumulators = (0, import_accumulators.captureAccumulators)(import_api.context.active());
|
|
223
|
+
const agentName = (_b = invocationContext.agent) == null ? void 0 : _b.name;
|
|
224
|
+
const commonAttributes = {
|
|
225
|
+
...agentName ? { [import_attributes.GenAiAttr.AGENT_NAME]: agentName } : {},
|
|
226
|
+
[import_attributes.GenAiAttr.CONVERSATION_ID]: (_c = invocationContext.session) == null ? void 0 : _c.id,
|
|
227
|
+
[import_attributes.GcpAttr.EVENT_ID]: modelResponseEvent.id,
|
|
228
|
+
[import_attributes.GcpAttr.INVOCATION_ID]: invocationContext.invocationId,
|
|
229
|
+
[import_attributes.GenAiAttr.PROVIDER_NAME]: (0, import_provider_name.resolveProviderName)(llmRequest.model)
|
|
230
|
+
};
|
|
231
|
+
const span = (0, import_inference2.startInferenceSpan)({ llmRequest, commonAttributes });
|
|
232
|
+
(0, import_inference_start_hook.notifyInferenceStart)();
|
|
233
|
+
const requestDetails = (0, import_genai_messages.buildRequestOperationDetails)(llmRequest);
|
|
234
|
+
const outputMessages = [];
|
|
235
|
+
let responseAttributes = {};
|
|
236
|
+
let newestUsage;
|
|
237
|
+
let spanEnded = false;
|
|
238
|
+
let finished = false;
|
|
239
|
+
const endSpan = /* @__PURE__ */ __name((failure) => {
|
|
240
|
+
var _a2;
|
|
241
|
+
if (spanEnded) {
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
spanEnded = true;
|
|
245
|
+
if (failure) {
|
|
246
|
+
(0, import_tracer.setSpanError)(span, failure.error);
|
|
247
|
+
}
|
|
248
|
+
const details = outputMessages.length > 0 ? { ...requestDetails, [import_attributes.GenAiAttr.OUTPUT_MESSAGES]: outputMessages } : requestDetails;
|
|
249
|
+
const captureContent = (0, import_config.shouldAddContentToLogs)(config);
|
|
250
|
+
(0, import_inference.emitInferenceOperationDetails)(span, {
|
|
251
|
+
...commonAttributes,
|
|
252
|
+
...captureContent ? { [import_attributes.USER_ID_ATTR]: (_a2 = invocationContext.session) == null ? void 0 : _a2.userId } : {},
|
|
253
|
+
...responseAttributes,
|
|
254
|
+
...captureContent ? details : (0, import_genai_messages.withoutContent)(details)
|
|
255
|
+
});
|
|
256
|
+
(0, import_inference2.setInferenceOperationDetails)(span, details, config);
|
|
257
|
+
span.end();
|
|
258
|
+
}, "endSpan");
|
|
259
|
+
return {
|
|
260
|
+
context: import_api.trace.setSpan(import_api.context.active(), span),
|
|
261
|
+
record(llmResponse) {
|
|
262
|
+
var _a2;
|
|
263
|
+
newestUsage = (_a2 = llmResponse.usageMetadata) != null ? _a2 : newestUsage;
|
|
264
|
+
if (spanEnded) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
(0, import_inference2.setInferenceResponseAttributes)(span, llmResponse, config);
|
|
268
|
+
responseAttributes = {
|
|
269
|
+
...responseAttributes,
|
|
270
|
+
...(0, import_inference2.buildResponseAttributes)(llmResponse)
|
|
271
|
+
};
|
|
272
|
+
const outputMessage = (0, import_genai_messages.buildOutputMessage)(llmResponse);
|
|
273
|
+
if (outputMessage) {
|
|
274
|
+
outputMessages.push(outputMessage);
|
|
275
|
+
}
|
|
276
|
+
if ((0, import_finish_reason.isReportedFinishReason)(llmResponse.finishReason)) {
|
|
277
|
+
endSpan();
|
|
278
|
+
}
|
|
279
|
+
},
|
|
280
|
+
finish(failure) {
|
|
281
|
+
if (finished) {
|
|
282
|
+
return;
|
|
283
|
+
}
|
|
284
|
+
finished = true;
|
|
285
|
+
endSpan(failure);
|
|
286
|
+
accumulators.addInferenceCall();
|
|
287
|
+
if (newestUsage !== void 0) {
|
|
288
|
+
const usage = new import_token_usage.TokenUsage(newestUsage);
|
|
289
|
+
if (usage.input !== void 0 || usage.output !== void 0) {
|
|
290
|
+
accumulators.addTokens(usage);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
__name(startInference, "startInference");
|
|
297
|
+
function recordInference(params, createStream) {
|
|
298
|
+
return (async function* () {
|
|
299
|
+
const inference = startInference(params);
|
|
300
|
+
try {
|
|
301
|
+
for await (const llmResponse of (0, import_tracer.bindOtelContextToAsyncGenerator)(
|
|
302
|
+
inference.context,
|
|
303
|
+
import_api.context.with(inference.context, createStream)
|
|
304
|
+
)) {
|
|
305
|
+
inference.record(llmResponse);
|
|
306
|
+
yield llmResponse;
|
|
307
|
+
}
|
|
308
|
+
} catch (error) {
|
|
309
|
+
inference.finish({ error });
|
|
310
|
+
throw error;
|
|
311
|
+
} finally {
|
|
312
|
+
inference.finish();
|
|
313
|
+
}
|
|
314
|
+
})();
|
|
315
|
+
}
|
|
316
|
+
__name(recordInference, "recordInference");
|
|
317
|
+
async function recordSendData(params, fn) {
|
|
318
|
+
return (0, import_tracer.getTracer)().startActiveSpan("send_data", async (span) => {
|
|
319
|
+
try {
|
|
320
|
+
const result = await fn();
|
|
321
|
+
(0, import_live.setSendDataAttributes)(span, params);
|
|
322
|
+
return result;
|
|
323
|
+
} finally {
|
|
324
|
+
span.end();
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
__name(recordSendData, "recordSendData");
|
|
329
|
+
const TOOL_SCOPE_KEY = (0, import_api.createContextKey)("adk_tool_scope");
|
|
330
|
+
function isToolScopeState(value) {
|
|
331
|
+
return typeof value === "object" && value !== null && "skill" in value;
|
|
332
|
+
}
|
|
333
|
+
__name(isToolScopeState, "isToolScopeState");
|
|
334
|
+
async function recordToolExecution({ tool, args, invocationContext }, fn) {
|
|
335
|
+
var _a;
|
|
336
|
+
const startMillis = nowMillis();
|
|
337
|
+
const config = (0, import_config.resolveTelemetryConfig)((_a = invocationContext.runConfig) == null ? void 0 : _a.telemetry);
|
|
338
|
+
const accumulators = (0, import_accumulators.captureAccumulators)(import_api.context.active());
|
|
339
|
+
const toolScope = { skill: void 0 };
|
|
340
|
+
return (0, import_tracer.getTracer)().startActiveSpan(
|
|
341
|
+
`execute_tool ${tool.name}`,
|
|
342
|
+
{},
|
|
343
|
+
import_api.context.active().setValue(TOOL_SCOPE_KEY, toolScope),
|
|
344
|
+
async (span) => {
|
|
345
|
+
var _a2;
|
|
346
|
+
let outcome = { kind: "response" };
|
|
347
|
+
try {
|
|
348
|
+
return await fn({
|
|
349
|
+
recordSuccess({ functionResponseEvent, rawResult }) {
|
|
350
|
+
outcome = {
|
|
351
|
+
kind: "response",
|
|
352
|
+
functionResponseEvent,
|
|
353
|
+
errorType: (0, import_error.getToolResponseErrorType)(rawResult)
|
|
354
|
+
};
|
|
355
|
+
}
|
|
356
|
+
});
|
|
357
|
+
} catch (error) {
|
|
358
|
+
outcome = { kind: "error", errorType: (0, import_error.resolveErrorType)(error) };
|
|
359
|
+
(0, import_tracer.setSpanError)(span, error);
|
|
360
|
+
throw error;
|
|
361
|
+
} finally {
|
|
362
|
+
const agentName = (_a2 = invocationContext.agent) == null ? void 0 : _a2.name;
|
|
363
|
+
span.setAttributes(
|
|
364
|
+
(0, import_tool2.buildToolCallAttributes)({
|
|
365
|
+
tool,
|
|
366
|
+
args,
|
|
367
|
+
agentName,
|
|
368
|
+
outcome,
|
|
369
|
+
config
|
|
370
|
+
})
|
|
371
|
+
);
|
|
372
|
+
if (outcome.kind === "response" && outcome.errorType !== void 0) {
|
|
373
|
+
span.setStatus({
|
|
374
|
+
code: import_api.SpanStatusCode.ERROR,
|
|
375
|
+
message: outcome.errorType
|
|
376
|
+
});
|
|
377
|
+
}
|
|
378
|
+
const skillReport = toolScope.skill;
|
|
379
|
+
if (skillReport) {
|
|
380
|
+
(0, import_tool2.setSkillSpanAttributes)(span, tool.name, skillReport);
|
|
381
|
+
if (skillReport.isSkillLoad) {
|
|
382
|
+
accumulators.addSkillLoad();
|
|
383
|
+
if (agentName !== void 0) {
|
|
384
|
+
(0, import_tool.recordSkillLoad)({
|
|
385
|
+
agentName,
|
|
386
|
+
skill: skillReport.skill,
|
|
387
|
+
errorType: outcome.errorType,
|
|
388
|
+
config
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
} else if (skillReport.isSkillScript && skillReport.resourceName !== void 0 && agentName !== void 0) {
|
|
392
|
+
(0, import_tool.recordSkillScriptExecution)({
|
|
393
|
+
agentName,
|
|
394
|
+
skill: skillReport.skill,
|
|
395
|
+
scriptPath: skillReport.resourceName,
|
|
396
|
+
config
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
span.end();
|
|
401
|
+
accumulators.addToolCall();
|
|
402
|
+
(0, import_tool.recordToolDuration)({
|
|
403
|
+
agentName: agentName != null ? agentName : "",
|
|
404
|
+
toolName: tool.name,
|
|
405
|
+
toolType: tool.constructor.name,
|
|
406
|
+
durationSeconds: elapsedSeconds(startMillis),
|
|
407
|
+
errorType: outcome.errorType
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
__name(recordToolExecution, "recordToolExecution");
|
|
414
|
+
const NO_OP_SKILL_ACTIVITY_SCOPE = Object.freeze({
|
|
415
|
+
recordSkill() {
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
function toSkillReport(activity) {
|
|
419
|
+
switch (activity.kind) {
|
|
420
|
+
case "load":
|
|
421
|
+
return { skillName: activity.skillName, isSkillLoad: true };
|
|
422
|
+
case "resource":
|
|
423
|
+
return {
|
|
424
|
+
skillName: activity.skillName,
|
|
425
|
+
resourceName: activity.resourcePath,
|
|
426
|
+
isSkillLoad: false
|
|
427
|
+
};
|
|
428
|
+
case "script":
|
|
429
|
+
return {
|
|
430
|
+
skillName: activity.skillName,
|
|
431
|
+
resourceName: activity.scriptPath,
|
|
432
|
+
isSkillLoad: false,
|
|
433
|
+
isSkillScript: true
|
|
434
|
+
};
|
|
435
|
+
default: {
|
|
436
|
+
const exhaustive = activity;
|
|
437
|
+
throw new Error(`Unknown skill activity: ${JSON.stringify(exhaustive)}`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
__name(toSkillReport, "toSkillReport");
|
|
442
|
+
function recordSkillActivity(activity) {
|
|
443
|
+
const toolScope = import_api.context.active().getValue(TOOL_SCOPE_KEY);
|
|
444
|
+
if (!isToolScopeState(toolScope)) {
|
|
445
|
+
return NO_OP_SKILL_ACTIVITY_SCOPE;
|
|
446
|
+
}
|
|
447
|
+
const report = toSkillReport(activity);
|
|
448
|
+
toolScope.skill = report;
|
|
449
|
+
return {
|
|
450
|
+
recordSkill(skill) {
|
|
451
|
+
toolScope.skill = { ...report, skill };
|
|
452
|
+
}
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
__name(recordSkillActivity, "recordSkillActivity");
|
|
456
|
+
function recordMergedToolCalls({
|
|
457
|
+
responseEventId
|
|
458
|
+
}) {
|
|
459
|
+
(0, import_tracer.getTracer)().startSpan("execute_tool (merged)", {
|
|
460
|
+
attributes: (0, import_tool2.buildMergedToolCallsAttributes)(responseEventId)
|
|
461
|
+
}).end();
|
|
462
|
+
}
|
|
463
|
+
__name(recordMergedToolCalls, "recordMergedToolCalls");
|
|
464
|
+
const PASS_THROUGH_SCOPE = Object.freeze({
|
|
465
|
+
run: /* @__PURE__ */ __name((fn) => fn(), "run"),
|
|
466
|
+
end() {
|
|
467
|
+
}
|
|
468
|
+
});
|
|
469
|
+
function startSyncScope(span, ctx, onSuccess) {
|
|
470
|
+
let ended = false;
|
|
471
|
+
return {
|
|
472
|
+
run: /* @__PURE__ */ __name((fn) => import_api.context.with(ctx, fn), "run"),
|
|
473
|
+
end(error) {
|
|
474
|
+
if (ended) {
|
|
475
|
+
return;
|
|
476
|
+
}
|
|
477
|
+
ended = true;
|
|
478
|
+
if (error === void 0) {
|
|
479
|
+
onSuccess == null ? void 0 : onSuccess();
|
|
480
|
+
} else {
|
|
481
|
+
(0, import_tracer.setSpanError)(span, error);
|
|
482
|
+
}
|
|
483
|
+
span.end();
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
__name(startSyncScope, "startSyncScope");
|
|
488
|
+
function recordWorkflowInvocation({
|
|
489
|
+
workflow,
|
|
490
|
+
sessionId
|
|
491
|
+
}) {
|
|
492
|
+
const entrypointContext = (0, import_accumulators.claimEntrypointWorkflowFrame)(workflow);
|
|
493
|
+
if (entrypointContext) {
|
|
494
|
+
return { run: /* @__PURE__ */ __name((fn) => import_api.context.with(entrypointContext, fn), "run"), end() {
|
|
495
|
+
} };
|
|
496
|
+
}
|
|
497
|
+
return startWorkflowScope({
|
|
498
|
+
workflowName: workflow.name,
|
|
499
|
+
sessionId
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
__name(recordWorkflowInvocation, "recordWorkflowInvocation");
|
|
503
|
+
const PASS_THROUGH_NODE_SCOPE = Object.freeze({
|
|
504
|
+
...PASS_THROUGH_SCOPE,
|
|
505
|
+
recordEvent() {
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
function recordNodeInvocation({
|
|
509
|
+
node,
|
|
510
|
+
nodeName,
|
|
511
|
+
sessionId
|
|
512
|
+
}) {
|
|
513
|
+
if ((0, import_node.hasOwnInvocationSpan)(node)) {
|
|
514
|
+
return PASS_THROUGH_NODE_SCOPE;
|
|
515
|
+
}
|
|
516
|
+
const span = (0, import_node.startNodeSpan)({ nodeName, sessionId });
|
|
517
|
+
const eventIds = [];
|
|
518
|
+
return {
|
|
519
|
+
...startSyncScope(
|
|
520
|
+
span,
|
|
521
|
+
import_api.trace.setSpan(import_api.context.active(), span),
|
|
522
|
+
() => (0, import_node.setAssociatedEventIds)(span, eventIds)
|
|
523
|
+
),
|
|
524
|
+
recordEvent(event) {
|
|
525
|
+
eventIds.push(event.id);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
__name(recordNodeInvocation, "recordNodeInvocation");
|
|
530
|
+
async function recordCompaction({ invocationContext, trigger }, fn) {
|
|
531
|
+
const { session } = invocationContext;
|
|
532
|
+
const eventsBefore = [...session.events];
|
|
533
|
+
const accumulators = (0, import_accumulators.captureAccumulators)(import_api.context.active());
|
|
534
|
+
const span = (0, import_compaction.startCompactionSpan)({ sessionId: session.id, trigger });
|
|
535
|
+
return import_api.context.with(import_api.trace.setSpan(import_api.context.active(), span), async () => {
|
|
536
|
+
try {
|
|
537
|
+
const result = await fn();
|
|
538
|
+
const attributes = (0, import_compaction.buildCompactionResultAttributes)(
|
|
539
|
+
eventsBefore,
|
|
540
|
+
session.events
|
|
541
|
+
);
|
|
542
|
+
span.setAttributes(attributes);
|
|
543
|
+
if (import_attributes.GenAiAttr.COMPACTION_RESULT_EVENT_ID in attributes) {
|
|
544
|
+
accumulators.addCompaction();
|
|
545
|
+
}
|
|
546
|
+
return result;
|
|
547
|
+
} catch (error) {
|
|
548
|
+
(0, import_tracer.setSpanError)(span, error);
|
|
549
|
+
throw error;
|
|
550
|
+
} finally {
|
|
551
|
+
span.end();
|
|
552
|
+
}
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
__name(recordCompaction, "recordCompaction");
|
|
556
|
+
function instrumentMcpFetch(fetch) {
|
|
557
|
+
if (!(0, import_config.isExperimentalFeatureEnabled)((0, import_config.resolveTelemetryConfig)(), "mcp")) {
|
|
558
|
+
return fetch;
|
|
559
|
+
}
|
|
560
|
+
return async (url, init) => {
|
|
561
|
+
const settings = (0, import_mcp.readMcpHttpExchangeSettings)();
|
|
562
|
+
const requestContext = import_api.context.active();
|
|
563
|
+
const response = await (fetch != null ? fetch : globalThis.fetch)(url, init);
|
|
564
|
+
void (0, import_mcp.reportMcpHttpExchange)({
|
|
565
|
+
url,
|
|
566
|
+
init,
|
|
567
|
+
response,
|
|
568
|
+
settings,
|
|
569
|
+
context: requestContext
|
|
570
|
+
}).catch((error) => {
|
|
571
|
+
import_logger.logger.warn(
|
|
572
|
+
`Failed to record an MCP HTTP exchange: ${(0, import_error.resolveErrorType)(error)}`
|
|
573
|
+
);
|
|
574
|
+
});
|
|
575
|
+
return response;
|
|
576
|
+
};
|
|
577
|
+
}
|
|
578
|
+
__name(instrumentMcpFetch, "instrumentMcpFetch");
|
|
579
|
+
function propagateTraceContext(fetchImpl) {
|
|
580
|
+
return (input, init) => {
|
|
581
|
+
const send = fetchImpl != null ? fetchImpl : globalThis.fetch;
|
|
582
|
+
const injected = {};
|
|
583
|
+
try {
|
|
584
|
+
import_api.propagation.inject(import_api.context.active(), injected);
|
|
585
|
+
} catch (error) {
|
|
586
|
+
import_logger.logger.warn(
|
|
587
|
+
`Failed to inject trace context into a request: ${(0, import_error.resolveErrorType)(error)}`
|
|
588
|
+
);
|
|
589
|
+
return send(input, init);
|
|
590
|
+
}
|
|
591
|
+
if (Object.keys(injected).length === 0) {
|
|
592
|
+
return send(input, init);
|
|
593
|
+
}
|
|
594
|
+
return send(input, {
|
|
595
|
+
...init,
|
|
596
|
+
headers: (0, import_propagation.addMissingHeaders)(input, init, injected)
|
|
597
|
+
});
|
|
598
|
+
};
|
|
599
|
+
}
|
|
600
|
+
__name(propagateTraceContext, "propagateTraceContext");
|
|
601
|
+
function runWithRemoteTraceContext(headers, fn) {
|
|
602
|
+
const active = import_api.context.active();
|
|
603
|
+
if (import_api.trace.getSpan(active)) {
|
|
604
|
+
return fn();
|
|
605
|
+
}
|
|
606
|
+
let remote = active;
|
|
607
|
+
try {
|
|
608
|
+
remote = import_api.propagation.extract(active, headers, import_propagation.INCOMING_HEADERS_GETTER);
|
|
609
|
+
} catch (error) {
|
|
610
|
+
import_logger.logger.warn(
|
|
611
|
+
`Failed to extract trace context from a request: ${(0, import_error.resolveErrorType)(error)}`
|
|
612
|
+
);
|
|
613
|
+
}
|
|
614
|
+
return import_api.context.with(remote, fn);
|
|
615
|
+
}
|
|
616
|
+
__name(runWithRemoteTraceContext, "runWithRemoteTraceContext");
|
|
617
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
618
|
+
0 && (module.exports = {
|
|
619
|
+
instrumentMcpFetch,
|
|
620
|
+
propagateTraceContext,
|
|
621
|
+
recordAgentInvocation,
|
|
622
|
+
recordCompaction,
|
|
623
|
+
recordInference,
|
|
624
|
+
recordInvocation,
|
|
625
|
+
recordMergedToolCalls,
|
|
626
|
+
recordNodeInvocation,
|
|
627
|
+
recordSendData,
|
|
628
|
+
recordSkillActivity,
|
|
629
|
+
recordToolExecution,
|
|
630
|
+
recordWorkflowInvocation,
|
|
631
|
+
runWithRemoteTraceContext
|
|
632
|
+
});
|