@google/adk 2.2.1 → 2.4.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 (298) hide show
  1. package/dist/cjs/a2a/a2a_remote_agent.js +4 -1
  2. package/dist/cjs/a2a/agent_card.js +102 -26
  3. package/dist/cjs/a2a/agent_to_a2a.js +1 -1
  4. package/dist/cjs/agents/agent_engine_client.js +172 -0
  5. package/dist/cjs/agents/base_agent.js +20 -4
  6. package/dist/cjs/agents/functions.js +227 -25
  7. package/dist/cjs/agents/instructions.js +6 -2
  8. package/dist/cjs/agents/invocation_context.js +26 -4
  9. package/dist/cjs/agents/langgraph_agent.js +152 -0
  10. package/dist/cjs/agents/llm_agent.js +194 -107
  11. package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
  12. package/dist/cjs/agents/processors/code_execution_request_processor.js +18 -6
  13. package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
  14. package/dist/cjs/agents/processors/content_request_processor.js +34 -2
  15. package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
  16. package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
  17. package/dist/cjs/artifacts/in_memory_artifact_service.js +14 -0
  18. package/dist/cjs/auth/auth_handler.js +37 -5
  19. package/dist/cjs/auth/auth_schemes.js +9 -0
  20. package/dist/cjs/cli/cli_eval.js +532 -0
  21. package/dist/cjs/cli/utils/envs.js +116 -0
  22. package/dist/cjs/cli/utils/evals.js +137 -0
  23. package/dist/cjs/cli/utils/logs.js +150 -0
  24. package/dist/cjs/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  25. package/dist/cjs/code_executors/code_execution_utils.js +48 -16
  26. package/dist/cjs/code_executors/code_executor_context.js +6 -2
  27. package/dist/cjs/code_executors/container_code_executor.js +27 -16
  28. package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
  29. package/dist/cjs/common.js +61 -0
  30. package/dist/cjs/context/summarizers/llm_summarizer.js +12 -10
  31. package/dist/cjs/context/token_based_context_compactor.js +2 -1
  32. package/dist/cjs/errors/input_validation_error.js +3 -2
  33. package/dist/cjs/events/event.js +4 -2
  34. package/dist/cjs/examples/example_util.js +23 -2
  35. package/dist/cjs/flows/llm_flows/audio_transcriber.js +170 -0
  36. package/dist/cjs/index.js +104 -1
  37. package/dist/cjs/integrations/agent_registry/helpers.js +1 -1
  38. package/dist/cjs/models/gemini_llm_connection.js +16 -8
  39. package/dist/cjs/models/google_llm.js +13 -16
  40. package/dist/cjs/models/llm_response.js +9 -1
  41. package/dist/cjs/models/registry.js +1 -1
  42. package/dist/cjs/models/routed_llm.js +9 -8
  43. package/dist/cjs/planners/plan_re_act_planner.js +1 -1
  44. package/dist/cjs/plugins/base_plugin.js +13 -23
  45. package/dist/cjs/runner/in_memory_runner.js +6 -11
  46. package/dist/cjs/runner/runner.js +105 -33
  47. package/dist/cjs/sessions/base_session_service.js +14 -8
  48. package/dist/cjs/sessions/database_session_service.js +50 -28
  49. package/dist/cjs/sessions/db/operations.js +1 -1
  50. package/dist/cjs/sessions/in_memory_session_service.js +3 -1
  51. package/dist/cjs/sessions/stale_session_error.js +59 -0
  52. package/dist/cjs/sessions/state.js +8 -4
  53. package/dist/cjs/sessions/vertex_ai_session_service.js +34 -15
  54. package/dist/cjs/skills/loader.js +52 -18
  55. package/dist/cjs/telemetry/setup.js +0 -1
  56. package/dist/cjs/telemetry/tracing.js +147 -73
  57. package/dist/cjs/tools/agent_tool.js +44 -0
  58. package/dist/cjs/tools/apihub_tool/apihub_toolset.js +137 -0
  59. package/dist/cjs/tools/apihub_tool/clients/apihub_client.js +272 -0
  60. package/dist/cjs/tools/apihub_tool/clients/secret_client.js +148 -0
  61. package/dist/cjs/tools/apihub_tool/clients/service_account.js +48 -0
  62. package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +263 -0
  63. package/dist/cjs/tools/application_integration_tool/clients/cloud_request.js +133 -0
  64. package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +671 -0
  65. package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +223 -0
  66. package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -0
  67. package/dist/cjs/tools/example_tool.js +10 -0
  68. package/dist/cjs/tools/function_tool.js +319 -0
  69. package/dist/cjs/tools/google_api_tool/google_api_tool.js +100 -0
  70. package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
  71. package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
  72. package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +440 -0
  73. package/dist/cjs/tools/google_api_tool/index.js +61 -0
  74. package/dist/cjs/tools/load_artifacts_tool.js +12 -6
  75. package/dist/cjs/tools/load_memory_tool.js +12 -10
  76. package/dist/cjs/tools/mcp/index.js +12 -0
  77. package/dist/cjs/tools/mcp/mcp_session_manager.js +25 -0
  78. package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
  79. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +1 -2
  80. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +46 -2
  81. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
  82. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  83. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
  84. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
  85. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +14 -2
  86. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
  87. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
  88. package/dist/cjs/tools/retrieval/base_retrieval_tool.js +18 -3
  89. package/dist/cjs/tools/toolbox_toolset.js +174 -0
  90. package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
  91. package/dist/cjs/utils/client_labels.js +19 -2
  92. package/dist/cjs/utils/env_aware_utils.js +6 -8
  93. package/dist/cjs/utils/error_utils.js +11 -11
  94. package/dist/cjs/utils/failover_utils.js +1 -1
  95. package/dist/cjs/utils/file_extension_utils.js +11 -0
  96. package/dist/cjs/utils/file_utils.js +2 -24
  97. package/dist/cjs/utils/gemini_schema_util.js +28 -7
  98. package/dist/cjs/utils/json_utils.js +49 -0
  99. package/dist/cjs/utils/live_connection_utils.js +4 -5
  100. package/dist/cjs/utils/logger_node.js +11 -1
  101. package/dist/cjs/utils/object_notation_utils.js +6 -3
  102. package/dist/cjs/utils/output_schema_utils.js +5 -2
  103. package/dist/cjs/utils/streaming_utils.js +12 -12
  104. package/dist/cjs/utils/task.js +1 -1
  105. package/dist/cjs/version.js +1 -1
  106. package/dist/esm/a2a/a2a_remote_agent.js +4 -1
  107. package/dist/esm/a2a/agent_card.js +103 -27
  108. package/dist/esm/a2a/agent_to_a2a.js +5 -2
  109. package/dist/esm/agents/agent_engine_client.js +144 -0
  110. package/dist/esm/agents/base_agent.js +20 -4
  111. package/dist/esm/agents/functions.js +226 -25
  112. package/dist/esm/agents/instructions.js +6 -2
  113. package/dist/esm/agents/invocation_context.js +24 -4
  114. package/dist/esm/agents/langgraph_agent.js +123 -0
  115. package/dist/esm/agents/llm_agent.js +204 -110
  116. package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
  117. package/dist/esm/agents/processors/code_execution_request_processor.js +21 -8
  118. package/dist/esm/agents/processors/content_processor_utils.js +38 -10
  119. package/dist/esm/agents/processors/content_request_processor.js +34 -2
  120. package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
  121. package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
  122. package/dist/esm/artifacts/in_memory_artifact_service.js +14 -0
  123. package/dist/esm/auth/auth_handler.js +37 -5
  124. package/dist/esm/auth/auth_schemes.js +8 -0
  125. package/dist/esm/cli/cli_eval.js +510 -0
  126. package/dist/esm/cli/utils/envs.js +78 -0
  127. package/dist/esm/cli/utils/evals.js +109 -0
  128. package/dist/esm/cli/utils/logs.js +111 -0
  129. package/dist/esm/code_executors/agent_engine_sandbox_code_executor.js +7 -2
  130. package/dist/esm/code_executors/code_execution_utils.js +46 -16
  131. package/dist/esm/code_executors/code_executor_context.js +5 -2
  132. package/dist/esm/code_executors/container_code_executor.js +27 -16
  133. package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
  134. package/dist/esm/common.js +65 -4
  135. package/dist/esm/context/summarizers/llm_summarizer.js +12 -10
  136. package/dist/esm/context/token_based_context_compactor.js +2 -1
  137. package/dist/esm/errors/input_validation_error.js +3 -2
  138. package/dist/esm/events/event.js +4 -2
  139. package/dist/esm/examples/example_util.js +21 -1
  140. package/dist/esm/flows/llm_flows/audio_transcriber.js +142 -0
  141. package/dist/esm/index.js +114 -2
  142. package/dist/esm/integrations/agent_registry/helpers.js +1 -1
  143. package/dist/esm/models/gemini_llm_connection.js +16 -8
  144. package/dist/esm/models/google_llm.js +14 -17
  145. package/dist/esm/models/llm_response.js +9 -1
  146. package/dist/esm/models/registry.js +1 -1
  147. package/dist/esm/models/routed_llm.js +9 -8
  148. package/dist/esm/planners/plan_re_act_planner.js +1 -1
  149. package/dist/esm/plugins/base_plugin.js +13 -23
  150. package/dist/esm/runner/in_memory_runner.js +6 -11
  151. package/dist/esm/runner/runner.js +105 -33
  152. package/dist/esm/sessions/base_session_service.js +12 -7
  153. package/dist/esm/sessions/database_session_service.js +49 -28
  154. package/dist/esm/sessions/db/operations.js +1 -1
  155. package/dist/esm/sessions/in_memory_session_service.js +3 -1
  156. package/dist/esm/sessions/stale_session_error.js +31 -0
  157. package/dist/esm/sessions/state.js +8 -4
  158. package/dist/esm/sessions/vertex_ai_session_service.js +34 -15
  159. package/dist/esm/skills/loader.js +51 -17
  160. package/dist/esm/telemetry/setup.js +1 -2
  161. package/dist/esm/telemetry/tracing.js +151 -74
  162. package/dist/esm/tools/agent_tool.js +44 -0
  163. package/dist/esm/tools/apihub_tool/apihub_toolset.js +101 -0
  164. package/dist/esm/tools/apihub_tool/clients/apihub_client.js +244 -0
  165. package/dist/esm/tools/apihub_tool/clients/secret_client.js +132 -0
  166. package/dist/esm/tools/apihub_tool/clients/service_account.js +21 -0
  167. package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +245 -0
  168. package/dist/esm/tools/application_integration_tool/clients/cloud_request.js +103 -0
  169. package/dist/esm/tools/application_integration_tool/clients/connections_client.js +629 -0
  170. package/dist/esm/tools/application_integration_tool/clients/integration_client.js +219 -0
  171. package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -0
  172. package/dist/esm/tools/example_tool.js +13 -1
  173. package/dist/esm/tools/function_tool.js +316 -0
  174. package/dist/esm/tools/google_api_tool/google_api_tool.js +73 -0
  175. package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
  176. package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
  177. package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +393 -0
  178. package/dist/esm/tools/google_api_tool/index.js +31 -0
  179. package/dist/esm/tools/load_artifacts_tool.js +10 -5
  180. package/dist/esm/tools/load_memory_tool.js +12 -10
  181. package/dist/esm/tools/mcp/index.js +6 -0
  182. package/dist/esm/tools/mcp/mcp_session_manager.js +25 -0
  183. package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
  184. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +1 -2
  185. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +50 -3
  186. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +4 -3
  187. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +94 -10
  188. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
  189. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
  190. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -2
  191. package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
  192. package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
  193. package/dist/esm/tools/retrieval/base_retrieval_tool.js +16 -2
  194. package/dist/esm/tools/toolbox_toolset.js +148 -0
  195. package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
  196. package/dist/esm/utils/client_labels.js +19 -2
  197. package/dist/esm/utils/env_aware_utils.js +6 -8
  198. package/dist/esm/utils/error_utils.js +9 -10
  199. package/dist/esm/utils/failover_utils.js +1 -1
  200. package/dist/esm/utils/file_extension_utils.js +11 -0
  201. package/dist/esm/utils/file_utils.js +2 -23
  202. package/dist/esm/utils/gemini_schema_util.js +27 -7
  203. package/dist/esm/utils/json_utils.js +21 -0
  204. package/dist/esm/utils/live_connection_utils.js +4 -5
  205. package/dist/esm/utils/logger_node.js +11 -1
  206. package/dist/esm/utils/object_notation_utils.js +4 -2
  207. package/dist/esm/utils/output_schema_utils.js +5 -2
  208. package/dist/esm/utils/streaming_utils.js +11 -11
  209. package/dist/esm/utils/task.js +1 -1
  210. package/dist/esm/version.js +1 -1
  211. package/dist/types/a2a/a2a_remote_agent.d.ts +9 -0
  212. package/dist/types/a2a/agent_card.d.ts +44 -1
  213. package/dist/types/a2a/agent_to_a2a.d.ts +9 -0
  214. package/dist/types/a2a/index.d.ts +1 -0
  215. package/dist/types/agents/agent_engine_client.d.ts +37 -0
  216. package/dist/types/agents/base_agent.d.ts +12 -0
  217. package/dist/types/agents/functions.d.ts +33 -1
  218. package/dist/types/agents/invocation_context.d.ts +20 -1
  219. package/dist/types/agents/langgraph_agent.d.ts +153 -0
  220. package/dist/types/agents/llm_agent.d.ts +5 -1
  221. package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
  222. package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
  223. package/dist/types/auth/auth_handler.d.ts +28 -1
  224. package/dist/types/auth/auth_schemes.d.ts +13 -0
  225. package/dist/types/cli/cli_eval.d.ts +173 -0
  226. package/dist/types/cli/utils/envs.d.ts +23 -0
  227. package/dist/types/cli/utils/evals.d.ts +47 -0
  228. package/dist/types/cli/utils/logs.d.ts +38 -0
  229. package/dist/types/code_executors/code_execution_utils.d.ts +39 -0
  230. package/dist/types/code_executors/code_executor_context.d.ts +1 -0
  231. package/dist/types/code_executors/container_code_executor.d.ts +17 -5
  232. package/dist/types/common.d.ts +24 -5
  233. package/dist/types/errors/input_validation_error.d.ts +2 -1
  234. package/dist/types/events/event.d.ts +4 -0
  235. package/dist/types/examples/example_util.d.ts +17 -0
  236. package/dist/types/flows/llm_flows/audio_transcriber.d.ts +85 -0
  237. package/dist/types/index.d.ts +19 -2
  238. package/dist/types/models/gemini_llm_connection.d.ts +6 -7
  239. package/dist/types/models/routed_llm.d.ts +1 -1
  240. package/dist/types/plugins/base_plugin.d.ts +0 -10
  241. package/dist/types/runner/in_memory_runner.d.ts +2 -1
  242. package/dist/types/runner/runner.d.ts +34 -0
  243. package/dist/types/sessions/base_session_service.d.ts +5 -0
  244. package/dist/types/sessions/database_session_service.d.ts +17 -1
  245. package/dist/types/sessions/stale_session_error.d.ts +21 -0
  246. package/dist/types/sessions/state.d.ts +5 -1
  247. package/dist/types/sessions/vertex_ai_session_service.d.ts +8 -0
  248. package/dist/types/skills/loader.d.ts +3 -2
  249. package/dist/types/skills/skill.d.ts +1 -1
  250. package/dist/types/telemetry/tracing.d.ts +20 -4
  251. package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +115 -0
  252. package/dist/types/tools/apihub_tool/clients/apihub_client.d.ts +142 -0
  253. package/dist/types/tools/apihub_tool/clients/secret_client.d.ts +55 -0
  254. package/dist/types/tools/apihub_tool/clients/service_account.d.ts +11 -0
  255. package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +109 -0
  256. package/dist/types/tools/application_integration_tool/clients/cloud_request.d.ts +53 -0
  257. package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +229 -0
  258. package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +72 -0
  259. package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
  260. package/dist/types/tools/base_toolset.d.ts +6 -5
  261. package/dist/types/tools/example_tool.d.ts +10 -0
  262. package/dist/types/tools/function_tool.d.ts +32 -0
  263. package/dist/types/tools/google_api_tool/google_api_tool.d.ts +37 -0
  264. package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
  265. package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
  266. package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +165 -0
  267. package/dist/types/tools/google_api_tool/index.d.ts +10 -0
  268. package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
  269. package/dist/types/tools/load_memory_tool.d.ts +23 -1
  270. package/dist/types/tools/mcp/index.d.ts +3 -0
  271. package/dist/types/tools/mcp/mcp_session_manager.d.ts +34 -1
  272. package/dist/types/tools/mcp/mcp_toolset.d.ts +15 -0
  273. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +19 -0
  274. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +18 -1
  275. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
  276. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
  277. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +2 -1
  278. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
  279. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
  280. package/dist/types/tools/retrieval/base_retrieval_tool.d.ts +15 -0
  281. package/dist/types/tools/toolbox_toolset.d.ts +159 -0
  282. package/dist/types/utils/client_labels.d.ts +2 -1
  283. package/dist/types/utils/env_aware_utils.d.ts +18 -2
  284. package/dist/types/utils/error_utils.d.ts +7 -0
  285. package/dist/types/utils/file_utils.d.ts +6 -1
  286. package/dist/types/utils/gemini_schema_util.d.ts +9 -2
  287. package/dist/types/utils/json_utils.d.ts +11 -0
  288. package/dist/types/utils/object_notation_utils.d.ts +7 -0
  289. package/dist/types/utils/output_schema_utils.d.ts +3 -2
  290. package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
  291. package/dist/types/utils/streaming_utils.d.ts +11 -4
  292. package/dist/types/version.d.ts +1 -1
  293. package/dist/web/index_web.js +117 -110
  294. package/dist/web/index_web.js.map +4 -4
  295. package/package.json +38 -26
  296. package/dist/cjs/models/gemini_continuation.js +0 -232
  297. package/dist/esm/models/gemini_continuation.js +0 -205
  298. package/dist/types/models/gemini_continuation.d.ts +0 -59
