@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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@google/adk",
3
- "version": "2.2.1",
3
+ "version": "2.4.0",
4
4
  "description": "Google ADK JS",
5
5
  "author": "Google",
6
6
  "license": "Apache-2.0",
@@ -37,6 +37,12 @@
37
37
  "require": "./dist/cjs/a2a/index.js",
38
38
  "default": "./dist/esm/a2a/index.js"
39
39
  },
40
+ "./agents/agent-engine": {
41
+ "types": "./dist/types/agents/agent_engine_client.d.ts",
42
+ "import": "./dist/esm/agents/agent_engine_client.js",
43
+ "require": "./dist/cjs/agents/agent_engine_client.js",
44
+ "default": "./dist/esm/agents/agent_engine_client.js"
45
+ },
40
46
  "./artifacts/gcs": {
41
47
  "types": "./dist/types/artifacts/gcs_artifact_service.d.ts",
42
48
  "import": "./dist/esm/artifacts/gcs_artifact_service.js",
@@ -83,40 +89,42 @@
83
89
  },
84
90
  "dependencies": {
85
91
  "@a2a-js/sdk": "^0.3.10",
92
+ "@google-cloud/aiplatform": "^6.10.0",
86
93
  "@google-cloud/vertexai": "^1.12.0",
87
- "@google/genai": "^2.9.0",
88
- "@mikro-orm/core": "^7.2.0",
89
- "@opentelemetry/api": "1.9.0",
90
- "@opentelemetry/api-logs": "^0.222.0",
91
- "@opentelemetry/exporter-logs-otlp-http": "^0.222.0",
92
- "@opentelemetry/exporter-metrics-otlp-http": "^0.222.0",
93
- "@opentelemetry/exporter-trace-otlp-http": "^0.222.0",
94
- "@opentelemetry/resource-detector-gcp": "^0.40.0",
95
- "@opentelemetry/resources": "^2.1.0",
96
- "@opentelemetry/sdk-logs": "^0.222.0",
97
- "@opentelemetry/sdk-metrics": "^2.1.0",
98
- "@opentelemetry/sdk-trace-base": "^2.1.0",
99
- "@opentelemetry/sdk-trace-node": "^2.1.0",
100
- "@types/dockerode": "^4.0.1",
94
+ "@google/genai": "^2.29.1",
95
+ "@mikro-orm/core": "^7.2.5",
96
+ "@opentelemetry/api": "^1.9.1",
97
+ "@opentelemetry/api-logs": "^0.223.0",
98
+ "@opentelemetry/exporter-logs-otlp-http": "^0.223.0",
99
+ "@opentelemetry/exporter-metrics-otlp-http": "^0.223.0",
100
+ "@opentelemetry/exporter-trace-otlp-http": "^0.223.0",
101
+ "@opentelemetry/resource-detector-gcp": "^0.58.0",
102
+ "@opentelemetry/resources": "^2.12.0",
103
+ "@opentelemetry/sdk-logs": "^0.223.0",
104
+ "@opentelemetry/sdk-metrics": "^2.12.0",
105
+ "@opentelemetry/sdk-trace-base": "^2.12.0",
106
+ "@opentelemetry/sdk-trace-node": "^2.12.0",
107
+ "@types/dockerode": "^4.0.2",
101
108
  "adm-zip": "^0.6.1",
102
109
  "google-auth-library": "^10.3.0",
103
- "js-yaml": "^4.1.1",
110
+ "js-yaml": "^5.4.3",
104
111
  "jsonpath-plus": "^10.4.0",
105
112
  "lodash-es": "^4.18.1",
106
113
  "winston": "^3.19.0",
107
- "zod": "^4.2.1",
114
+ "zod": "^4.6.7",
108
115
  "zod-to-json-schema": "^3.25.1"
109
116
  },
110
117
  "optionalDependencies": {
111
118
  "dockerode": "^5.0.1"
112
119
  },
