@google/adk 2.4.0 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/a2a/a2a_remote_agent.js +17 -2
- package/dist/cjs/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/cjs/a2a/agent_card.js +5 -81
- package/dist/cjs/a2a/agent_to_a2a.js +7 -0
- package/dist/cjs/a2a/event_converter_utils.js +10 -3
- package/dist/cjs/agents/agent_engine_client.js +282 -55
- package/dist/cjs/agents/base_agent.js +111 -68
- package/dist/cjs/agents/functions.js +62 -85
- package/dist/cjs/agents/instructions.js +7 -6
- package/dist/cjs/agents/invocation_context.js +2 -2
- package/dist/cjs/agents/llm_agent.js +105 -95
- package/dist/cjs/agents/processors/content_processor_utils.js +42 -15
- package/dist/cjs/agents/processors/content_request_processor.js +28 -11
- package/dist/cjs/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +2 -1
- package/dist/cjs/artifacts/file_artifact_service.js +1 -1
- package/dist/cjs/cli/cli_eval.js +884 -17
- package/dist/cjs/cli/utils/cleanup.js +84 -0
- package/dist/cjs/cli/utils/envs.js +33 -2
- package/dist/cjs/cli/utils/evals.js +75 -8
- package/dist/cjs/cli/utils/logs.js +128 -9
- package/dist/cjs/cli/utils/path_validation.js +83 -0
- package/dist/cjs/code_executors/container_code_executor.js +158 -36
- package/dist/cjs/common.js +50 -12
- package/dist/cjs/context/compaction_utils.js +19 -0
- package/dist/cjs/events/event.js +7 -3
- package/dist/cjs/features/feature_registry.js +5 -0
- package/dist/cjs/index.js +29 -14
- package/dist/cjs/models/google_llm.js +33 -2
- package/dist/cjs/models/interactions_utils.js +3 -0
- package/dist/cjs/plugins/base_plugin.js +45 -21
- package/dist/cjs/plugins/plugin_manager.js +27 -0
- package/dist/cjs/runner/runner.js +306 -189
- package/dist/cjs/sessions/base_session_service.js +1 -4
- package/dist/cjs/sessions/database_session_service.js +191 -19
- package/dist/cjs/sessions/db/operations.js +70 -1
- package/dist/cjs/sessions/db/schema.js +4 -0
- package/dist/cjs/sessions/in_memory_session_service.js +2 -2
- package/dist/cjs/sessions/vertex_ai_session_service.js +11 -3
- package/dist/cjs/skills/loader.js +29 -28
- package/dist/cjs/telemetry/api/instrumentation.js +632 -0
- package/dist/cjs/telemetry/api/internal/common/accumulators.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/attributes.js +131 -0
- package/dist/cjs/telemetry/api/internal/common/config.js +159 -0
- package/dist/cjs/telemetry/api/internal/common/error.js +98 -0
- package/dist/cjs/telemetry/api/internal/common/finish_reason.js +63 -0
- package/dist/cjs/telemetry/api/internal/common/genai_messages.js +217 -0
- package/dist/cjs/telemetry/api/internal/common/http_exchange.js +169 -0
- package/dist/cjs/telemetry/api/internal/common/provider_name.js +87 -0
- package/dist/cjs/telemetry/api/internal/common/redaction.js +148 -0
- package/dist/cjs/telemetry/api/internal/common/serialization.js +58 -0
- package/dist/cjs/telemetry/api/internal/common/token_usage.js +118 -0
- package/dist/cjs/telemetry/api/internal/logs/inference.js +50 -0
- package/dist/cjs/telemetry/api/internal/logs/logger.js +46 -0
- package/dist/cjs/telemetry/api/internal/logs/mcp.js +141 -0
- package/dist/cjs/telemetry/api/internal/metrics/agent.js +128 -0
- package/dist/cjs/telemetry/api/internal/metrics/inference_start_hook.js +56 -0
- package/dist/cjs/telemetry/api/internal/metrics/meters.js +189 -0
- package/dist/cjs/telemetry/api/internal/metrics/tool.js +147 -0
- package/dist/cjs/telemetry/api/internal/metrics/workflow.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/agent.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/compaction.js +78 -0
- package/dist/cjs/telemetry/api/internal/trace/inference.js +132 -0
- package/dist/cjs/telemetry/api/internal/trace/live.js +52 -0
- package/dist/cjs/telemetry/api/internal/trace/node.js +73 -0
- package/dist/cjs/telemetry/api/internal/trace/propagation.js +67 -0
- package/dist/cjs/telemetry/api/internal/trace/tool.js +122 -0
- package/dist/cjs/telemetry/api/internal/trace/tracer.js +77 -0
- package/dist/cjs/telemetry/api/internal/trace/workflow.js +77 -0
- package/dist/cjs/telemetry/export/agent_engine.js +90 -0
- package/dist/cjs/telemetry/export/agent_runtime.js +73 -0
- package/dist/cjs/telemetry/export/google_cloud.js +763 -0
- package/dist/cjs/telemetry/export/request_driven_metric_reader.js +303 -0
- package/dist/cjs/telemetry/{setup.js → export/setup.js} +72 -5
- package/dist/cjs/tools/agent_tool.js +9 -1
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +22 -34
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +60 -20
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +14 -23
- package/dist/cjs/tools/base_toolset.js +1 -1
- package/dist/cjs/tools/computer_use/base_computer.js +125 -0
- package/dist/cjs/tools/computer_use/computer_use_actions.js +502 -0
- package/dist/cjs/tools/computer_use/computer_use_tool.js +244 -0
- package/dist/cjs/tools/computer_use/computer_use_toolset.js +360 -0
- package/dist/cjs/tools/function_tool.js +15 -5
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +3 -2
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/cjs/tools/load_artifacts_tool.js +15 -5
- package/dist/cjs/tools/load_memory_tool.js +2 -5
- package/dist/cjs/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/cjs/tools/mcp/mcp_tool.js +7 -3
- package/dist/cjs/tools/mcp/mcp_toolset.js +18 -6
- package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +30 -29
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +45 -14
- package/dist/cjs/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/cjs/tools/skill/load_skill_tool.js +3 -0
- package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/cjs/tools/toolbox_toolset.js +47 -28
- package/dist/cjs/utils/async_queue.js +37 -3
- package/dist/cjs/utils/client_labels.js +9 -11
- package/dist/cjs/utils/env_aware_utils.js +13 -7
- package/dist/cjs/utils/error_utils.js +40 -2
- package/dist/cjs/utils/failover_utils.js +10 -9
- package/dist/cjs/utils/gemini_schema_util.js +125 -12
- package/dist/cjs/utils/id_provider.js +63 -0
- package/dist/cjs/utils/model_name.js +15 -0
- package/dist/cjs/utils/simple_zod_to_json.js +13 -31
- package/dist/cjs/utils/ssrf_guard.js +46 -16
- package/dist/cjs/version.js +1 -1
- package/dist/cjs/workflow/index.js +2 -0
- package/dist/cjs/workflow/node_runner.js +24 -80
- package/dist/cjs/workflow/nodes/parallel_worker.js +18 -7
- package/dist/cjs/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/cjs/workflow/utils/retry_utils.js +2 -2
- package/dist/cjs/workflow/workflow.js +12 -12
- package/dist/esm/a2a/a2a_remote_agent.js +23 -3
- package/dist/esm/a2a/a2a_remote_agent_utils.js +8 -4
- package/dist/esm/a2a/agent_card.js +5 -83
- package/dist/esm/a2a/agent_to_a2a.js +7 -0
- package/dist/esm/a2a/event_converter_utils.js +10 -3
- package/dist/esm/agents/agent_engine_client.js +293 -55
- package/dist/esm/agents/base_agent.js +111 -72
- package/dist/esm/agents/functions.js +67 -89
- package/dist/esm/agents/instructions.js +7 -6
- package/dist/esm/agents/invocation_context.js +2 -2
- package/dist/esm/agents/llm_agent.js +111 -100
- package/dist/esm/agents/processors/content_processor_utils.js +42 -15
- package/dist/esm/agents/processors/content_request_processor.js +28 -11
- package/dist/esm/agents/processors/context_compactor_request_processor.js +5 -1
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +2 -1
- package/dist/esm/artifacts/file_artifact_service.js +1 -1
- package/dist/esm/cli/cli_eval.js +880 -17
- package/dist/esm/cli/utils/cleanup.js +56 -0
- package/dist/esm/cli/utils/envs.js +33 -2
- package/dist/esm/cli/utils/evals.js +74 -8
- package/dist/esm/cli/utils/logs.js +128 -9
- package/dist/esm/cli/utils/path_validation.js +45 -0
- package/dist/esm/code_executors/container_code_executor.js +158 -36
- package/dist/esm/common.js +49 -6
- package/dist/esm/context/compaction_utils.js +19 -0
- package/dist/esm/events/event.js +7 -3
- package/dist/esm/features/feature_registry.js +5 -0
- package/dist/esm/index.js +27 -15
- package/dist/esm/models/google_llm.js +33 -2
- package/dist/esm/models/interactions_utils.js +3 -0
- package/dist/esm/plugins/base_plugin.js +45 -21
- package/dist/esm/plugins/plugin_manager.js +27 -0
- package/dist/esm/runner/runner.js +310 -192
- package/dist/esm/sessions/base_session_service.js +1 -4
- package/dist/esm/sessions/database_session_service.js +191 -19
- package/dist/esm/sessions/db/operations.js +70 -1
- package/dist/esm/sessions/db/schema.js +4 -0
- package/dist/esm/sessions/in_memory_session_service.js +2 -2
- package/dist/esm/sessions/vertex_ai_session_service.js +11 -3
- package/dist/esm/skills/loader.js +29 -28
- package/dist/esm/telemetry/api/instrumentation.js +655 -0
- package/dist/esm/telemetry/api/internal/common/accumulators.js +139 -0
- package/dist/esm/telemetry/api/internal/common/attributes.js +94 -0
- package/dist/esm/telemetry/api/internal/common/config.js +128 -0
- package/dist/esm/telemetry/api/internal/common/error.js +69 -0
- package/dist/esm/telemetry/api/internal/common/finish_reason.js +35 -0
- package/dist/esm/telemetry/api/internal/common/genai_messages.js +188 -0
- package/dist/esm/telemetry/api/internal/common/http_exchange.js +142 -0
- package/dist/esm/telemetry/api/internal/common/provider_name.js +59 -0
- package/dist/esm/telemetry/api/internal/common/redaction.js +121 -0
- package/dist/esm/telemetry/api/internal/common/serialization.js +30 -0
- package/dist/esm/telemetry/api/internal/common/token_usage.js +85 -0
- package/dist/esm/telemetry/api/internal/logs/inference.js +23 -0
- package/dist/esm/telemetry/api/internal/logs/logger.js +19 -0
- package/dist/esm/telemetry/api/internal/logs/mcp.js +113 -0
- package/dist/esm/telemetry/api/internal/metrics/agent.js +107 -0
- package/dist/esm/telemetry/api/internal/metrics/inference_start_hook.js +29 -0
- package/dist/esm/telemetry/api/internal/metrics/meters.js +165 -0
- package/dist/esm/telemetry/api/internal/metrics/tool.js +119 -0
- package/dist/esm/telemetry/api/internal/metrics/workflow.js +112 -0
- package/dist/esm/telemetry/api/internal/trace/agent.js +25 -0
- package/dist/esm/telemetry/api/internal/trace/compaction.js +50 -0
- package/dist/esm/telemetry/api/internal/trace/inference.js +107 -0
- package/dist/esm/telemetry/api/internal/trace/live.js +28 -0
- package/dist/esm/telemetry/api/internal/trace/node.js +44 -0
- package/dist/esm/telemetry/api/internal/trace/propagation.js +39 -0
- package/dist/esm/telemetry/api/internal/trace/tool.js +96 -0
- package/dist/esm/telemetry/api/internal/trace/tracer.js +52 -0
- package/dist/esm/telemetry/api/internal/trace/workflow.js +54 -0
- package/dist/esm/telemetry/export/agent_engine.js +67 -0
- package/dist/esm/telemetry/export/agent_runtime.js +46 -0
- package/dist/esm/telemetry/export/google_cloud.js +733 -0
- package/dist/esm/telemetry/export/request_driven_metric_reader.js +276 -0
- package/dist/esm/telemetry/export/setup.js +160 -0
- package/dist/esm/tools/agent_tool.js +9 -1
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +23 -35
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +64 -21
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +26 -10
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +14 -23
- package/dist/esm/tools/base_toolset.js +1 -1
- package/dist/esm/tools/computer_use/base_computer.js +99 -0
- package/dist/esm/tools/computer_use/computer_use_actions.js +477 -0
- package/dist/esm/tools/computer_use/computer_use_tool.js +217 -0
- package/dist/esm/tools/computer_use/computer_use_toolset.js +344 -0
- package/dist/esm/tools/function_tool.js +15 -5
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +3 -2
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +3 -1
- package/dist/esm/tools/load_artifacts_tool.js +15 -5
- package/dist/esm/tools/load_memory_tool.js +2 -5
- package/dist/esm/tools/mcp/mcp_session_manager.js +23 -3
- package/dist/esm/tools/mcp/mcp_tool.js +7 -3
- package/dist/esm/tools/mcp/mcp_toolset.js +18 -6
- package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +27 -26
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +45 -14
- package/dist/esm/tools/skill/load_skill_resource_tool.js +7 -0
- package/dist/esm/tools/skill/load_skill_tool.js +3 -0
- package/dist/esm/tools/skill/run_skill_script_tool.js +12 -2
- package/dist/esm/tools/toolbox_toolset.js +47 -28
- package/dist/esm/utils/async_queue.js +37 -3
- package/dist/esm/utils/client_labels.js +9 -11
- package/dist/esm/utils/env_aware_utils.js +12 -7
- package/dist/esm/utils/error_utils.js +37 -1
- package/dist/esm/utils/failover_utils.js +10 -9
- package/dist/esm/utils/gemini_schema_util.js +124 -11
- package/dist/esm/utils/id_provider.js +33 -0
- package/dist/esm/utils/model_name.js +14 -0
- package/dist/esm/utils/simple_zod_to_json.js +13 -31
- package/dist/esm/utils/ssrf_guard.js +55 -15
- package/dist/esm/version.js +1 -1
- package/dist/esm/workflow/index.js +2 -1
- package/dist/esm/workflow/node_runner.js +26 -80
- package/dist/esm/workflow/nodes/parallel_worker.js +16 -6
- package/dist/esm/workflow/run_llm_agent_as_node.js +19 -14
- package/dist/esm/workflow/utils/retry_utils.js +2 -2
- package/dist/esm/workflow/workflow.js +12 -12
- package/dist/types/a2a/a2a_remote_agent.d.ts +6 -0
- package/dist/types/a2a/a2a_remote_agent_utils.d.ts +3 -2
- package/dist/types/agents/agent_engine_client.d.ts +121 -3
- package/dist/types/agents/base_agent.d.ts +2 -0
- package/dist/types/agents/processors/content_processor_utils.d.ts +9 -9
- package/dist/types/agents/run_config.d.ts +14 -0
- package/dist/types/cli/cli_eval.d.ts +172 -9
- package/dist/types/cli/utils/cleanup.d.ts +18 -0
- package/dist/types/cli/utils/envs.d.ts +13 -3
- package/dist/types/cli/utils/evals.d.ts +64 -1
- package/dist/types/cli/utils/logs.d.ts +19 -2
- package/dist/types/cli/utils/path_validation.d.ts +30 -0
- package/dist/types/code_executors/container_code_executor.d.ts +49 -8
- package/dist/types/common.d.ts +16 -9
- package/dist/types/context/compaction_utils.d.ts +13 -1
- package/dist/types/events/event.d.ts +3 -0
- package/dist/types/features/feature_registry.d.ts +1 -0
- package/dist/types/index.d.ts +9 -6
- package/dist/types/plugins/base_plugin.d.ts +50 -21
- package/dist/types/plugins/plugin_manager.d.ts +13 -0
- package/dist/types/runner/runner.d.ts +11 -0
- package/dist/types/sessions/base_session_service.d.ts +0 -2
- package/dist/types/sessions/db/operations.d.ts +2 -1
- package/dist/types/sessions/db/schema.d.ts +5 -3
- package/dist/types/telemetry/api/instrumentation.d.ts +259 -0
- package/dist/types/telemetry/api/internal/common/accumulators.d.ts +91 -0
- package/dist/types/telemetry/api/internal/common/attributes.d.ts +90 -0
- package/dist/types/telemetry/api/internal/common/config.d.ts +61 -0
- package/dist/types/telemetry/api/internal/common/error.d.ts +29 -0
- package/dist/types/telemetry/api/internal/common/finish_reason.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/genai_messages.d.ts +26 -0
- package/dist/types/telemetry/api/internal/common/http_exchange.d.ts +50 -0
- package/dist/types/telemetry/api/internal/common/provider_name.d.ts +16 -0
- package/dist/types/telemetry/api/internal/common/redaction.d.ts +14 -0
- package/dist/types/telemetry/api/internal/common/serialization.d.ts +18 -0
- package/dist/types/telemetry/api/internal/common/token_usage.d.ts +47 -0
- package/dist/types/telemetry/api/internal/logs/inference.d.ts +15 -0
- package/dist/types/telemetry/api/internal/logs/logger.d.ts +13 -0
- package/dist/types/telemetry/api/internal/logs/mcp.d.ts +31 -0
- package/dist/types/telemetry/api/internal/metrics/agent.d.ts +28 -0
- package/dist/types/telemetry/api/internal/metrics/inference_start_hook.d.ts +12 -0
- package/dist/types/telemetry/api/internal/metrics/meters.d.ts +57 -0
- package/dist/types/telemetry/api/internal/metrics/tool.d.ts +44 -0
- package/dist/types/telemetry/api/internal/metrics/workflow.d.ts +32 -0
- package/dist/types/telemetry/api/internal/trace/agent.d.ts +14 -0
- package/dist/types/telemetry/api/internal/trace/compaction.d.ts +20 -0
- package/dist/types/telemetry/api/internal/trace/inference.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/live.d.ts +21 -0
- package/dist/types/telemetry/api/internal/trace/node.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/propagation.d.ts +22 -0
- package/dist/types/telemetry/api/internal/trace/tool.d.ts +57 -0
- package/dist/types/telemetry/api/internal/trace/tracer.d.ts +31 -0
- package/dist/types/telemetry/api/internal/trace/workflow.d.ts +21 -0
- package/dist/types/telemetry/export/agent_engine.d.ts +23 -0
- package/dist/types/telemetry/export/agent_runtime.d.ts +40 -0
- package/dist/types/telemetry/export/google_cloud.d.ts +189 -0
- package/dist/types/telemetry/export/request_driven_metric_reader.d.ts +144 -0
- package/dist/types/telemetry/{setup.d.ts → export/setup.d.ts} +3 -0
- package/dist/types/tools/agent_tool.d.ts +1 -1
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +13 -4
- package/dist/types/tools/base_toolset.d.ts +1 -1
- package/dist/types/tools/computer_use/base_computer.d.ts +281 -0
- package/dist/types/tools/computer_use/computer_use_actions.d.ts +53 -0
- package/dist/types/tools/computer_use/computer_use_tool.d.ts +108 -0
- package/dist/types/tools/computer_use/computer_use_toolset.d.ts +132 -0
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +2 -0
- package/dist/types/tools/load_artifacts_tool.d.ts +5 -1
- package/dist/types/tools/load_memory_tool.d.ts +13 -7
- package/dist/types/tools/mcp/mcp_session_manager.d.ts +16 -0
- package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +8 -8
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +7 -3
- package/dist/types/tools/toolbox_toolset.d.ts +15 -20
- package/dist/types/utils/async_queue.d.ts +14 -0
- package/dist/types/utils/env_aware_utils.d.ts +11 -0
- package/dist/types/utils/error_utils.d.ts +4 -0
- package/dist/types/utils/gemini_schema_util.d.ts +27 -6
- package/dist/types/utils/id_provider.d.ts +43 -0
- package/dist/types/utils/model_name.d.ts +8 -0
- package/dist/types/utils/ssrf_guard.d.ts +2 -0
- package/dist/types/version.d.ts +1 -1
- package/dist/types/workflow/index.d.ts +1 -1
- package/dist/types/workflow/nodes/parallel_worker.d.ts +8 -1
- package/dist/web/index_web.js +86 -88
- package/dist/web/index_web.js.map +4 -4
- package/package.json +13 -15
- package/dist/cjs/telemetry/google_cloud.js +0 -116
- package/dist/cjs/telemetry/tracing.js +0 -393
- package/dist/esm/telemetry/google_cloud.js +0 -99
- package/dist/esm/telemetry/setup.js +0 -88
- package/dist/esm/telemetry/tracing.js +0 -361
- package/dist/types/telemetry/google_cloud.d.ts +0 -9
- package/dist/types/telemetry/tracing.d.ts +0 -143
|
@@ -1,88 +0,0 @@
|
|
|
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 2025 Google LLC
|
|
8
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
*/
|
|
10
|
-
import { metrics } from "@opentelemetry/api";
|
|
11
|
-
import { logs } from "@opentelemetry/api-logs";
|
|
12
|
-
import { OTLPLogExporter } from "@opentelemetry/exporter-logs-otlp-http";
|
|
13
|
-
import { OTLPMetricExporter } from "@opentelemetry/exporter-metrics-otlp-http";
|
|
14
|
-
import { OTLPTraceExporter } from "@opentelemetry/exporter-trace-otlp-http";
|
|
15
|
-
import { detectResources } from "@opentelemetry/resources";
|
|
16
|
-
import {
|
|
17
|
-
BatchLogRecordProcessor,
|
|
18
|
-
LoggerProvider
|
|
19
|
-
} from "@opentelemetry/sdk-logs";
|
|
20
|
-
import {
|
|
21
|
-
MeterProvider,
|
|
22
|
-
PeriodicExportingMetricReader
|
|
23
|
-
} from "@opentelemetry/sdk-metrics";
|
|
24
|
-
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
25
|
-
import { NodeTracerProvider } from "@opentelemetry/sdk-trace-node";
|
|
26
|
-
function maybeSetOtelProviders(otelHooksToSetup = [], otelResource) {
|
|
27
|
-
const resource = otelResource || getOtelResource();
|
|
28
|
-
const allHooks = [...otelHooksToSetup, getOtelExporters()];
|
|
29
|
-
const spanProcessors = allHooks.flatMap(
|
|
30
|
-
(hooks) => hooks.spanProcessors || []
|
|
31
|
-
);
|
|
32
|
-
const metricReaders = allHooks.flatMap((hooks) => hooks.metricReaders || []);
|
|
33
|
-
const logRecordProcessors = allHooks.flatMap(
|
|
34
|
-
(hooks) => hooks.logRecordProcessors || []
|
|
35
|
-
);
|
|
36
|
-
if (spanProcessors.length > 0) {
|
|
37
|
-
const tracerProvider = new NodeTracerProvider({
|
|
38
|
-
resource,
|
|
39
|
-
spanProcessors
|
|
40
|
-
});
|
|
41
|
-
tracerProvider.register();
|
|
42
|
-
}
|
|
43
|
-
if (metricReaders.length > 0) {
|
|
44
|
-
const meterProvider = new MeterProvider({
|
|
45
|
-
readers: metricReaders,
|
|
46
|
-
resource
|
|
47
|
-
});
|
|
48
|
-
metrics.setGlobalMeterProvider(meterProvider);
|
|
49
|
-
}
|
|
50
|
-
if (logRecordProcessors.length > 0) {
|
|
51
|
-
const loggerProvider = new LoggerProvider({
|
|
52
|
-
resource,
|
|
53
|
-
processors: logRecordProcessors
|
|
54
|
-
});
|
|
55
|
-
logs.setGlobalLoggerProvider(loggerProvider);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
__name(maybeSetOtelProviders, "maybeSetOtelProviders");
|
|
59
|
-
function getOtelResource() {
|
|
60
|
-
return detectResources({
|
|
61
|
-
detectors: []
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
__name(getOtelResource, "getOtelResource");
|
|
65
|
-
function getOtelExportersConfig() {
|
|
66
|
-
return {
|
|
67
|
-
enableTracing: !!(process.env.OTEL_EXPORTER_OTLP_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_TRACES_ENDPOINT),
|
|
68
|
-
enableMetrics: !!(process.env.OTEL_EXPORTER_OTLP_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_METRICS_ENDPOINT),
|
|
69
|
-
enableLogging: !!(process.env.OTEL_EXPORTER_OTLP_ENDPOINT || process.env.OTEL_EXPORTER_OTLP_LOGS_ENDPOINT)
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
__name(getOtelExportersConfig, "getOtelExportersConfig");
|
|
73
|
-
function getOtelExporters(config = getOtelExportersConfig()) {
|
|
74
|
-
const { enableTracing, enableMetrics, enableLogging } = config;
|
|
75
|
-
return {
|
|
76
|
-
spanProcessors: enableTracing ? [new BatchSpanProcessor(new OTLPTraceExporter())] : [],
|
|
77
|
-
metricReaders: enableMetrics ? [
|
|
78
|
-
new PeriodicExportingMetricReader({
|
|
79
|
-
exporter: new OTLPMetricExporter()
|
|
80
|
-
})
|
|
81
|
-
] : [],
|
|
82
|
-
logRecordProcessors: enableLogging ? [new BatchLogRecordProcessor({ exporter: new OTLPLogExporter() })] : []
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
__name(getOtelExporters, "getOtelExporters");
|
|
86
|
-
export {
|
|
87
|
-
maybeSetOtelProviders
|
|
88
|
-
};
|
|
@@ -1,361 +0,0 @@
|
|
|
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 2025 Google LLC
|
|
8
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
9
|
-
*/
|
|
10
|
-
import { ApiError } from "@google/genai";
|
|
11
|
-
import {
|
|
12
|
-
context,
|
|
13
|
-
SpanStatusCode,
|
|
14
|
-
trace
|
|
15
|
-
} from "@opentelemetry/api";
|
|
16
|
-
import { version } from "../version.js";
|
|
17
|
-
var GenAiAttr = /* @__PURE__ */ ((GenAiAttr2) => {
|
|
18
|
-
GenAiAttr2["AGENT_DESCRIPTION"] = "gen_ai.agent.description";
|
|
19
|
-
GenAiAttr2["AGENT_NAME"] = "gen_ai.agent.name";
|
|
20
|
-
GenAiAttr2["CONVERSATION_ID"] = "gen_ai.conversation.id";
|
|
21
|
-
GenAiAttr2["OPERATION_NAME"] = "gen_ai.operation.name";
|
|
22
|
-
GenAiAttr2["SYSTEM"] = "gen_ai.system";
|
|
23
|
-
GenAiAttr2["TOOL_CALL_ID"] = "gen_ai.tool.call.id";
|
|
24
|
-
GenAiAttr2["TOOL_DESCRIPTION"] = "gen_ai.tool.description";
|
|
25
|
-
GenAiAttr2["TOOL_NAME"] = "gen_ai.tool.name";
|
|
26
|
-
GenAiAttr2["TOOL_TYPE"] = "gen_ai.tool.type";
|
|
27
|
-
GenAiAttr2["REQUEST_MODEL"] = "gen_ai.request.model";
|
|
28
|
-
GenAiAttr2["REQUEST_TOP_P"] = "gen_ai.request.top_p";
|
|
29
|
-
GenAiAttr2["REQUEST_MAX_TOKENS"] = "gen_ai.request.max_tokens";
|
|
30
|
-
GenAiAttr2["USAGE_INPUT_TOKENS"] = "gen_ai.usage.input_tokens";
|
|
31
|
-
GenAiAttr2["USAGE_OUTPUT_TOKENS"] = "gen_ai.usage.output_tokens";
|
|
32
|
-
GenAiAttr2["RESPONSE_FINISH_REASONS"] = "gen_ai.response.finish_reasons";
|
|
33
|
-
return GenAiAttr2;
|
|
34
|
-
})(GenAiAttr || {});
|
|
35
|
-
var AdkAttr = /* @__PURE__ */ ((AdkAttr2) => {
|
|
36
|
-
AdkAttr2["WORKFLOW_NAME"] = "adk.workflow.name";
|
|
37
|
-
AdkAttr2["NODE_PATH"] = "adk.node.path";
|
|
38
|
-
AdkAttr2["NODE_RUN_ID"] = "adk.node.run_id";
|
|
39
|
-
AdkAttr2["NODE_ATTEMPT"] = "adk.node.attempt";
|
|
40
|
-
AdkAttr2["NODE_STATUS"] = "adk.node.status";
|
|
41
|
-
AdkAttr2["NODE_INTERRUPT_COUNT"] = "adk.node.interrupt_count";
|
|
42
|
-
return AdkAttr2;
|
|
43
|
-
})(AdkAttr || {});
|
|
44
|
-
var GcpAttr = /* @__PURE__ */ ((GcpAttr2) => {
|
|
45
|
-
GcpAttr2["INVOCATION_ID"] = "gcp.vertex.agent.invocation_id";
|
|
46
|
-
GcpAttr2["SESSION_ID"] = "gcp.vertex.agent.session_id";
|
|
47
|
-
GcpAttr2["EVENT_ID"] = "gcp.vertex.agent.event_id";
|
|
48
|
-
GcpAttr2["LLM_REQUEST"] = "gcp.vertex.agent.llm_request";
|
|
49
|
-
GcpAttr2["LLM_RESPONSE"] = "gcp.vertex.agent.llm_response";
|
|
50
|
-
GcpAttr2["TOOL_CALL_ARGS"] = "gcp.vertex.agent.tool_call_args";
|
|
51
|
-
GcpAttr2["TOOL_RESPONSE"] = "gcp.vertex.agent.tool_response";
|
|
52
|
-
GcpAttr2["DATA"] = "gcp.vertex.agent.data";
|
|
53
|
-
return GcpAttr2;
|
|
54
|
-
})(GcpAttr || {});
|
|
55
|
-
const GEN_AI_SYSTEM_VALUE = "gcp.vertex.agent";
|
|
56
|
-
const tracer = trace.getTracer(GEN_AI_SYSTEM_VALUE, version);
|
|
57
|
-
function safeJsonSerialize(obj) {
|
|
58
|
-
try {
|
|
59
|
-
return JSON.stringify(obj);
|
|
60
|
-
} catch (_e) {
|
|
61
|
-
return "<not serializable>";
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
__name(safeJsonSerialize, "safeJsonSerialize");
|
|
65
|
-
function traceAgentInvocation({
|
|
66
|
-
agent,
|
|
67
|
-
invocationContext
|
|
68
|
-
}) {
|
|
69
|
-
const span = trace.getActiveSpan();
|
|
70
|
-
if (!span) return;
|
|
71
|
-
span.setAttributes({
|
|
72
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "invoke_agent",
|
|
73
|
-
// Conditionally Required
|
|
74
|
-
["gen_ai.agent.description" /* AGENT_DESCRIPTION */]: agent.description,
|
|
75
|
-
["gen_ai.agent.name" /* AGENT_NAME */]: agent.name,
|
|
76
|
-
["gen_ai.conversation.id" /* CONVERSATION_ID */]: invocationContext.session.id
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
__name(traceAgentInvocation, "traceAgentInvocation");
|
|
80
|
-
function traceWorkflowInvocation({
|
|
81
|
-
workflowName,
|
|
82
|
-
nodePath,
|
|
83
|
-
sessionId
|
|
84
|
-
}) {
|
|
85
|
-
const span = trace.getActiveSpan();
|
|
86
|
-
if (!span) return;
|
|
87
|
-
span.setAttributes({
|
|
88
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "invoke_workflow",
|
|
89
|
-
["gen_ai.conversation.id" /* CONVERSATION_ID */]: sessionId,
|
|
90
|
-
["adk.workflow.name" /* WORKFLOW_NAME */]: workflowName,
|
|
91
|
-
["adk.node.path" /* NODE_PATH */]: nodePath
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
__name(traceWorkflowInvocation, "traceWorkflowInvocation");
|
|
95
|
-
function traceNodeExecution({
|
|
96
|
-
nodePath,
|
|
97
|
-
runId,
|
|
98
|
-
attempt,
|
|
99
|
-
status,
|
|
100
|
-
interruptCount
|
|
101
|
-
}) {
|
|
102
|
-
const span = trace.getActiveSpan();
|
|
103
|
-
if (!span) return;
|
|
104
|
-
span.setAttributes({
|
|
105
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "execute_node",
|
|
106
|
-
["adk.node.path" /* NODE_PATH */]: nodePath,
|
|
107
|
-
["adk.node.run_id" /* NODE_RUN_ID */]: runId,
|
|
108
|
-
["adk.node.attempt" /* NODE_ATTEMPT */]: attempt,
|
|
109
|
-
["adk.node.status" /* NODE_STATUS */]: status,
|
|
110
|
-
["adk.node.interrupt_count" /* NODE_INTERRUPT_COUNT */]: interruptCount
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
__name(traceNodeExecution, "traceNodeExecution");
|
|
114
|
-
function resolveErrorType(error) {
|
|
115
|
-
var _a, _b;
|
|
116
|
-
if (error !== null && (typeof error === "object" || typeof error === "function")) {
|
|
117
|
-
try {
|
|
118
|
-
const errorObject = error;
|
|
119
|
-
const customErrorType = (_a = errorObject.errorType) != null ? _a : errorObject.error_type;
|
|
120
|
-
if (typeof customErrorType === "string" || typeof customErrorType === "number") {
|
|
121
|
-
return String(customErrorType);
|
|
122
|
-
}
|
|
123
|
-
if (error instanceof ApiError) {
|
|
124
|
-
return String(error.status);
|
|
125
|
-
}
|
|
126
|
-
const constructorName = (_b = errorObject.constructor) == null ? void 0 : _b.name;
|
|
127
|
-
if (typeof constructorName === "string" && constructorName.length > 0) {
|
|
128
|
-
return constructorName;
|
|
129
|
-
}
|
|
130
|
-
} catch {
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return typeof error;
|
|
134
|
-
}
|
|
135
|
-
__name(resolveErrorType, "resolveErrorType");
|
|
136
|
-
function traceToolCall(params) {
|
|
137
|
-
var _a, _b, _c;
|
|
138
|
-
const {
|
|
139
|
-
tool,
|
|
140
|
-
args,
|
|
141
|
-
functionResponseEvent,
|
|
142
|
-
invocationContext,
|
|
143
|
-
error,
|
|
144
|
-
errorType
|
|
145
|
-
} = params;
|
|
146
|
-
const span = (_a = params.span) != null ? _a : trace.getActiveSpan();
|
|
147
|
-
if (!span) return;
|
|
148
|
-
const hasError = Object.hasOwn(params, "error");
|
|
149
|
-
const failureType = hasError ? resolveErrorType(error) : errorType;
|
|
150
|
-
if (hasError) {
|
|
151
|
-
let exception;
|
|
152
|
-
try {
|
|
153
|
-
exception = error instanceof Error ? error : resolveErrorType(error);
|
|
154
|
-
} catch {
|
|
155
|
-
exception = resolveErrorType(error);
|
|
156
|
-
}
|
|
157
|
-
span.recordException(exception);
|
|
158
|
-
}
|
|
159
|
-
if (failureType !== void 0) {
|
|
160
|
-
span.setAttribute("error.type", failureType);
|
|
161
|
-
span.setStatus({ code: SpanStatusCode.ERROR, message: failureType });
|
|
162
|
-
}
|
|
163
|
-
span.setAttributes({
|
|
164
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "execute_tool",
|
|
165
|
-
["gen_ai.system" /* SYSTEM */]: GEN_AI_SYSTEM_VALUE,
|
|
166
|
-
["gen_ai.tool.description" /* TOOL_DESCRIPTION */]: tool.description || "",
|
|
167
|
-
["gen_ai.tool.name" /* TOOL_NAME */]: tool.name,
|
|
168
|
-
// e.g. FunctionTool
|
|
169
|
-
["gen_ai.tool.type" /* TOOL_TYPE */]: tool.constructor.name,
|
|
170
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
171
|
-
// Setting empty llm request and response (as UI expect these) while not
|
|
172
|
-
// applicable for tool_response.
|
|
173
|
-
["gcp.vertex.agent.llm_request" /* LLM_REQUEST */]: "{}",
|
|
174
|
-
["gcp.vertex.agent.llm_response" /* LLM_RESPONSE */]: "{}",
|
|
175
|
-
["gcp.vertex.agent.tool_call_args" /* TOOL_CALL_ARGS */]: shouldAddRequestResponseToSpans() ? safeJsonSerialize(args) : "{}"
|
|
176
|
-
});
|
|
177
|
-
let toolCallId = "<not specified>";
|
|
178
|
-
let toolResponse = "<not specified>";
|
|
179
|
-
if ((_b = functionResponseEvent == null ? void 0 : functionResponseEvent.content) == null ? void 0 : _b.parts) {
|
|
180
|
-
const responseParts = functionResponseEvent.content.parts;
|
|
181
|
-
const functionResponse = (_c = responseParts[0]) == null ? void 0 : _c.functionResponse;
|
|
182
|
-
if (functionResponse == null ? void 0 : functionResponse.id) {
|
|
183
|
-
toolCallId = functionResponse.id;
|
|
184
|
-
}
|
|
185
|
-
if (functionResponse == null ? void 0 : functionResponse.response) {
|
|
186
|
-
toolResponse = functionResponse.response;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
if (typeof toolResponse !== "object" || toolResponse === null) {
|
|
190
|
-
toolResponse = { result: toolResponse };
|
|
191
|
-
}
|
|
192
|
-
span.setAttributes({
|
|
193
|
-
["gen_ai.tool.call.id" /* TOOL_CALL_ID */]: toolCallId,
|
|
194
|
-
...functionResponseEvent ? { ["gcp.vertex.agent.event_id" /* EVENT_ID */]: functionResponseEvent.id } : {},
|
|
195
|
-
["gcp.vertex.agent.tool_response" /* TOOL_RESPONSE */]: shouldAddRequestResponseToSpans() ? safeJsonSerialize(toolResponse) : "{}"
|
|
196
|
-
});
|
|
197
|
-
}
|
|
198
|
-
__name(traceToolCall, "traceToolCall");
|
|
199
|
-
function traceMergedToolCalls({
|
|
200
|
-
responseEventId,
|
|
201
|
-
functionResponseEvent,
|
|
202
|
-
invocationContext
|
|
203
|
-
}) {
|
|
204
|
-
const span = trace.getActiveSpan();
|
|
205
|
-
if (!span) return;
|
|
206
|
-
span.setAttributes({
|
|
207
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "execute_tool",
|
|
208
|
-
["gen_ai.system" /* SYSTEM */]: GEN_AI_SYSTEM_VALUE,
|
|
209
|
-
["gen_ai.tool.name" /* TOOL_NAME */]: "(merged tools)",
|
|
210
|
-
["gen_ai.tool.description" /* TOOL_DESCRIPTION */]: "(merged tools)",
|
|
211
|
-
["gen_ai.tool.call.id" /* TOOL_CALL_ID */]: responseEventId,
|
|
212
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
213
|
-
["gcp.vertex.agent.tool_call_args" /* TOOL_CALL_ARGS */]: "N/A",
|
|
214
|
-
["gcp.vertex.agent.event_id" /* EVENT_ID */]: responseEventId,
|
|
215
|
-
// Setting empty llm request and response (as UI expect these) while not
|
|
216
|
-
// applicable for tool_response.
|
|
217
|
-
["gcp.vertex.agent.llm_request" /* LLM_REQUEST */]: "{}",
|
|
218
|
-
["gcp.vertex.agent.llm_response" /* LLM_RESPONSE */]: "{}"
|
|
219
|
-
});
|
|
220
|
-
span.setAttribute(
|
|
221
|
-
"gcp.vertex.agent.tool_response" /* TOOL_RESPONSE */,
|
|
222
|
-
shouldAddRequestResponseToSpans() ? safeJsonSerialize(functionResponseEvent) : "{}"
|
|
223
|
-
);
|
|
224
|
-
}
|
|
225
|
-
__name(traceMergedToolCalls, "traceMergedToolCalls");
|
|
226
|
-
function traceCallLlm({
|
|
227
|
-
invocationContext,
|
|
228
|
-
eventId,
|
|
229
|
-
llmRequest,
|
|
230
|
-
llmResponse
|
|
231
|
-
}) {
|
|
232
|
-
var _a, _b, _c, _d;
|
|
233
|
-
const span = trace.getActiveSpan();
|
|
234
|
-
if (!span) return;
|
|
235
|
-
span.setAttributes({
|
|
236
|
-
["gen_ai.system" /* SYSTEM */]: GEN_AI_SYSTEM_VALUE,
|
|
237
|
-
["gen_ai.request.model" /* REQUEST_MODEL */]: llmRequest.model,
|
|
238
|
-
...((_a = invocationContext.agent) == null ? void 0 : _a.name) ? { ["gen_ai.agent.name" /* AGENT_NAME */]: invocationContext.agent.name } : {},
|
|
239
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
240
|
-
["gcp.vertex.agent.session_id" /* SESSION_ID */]: invocationContext.session.id,
|
|
241
|
-
["gcp.vertex.agent.event_id" /* EVENT_ID */]: eventId,
|
|
242
|
-
// Consider removing once GenAI SDK provides a way to record this info.
|
|
243
|
-
["gcp.vertex.agent.llm_request" /* LLM_REQUEST */]: shouldAddRequestResponseToSpans() ? safeJsonSerialize(buildLlmRequestForTrace(llmRequest)) : "{}"
|
|
244
|
-
});
|
|
245
|
-
if ((_b = llmRequest.config) == null ? void 0 : _b.topP) {
|
|
246
|
-
span.setAttribute("gen_ai.request.top_p" /* REQUEST_TOP_P */, llmRequest.config.topP);
|
|
247
|
-
}
|
|
248
|
-
if (((_c = llmRequest.config) == null ? void 0 : _c.maxOutputTokens) !== void 0) {
|
|
249
|
-
span.setAttribute(
|
|
250
|
-
"gen_ai.request.max_tokens" /* REQUEST_MAX_TOKENS */,
|
|
251
|
-
llmRequest.config.maxOutputTokens
|
|
252
|
-
);
|
|
253
|
-
}
|
|
254
|
-
span.setAttribute(
|
|
255
|
-
"gcp.vertex.agent.llm_response" /* LLM_RESPONSE */,
|
|
256
|
-
shouldAddRequestResponseToSpans() ? safeJsonSerialize(llmResponse) : "{}"
|
|
257
|
-
);
|
|
258
|
-
if (llmResponse.usageMetadata) {
|
|
259
|
-
span.setAttribute(
|
|
260
|
-
"gen_ai.usage.input_tokens" /* USAGE_INPUT_TOKENS */,
|
|
261
|
-
llmResponse.usageMetadata.promptTokenCount || 0
|
|
262
|
-
);
|
|
263
|
-
}
|
|
264
|
-
if ((_d = llmResponse.usageMetadata) == null ? void 0 : _d.candidatesTokenCount) {
|
|
265
|
-
span.setAttribute(
|
|
266
|
-
"gen_ai.usage.output_tokens" /* USAGE_OUTPUT_TOKENS */,
|
|
267
|
-
llmResponse.usageMetadata.candidatesTokenCount
|
|
268
|
-
);
|
|
269
|
-
}
|
|
270
|
-
if (llmResponse.finishReason) {
|
|
271
|
-
const finishReasonValue = typeof llmResponse.finishReason === "string" ? llmResponse.finishReason.toLowerCase() : String(llmResponse.finishReason).toLowerCase();
|
|
272
|
-
span.setAttribute("gen_ai.response.finish_reasons" /* RESPONSE_FINISH_REASONS */, [finishReasonValue]);
|
|
273
|
-
}
|
|
274
|
-
}
|
|
275
|
-
__name(traceCallLlm, "traceCallLlm");
|
|
276
|
-
function traceSendData({
|
|
277
|
-
invocationContext,
|
|
278
|
-
eventId,
|
|
279
|
-
data
|
|
280
|
-
}) {
|
|
281
|
-
const span = trace.getActiveSpan();
|
|
282
|
-
if (!span) return;
|
|
283
|
-
span.setAttributes({
|
|
284
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
285
|
-
["gcp.vertex.agent.event_id" /* EVENT_ID */]: eventId
|
|
286
|
-
});
|
|
287
|
-
span.setAttribute(
|
|
288
|
-
"gcp.vertex.agent.data" /* DATA */,
|
|
289
|
-
shouldAddRequestResponseToSpans() ? safeJsonSerialize(data) : "{}"
|
|
290
|
-
);
|
|
291
|
-
}
|
|
292
|
-
__name(traceSendData, "traceSendData");
|
|
293
|
-
function redactHttpOptions(httpOptions) {
|
|
294
|
-
const redacted = { ...httpOptions };
|
|
295
|
-
delete redacted.headers;
|
|
296
|
-
delete redacted.extraBody;
|
|
297
|
-
return redacted;
|
|
298
|
-
}
|
|
299
|
-
__name(redactHttpOptions, "redactHttpOptions");
|
|
300
|
-
function buildLlmRequestForTrace(llmRequest) {
|
|
301
|
-
const result = {
|
|
302
|
-
model: llmRequest.model,
|
|
303
|
-
contents: []
|
|
304
|
-
};
|
|
305
|
-
if (llmRequest.config) {
|
|
306
|
-
const { responseSchema: _responseSchema, ...cleanConfig } = llmRequest.config;
|
|
307
|
-
if (cleanConfig.httpOptions) {
|
|
308
|
-
cleanConfig.httpOptions = redactHttpOptions(cleanConfig.httpOptions);
|
|
309
|
-
}
|
|
310
|
-
result.config = cleanConfig;
|
|
311
|
-
}
|
|
312
|
-
result.contents = llmRequest.contents.map((content) => {
|
|
313
|
-
var _a;
|
|
314
|
-
return {
|
|
315
|
-
role: content.role,
|
|
316
|
-
parts: ((_a = content.parts) == null ? void 0 : _a.filter((part) => !part.inlineData)) || []
|
|
317
|
-
};
|
|
318
|
-
});
|
|
319
|
-
return result;
|
|
320
|
-
}
|
|
321
|
-
__name(buildLlmRequestForTrace, "buildLlmRequestForTrace");
|
|
322
|
-
function bindOtelContextToAsyncGenerator(ctx, generator) {
|
|
323
|
-
return {
|
|
324
|
-
// Bind the next() method to execute within the provided context
|
|
325
|
-
next: context.bind(ctx, generator.next.bind(generator)),
|
|
326
|
-
// Bind the return() method to execute within the provided context
|
|
327
|
-
return: context.bind(ctx, generator.return.bind(generator)),
|
|
328
|
-
// Bind the throw() method to execute within the provided context
|
|
329
|
-
throw: context.bind(ctx, generator.throw.bind(generator)),
|
|
330
|
-
// Ensure the async iterator symbol also returns a context-bound generator
|
|
331
|
-
[Symbol.asyncIterator]() {
|
|
332
|
-
return bindOtelContextToAsyncGenerator(
|
|
333
|
-
ctx,
|
|
334
|
-
generator[Symbol.asyncIterator]()
|
|
335
|
-
);
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
|
-
}
|
|
339
|
-
__name(bindOtelContextToAsyncGenerator, "bindOtelContextToAsyncGenerator");
|
|
340
|
-
function runAsyncGeneratorWithOtelContext(otelContext, generatorFnContext, generatorFn) {
|
|
341
|
-
const generator = generatorFn.call(generatorFnContext);
|
|
342
|
-
return bindOtelContextToAsyncGenerator(otelContext, generator);
|
|
343
|
-
}
|
|
344
|
-
__name(runAsyncGeneratorWithOtelContext, "runAsyncGeneratorWithOtelContext");
|
|
345
|
-
function shouldAddRequestResponseToSpans() {
|
|
346
|
-
const envValue = process.env.ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS || "true";
|
|
347
|
-
return envValue === "true" || envValue === "1";
|
|
348
|
-
}
|
|
349
|
-
__name(shouldAddRequestResponseToSpans, "shouldAddRequestResponseToSpans");
|
|
350
|
-
export {
|
|
351
|
-
resolveErrorType,
|
|
352
|
-
runAsyncGeneratorWithOtelContext,
|
|
353
|
-
traceAgentInvocation,
|
|
354
|
-
traceCallLlm,
|
|
355
|
-
traceMergedToolCalls,
|
|
356
|
-
traceNodeExecution,
|
|
357
|
-
traceSendData,
|
|
358
|
-
traceToolCall,
|
|
359
|
-
traceWorkflowInvocation,
|
|
360
|
-
tracer
|
|
361
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
import { Resource } from '@opentelemetry/resources';
|
|
7
|
-
import { OtelExportersConfig, OTelHooks } from './setup.js';
|
|
8
|
-
export declare function getGcpExporters(config?: OtelExportersConfig): Promise<OTelHooks>;
|
|
9
|
-
export declare function getGcpResource(): Resource;
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2025 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* NOTE:
|
|
8
|
-
*
|
|
9
|
-
* We expect that the underlying GenAI SDK will provide a certain
|
|
10
|
-
* level of tracing and logging telemetry aligned with Open Telemetry
|
|
11
|
-
* Semantic Conventions (such as logging prompts, responses,
|
|
12
|
-
* request properties, etc.) and so the information that is recorded by the
|
|
13
|
-
* Agent Development Kit should be focused on the higher-level
|
|
14
|
-
* constructs of the framework that are not observable by the SDK.
|
|
15
|
-
*/
|
|
16
|
-
import { Content } from '@google/genai';
|
|
17
|
-
import { Context, Span } from '@opentelemetry/api';
|
|
18
|
-
import { BaseAgent } from '../agents/base_agent.js';
|
|
19
|
-
import { InvocationContext } from '../agents/invocation_context.js';
|
|
20
|
-
import { Event } from '../events/event.js';
|
|
21
|
-
import { LlmRequest } from '../models/llm_request.js';
|
|
22
|
-
import { LlmResponse } from '../models/llm_response.js';
|
|
23
|
-
import { BaseTool } from '../tools/base_tool.js';
|
|
24
|
-
export declare const tracer: import("@opentelemetry/api").Tracer;
|
|
25
|
-
export interface TraceAgentInvocationParams {
|
|
26
|
-
agent: BaseAgent;
|
|
27
|
-
invocationContext: InvocationContext;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Sets span attributes immediately available on agent invocation according to OTEL semconv version 1.37.
|
|
31
|
-
*
|
|
32
|
-
* @param params The parameters object containing agent and invocation context.
|
|
33
|
-
*
|
|
34
|
-
* Inference related fields are not set, due to their planned removal from invoke_agent span:
|
|
35
|
-
* https://github.com/open-telemetry/semantic-conventions/issues/2632
|
|
36
|
-
*
|
|
37
|
-
* `gen_ai.agent.id` is not set because currently it's unclear what attributes this field should have, specifically:
|
|
38
|
-
* - In which scope should it be unique (globally, given project, given agentic flow, given deployment).
|
|
39
|
-
* - Should it be unchanging between deployments, and how this should this be achieved.
|
|
40
|
-
*
|
|
41
|
-
* `gen_ai.data_source.id` is not set because it's not available.
|
|
42
|
-
* Closest type which could contain this information is types.GroundingMetadata, which does not have an ID.
|
|
43
|
-
*
|
|
44
|
-
* `server.*` attributes are not set pending confirmation from aabmass.
|
|
45
|
-
*/
|
|
46
|
-
export declare function traceAgentInvocation({ agent, invocationContext, }: TraceAgentInvocationParams): void;
|
|
47
|
-
export interface TraceWorkflowInvocationParams {
|
|
48
|
-
workflowName: string;
|
|
49
|
-
nodePath: string;
|
|
50
|
-
sessionId: string;
|
|
51
|
-
}
|
|
52
|
-
export declare function traceWorkflowInvocation({ workflowName, nodePath, sessionId, }: TraceWorkflowInvocationParams): void;
|
|
53
|
-
export type NodeExecutionStatus = 'completed' | 'waiting' | 'failed';
|
|
54
|
-
export interface TraceNodeExecutionParams {
|
|
55
|
-
nodePath: string;
|
|
56
|
-
runId: string;
|
|
57
|
-
attempt: number;
|
|
58
|
-
status: NodeExecutionStatus;
|
|
59
|
-
interruptCount: number;
|
|
60
|
-
}
|
|
61
|
-
export declare function traceNodeExecution({ nodePath, runId, attempt, status, interruptCount, }: TraceNodeExecutionParams): void;
|
|
62
|
-
export interface TraceToolCallParams {
|
|
63
|
-
tool: BaseTool;
|
|
64
|
-
args: Record<string, unknown>;
|
|
65
|
-
functionResponseEvent?: Event;
|
|
66
|
-
/** The exception raised while executing the tool, if any. */
|
|
67
|
-
error?: unknown;
|
|
68
|
-
/** An error type reported by a tool response instead of a thrown error. */
|
|
69
|
-
errorType?: string;
|
|
70
|
-
/** The tool execution span. Defaults to the active span when omitted. */
|
|
71
|
-
span?: Span;
|
|
72
|
-
invocationContext: InvocationContext;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Resolves a stable error classification suitable for the OpenTelemetry
|
|
76
|
-
* `error.type` attribute without using the potentially sensitive error message.
|
|
77
|
-
*
|
|
78
|
-
* @param error The thrown value.
|
|
79
|
-
* @returns The explicit ADK error type, GenAI API status, or error class name.
|
|
80
|
-
*/
|
|
81
|
-
export declare function resolveErrorType(error: unknown): string;
|
|
82
|
-
/**
|
|
83
|
-
* Traces tool call.
|
|
84
|
-
*
|
|
85
|
-
* @param params The parameters object containing tool, args, and function response event.
|
|
86
|
-
*/
|
|
87
|
-
export declare function traceToolCall(params: TraceToolCallParams): void;
|
|
88
|
-
export interface TraceMergedToolCallsParams {
|
|
89
|
-
responseEventId: string;
|
|
90
|
-
functionResponseEvent: Event;
|
|
91
|
-
invocationContext: InvocationContext;
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Traces merged tool call events.
|
|
95
|
-
*
|
|
96
|
-
* Calling this function is not needed for telemetry purposes. This is provided
|
|
97
|
-
* for preventing /debug/trace requests (typically sent by web UI).
|
|
98
|
-
*
|
|
99
|
-
* @param params The parameters object containing response event ID and function response event.
|
|
100
|
-
*/
|
|
101
|
-
export declare function traceMergedToolCalls({ responseEventId, functionResponseEvent, invocationContext, }: TraceMergedToolCallsParams): void;
|
|
102
|
-
export interface TraceCallLlmParams {
|
|
103
|
-
invocationContext: InvocationContext;
|
|
104
|
-
eventId: string;
|
|
105
|
-
llmRequest: LlmRequest;
|
|
106
|
-
llmResponse: LlmResponse;
|
|
107
|
-
}
|
|
108
|
-
/**
|
|
109
|
-
* Traces a call to the LLM.
|
|
110
|
-
*
|
|
111
|
-
* This function records details about the LLM request and response as
|
|
112
|
-
* attributes on the current OpenTelemetry span.
|
|
113
|
-
*
|
|
114
|
-
* @param params The parameters object containing invocationContext, eventId, llmRequest, and llmResponse.
|
|
115
|
-
*/
|
|
116
|
-
export declare function traceCallLlm({ invocationContext, eventId, llmRequest, llmResponse, }: TraceCallLlmParams): void;
|
|
117
|
-
export interface TraceSendDataParams {
|
|
118
|
-
/** The invocation context for the current agent run. */
|
|
119
|
-
invocationContext: InvocationContext;
|
|
120
|
-
/** The ID of the event. */
|
|
121
|
-
eventId: string;
|
|
122
|
-
/** A list of content objects. */
|
|
123
|
-
data: Content[];
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Traces the sending of data to the agent.
|
|
127
|
-
*
|
|
128
|
-
* This function records details about the data sent to the agent as
|
|
129
|
-
* attributes on the current OpenTelemetry span.
|
|
130
|
-
*
|
|
131
|
-
* @param params The parameters object containing invocationContext, eventId, and data.
|
|
132
|
-
*/
|
|
133
|
-
export declare function traceSendData({ invocationContext, eventId, data, }: TraceSendDataParams): void;
|
|
134
|
-
/**
|
|
135
|
-
* Runs an async generator function with both OTEL context and JavaScript 'this' context.
|
|
136
|
-
*
|
|
137
|
-
* @param otelContext - The OpenTelemetry context to bind the generator to
|
|
138
|
-
* @param generatorFnContext - The 'this' context to bind to the generator function
|
|
139
|
-
* @param generatorFn - The generator function to execute
|
|
140
|
-
*
|
|
141
|
-
* @returns A new async generator that executes within both contexts
|
|
142
|
-
*/
|
|
143
|
-
export declare function runAsyncGeneratorWithOtelContext<TThis, T>(otelContext: Context, generatorFnContext: TThis, generatorFn: (this: TThis) => AsyncGenerator<T, void, void>): AsyncGenerator<T, void, void>;
|