@@ -0,0 +1,223 @@
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 integration_client_exports = {};
35
+ __export(integration_client_exports, {
36
+ IntegrationClient: () => IntegrationClient
37
+ });
38
+ module.exports = __toCommonJS(integration_client_exports);
39
+ var import_experimental = require("../../../utils/experimental.js");
40
+ var import_json_utils = require("../../../utils/json_utils.js");
41
+ var import_cloud_request = require("./cloud_request.js");
42
+ var import_connections_client = require("./connections_client.js");
43
+ /**
44
+ * @license
45
+ * Copyright 2026 Google LLC
46
+ * SPDX-License-Identifier: Apache-2.0
47
+ */
48
+ const EXECUTE_CONNECTION_INTEGRATION = "ExecuteConnection";
49
+ const EXECUTE_CUSTOM_QUERY_ACTION = "ExecuteCustomQuery";
50
+ let IntegrationClient = class {
51
+ constructor(options) {
52
+ var _a, _b;
53
+ this.project = options.project;
54
+ this.location = options.location;
55
+ this.integration = options.integration;
56
+ this.triggers = options.triggers;
57
+ this.connection = options.connection;
58
+ this.entityOperations = (_a = options.entityOperations) != null ? _a : {};
59
+ this.actions = (_b = options.actions) != null ? _b : [];
60
+ this.serviceAccountJson = options.serviceAccountJson;
61
+ this.tokenSource = new import_cloud_request.CloudPlatformTokenSource(options.serviceAccountJson);
62
+ }
63
+ /**
64
+ * Fetches the OpenAPI spec Application Integration generates for the API
65
+ * trigger of the integration.
66
+ *
67
+ * @throws Error For a rejected request, a missing credential, or a response
68
+ * that carries no parseable spec.
69
+ */
70
+ async getOpenApiSpecForIntegration() {
71
+ var _a;
72
+ const url = `https://${this.location}-integrations.googleapis.com/v1/projects/${this.project}/locations/${this.location}:generateOpenApiSpec`;
73
+ const triggerId = (_a = this.triggers) != null ? _a : null;
74
+ const invalidRequestMessage = `Invalid request. Please check the provided values of project(${this.project}), location(${this.location}), integration(${this.integration}).`;
75
+ const body = await (0, import_cloud_request.sendCloudRequest)({
76
+ url,
77
+ method: "POST",
78
+ body: {
79
+ apiTriggerResources: [
80
+ {
81
+ integrationResource: this.integration,
82
+ triggerId
83
+ }
84
+ ],
85
+ fileFormat: "JSON"
86
+ },
87
+ tokenSource: this.tokenSource,
88
+ invalidRequestMessage
89
+ });
90
+ try {
91
+ const spec = (0, import_json_utils.isJsonObject)(body) ? body["openApiSpec"] : void 0;
92
+ if (typeof spec !== "string") {
93
+ throw new Error("The response carries no openApiSpec string.");
94
+ }
95
+ const parsed = JSON.parse(spec);
96
+ if (!(0, import_json_utils.isJsonObject)(parsed)) {
97
+ throw new Error("The openApiSpec is not a JSON object.");
98
+ }
99
+ return parsed;
100
+ } catch (e) {
101
+ throw (0, import_cloud_request.unexpectedError)(e);
102
+ }
103
+ }
104
+ /**
105
+ * Builds an OpenAPI spec for the entity operations and actions of the
106
+ * connection.
107
+ *
108
+ * Every operation becomes a POST to the `ExecuteConnection` integration,
109
+ * with a path fragment that keeps the paths distinct.
110
+ *
111
+ * @param toolName Prefix of every generated `operationId`.
112
+ * @param toolInstructions Text appended to every operation description.
113
+ * @throws Error When neither entity operations nor actions are configured,
114
+ * or an operation is not one of create, update, delete, list or get.
115
+ */
116
+ async getOpenApiSpecForConnection(toolName = "", toolInstructions = "") {
117
+ var _a;
118
+ if (Object.keys(this.entityOperations).length === 0 && this.actions.length === 0) {
119
+ throw new Error(
120
+ "No entity operations or actions provided. Please provide at least one of them."
121
+ );
122
+ }
123
+ const connectionsClient = new import_connections_client.ConnectionsClient({
124
+ project: this.project,
125
+ location: this.location,
126
+ connection: (_a = this.connection) != null ? _a : "",
127
+ serviceAccountJson: this.serviceAccountJson
128
+ });
129
+ const connectorSpec = structuredClone(import_connections_client.CONNECTOR_BASE_SPEC);
130
+ const schemas = connectorSpec.components.schemas;
131
+ const pathPrefix = `/v2/projects/${this.project}/locations/${this.location}/integrations/${EXECUTE_CONNECTION_INTEGRATION}:execute?triggerId=api_trigger/${EXECUTE_CONNECTION_INTEGRATION}`;
132
+ for (const [entity, requestedOperations] of Object.entries(
133
+ this.entityOperations
134
+ )) {
135
+ const { schema, operations: supportedOperations } = await connectionsClient.getEntitySchemaAndOperations(entity);
136
+ const operations = requestedOperations.length > 0 ? requestedOperations : supportedOperations;
137
+ const schemaAsString = JSON.stringify(schema);
138
+ schemas[`connectorInputPayload_${entity}`] = (0, import_connections_client.connectorPayload)(schema);
139
+ for (const operation of operations) {
140
+ const operationLower = operation.toLowerCase();
141
+ const path = `${pathPrefix}#${operationLower}_${entity}`;
142
+ switch (operationLower) {
143
+ case "create":
144
+ connectorSpec.paths[path] = (0, import_connections_client.createOperation)({
145
+ entity,
146
+ toolName,
147
+ toolInstructions
148
+ });
149
+ schemas[`create_${entity}_Request`] = (0, import_connections_client.createOperationRequest)(entity);
150
+ break;
151
+ case "update":
152
+ connectorSpec.paths[path] = (0, import_connections_client.updateOperation)({
153
+ entity,
154
+ toolName,
155
+ toolInstructions
156
+ });
157
+ schemas[`update_${entity}_Request`] = (0, import_connections_client.updateOperationRequest)(entity);
158
+ break;
159
+ case "delete":
160
+ connectorSpec.paths[path] = (0, import_connections_client.deleteOperation)({
161
+ entity,
162
+ toolName,
163
+ toolInstructions
164
+ });
165
+ schemas[`delete_${entity}_Request`] = (0, import_connections_client.deleteOperationRequest)();
166
+ break;
167
+ case "list":
168
+ connectorSpec.paths[path] = (0, import_connections_client.listOperation)({
169
+ entity,
170
+ schemaAsString,
171
+ toolName,
172
+ toolInstructions
173
+ });
174
+ schemas[`list_${entity}_Request`] = (0, import_connections_client.listOperationRequest)();
175
+ break;
176
+ case "get":
177
+ connectorSpec.paths[path] = (0, import_connections_client.getOperation)({
178
+ entity,
179
+ schemaAsString,
180
+ toolName,
181
+ toolInstructions
182
+ });
183
+ schemas[`get_${entity}_Request`] = (0, import_connections_client.getOperationRequest)();
184
+ break;
185
+ default:
186
+ throw new Error(
187
+ `Invalid operation: ${operation} for entity: ${entity}`
188
+ );
189
+ }
190
+ }
191
+ }
192
+ for (const action of this.actions) {
193
+ const { inputSchema, outputSchema, displayName } = await connectionsClient.getActionSchema(action);
194
+ const actionDisplayName = displayName.replace(/ /g, "");
195
+ let operation = "EXECUTE_ACTION";
196
+ if (action === EXECUTE_CUSTOM_QUERY_ACTION) {
197
+ schemas[`${actionDisplayName}_Request`] = (0, import_connections_client.executeCustomQueryRequest)();
198
+ operation = "EXECUTE_QUERY";
199
+ } else {
200
+ schemas[`${actionDisplayName}_Request`] = (0, import_connections_client.actionRequest)(actionDisplayName);
201
+ schemas[`connectorInputPayload_${actionDisplayName}`] = (0, import_connections_client.connectorPayload)(inputSchema);
202
+ }
203
+ schemas[`connectorOutputPayload_${actionDisplayName}`] = (0, import_connections_client.connectorPayload)(outputSchema);
204
+ schemas[`${actionDisplayName}_Response`] = (0, import_connections_client.actionResponse)(actionDisplayName);
205
+ connectorSpec.paths[`${pathPrefix}#${action}`] = (0, import_connections_client.getActionOperation)({
206
+ action,
207
+ operation,
208
+ actionDisplayName,
209
+ toolName,
210
+ toolInstructions
211
+ });
212
+ }
213
+ return connectorSpec;
214
+ }
215
+ };
216
+ __name(IntegrationClient, "IntegrationClient");
217
+ IntegrationClient = __decorateClass([
218
+ import_experimental.experimental
219
+ ], IntegrationClient);
220
+ // Annotate the CommonJS export names for ESM import in node:
221
+ 0 && (module.exports = {
222
+ IntegrationClient
223
+ });
@@ -0,0 +1,184 @@
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 integration_connector_tool_exports = {};
35
+ __export(integration_connector_tool_exports, {
36
+ IntegrationConnectorTool: () => IntegrationConnectorTool
37
+ });
38
+ module.exports = __toCommonJS(integration_connector_tool_exports);
39
+ var import_experimental = require("../../utils/experimental.js");
40
+ var import_logger = require("../../utils/logger.js");
41
+ var import_base_tool = require("../base_tool.js");
42
+ var import_tool_auth_handler = require("../openapi_tool/openapi_spec_parser/tool_auth_handler.js");
43
+ /**
44
+ * @license
45
+ * Copyright 2026 Google LLC
46
+ * SPDX-License-Identifier: Apache-2.0
47
+ */
48
+ const DYNAMIC_AUTH_EXCLUDE_FIELDS = Object.freeze([
49
+ "dynamic_auth_config",
50
+ "dynamicAuthConfig"
51
+ ]);
52
+ let IntegrationConnectorTool = class extends import_base_tool.BaseTool {
53
+ constructor(options) {
54
+ var _a, _b, _c;
55
+ super(options);
56
+ this.connectionName = options.connectionName;
57
+ this.connectionHost = options.connectionHost;
58
+ this.connectionServiceName = options.connectionServiceName;
59
+ this.entity = (_a = options.entity) != null ? _a : "";
60
+ this.operation = (_b = options.operation) != null ? _b : "";
61
+ this.action = (_c = options.action) != null ? _c : "";
62
+ this.restApiTool = options.restApiTool;
63
+ this.authScheme = options.authScheme;
64
+ this.authCredential = options.authCredential;
65
+ }
66
+ _getDeclaration() {
67
+ const declaration = this.restApiTool._getDeclaration();
68
+ const rawParameters = declaration == null ? void 0 : declaration.parameters;
69
+ let parameters;
70
+ if (rawParameters) {
71
+ parameters = { ...rawParameters };
72
+ if (rawParameters.properties) {
73
+ const properties = { ...rawParameters.properties };
74
+ for (const field of [
75
+ ...IntegrationConnectorTool.EXCLUDE_FIELDS,
76
+ ...DYNAMIC_AUTH_EXCLUDE_FIELDS
77
+ ]) {
78
+ delete properties[field];
79
+ }
80
+ parameters.properties = properties;
81
+ }
82
+ if (rawParameters.required) {
83
+ parameters.required = rawParameters.required.filter(
84
+ (field) => !IntegrationConnectorTool.EXCLUDE_FIELDS.includes(field) && !DYNAMIC_AUTH_EXCLUDE_FIELDS.includes(field) && !IntegrationConnectorTool.OPTIONAL_FIELDS.includes(field)
85
+ );
86
+ }
87
+ }
88
+ return {
89
+ name: this.name,
90
+ description: this.description,
91
+ parameters
92
+ };
93
+ }
94
+ async runAsync(request) {
95
+ const toolAuthHandler = import_tool_auth_handler.ToolAuthHandler.fromToolContext(
96
+ request.toolContext,
97
+ this.authScheme,
98
+ this.authCredential
99
+ );
100
+ const authResult = await toolAuthHandler.prepareAuthCredentials();
101
+ if (authResult.state === "pending") {
102
+ return {
103
+ pending: true,
104
+ message: "Needs your authorization to access your data."
105
+ };
106
+ }
107
+ const updatedArgs = {
108
+ ...request.args,
109
+ connection_name: this.connectionName,
110
+ connectionName: this.connectionName,
111
+ service_name: this.connectionServiceName,
112
+ serviceName: this.connectionServiceName,
113
+ host: this.connectionHost
114
+ };
115
+ if (this.entity) {
116
+ updatedArgs["entity"] = this.entity;
117
+ }
118
+ if (this.operation) {
119
+ updatedArgs["operation"] = this.operation;
120
+ }
121
+ if (this.action) {
122
+ updatedArgs["action"] = this.action;
123
+ }
124
+ if (authResult.authCredential) {
125
+ const token = prepareDynamicEuc(authResult.authCredential);
126
+ const dynamicAuthPayload = {
127
+ "oauth2_auth_code_flow.access_token": token != null ? token : {}
128
+ };
129
+ updatedArgs["dynamic_auth_config"] = dynamicAuthPayload;
130
+ updatedArgs["dynamicAuthConfig"] = dynamicAuthPayload;
131
+ }
132
+ import_logger.logger.debug(`Running tool: ${this.name}`);
133
+ return this.restApiTool.runAsync({
134
+ args: updatedArgs,
135
+ toolContext: request.toolContext
136
+ });
137
+ }
138
+ };
139
+ __name(IntegrationConnectorTool, "IntegrationConnectorTool");
140
+ /**
141
+ * Request fields that {@link IntegrationConnectorTool} injects at runtime and
142
+ * excludes from the function declaration shown to the model.
143
+ */
144
+ IntegrationConnectorTool.EXCLUDE_FIELDS = Object.freeze([
145
+ "connection_name",
146
+ "connectionName",
147
+ "service_name",
148
+ "serviceName",
149
+ "host",
150
+ "entity",
151
+ "operation",
152
+ "action"
153
+ ]);
154
+ /**
155
+ * Request fields that {@link IntegrationConnectorTool} removes from the
156
+ * `required` list in the function declaration shown to the model.
157
+ */
158
+ IntegrationConnectorTool.OPTIONAL_FIELDS = Object.freeze([
159
+ "page_size",
160
+ "pageSize",
161
+ "page_token",
162
+ "pageToken",
163
+ "filter",
164
+ "filter_clause",
165
+ "filterClause"
166
+ ]);
167
+ __decorateClass([
168
+ import_experimental.experimental
169
+ ], IntegrationConnectorTool.prototype, "_getDeclaration", 1);
170
+ __decorateClass([
171
+ import_experimental.experimental
172
+ ], IntegrationConnectorTool.prototype, "runAsync", 1);
173
+ IntegrationConnectorTool = __decorateClass([
174
+ import_experimental.experimental
175
+ ], IntegrationConnectorTool);
176
+ function prepareDynamicEuc(authCredential) {
177
+ var _a, _b;
178
+ return ((_b = (_a = authCredential.http) == null ? void 0 : _a.credentials) == null ? void 0 : _b.token) || void 0;
179
+ }
180
+ __name(prepareDynamicEuc, "prepareDynamicEuc");
181
+ // Annotate the CommonJS export names for ESM import in node:
182
+ 0 && (module.exports = {
183
+ IntegrationConnectorTool
184
+ });
@@ -28,6 +28,7 @@ __export(example_tool_exports, {
28
28
  ExampleTool: () => ExampleTool
29
29
  });
