@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,244 @@
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 __decorateClass = (decorators, target, key, kind) => {
27
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
28
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
29
+ if (decorator = decorators[i])
30
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
31
+ if (kind && result) __defProp(target, key, result);
32
+ return result;
33
+ };
34
+ var computer_use_tool_exports = {};
35
+ __export(computer_use_tool_exports, {
36
+ ComputerUseTool: () => ComputerUseTool,
37
+ isComputerUseTool: () => isComputerUseTool
38
+ });
39
+ module.exports = __toCommonJS(computer_use_tool_exports);
40
+ var import_env_aware_utils = require("../../utils/env_aware_utils.js");
41
+ var import_experimental = require("../../utils/experimental.js");
42
+ var import_logger = require("../../utils/logger.js");
43
+ var import_function_tool = require("../function_tool.js");
44
+ var import_base_computer = require("./base_computer.js");
45
+ /**
46
+ * @license
47
+ * Copyright 2026 Google LLC
48
+ * SPDX-License-Identifier: Apache-2.0
49
+ */
50
+ var _a, _b;
51
+ const DEFAULT_VIRTUAL_SCREEN_SIZE = [1e3, 1e3];
52
+ const X_COORDINATE_FIELDS = ["x", "destination_x", "start_x", "end_x"];
53
+ const Y_COORDINATE_FIELDS = ["y", "destination_y", "start_y", "end_y"];
54
+ const INTEGER_STRING = /^-?\d+$/;
55
+ const REQUIRE_CONFIRMATION = "require_confirmation";
56
+ const COMPUTER_USE_TOOL_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
57
+ "google.adk.computerUseTool"
58
+ );
59
+ function isComputerUseTool(obj) {
60
+ return typeof obj === "object" && obj !== null && COMPUTER_USE_TOOL_SIGNATURE_SYMBOL in obj && obj[COMPUTER_USE_TOOL_SIGNATURE_SYMBOL] === true;
61
+ }
62
+ __name(isComputerUseTool, "isComputerUseTool");
63
+ let ComputerUseTool = class extends (_b = import_function_tool.FunctionTool, _a = COMPUTER_USE_TOOL_SIGNATURE_SYMBOL, _b) {
64
+ /**
65
+ * @param options The options for the tool.
66
+ * @throws {Error} If `screenSize` or `virtualScreenSize` is not a pair of
67
+ * positive numbers.
68
+ */
69
+ constructor(options) {
70
+ var _a2;
71
+ (0, import_base_computer.checkComputerUseEnabled)();
72
+ const virtualScreenSize = (_a2 = options.virtualScreenSize) != null ? _a2 : DEFAULT_VIRTUAL_SCREEN_SIZE;
73
+ checkScreenSize("screenSize", options.screenSize);
74
+ checkScreenSize("virtualScreenSize", virtualScreenSize);
75
+ const func = options.execute;
76
+ super({
77
+ name: options.name,
78
+ description: options.description,
79
+ parameters: options.parameters,
80
+ execute: /* @__PURE__ */ __name((input, toolContext) => func(isRecord(input) ? input : {}, toolContext), "execute")
81
+ });
82
+ /** A unique symbol to identify ADK computer use tool class. */
83
+ this[_a] = true;
84
+ this.func = func;
85
+ this.screenSize = options.screenSize;
86
+ this.virtualScreenSize = virtualScreenSize;
87
+ }
88
+ /**
89
+ * Runs the computer control function with scaled coordinates.
90
+ *
91
+ * @param request The tool request containing arguments and tool context.
92
+ * @returns The function's result, with a {@link ComputerState} converted to
93
+ * a response carrying the base64-encoded screenshot.
94
+ * @throws {Error} If a coordinate is not numeric, or the function returns a
95
+ * state with no screenshot.
96
+ */
97
+ async runAsync({
98
+ args,
99
+ toolContext
100
+ }) {
101
+ const confirmation = toolContext.toolConfirmation;
102
+ if (!confirmation) {
103
+ const safetyDecision = getSafetyDecision(args);
104
+ if ((safetyDecision == null ? void 0 : safetyDecision.decision) === REQUIRE_CONFIRMATION) {
105
+ toolContext.requestConfirmation({
106
+ hint: typeof safetyDecision.explanation === "string" && safetyDecision.explanation ? safetyDecision.explanation : "This computer use action requires safety confirmation."
107
+ });
108
+ toolContext.actions.skipSummarization = true;
109
+ return {
110
+ error: "This tool call requires confirmation, please approve or reject."
111
+ };
112
+ }
113
+ } else if (!confirmation.confirmed) {
114
+ return { error: "This tool call is rejected." };
115
+ }
116
+ const scaledArgs = this.scaleCoordinates(args);
117
+ const result = await super.runAsync({ args: scaledArgs, toolContext });
118
+ let response = result;
119
+ if (isComputerState(result)) {
120
+ if (!result.screenshot) {
121
+ throw new Error(
122
+ "A computer action returned a state with no screenshot"
123
+ );
124
+ }
125
+ response = {
126
+ image: { mimetype: "image/png", data: (0, import_env_aware_utils.base64Encode)(result.screenshot) },
127
+ url: result.url
128
+ };
129
+ }
130
+ if (confirmation == null ? void 0 : confirmation.confirmed) {
131
+ const acknowledged = isRecord(response) ? response : { result: response };
132
+ acknowledged["safety_acknowledgement"] = "true";
133
+ return acknowledged;
134
+ }
135
+ return response;
136
+ }
137
+ /**
138
+ * Whether this call needs user confirmation: when the model marked it with
139
+ * a `safety_decision` of `require_confirmation`, or when the base tool says
140
+ * so.
141
+ *
142
+ * @param args The arguments the tool would run with.
143
+ * @param toolContext The context of the call, when there is one.
144
+ * @returns Whether the call requires confirmation.
145
+ */
146
+ async checkRequireConfirmation(args, toolContext) {
147
+ var _a2;
148
+ if (((_a2 = getSafetyDecision(args)) == null ? void 0 : _a2.decision) === REQUIRE_CONFIRMATION) {
149
+ return true;
150
+ }
151
+ return super.checkRequireConfirmation(args, toolContext);
152
+ }
153
+ /**
154
+ * Adds nothing to the request: {@link ComputerUseToolset} adds the single
155
+ * computer use configuration and registers its tools by name.
156
+ */
157
+ async processLlmRequest(_request) {
158
+ }
159
+ /** Returns a copy of `args` with every coordinate scaled to the screen. */
160
+ scaleCoordinates(args) {
161
+ const scaled = { ...args };
162
+ delete scaled["safety_decision"];
163
+ for (const field of X_COORDINATE_FIELDS) {
164
+ if (field in scaled) {
165
+ scaled[field] = scaleCoordinate({
166
+ field,
167
+ value: scaled[field],
168
+ virtual: this.virtualScreenSize[0],
169
+ actual: this.screenSize[0]
170
+ });
171
+ }
172
+ }
173
+ for (const field of Y_COORDINATE_FIELDS) {
174
+ if (field in scaled) {
175
+ scaled[field] = scaleCoordinate({
176
+ field,
177
+ value: scaled[field],
178
+ virtual: this.virtualScreenSize[1],
179
+ actual: this.screenSize[1]
180
+ });
181
+ }
182
+ }
183
+ return scaled;
184
+ }
185
+ };
186
+ __name(ComputerUseTool, "ComputerUseTool");
187
+ ComputerUseTool = __decorateClass([
188
+ import_experimental.experimental
189
+ ], ComputerUseTool);
190
+ function scaleCoordinate({
191
+ field,
192
+ value,
193
+ virtual,
194
+ actual
195
+ }) {
196
+ const numeric = typeof value === "string" && INTEGER_STRING.test(value) ? Number(value) : value;
197
+ if (typeof numeric !== "number" || !Number.isFinite(numeric)) {
198
+ throw new Error(
199
+ `${field} coordinate must be numeric, got ${typeof value} ${JSON.stringify(value)}`
200
+ );
201
+ }
202
+ const scaled = Math.max(
203
+ 0,
204
+ Math.min(Math.trunc(numeric / virtual * actual), actual - 1)
205
+ );
206
+ import_logger.logger.debug(`Normalized ${field}: ${numeric} -> ${scaled}`);
207
+ return scaled;
208
+ }
209
+ __name(scaleCoordinate, "scaleCoordinate");
210
+ function checkScreenSize(name, size) {
211
+ if (!Array.isArray(size) || size.length !== 2) {
212
+ throw new Error(`${name} must be a pair of (width, height)`);
213
+ }
214
+ if (!size.every((dimension) => Number.isFinite(dimension) && dimension > 0)) {
215
+ throw new Error(`${name} dimensions must be positive`);
216
+ }
217
+ }
218
+ __name(checkScreenSize, "checkScreenSize");
219
+ function getSafetyDecision(args) {
220
+ const decision = args["safety_decision"];
221
+ return isRecord(decision) ? decision : void 0;
222
+ }
223
+ __name(getSafetyDecision, "getSafetyDecision");
224
+ function isRecord(value) {
225
+ return typeof value === "object" && value !== null && !Array.isArray(value);
226
+ }
227
+ __name(isRecord, "isRecord");
228
+ function isComputerState(value) {
229
+ if (!isRecord(value)) {
230
+ return false;
231
+ }
232
+ const keys = Object.keys(value);
233
+ if (keys.length === 0 || keys.some((k) => k !== "screenshot" && k !== "url")) {
234
+ return false;
235
+ }
236
+ const { screenshot, url } = value;
237
+ return (screenshot === void 0 || screenshot instanceof Uint8Array) && (url === void 0 || typeof url === "string");
238
+ }
239
+ __name(isComputerState, "isComputerState");
240
+ // Annotate the CommonJS export names for ESM import in node:
241
+ 0 && (module.exports = {
242
+ ComputerUseTool,
243
+ isComputerUseTool
244
+ });
@@ -0,0 +1,360 @@
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 __decorateClass = (decorators, target, key, kind) => {
27
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
28
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
29
+ if (decorator = decorators[i])
30
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
31
+ if (kind && result) __defProp(target, key, result);
32
+ return result;
33
+ };
34
+ var computer_use_toolset_exports = {};
35
+ __export(computer_use_toolset_exports, {
36
+ ComputerUseToolset: () => ComputerUseToolset,
37
+ adaptComputerUseTool: () => adaptComputerUseTool,
38
+ isComputerUseToolset: () => isComputerUseToolset
39
+ });
40
+ module.exports = __toCommonJS(computer_use_toolset_exports);
41
+ var import_genai = require("@google/genai");
42
+ var import_experimental = require("../../utils/experimental.js");
43
+ var import_logger = require("../../utils/logger.js");
44
+ var import_model_name = require("../../utils/model_name.js");
45
+ var import_base_toolset = require("../base_toolset.js");
46
+ var import_base_computer = require("./base_computer.js");
47
+ var import_computer_use_actions = require("./computer_use_actions.js");
48
+ var import_computer_use_tool = require("./computer_use_tool.js");
49
+ /**
50
+ * @license
51
+ * Copyright 2026 Google LLC
52
+ * SPDX-License-Identifier: Apache-2.0
53
+ */
54
+ var _a, _b;
55
+ const DIRECT_EXCLUSION_MAP = Object.freeze({
56
+ // Legacy -> modern.
57
+ click_at: ["click"],
58
+ hover_at: ["move"],
59
+ type_text_at: ["type"],
60
+ type_text: ["type"],
61
+ scroll_at: ["scroll"],
62
+ // Whole-page scroll has no modern counterpart.
63
+ scroll_document: [],
64
+ current_state: ["take_screenshot"],
65
+ key_combination: ["press_key", "hotkey"],
66
+ wait_5_seconds: ["wait"],
67
+ // Modern -> legacy.
68
+ click: ["click_at"],
69
+ move: ["hover_at"],
70
+ type: ["type_text_at"],
71
+ // Does not drop scroll_document.
72
+ scroll: ["scroll_at"],
73
+ take_screenshot: ["current_state"],
74
+ // key_combination is dropped only when both of these are excluded.
75
+ press_key: [],
76
+ hotkey: [],
77
+ wait: ["wait_5_seconds"]
78
+ });
79
+ const LEGACY_EXCLUSION_NAMES = /* @__PURE__ */ new Set([
80
+ "click_at",
81
+ "hover_at",
82
+ "type_text_at",
83
+ "type_text",
84
+ "scroll_at",
85
+ "scroll_document",
86
+ "current_state",
87
+ "key_combination",
88
+ "wait_5_seconds"
89
+ ]);
90
+ const MODERN_EXCLUSION_NAMES = /* @__PURE__ */ new Set([
91
+ "click",
92
+ "move",
93
+ "type",
94
+ "scroll",
95
+ "take_screenshot",
96
+ "press_key",
97
+ "hotkey",
98
+ "wait",
99
+ ...import_computer_use_actions.OPTIONAL_MOUSE_ACTIONS,
100
+ ...import_computer_use_actions.OPTIONAL_KEY_ACTIONS
101
+ ]);
102
+ const TYPING_ACTIONS = ["type", "type_text_at", "type_text"];
103
+ const computerQueues = /* @__PURE__ */ new WeakMap();
104
+ function expandLocalExclusions(excludedNames) {
105
+ var _a2;
106
+ const expanded = new Set(excludedNames);
107
+ for (const name of excludedNames) {
108
+ for (const counterpart of (_a2 = DIRECT_EXCLUSION_MAP[name]) != null ? _a2 : []) {
109
+ expanded.add(counterpart);
110
+ }
111
+ }
112
+ if (TYPING_ACTIONS.some((name) => expanded.has(name))) {
113
+ TYPING_ACTIONS.forEach((name) => expanded.add(name));
114
+ }
115
+ if (expanded.has("press_key") && expanded.has("hotkey")) {
116
+ expanded.add("key_combination");
117
+ }
118
+ return expanded;
119
+ }
120
+ __name(expandLocalExclusions, "expandLocalExclusions");
121
+ function resolveExcludedPredefinedFunctions({
122
+ excludedNames,
123
+ model,
124
+ unimplementedActions
125
+ }) {
126
+ var _a2;
127
+ const major = (0, import_model_name.getGeminiMajorVersion)(model);
128
+ if (major !== void 0 && major < 3) {
129
+ if (excludedNames === void 0) {
130
+ return void 0;
131
+ }
132
+ const bothModernKeys = excludedNames.includes("press_key") && excludedNames.includes("hotkey");
133
+ const resolved2 = [];
134
+ for (const name of excludedNames) {
135
+ if (name === "press_key" || name === "hotkey") {
136
+ if (bothModernKeys) {
137
+ resolved2.push("key_combination");
138
+ }
139
+ } else if (name === "type_text") {
140
+ resolved2.push("type_text_at");
141
+ } else if (MODERN_EXCLUSION_NAMES.has(name)) {
142
+ resolved2.push(...(_a2 = DIRECT_EXCLUSION_MAP[name]) != null ? _a2 : []);
143
+ } else {
144
+ resolved2.push(name);
145
+ }
146
+ }
147
+ return [...new Set(resolved2)];
148
+ }
149
+ const resolved = [];
150
+ for (const name of excludedNames != null ? excludedNames : []) {
151
+ if (LEGACY_EXCLUSION_NAMES.has(name)) {
152
+ resolved.push(...DIRECT_EXCLUSION_MAP[name]);
153
+ } else {
154
+ resolved.push(name);
155
+ }
156
+ }
157
+ if (major !== void 0 && major >= 3) {
158
+ resolved.push(...unimplementedActions);
159
+ }
160
+ const deduped = [...new Set(resolved)];
161
+ if (deduped.length === 0 && excludedNames === void 0) {
162
+ return void 0;
163
+ }
164
+ return deduped;
165
+ }
166
+ __name(resolveExcludedPredefinedFunctions, "resolveExcludedPredefinedFunctions");
167
+ async function runExclusive(computer, action) {
168
+ var _a2;
169
+ const previous = (_a2 = computerQueues.get(computer)) != null ? _a2 : Promise.resolve();
170
+ const result = previous.then(action);
171
+ computerQueues.set(
172
+ computer,
173
+ result.then(
174
+ () => void 0,
175
+ () => void 0
176
+ )
177
+ );
178
+ return result;
179
+ }
180
+ __name(runExclusive, "runExclusive");
181
+ function toGenaiEnvironment(environment) {
182
+ switch (environment) {
183
+ case import_base_computer.ComputerEnvironment.ENVIRONMENT_UNSPECIFIED:
184
+ return import_genai.Environment.ENVIRONMENT_UNSPECIFIED;
185
+ case import_base_computer.ComputerEnvironment.ENVIRONMENT_BROWSER:
186
+ return import_genai.Environment.ENVIRONMENT_BROWSER;
187
+ default: {
188
+ const exhaustive = environment;
189
+ throw new Error(`Unknown computer environment: ${exhaustive}`);
190
+ }
191
+ }
192
+ }
193
+ __name(toGenaiEnvironment, "toGenaiEnvironment");
194
+ function isComputerUseConfig(tool) {
195
+ return "computerUse" in tool && tool.computerUse !== void 0;
196
+ }
197
+ __name(isComputerUseConfig, "isComputerUseConfig");
198
+ async function adaptComputerUseTool({
199
+ methodName,
200
+ adapter,
201
+ llmRequest
202
+ }) {
203
+ if (!import_computer_use_actions.LEGACY_ACTION_NAMES.includes(methodName)) {
204
+ import_logger.logger.warn(`Method ${methodName} is not a valid BaseComputer method`);
205
+ return;
206
+ }
207
+ const original = Object.hasOwn(llmRequest.toolsDict, methodName) ? llmRequest.toolsDict[methodName] : void 0;
208
+ if (!(0, import_computer_use_tool.isComputerUseTool)(original)) {
209
+ import_logger.logger.warn(`Method ${methodName} not found in toolsDict`);
210
+ return;
211
+ }
212
+ const adapted = await adapter(original.func);
213
+ llmRequest.toolsDict[adapted.name] = new import_computer_use_tool.ComputerUseTool({
214
+ ...adapted,
215
+ screenSize: original.screenSize,
216
+ virtualScreenSize: original.virtualScreenSize
217
+ });
218
+ if (adapted.name !== methodName) {
219
+ delete llmRequest.toolsDict[methodName];
220
+ }
221
+ import_logger.logger.debug(`Adapted tool ${methodName} to ${adapted.name}`);
222
+ }
223
+ __name(adaptComputerUseTool, "adaptComputerUseTool");
224
+ const COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
225
+ "google.adk.computerUseToolset"
226
+ );
227
+ function isComputerUseToolset(obj) {
228
+ return typeof obj === "object" && obj !== null && COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL in obj && obj[COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL] === true;
229
+ }
230
+ __name(isComputerUseToolset, "isComputerUseToolset");
231
+ let ComputerUseToolset = class extends (_b = import_base_toolset.BaseToolset, _a = COMPUTER_USE_TOOLSET_SIGNATURE_SYMBOL, _b) {
232
+ /**
233
+ * @param options The computer and its configuration.
234
+ */
235
+ constructor(options) {
236
+ var _a2;
237
+ (0, import_base_computer.checkComputerUseEnabled)();
238
+ super([]);
239
+ /** A unique symbol to identify ADK computer use toolset class. */
240
+ this[_a] = true;
241
+ this.closed = false;
242
+ this.computer = options.computer;
243
+ this.excludedPredefinedFunctions = options.excludedPredefinedFunctions;
244
+ this.allowPrivateNetworkAccess = (_a2 = options.allowPrivateNetworkAccess) != null ? _a2 : false;
245
+ }
246
+ /**
247
+ * Returns a tool for every action the computer supports, except the
248
+ * excluded ones. The computer is initialized on the first call, and the
249
+ * tools are cached until {@link close}.
250
+ */
251
+ async getTools() {
252
+ var _a2;
253
+ (_a2 = this.loadingTools) != null ? _a2 : this.loadingTools = this.loadTools();
254
+ try {
255
+ return await this.loadingTools;
256
+ } catch (error) {
257
+ this.loadingTools = void 0;
258
+ throw error;
259
+ }
260
+ }
261
+ /**
262
+ * Closes the computer and drops the cached tools. The next call to
263
+ * {@link getTools} initializes the computer again.
264
+ */
265
+ async close() {
266
+ if (!this.closed) {
267
+ await this.computer.close();
268
+ this.closed = true;
269
+ }
270
+ this.initializing = void 0;
271
+ this.loadingTools = void 0;
272
+ }
273
+ /**
274
+ * Registers the computer use tools in the request and adds the computer use
275
+ * configuration, unless the request already has one.
276
+ *
277
+ * @param _toolContext The context of the tool.
278
+ * @param llmRequest The outgoing request.
279
+ */
280
+ async processLlmRequest(_toolContext, llmRequest) {
281
+ var _a2, _b2, _c;
282
+ for (const tool of await this.getTools()) {
283
+ llmRequest.toolsDict[tool.name] = tool;
284
+ }
285
+ (_a2 = llmRequest.config) != null ? _a2 : llmRequest.config = {};
286
+ (_c = (_b2 = llmRequest.config).tools) != null ? _c : _b2.tools = [];
287
+ if (llmRequest.config.tools.some(isComputerUseConfig)) {
288
+ import_logger.logger.debug("Computer use already configured in LLM request");
289
+ return;
290
+ }
291
+ const environment = toGenaiEnvironment(await this.computer.environment());
292
+ const excludedPredefinedFunctions = resolveExcludedPredefinedFunctions({
293
+ excludedNames: this.excludedPredefinedFunctions,
294
+ model: llmRequest.model,
295
+ unimplementedActions: (0, import_computer_use_actions.unimplementedOptionalActions)(this.computer)
296
+ });
297
+ llmRequest.config.tools.push({
298
+ computerUse: excludedPredefinedFunctions === void 0 ? { environment } : { environment, excludedPredefinedFunctions }
299
+ });
300
+ import_logger.logger.debug(
301
+ `Added computer use tool with environment: ${environment}, excluded functions: ${excludedPredefinedFunctions}`
302
+ );
303
+ }
304
+ ensureInitialized() {
305
+ var _a2;
306
+ (_a2 = this.initializing) != null ? _a2 : this.initializing = this.computer.initialize().then(
307
+ () => {
308
+ this.closed = false;
309
+ },
310
+ (error) => {
311
+ this.initializing = void 0;
312
+ throw error;
313
+ }
314
+ );
315
+ return this.initializing;
316
+ }
317
+ async loadTools() {
318
+ var _a2;
319
+ await this.ensureInitialized();
320
+ const screenSize = await this.computer.screenSize();
321
+ const excluded = expandLocalExclusions(
322
+ (_a2 = this.excludedPredefinedFunctions) != null ? _a2 : []
323
+ );
324
+ return (0, import_computer_use_actions.createComputerActions)({
325
+ computer: this.computer,
326
+ allowPrivateNetworkAccess: this.allowPrivateNetworkAccess
327
+ }).filter((action) => !excluded.has(action.name)).map(
328
+ (action) => new import_computer_use_tool.ComputerUseTool({
329
+ name: action.name,
330
+ description: action.description,
331
+ parameters: action.parameters,
332
+ execute: this.bindToComputer(action),
333
+ screenSize
334
+ })
335
+ );
336
+ }
337
+ /**
338
+ * Wraps an action so it runs exclusively on the computer, after the
339
+ * computer has prepared for the calling session.
340
+ */
341
+ bindToComputer(action) {
342
+ const computer = this.computer;
343
+ return (args, toolContext) => runExclusive(computer, async () => {
344
+ if (toolContext) {
345
+ await computer.prepare(toolContext);
346
+ }
347
+ return action.execute(args);
348
+ });
349
+ }
350
+ };
351
+ __name(ComputerUseToolset, "ComputerUseToolset");
352
+ ComputerUseToolset = __decorateClass([
353
+ import_experimental.experimental
354
+ ], ComputerUseToolset);
355
+ // Annotate the CommonJS export names for ESM import in node:
356
+ 0 && (module.exports = {
357
+ ComputerUseToolset,
358
+ adaptComputerUseTool,
359
+ isComputerUseToolset
360
+ });
@@ -59,9 +59,10 @@ function toResponseSchema(response) {
59
59
  return (0, import_simple_zod_to_json.zodObjectToSchema)(response);
60
60
  }