113
120
  "devDependencies": {
114
- "@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.21.0",
121
+ "@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.22.0",
115
122
  "@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
123
+ "@google-cloud/secret-manager": "^7.2.0",
116
124
  "@google-cloud/storage": "^7.17.1",
117
- "@mikro-orm/sqlite": "^7.2.0",
125
+ "@mikro-orm/sqlite": "^7.2.5",
118
126
  "@modelcontextprotocol/sdk": "^1.26.0",
119
- "@opentelemetry/context-async-hooks": "^2.1.0",
127
+ "@opentelemetry/context-async-hooks": "^2.12.0",
120
128
  "@types/adm-zip": "^0.5.8",
121
129
  "@types/express": "^4.17.25",
122
130
  "@types/lodash-es": "^4.17.12",
@@ -124,14 +132,15 @@
124
132
  "openapi-types": "^12.1.3"
125
133
  },
126
134
  "peerDependencies": {
127
- "@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.21.0",
135
+ "@google-cloud/opentelemetry-cloud-monitoring-exporter": "^0.22.0",
128
136
  "@google-cloud/opentelemetry-cloud-trace-exporter": "^3.0.0",
137
+ "@google-cloud/secret-manager": "^7.2.0",
129
138
  "@google-cloud/storage": "^7.17.1",
130
- "@mikro-orm/mariadb": "^7.2.0",
131
- "@mikro-orm/mssql": "^7.2.0",
132
- "@mikro-orm/mysql": "^7.2.0",
133
- "@mikro-orm/postgresql": "^7.2.0",
134
- "@mikro-orm/sqlite": "^7.2.0",
139
+ "@mikro-orm/mariadb": "^7.2.5",
140
+ "@mikro-orm/mssql": "^7.2.5",
141
+ "@mikro-orm/mysql": "^7.2.5",
142
+ "@mikro-orm/postgresql": "^7.2.5",
143
+ "@mikro-orm/sqlite": "^7.2.5",
135
144
  "@modelcontextprotocol/sdk": "^1.26.0",
136
145
  "express": "^4.22.1 || ^5.1.0"
137
146
  },
@@ -142,6 +151,9 @@
142
151
  "@google-cloud/opentelemetry-cloud-trace-exporter": {
143
152
  "optional": true
144
153
  },
154
+ "@google-cloud/secret-manager": {
155
+ "optional": true
156
+ },
145
157
  "@google-cloud/storage": {
146
158
  "optional": true
147
159
  },
