@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
@@ -0,0 +1,189 @@
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 meters_exports = {};
27
+ __export(meters_exports, {
28
+ CALL_COUNT_BUCKETS: () => CALL_COUNT_BUCKETS,
29
+ INPUT_TOKEN_BUCKETS: () => INPUT_TOKEN_BUCKETS,
30
+ OUTPUT_TOKEN_BUCKETS: () => OUTPUT_TOKEN_BUCKETS,
31
+ cachedInstruments: () => cachedInstruments,
32
+ createHistogram: () => createHistogram,
33
+ createTokenHistograms: () => createTokenHistograms,
34
+ recordTokenHistograms: () => recordTokenHistograms
35
+ });
36
+ module.exports = __toCommonJS(meters_exports);
37
+ var import_api = require("@opentelemetry/api");
38
+ var import_version = require("../../../../version.js");
39
+ var import_attributes = require("../common/attributes.js");
40
+ var import_token_usage = require("../common/token_usage.js");
41
+ /**
42
+ * @license
43
+ * Copyright 2026 Google LLC
44
+ * SPDX-License-Identifier: Apache-2.0
45
+ */
46
+ const CALL_COUNT_BUCKETS = Object.freeze([
47
+ 0,
48
+ 1,
49
+ 2,
50
+ 3,
51
+ 4,
52
+ 5,
53
+ 6,
54
+ 8,
55
+ 12,
56
+ 16,
57
+ 24,
58
+ 32,
59
+ 64,
60
+ 128,
61
+ 256,
62
+ 512
63
+ ]);
64
+ const INPUT_TOKEN_BUCKETS = Object.freeze([
65
+ 0,
66
+ 128,
67
+ 256,
68
+ 512,
69
+ 1024,
70
+ 2048,
71
+ 4096,
72
+ 8192,
73
+ 16384,
74
+ 32768,
75
+ 65536,
76
+ 131072,
77
+ 262144,
78
+ 524288,
79
+ 1048576
80
+ ]);
81
+ const OUTPUT_TOKEN_BUCKETS = Object.freeze([
82
+ 0,
83
+ 32,
84
+ 64,
85
+ 128,
86
+ 256,
87
+ 512,
88
+ 1024,
89
+ 2048,
90
+ 4096,
91
+ 8192,
92
+ 16384,
93
+ 32768,
94
+ 65536,
95
+ 131072
96
+ ]);
97
+ function cachedInstruments(create) {
98
+ const cache = /* @__PURE__ */ new WeakMap();
99
+ return () => {
100
+ const provider = import_api.metrics.getMeterProvider();
101
+ let instruments = cache.get(provider);
102
+ if (instruments === void 0) {
103
+ instruments = create(
104
+ provider.getMeter(import_attributes.GEN_AI_SYSTEM_VALUE, import_version.version, {
105
+ schemaUrl: import_attributes.SCHEMA_URL
106
+ })
107
+ );
108
+ cache.set(provider, instruments);
109
+ }
110
+ return instruments;
111
+ };
112
+ }
113
+ __name(cachedInstruments, "cachedInstruments");
114
+ function createHistogram({
115
+ meter,
116
+ name,
117
+ unit,
118
+ description,
119
+ buckets
120
+ }) {
121
+ return meter.createHistogram(name, {
122
+ unit,
123
+ description,
124
+ ...buckets === void 0 ? {} : { advice: { explicitBucketBoundaries: [...buckets] } }
125
+ });
126
+ }
127
+ __name(createHistogram, "createHistogram");
128
+ function createTokenHistograms(meter, prefix, scopeDescription) {
129
+ const tokenHistogram = /* @__PURE__ */ __name((suffix, meaning, buckets) => createHistogram({
130
+ meter,
131
+ name: `${prefix}.${suffix}`,
132
+ unit: "{token}",
133
+ description: `${meaning} Summed over ${scopeDescription}.`,
134
+ buckets
135
+ }), "tokenHistogram");
136
+ return {
137
+ input: tokenHistogram(
138
+ "input_tokens",
139
+ import_token_usage.INPUT_TOKENS_MEANING,
140
+ INPUT_TOKEN_BUCKETS
141
+ ),
142
+ output: tokenHistogram(
143
+ "output_tokens",
144
+ import_token_usage.OUTPUT_TOKENS_MEANING,
145
+ OUTPUT_TOKEN_BUCKETS
146
+ ),
147
+ total: tokenHistogram(
148
+ "total_tokens",
149
+ import_token_usage.TOTAL_TOKENS_MEANING,
150
+ INPUT_TOKEN_BUCKETS
151
+ ),
152
+ cacheRead: tokenHistogram(
153
+ "cache_read.input_tokens",
154
+ import_token_usage.CACHE_READ_INPUT_TOKENS_MEANING,
155
+ INPUT_TOKEN_BUCKETS
156
+ ),
157
+ reasoning: tokenHistogram(
158
+ "reasoning.output_tokens",
159
+ import_token_usage.REASONING_OUTPUT_TOKENS_MEANING,
160
+ OUTPUT_TOKEN_BUCKETS
161
+ ),
162
+ toolInput: tokenHistogram(
163
+ "tool.input_tokens",
164
+ import_token_usage.TOOL_INPUT_TOKENS_MEANING,
165
+ INPUT_TOKEN_BUCKETS
166
+ )
167
+ };
168
+ }
169
+ __name(createTokenHistograms, "createTokenHistograms");
170
+ function recordTokenHistograms(histograms, usage, attributes) {
171
+ var _a, _b, _c, _d, _e;
172
+ histograms.input.record((_a = usage.input) != null ? _a : 0, attributes);
173
+ histograms.output.record((_b = usage.output) != null ? _b : 0, attributes);
174
+ histograms.total.record(usage.totalTokenUsage(), attributes);
175
+ histograms.cacheRead.record((_c = usage.cacheRead) != null ? _c : 0, attributes);
176
+ histograms.reasoning.record((_d = usage.reasoning) != null ? _d : 0, attributes);
177
+ histograms.toolInput.record((_e = usage.toolInput) != null ? _e : 0, attributes);
178
+ }
179
+ __name(recordTokenHistograms, "recordTokenHistograms");
180
+ // Annotate the CommonJS export names for ESM import in node:
181
+ 0 && (module.exports = {
182
+ CALL_COUNT_BUCKETS,
183
+ INPUT_TOKEN_BUCKETS,
184
+ OUTPUT_TOKEN_BUCKETS,
185
+ cachedInstruments,
186
+ createHistogram,
187
+ createTokenHistograms,
188
+ recordTokenHistograms
189
+ });
@@ -0,0 +1,147 @@
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 tool_exports = {};
27
+ __export(tool_exports, {
28
+ TOOL_DURATION_BUCKETS: () => TOOL_DURATION_BUCKETS,
29
+ recordSkillLoad: () => recordSkillLoad,
30
+ recordSkillScriptExecution: () => recordSkillScriptExecution,
31
+ recordToolDuration: () => recordToolDuration
32
+ });
33
+ module.exports = __toCommonJS(tool_exports);
34
+ var import_attributes = require("../common/attributes.js");
35
+ var import_config = require("../common/config.js");
36
+ var import_meters = require("./meters.js");
37
+ /**
38
+ * @license
39
+ * Copyright 2026 Google LLC
40
+ * SPDX-License-Identifier: Apache-2.0
41
+ */
42
+ const HALLUCINATED = "<hallucinated>";
43
+ const TOOL_DURATION_BUCKETS = Object.freeze([
44
+ 0.01,
45
+ 0.02,
46
+ 0.04,
47
+ 0.08,
48
+ 0.16,
49
+ 0.32,
50
+ 0.64,
51
+ 1.28,
52
+ 2.56,
53
+ 5.12,
54
+ 10.24,
55
+ 20.48,
56
+ 40.96,
57
+ 81.92
58
+ ]);
59
+ const getToolInstruments = (0, import_meters.cachedInstruments)((meter) => ({
60
+ duration: (0, import_meters.createHistogram)({
61
+ meter,
62
+ name: "gen_ai.execute_tool.duration",
63
+ unit: "s",
64
+ description: "Duration of tool executions.",
65
+ buckets: TOOL_DURATION_BUCKETS
66
+ }),
67
+ skillLoads: meter.createCounter("adk.experimental.skill.loads", {
68
+ unit: "1",
69
+ description: "Number of times a skill was loaded. Counts the attempt, so a load that resolved no skill is counted too, under its `error.type`."
70
+ }),
71
+ skillScriptExecutions: meter.createCounter(
72
+ "adk.experimental.skill.script.executions",
73
+ {
74
+ unit: "1",
75
+ description: "Number of skill script executions."
76
+ }
77
+ )
78
+ }));
79
+ function recordToolDuration({
80
+ agentName,
81
+ toolName,
82
+ toolType,
83
+ durationSeconds,
84
+ errorType
85
+ }) {
86
+ const attributes = {
87
+ [import_attributes.GenAiAttr.AGENT_NAME]: agentName,
88
+ [import_attributes.GenAiAttr.TOOL_NAME]: toolName,
89
+ [import_attributes.GenAiAttr.TOOL_TYPE]: toolType,
90
+ ...errorType === void 0 ? {} : { [import_attributes.ERROR_TYPE_ATTR]: errorType }
91
+ };
92
+ getToolInstruments().duration.record(durationSeconds, attributes);
93
+ }
94
+ __name(recordToolDuration, "recordToolDuration");
95
+ function recordSkillLoad({
96
+ agentName,
97
+ skill,
98
+ errorType,
99
+ config
100
+ }) {
101
+ var _a;
102
+ if (!(0, import_config.isExperimentalFeatureEnabled)(config, "skills")) {
103
+ return;
104
+ }
105
+ const attributes = {
106
+ [import_attributes.GenAiAttr.AGENT_NAME]: agentName,
107
+ [import_attributes.GenAiAttr.SKILL_NAME]: (_a = skill == null ? void 0 : skill.frontmatter.name) != null ? _a : HALLUCINATED,
108
+ ...errorType === void 0 ? {} : { [import_attributes.ERROR_TYPE_ATTR]: errorType }
109
+ };
110
+ getToolInstruments().skillLoads.add(1, attributes);
111
+ }
112
+ __name(recordSkillLoad, "recordSkillLoad");
113
+ function hasSkillScript(skill, scriptPath) {
114
+ var _a;
115
+ const scripts = (_a = skill == null ? void 0 : skill.resources) == null ? void 0 : _a.scripts;
116
+ if (!scripts) {
117
+ return false;
118
+ }
119
+ const relativePath = scriptPath.startsWith("scripts/") ? scriptPath.slice("scripts/".length) : scriptPath;
120
+ return Object.prototype.hasOwnProperty.call(scripts, relativePath) || Object.prototype.hasOwnProperty.call(scripts, scriptPath);
121
+ }
122
+ __name(hasSkillScript, "hasSkillScript");
123
+ function recordSkillScriptExecution({
124
+ agentName,
125
+ skill,
126
+ scriptPath,
127
+ config
128
+ }) {
129
+ var _a;
130
+ if (!(0, import_config.isExperimentalFeatureEnabled)(config, "skills")) {
131
+ return;
132
+ }
133
+ const attributes = {
134
+ [import_attributes.GenAiAttr.AGENT_NAME]: agentName,
135
+ [import_attributes.GenAiAttr.SKILL_NAME]: (_a = skill == null ? void 0 : skill.frontmatter.name) != null ? _a : HALLUCINATED,
136
+ [import_attributes.GenAiAttr.SKILL_RESOURCE_NAME]: hasSkillScript(skill, scriptPath) ? scriptPath : HALLUCINATED
137
+ };
138
+ getToolInstruments().skillScriptExecutions.add(1, attributes);
139
+ }
140
+ __name(recordSkillScriptExecution, "recordSkillScriptExecution");
141
+ // Annotate the CommonJS export names for ESM import in node:
142
+ 0 && (module.exports = {
143
+ TOOL_DURATION_BUCKETS,
144
+ recordSkillLoad,
145
+ recordSkillScriptExecution,
146
+ recordToolDuration
147
+ });
@@ -0,0 +1,132 @@
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 workflow_exports = {};
27
+ __export(workflow_exports, {
28
+ recordWorkflowDuration: () => recordWorkflowDuration,
29
+ recordWorkflowTotals: () => recordWorkflowTotals
30
+ });
31
+ module.exports = __toCommonJS(workflow_exports);
32
+ var import_attributes = require("../common/attributes.js");
33
+ var import_config = require("../common/config.js");
34
+ var import_meters = require("./meters.js");
35
+ /**
36
+ * @license
37
+ * Copyright 2026 Google LLC
38
+ * SPDX-License-Identifier: Apache-2.0
39
+ */
40
+ const PER_WORKFLOW = "one workflow invocation, across every agent that ran in it";
41
+ const getWorkflowInstruments = (0, import_meters.cachedInstruments)(
42
+ (meter) => ({
43
+ duration: (0, import_meters.createHistogram)({
44
+ meter,
45
+ name: "gen_ai.invoke_workflow.duration",
46
+ unit: "s",
47
+ description: "Duration of workflow invocations."
48
+ }),
49
+ inferenceCalls: (0, import_meters.createHistogram)({
50
+ meter,
51
+ name: "adk.experimental.invoke_workflow.inference_calls",
52
+ unit: "1",
53
+ description: `Number of inference (model) calls over ${PER_WORKFLOW}.`,
54
+ buckets: import_meters.CALL_COUNT_BUCKETS
55
+ }),
56
+ toolCalls: (0, import_meters.createHistogram)({
57
+ meter,
58
+ name: "adk.experimental.invoke_workflow.tool_calls",
59
+ unit: "1",
60
+ description: `Number of tool calls over ${PER_WORKFLOW}. Includes the \`transfer_to_agent\` calls that route between them.`,
61
+ buckets: import_meters.CALL_COUNT_BUCKETS
62
+ }),
63
+ skillLoads: (0, import_meters.createHistogram)({
64
+ meter,
65
+ name: "adk.experimental.invoke_workflow.skill.loads",
66
+ unit: "1",
67
+ description: `Number of skill loads over ${PER_WORKFLOW}.`,
68
+ buckets: import_meters.CALL_COUNT_BUCKETS
69
+ }),
70
+ compactions: (0, import_meters.createHistogram)({
71
+ meter,
72
+ name: "adk.experimental.invoke_workflow.compactions",
73
+ unit: "1",
74
+ description: `Number of conversation compactions over ${PER_WORKFLOW}. Counts every summary produced, including one the runner then discards because a newer turn changed the session meanwhile. Recorded whether or not the workflow compacted, so the share of turns that do is readable off the unnested datapoints.`,
75
+ buckets: import_meters.CALL_COUNT_BUCKETS
76
+ }),
77
+ tokens: (0, import_meters.createTokenHistograms)(
78
+ meter,
79
+ "adk.experimental.invoke_workflow",
80
+ PER_WORKFLOW
81
+ )
82
+ })
83
+ );
84
+ function recordWorkflowDuration({
85
+ workflowName,
86
+ durationSeconds,
87
+ nested,
88
+ errorType
89
+ }) {
90
+ const attributes = {
91
+ [import_attributes.GenAiAttr.OPERATION_NAME]: "invoke_workflow",
92
+ ...nested ? { [import_attributes.GenAiAttr.WORKFLOW_NESTED]: true } : {},
93
+ ...errorType === void 0 ? {} : { [import_attributes.ERROR_TYPE_ATTR]: errorType },
94
+ ...workflowName ? { [import_attributes.GenAiAttr.WORKFLOW_NAME]: workflowName } : {}
95
+ };
96
+ getWorkflowInstruments().duration.record(durationSeconds, attributes);
97
+ }
98
+ __name(recordWorkflowDuration, "recordWorkflowDuration");
99
+ function recordWorkflowTotals({
100
+ rootAgentName,
101
+ workflowName,
102
+ nested,
103
+ totals,
104
+ config
105
+ }) {
106
+ if (!(0, import_config.isExperimentalFeatureEnabled)(config, "workflow")) {
107
+ return;
108
+ }
109
+ const instruments = getWorkflowInstruments();
110
+ const attributes = {
111
+ [import_attributes.AdkAttr.EXPERIMENTAL_ROOT_AGENT_NAME]: rootAgentName,
112
+ ...workflowName ? { [import_attributes.GenAiAttr.WORKFLOW_NAME]: workflowName } : {},
113
+ ...nested ? { [import_attributes.GenAiAttr.WORKFLOW_NESTED]: true } : {}
114
+ };
115
+ if (totals.tokens !== void 0 && (0, import_config.isExperimentalFeatureEnabled)(config, "token_usage")) {
116
+ (0, import_meters.recordTokenHistograms)(instruments.tokens, totals.tokens, attributes);
117
+ }
118
+ instruments.inferenceCalls.record(totals.inferenceCalls, attributes);
119
+ instruments.toolCalls.record(totals.toolCalls, attributes);
120
+ if ((0, import_config.isExperimentalFeatureEnabled)(config, "skills")) {
121
+ instruments.skillLoads.record(totals.skillLoads, attributes);
122
+ }
123
+ if ((0, import_config.isExperimentalFeatureEnabled)(config, "compaction")) {
124
+ instruments.compactions.record(totals.compactions, attributes);
125
+ }
126
+ }
127
+ __name(recordWorkflowTotals, "recordWorkflowTotals");
128
+ // Annotate the CommonJS export names for ESM import in node:
129
+ 0 && (module.exports = {
130
+ recordWorkflowDuration,
131
+ recordWorkflowTotals
132
+ });
@@ -0,0 +1,52 @@
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 agent_exports = {};
27
+ __export(agent_exports, {
28
+ buildAgentInvocationAttributes: () => buildAgentInvocationAttributes
29
+ });
30
+ module.exports = __toCommonJS(agent_exports);
31
+ var import_attributes = require("../common/attributes.js");
32
+ /**
33
+ * @license
34
+ * Copyright 2026 Google LLC
35
+ * SPDX-License-Identifier: Apache-2.0
36
+ */
37
+ function buildAgentInvocationAttributes({
38
+ agent,
39
+ sessionId
40
+ }) {
41
+ return {
42
+ [import_attributes.GenAiAttr.OPERATION_NAME]: "invoke_agent",
43
+ [import_attributes.GenAiAttr.AGENT_DESCRIPTION]: agent.description,
44
+ [import_attributes.GenAiAttr.AGENT_NAME]: agent.name,
45
+ ...sessionId === void 0 ? {} : { [import_attributes.GenAiAttr.CONVERSATION_ID]: sessionId }
46
+ };
47
+ }
48
+ __name(buildAgentInvocationAttributes, "buildAgentInvocationAttributes");
49
+ // Annotate the CommonJS export names for ESM import in node:
50
+ 0 && (module.exports = {
51
+ buildAgentInvocationAttributes
52
+ });
@@ -0,0 +1,78 @@
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 compaction_exports = {};
27
+ __export(compaction_exports, {
28
+ buildCompactionResultAttributes: () => buildCompactionResultAttributes,
29
+ startCompactionSpan: () => startCompactionSpan
30
+ });
31
+ module.exports = __toCommonJS(compaction_exports);
32
+ var import_compacted_event = require("../../../../events/compacted_event.js");
33
+ var import_case_utils = require("../../../../utils/case_utils.js");
34
+ var import_attributes = require("../common/attributes.js");
35
+ var import_provider_name = require("../common/provider_name.js");
36
+ var import_tracer = require("./tracer.js");
37
+ /**
38
+ * @license
39
+ * Copyright 2026 Google LLC
40
+ * SPDX-License-Identifier: Apache-2.0
41
+ */
42
+ function startCompactionSpan({
43
+ sessionId,
44
+ trigger
45
+ }) {
46
+ const triggerName = (0, import_case_utils.toSnakeCaseName)(trigger);
47
+ return (0, import_tracer.getTracer)().startSpan(`compact_events ${triggerName}`, {
48
+ attributes: {
49
+ [import_attributes.GenAiAttr.SYSTEM]: (0, import_provider_name.guessGeminiSystemName)(),
50
+ [import_attributes.GenAiAttr.OPERATION_NAME]: "compact_events",
51
+ [import_attributes.GenAiAttr.CONVERSATION_ID]: sessionId,
52
+ [import_attributes.GenAiAttr.COMPACTION_TRIGGER]: triggerName
53
+ }
54
+ });
55
+ }
56
+ __name(startCompactionSpan, "startCompactionSpan");
57
+ function buildCompactionResultAttributes(eventsBefore, eventsAfter) {
58
+ const before = new Set(eventsBefore);
59
+ const compactedEvent = eventsAfter.filter((event) => !before.has(event)).find(import_compacted_event.isCompactedEvent);
60
+ if (!compactedEvent) {
61
+ return {};
62
+ }
63
+ const { startTime, endTime } = compactedEvent;
64
+ return {
65
+ [import_attributes.GenAiAttr.COMPACTION_EVENT_COUNT]: eventsBefore.filter(
66
+ (event) => event.timestamp >= startTime && event.timestamp <= endTime
67
+ ).length,
68
+ [import_attributes.GenAiAttr.COMPACTION_RESULT_EVENT_ID]: compactedEvent.id,
69
+ [import_attributes.GenAiAttr.COMPACTION_START_TIMESTAMP]: startTime,
70
+ [import_attributes.GenAiAttr.COMPACTION_END_TIMESTAMP]: endTime
71
+ };
72
+ }
73
+ __name(buildCompactionResultAttributes, "buildCompactionResultAttributes");
74
+ // Annotate the CommonJS export names for ESM import in node:
75
+ 0 && (module.exports = {
76
+ buildCompactionResultAttributes,
77
+ startCompactionSpan
78
+ });