@google/adk 1.2.0 → 1.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 (294) hide show
  1. package/dist/cjs/agents/active_streaming_tool.js +6 -1
  2. package/dist/cjs/agents/base_agent.js +19 -1
  3. package/dist/cjs/agents/context.js +1 -11
  4. package/dist/cjs/agents/functions.js +35 -16
  5. package/dist/cjs/agents/instructions.js +99 -33
  6. package/dist/cjs/agents/invocation_context.js +2 -6
  7. package/dist/cjs/agents/llm_agent.js +60 -11
  8. package/dist/cjs/agents/processors/agent_transfer_llm_request_processor.js +7 -0
  9. package/dist/cjs/agents/processors/basic_llm_request_processor.js +8 -1
  10. package/dist/cjs/agents/processors/code_execution_request_processor.js +0 -3
  11. package/dist/cjs/agents/processors/content_processor_utils.js +51 -25
  12. package/dist/cjs/agents/processors/content_request_processor.js +7 -0
  13. package/dist/cjs/agents/processors/context_compactor_request_processor.js +16 -2
  14. package/dist/cjs/agents/processors/identity_llm_request_processor.js +7 -0
  15. package/dist/cjs/agents/processors/instructions_llm_request_processor.js +5 -0
  16. package/dist/cjs/agents/processors/interactions_request_processor.js +63 -0
  17. package/dist/cjs/agents/processors/request_confirmation_llm_request_processor.js +9 -1
  18. package/dist/cjs/agents/processors/tool_filter_request_processor.js +7 -1
  19. package/dist/cjs/apps/app.js +79 -0
  20. package/dist/cjs/apps/resumability_config.js +44 -0
  21. package/dist/cjs/artifacts/file_artifact_service.js +14 -1
  22. package/dist/cjs/artifacts/gcs_artifact_service.js +57 -15
  23. package/dist/cjs/artifacts/in_memory_artifact_service.js +5 -1
  24. package/dist/cjs/artifacts/scoped_artifact_service.js +101 -0
  25. package/dist/cjs/artifacts/session_artifact_service.js +27 -0
  26. package/dist/cjs/auth/auth_preprocessor.js +12 -10
  27. package/dist/cjs/auth/oauth2/oauth2_discovery.js +17 -5
  28. package/dist/cjs/auth/oauth2/oauth2_utils.js +12 -1
  29. package/dist/cjs/code_executors/code_executor_context.js +7 -7
  30. package/dist/cjs/common.js +86 -0
  31. package/dist/cjs/context/agent_controlled_context_compactor.js +109 -0
  32. package/dist/cjs/context/summarizers/llm_summarizer.js +11 -0
  33. package/dist/cjs/context/token_based_context_compactor.js +43 -11
  34. package/dist/cjs/context/trajectory_thought_pruning_compactor.js +71 -0
  35. package/dist/cjs/events/event.js +25 -1
  36. package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
  37. package/dist/cjs/models/gemini_llm_connection.js +62 -19
  38. package/dist/cjs/models/google_llm.js +51 -18
  39. package/dist/cjs/models/interactions_utils.js +732 -0
  40. package/dist/cjs/plugins/base_plugin.js +1 -0
  41. package/dist/cjs/plugins/security_plugin.js +16 -0
  42. package/dist/cjs/runner/in_memory_runner.js +13 -2
  43. package/dist/cjs/runner/runner.js +93 -72
  44. package/dist/cjs/sessions/base_session_service.js +19 -3
  45. package/dist/cjs/sessions/database_session_service.js +26 -9
  46. package/dist/cjs/sessions/db/schema.js +45 -10
  47. package/dist/cjs/sessions/in_memory_session_service.js +2 -1
  48. package/dist/cjs/sessions/vertex_ai_session_service.js +21 -5
  49. package/dist/cjs/skills/gcp_skill_registry.js +104 -0
  50. package/dist/cjs/skills/loader.js +67 -2
  51. package/dist/cjs/skills/skill_registry.js +27 -0
  52. package/dist/cjs/tools/base_toolset.js +1 -1
  53. package/dist/cjs/tools/consolidate_context_tool.js +79 -0
  54. package/dist/cjs/tools/forwarding_artifact_service.js +16 -28
  55. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +232 -0
  56. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +224 -0
  57. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +117 -0
  58. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +133 -0
  59. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +256 -0
  60. package/dist/cjs/tools/skill/load_skill_resource_tool.js +25 -3
  61. package/dist/cjs/tools/skill/load_skill_tool.js +12 -1
  62. package/dist/cjs/tools/skill/run_skill_script_tool.js +12 -1
  63. package/dist/cjs/tools/skill/search_skills_tool.js +108 -0
  64. package/dist/cjs/tools/skill/skill_toolset.js +40 -5
  65. package/dist/cjs/utils/async_hooks_shim.js +52 -0
  66. package/dist/cjs/utils/async_queue.js +88 -0
  67. package/dist/cjs/utils/case_utils.js +53 -0
  68. package/dist/cjs/utils/client_labels.js +41 -3
  69. package/dist/cjs/utils/env_aware_utils.js +14 -1
  70. package/dist/cjs/utils/live_connection_utils.js +284 -0
  71. package/dist/cjs/utils/model_name.js +9 -0
  72. package/dist/cjs/utils/streaming_utils.js +18 -11
  73. package/dist/cjs/utils/task.js +62 -0
  74. package/dist/cjs/version.js +1 -1
  75. package/dist/esm/agents/active_streaming_tool.js +6 -1
  76. package/dist/esm/agents/base_agent.js +19 -1
  77. package/dist/esm/agents/context.js +1 -11
  78. package/dist/esm/agents/functions.js +36 -15
  79. package/dist/esm/agents/instructions.js +99 -33
  80. package/dist/esm/agents/invocation_context.js +2 -6
  81. package/dist/esm/agents/llm_agent.js +61 -11
  82. package/dist/esm/agents/processors/agent_transfer_llm_request_processor.js +7 -0
  83. package/dist/esm/agents/processors/basic_llm_request_processor.js +8 -1
  84. package/dist/esm/agents/processors/code_execution_request_processor.js +0 -3
  85. package/dist/esm/agents/processors/content_processor_utils.js +48 -24
  86. package/dist/esm/agents/processors/content_request_processor.js +7 -0
  87. package/dist/esm/agents/processors/context_compactor_request_processor.js +16 -2
  88. package/dist/esm/agents/processors/identity_llm_request_processor.js +7 -0
  89. package/dist/esm/agents/processors/instructions_llm_request_processor.js +5 -0
  90. package/dist/esm/agents/processors/interactions_request_processor.js +34 -0
  91. package/dist/esm/agents/processors/request_confirmation_llm_request_processor.js +9 -1
  92. package/dist/esm/agents/processors/tool_filter_request_processor.js +7 -1
  93. package/dist/esm/apps/app.js +49 -0
  94. package/dist/esm/apps/resumability_config.js +16 -0
  95. package/dist/esm/artifacts/file_artifact_service.js +14 -1
  96. package/dist/esm/artifacts/gcs_artifact_service.js +57 -15
  97. package/dist/esm/artifacts/in_memory_artifact_service.js +5 -1
  98. package/dist/esm/artifacts/scoped_artifact_service.js +73 -0
  99. package/dist/esm/artifacts/session_artifact_service.js +7 -0
  100. package/dist/esm/auth/auth_preprocessor.js +12 -10
  101. package/dist/esm/auth/oauth2/oauth2_discovery.js +14 -4
  102. package/dist/esm/auth/oauth2/oauth2_utils.js +12 -1
  103. package/dist/esm/code_executors/code_executor_context.js +7 -7
  104. package/dist/esm/common.js +75 -3
  105. package/dist/esm/context/agent_controlled_context_compactor.js +81 -0
  106. package/dist/esm/context/summarizers/llm_summarizer.js +11 -0
  107. package/dist/esm/context/token_based_context_compactor.js +43 -11
  108. package/dist/esm/context/trajectory_thought_pruning_compactor.js +43 -0
  109. package/dist/esm/events/event.js +23 -1
  110. package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
  111. package/dist/esm/models/gemini_llm_connection.js +62 -19
  112. package/dist/esm/models/google_llm.js +49 -17
  113. package/dist/esm/models/interactions_utils.js +697 -0
  114. package/dist/esm/plugins/base_plugin.js +1 -0
  115. package/dist/esm/plugins/security_plugin.js +16 -0
  116. package/dist/esm/runner/in_memory_runner.js +13 -2
  117. package/dist/esm/runner/runner.js +91 -73
  118. package/dist/esm/sessions/base_session_service.js +17 -2
  119. package/dist/esm/sessions/database_session_service.js +26 -9
  120. package/dist/esm/sessions/db/schema.js +44 -10
  121. package/dist/esm/sessions/in_memory_session_service.js +4 -2
  122. package/dist/esm/sessions/vertex_ai_session_service.js +21 -5
  123. package/dist/esm/skills/gcp_skill_registry.js +78 -0
  124. package/dist/esm/skills/loader.js +66 -2
  125. package/dist/esm/skills/skill_registry.js +7 -0
  126. package/dist/esm/tools/base_toolset.js +1 -1
  127. package/dist/esm/tools/consolidate_context_tool.js +51 -0
  128. package/dist/esm/tools/forwarding_artifact_service.js +16 -28
  129. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +206 -0
  130. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
  131. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +91 -0
  132. package/dist/esm/tools/openapi_tool/openapi_toolset.js +97 -0
  133. package/dist/esm/tools/openapi_tool/rest_api_tool.js +229 -0
  134. package/dist/esm/tools/skill/load_skill_resource_tool.js +25 -3
  135. package/dist/esm/tools/skill/load_skill_tool.js +12 -1
  136. package/dist/esm/tools/skill/run_skill_script_tool.js +12 -1
  137. package/dist/esm/tools/skill/search_skills_tool.js +82 -0
  138. package/dist/esm/tools/skill/skill_toolset.js +40 -5
  139. package/dist/esm/utils/async_hooks_shim.js +24 -0
  140. package/dist/esm/utils/async_queue.js +60 -0
  141. package/dist/esm/utils/case_utils.js +25 -0
  142. package/dist/esm/utils/client_labels.js +38 -2
  143. package/dist/esm/utils/env_aware_utils.js +14 -1
  144. package/dist/esm/utils/live_connection_utils.js +256 -0
  145. package/dist/esm/utils/model_name.js +8 -0
  146. package/dist/esm/utils/streaming_utils.js +18 -11
  147. package/dist/esm/utils/task.js +34 -0
  148. package/dist/esm/version.js +1 -1
  149. package/dist/types/a2a/a2a_remote_agent_utils.d.ts +29 -4
  150. package/dist/types/a2a/event_converter_utils.d.ts +14 -1
  151. package/dist/types/a2a/metadata_converter_utils.d.ts +18 -0
  152. package/dist/types/a2a/part_converter_utils.d.ts +51 -6
  153. package/dist/types/agents/active_streaming_tool.d.ts +3 -4
  154. package/dist/types/agents/functions.d.ts +12 -9
  155. package/dist/types/agents/invocation_context.d.ts +7 -12
  156. package/dist/types/agents/llm_agent.d.ts +14 -0
  157. package/dist/types/agents/processors/agent_transfer_llm_request_processor.d.ts +14 -0
  158. package/dist/types/agents/processors/basic_llm_request_processor.d.ts +7 -0
  159. package/dist/types/agents/processors/content_processor_utils.d.ts +34 -0
  160. package/dist/types/agents/processors/content_request_processor.d.ts +16 -0
  161. package/dist/types/agents/processors/context_compactor_request_processor.d.ts +12 -0
  162. package/dist/types/agents/processors/identity_llm_request_processor.d.ts +7 -0
  163. package/dist/types/agents/processors/interactions_request_processor.d.ts +17 -0
  164. package/dist/types/agents/processors/request_confirmation_llm_request_processor.d.ts +9 -1
  165. package/dist/types/agents/processors/tool_filter_request_processor.d.ts +12 -1
  166. package/dist/types/apps/app.d.ts +52 -0
  167. package/dist/types/apps/resumability_config.d.ts +27 -0
  168. package/dist/types/artifacts/base_artifact_service.d.ts +6 -36
  169. package/dist/types/artifacts/gcs_artifact_service.d.ts +2 -1
  170. package/dist/types/artifacts/scoped_artifact_service.d.ts +25 -0
  171. package/dist/types/artifacts/session_artifact_service.d.ts +25 -0
  172. package/dist/types/auth/oauth2/oauth2_discovery.d.ts +11 -0
  173. package/dist/types/common.d.ts +35 -4
  174. package/dist/types/context/agent_controlled_context_compactor.d.ts +24 -0
  175. package/dist/types/context/base_context_compactor.d.ts +3 -0
  176. package/dist/types/context/summarizers/llm_summarizer.d.ts +17 -0
  177. package/dist/types/context/token_based_context_compactor.d.ts +6 -1
  178. package/dist/types/context/trajectory_thought_pruning_compactor.d.ts +27 -0
  179. package/dist/types/events/event.d.ts +8 -0
  180. package/dist/types/events/event_actions.d.ts +1 -2
  181. package/dist/types/integrations/agent_registry/agent_registry_mcp_toolset.d.ts +21 -2
  182. package/dist/types/models/base_llm_connection.d.ts +10 -0
  183. package/dist/types/models/gemini_llm_connection.d.ts +15 -4
  184. package/dist/types/models/google_llm.d.ts +15 -1
  185. package/dist/types/models/interactions_utils.d.ts +92 -0
  186. package/dist/types/models/llm_request.d.ts +4 -0
  187. package/dist/types/models/llm_response.d.ts +14 -1
  188. package/dist/types/plugins/base_plugin.d.ts +2 -1
  189. package/dist/types/plugins/security_plugin.d.ts +30 -0
  190. package/dist/types/runner/in_memory_runner.d.ts +7 -1
  191. package/dist/types/runner/runner.d.ts +43 -9
  192. package/dist/types/sessions/base_session_service.d.ts +7 -16
  193. package/dist/types/sessions/db/schema.d.ts +1 -0
  194. package/dist/types/sessions/session.d.ts +11 -0
  195. package/dist/types/sessions/vertex_ai_session_service.d.ts +9 -1
  196. package/dist/types/skills/gcp_skill_registry.d.ts +24 -0
  197. package/dist/types/skills/loader.d.ts +7 -0
  198. package/dist/types/skills/skill.d.ts +1 -1
  199. package/dist/types/skills/skill_registry.d.ts +29 -0
  200. package/dist/types/tools/consolidate_context_tool.d.ts +19 -0
  201. package/dist/types/tools/forwarding_artifact_service.d.ts +3 -2
  202. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +34 -0
  203. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +59 -0
  204. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +23 -0
  205. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +27 -0
  206. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +50 -0
  207. package/dist/types/tools/skill/load_skill_resource_tool.d.ts +1 -1
  208. package/dist/types/tools/skill/search_skills_tool.d.ts +14 -0
  209. package/dist/types/tools/skill/skill_toolset.d.ts +5 -0
  210. package/dist/types/utils/async_hooks_shim.d.ts +10 -0
  211. package/dist/types/utils/async_queue.d.ts +18 -0
  212. package/dist/types/utils/case_utils.d.ts +12 -0
  213. package/dist/types/utils/client_labels.d.ts +10 -0
  214. package/dist/types/utils/env_aware_utils.d.ts +3 -3
  215. package/dist/types/utils/live_connection_utils.d.ts +30 -0
  216. package/dist/types/utils/model_name.d.ts +7 -0
  217. package/dist/types/utils/streaming_utils.d.ts +0 -1
  218. package/dist/types/utils/task.d.ts +24 -0
  219. package/dist/types/version.d.ts +1 -1
  220. package/dist/web/agents/active_streaming_tool.js +6 -1
  221. package/dist/web/agents/base_agent.js +31 -1
  222. package/dist/web/agents/context.js +1 -11
  223. package/dist/web/agents/functions.js +36 -15
  224. package/dist/web/agents/instructions.js +99 -33
  225. package/dist/web/agents/invocation_context.js +2 -6
  226. package/dist/web/agents/llm_agent.js +61 -11
  227. package/dist/web/agents/processors/agent_transfer_llm_request_processor.js +7 -0
  228. package/dist/web/agents/processors/basic_llm_request_processor.js +8 -1
  229. package/dist/web/agents/processors/code_execution_request_processor.js +0 -3
  230. package/dist/web/agents/processors/content_processor_utils.js +66 -24
  231. package/dist/web/agents/processors/content_request_processor.js +7 -0
  232. package/dist/web/agents/processors/context_compactor_request_processor.js +16 -2
  233. package/dist/web/agents/processors/identity_llm_request_processor.js +7 -0
  234. package/dist/web/agents/processors/instructions_llm_request_processor.js +5 -0
  235. package/dist/web/agents/processors/interactions_request_processor.js +52 -0
  236. package/dist/web/agents/processors/request_confirmation_llm_request_processor.js +9 -1
  237. package/dist/web/agents/processors/tool_filter_request_processor.js +7 -1
  238. package/dist/web/apps/app.js +49 -0
  239. package/dist/web/apps/resumability_config.js +31 -0
  240. package/dist/web/artifacts/file_artifact_service.js +14 -1
  241. package/dist/web/artifacts/gcs_artifact_service.js +55 -15
  242. package/dist/web/artifacts/in_memory_artifact_service.js +5 -1
  243. package/dist/web/artifacts/scoped_artifact_service.js +86 -0
  244. package/dist/web/artifacts/session_artifact_service.js +7 -0
  245. package/dist/web/auth/auth_preprocessor.js +12 -10
  246. package/dist/web/auth/oauth2/oauth2_discovery.js +14 -4
  247. package/dist/web/auth/oauth2/oauth2_utils.js +12 -1
  248. package/dist/web/code_executors/code_executor_context.js +7 -7
  249. package/dist/web/common.js +75 -3
  250. package/dist/web/context/agent_controlled_context_compactor.js +81 -0
  251. package/dist/web/context/summarizers/llm_summarizer.js +11 -0
  252. package/dist/web/context/token_based_context_compactor.js +43 -11
  253. package/dist/web/context/trajectory_thought_pruning_compactor.js +43 -0
  254. package/dist/web/events/event.js +21 -1
  255. package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +21 -2
  256. package/dist/web/models/gemini_llm_connection.js +75 -19
  257. package/dist/web/models/google_llm.js +80 -17
  258. package/dist/web/models/interactions_utils.js +728 -0
  259. package/dist/web/plugins/base_plugin.js +1 -0
  260. package/dist/web/plugins/security_plugin.js +16 -0
  261. package/dist/web/runner/in_memory_runner.js +13 -2
  262. package/dist/web/runner/runner.js +111 -75
  263. package/dist/web/sessions/base_session_service.js +17 -2
  264. package/dist/web/sessions/database_session_service.js +26 -9
  265. package/dist/web/sessions/db/schema.js +44 -10
  266. package/dist/web/sessions/in_memory_session_service.js +4 -2
  267. package/dist/web/sessions/vertex_ai_session_service.js +21 -5
  268. package/dist/web/skills/gcp_skill_registry.js +78 -0
  269. package/dist/web/skills/loader.js +66 -2
  270. package/dist/web/skills/skill_registry.js +7 -0
  271. package/dist/web/tools/base_toolset.js +1 -1
  272. package/dist/web/tools/consolidate_context_tool.js +51 -0
  273. package/dist/web/tools/forwarding_artifact_service.js +16 -28
  274. package/dist/web/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +221 -0
  275. package/dist/web/tools/openapi_tool/openapi_spec_parser/operation_parser.js +198 -0
  276. package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +91 -0
  277. package/dist/web/tools/openapi_tool/openapi_toolset.js +97 -0
  278. package/dist/web/tools/openapi_tool/rest_api_tool.js +229 -0
  279. package/dist/web/tools/skill/load_skill_resource_tool.js +25 -3
  280. package/dist/web/tools/skill/load_skill_tool.js +12 -1
  281. package/dist/web/tools/skill/run_skill_script_tool.js +12 -1
  282. package/dist/web/tools/skill/search_skills_tool.js +82 -0
  283. package/dist/web/tools/skill/skill_toolset.js +40 -5
  284. package/dist/web/utils/async_hooks_shim.js +24 -0
  285. package/dist/web/utils/async_queue.js +60 -0
  286. package/dist/web/utils/case_utils.js +25 -0
  287. package/dist/web/utils/client_labels.js +38 -2
  288. package/dist/web/utils/env_aware_utils.js +14 -1
  289. package/dist/web/utils/live_connection_utils.js +254 -0
  290. package/dist/web/utils/model_name.js +8 -0
  291. package/dist/web/utils/streaming_utils.js +18 -11
  292. package/dist/web/utils/task.js +34 -0
  293. package/dist/web/version.js +1 -1
  294. package/package.json +4 -2
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { OpenAPIV3 } from 'openapi-types';
7
+ export interface ApiParameter {
8
+ originalName: string;
9
+ paramLocation: string;
10
+ paramSchema: OpenAPIV3.SchemaObject;
11
+ description?: string;
12
+ name: string;
13
+ required: boolean;
14
+ }
15
+ /**
16
+ * Parses an OpenAPI OperationObject and extracts its parameters, request body, and return value.
17
+ *
18
+ * It maps OpenAPI parameters and request bodies into a flat list of `ApiParameter` objects
19
+ * that are compatible with Gemini's tool function declarations.
20
+ */
21
+ export declare class OperationParser {
22
+ private readonly operation;
23
+ private params;
24
+ private returnValue?;
25
+ private preservePropertyNames;
26
+ constructor(operation: OpenAPIV3.OperationObject, options?: {
27
+ preservePropertyNames?: boolean;
28
+ });
29
+ private getParamName;
30
+ private processOperationParameters;
31
+ private processRequestBody;
32
+ private processReturnValue;
33
+ private dedupeParamNames;
34
+ /**
35
+ * Gets the list of parsed parameters extracted from the OpenAPI operation.
36
+ *
37
+ * @returns An array of parsed parameters.
38
+ */
39
+ getParameters(): ApiParameter[];
40
+ /**
41
+ * Generates a JSON schema representing the arguments of the tool function call.
42
+ *
43
+ * @returns A JSON Schema object.
44
+ */
45
+ getJsonSchema(): Record<string, unknown>;
46
+ /**
47
+ * Gets a valid tool function name derived from the operation's operationId.
48
+ *
49
+ * @throws {Error} If the operation does not have an operationId.
50
+ * @returns A string representing the function name.
51
+ */
52
+ getFunctionName(): string;
53
+ /**
54
+ * Gets the description of the tool, derived from the operation's description or summary.
55
+ *
56
+ * @returns A string representing the description.
57
+ */
58
+ getDescription(): string;
59
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { OpenAPIV3 } from 'openapi-types';
7
+ import { Context } from '../../../agents/context.js';
8
+ import { AuthCredential } from '../../../auth/auth_credential.js';
9
+ export interface AuthPreparationResult {
10
+ state: 'pending' | 'done';
11
+ authCredential?: AuthCredential;
12
+ }
13
+ export declare class ToolAuthHandler {
14
+ private readonly context;
15
+ private readonly authScheme?;
16
+ private readonly authCredential?;
17
+ private readonly credentialKey?;
18
+ constructor(context: Context, authScheme?: OpenAPIV3.SecuritySchemeObject | undefined, authCredential?: AuthCredential | undefined, credentialKey?: string | undefined);
19
+ static fromToolContext(context: Context, authScheme?: OpenAPIV3.SecuritySchemeObject, authCredential?: AuthCredential, options?: {
20
+ credentialKey?: string;
21
+ }): ToolAuthHandler;
22
+ prepareAuthCredentials(): Promise<AuthPreparationResult>;
23
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { OpenAPIV3 } from 'openapi-types';
7
+ import { ReadonlyContext } from '../../agents/readonly_context.js';
8
+ import { AuthCredential } from '../../auth/auth_credential.js';
9
+ import { BaseTool } from '../base_tool.js';
10
+ import { BaseToolset, ToolPredicate } from '../base_toolset.js';
11
+ export declare class OpenAPIToolset extends BaseToolset {
12
+ private tools;
13
+ constructor(options?: {
14
+ specDict?: OpenAPIV3.Document;
15
+ specStr?: string;
16
+ specType?: 'json' | 'yaml';
17
+ toolFilter?: ToolPredicate | string[];
18
+ prefix?: string;
19
+ preservePropertyNames?: boolean;
20
+ authScheme?: OpenAPIV3.SecuritySchemeObject;
21
+ authCredential?: AuthCredential;
22
+ credentialKey?: string;
23
+ headerProvider?: (context: ReadonlyContext) => Record<string, string>;
24
+ });
25
+ getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
26
+ close(): Promise<void>;
27
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { FunctionDeclaration } from '@google/genai';
7
+ import { OpenAPIV3 } from 'openapi-types';
8
+ import { ReadonlyContext } from '../../agents/readonly_context.js';
9
+ import { AuthCredential } from '../../auth/auth_credential.js';
10
+ import { BaseTool, RunAsyncToolRequest } from '../base_tool.js';
11
+ import { ApiParameter } from './openapi_spec_parser/operation_parser.js';
12
+ import { OperationEndpoint } from './openapi_spec_parser/openapi_spec_parser.js';
13
+ export declare class RestApiTool extends BaseTool {
14
+ private readonly endpoint;
15
+ private readonly operation;
16
+ private authScheme?;
17
+ private authCredential?;
18
+ private operationParser;
19
+ private headerProvider?;
20
+ private credentialKey?;
21
+ constructor(name: string, description: string, endpoint: OperationEndpoint, operation: OpenAPIV3.OperationObject, authScheme?: OpenAPIV3.SecuritySchemeObject | undefined, authCredential?: AuthCredential | undefined, options?: {
22
+ preservePropertyNames?: boolean;
23
+ headerProvider?: (context: ReadonlyContext) => Record<string, string>;
24
+ credentialKey?: string;
25
+ });
26
+ configureAuthScheme(authScheme: OpenAPIV3.SecuritySchemeObject): void;
27
+ configureAuthCredential(authCredential: AuthCredential): void;
28
+ configureCredentialKey(credentialKey: string): void;
29
+ _getDeclaration(): FunctionDeclaration;
30
+ runAsync(request: RunAsyncToolRequest): Promise<unknown>;
31
+ }
32
+ export interface PreparedParams {
33
+ url: string;
34
+ headers: Record<string, string>;
35
+ body: unknown;
36
+ bodyData: Record<string, unknown>;
37
+ }
38
+ export declare function prepareRequestParams(endpoint: OperationEndpoint, parameters: ApiParameter[], args: Record<string, unknown>): PreparedParams;
39
+ export declare function prepareRequestBody(requestBody: OpenAPIV3.RequestBodyObject | OpenAPIV3.ReferenceObject | undefined, body: unknown, bodyData: Record<string, unknown>, headers: Record<string, string>): unknown;
40
+ export declare function createRestApiTool(parsed: {
41
+ name: string;
42
+ description: string;
43
+ endpoint: OperationEndpoint;
44
+ operation: OpenAPIV3.OperationObject;
45
+ authScheme?: OpenAPIV3.SecuritySchemeObject;
46
+ }, options?: {
47
+ preservePropertyNames?: boolean;
48
+ headerProvider?: (context: ReadonlyContext) => Record<string, string>;
49
+ credentialKey?: string;
50
+ }): RestApiTool;
@@ -10,6 +10,6 @@ export declare class LoadSkillResourceTool extends BaseTool {
10
10
  private toolset;
11
11
  constructor(toolset: SkillToolset);
12
12
  _getDeclaration(): FunctionDeclaration;
13
- runAsync({ args }: RunAsyncToolRequest): Promise<unknown>;
13
+ runAsync({ args, toolContext, }: RunAsyncToolRequest): Promise<unknown>;
14
14
  processLlmRequest(request: ToolProcessLlmRequest): Promise<void>;
15
15
  }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { FunctionDeclaration } from '@google/genai';
7
+ import { BaseTool, RunAsyncToolRequest } from '../base_tool.js';
8
+ import { SkillToolset } from './skill_toolset.js';
9
+ export declare class SearchSkillsTool extends BaseTool {
10
+ private toolset;
11
+ constructor(toolset: SkillToolset);
12
+ _getDeclaration(): FunctionDeclaration;
13
+ runAsync({ args }: RunAsyncToolRequest): Promise<unknown>;
14
+ }
@@ -8,6 +8,7 @@ import { ReadonlyContext } from '../../agents/readonly_context.js';
8
8
  import { BaseCodeExecutor } from '../../code_executors/base_code_executor.js';
9
9
  import { LlmRequest } from '../../models/llm_request.js';
10
10
  import { Skill } from '../../skills/skill.js';
11
+ import { SkillRegistry } from '../../skills/skill_registry.js';
11
12
  import { BaseTool } from '../base_tool.js';
12
13
  import { BaseToolset } from '../base_toolset.js';
13
14
  export declare class SkillToolset extends BaseToolset {
@@ -15,14 +16,18 @@ export declare class SkillToolset extends BaseToolset {
15
16
  private tools;
16
17
  additionalTools: Array<BaseTool | BaseToolset>;
17
18
  codeExecutor?: BaseCodeExecutor;
19
+ registry?: SkillRegistry;
18
20
  private toolCache;
21
+ private fetchedSkillCache;
19
22
  constructor(skills: Record<string, Skill> | Skill[], options?: {
20
23
  codeExecutor?: BaseCodeExecutor;
21
24
  additionalTools?: Array<BaseTool | BaseToolset>;
25
+ registry?: SkillRegistry;
22
26
  });
23
27
  getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
24
28
  close(): Promise<void>;
25
29
  getSkill(name: string): Skill | undefined;
30
+ getOrFetchSkill(name: string, invocationId?: string): Promise<Skill | undefined>;
26
31
  processLlmRequest(toolContext: Context, llmRequest: LlmRequest): Promise<void>;
27
32
  private resolveAdditionalTools;
28
33
  }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export declare class AsyncLocalStorage<T> {
7
+ private store;
8
+ run<R>(store: T, callback: () => R): R;
9
+ getStore(): T | undefined;
10
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * A generic, async-safe queue that implements AsyncIterable.
8
+ */
9
+ export declare class AsyncQueue<T> implements AsyncIterable<T> {
10
+ private queue;
11
+ private resolvers;
12
+ private closed;
13
+ private errorVal?;
14
+ push(value: T): void;
15
+ error(err: unknown): void;
16
+ close(): void;
17
+ [Symbol.asyncIterator](): AsyncIterator<T>;
18
+ }
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Recursively converts snake_case keys of an object to camelCase.
8
+ *
9
+ * @param val The value to convert.
10
+ * @returns The converted value.
11
+ */
12
+ export declare function camelCaseKeys(val: unknown): unknown;
@@ -3,6 +3,16 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ export declare function parseUserAgent(userAgent: string): string;
7
+ /**
8
+ * Runs the given callback within a context that has the specified client label.
9
+ * All LLM calls made within this callback will include the client label in their tracking headers.
10
+ *
11
+ * @param clientLabel The custom client label to apply.
12
+ * @param callback The callback function to execute.
13
+ * @return The result of the callback.
14
+ */
15
+ export declare function runWithClientLabel<R>(clientLabel: string, callback: () => R): R;
6
16
  /**
7
17
  * Returns the current list of client labels that can be added to HTTP Headers.
8
18
  */
@@ -9,12 +9,12 @@
9
9
  export declare function isBrowser(): boolean;
10
10
  export declare function randomUUID(): string;
11
11
  /**
12
- * Encodes the given string to base64.
12
+ * Encodes the given string or Uint8Array to base64.
13
13
  *
14
- * @param data The string to encode.
14
+ * @param data The data to encode.
15
15
  * @return The base64-encoded string.
16
16
  */
17
- export declare function base64Encode(data: string): string;
17
+ export declare function base64Encode(data: string | Uint8Array): string;
18
18
  /**
19
19
  * Decodes the given base64 string to a string.
20
20
  *
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { LiveServerMessage } from '@google/genai';
7
+ import { LlmResponse } from '../models/llm_response.js';
8
+ /**
9
+ * Aggregator and mapper for Gemini Live WebSocket server messages.
10
+ *
11
+ * Translates incoming raw WebSocket server messages (push stream) into unified
12
+ * agent-consumable LlmResponse objects (pull stream), managing transcription buffers,
13
+ * grounding metadata, text segments, and tool calls.
14
+ */
15
+ export declare class LiveResponseAggregator {
16
+ private readonly modelVersion?;
17
+ private text;
18
+ private isThought;
19
+ private toolCallParts;
20
+ private pendingGroundingMetadata;
21
+ private inputTranscriptionText;
22
+ private outputTranscriptionText;
23
+ constructor(modelVersion?: string | undefined);
24
+ processMessage(message: LiveServerMessage): Generator<LlmResponse, void, void>;
25
+ /**
26
+ * Flushes any remaining aggregated components when the connection is closed.
27
+ */
28
+ close(): Generator<LlmResponse, void, void>;
29
+ private buildFullTextResponse;
30
+ }
@@ -32,6 +32,13 @@ export declare function isGemini1Model(modelString: string): boolean;
32
32
  * @return true if it's a Gemini 2.x model, false otherwise.
33
33
  */
34
34
  export declare function isGemini2OrAbove(modelString: string): boolean;
35
+ /**
36
+ * Check if the model is a Gemini 3.x Flash Live model.
37
+ *
38
+ * @param modelString Either a simple model name or path-based model name
39
+ * @return true if it's a Gemini 3.x Flash Live model, false otherwise.
40
+ */
41
+ export declare function isGemini3xFlashLive(modelString: string | undefined): boolean;
35
42
  /**
36
43
  * Returns True when Gemini model-id validation should be bypassed.
37
44
  */
@@ -19,7 +19,6 @@ export declare class StreamingResponseAggregator {
19
19
  private response?;
20
20
  private finishReason?;
21
21
  private lastThoughtSignature;
22
- private sawFunctionCall;
23
22
  private readonly strategy;
24
23
  constructor(isProgressiveMode?: boolean);
25
24
  processResponse(response: GenerateContentResponse): AsyncGenerator<LlmResponse, void, void>;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export type TaskExecutable<T = void> = (abortSignal: AbortSignal) => Promise<T>;
7
+ /**
8
+ * Represents a runtime task wrapping a promise, allowing status check and cancellation.
9
+ */
10
+ export declare class Task<T = void> {
11
+ executable: TaskExecutable<T>;
12
+ private isDone;
13
+ private abortController;
14
+ promise: Promise<T>;
15
+ constructor(executable: TaskExecutable<T>);
16
+ /**
17
+ * Cancels the task execution.
18
+ */
19
+ cancel(): void;
20
+ /**
21
+ * Returns true if the task has completed (either resolved or rejected).
22
+ */
23
+ done(): boolean;
24
+ }
@@ -3,4 +3,4 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
- export declare const version = "1.2.0";
6
+ export declare const version = "1.4.0";
@@ -5,9 +5,14 @@ const require = topLevelCreateRequire(import.meta.url);
5
5
  * Copyright 2025 Google LLC
6
6
  * SPDX-License-Identifier: Apache-2.0
7
7
  */
8
+ import { Task } from "../utils/task.js";
8
9
  class ActiveStreamingTool {
9
10
  constructor(params = {}) {
10
- this.task = params.task;
11
+ if (params.task instanceof Promise) {
12
+ this.task = new Task(() => params.task);
13
+ } else {
14
+ this.task = params.task;
15
+ }
11
16
  this.stream = params.stream;
12
17
  }
13
18
  }
@@ -184,10 +184,40 @@ class BaseAgent {
184
184
  this,
185
185
  function() {
186
186
  return __asyncGenerator(this, null, function* () {
187
+ var _a2, _b;
188
+ const context2 = this.createInvocationContext(parentContext);
189
+ const beforeAgentCallbackEvent = yield new __await(this.handleBeforeAgentCallback(context2));
190
+ if (beforeAgentCallbackEvent) {
191
+ yield beforeAgentCallbackEvent;
192
+ }
193
+ if (context2.endInvocation || ((_a2 = parentContext.abortSignal) == null ? void 0 : _a2.aborted)) {
194
+ return;
195
+ }
196
+ try {
197
+ for (var iter = __forAwait(this.runLiveImpl(context2)), more, temp, error; more = !(temp = yield new __await(iter.next())).done; more = false) {
198
+ const event = temp.value;
199
+ yield event;
200
+ }
201
+ } catch (temp) {
202
+ error = [temp];
203
+ } finally {
204
+ try {
205
+ more && (temp = iter.return) && (yield new __await(temp.call(iter)));
206
+ } finally {
207
+ if (error)
208
+ throw error[0];
209
+ }
210
+ }
211
+ if (context2.endInvocation || ((_b = parentContext.abortSignal) == null ? void 0 : _b.aborted)) {
212
+ return;
213
+ }
214
+ const afterAgentCallbackEvent = yield new __await(this.handleAfterAgentCallback(context2));
215
+ if (afterAgentCallbackEvent) {
216
+ yield afterAgentCallbackEvent;
217
+ }
187
218
  });
188
219
  }
189
220
  ));
190
- throw new Error("Live mode is not implemented yet.");
191
221
  } finally {
192
222
  span.end();
193
223
  }
@@ -56,9 +56,6 @@ class Context extends ReadonlyContext {
56
56
  throw new Error("Artifact service is not initialized.");
57
57
  }
58
58
  return this.invocationContext.artifactService.loadArtifact({
59
- appName: this.invocationContext.appName,
60
- userId: this.invocationContext.userId,
61
- sessionId: this.invocationContext.session.id,
62
59
  filename,
63
60
  version
64
61
  });
@@ -75,9 +72,6 @@ class Context extends ReadonlyContext {
75
72
  throw new Error("Artifact service is not initialized.");
76
73
  }
77
74
  const version = await this.invocationContext.artifactService.saveArtifact({
78
- appName: this.invocationContext.appName,
79
- userId: this.invocationContext.userId,
80
- sessionId: this.invocationContext.session.id,
81
75
  filename,
82
76
  artifact
83
77
  });
@@ -110,11 +104,7 @@ class Context extends ReadonlyContext {
110
104
  if (!this.invocationContext.artifactService) {
111
105
  throw new Error("Artifact service is not initialized.");
112
106
  }
113
- return this.invocationContext.artifactService.listArtifactKeys({
114
- appName: this.invocationContext.session.appName,
115
- userId: this.invocationContext.session.userId,
116
- sessionId: this.invocationContext.session.id
117
- });
107
+ return this.invocationContext.artifactService.listArtifactKeys();
118
108
  }
119
109
  /**
120
110
  * Searches the memory of the current user.
@@ -7,7 +7,11 @@ const require = topLevelCreateRequire(import.meta.url);
7
7
  */
8
8
  import { createUserContent } from "@google/genai";
9
9
  import { isEmpty } from "lodash-es";
10
- import { createEvent, getFunctionCalls } from "../events/event.js";
10
+ import {
11
+ createEvent,
12
+ getFunctionCalls,
13
+ getFunctionResponses
14
+ } from "../events/event.js";
11
15
  import { mergeEventActions } from "../events/event_actions.js";
12
16
  import { randomUUID } from "../utils/env_aware_utils.js";
13
17
  import { logger } from "../utils/logger.js";
@@ -39,18 +43,6 @@ function populateClientFunctionCallId(modelResponseEvent) {
39
43
  }
40
44
  }
41
45
  }
42
- function removeClientFunctionCallId(content) {
43
- if (content && content.parts) {
44
- for (const part of content.parts) {
45
- if (part.functionCall && part.functionCall.id && part.functionCall.id.startsWith(AF_FUNCTION_CALL_ID_PREFIX)) {
46
- part.functionCall.id = void 0;
47
- }
48
- if (part.functionResponse && part.functionResponse.id && part.functionResponse.id.startsWith(AF_FUNCTION_CALL_ID_PREFIX)) {
49
- part.functionResponse.id = void 0;
50
- }
51
- }
52
- }
53
- }
54
46
  function getLongRunningFunctionCalls(functionCalls, toolsDict) {
55
47
  const longRunningToolIds = /* @__PURE__ */ new Set();
56
48
  for (const functionCall of functionCalls) {
@@ -393,9 +385,39 @@ function mergeParallelFunctionResponseEvents(functionResponseEvents) {
393
385
  timestamp: baseEvent.timestamp
394
386
  });
395
387
  }
388
+ function findEventByFunctionCallId(events, functionCallId, endIndex = events.length) {
389
+ for (let i = endIndex - 1; i >= 0; i--) {
390
+ const event = events[i];
391
+ const functionCalls = getFunctionCalls(event);
392
+ for (const functionCall of functionCalls) {
393
+ if (functionCall.id === functionCallId) {
394
+ return event;
395
+ }
396
+ }
397
+ }
398
+ return void 0;
399
+ }
400
+ function findMatchingFunctionCall(events) {
401
+ if (!events.length) {
402
+ return void 0;
403
+ }
404
+ const lastEvent = events[events.length - 1];
405
+ const functionResponses = getFunctionResponses(lastEvent);
406
+ if (!functionResponses.length || !functionResponses[0].id) {
407
+ return void 0;
408
+ }
409
+ return findEventByFunctionCallId(
410
+ events,
411
+ functionResponses[0].id,
412
+ events.length - 1
413
+ );
414
+ }
396
415
  export {
416
+ AF_FUNCTION_CALL_ID_PREFIX,
397
417
  REQUEST_CONFIRMATION_FUNCTION_CALL_NAME,
398
418
  REQUEST_EUC_FUNCTION_CALL_NAME,
419
+ findEventByFunctionCallId,
420
+ findMatchingFunctionCall,
399
421
  functionsExportedForTestingOnly,
400
422
  generateAuthEvent,
401
423
  generateClientFunctionCallId,
@@ -404,6 +426,5 @@ export {
404
426
  handleFunctionCallList,
405
427
  handleFunctionCallsAsync,
406
428
  mergeParallelFunctionResponseEvents,
407
- populateClientFunctionCallId,
408
- removeClientFunctionCallId
429
+ populateClientFunctionCallId
409
430
  };