30
30
  module.exports = __toCommonJS(example_tool_exports);
31
+ var import_base_example_provider = require("../examples/base_example_provider.js");
31
32
  var import_example_util = require("../examples/example_util.js");
32
33
  var import_llm_request = require("../models/llm_request.js");
33
34
  var import_base_tool = require("./base_tool.js");
@@ -37,6 +38,12 @@ var import_base_tool = require("./base_tool.js");
37
38
  * SPDX-License-Identifier: Apache-2.0
38
39
  */
39
40
  const _ExampleTool = class _ExampleTool extends import_base_tool.BaseTool {
41
+ /**
42
+ * @param examples - A list of {@link Example}s, or a
43
+ * {@link BaseExampleProvider} that returns them for a query.
44
+ * @throws {InputValidationError} When `examples` is neither a
45
+ * {@link BaseExampleProvider} nor a list of well-formed examples.
46
+ */
40
47
  constructor(examples) {
41
48
  super({
42
49
  // Name and description are not used because this tool only changes
@@ -44,6 +51,9 @@ const _ExampleTool = class _ExampleTool extends import_base_tool.BaseTool {
44
51
  name: "example_tool",
45
52
  description: "example tool"
46
53
  });
54
+ if (!(0, import_base_example_provider.isBaseExampleProvider)(examples)) {
55
+ (0, import_example_util.validateExamples)(examples);
56
+ }
47
57
  this.examples = examples;
48
58
  }
49
59
  async runAsync(_request) {