@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
@@ -90,6 +90,29 @@ export interface CodeExecutionResult {
90
90
  * @return The file content as a base64-encoded bytes.
91
91
  */
92
92
  export declare function getEncodedFileContent(data: string): string;
93
+ /**
94
+ * Gets the language of the code in a block from the block's leading delimiter.
95
+ *
96
+ * @param leadingDelimiter The leading delimiter of a code block, for example
97
+ * '```javascript\n'.
98
+ * @return The language that the fence tag names, or
99
+ * `CodeExecutionLanguage.UNSPECIFIED` for a tag that is not known. The
100
+ * executor decides what to do with an unspecified language.
101
+ */
102
+ export declare function getCodeBlockLanguage(leadingDelimiter: string): CodeExecutionLanguage;
103
+ /**
104
+ * A code block extracted from a model response.
105
+ */
106
+ export interface ExtractedCodeBlock {
107
+ /**
108
+ * The code in the block, or an empty string if there is no block.
109
+ */
110
+ code: string;
111
+ /**
112
+ * The language of the code, from the fence that matched it.
113
+ */
114
+ language: CodeExecutionLanguage;
115
+ }
93
116
  /**
94
117
  * Extracts the first code block from the content and truncate everything after
95
118
  * it.
@@ -100,6 +123,22 @@ export declare function getEncodedFileContent(data: string): string;
100
123
  * @return The first code block if found, otherwise an empty string.
101
124
  */
102
125
  export declare function extractCodeAndTruncateContent(content: Content, codeBlockDelimiters: Array<[string, string]>): string;
126
+ /**
127
+ * Extracts the first code block and its language from the content, and
128
+ * truncates everything after it.
129
+ *
130
+ * An `executableCode` part holds Python. A code block in text has the
131
+ * language of the fence tag in its leading delimiter: see
132
+ * {@link getCodeBlockLanguage}.
133
+ *
134
+ * @param content The mutable content to extract the code from.
135
+ * @param codeBlockDelimiters The list of the enclosing delimiters to identify
136
+ * the code blocks.
137
+ * @return The first code block and its language. With no code block, the
138
+ * code is an empty string and the language is
139
+ * `CodeExecutionLanguage.UNSPECIFIED`.
140
+ */
141
+ export declare function extractCodeBlockAndTruncateContent(content: Content, codeBlockDelimiters: Array<[string, string]>): ExtractedCodeBlock;
103
142
  /**
104
143
  * Builds an executable code part with code string.
105
144
  *
@@ -1,5 +1,6 @@
1
1
  import { State } from '../sessions/state.js';
2
2
  import { File } from './code_execution_utils.js';
3
+ export declare const CONTEXT_KEY = "_code_execution_context";
3
4
  /**
4
5
  * The parameters for updating the code execution result.
5
6
  * */
@@ -56,6 +56,17 @@ export interface ContainerCodeExecutorOptions {
56
56
  * can be re-enabled via `networkEnabled: true` when the executed code is
57
57
  * trusted.
58
58
  *
59
+ * A separate container is started per session (keyed on `appName`, `userId`,
60
+ * and `session.id` from `ExecuteCodeParams.invocationContext`) rather than
61
+ * one container shared across every call: `codeExecutor` is a single
62
+ * property set once on an `LlmAgent` instance, and that instance is the
63
+ * long-lived object serving every session the agent handles, so a single
64
+ * shared container would let one session's files, environment, and
65
+ * background processes persist into a later, unrelated session's execution.
66
+ * A container is still reused across multiple calls *within* the same
67
+ * session, so the per-call container-startup cost is paid once per session,
68
+ * not once per call.
69
+ *
59
70
  * Limitations: this executor runs a code string only. `inputFiles` and `args`
60
71
  * on the request are not copied into the container, and output files are not
61
72
  * collected (`outputFiles` is always empty), so tools that stage resource
@@ -67,8 +78,8 @@ export declare class ContainerCodeExecutor extends BaseCodeExecutor {
67
78
  private readonly dockerPath?;
68
79
  private readonly containerOptions;
69
80
  private readonly timeoutSeconds;
70
- private container?;
71
- private initPromise?;
81
+ private readonly containers;
82
+ private readonly initPromises;
72
83
  constructor(options?: ContainerCodeExecutorOptions);
73
84
  executeCode(params: ExecuteCodeParams): Promise<CodeExecutionResult>;
74
85
  /**
@@ -79,11 +90,12 @@ export declare class ContainerCodeExecutor extends BaseCodeExecutor {
79
90
  */
80
91
  private describeExit;
81
92
  /**
82
- * Stops and removes the container. Safe to call when no container has been
83
- * started; provided for deterministic teardown in tests and app shutdown.
93
+ * Stops and removes every session's container. Safe to call when none has
94
+ * been started; provided for deterministic teardown in tests and app
95
+ * shutdown.
84
96
  */
85
97
  close(): Promise<void>;
86
- /** Lazily builds/starts the container exactly once. */
98
+ /** Lazily builds/starts the given session's container exactly once. */
87
99
  private ensureContainer;
88
100
  private initContainer;
89
101
  }
@@ -8,9 +8,11 @@ export type { ActiveStreamingToolParams } from './agents/active_streaming_tool.j
8
8
  export { BaseAgent, isBaseAgent } from './agents/base_agent.js';
9
9
  export type { AfterAgentCallback, BaseAgentConfig, BeforeAgentCallback, SingleAgentCallback, } from './agents/base_agent.js';
10
10
  export { Context } from './agents/context.js';
11
- export { REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, REQUEST_CREDENTIAL_FUNCTION_CALL_NAME, REQUEST_INPUT_FUNCTION_CALL_NAME, findEventByFunctionCallId, findMatchingFunctionCall, functionsExportedForTestingOnly, isToolNotFound, } from './agents/functions.js';
12
- export { InvocationContext, requireAgent } from './agents/invocation_context.js';
11
+ export { REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, REQUEST_CREDENTIAL_FUNCTION_CALL_NAME, REQUEST_INPUT_FUNCTION_CALL_NAME, findEventByFunctionCallId, findMatchingFunctionCall, functionsExportedForTestingOnly, handleFunctionCallsLive, isToolNotFound, } from './agents/functions.js';
12
+ export { InvocationContext, LlmCallsLimitExceededError, isLlmCallsLimitExceededError, requireAgent, } from './agents/invocation_context.js';
13
13
  export type { InvocationContextParams, WorkflowInstructionScope, } from './agents/invocation_context.js';
14
+ export { LangGraphAgent, getLastHumanMessages, isLangGraphAgent, } from './agents/langgraph_agent.js';
15
+ export type { CompiledGraphLike, LangGraphAIMessage, LangGraphAgentConfig, LangGraphContentPart, LangGraphHumanMessage, LangGraphInvokeInput, LangGraphInvokeOutput, LangGraphMessageContent, LangGraphMessageLike, LangGraphRunnableConfig, LangGraphStateSnapshot, LangGraphSystemMessage, } from './agents/langgraph_agent.js';
14
16
  export { LiveRequestQueue } from './agents/live_request_queue.js';
15
17
  export type { LiveRequest } from './agents/live_request_queue.js';
16
18
  export { LlmAgent as Agent, LlmAgent, isLlmAgent } from './agents/llm_agent.js';
@@ -20,13 +22,14 @@ export type { LoopAgentConfig } from './agents/loop_agent.js';
20
22
  export { ParallelAgent, isParallelAgent } from './agents/parallel_agent.js';
21
23
  export { AgentTransferLlmRequestProcessor } from './agents/processors/agent_transfer_llm_request_processor.js';
22
24
  export { BaseLlmRequestProcessor, BaseLlmResponseProcessor, } from './agents/processors/base_llm_processor.js';
25
+ export { CodeExecutionResponseProcessor } from './agents/processors/code_execution_request_processor.js';
23
26
  export { CONTENT_REQUEST_PROCESSOR, ContentRequestProcessor, } from './agents/processors/content_request_processor.js';
24
27
  export { ContextCompactorRequestProcessor } from './agents/processors/context_compactor_request_processor.js';
25
28
  export { INTERACTIONS_REQUEST_PROCESSOR, InteractionsRequestProcessor, } from './agents/processors/interactions_request_processor.js';
26
29
  export { ReadonlyContext } from './agents/readonly_context.js';
27
30
  export { RoutedAgent, isRoutedAgent } from './agents/routed_agent.js';
28
31
  export type { AgentRouter, RoutedAgentConfig } from './agents/routed_agent.js';
29
- export { StreamingMode } from './agents/run_config.js';
32
+ export { StreamingMode, createRunConfig } from './agents/run_config.js';
30
33
  export type { RunConfig } from './agents/run_config.js';
31
34
  export { SequentialAgent, isSequentialAgent } from './agents/sequential_agent.js';
32
35
  export type { TranscriptionEntry } from './agents/transcription_entry.js';
@@ -44,7 +47,7 @@ export type { AuthCredential, HttpAuth, HttpCredentials, OAuth2Auth, ServiceAcco
44
47
  export { AuthHandler } from './auth/auth_handler.js';
45
48
  export { AUTH_PREPROCESSOR, AuthPreprocessor } from './auth/auth_preprocessor.js';
46
49
  export { AuthProviderRegistry } from './auth/auth_provider_registry.js';
47
- export { OAuthGrantType } from './auth/auth_schemes.js';
50
+ export { AuthSchemeType, OAuthGrantType, getOAuthGrantTypeFromFlow, } from './auth/auth_schemes.js';
48
51
  export type { AuthScheme, OpenIdConnectWithConfig } from './auth/auth_schemes.js';
49
52
  export type { AuthConfig } from './auth/auth_tool.js';
50
53
  export type { BaseAuthProvider } from './auth/base_auth_provider.js';
@@ -104,7 +107,9 @@ export { ChromeBuiltInLlm, ChromeModelUnavailableError, stripAdkIdentityPreamble
104
107
  export type { ChromeBuiltInDiagnostic, ChromeBuiltInLlmParams, ChromeCreateCoreOptions, ChromeCreateMonitor, ChromeCreateOptions, ChromeExpectedModality, ChromeLanguageModelFactory, ChromeLanguageModelSession, ChromeMessage, ChromeMessageContent, ChromeModelAvailability, ChromePromptOptions, } from './models/chrome_prompt_llm.js';
105
108
  export { Gemini, geminiInitParams } from './models/google_llm.js';
106
109
  export type { GeminiParams } from './models/google_llm.js';
110
+ export { appendInstructions } from './models/llm_request.js';
107
111
  export type { LlmRequest } from './models/llm_request.js';
112
+ export { createLlmResponse } from './models/llm_response.js';
108
113
  export type { LlmResponse } from './models/llm_response.js';
109
114
  export { LLMRegistry } from './models/registry.js';
110
115
  export type { BaseLlmType } from './models/registry.js';
@@ -115,6 +120,7 @@ export { BuiltInPlanner, isBuiltInPlanner } from './planners/built_in_planner.js
115
120
  export { PlanReActPlanner } from './planners/plan_re_act_planner.js';
116
121
  export { GLOBAL_SCOPE_KEY, REFLECT_AND_RETRY_RESPONSE_TYPE, ScopedFailureTracker, TrackingScope, resolveScopeKey, type PerItemFailuresCounter, type ToolFailureResponse, } from './plugins/_reflect_retry_utils.js';
117
122
  export { BasePlugin, ContextCompactionTrigger } from './plugins/base_plugin.js';
123
+ export type { DebugEntry, DebugLoggingPluginOptions, InvocationDebugState, } from './plugins/debug_logging_plugin.js';
118
124
  export { GlobalInstructionPlugin } from './plugins/global_instruction_plugin.js';
119
125
  export { LoggingPlugin } from './plugins/logging_plugin.js';
120
126
  export { PluginManager } from './plugins/plugin_manager.js';
@@ -176,11 +182,16 @@ export type { WebMCPDocument, WebMCPExecuteToolOptions, WebMCPGetToolsOptions, W
176
182
  export { AsyncQueue } from './utils/async_queue.js';
177
183
  export { renameReservedKeywords, toSnakeCaseName } from './utils/case_utils.js';
178
184
  export { getClientLabels, runWithClientLabel } from './utils/client_labels.js';
185
+ export { toGeminiSchema } from './utils/gemini_schema_util.js';
186
+ export type { MCPToolSchema } from './utils/gemini_schema_util.js';
187
+ export { genaiSchemaToJsonSchema } from './utils/genai_schema_to_json.js';
179
188
  export { LogLevel, getLogger, logger, resetLogger, setLogLevel, setLogger, } from './utils/logger.js';
180
189
  export type { Logger } from './utils/logger.js';
181
190
  export { isGemini2OrAbove, isGemini35LiveTranslate, isGemini3xFlashLive, isGemini3xLive, } from './utils/model_name.js';
191
+ export { toJsonSchema } from './utils/schema.js';
182
192
  export type { SchemaLike } from './utils/schema.js';
183
- export { zodObjectToSchema } from './utils/simple_zod_to_json.js';
193
+ export { isZodObject, isZodSchema, zodObjectToSchema, } from './utils/simple_zod_to_json.js';
194
+ export type { ZodSchema } from './utils/simple_zod_to_json.js';
184
195
  export { Task } from './utils/task.js';
185
196
  export type { TaskExecutable } from './utils/task.js';
186
197
  export { GoogleLLMVariant } from './utils/variant_utils.js';
@@ -204,3 +215,11 @@ export * from './features/feature_registry.js';
204
215
  export * from './memory/base_memory_service.js';
205
216
  export * from './sessions/base_session_service.js';
206
217
  export * from './tools/base_tool.js';
218
+ export { convertSessionToEvalFormat, createEmptyState, } from './cli/utils/evals.js';
219
+ export type { EvaluationItem, IntermediateAgentResponseItem, ToolUseItem, } from './cli/utils/evals.js';
220
+ export { buildFunctionDeclarationForLangchain, buildFunctionDeclarationForParamsForCrewai, buildFunctionDeclarationUtil, } from './tools/function_tool.js';
221
+ export type { CallLiveToolRequest } from './tools/function_tool.js';
222
+ export type { LoadMemoryResponse, LoadMemoryToolOptions, } from './tools/load_memory_tool.js';
223
+ export { isBaseRetrievalTool } from './tools/retrieval/base_retrieval_tool.js';
224
+ export { ToolboxToolset, isToolboxToolset } from './tools/toolbox_toolset.js';
225
+ export type { ToolboxLoadOptions, ToolboxToolLike, ToolboxToolsetClientLike, ToolboxToolsetOptions, } from './tools/toolbox_toolset.js';
@@ -9,6 +9,7 @@
9
9
  export declare class InputValidationError extends Error {
10
10
  /**
11
11
  * @param message A message describing why the input is invalid.
12
+ * @param options Standard error options, e.g. `{cause}`.
12
13
  */
13
- constructor(message?: string);
14
+ constructor(message?: string, options?: ErrorOptions);
14
15
  }
@@ -178,6 +178,10 @@ export declare function hasTrailingCodeExecutionResult(event: Event): boolean;
178
178
  export declare function stringifyContent(event: Event): string;
179
179
  /**
180
180
  * Estimates the number of tokens in the event based on usage metadata or characters.
181
+ *
182
+ * Prefers `initialPromptTokenCount`, because the promptTokenCount of a
183
+ * generation that @google/genai resumed after continuation pauses is summed
184
+ * over every resumed request, each of which resent the prompt.
181
185
  */
182
186
  export declare function getEventTokens(event: Event): number;
183
187
  /**
@@ -6,6 +6,23 @@
6
6
  import { Session } from '../sessions/session.js';
7
7
  import { BaseExampleProvider } from './base_example_provider.js';
8
8
  import { Example } from './example.js';
9
+ /**
10
+ * Throws unless `examples` is a well-formed list of {@link Example}s.
11
+ *
12
+ * Mirrors `TypeAdapter(list[Example]).validate_python` in the adk-python
13
+ * `ExampleTool` constructor. {@link Example} is erased at compile time, so a
14
+ * value that reaches the SDK from untyped JavaScript or from a configuration
15
+ * file is otherwise unchecked, and a malformed entry only fails later while the
16
+ * few-shot instruction is rendered.
17
+ *
18
+ * The value is checked but not replaced, so it keeps reference identity and no
19
+ * defensive copy is made.
20
+ *
21
+ * @param examples - The value to check.
22
+ * @throws {InputValidationError} When the value is not a list of well-formed
23
+ * examples. The message names the path of each failing field.
24
+ */
25
+ export declare function validateExamples(examples: unknown): asserts examples is Example[];
9
26
  /**
10
27
  * Converts a list of examples to a string that can be used in a system
11
28
  * instruction.
@@ -0,0 +1,85 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Content } from '@google/genai';
7
+ import { InvocationContext } from '../../agents/invocation_context.js';
8
+ /**
9
+ * Audio encoding values matching Google Cloud Speech-to-Text `AudioEncoding`.
10
+ */
11
+ export declare enum AudioEncoding {
12
+ ENCODING_UNSPECIFIED = 0,
13
+ LINEAR16 = 1
14
+ }
15
+ /**
16
+ * Configuration passed to a Speech-to-Text client `recognize` call.
17
+ */
18
+ export interface RecognitionConfig {
19
+ encoding: AudioEncoding | keyof typeof AudioEncoding | number;
20
+ sampleRateHertz: number;
21
+ languageCode: string;
22
+ }
23
+ /**
24
+ * Audio payload passed to a Speech-to-Text client `recognize` call.
25
+ */
26
+ export interface RecognitionAudio {
27
+ content: Uint8Array | string;
28
+ }
29
+ /**
30
+ * A single alternative hypothesis from a Speech-to-Text recognition result.
31
+ */
32
+ export interface SpeechRecognitionAlternative {
33
+ transcript?: string | null;
34
+ confidence?: number | null;
35
+ }
36
+ /**
37
+ * A single Speech-to-Text recognition result segment.
38
+ */
39
+ export interface SpeechRecognitionResult {
40
+ alternatives?: SpeechRecognitionAlternative[] | null;
41
+ }
42
+ /**
43
+ * Response returned by a Speech-to-Text client `recognize` call.
44
+ */
45
+ export interface RecognizeResponse {
46
+ results?: SpeechRecognitionResult[] | null;
47
+ }
48
+ /**
49
+ * Duck-typed interface compatible with `@google-cloud/speech`'s `SpeechClient`
50
+ * as well as lightweight test or browser speech recognition clients.
51
+ */
52
+ export interface SpeechClientLike {
53
+ recognize(request: {
54
+ config: RecognitionConfig;
55
+ audio: RecognitionAudio;
56
+ }): Promise<RecognizeResponse | [RecognizeResponse, ...unknown[]]> | RecognizeResponse | [RecognizeResponse, ...unknown[]];
57
+ }
58
+ /**
59
+ * Options for constructing an {@link AudioTranscriber}.
60
+ */
61
+ export interface AudioTranscriberOptions {
62
+ /**
63
+ * Pre-configured Speech-to-Text client used to transcribe bundled user audio.
64
+ */
65
+ client?: SpeechClientLike;
66
+ }
67
+ /**
68
+ * Transcribes cached audio entries in an {@link InvocationContext} into
69
+ * conversation `Content` objects.
70
+ */
71
+ export declare class AudioTranscriber {
72
+ client: SpeechClientLike;
73
+ constructor(optionsOrClient?: AudioTranscriberOptions | SpeechClientLike);
74
+ /**
75
+ * Bundles consecutive audio blobs from the same speaker in
76
+ * `invocationContext.transcriptionCache`, transcribes user audio bundles into
77
+ * text `Content` entries, preserves already-transcribed `Content`
78
+ * entries in order, clears `invocationContext.transcriptionCache`, and
79
+ * returns the resulting content list.
80
+ *
81
+ * @param invocationContext The invocation context holding `transcriptionCache`.
82
+ * @returns Ordered list of transcribed `Content` objects.
83
+ */
84
+ transcribeFile(invocationContext: InvocationContext): Promise<Content[]>;
85
+ }
@@ -20,20 +20,30 @@ export { VertexAiMemoryBankService } from './memory/vertex_ai_memory_bank_servic
20
20
  export type { VertexAiMemoryBankServiceOptions } from './memory/vertex_ai_memory_bank_service.js';
21
21
  export { VertexAiRagMemoryService } from './memory/vertex_ai_rag_memory_service.js';
22
22
  export type { VertexAiRagMemoryServiceOptions } from './memory/vertex_ai_rag_memory_service.js';
23
- export { DatabaseSessionService } from './sessions/database_session_service.js';
23
+ export { DebugLoggingPlugin, isDebugLoggingPlugin, } from './plugins/debug_logging_plugin.js';
24
+ export { DatabaseSessionService, isStaleSessionError, StaleSessionError, } from './sessions/database_session_service.js';
25
+ export type { DatabaseSessionServiceOptions } from './sessions/database_session_service.js';
24
26
  export { getSessionServiceFromUri } from './sessions/registry.js';
25
27
  export { VertexAiSessionService } from './sessions/vertex_ai_session_service.js';
26
28
  export type { VertexAiCreateSessionRequest, VertexAiSessionServiceOptions, } from './sessions/vertex_ai_session_service.js';
27
29
  export { GCPSkillRegistry } from './skills/gcp_skill_registry.js';
28
30
  export type { GCPSkillRegistryOptions } from './skills/gcp_skill_registry.js';
29
31
  export { loadAllSkillsInDir, loadSkillFromDir, loadSkillFromZipBuffer, validateSkillDir, } from './skills/loader.js';
32
+ export { APIHubToolset, type APIHubToolsetOptions, } from './tools/apihub_tool/apihub_toolset.js';
33
+ export { APIHubClient, type APIHubApi, type APIHubApiVersion, type APIHubClientOptions, type BaseAPIHubClient, } from './tools/apihub_tool/clients/apihub_client.js';
34
+ export { SecretManagerClient, type SecretManagerClientOptions, } from './tools/apihub_tool/clients/secret_client.js';
35
+ export { ApplicationIntegrationToolset, type ApplicationIntegrationToolsetOptions, } from './tools/application_integration_tool/application_integration_toolset.js';
36
+ export { actionRequest, actionResponse, ConnectionsClient, CONNECTOR_BASE_SPEC, connectorPayload, createOperation, createOperationRequest, deleteOperation, deleteOperationRequest, executeCustomQueryRequest, getActionOperation, getOperation, getOperationRequest, listOperation, listOperationRequest, updateOperation, updateOperationRequest, type ActionSchema, type ConnectionDetails, type ConnectionsClientOptions, type ConnectorSpec, type EntityOperationOptions, type EntitySchemaAndOperations, type EntitySchemaOperationOptions, type GetActionOperationOptions, } from './tools/application_integration_tool/clients/connections_client.js';
37
+ export { IntegrationClient, type IntegrationClientOptions, } from './tools/application_integration_tool/clients/integration_client.js';
38
+ export { IntegrationConnectorTool, type IntegrationConnectorToolOptions, } from './tools/application_integration_tool/integration_connector_tool.js';
30
39
  export { LOAD_WEB_PAGE, loadWebPage } from './tools/load_web_page.js';
31
40
  export type { LoadWebPageOptions } from './tools/load_web_page.js';
32
41
  export { credentialToParam, dictToAuthScheme, INTERNAL_AUTH_PREFIX, openidDictToSchemeCredential, openidUrlToSchemeCredential, serviceAccountDictToSchemeCredential, serviceAccountSchemeCredential, tokenToSchemeCredential, } from './tools/openapi_tool/auth/auth_helpers.js';
42
+ export type { OpenIdConfig } from './tools/openapi_tool/auth/auth_helpers.js';
33
43
  export { AutoAuthCredentialExchanger } from './tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js';
34
44
  export type { CustomCredentialExchangers } from './tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js';
35
45
  export { AuthCredentialMissingError, BaseAuthCredentialExchanger, } from './tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js';
36
- export { exchangeCredential, OAuth2BearerExchanger, } from './tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js';
46
+ export { exchangeCredential, generateAuthToken, OAuth2BearerExchanger, } from './tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js';
37
47
  export { ServiceAccountCredentialExchanger } from './tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js';
38
48
  export { createApiParameter, generateParamDoc, generateReturnDoc, getTypeHint, } from './tools/openapi_tool/common/common.js';
39
49
  export type { ApiParameterInit } from './tools/openapi_tool/common/common.js';
@@ -52,7 +62,14 @@ export { LoadSkillResourceTool } from './tools/skill/load_skill_resource_tool.js
52
62
  export { RunSkillInlineScriptErrorCode, RunSkillInlineScriptTool, } from './tools/skill/run_skill_inline_script_tool.js';
53
63
  export { RunSkillScriptTool } from './tools/skill/run_skill_script_tool.js';
54
64
  export { SkillToolset } from './tools/skill/skill_toolset.js';
65
+ export type { JsonObject } from './utils/json_utils.js';
55
66
  export * from './integrations/agent_registry/agent_registry.js';
56
67
  export * from './telemetry/google_cloud.js';
57
68
  export * from './telemetry/setup.js';
69
+ export * from './tools/google_api_tool/index.js';
70
+ export { DEFAULT_CRITERIA, EVAL_SESSION_ID_PREFIX, EvalStatus, getEvaluationCriteriaOrDefault, getRootAgent, MISSING_EVAL_DEPENDENCIES_MESSAGE, parseAndGetEvalsToRun, RESPONSE_EVALUATION_SCORE_KEY, RESPONSE_MATCH_SCORE_KEY, runEvals, TOOL_TRAJECTORY_SCORE_KEY, tryGetResetFunc, } from './cli/cli_eval.js';
71
+ export type { AddSessionToEvalSetRequest, EvalEntry, EvalInitialSession, EvalMetric, EvalMetricResult, EvalResult, EvalSetItem, InvocationEvalMetricResult, RunEvalRequest, RunEvalResult, RunEvalsOptions, } from './cli/cli_eval.js';
72
+ export { loadDotenvForAgent, walkToRootUntilFound } from './cli/utils/envs.js';
73
+ export { LOGGING_FORMAT, logToTmpFolder, setupAdkLogger, } from './cli/utils/logs.js';
74
+ export type { LogToTmpFolderOptions } from './cli/utils/logs.js';
58
75
  export * from './tools/mcp/index.js';
@@ -11,6 +11,7 @@ export declare class GeminiLlmConnection implements BaseLlmConnection {
11
11
  private readonly geminiSession;
12
12
  private readonly modelVersion?;
13
13
  private readonly messageQueue?;
14
+ private messageIterator?;
14
15
  constructor(geminiSession: Session, modelVersion?: string | undefined, messageQueue?: AsyncIterable<LiveServerMessage> | undefined);
15
16
  /**
16
17
  * Sends the conversation history to the gemini model.
@@ -47,15 +48,13 @@ export declare class GeminiLlmConnection implements BaseLlmConnection {
47
48
  */
48
49
  sendActivityEnd(): Promise<void>;
49
50
  /**
50
- * Builds a full text response.
51
+ * Receives the model responses for one model turn.
51
52
  *
52
- * The text should not be partial and the returned LlmResponse is not be
53
- * partial.
53
+ * The generator ends after the message that completes the turn has been
54
+ * processed, or when the server closes the connection. Call `receive()`
55
+ * again to read the next turn; it continues from the next server message.
54
56
  *
55
- * @param text The text to be included in the response.
56
- * @param isThought Whether the text is a thought.
57
- * @param groundingMetadata The grounding metadata to include.
58
- * @returns An LlmResponse containing the full text.
57
+ * @returns A generator of the LlmResponses of one model turn.
59
58
  */
60
59
  receive(): AsyncGenerator<LlmResponse, void, void>;
61
60
  /**
@@ -28,7 +28,7 @@ export declare class RoutedLlm extends BaseLlm {
28
28
  /**
29
29
  * Generates content by delegating to the selected model.
30
30
  */
31
- generateContentAsync(llmRequest: LlmRequest, stream?: boolean): AsyncGenerator<LlmResponse, void>;
31
+ generateContentAsync(llmRequest: LlmRequest, stream?: boolean, abortSignal?: AbortSignal): AsyncGenerator<LlmResponse, void>;
32
32
  /**
33
33
  * Creates a live connection to the LLM by delegating to the selected model.
34
34
  * This live connection cannot be switched mid-stream, it is tied to the model
@@ -375,16 +375,6 @@ export declare abstract class BasePlugin {
375
375
  toolContext: Context;
376
376
  result: Record<string, unknown>;
377
377
  }): Promise<Record<string, unknown> | undefined>;
378
- /**
379
- * Callback executed when a tool call encounters an error.
380
- tool: BaseTool;
381
- toolArgs: Record<string, unknown>;
382
- toolContext: Context;
383
- result: Record<string, unknown>;
384
- }): Promise<Record<string, unknown> | undefined> {
385
- return;
386
- }
387
-
388
378
  /**
389
379
  * Callback executed when a tool call encounters an error.
390
380
  *
@@ -34,7 +34,8 @@ export declare class InMemoryRunner extends Runner {
34
34
  * @param params The configuration for the runner.
35
35
  * @param params.app An optional application instance to run.
36
36
  * @param params.agent The root agent to run.
37
- * @param params.appName The application name. Defaults to `'InMemoryRunner'`.
37
+ * @param params.appName The application name. Defaults to `app.name` when
38
+ * `app` is provided, or `'InMemoryRunner'` otherwise.
38
39
  * @param params.plugins An optional list of plugins.
39
40
  * @param params.resumabilityConfig An optional resumability configuration.
40
41
  */
@@ -65,6 +65,17 @@ export interface RunnerConfig {
65
65
  * An optional resumability configuration applied to the runner.
66
66
  */
67
67
  resumabilityConfig?: ResumabilityConfig;
68
+ /**
69
+ * Whether to create the session when `runAsync` is given a session id that
70
+ * does not exist. Defaults to `false`, which reports the missing session as
71
+ * an error instead.
72
+ *
73
+ * Enabling this trades a loud failure for a silent one: a caller that
74
+ * mistypes a session id gets a new empty conversation rather than an error.
75
+ * Turn it on only where the session id is a key the caller owns and a first
76
+ * use is expected to create it.
77
+ */
78
+ autoCreateSession?: boolean;
68
79
  }
69
80
  /**
70
81
  * A unique symbol to identify ADK agent classes.
@@ -116,12 +127,20 @@ export declare class Runner {
116
127
  readonly memoryService?: BaseMemoryService;
117
128
  readonly credentialService?: BaseCredentialService;
118
129
  readonly resumabilityConfig?: ResumabilityConfig;
130
+ readonly autoCreateSession: boolean;
119
131
  /**
120
132
  * Creates a new Runner instance.
121
133
  *
122
134
  * @param input The configuration for the runner.
123
135
  */
124
136
  constructor(input: RunnerConfig);
137
+ /**
138
+ * Looks the session up, creating it first when `autoCreateSession` is set.
139
+ *
140
+ * A runner with no `appName` cannot address a session, so it falls through to
141
+ * the plain lookup rather than creating one under an undefined app name.
142
+ */
143
+ private resolveSession;
125
144
  /**
126
145
  * Runs the agent with a new, ephemeral session.
127
146
  *
@@ -171,6 +190,21 @@ export declare class Runner {
171
190
  * plugins; there is nothing to lack if there is only one loop.
172
191
  */
173
192
  private runRoot;
193
+ /**
194
+ * Runs the on_event plugin callbacks on an event and appends the result to
195
+ * the session unless it is partial.
196
+ *
197
+ * @returns The event as streamed to the caller.
198
+ */
199
+ private processAndAppendEvent;
200
+ /**
201
+ * Seals an aborted invocation in session history: answers its dangling
202
+ * function calls with error responses, or records a plain abort event when
203
+ * there is nothing to answer.
204
+ *
205
+ * @returns The synthetic events after plugin processing and persistence.
206
+ */
207
+ private synthesizeAbortEvents;
174
208
  /**
175
209
  * Saves artifacts from the message parts and replaces the inline data with
176
210
  * a file name placeholder and optional file reference.
@@ -139,6 +139,11 @@ export declare abstract class BaseSessionService {
139
139
  */
140
140
  private updateSessionState;
141
141
  }
142
+ /**
143
+ * Places `event` into `session.events`, replacing the entry with the same id
144
+ * if one is already there and appending it otherwise.
145
+ */
146
+ export declare function upsertSessionEvent(session: Session, event: Event): void;
142
147
  /**
143
148
  * Removes temporary state delta keys from the event.
144
149
  */
@@ -7,6 +7,21 @@ import type { MikroORMOptions as MikroDBOptions } from './db/operations.js';
7
7
  import { Event } from '../events/event.js';
8
8
  import { AppendEventRequest, BaseSessionService, CreateSessionRequest, DeleteSessionRequest, GetSessionRequest, ListSessionsRequest, ListSessionsResponse } from './base_session_service.js';
9
9
  import { Session } from './session.js';
10
+ export { isStaleSessionError, StaleSessionError } from './stale_session_error.js';
11
+ /**
12
+ * Options for configuring {@link DatabaseSessionService}.
13
+ */
14
+ export interface DatabaseSessionServiceOptions extends MikroDBOptions {
15
+ /**
16
+ * How to handle stale sessions in {@link DatabaseSessionService.appendEvent}.
17
+ *
18
+ * - `'reject'` (default): throws a {@link StaleSessionError} without persisting changes.
19
+ * - `'reload'`: reloads stored events and state into the session object after writing.
20
+ *
21
+ * @deprecated 'reload' is deprecated and will be removed in a future release. Use 'reject' (the default) and re-read the session with `getSession` to retry.
22
+ */
23
+ staleSession?: 'reject' | 'reload';
24
+ }
10
25
  /**
11
26
  * Checks if a URI is a database connection URI.
12
27
  *
@@ -22,7 +37,8 @@ export declare class DatabaseSessionService extends BaseSessionService {
22
37
  private initialized;
23
38
  private options?;
24
39
  private connectionString?;
25
- constructor(connectionStringOrOptions: MikroDBOptions | string);
40
+ private readonly staleSession;
41
+ constructor(connectionStringOrOptions: DatabaseSessionServiceOptions | string, options?: DatabaseSessionServiceOptions);
26
42
  init(): Promise<void>;
27
43
  createSession({ appName, userId, state, sessionId, }: CreateSessionRequest): Promise<Session>;
28
44
  getSession({ appName, userId, sessionId, config, }: GetSessionRequest): Promise<Session | undefined>;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ declare const STALE_SESSION_ERROR_SIGNATURE_SYMBOL: unique symbol;
7
+ /**
8
+ * Error thrown when a session write loses an optimistic concurrency race.
9
+ */
10
+ export declare class StaleSessionError extends Error {
11
+ readonly [STALE_SESSION_ERROR_SIGNATURE_SYMBOL] = true;
12
+ constructor(message: string);
13
+ }
14
+ /**
15
+ * Type guard for {@link StaleSessionError}.
16
+ *
17
+ * @param obj The value to check.
18
+ * @returns True if obj is a {@link StaleSessionError}.
19
+ */
20
+ export declare function isStaleSessionError(obj: unknown): obj is StaleSessionError;
21
+ export {};
@@ -56,6 +56,9 @@ export declare class State {
56
56
  /**
57
57
  * Returns the value of the state dict for the given key.
58
58
  *
59
+ * Only keys the state holds itself are found. Names inherited from
60
+ * `Object.prototype`, such as `toString`, are treated as missing.
61
+ *
59
62
  * @param key The key to get the value for.
60
63
  * @param defaultValue The default value to return if the key is not found.
61
64
  * @return The value of the state for the given key, or the default value if
@@ -70,7 +73,8 @@ export declare class State {
70
73
  */
71
74
  set(key: string, value: unknown): void;
72
75
  /**
73
- * Whether the state has pending delta.
76
+ * Whether the state holds the given key, either as a stored value or as a
77
+ * pending delta. Names inherited from `Object.prototype` are not keys.
74
78
  */
75
79
  has(key: string): boolean;
76
80
  /**
@@ -20,7 +20,15 @@ export declare function isVertexAiConnectionString(uri?: string): boolean;
20
20
  */
21
21
  export declare function quoteFilterLiteral(value: string): string;
22
22
  export interface VertexAiSessionServiceOptions {
23
+ /**
24
+ * Google Cloud project ID. Defaults to `process.env.GOOGLE_CLOUD_PROJECT`
25
+ * unless `expressModeApiKey` is passed.
26
+ */
23
27
  projectId?: string;
28
+ /**
29
+ * Google Cloud location. Defaults to `process.env.GOOGLE_CLOUD_LOCATION`
30
+ * unless `expressModeApiKey` is passed.
31
+ */
24
32
  location?: string;
25
33
  agentEngineId?: string;
26
34
  expressModeApiKey?: string;
@@ -9,7 +9,7 @@ import { Frontmatter, Skill } from './skill.js';
9
9
  *
10
10
  * @param content - The raw content of the SKILL.md file.
11
11
  * @returns An object containing the parsed frontmatter and the remaining markdown body.
12
- * @throws {Error} If the content is not properly formatted with YAML frontmatter.
12
+ * @throws {InputValidationError} If the content is not properly formatted with YAML frontmatter.
13
13
  */
14
14
  export declare function parseSkillMdContent(content: string): {
15
15
  frontmatter: Frontmatter;
@@ -44,7 +44,8 @@ export declare function loadAllSkillsInDir(skillsBasePath: string): Promise<Reco
44
44
  *
45
45
  * @param zipBuffer - The raw Buffer of the zip file containing the skill.
46
46
  * @returns A Skill object with all components loaded.
47
- * @throws {Error} If a member name is a traversal path, if SKILL.md is missing,
47
+ * @throws {NotFoundError} If the archive has no SKILL.md.
48
+ * @throws {InputValidationError} If a member name is a traversal path,
48
49
  * or if the skill name is missing or is not a bare path segment.
49
50
  */
50
51
  export declare function loadSkillFromZipBuffer(zipBuffer: Buffer): Skill;
@@ -15,7 +15,7 @@ export declare const FrontmatterSchema: z.ZodPreprocess<z.ZodObject<{
15
15
  compatibility: z.ZodOptional<z.ZodString>;
16
16
  'allowed-tools': z.ZodOptional<z.ZodString>;
17
17
  metadata: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
18
- }, z.core.$loose>>;
18
+ }, z.core.$loose>, unknown>;
19
19
  export interface Frontmatter {
20
20
  name: string;
21
21
  description: string;