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