@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@google/adk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"description": "Google ADK JS",
|
|
5
5
|
"author": "Google",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -21,8 +21,11 @@
|
|
|
21
21
|
"browser": "./dist/web/index_web.js",
|
|
22
22
|
"exports": {
|
|
23
23
|
".": {
|
|
24
|
+
"browser": {
|
|
25
|
+
"types": "./dist/types/index_web.d.ts",
|
|
26
|
+
"default": "./dist/web/index_web.js"
|
|
27
|
+
},
|
|
24
28
|
"types": "./dist/types/index.d.ts",
|
|
25
|
-
"browser": "./dist/web/index_web.js",
|
|
26
29
|
"import": "./dist/esm/index.js",
|
|
27
30
|
"require": "./dist/cjs/index.js",
|
|
28
31
|
"default": "./dist/esm/index.js"
|
|
@@ -56,10 +59,10 @@
|
|
|
56
59
|
"default": "./dist/esm/sessions/database_session_service.js"
|
|
57
60
|
},
|
|
58
61
|
"./telemetry/gcp": {
|
|
59
|
-
"types": "./dist/types/telemetry/google_cloud.d.ts",
|
|
60
|
-
"import": "./dist/esm/telemetry/google_cloud.js",
|
|
61
|
-
"require": "./dist/cjs/telemetry/google_cloud.js",
|
|
62
|
-
"default": "./dist/esm/telemetry/google_cloud.js"
|
|
62
|
+
"types": "./dist/types/telemetry/export/google_cloud.d.ts",
|
|
63
|
+
"import": "./dist/esm/telemetry/export/google_cloud.js",
|
|
64
|
+
"require": "./dist/cjs/telemetry/export/google_cloud.js",
|
|
65
|
+
"default": "./dist/esm/telemetry/export/google_cloud.js"
|
|
63
66
|
},
|
|
64
67
|
"./tools/mcp": {
|
|
65
68
|
"types": "./dist/types/tools/mcp/index.d.ts",
|
|
@@ -89,7 +92,6 @@
|
|
|
89
92
|
},
|
|
90
93
|
"dependencies": {
|
|
91
94
|
"@a2a-js/sdk": "^0.3.10",
|
|
92
|
-
"@google-cloud/aiplatform": "^6.10.0",
|
|
93
95
|
"@google-cloud/vertexai": "^1.12.0",
|
|
94
96
|
"@google/genai": "^2.29.1",
|
|
95
97
|
"@mikro-orm/core": "^7.2.5",
|
|
@@ -118,13 +120,13 @@
|
|
|
118
120
|
"dockerode": "^5.0.1"
|
|
119
121
|
},
|
|
120
122
|
"devDependencies": {
|
|
121
|
-
"@google-cloud/
|
|
122
|
-
"@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
|
|
123
|
+
"@google-cloud/aiplatform": "^6.10.0",
|
|
123
124
|
"@google-cloud/secret-manager": "^7.2.0",
|
|
124
125
|
"@google-cloud/storage": "^7.17.1",
|
|
125
126
|
"@mikro-orm/sqlite": "^7.2.5",
|
|
126
127
|
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
127
128
|
"@opentelemetry/context-async-hooks": "^2.12.0",
|
|
129
|
+
"@opentelemetry/core": "^2.12.0",
|
|
128
130
|
"@types/adm-zip": "^0.5.8",
|
|
129
131
|
"@types/express": "^4.17.25",
|
|
130
132
|
"@types/lodash-es": "^4.17.12",
|
|
@@ -132,8 +134,7 @@
|
|
|
132
134
|
"openapi-types": "^12.1.3"
|
|
133
135
|
},
|
|
134
136
|
"peerDependencies": {
|
|
135
|
-
"@google-cloud/
|
|
136
|
-
"@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
|
|
137
|
+
"@google-cloud/aiplatform": "^6.10.0",
|
|
137
138
|
"@google-cloud/secret-manager": "^7.2.0",
|
|
138
139
|
"@google-cloud/storage": "^7.17.1",
|
|
139
140
|
"@mikro-orm/mariadb": "^7.2.5",
|
|
@@ -145,10 +146,7 @@
|
|
|
145
146
|
"express": "^4.22.1 || ^5.1.0"
|
|
146
147
|
},
|
|
147
148
|
"peerDependenciesMeta": {
|
|
148
|
-
"@google-cloud/
|
|
149
|
-
"optional": true
|
|
150
|
-
},
|
|
151
|
-
"@google-cloud/opentelemetry-cloud-trace-exporter": {
|
|
149
|
+
"@google-cloud/aiplatform": {
|
|
152
150
|
"optional": true
|
|
153
151
|
},
|
|
154
152
|
"@google-cloud/secret-manager": {
|
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
"use strict";
|
|
8
|
-
var __create = Object.create;
|
|
9
|
-
var __defProp = Object.defineProperty;
|
|
10
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
13
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
14
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
15
|
-
var __export = (target, all) => {
|
|
16
|
-
for (var name in all)
|
|
17
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
18
|
-
};
|
|
19
|
-
var __copyProps = (to, from, except, desc) => {
|
|
20
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
21
|
-
for (let key of __getOwnPropNames(from))
|
|
22
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
23
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
|
-
}
|
|
25
|
-
return to;
|
|
26
|
-
};
|
|
27
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
28
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
29
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
30
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
31
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
32
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
33
|
-
mod
|
|
34
|
-
));
|
|
35
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
-
var google_cloud_exports = {};
|
|
37
|
-
__export(google_cloud_exports, {
|
|
38
|
-
getGcpExporters: () => getGcpExporters,
|
|
39
|
-
getGcpResource: () => getGcpResource
|
|
40
|
-
});
|
|
41
|
-
module.exports = __toCommonJS(google_cloud_exports);
|
|
42
|
-
var import_resource_detector_gcp = require("@opentelemetry/resource-detector-gcp");
|
|
43
|
-
var import_resources = require("@opentelemetry/resources");
|
|
44
|
-
var import_sdk_metrics = require("@opentelemetry/sdk-metrics");
|
|
45
|
-
var import_sdk_trace_base = require("@opentelemetry/sdk-trace-base");
|
|
46
|
-
var import_google_auth_library = require("google-auth-library");
|
|
47
|
-
var import_logger = require("../utils/logger.js");
|
|
48
|
-
var import_optional_peer = require("../utils/optional_peer.js");
|
|
49
|
-
/**
|
|
50
|
-
* @license
|
|
51
|
-
* Copyright 2025 Google LLC
|
|
52
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
53
|
-
*/
|
|
54
|
-
const GCP_PROJECT_ERROR_MESSAGE = "Cannot determine GCP Project. OTel GCP Exporters cannot be set up. Please make sure to log into correct GCP Project.";
|
|
55
|
-
async function getGcpProjectId() {
|
|
56
|
-
try {
|
|
57
|
-
const auth = new import_google_auth_library.GoogleAuth();
|
|
58
|
-
const projectId = await auth.getProjectId();
|
|
59
|
-
return projectId || void 0;
|
|
60
|
-
} catch (_e) {
|
|
61
|
-
return void 0;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
__name(getGcpProjectId, "getGcpProjectId");
|
|
65
|
-
async function createCloudTraceProcessor(projectId) {
|
|
66
|
-
const { TraceExporter } = await (0, import_optional_peer.loadOptionalPeer)(
|
|
67
|
-
{
|
|
68
|
-
packageName: "@google-cloud/opentelemetry-cloud-trace-exporter",
|
|
69
|
-
feature: "getGcpExporters({enableTracing: true})"
|
|
70
|
-
},
|
|
71
|
-
() => Promise.resolve().then(() => __toESM(require("@google-cloud/opentelemetry-cloud-trace-exporter"), 1))
|
|
72
|
-
);
|
|
73
|
-
return new import_sdk_trace_base.BatchSpanProcessor(new TraceExporter({ projectId }));
|
|
74
|
-
}
|
|
75
|
-
__name(createCloudTraceProcessor, "createCloudTraceProcessor");
|
|
76
|
-
async function createCloudMetricReader(projectId) {
|
|
77
|
-
const { MetricExporter } = await (0, import_optional_peer.loadOptionalPeer)(
|
|
78
|
-
{
|
|
79
|
-
packageName: "@google-cloud/opentelemetry-cloud-monitoring-exporter",
|
|
80
|
-
feature: "getGcpExporters({enableMetrics: true})"
|
|
81
|
-
},
|
|
82
|
-
() => Promise.resolve().then(() => __toESM(require("@google-cloud/opentelemetry-cloud-monitoring-exporter"), 1))
|
|
83
|
-
);
|
|
84
|
-
return new import_sdk_metrics.PeriodicExportingMetricReader({
|
|
85
|
-
exporter: new MetricExporter({ projectId }),
|
|
86
|
-
exportIntervalMillis: 5e3
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
__name(createCloudMetricReader, "createCloudMetricReader");
|
|
90
|
-
async function getGcpExporters(config = {}) {
|
|
91
|
-
const {
|
|
92
|
-
enableTracing = false,
|
|
93
|
-
enableMetrics = false
|
|
94
|
-
// enableCloudLogging = false,
|
|
95
|
-
} = config;
|
|
96
|
-
const projectId = await getGcpProjectId();
|
|
97
|
-
if (!projectId) {
|
|
98
|
-
import_logger.logger.warn(GCP_PROJECT_ERROR_MESSAGE);
|
|
99
|
-
return {};
|
|
100
|
-
}
|
|
101
|
-
return {
|
|
102
|
-
spanProcessors: enableTracing ? [await createCloudTraceProcessor(projectId)] : [],
|
|
103
|
-
metricReaders: enableMetrics ? [await createCloudMetricReader(projectId)] : [],
|
|
104
|
-
logRecordProcessors: []
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
__name(getGcpExporters, "getGcpExporters");
|
|
108
|
-
function getGcpResource() {
|
|
109
|
-
return (0, import_resources.detectResources)({ detectors: [import_resource_detector_gcp.gcpDetector] });
|
|
110
|
-
}
|
|
111
|
-
__name(getGcpResource, "getGcpResource");
|
|
112
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
113
|
-
0 && (module.exports = {
|
|
114
|
-
getGcpExporters,
|
|
115
|
-
getGcpResource
|
|
116
|
-
});
|
|
@@ -1,393 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright 2026 Google LLC
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
"use strict";
|
|
8
|
-
var __defProp = Object.defineProperty;
|
|
9
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
-
var __export = (target, all) => {
|
|
14
|
-
for (var name in all)
|
|
15
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
-
};
|
|
17
|
-
var __copyProps = (to, from, except, desc) => {
|
|
18
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
-
for (let key of __getOwnPropNames(from))
|
|
20
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
-
}
|
|
23
|
-
return to;
|
|
24
|
-
};
|
|
25
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
-
var tracing_exports = {};
|
|
27
|
-
__export(tracing_exports, {
|
|
28
|
-
resolveErrorType: () => resolveErrorType,
|
|
29
|
-
runAsyncGeneratorWithOtelContext: () => runAsyncGeneratorWithOtelContext,
|
|
30
|
-
traceAgentInvocation: () => traceAgentInvocation,
|
|
31
|
-
traceCallLlm: () => traceCallLlm,
|
|
32
|
-
traceMergedToolCalls: () => traceMergedToolCalls,
|
|
33
|
-
traceNodeExecution: () => traceNodeExecution,
|
|
34
|
-
traceSendData: () => traceSendData,
|
|
35
|
-
traceToolCall: () => traceToolCall,
|
|
36
|
-
traceWorkflowInvocation: () => traceWorkflowInvocation,
|
|
37
|
-
tracer: () => tracer
|
|
38
|
-
});
|
|
39
|
-
module.exports = __toCommonJS(tracing_exports);
|
|
40
|
-
var import_genai = require("@google/genai");
|
|
41
|
-
var import_api = require("@opentelemetry/api");
|
|
42
|
-
var import_version = require("../version.js");
|
|
43
|
-
/**
|
|
44
|
-
* @license
|
|
45
|
-
* Copyright 2025 Google LLC
|
|
46
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
47
|
-
*/
|
|
48
|
-
var GenAiAttr = /* @__PURE__ */ ((GenAiAttr2) => {
|
|
49
|
-
GenAiAttr2["AGENT_DESCRIPTION"] = "gen_ai.agent.description";
|
|
50
|
-
GenAiAttr2["AGENT_NAME"] = "gen_ai.agent.name";
|
|
51
|
-
GenAiAttr2["CONVERSATION_ID"] = "gen_ai.conversation.id";
|
|
52
|
-
GenAiAttr2["OPERATION_NAME"] = "gen_ai.operation.name";
|
|
53
|
-
GenAiAttr2["SYSTEM"] = "gen_ai.system";
|
|
54
|
-
GenAiAttr2["TOOL_CALL_ID"] = "gen_ai.tool.call.id";
|
|
55
|
-
GenAiAttr2["TOOL_DESCRIPTION"] = "gen_ai.tool.description";
|
|
56
|
-
GenAiAttr2["TOOL_NAME"] = "gen_ai.tool.name";
|
|
57
|
-
GenAiAttr2["TOOL_TYPE"] = "gen_ai.tool.type";
|
|
58
|
-
GenAiAttr2["REQUEST_MODEL"] = "gen_ai.request.model";
|
|
59
|
-
GenAiAttr2["REQUEST_TOP_P"] = "gen_ai.request.top_p";
|
|
60
|
-
GenAiAttr2["REQUEST_MAX_TOKENS"] = "gen_ai.request.max_tokens";
|
|
61
|
-
GenAiAttr2["USAGE_INPUT_TOKENS"] = "gen_ai.usage.input_tokens";
|
|
62
|
-
GenAiAttr2["USAGE_OUTPUT_TOKENS"] = "gen_ai.usage.output_tokens";
|
|
63
|
-
GenAiAttr2["RESPONSE_FINISH_REASONS"] = "gen_ai.response.finish_reasons";
|
|
64
|
-
return GenAiAttr2;
|
|
65
|
-
})(GenAiAttr || {});
|
|
66
|
-
var AdkAttr = /* @__PURE__ */ ((AdkAttr2) => {
|
|
67
|
-
AdkAttr2["WORKFLOW_NAME"] = "adk.workflow.name";
|
|
68
|
-
AdkAttr2["NODE_PATH"] = "adk.node.path";
|
|
69
|
-
AdkAttr2["NODE_RUN_ID"] = "adk.node.run_id";
|
|
70
|
-
AdkAttr2["NODE_ATTEMPT"] = "adk.node.attempt";
|
|
71
|
-
AdkAttr2["NODE_STATUS"] = "adk.node.status";
|
|
72
|
-
AdkAttr2["NODE_INTERRUPT_COUNT"] = "adk.node.interrupt_count";
|
|
73
|
-
return AdkAttr2;
|
|
74
|
-
})(AdkAttr || {});
|
|
75
|
-
var GcpAttr = /* @__PURE__ */ ((GcpAttr2) => {
|
|
76
|
-
GcpAttr2["INVOCATION_ID"] = "gcp.vertex.agent.invocation_id";
|
|
77
|
-
GcpAttr2["SESSION_ID"] = "gcp.vertex.agent.session_id";
|
|
78
|
-
GcpAttr2["EVENT_ID"] = "gcp.vertex.agent.event_id";
|
|
79
|
-
GcpAttr2["LLM_REQUEST"] = "gcp.vertex.agent.llm_request";
|
|
80
|
-
GcpAttr2["LLM_RESPONSE"] = "gcp.vertex.agent.llm_response";
|
|
81
|
-
GcpAttr2["TOOL_CALL_ARGS"] = "gcp.vertex.agent.tool_call_args";
|
|
82
|
-
GcpAttr2["TOOL_RESPONSE"] = "gcp.vertex.agent.tool_response";
|
|
83
|
-
GcpAttr2["DATA"] = "gcp.vertex.agent.data";
|
|
84
|
-
return GcpAttr2;
|
|
85
|
-
})(GcpAttr || {});
|
|
86
|
-
const GEN_AI_SYSTEM_VALUE = "gcp.vertex.agent";
|
|
87
|
-
const tracer = import_api.trace.getTracer(GEN_AI_SYSTEM_VALUE, import_version.version);
|
|
88
|
-
function safeJsonSerialize(obj) {
|
|
89
|
-
try {
|
|
90
|
-
return JSON.stringify(obj);
|
|
91
|
-
} catch (_e) {
|
|
92
|
-
return "<not serializable>";
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
__name(safeJsonSerialize, "safeJsonSerialize");
|
|
96
|
-
function traceAgentInvocation({
|
|
97
|
-
agent,
|
|
98
|
-
invocationContext
|
|
99
|
-
}) {
|
|
100
|
-
const span = import_api.trace.getActiveSpan();
|
|
101
|
-
if (!span) return;
|
|
102
|
-
span.setAttributes({
|
|
103
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "invoke_agent",
|
|
104
|
-
// Conditionally Required
|
|
105
|
-
["gen_ai.agent.description" /* AGENT_DESCRIPTION */]: agent.description,
|
|
106
|
-
["gen_ai.agent.name" /* AGENT_NAME */]: agent.name,
|
|
107
|
-
["gen_ai.conversation.id" /* CONVERSATION_ID */]: invocationContext.session.id
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
__name(traceAgentInvocation, "traceAgentInvocation");
|
|
111
|
-
function traceWorkflowInvocation({
|
|
112
|
-
workflowName,
|
|
113
|
-
nodePath,
|
|
114
|
-
sessionId
|
|
115
|
-
}) {
|
|
116
|
-
const span = import_api.trace.getActiveSpan();
|
|
117
|
-
if (!span) return;
|
|
118
|
-
span.setAttributes({
|
|
119
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "invoke_workflow",
|
|
120
|
-
["gen_ai.conversation.id" /* CONVERSATION_ID */]: sessionId,
|
|
121
|
-
["adk.workflow.name" /* WORKFLOW_NAME */]: workflowName,
|
|
122
|
-
["adk.node.path" /* NODE_PATH */]: nodePath
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
__name(traceWorkflowInvocation, "traceWorkflowInvocation");
|
|
126
|
-
function traceNodeExecution({
|
|
127
|
-
nodePath,
|
|
128
|
-
runId,
|
|
129
|
-
attempt,
|
|
130
|
-
status,
|
|
131
|
-
interruptCount
|
|
132
|
-
}) {
|
|
133
|
-
const span = import_api.trace.getActiveSpan();
|
|
134
|
-
if (!span) return;
|
|
135
|
-
span.setAttributes({
|
|
136
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "execute_node",
|
|
137
|
-
["adk.node.path" /* NODE_PATH */]: nodePath,
|
|
138
|
-
["adk.node.run_id" /* NODE_RUN_ID */]: runId,
|
|
139
|
-
["adk.node.attempt" /* NODE_ATTEMPT */]: attempt,
|
|
140
|
-
["adk.node.status" /* NODE_STATUS */]: status,
|
|
141
|
-
["adk.node.interrupt_count" /* NODE_INTERRUPT_COUNT */]: interruptCount
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
__name(traceNodeExecution, "traceNodeExecution");
|
|
145
|
-
function resolveErrorType(error) {
|
|
146
|
-
var _a, _b;
|
|
147
|
-
if (error !== null && (typeof error === "object" || typeof error === "function")) {
|
|
148
|
-
try {
|
|
149
|
-
const errorObject = error;
|
|
150
|
-
const customErrorType = (_a = errorObject.errorType) != null ? _a : errorObject.error_type;
|
|
151
|
-
if (typeof customErrorType === "string" || typeof customErrorType === "number") {
|
|
152
|
-
return String(customErrorType);
|
|
153
|
-
}
|
|
154
|
-
if (error instanceof import_genai.ApiError) {
|
|
155
|
-
return String(error.status);
|
|
156
|
-
}
|
|
157
|
-
const constructorName = (_b = errorObject.constructor) == null ? void 0 : _b.name;
|
|
158
|
-
if (typeof constructorName === "string" && constructorName.length > 0) {
|
|
159
|
-
return constructorName;
|
|
160
|
-
}
|
|
161
|
-
} catch {
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
return typeof error;
|
|
165
|
-
}
|
|
166
|
-
__name(resolveErrorType, "resolveErrorType");
|
|
167
|
-
function traceToolCall(params) {
|
|
168
|
-
var _a, _b, _c;
|
|
169
|
-
const {
|
|
170
|
-
tool,
|
|
171
|
-
args,
|
|
172
|
-
functionResponseEvent,
|
|
173
|
-
invocationContext,
|
|
174
|
-
error,
|
|
175
|
-
errorType
|
|
176
|
-
} = params;
|
|
177
|
-
const span = (_a = params.span) != null ? _a : import_api.trace.getActiveSpan();
|
|
178
|
-
if (!span) return;
|
|
179
|
-
const hasError = Object.hasOwn(params, "error");
|
|
180
|
-
const failureType = hasError ? resolveErrorType(error) : errorType;
|
|
181
|
-
if (hasError) {
|
|
182
|
-
let exception;
|
|
183
|
-
try {
|
|
184
|
-
exception = error instanceof Error ? error : resolveErrorType(error);
|
|
185
|
-
} catch {
|
|
186
|
-
exception = resolveErrorType(error);
|
|
187
|
-
}
|
|
188
|
-
span.recordException(exception);
|
|
189
|
-
}
|
|
190
|
-
if (failureType !== void 0) {
|
|
191
|
-
span.setAttribute("error.type", failureType);
|
|
192
|
-
span.setStatus({ code: import_api.SpanStatusCode.ERROR, message: failureType });
|
|
193
|
-
}
|
|
194
|
-
span.setAttributes({
|
|
195
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "execute_tool",
|
|
196
|
-
["gen_ai.system" /* SYSTEM */]: GEN_AI_SYSTEM_VALUE,
|
|
197
|
-
["gen_ai.tool.description" /* TOOL_DESCRIPTION */]: tool.description || "",
|
|
198
|
-
["gen_ai.tool.name" /* TOOL_NAME */]: tool.name,
|
|
199
|
-
// e.g. FunctionTool
|
|
200
|
-
["gen_ai.tool.type" /* TOOL_TYPE */]: tool.constructor.name,
|
|
201
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
202
|
-
// Setting empty llm request and response (as UI expect these) while not
|
|
203
|
-
// applicable for tool_response.
|
|
204
|
-
["gcp.vertex.agent.llm_request" /* LLM_REQUEST */]: "{}",
|
|
205
|
-
["gcp.vertex.agent.llm_response" /* LLM_RESPONSE */]: "{}",
|
|
206
|
-
["gcp.vertex.agent.tool_call_args" /* TOOL_CALL_ARGS */]: shouldAddRequestResponseToSpans() ? safeJsonSerialize(args) : "{}"
|
|
207
|
-
});
|
|
208
|
-
let toolCallId = "<not specified>";
|
|
209
|
-
let toolResponse = "<not specified>";
|
|
210
|
-
if ((_b = functionResponseEvent == null ? void 0 : functionResponseEvent.content) == null ? void 0 : _b.parts) {
|
|
211
|
-
const responseParts = functionResponseEvent.content.parts;
|
|
212
|
-
const functionResponse = (_c = responseParts[0]) == null ? void 0 : _c.functionResponse;
|
|
213
|
-
if (functionResponse == null ? void 0 : functionResponse.id) {
|
|
214
|
-
toolCallId = functionResponse.id;
|
|
215
|
-
}
|
|
216
|
-
if (functionResponse == null ? void 0 : functionResponse.response) {
|
|
217
|
-
toolResponse = functionResponse.response;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
if (typeof toolResponse !== "object" || toolResponse === null) {
|
|
221
|
-
toolResponse = { result: toolResponse };
|
|
222
|
-
}
|
|
223
|
-
span.setAttributes({
|
|
224
|
-
["gen_ai.tool.call.id" /* TOOL_CALL_ID */]: toolCallId,
|
|
225
|
-
...functionResponseEvent ? { ["gcp.vertex.agent.event_id" /* EVENT_ID */]: functionResponseEvent.id } : {},
|
|
226
|
-
["gcp.vertex.agent.tool_response" /* TOOL_RESPONSE */]: shouldAddRequestResponseToSpans() ? safeJsonSerialize(toolResponse) : "{}"
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
__name(traceToolCall, "traceToolCall");
|
|
230
|
-
function traceMergedToolCalls({
|
|
231
|
-
responseEventId,
|
|
232
|
-
functionResponseEvent,
|
|
233
|
-
invocationContext
|
|
234
|
-
}) {
|
|
235
|
-
const span = import_api.trace.getActiveSpan();
|
|
236
|
-
if (!span) return;
|
|
237
|
-
span.setAttributes({
|
|
238
|
-
["gen_ai.operation.name" /* OPERATION_NAME */]: "execute_tool",
|
|
239
|
-
["gen_ai.system" /* SYSTEM */]: GEN_AI_SYSTEM_VALUE,
|
|
240
|
-
["gen_ai.tool.name" /* TOOL_NAME */]: "(merged tools)",
|
|
241
|
-
["gen_ai.tool.description" /* TOOL_DESCRIPTION */]: "(merged tools)",
|
|
242
|
-
["gen_ai.tool.call.id" /* TOOL_CALL_ID */]: responseEventId,
|
|
243
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
244
|
-
["gcp.vertex.agent.tool_call_args" /* TOOL_CALL_ARGS */]: "N/A",
|
|
245
|
-
["gcp.vertex.agent.event_id" /* EVENT_ID */]: responseEventId,
|
|
246
|
-
// Setting empty llm request and response (as UI expect these) while not
|
|
247
|
-
// applicable for tool_response.
|
|
248
|
-
["gcp.vertex.agent.llm_request" /* LLM_REQUEST */]: "{}",
|
|
249
|
-
["gcp.vertex.agent.llm_response" /* LLM_RESPONSE */]: "{}"
|
|
250
|
-
});
|
|
251
|
-
span.setAttribute(
|
|
252
|
-
"gcp.vertex.agent.tool_response" /* TOOL_RESPONSE */,
|
|
253
|
-
shouldAddRequestResponseToSpans() ? safeJsonSerialize(functionResponseEvent) : "{}"
|
|
254
|
-
);
|
|
255
|
-
}
|
|
256
|
-
__name(traceMergedToolCalls, "traceMergedToolCalls");
|
|
257
|
-
function traceCallLlm({
|
|
258
|
-
invocationContext,
|
|
259
|
-
eventId,
|
|
260
|
-
llmRequest,
|
|
261
|
-
llmResponse
|
|
262
|
-
}) {
|
|
263
|
-
var _a, _b, _c, _d;
|
|
264
|
-
const span = import_api.trace.getActiveSpan();
|
|
265
|
-
if (!span) return;
|
|
266
|
-
span.setAttributes({
|
|
267
|
-
["gen_ai.system" /* SYSTEM */]: GEN_AI_SYSTEM_VALUE,
|
|
268
|
-
["gen_ai.request.model" /* REQUEST_MODEL */]: llmRequest.model,
|
|
269
|
-
...((_a = invocationContext.agent) == null ? void 0 : _a.name) ? { ["gen_ai.agent.name" /* AGENT_NAME */]: invocationContext.agent.name } : {},
|
|
270
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
271
|
-
["gcp.vertex.agent.session_id" /* SESSION_ID */]: invocationContext.session.id,
|
|
272
|
-
["gcp.vertex.agent.event_id" /* EVENT_ID */]: eventId,
|
|
273
|
-
// Consider removing once GenAI SDK provides a way to record this info.
|
|
274
|
-
["gcp.vertex.agent.llm_request" /* LLM_REQUEST */]: shouldAddRequestResponseToSpans() ? safeJsonSerialize(buildLlmRequestForTrace(llmRequest)) : "{}"
|
|
275
|
-
});
|
|
276
|
-
if ((_b = llmRequest.config) == null ? void 0 : _b.topP) {
|
|
277
|
-
span.setAttribute("gen_ai.request.top_p" /* REQUEST_TOP_P */, llmRequest.config.topP);
|
|
278
|
-
}
|
|
279
|
-
if (((_c = llmRequest.config) == null ? void 0 : _c.maxOutputTokens) !== void 0) {
|
|
280
|
-
span.setAttribute(
|
|
281
|
-
"gen_ai.request.max_tokens" /* REQUEST_MAX_TOKENS */,
|
|
282
|
-
llmRequest.config.maxOutputTokens
|
|
283
|
-
);
|
|
284
|
-
}
|
|
285
|
-
span.setAttribute(
|
|
286
|
-
"gcp.vertex.agent.llm_response" /* LLM_RESPONSE */,
|
|
287
|
-
shouldAddRequestResponseToSpans() ? safeJsonSerialize(llmResponse) : "{}"
|
|
288
|
-
);
|
|
289
|
-
if (llmResponse.usageMetadata) {
|
|
290
|
-
span.setAttribute(
|
|
291
|
-
"gen_ai.usage.input_tokens" /* USAGE_INPUT_TOKENS */,
|
|
292
|
-
llmResponse.usageMetadata.promptTokenCount || 0
|
|
293
|
-
);
|
|
294
|
-
}
|
|
295
|
-
if ((_d = llmResponse.usageMetadata) == null ? void 0 : _d.candidatesTokenCount) {
|
|
296
|
-
span.setAttribute(
|
|
297
|
-
"gen_ai.usage.output_tokens" /* USAGE_OUTPUT_TOKENS */,
|
|
298
|
-
llmResponse.usageMetadata.candidatesTokenCount
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
if (llmResponse.finishReason) {
|
|
302
|
-
const finishReasonValue = typeof llmResponse.finishReason === "string" ? llmResponse.finishReason.toLowerCase() : String(llmResponse.finishReason).toLowerCase();
|
|
303
|
-
span.setAttribute("gen_ai.response.finish_reasons" /* RESPONSE_FINISH_REASONS */, [finishReasonValue]);
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
__name(traceCallLlm, "traceCallLlm");
|
|
307
|
-
function traceSendData({
|
|
308
|
-
invocationContext,
|
|
309
|
-
eventId,
|
|
310
|
-
data
|
|
311
|
-
}) {
|
|
312
|
-
const span = import_api.trace.getActiveSpan();
|
|
313
|
-
if (!span) return;
|
|
314
|
-
span.setAttributes({
|
|
315
|
-
["gcp.vertex.agent.invocation_id" /* INVOCATION_ID */]: invocationContext.invocationId,
|
|
316
|
-
["gcp.vertex.agent.event_id" /* EVENT_ID */]: eventId
|
|
317
|
-
});
|
|
318
|
-
span.setAttribute(
|
|
319
|
-
"gcp.vertex.agent.data" /* DATA */,
|
|
320
|
-
shouldAddRequestResponseToSpans() ? safeJsonSerialize(data) : "{}"
|
|
321
|
-
);
|
|
322
|
-
}
|
|
323
|
-
__name(traceSendData, "traceSendData");
|
|
324
|
-
function redactHttpOptions(httpOptions) {
|
|
325
|
-
const redacted = { ...httpOptions };
|
|
326
|
-
delete redacted.headers;
|
|
327
|
-
delete redacted.extraBody;
|
|
328
|
-
return redacted;
|
|
329
|
-
}
|
|
330
|
-
__name(redactHttpOptions, "redactHttpOptions");
|
|
331
|
-
function buildLlmRequestForTrace(llmRequest) {
|
|
332
|
-
const result = {
|
|
333
|
-
model: llmRequest.model,
|
|
334
|
-
contents: []
|
|
335
|
-
};
|
|
336
|
-
if (llmRequest.config) {
|
|
337
|
-
const { responseSchema: _responseSchema, ...cleanConfig } = llmRequest.config;
|
|
338
|
-
if (cleanConfig.httpOptions) {
|
|
339
|
-
cleanConfig.httpOptions = redactHttpOptions(cleanConfig.httpOptions);
|
|
340
|
-
}
|
|
341
|
-
result.config = cleanConfig;
|
|
342
|
-
}
|
|
343
|
-
result.contents = llmRequest.contents.map((content) => {
|
|
344
|
-
var _a;
|
|
345
|
-
return {
|
|
346
|
-
role: content.role,
|
|
347
|
-
parts: ((_a = content.parts) == null ? void 0 : _a.filter((part) => !part.inlineData)) || []
|
|
348
|
-
};
|
|
349
|
-
});
|
|
350
|
-
return result;
|
|
351
|
-
}
|
|
352
|
-
__name(buildLlmRequestForTrace, "buildLlmRequestForTrace");
|
|
353
|
-
function bindOtelContextToAsyncGenerator(ctx, generator) {
|
|
354
|
-
return {
|
|
355
|
-
// Bind the next() method to execute within the provided context
|
|
356
|
-
next: import_api.context.bind(ctx, generator.next.bind(generator)),
|
|
357
|
-
// Bind the return() method to execute within the provided context
|
|
358
|
-
return: import_api.context.bind(ctx, generator.return.bind(generator)),
|
|
359
|
-
// Bind the throw() method to execute within the provided context
|
|
360
|
-
throw: import_api.context.bind(ctx, generator.throw.bind(generator)),
|
|
361
|
-
// Ensure the async iterator symbol also returns a context-bound generator
|
|
362
|
-
[Symbol.asyncIterator]() {
|
|
363
|
-
return bindOtelContextToAsyncGenerator(
|
|
364
|
-
ctx,
|
|
365
|
-
generator[Symbol.asyncIterator]()
|
|
366
|
-
);
|
|
367
|
-
}
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
__name(bindOtelContextToAsyncGenerator, "bindOtelContextToAsyncGenerator");
|
|
371
|
-
function runAsyncGeneratorWithOtelContext(otelContext, generatorFnContext, generatorFn) {
|
|
372
|
-
const generator = generatorFn.call(generatorFnContext);
|
|
373
|
-
return bindOtelContextToAsyncGenerator(otelContext, generator);
|
|
374
|
-
}
|
|
375
|
-
__name(runAsyncGeneratorWithOtelContext, "runAsyncGeneratorWithOtelContext");
|
|
376
|
-
function shouldAddRequestResponseToSpans() {
|
|
377
|
-
const envValue = process.env.ADK_CAPTURE_MESSAGE_CONTENT_IN_SPANS || "true";
|
|
378
|
-
return envValue === "true" || envValue === "1";
|
|
379
|
-
}
|
|
380
|
-
__name(shouldAddRequestResponseToSpans, "shouldAddRequestResponseToSpans");
|
|
381
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
382
|
-
0 && (module.exports = {
|
|
383
|
-
resolveErrorType,
|
|
384
|
-
runAsyncGeneratorWithOtelContext,
|
|
385
|
-
traceAgentInvocation,
|
|
386
|
-
traceCallLlm,
|
|
387
|
-
traceMergedToolCalls,
|
|
388
|
-
traceNodeExecution,
|
|
389
|
-
traceSendData,
|
|
390
|
-
traceToolCall,
|
|
391
|
-
traceWorkflowInvocation,
|
|
392
|
-
tracer
|
|
393
|
-
});
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import {createRequire as topLevelCreateRequire} from 'module';
|
|
2
|
-
const require = topLevelCreateRequire(import.meta.url);
|
|
3
|
-
var __create = Object.create;
|
|
4
|
-
var __defProp = Object.defineProperty;
|
|
5
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
19
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
20
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
21
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
22
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
23
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
24
|
-
mod
|
|
25
|
-
));
|
|
26
|
-
/**
|
|
27
|
-
* @license
|
|
28
|
-
* Copyright 2025 Google LLC
|
|
29
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
30
|
-
*/
|
|
31
|
-
import { gcpDetector } from "@opentelemetry/resource-detector-gcp";
|
|
32
|
-
import { detectResources } from "@opentelemetry/resources";
|
|
33
|
-
import { PeriodicExportingMetricReader } from "@opentelemetry/sdk-metrics";
|
|
34
|
-
import { BatchSpanProcessor } from "@opentelemetry/sdk-trace-base";
|
|
35
|
-
import { GoogleAuth } from "google-auth-library";
|
|
36
|
-
import { logger } from "../utils/logger.js";
|
|
37
|
-
import { loadOptionalPeer } from "../utils/optional_peer.js";
|
|
38
|
-
const GCP_PROJECT_ERROR_MESSAGE = "Cannot determine GCP Project. OTel GCP Exporters cannot be set up. Please make sure to log into correct GCP Project.";
|
|
39
|
-
async function getGcpProjectId() {
|
|
40
|
-
try {
|
|
41
|
-
const auth = new GoogleAuth();
|
|
42
|
-
const projectId = await auth.getProjectId();
|
|
43
|
-
return projectId || void 0;
|
|
44
|
-
} catch (_e) {
|
|
45
|
-
return void 0;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
__name(getGcpProjectId, "getGcpProjectId");
|
|
49
|
-
async function createCloudTraceProcessor(projectId) {
|
|
50
|
-
const { TraceExporter } = await loadOptionalPeer(
|
|
51
|
-
{
|
|
52
|
-
packageName: "@google-cloud/opentelemetry-cloud-trace-exporter",
|
|
53
|
-
feature: "getGcpExporters({enableTracing: true})"
|
|
54
|
-
},
|
|
55
|
-
() => Promise.resolve().then(() => __toESM(require("@google-cloud/opentelemetry-cloud-trace-exporter"), 1))
|
|
56
|
-
);
|
|
57
|
-
return new BatchSpanProcessor(new TraceExporter({ projectId }));
|
|
58
|
-
}
|
|
59
|
-
__name(createCloudTraceProcessor, "createCloudTraceProcessor");
|
|
60
|
-
async function createCloudMetricReader(projectId) {
|
|
61
|
-
const { MetricExporter } = await loadOptionalPeer(
|
|
62
|
-
{
|
|
63
|
-
packageName: "@google-cloud/opentelemetry-cloud-monitoring-exporter",
|
|
64
|
-
feature: "getGcpExporters({enableMetrics: true})"
|
|
65
|
-
},
|
|
66
|
-
() => Promise.resolve().then(() => __toESM(require("@google-cloud/opentelemetry-cloud-monitoring-exporter"), 1))
|
|
67
|
-
);
|
|
68
|
-
return new PeriodicExportingMetricReader({
|
|
69
|
-
exporter: new MetricExporter({ projectId }),
|
|
70
|
-
exportIntervalMillis: 5e3
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
__name(createCloudMetricReader, "createCloudMetricReader");
|
|
74
|
-
async function getGcpExporters(config = {}) {
|
|
75
|
-
const {
|
|
76
|
-
enableTracing = false,
|
|
77
|
-
enableMetrics = false
|
|
78
|
-
// enableCloudLogging = false,
|
|
79
|
-
} = config;
|
|
80
|
-
const projectId = await getGcpProjectId();
|
|
81
|
-
if (!projectId) {
|
|
82
|
-
logger.warn(GCP_PROJECT_ERROR_MESSAGE);
|
|
83
|
-
return {};
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
spanProcessors: enableTracing ? [await createCloudTraceProcessor(projectId)] : [],
|
|
87
|
-
metricReaders: enableMetrics ? [await createCloudMetricReader(projectId)] : [],
|
|
88
|
-
logRecordProcessors: []
|
|
89
|
-
};
|
|
90
|
-
}
|
|
91
|
-
__name(getGcpExporters, "getGcpExporters");
|
|
92
|
-
function getGcpResource() {
|
|
93
|
-
return detectResources({ detectors: [gcpDetector] });
|
|
94
|
-
}
|
|
95
|
-
__name(getGcpResource, "getGcpResource");
|
|
96
|
-
export {
|
|
97
|
-
getGcpExporters,
|
|
98
|
-
getGcpResource
|
|
99
|
-
};
|