@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
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** OpenTelemetry GenAI semantic-convention attribute keys. */
|
|
7
|
+
export declare enum GenAiAttr {
|
|
8
|
+
AGENT_DESCRIPTION = "gen_ai.agent.description",
|
|
9
|
+
AGENT_NAME = "gen_ai.agent.name",
|
|
10
|
+
CONVERSATION_ID = "gen_ai.conversation.id",
|
|
11
|
+
OPERATION_NAME = "gen_ai.operation.name",
|
|
12
|
+
PROVIDER_NAME = "gen_ai.provider.name",
|
|
13
|
+
SYSTEM = "gen_ai.system",
|
|
14
|
+
WORKFLOW_NAME = "gen_ai.workflow.name",
|
|
15
|
+
WORKFLOW_NESTED = "gen_ai.workflow.nested",
|
|
16
|
+
TOOL_CALL_ID = "gen_ai.tool.call.id",
|
|
17
|
+
TOOL_CALL_ARGUMENTS = "gen_ai.tool.call.arguments",
|
|
18
|
+
TOOL_CALL_RESULT = "gen_ai.tool.call.result",
|
|
19
|
+
TOOL_DEFINITIONS = "gen_ai.tool.definitions",
|
|
20
|
+
TOOL_DESCRIPTION = "gen_ai.tool.description",
|
|
21
|
+
TOOL_NAME = "gen_ai.tool.name",
|
|
22
|
+
TOOL_TYPE = "gen_ai.tool.type",
|
|
23
|
+
REQUEST_MODEL = "gen_ai.request.model",
|
|
24
|
+
REQUEST_TOP_P = "gen_ai.request.top_p",
|
|
25
|
+
REQUEST_MAX_TOKENS = "gen_ai.request.max_tokens",
|
|
26
|
+
RESPONSE_FINISH_REASONS = "gen_ai.response.finish_reasons",
|
|
27
|
+
INPUT_MESSAGES = "gen_ai.input.messages",
|
|
28
|
+
OUTPUT_MESSAGES = "gen_ai.output.messages",
|
|
29
|
+
SYSTEM_INSTRUCTIONS = "gen_ai.system_instructions",
|
|
30
|
+
USAGE_INPUT_TOKENS = "gen_ai.usage.input_tokens",
|
|
31
|
+
USAGE_OUTPUT_TOKENS = "gen_ai.usage.output_tokens",
|
|
32
|
+
USAGE_CACHE_READ_INPUT_TOKENS = "gen_ai.usage.cache_read.input_tokens",
|
|
33
|
+
USAGE_REASONING_OUTPUT_TOKENS = "gen_ai.usage.reasoning.output_tokens",
|
|
34
|
+
SKILL_NAME = "gen_ai.skill.name",
|
|
35
|
+
SKILL_DESCRIPTION = "gen_ai.skill.description",
|
|
36
|
+
SKILL_RESOURCE_NAME = "gen_ai.skill.resource.name",
|
|
37
|
+
COMPACTION_TRIGGER = "gen_ai.compaction.trigger",
|
|
38
|
+
COMPACTION_EVENT_COUNT = "gen_ai.compaction.event_count",
|
|
39
|
+
COMPACTION_RESULT_EVENT_ID = "gen_ai.compaction.result_event_id",
|
|
40
|
+
COMPACTION_START_TIMESTAMP = "gen_ai.compaction.start_timestamp",
|
|
41
|
+
COMPACTION_END_TIMESTAMP = "gen_ai.compaction.end_timestamp"
|
|
42
|
+
}
|
|
43
|
+
/** ADK-specific attribute keys outside the GenAI semantic conventions. */
|
|
44
|
+
export declare enum AdkAttr {
|
|
45
|
+
SKILL_ADDITIONAL_TOOLS = "adk.skill.additional_tools",
|
|
46
|
+
EXPERIMENTAL_ROOT_AGENT_NAME = "adk.experimental.root_agent.name",
|
|
47
|
+
EXPERIMENTAL_GROUNDING_QUERY_COUNT = "adk.experimental.grounding.query_count",
|
|
48
|
+
EXPERIMENTAL_GROUNDING_CHUNK_COUNT = "adk.experimental.grounding.chunk_count",
|
|
49
|
+
EXPERIMENTAL_GROUNDING_WEB_SEARCH_QUERIES = "adk.experimental.grounding.web_search_queries",
|
|
50
|
+
EXPERIMENTAL_GROUNDING_SOURCE_URIS = "adk.experimental.grounding.source_uris"
|
|
51
|
+
}
|
|
52
|
+
/** GCP Vertex agent attribute keys, consumed by the Vertex trace UI. */
|
|
53
|
+
export declare enum GcpAttr {
|
|
54
|
+
INVOCATION_ID = "gcp.vertex.agent.invocation_id",
|
|
55
|
+
EVENT_ID = "gcp.vertex.agent.event_id",
|
|
56
|
+
ASSOCIATED_EVENT_IDS = "gcp.vertex.agent.associated_event_ids",
|
|
57
|
+
DATA = "gcp.vertex.agent.data"
|
|
58
|
+
}
|
|
59
|
+
/** OpenTelemetry HTTP client semantic-convention keys. */
|
|
60
|
+
export declare enum HttpAttr {
|
|
61
|
+
REQUEST_METHOD = "http.request.method",
|
|
62
|
+
RESPONSE_STATUS_CODE = "http.response.status_code",
|
|
63
|
+
REQUEST_BODY_CONTENT = "http.request.body.content",
|
|
64
|
+
RESPONSE_BODY_CONTENT = "http.response.body.content",
|
|
65
|
+
/** Prefix of `http.request.header.<lowercased name>`. */
|
|
66
|
+
REQUEST_HEADER_PREFIX = "http.request.header.",
|
|
67
|
+
/** Prefix of `http.response.header.<lowercased name>`. */
|
|
68
|
+
RESPONSE_HEADER_PREFIX = "http.response.header.",
|
|
69
|
+
URL_FULL = "url.full",
|
|
70
|
+
SERVER_ADDRESS = "server.address",
|
|
71
|
+
SERVER_PORT = "server.port"
|
|
72
|
+
}
|
|
73
|
+
/** OpenTelemetry MCP semantic-convention keys. */
|
|
74
|
+
export declare enum McpAttr {
|
|
75
|
+
SESSION_ID = "mcp.session.id",
|
|
76
|
+
PROTOCOL_VERSION = "mcp.protocol.version"
|
|
77
|
+
}
|
|
78
|
+
/** Standard OpenTelemetry error classification attribute key. */
|
|
79
|
+
export declare const ERROR_TYPE_ATTR = "error.type";
|
|
80
|
+
/** Standard OpenTelemetry end-user identifier attribute key. */
|
|
81
|
+
export declare const USER_ID_ATTR = "user.id";
|
|
82
|
+
/**
|
|
83
|
+
* Attribute on the top span of a trace that holds the caller's `traceparent`
|
|
84
|
+
* header, so a support request can be matched to the trace.
|
|
85
|
+
*/
|
|
86
|
+
export declare const SUPPORT_ID_ATTR = "supportID";
|
|
87
|
+
/** Instrumentation scope name identifying ADK as the emitter. */
|
|
88
|
+
export declare const GEN_AI_SYSTEM_VALUE = "gcp.vertex.agent";
|
|
89
|
+
/** Schema URL of the OpenTelemetry semantic conventions ADK emits. */
|
|
90
|
+
export declare const SCHEMA_URL = "https://opentelemetry.io/schemas/1.44.0";
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Where GenAI message content is recorded, as named by
|
|
8
|
+
* `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT`.
|
|
9
|
+
*/
|
|
10
|
+
export type ContentCapturingMode = 'NO_CONTENT' | 'EVENT_ONLY' | 'SPAN_ONLY' | 'SPAN_AND_EVENT';
|
|
11
|
+
/** A named group of experimental telemetry that can be enabled on its own. */
|
|
12
|
+
export type ExperimentalFeature = 'skills' | 'workflow' | 'context_cache' | 'grounding' | 'mcp' | 'token_usage' | 'compaction';
|
|
13
|
+
/**
|
|
14
|
+
* Per-run telemetry overrides, set through `RunConfig.telemetry`.
|
|
15
|
+
*
|
|
16
|
+
* A field left unset falls back to the environment variable it overrides.
|
|
17
|
+
* When `ADK_TELEMETRY_IGNORE_RUN_CONFIG` is `true` or `1`, every field is
|
|
18
|
+
* ignored and the environment decides.
|
|
19
|
+
*/
|
|
20
|
+
export interface TelemetryConfig {
|
|
21
|
+
/** Overrides `OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT`. */
|
|
22
|
+
readonly captureMessageContent?: ContentCapturingMode;
|
|
23
|
+
/**
|
|
24
|
+
* Overrides `ADK_EXPERIMENTAL_TELEMETRY`. `true` enables every experimental
|
|
25
|
+
* feature for the run, and `false` disables every one, including those named
|
|
26
|
+
* in `ADK_EXPERIMENTAL_TELEMETRY_FEATURES` or `experimentalFeaturesOptIn`.
|
|
27
|
+
*/
|
|
28
|
+
readonly adkExperimentalTelemetryOptIn?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Overrides `ADK_EXPERIMENTAL_TELEMETRY_FEATURES`: exactly these features
|
|
31
|
+
* are enabled for the run. Unrecognized names are ignored, and a list with
|
|
32
|
+
* no recognized name falls back to the environment.
|
|
33
|
+
*/
|
|
34
|
+
readonly experimentalFeaturesOptIn?: readonly ExperimentalFeature[];
|
|
35
|
+
}
|
|
36
|
+
/** The telemetry decisions for one scope. */
|
|
37
|
+
export interface ResolvedTelemetryConfig {
|
|
38
|
+
/** Where message content is recorded. */
|
|
39
|
+
readonly contentCapturingMode: ContentCapturingMode;
|
|
40
|
+
/** Whether every experimental feature is enabled. */
|
|
41
|
+
readonly experimentalTelemetry: boolean;
|
|
42
|
+
/** Features enabled one by one. */
|
|
43
|
+
readonly experimentalFeatures: ReadonlySet<ExperimentalFeature>;
|
|
44
|
+
}
|
|
45
|
+
/** Whether an environment variable is `true` or `1`, ignoring case and spaces. */
|
|
46
|
+
export declare function isTruthyEnv(name: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Resolves the telemetry configuration of one scope.
|
|
49
|
+
*
|
|
50
|
+
* Each value comes from `overrides` when it sets it, else from its environment
|
|
51
|
+
* variable, else from its default. `ADK_TELEMETRY_IGNORE_RUN_CONFIG` makes the
|
|
52
|
+
* environment win over every override. The environment is read on each call
|
|
53
|
+
* rather than at import, so a change to it applies to the next scope.
|
|
54
|
+
*/
|
|
55
|
+
export declare function resolveTelemetryConfig(overrides?: TelemetryConfig): ResolvedTelemetryConfig;
|
|
56
|
+
/** Whether message content goes on log records (`EVENT_ONLY`, `SPAN_AND_EVENT`). */
|
|
57
|
+
export declare function shouldAddContentToLogs(config: ResolvedTelemetryConfig): boolean;
|
|
58
|
+
/** Whether message content goes on spans (`SPAN_ONLY`, `SPAN_AND_EVENT`). */
|
|
59
|
+
export declare function shouldAddContentToSpans(config: ResolvedTelemetryConfig): boolean;
|
|
60
|
+
/** Whether the named experimental feature is enabled. */
|
|
61
|
+
export declare function isExperimentalFeatureEnabled(config: ResolvedTelemetryConfig, feature: ExperimentalFeature): boolean;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Normalizes a candidate error classification by trimming strings and
|
|
8
|
+
* stringifying finite numbers.
|
|
9
|
+
*
|
|
10
|
+
* @param value The candidate classification value.
|
|
11
|
+
* @returns The non-empty trimmed classification string, or undefined if invalid.
|
|
12
|
+
*/
|
|
13
|
+
export declare function normalizeErrorClassification(value: unknown): string | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves a stable error classification suitable for the OpenTelemetry
|
|
16
|
+
* `error.type` attribute without using the potentially sensitive error message.
|
|
17
|
+
*
|
|
18
|
+
* @param error The thrown value.
|
|
19
|
+
* @returns The explicit ADK error type, GenAI API status, or error class name.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveErrorType(error: unknown): string;
|
|
22
|
+
/**
|
|
23
|
+
* Gets an explicitly reported error type from a tool response object.
|
|
24
|
+
*
|
|
25
|
+
* Tools may return an error payload instead of throwing. Only the dedicated
|
|
26
|
+
* error type or error code field is copied to telemetry; the payload itself is
|
|
27
|
+
* never used as the error classification.
|
|
28
|
+
*/
|
|
29
|
+
export declare function getToolResponseErrorType(result: unknown): string | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { FinishReason } from '@google/genai';
|
|
7
|
+
/**
|
|
8
|
+
* Whether the model reported why generation stopped.
|
|
9
|
+
*
|
|
10
|
+
* The unspecified value is the proto3 zero value, so a response that carries
|
|
11
|
+
* it has not reported a reason.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isReportedFinishReason(finishReason: FinishReason | undefined): finishReason is FinishReason;
|
|
14
|
+
/**
|
|
15
|
+
* Maps a finish reason to the `finish_reason` of a GenAI output message, or
|
|
16
|
+
* `''` when none was reported.
|
|
17
|
+
*/
|
|
18
|
+
export declare function toOutputMessageFinishReason(finishReason: FinishReason | undefined): string;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { AnyValue, AnyValueMap } from '@opentelemetry/api-logs';
|
|
7
|
+
import type { LlmRequest } from '../../../../models/llm_request.js';
|
|
8
|
+
import type { LlmResponse } from '../../../../models/llm_response.js';
|
|
9
|
+
import { GenAiAttr } from './attributes.js';
|
|
10
|
+
/** Message content and tool definitions of one model call, by attribute key. */
|
|
11
|
+
export type OperationDetails = Partial<Record<GenAiAttr.INPUT_MESSAGES | GenAiAttr.OUTPUT_MESSAGES | GenAiAttr.SYSTEM_INSTRUCTIONS | GenAiAttr.TOOL_DEFINITIONS, AnyValue[]>>;
|
|
12
|
+
/**
|
|
13
|
+
* Builds the operation details a model request contributes: input messages,
|
|
14
|
+
* system instructions and tool definitions.
|
|
15
|
+
*/
|
|
16
|
+
export declare function buildRequestOperationDetails(llmRequest: LlmRequest): OperationDetails;
|
|
17
|
+
/**
|
|
18
|
+
* Builds the output message for one model response, or `undefined` when it
|
|
19
|
+
* carries no content.
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildOutputMessage(llmResponse: LlmResponse): AnyValueMap | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* Returns the view of the operation details that carries no message content:
|
|
24
|
+
* the tool definitions without their parameter schemas.
|
|
25
|
+
*/
|
|
26
|
+
export declare function withoutContent(details: OperationDetails): OperationDetails;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/** One HTTP request and its response, made safe to record. */
|
|
7
|
+
export interface HttpExchange {
|
|
8
|
+
/** The request method, in upper case. */
|
|
9
|
+
readonly method: string;
|
|
10
|
+
/** The request URL without userinfo, with every query value redacted. */
|
|
11
|
+
readonly url: string;
|
|
12
|
+
/** The URL host name, without IPv6 brackets. */
|
|
13
|
+
readonly serverAddress: string;
|
|
14
|
+
/** The URL port, when the URL names one. */
|
|
15
|
+
readonly serverPort?: number;
|
|
16
|
+
/** The `sessionId` or `session_id` query value of the request URL. */
|
|
17
|
+
readonly querySessionId?: string;
|
|
18
|
+
readonly statusCode: number;
|
|
19
|
+
/** Request headers by lowercased name, with credentials redacted. */
|
|
20
|
+
readonly requestHeaders: ReadonlyMap<string, string>;
|
|
21
|
+
/** Response headers by lowercased name, with credentials redacted. */
|
|
22
|
+
readonly responseHeaders: ReadonlyMap<string, string>;
|
|
23
|
+
/**
|
|
24
|
+
* The request body, truncated. Absent when bodies are not captured, or when
|
|
25
|
+
* the body cannot be read without consuming it.
|
|
26
|
+
*/
|
|
27
|
+
readonly requestBody?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The response body, truncated, or a marker for a body that is not read.
|
|
30
|
+
* Absent when bodies are not captured.
|
|
31
|
+
*/
|
|
32
|
+
readonly responseBody?: string;
|
|
33
|
+
}
|
|
34
|
+
/** Parameters for {@link captureHttpExchange}. */
|
|
35
|
+
export interface CaptureHttpExchangeParams {
|
|
36
|
+
readonly url: string | URL;
|
|
37
|
+
readonly init?: Parameters<typeof fetch>[1];
|
|
38
|
+
readonly response: Response;
|
|
39
|
+
/** Whether to read the request and response bodies. */
|
|
40
|
+
readonly captureBodies: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Captures one HTTP exchange for recording.
|
|
44
|
+
*
|
|
45
|
+
* Everything it needs from `response` is taken before it returns, so the
|
|
46
|
+
* caller may hand the response on as soon as this returns: the response body
|
|
47
|
+
* is read from a clone in the background, and never for an event stream,
|
|
48
|
+
* which does not end.
|
|
49
|
+
*/
|
|
50
|
+
export declare function captureHttpExchange({ url, init, response, captureBodies, }: CaptureHttpExchangeParams): Promise<HttpExchange>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Returns the `gen_ai.system` name of the Gemini backend in use.
|
|
8
|
+
*/
|
|
9
|
+
export declare function guessGeminiSystemName(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the `gen_ai.provider.name` of the provider serving `model`.
|
|
12
|
+
*
|
|
13
|
+
* A `<provider>/<model>` id names its provider in the prefix. Otherwise, and
|
|
14
|
+
* for Gemini models, the name follows the Gemini backend in use.
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveProviderName(model: string | undefined): string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Returns a copy of a JSON-like payload with credential secrets removed.
|
|
8
|
+
*
|
|
9
|
+
* Removes the secret fields of anything shaped like an auth credential or auth
|
|
10
|
+
* config, wherever it is nested: a credential object, the arguments and
|
|
11
|
+
* response of a credential request, and the credential-carrying fields of
|
|
12
|
+
* event actions.
|
|
13
|
+
*/
|
|
14
|
+
export declare function redactCredentialSecrets(value: unknown): unknown;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Convert any JavaScript object to a JSON-serializable string.
|
|
8
|
+
*
|
|
9
|
+
* @param obj The object to serialize.
|
|
10
|
+
* @returns The JSON-serialized object string or '<not serializable>' if the object cannot be serialized.
|
|
11
|
+
*/
|
|
12
|
+
export declare function safeJsonSerialize(obj: unknown): string;
|
|
13
|
+
/**
|
|
14
|
+
* Determines whether to add live request content to the `send_data` span.
|
|
15
|
+
*
|
|
16
|
+
* @returns false only when ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS is explicitly set to 'false' or '0'
|
|
17
|
+
*/
|
|
18
|
+
export declare function shouldAddRequestResponseToSpans(): boolean;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { GenerateContentResponseUsageMetadata } from '@google/genai';
|
|
7
|
+
import type { Attributes } from '@opentelemetry/api';
|
|
8
|
+
/** Description of the `input_tokens` metric bucket. */
|
|
9
|
+
export declare const INPUT_TOKENS_MEANING: string;
|
|
10
|
+
/** Description of the `output_tokens` metric bucket. */
|
|
11
|
+
export declare const OUTPUT_TOKENS_MEANING: string;
|
|
12
|
+
/** Description of the `total_tokens` metric bucket. */
|
|
13
|
+
export declare const TOTAL_TOKENS_MEANING: string;
|
|
14
|
+
/** Description of the `cache_read.input_tokens` metric bucket. */
|
|
15
|
+
export declare const CACHE_READ_INPUT_TOKENS_MEANING = "Input tokens served from a provider-managed cache.";
|
|
16
|
+
/** Description of the `reasoning.output_tokens` metric bucket. */
|
|
17
|
+
export declare const REASONING_OUTPUT_TOKENS_MEANING = "Output tokens spent on reasoning (chain-of-thought / extended thinking).";
|
|
18
|
+
/** Description of the `tool.input_tokens` metric bucket. */
|
|
19
|
+
export declare const TOOL_INPUT_TOKENS_MEANING: string;
|
|
20
|
+
/**
|
|
21
|
+
* GenAI token usage, either one model call's or a sum over several.
|
|
22
|
+
*
|
|
23
|
+
* Input tokens sum the prompt and server-side tool results; output tokens sum
|
|
24
|
+
* candidates and reasoning. A bucket that nothing reported is `undefined`
|
|
25
|
+
* rather than zero: {@link asAttributes} omits it and {@link add} keeps it
|
|
26
|
+
* `undefined` until some call reports it.
|
|
27
|
+
*/
|
|
28
|
+
export declare class TokenUsage {
|
|
29
|
+
input?: number;
|
|
30
|
+
output?: number;
|
|
31
|
+
cacheRead?: number;
|
|
32
|
+
reasoning?: number;
|
|
33
|
+
toolInput?: number;
|
|
34
|
+
constructor(usage?: GenerateContentResponseUsageMetadata);
|
|
35
|
+
/** Folds another call's usage into these totals, bucket by bucket. */
|
|
36
|
+
add(other: TokenUsage): void;
|
|
37
|
+
/**
|
|
38
|
+
* Input plus output tokens, derived from those two rather than taken from
|
|
39
|
+
* the model-reported total.
|
|
40
|
+
*/
|
|
41
|
+
totalTokenUsage(): number;
|
|
42
|
+
/**
|
|
43
|
+
* Returns the GenAI token usage attributes for the reported buckets,
|
|
44
|
+
* omitting `undefined` buckets and preserving `0`.
|
|
45
|
+
*/
|
|
46
|
+
asAttributes(): Attributes;
|
|
47
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type Span } from '@opentelemetry/api';
|
|
7
|
+
import type { LogAttributes } from '@opentelemetry/api-logs';
|
|
8
|
+
/**
|
|
9
|
+
* Emits the `gen_ai.client.inference.operation.details` record of one model
|
|
10
|
+
* call, parented to its `generate_content` span.
|
|
11
|
+
*
|
|
12
|
+
* The span is named explicitly rather than taken from the active context,
|
|
13
|
+
* which need not hold it when the call ends.
|
|
14
|
+
*/
|
|
15
|
+
export declare function emitInferenceOperationDetails(span: Span, attributes: LogAttributes): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type Logger } from '@opentelemetry/api-logs';
|
|
7
|
+
/**
|
|
8
|
+
* Returns the ADK logger from the global `LoggerProvider`.
|
|
9
|
+
*
|
|
10
|
+
* Resolved on every call rather than once at import, so records reach a
|
|
11
|
+
* provider the application registers after importing ADK.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getTelemetryLogger(): Logger;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Context } from '@opentelemetry/api';
|
|
7
|
+
/** What to record about MCP HTTP exchanges, read from the environment. */
|
|
8
|
+
export interface McpHttpExchangeSettings {
|
|
9
|
+
readonly captureBodies: boolean;
|
|
10
|
+
readonly requestHeaderPatterns: readonly RegExp[];
|
|
11
|
+
readonly responseHeaderPatterns: readonly RegExp[];
|
|
12
|
+
}
|
|
13
|
+
/** Reads the MCP HTTP exchange settings from the environment. */
|
|
14
|
+
export declare function readMcpHttpExchangeSettings(): McpHttpExchangeSettings;
|
|
15
|
+
/** Parameters for {@link reportMcpHttpExchange}. */
|
|
16
|
+
export interface ReportMcpHttpExchangeParams {
|
|
17
|
+
readonly url: string | URL;
|
|
18
|
+
readonly init?: Parameters<typeof fetch>[1];
|
|
19
|
+
readonly response: Response;
|
|
20
|
+
readonly settings: McpHttpExchangeSettings;
|
|
21
|
+
/** The context the request was sent in, which parents the record. */
|
|
22
|
+
readonly context: Context;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Emits the `adk.experimental.mcp.http.client.response.end` record of one MCP
|
|
26
|
+
* HTTP exchange.
|
|
27
|
+
*
|
|
28
|
+
* Takes what it needs from `response` before its first await, so the caller
|
|
29
|
+
* can hand the response on at once and leave the returned promise running.
|
|
30
|
+
*/
|
|
31
|
+
export declare function reportMcpHttpExchange({ url, init, response, settings, context, }: ReportMcpHttpExchangeParams): Promise<void>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Totals } from '../common/accumulators.js';
|
|
7
|
+
import { type ResolvedTelemetryConfig } from '../common/config.js';
|
|
8
|
+
/** Advisory bucket boundaries for `gen_ai.invoke_agent.duration`. */
|
|
9
|
+
export declare const AGENT_DURATION_BUCKETS: readonly number[];
|
|
10
|
+
/** Parameters for {@link recordAgentDuration}. */
|
|
11
|
+
export interface RecordAgentDurationParams {
|
|
12
|
+
readonly agentName: string;
|
|
13
|
+
readonly durationSeconds: number;
|
|
14
|
+
readonly errorType?: string;
|
|
15
|
+
}
|
|
16
|
+
/** Records `gen_ai.invoke_agent.duration` at the end of an agent invocation. */
|
|
17
|
+
export declare function recordAgentDuration({ agentName, durationSeconds, errorType, }: RecordAgentDurationParams): void;
|
|
18
|
+
/** Parameters for {@link recordAgentTotals}. */
|
|
19
|
+
export interface RecordAgentTotalsParams {
|
|
20
|
+
readonly agentName: string;
|
|
21
|
+
readonly totals: Totals;
|
|
22
|
+
readonly config: ResolvedTelemetryConfig;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Records the per-agent call, skill-load, and token totals accumulated over
|
|
26
|
+
* one agent invocation.
|
|
27
|
+
*/
|
|
28
|
+
export declare function recordAgentTotals({ agentName, totals, config, }: RecordAgentTotalsParams): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Tells the installed metric reader, if any, that a model call has started.
|
|
8
|
+
*
|
|
9
|
+
* Never throws: a failure in the hook is logged and does not reach the model
|
|
10
|
+
* call that triggered it.
|
|
11
|
+
*/
|
|
12
|
+
export declare function notifyInferenceStart(): void;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import { type Attributes, type Histogram, type Meter } from '@opentelemetry/api';
|
|
7
|
+
import { type TokenUsage } from '../common/token_usage.js';
|
|
8
|
+
/**
|
|
9
|
+
* Advisory bucket boundaries for per-invocation and per-workflow call-count
|
|
10
|
+
* histograms. Upper-inclusive, so the leading `0` buckets exact zeros on their
|
|
11
|
+
* own.
|
|
12
|
+
*/
|
|
13
|
+
export declare const CALL_COUNT_BUCKETS: readonly number[];
|
|
14
|
+
/**
|
|
15
|
+
* Advisory bucket boundaries for input, total, cache-read, and tool-input
|
|
16
|
+
* token histograms.
|
|
17
|
+
*/
|
|
18
|
+
export declare const INPUT_TOKEN_BUCKETS: readonly number[];
|
|
19
|
+
/**
|
|
20
|
+
* Advisory bucket boundaries for output and reasoning token histograms.
|
|
21
|
+
*/
|
|
22
|
+
export declare const OUTPUT_TOKEN_BUCKETS: readonly number[];
|
|
23
|
+
/**
|
|
24
|
+
* Lazily builds and caches one set of domain instruments per registered
|
|
25
|
+
* `MeterProvider`, so a provider registered after ADK is imported still
|
|
26
|
+
* receives metrics under the ADK instrumentation scope and schema URL.
|
|
27
|
+
*/
|
|
28
|
+
export declare function cachedInstruments<T>(create: (meter: Meter) => T): () => T;
|
|
29
|
+
/** Parameters for {@link createHistogram}. */
|
|
30
|
+
export interface CreateHistogramParams {
|
|
31
|
+
readonly meter: Meter;
|
|
32
|
+
readonly name: string;
|
|
33
|
+
readonly unit: string;
|
|
34
|
+
readonly description: string;
|
|
35
|
+
readonly buckets?: readonly number[];
|
|
36
|
+
}
|
|
37
|
+
/** Creates a histogram with optional advisory bucket boundaries. */
|
|
38
|
+
export declare function createHistogram({ meter, name, unit, description, buckets, }: CreateHistogramParams): Histogram;
|
|
39
|
+
/** The six token histograms of one family (`invoke_agent` or `invoke_workflow`). */
|
|
40
|
+
export interface TokenHistograms {
|
|
41
|
+
readonly input: Histogram;
|
|
42
|
+
readonly output: Histogram;
|
|
43
|
+
readonly total: Histogram;
|
|
44
|
+
readonly cacheRead: Histogram;
|
|
45
|
+
readonly reasoning: Histogram;
|
|
46
|
+
readonly toolInput: Histogram;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Builds the six token histograms for `prefix`, interpolating the shared token
|
|
50
|
+
* meaning descriptions with `scopeDescription`.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createTokenHistograms(meter: Meter, prefix: string, scopeDescription: string): TokenHistograms;
|
|
53
|
+
/**
|
|
54
|
+
* Records all six token histograms for a scope where at least one model call
|
|
55
|
+
* reported token usage. Unreported buckets record `0`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function recordTokenHistograms(histograms: TokenHistograms, usage: TokenUsage, attributes: Attributes): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Skill } from '../../../../skills/skill.js';
|
|
7
|
+
import { type ResolvedTelemetryConfig } from '../common/config.js';
|
|
8
|
+
/** Advisory bucket boundaries for `gen_ai.execute_tool.duration`. */
|
|
9
|
+
export declare const TOOL_DURATION_BUCKETS: readonly number[];
|
|
10
|
+
/** Parameters for {@link recordToolDuration}. */
|
|
11
|
+
export interface RecordToolDurationParams {
|
|
12
|
+
readonly agentName: string;
|
|
13
|
+
readonly toolName: string;
|
|
14
|
+
readonly toolType: string;
|
|
15
|
+
readonly durationSeconds: number;
|
|
16
|
+
readonly errorType?: string;
|
|
17
|
+
}
|
|
18
|
+
/** Records `gen_ai.execute_tool.duration` at the end of a tool call. */
|
|
19
|
+
export declare function recordToolDuration({ agentName, toolName, toolType, durationSeconds, errorType, }: RecordToolDurationParams): void;
|
|
20
|
+
/** Parameters for {@link recordSkillLoad}. */
|
|
21
|
+
export interface RecordSkillLoadParams {
|
|
22
|
+
readonly agentName: string;
|
|
23
|
+
readonly skill?: Skill;
|
|
24
|
+
readonly errorType?: string;
|
|
25
|
+
readonly config: ResolvedTelemetryConfig;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Records one `adk.experimental.skill.loads` increment when `skills` is
|
|
29
|
+
* enabled, bounding unresolved skill names to `<hallucinated>`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function recordSkillLoad({ agentName, skill, errorType, config, }: RecordSkillLoadParams): void;
|
|
32
|
+
/** Parameters for {@link recordSkillScriptExecution}. */
|
|
33
|
+
export interface RecordSkillScriptExecutionParams {
|
|
34
|
+
readonly agentName: string;
|
|
35
|
+
readonly skill?: Skill;
|
|
36
|
+
readonly scriptPath: string;
|
|
37
|
+
readonly config: ResolvedTelemetryConfig;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Records one `adk.experimental.skill.script.executions` increment when
|
|
41
|
+
* `skills` is enabled, bounding unresolved skill names and script paths to
|
|
42
|
+
* `<hallucinated>`.
|
|
43
|
+
*/
|
|
44
|
+
export declare function recordSkillScriptExecution({ agentName, skill, scriptPath, config, }: RecordSkillScriptExecutionParams): void;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Totals } from '../common/accumulators.js';
|
|
7
|
+
import { type ResolvedTelemetryConfig } from '../common/config.js';
|
|
8
|
+
/** Parameters for {@link recordWorkflowDuration}. */
|
|
9
|
+
export interface RecordWorkflowDurationParams {
|
|
10
|
+
readonly workflowName: string;
|
|
11
|
+
readonly durationSeconds: number;
|
|
12
|
+
readonly nested: boolean;
|
|
13
|
+
readonly errorType?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Records `gen_ai.invoke_workflow.duration` at the end of a workflow
|
|
17
|
+
* invocation.
|
|
18
|
+
*/
|
|
19
|
+
export declare function recordWorkflowDuration({ workflowName, durationSeconds, nested, errorType, }: RecordWorkflowDurationParams): void;
|
|
20
|
+
/** Parameters for {@link recordWorkflowTotals}. */
|
|
21
|
+
export interface RecordWorkflowTotalsParams {
|
|
22
|
+
readonly rootAgentName: string;
|
|
23
|
+
readonly workflowName: string;
|
|
24
|
+
readonly nested: boolean;
|
|
25
|
+
readonly totals: Totals;
|
|
26
|
+
readonly config: ResolvedTelemetryConfig;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Records the inclusive call, skill-load, compaction, and token totals for one
|
|
30
|
+
* workflow invocation when the `workflow` experimental feature is enabled.
|
|
31
|
+
*/
|
|
32
|
+
export declare function recordWorkflowTotals({ rootAgentName, workflowName, nested, totals, config, }: RecordWorkflowTotalsParams): void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Attributes } from '@opentelemetry/api';
|
|
7
|
+
import type { BaseAgent } from '../../../../agents/base_agent.js';
|
|
8
|
+
/** Parameters for {@link buildAgentInvocationAttributes}. */
|
|
9
|
+
export interface AgentInvocationAttributesParams {
|
|
10
|
+
readonly agent: BaseAgent;
|
|
11
|
+
readonly sessionId: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
/** Builds the attributes of an `invoke_agent` span. */
|
|
14
|
+
export declare function buildAgentInvocationAttributes({ agent, sessionId, }: AgentInvocationAttributesParams): Attributes;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
import type { Attributes, Span } from '@opentelemetry/api';
|
|
7
|
+
import type { Event } from '../../../../events/event.js';
|
|
8
|
+
/** Parameters for {@link startCompactionSpan}. */
|
|
9
|
+
export interface StartCompactionSpanParams {
|
|
10
|
+
readonly sessionId: string;
|
|
11
|
+
readonly trigger: string;
|
|
12
|
+
}
|
|
13
|
+
/** Starts a `compact_events {trigger}` span under the active context. */
|
|
14
|
+
export declare function startCompactionSpan({ sessionId, trigger, }: StartCompactionSpanParams): Span;
|
|
15
|
+
/**
|
|
16
|
+
* Builds the result attributes of a compaction from the session events before
|
|
17
|
+
* and after it ran: the summary event it added, the time range it covers, and
|
|
18
|
+
* how many of the earlier events fall in that range.
|
|
19
|
+
*/
|
|
20
|
+
export declare function buildCompactionResultAttributes(eventsBefore: readonly Event[], eventsAfter: readonly Event[]): Attributes;
|