61
61
  if (typeof response === "object" && response !== null && "safeParse" in response && typeof response.safeParse === "function") {
62
- return (_a2 = (0, import_gemini_schema_util.toGeminiSchema)(
63
- (0, import_schema.toJsonSchema)(response)
64
- )) != null ? _a2 : { type: import_genai.Type.TYPE_UNSPECIFIED };
62
+ const jsonSchema = (0, import_schema.toJsonSchema)(response);
63
+ return (_a2 = (0, import_gemini_schema_util.toGeminiSchema)(jsonSchema)) != null ? _a2 : {
64
+ type: import_genai.Type.TYPE_UNSPECIFIED
65
+ };
65
66
  }
66
67
  return response;
67
68
  }
@@ -281,6 +282,11 @@ function annotateNullableFields(schema) {
281
282
  if (!isPlainRecord(propertySchema)) {
282
283
  continue;
283
284
  }
285
+ const propType = propertySchema["type"];
286
+ if (propType === null || propType === "null" || propType === import_genai.Type.NULL) {
287
+ propertySchema["type"] = import_genai.Type.OBJECT;
288
+ propertySchema["nullable"] = true;
289
+ }
284
290
  const anyOf = propertySchema["anyOf"];
285
291
  if (!Array.isArray(anyOf)) {
286
292
  continue;
@@ -383,8 +389,12 @@ function processParameterSchema(vertexai, schema) {
383
389
  __name(processParameterSchema, "processParameterSchema");
384
390
  function mapPropertySchemaType(propertySchema) {
385
391
  var _a2, _b2;
386
- if (typeof propertySchema["type"] === "string") {
387
- propertySchema["type"] = (_a2 = SCHEMA_TYPE_MAP[propertySchema["type"]]) != null ? _a2 : import_genai.Type.TYPE_UNSPECIFIED;
392
+ const rawType = propertySchema["type"];
393
+ if (rawType === null || rawType === "null" || rawType === import_genai.Type.NULL) {
394
+ propertySchema["type"] = import_genai.Type.OBJECT;
395
+ propertySchema["nullable"] = true;
396
+ } else if (typeof rawType === "string") {
397
+ propertySchema["type"] = (_a2 = SCHEMA_TYPE_MAP[rawType]) != null ? _a2 : import_genai.Type.TYPE_UNSPECIFIED;
388
398
  if (propertySchema["type"] === import_genai.Type.ARRAY && isPlainRecord(propertySchema["items"])) {
389
399
  mapPropertySchemaType(propertySchema["items"]);
390
400
  }
@@ -71,6 +71,7 @@ let GoogleApiToolset = class extends (_b = import_base_toolset.BaseToolset, _a =
71
71
  this.apiVersion = options.apiVersion;
72
72
  this.clientId = options.clientId;
73
73
  this.clientSecret = options.clientSecret;
74
+ this.scopes = options.scopes ? [...options.scopes] : void 0;
74
75
  }
75
76
  async loadToolsetWithOidcAuth() {
76
77
  var _a2, _b2, _c, _d, _e;
@@ -86,7 +87,7 @@ let GoogleApiToolset = class extends (_b = import_base_toolset.BaseToolset, _a =
86
87
  const oauth2Scheme = (_b2 = (_a2 = specDict.components) == null ? void 0 : _a2.securitySchemes) == null ? void 0 : _b2["oauth2"];
87
88
  const scopesMap = (_e = (_d = (_c = oauth2Scheme == null ? void 0 : oauth2Scheme.flows) == null ? void 0 : _c.authorizationCode) == null ? void 0 : _d.scopes) != null ? _e : {};
88
89
  const firstScope = Object.keys(scopesMap)[0];
89
- const scopes = firstScope ? [firstScope] : void 0;
90
+ const scopes = this.scopes !== void 0 ? [...this.scopes] : firstScope ? [firstScope] : void 0;
90
91
  const authScheme = {
91
92
  type: "openIdConnect",
92
93
  openIdConnectUrl: "",
@@ -109,7 +110,7 @@ let GoogleApiToolset = class extends (_b = import_base_toolset.BaseToolset, _a =
109
110
  }
110
111
  async ensureToolsLoaded() {
111
112
  var _a2;
112
- if (this.openapiToolset || !this.apiName || !this.apiVersion) {
113
+ if (this.openapiToolset) {
113
114
  return;
114
115
  }
115
116
  (_a2 = this.loadingPromise) != null ? _a2 : this.loadingPromise = (async () => {
@@ -251,11 +251,13 @@ function convertOperation(methodData, pathParams) {
251
251
  var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j;
252
252
  const parameters = [];
253
253
  for (const paramName of pathParams) {
254
+ const paramData = methodData.parameters && Object.hasOwn(methodData.parameters, paramName) ? methodData.parameters[paramName] : void 0;
254
255
  parameters.push({
255
256
  name: paramName,
256
257
  in: "path",
258
+ ...(paramData == null ? void 0 : paramData.description) !== void 0 ? { description: paramData.description } : {},
257
259
  required: true,
258
- schema: { type: "string" }
260
+ schema: paramData ? convertParameterSchema(paramData) : { type: "string" }
259
261
  });
260
262
  }
261
263
  const pathParamSet = new Set(pathParams);