@@ -1,232 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- "use strict";
8
- var __defProp = Object.defineProperty;
9
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
10
- var __getOwnPropNames = Object.getOwnPropertyNames;
11
- var __hasOwnProp = Object.prototype.hasOwnProperty;
12
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
13
- var __export = (target, all) => {
14
- for (var name in all)
15
- __defProp(target, name, { get: all[name], enumerable: true });
16
- };
17
- var __copyProps = (to, from, except, desc) => {
18
- if (from && typeof from === "object" || typeof from === "function") {
19
- for (let key of __getOwnPropNames(from))
20
- if (!__hasOwnProp.call(to, key) && key !== except)
21
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
22
- }
23
- return to;
24
- };
25
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
26
- var gemini_continuation_exports = {};
27
- __export(gemini_continuation_exports, {
28
- GeminiContinuation: () => GeminiContinuation,
29
- MAX_RESUMES: () => MAX_RESUMES,
30
- resumeToken: () => resumeToken
31
- });
32
- module.exports = __toCommonJS(gemini_continuation_exports);
33
- var import_genai = require("@google/genai");
34
- var import_content_processor_utils = require("../agents/processors/content_processor_utils.js");
35
- var import_logger = require("../utils/logger.js");
36
- var import_llm_response = require("./llm_response.js");
37
- /**
38
- * @license
39
- * Copyright 2026 Google LLC
40
- * SPDX-License-Identifier: Apache-2.0
41
- */
42
- const MAX_RESUMES = 256;
43
- function resumeToken(response) {
44
- var _a;
45
- const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
46
- if ((candidate == null ? void 0 : candidate.finishReason) !== import_genai.FinishReason.CONTINUATION) {
47
- return void 0;
48
- }
49
- if (!candidate.continuationToken) {
50
- import_logger.logger.warn(
51
- "The model paused the generation for continuation, but the response carries no continuation token, so the partial output is returned."
52
- );
53
- return void 0;
54
- }
55
- return candidate.continuationToken;
56
- }
57
- __name(resumeToken, "resumeToken");
58
- const _GeminiContinuation = class _GeminiContinuation {
59
- constructor(contents, config) {
60
- this.config = config;
61
- this.parts = [];
62
- this.resumes = 0;
63
- this.contents = [...contents];
64
- }
65
- /**
66
- * Adds one request's output to the generation: its parts to the content and
67
- * its usage to the total.
68
- */
69
- addOutput(newParts, newUsage) {
70
- this.usage = addUsage(this.usage, newUsage);
71
- this.appendParts(newParts);
72
- }
73
- /**
74
- * Returns the request that resumes the generation after a request that
75
- * ended with `nextToken`. Returns undefined if the request did not pause,
76
- * returned the previous token again, or the generation was already resumed
77
- * {@link MAX_RESUMES} times.
78
- */
79
- resumeRequest(nextToken) {
80
- if (nextToken === void 0) {
81
- return void 0;
82
- }
83
- if (!this.willResume(nextToken)) {
84
- if (nextToken === this.token) {
85
- import_logger.logger.warn(
86
- "The model returned the same continuation token twice; returning the output generated so far."
87
- );
88
- } else {
89
- import_logger.logger.warn(
90
- `The model paused the generation ${MAX_RESUMES} times; returning the output generated so far.`
91
- );
92
- }
93
- return void 0;
94
- }
95
- this.token = nextToken;
96
- this.resumes++;
97
- import_logger.logger.debug("The model paused the generation; resuming it.");
98
- return this.buildResumeRequest(nextToken);
99
- }
100
- /** Returns `response` with the content and usage of all requests, if resumed. */
101
- complete(response) {
102
- var _a;
103
- if (!this.resumed) {
104
- return (0, import_llm_response.createLlmResponse)(response);
105
- }
106
- const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
107
- return (0, import_llm_response.createLlmResponse)({
108
- ...response,
109
- usageMetadata: this.usage,
110
- candidates: candidate && this.parts.length > 0 ? [{ ...candidate, content: this.content() }] : response.candidates
111
- });
112
- }
113
- /**
114
- * Returns the final streamed `response`, with usage summed across all
115
- * requests if resumed.
116
- */
117
- withSummedUsage(response) {
118
- return this.resumed ? { ...response, usageMetadata: this.usage } : response;
119
- }
120
- /** Returns whether a request that ended with `nextToken` is resumed. */
121
- willResume(nextToken) {
122
- return nextToken !== this.token && this.resumes < MAX_RESUMES;
123
- }
124
- /** Whether the generation took more than one request. */
125
- get resumed() {
126
- return this.token !== void 0;
127
- }
128
- content() {
129
- return { role: "model", parts: [...this.parts] };
130
- }
131
- buildResumeRequest(nextToken) {
132
- const contents = [...this.contents];
133
- if (this.parts.length > 0) {
134
- const content = structuredClone(this.content());
135
- (0, import_content_processor_utils.removeClientFunctionCallId)(content);
136
- contents.push(content);
137
- }
138
- return {
139
- contents,
140
- config: { ...this.config, continuationToken: nextToken }
141
- };
142
- }
143
- /** Appends `newParts`, joining text as the streaming aggregator does. */
144
- appendParts(newParts) {
145
- for (const part of newParts) {
146
- const last = this.parts.length - 1;
147
- const previous = last >= 0 ? this.parts[last] : void 0;
148
- if (previous && canJoin(previous, part)) {
149
- const joined = { text: previous.text + part.text };
150
- if (previous.thought !== void 0) {
151
- joined.thought = previous.thought;
152
- }
153
- const signature = previous.thoughtSignature || part.thoughtSignature;
154
- if (signature !== void 0) {
155
- joined.thoughtSignature = signature;
156
- }
157
- this.parts[last] = joined;
158
- } else {
159
- this.parts.push(part);
160
- }
161
- }
162
- }
163
- };
164
- __name(_GeminiContinuation, "GeminiContinuation");
165
- let GeminiContinuation = _GeminiContinuation;
166
- function canJoin(first, second) {
167
- var _a, _b;
168
- return isText(first) && isText(second) && ((_a = first.thought) != null ? _a : false) === ((_b = second.thought) != null ? _b : false);
169
- }
170
- __name(canJoin, "canJoin");
171
- function isText(part) {
172
- if (!part.text) {
173
- return false;
174
- }
175
- return Object.entries(part).every(
176
- ([key, value]) => value === void 0 || key === "text" || key === "thought" || key === "thoughtSignature"
177
- );
178
- }
179
- __name(isText, "isText");
180
- const COUNT_FIELDS = [
181
- "promptTokenCount",
182
- "candidatesTokenCount",
183
- "totalTokenCount",
184
- "cachedContentTokenCount",
185
- "thoughtsTokenCount",
186
- "toolUsePromptTokenCount"
187
- ];
188
- const MODALITY_FIELDS = [
189
- "promptTokensDetails",
190
- "candidatesTokensDetails",
191
- "cacheTokensDetails",
192
- "toolUsePromptTokensDetails"
193
- ];
194
- function addUsage(total, next) {
195
- var _a, _b;
196
- if (!total || !next) {
197
- return total != null ? total : next;
198
- }
199
- const combined = { ...next };
200
- for (const field of COUNT_FIELDS) {
201
- if (total[field] !== void 0 || next[field] !== void 0) {
202
- combined[field] = ((_a = total[field]) != null ? _a : 0) + ((_b = next[field]) != null ? _b : 0);
203
- }
204
- }
205
- for (const field of MODALITY_FIELDS) {
206
- if (total[field] !== void 0 || next[field] !== void 0) {
207
- combined[field] = addModalityCounts(total[field], next[field]);
208
- }
209
- }
210
- return combined;
211
- }
212
- __name(addUsage, "addUsage");
213
- function addModalityCounts(first, second) {
214
- var _a, _b;
215
- const totals = /* @__PURE__ */ new Map();
216
- for (const count of [...first != null ? first : [], ...second != null ? second : []]) {
217
- totals.set(
218
- count.modality,
219
- ((_a = totals.get(count.modality)) != null ? _a : 0) + ((_b = count.tokenCount) != null ? _b : 0)
220
- );
221
- }
222
- return [...totals].map(
223
- ([modality, tokenCount]) => modality === void 0 ? { tokenCount } : { modality, tokenCount }
224
- );
225
- }
226
- __name(addModalityCounts, "addModalityCounts");
227
- // Annotate the CommonJS export names for ESM import in node:
228
- 0 && (module.exports = {
229
- GeminiContinuation,
230
- MAX_RESUMES,
231
- resumeToken
232
- });
@@ -1,205 +0,0 @@
1
- import {createRequire as topLevelCreateRequire} from 'module';
2
- const require = topLevelCreateRequire(import.meta.url);
3
- var __defProp = Object.defineProperty;
4
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
- /**
6
- * @license
7
- * Copyright 2026 Google LLC
8
- * SPDX-License-Identifier: Apache-2.0
9
- */
10
- import {
11
- FinishReason
12
- } from "@google/genai";
13
- import { removeClientFunctionCallId } from "../agents/processors/content_processor_utils.js";
14
- import { logger } from "../utils/logger.js";
15
- import { createLlmResponse } from "./llm_response.js";
16
- const MAX_RESUMES = 256;
17
- function resumeToken(response) {
18
- var _a;
19
- const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
20
- if ((candidate == null ? void 0 : candidate.finishReason) !== FinishReason.CONTINUATION) {
21
- return void 0;
22
- }
23
- if (!candidate.continuationToken) {
24
- logger.warn(
25
- "The model paused the generation for continuation, but the response carries no continuation token, so the partial output is returned."
26
- );
27
- return void 0;
28
- }
29
- return candidate.continuationToken;
30
- }
31
- __name(resumeToken, "resumeToken");
32
- const _GeminiContinuation = class _GeminiContinuation {
33
- constructor(contents, config) {
34
- this.config = config;
35
- this.parts = [];
36
- this.resumes = 0;
37
- this.contents = [...contents];
38
- }
39
- /**
40
- * Adds one request's output to the generation: its parts to the content and
41
- * its usage to the total.
42
- */
43
- addOutput(newParts, newUsage) {
44
- this.usage = addUsage(this.usage, newUsage);
45
- this.appendParts(newParts);
46
- }
47
- /**
48
- * Returns the request that resumes the generation after a request that
49
- * ended with `nextToken`. Returns undefined if the request did not pause,
50
- * returned the previous token again, or the generation was already resumed
51
- * {@link MAX_RESUMES} times.
52
- */
53
- resumeRequest(nextToken) {
54
- if (nextToken === void 0) {
55
- return void 0;
56
- }
57
- if (!this.willResume(nextToken)) {
58
- if (nextToken === this.token) {
59
- logger.warn(
60
- "The model returned the same continuation token twice; returning the output generated so far."
61
- );
62
- } else {
63
- logger.warn(
64
- `The model paused the generation ${MAX_RESUMES} times; returning the output generated so far.`
65
- );
66
- }
67
- return void 0;
68
- }
69
- this.token = nextToken;
70
- this.resumes++;
71
- logger.debug("The model paused the generation; resuming it.");
72
- return this.buildResumeRequest(nextToken);
73
- }
74
- /** Returns `response` with the content and usage of all requests, if resumed. */
75
- complete(response) {
76
- var _a;
77
- if (!this.resumed) {
78
- return createLlmResponse(response);
79
- }
80
- const candidate = (_a = response.candidates) == null ? void 0 : _a[0];
81
- return createLlmResponse({
82
- ...response,
83
- usageMetadata: this.usage,
84
- candidates: candidate && this.parts.length > 0 ? [{ ...candidate, content: this.content() }] : response.candidates
85
- });
86
- }
87
- /**
88
- * Returns the final streamed `response`, with usage summed across all
89
- * requests if resumed.
90
- */
91
- withSummedUsage(response) {
92
- return this.resumed ? { ...response, usageMetadata: this.usage } : response;
93
- }
94
- /** Returns whether a request that ended with `nextToken` is resumed. */
95
- willResume(nextToken) {
96
- return nextToken !== this.token && this.resumes < MAX_RESUMES;
97
- }
98
- /** Whether the generation took more than one request. */
99
- get resumed() {
100
- return this.token !== void 0;
101
- }
102
- content() {
103
- return { role: "model", parts: [...this.parts] };
104
- }
105
- buildResumeRequest(nextToken) {
106
- const contents = [...this.contents];
107
- if (this.parts.length > 0) {
108
- const content = structuredClone(this.content());
109
- removeClientFunctionCallId(content);
110
- contents.push(content);
111
- }
112
- return {
113
- contents,
114
- config: { ...this.config, continuationToken: nextToken }
115
- };
116
- }
117
- /** Appends `newParts`, joining text as the streaming aggregator does. */
118
- appendParts(newParts) {
119
- for (const part of newParts) {
120
- const last = this.parts.length - 1;
121
- const previous = last >= 0 ? this.parts[last] : void 0;
122
- if (previous && canJoin(previous, part)) {
123
- const joined = { text: previous.text + part.text };
124
- if (previous.thought !== void 0) {
125
- joined.thought = previous.thought;
126
- }
127
- const signature = previous.thoughtSignature || part.thoughtSignature;
128
- if (signature !== void 0) {
129
- joined.thoughtSignature = signature;
130
- }
131
- this.parts[last] = joined;
132
- } else {
133
- this.parts.push(part);
134
- }
135
- }
136
- }
137
- };
138
- __name(_GeminiContinuation, "GeminiContinuation");
139
- let GeminiContinuation = _GeminiContinuation;
140
- function canJoin(first, second) {
141
- var _a, _b;
142
- return isText(first) && isText(second) && ((_a = first.thought) != null ? _a : false) === ((_b = second.thought) != null ? _b : false);
143
- }
144
- __name(canJoin, "canJoin");
145
- function isText(part) {
146
- if (!part.text) {
147
- return false;
148
- }
149
- return Object.entries(part).every(
150
- ([key, value]) => value === void 0 || key === "text" || key === "thought" || key === "thoughtSignature"
151
- );
152
- }
153
- __name(isText, "isText");
154
- const COUNT_FIELDS = [
155
- "promptTokenCount",
156
- "candidatesTokenCount",
157
- "totalTokenCount",
158
- "cachedContentTokenCount",
159
- "thoughtsTokenCount",
160
- "toolUsePromptTokenCount"
161
- ];
162
- const MODALITY_FIELDS = [
163
- "promptTokensDetails",
164
- "candidatesTokensDetails",
165
- "cacheTokensDetails",
166
- "toolUsePromptTokensDetails"
167
- ];
168
- function addUsage(total, next) {
169
- var _a, _b;
170
- if (!total || !next) {
171
- return total != null ? total : next;
172
- }
173
- const combined = { ...next };
174
- for (const field of COUNT_FIELDS) {
175
- if (total[field] !== void 0 || next[field] !== void 0) {
176
- combined[field] = ((_a = total[field]) != null ? _a : 0) + ((_b = next[field]) != null ? _b : 0);
177
- }
178
- }
179
- for (const field of MODALITY_FIELDS) {
180
- if (total[field] !== void 0 || next[field] !== void 0) {
181
- combined[field] = addModalityCounts(total[field], next[field]);
182
- }
183
- }
184
- return combined;
185
- }
186
- __name(addUsage, "addUsage");
187
- function addModalityCounts(first, second) {
188
- var _a, _b;
189
- const totals = /* @__PURE__ */ new Map();
190
- for (const count of [...first != null ? first : [], ...second != null ? second : []]) {
191
- totals.set(
192
- count.modality,
193
- ((_a = totals.get(count.modality)) != null ? _a : 0) + ((_b = count.tokenCount) != null ? _b : 0)
194
- );
195
- }
196
- return [...totals].map(
197
- ([modality, tokenCount]) => modality === void 0 ? { tokenCount } : { modality, tokenCount }
198
- );
199
- }
200
- __name(addModalityCounts, "addModalityCounts");
201
- export {
202
- GeminiContinuation,
203
- MAX_RESUMES,
204
- resumeToken
205
- };
@@ -1,59 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2026 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
- import { Content, GenerateContentConfig, GenerateContentResponse, GenerateContentResponseUsageMetadata, Part } from '@google/genai';
7
- import { LlmResponse } from './llm_response.js';
8
- /** The most times one generation is resumed after the model pauses it. */
9
- export declare const MAX_RESUMES = 256;
10
- /** The contents and config of a request that resumes a paused generation. */
11
- export interface ResumeRequest {
12
- contents: Content[];
13
- config: GenerateContentConfig;
14
- }
15
- /**
16
- * Returns the token that resumes `response`, or undefined if it did not pause
17
- * or has no token.
18
- */
19
- export declare function resumeToken(response: GenerateContentResponse): string | undefined;
20
- /**
21
- * One generation, carried across the requests that resume it after the model
22
- * pauses it.
23
- */
24
- export declare class GeminiContinuation {
25
- private readonly config?;
26
- private readonly contents;
27
- private readonly parts;
28
- private usage?;
29
- private token?;
30
- private resumes;
31
- constructor(contents: Content[], config?: GenerateContentConfig | undefined);
32
- /**
33
- * Adds one request's output to the generation: its parts to the content and
34
- * its usage to the total.
35
- */
36
- addOutput(newParts: Part[], newUsage: GenerateContentResponseUsageMetadata | undefined): void;
37
- /**
38
- * Returns the request that resumes the generation after a request that
39
- * ended with `nextToken`. Returns undefined if the request did not pause,
40
- * returned the previous token again, or the generation was already resumed
41
- * {@link MAX_RESUMES} times.
42
- */
43
- resumeRequest(nextToken: string | undefined): ResumeRequest | undefined;
44
- /** Returns `response` with the content and usage of all requests, if resumed. */
45
- complete(response: GenerateContentResponse): LlmResponse;
46
- /**
47
- * Returns the final streamed `response`, with usage summed across all
48
- * requests if resumed.
49
- */
50
- withSummedUsage(response: LlmResponse): LlmResponse;
51
- /** Returns whether a request that ended with `nextToken` is resumed. */
52
- willResume(nextToken: string): boolean;
53
- /** Whether the generation took more than one request. */
54
- private get resumed();
55
- private content;
56
- private buildResumeRequest;
57
- /** Appends `newParts`, joining text as the streaming aggregator does. */
58
- private appendParts;
59
- }