@google/adk 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (248) hide show
  1. package/dist/cjs/a2a/agent_to_a2a.js +18 -2
  2. package/dist/cjs/a2a/event_converter_utils.js +8 -4
  3. package/dist/cjs/a2a/metadata_converter_utils.js +1 -1
  4. package/dist/cjs/agents/active_streaming_tool.js +6 -1
  5. package/dist/cjs/agents/base_agent.js +39 -0
  6. package/dist/cjs/agents/context.js +1 -11
  7. package/dist/cjs/agents/functions.js +39 -35
  8. package/dist/cjs/agents/instructions.js +23 -5
  9. package/dist/cjs/agents/invocation_context.js +2 -5
  10. package/dist/cjs/agents/llm_agent.js +10 -7
  11. package/dist/cjs/agents/loop_agent.js +15 -3
  12. package/dist/cjs/agents/processors/code_execution_request_processor.js +0 -3
  13. package/dist/cjs/agents/processors/content_processor_utils.js +18 -4
  14. package/dist/cjs/agents/processors/context_compactor_request_processor.js +4 -2
  15. package/dist/cjs/agents/processors/interactions_request_processor.js +63 -0
  16. package/dist/cjs/agents/routed_agent.js +31 -0
  17. package/dist/cjs/agents/run_config.js +3 -2
  18. package/dist/cjs/apps/app.js +79 -0
  19. package/dist/cjs/apps/resumability_config.js +44 -0
  20. package/dist/cjs/artifacts/file_artifact_service.js +14 -1
  21. package/dist/cjs/artifacts/gcs_artifact_service.js +57 -15
  22. package/dist/cjs/artifacts/in_memory_artifact_service.js +12 -1
  23. package/dist/cjs/artifacts/scoped_artifact_service.js +101 -0
  24. package/dist/cjs/artifacts/session_artifact_service.js +27 -0
  25. package/dist/cjs/auth/oauth2/oauth2_discovery.js +17 -5
  26. package/dist/cjs/auth/oauth2/oauth2_utils.js +12 -1
  27. package/dist/cjs/common.js +76 -0
  28. package/dist/cjs/context/agent_controlled_context_compactor.js +109 -0
  29. package/dist/cjs/context/anchored_context_compactor.js +127 -0
  30. package/dist/cjs/context/compaction_utils.js +52 -0
  31. package/dist/cjs/context/token_based_context_compactor.js +52 -33
  32. package/dist/cjs/context/trajectory_thought_pruning_compactor.js +71 -0
  33. package/dist/cjs/events/compacted_event.js +9 -3
  34. package/dist/cjs/events/event.js +52 -0
  35. package/dist/cjs/index.js +4 -0
  36. package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
  37. package/dist/cjs/models/google_llm.js +25 -10
  38. package/dist/cjs/models/interactions_utils.js +732 -0
  39. package/dist/cjs/plugins/base_plugin.js +1 -0
  40. package/dist/cjs/plugins/global_instruction_plugin.js +97 -0
  41. package/dist/cjs/runner/in_memory_runner.js +13 -2
  42. package/dist/cjs/runner/runner.js +143 -83
  43. package/dist/cjs/sessions/base_session_service.js +6 -1
  44. package/dist/cjs/sessions/database_session_service.js +24 -7
  45. package/dist/cjs/sessions/vertex_ai_session_service.js +19 -4
  46. package/dist/cjs/skills/loader.js +2 -2
  47. package/dist/cjs/tools/base_toolset.js +1 -1
  48. package/dist/cjs/tools/consolidate_context_tool.js +79 -0
  49. package/dist/cjs/tools/enterprise_web_search_tool.js +81 -0
  50. package/dist/cjs/tools/example_tool.js +68 -0
  51. package/dist/cjs/tools/forwarding_artifact_service.js +16 -28
  52. package/dist/cjs/tools/load_web_page.js +250 -0
  53. package/dist/cjs/tools/mcp/load_mcp_resource_tool.js +140 -0
  54. package/dist/cjs/tools/mcp/mcp_toolset.js +63 -0
  55. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -22
  56. package/dist/cjs/tools/skill/run_skill_inline_script_tool.js +54 -4
  57. package/dist/cjs/tools/skill/skill_toolset.js +4 -2
  58. package/dist/cjs/utils/async_hooks_shim.js +52 -0
  59. package/dist/cjs/utils/branch_trie.js +41 -0
  60. package/dist/cjs/utils/client_labels.js +41 -3
  61. package/dist/cjs/utils/env_aware_utils.js +10 -1
  62. package/dist/cjs/utils/streaming_utils.js +15 -9
  63. package/dist/cjs/utils/task.js +62 -0
  64. package/dist/cjs/version.js +1 -1
  65. package/dist/esm/a2a/agent_to_a2a.js +18 -2
  66. package/dist/esm/a2a/event_converter_utils.js +8 -4
  67. package/dist/esm/a2a/metadata_converter_utils.js +1 -1
  68. package/dist/esm/agents/active_streaming_tool.js +6 -1
  69. package/dist/esm/agents/base_agent.js +39 -0
  70. package/dist/esm/agents/context.js +1 -11
  71. package/dist/esm/agents/functions.js +43 -32
  72. package/dist/esm/agents/instructions.js +23 -5
  73. package/dist/esm/agents/invocation_context.js +2 -5
  74. package/dist/esm/agents/llm_agent.js +12 -9
  75. package/dist/esm/agents/loop_agent.js +15 -3
  76. package/dist/esm/agents/processors/code_execution_request_processor.js +0 -3
  77. package/dist/esm/agents/processors/content_processor_utils.js +16 -3
  78. package/dist/esm/agents/processors/context_compactor_request_processor.js +4 -2
  79. package/dist/esm/agents/processors/interactions_request_processor.js +34 -0
  80. package/dist/esm/agents/routed_agent.js +31 -0
  81. package/dist/esm/agents/run_config.js +3 -2
  82. package/dist/esm/apps/app.js +49 -0
  83. package/dist/esm/apps/resumability_config.js +16 -0
  84. package/dist/esm/artifacts/file_artifact_service.js +14 -1
  85. package/dist/esm/artifacts/gcs_artifact_service.js +57 -15
  86. package/dist/esm/artifacts/in_memory_artifact_service.js +12 -1
  87. package/dist/esm/artifacts/scoped_artifact_service.js +73 -0
  88. package/dist/esm/artifacts/session_artifact_service.js +7 -0
  89. package/dist/esm/auth/oauth2/oauth2_discovery.js +14 -4
  90. package/dist/esm/auth/oauth2/oauth2_utils.js +12 -1
  91. package/dist/esm/common.js +67 -3
  92. package/dist/esm/context/agent_controlled_context_compactor.js +81 -0
  93. package/dist/esm/context/anchored_context_compactor.js +99 -0
  94. package/dist/esm/context/compaction_utils.js +27 -0
  95. package/dist/esm/context/token_based_context_compactor.js +52 -33
  96. package/dist/esm/context/trajectory_thought_pruning_compactor.js +43 -0
  97. package/dist/esm/events/compacted_event.js +7 -2
  98. package/dist/esm/events/event.js +46 -0
  99. package/dist/esm/index.js +6 -1
  100. package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
  101. package/dist/esm/models/google_llm.js +23 -9
  102. package/dist/esm/models/interactions_utils.js +697 -0
  103. package/dist/esm/plugins/base_plugin.js +1 -0
  104. package/dist/esm/plugins/global_instruction_plugin.js +69 -0
  105. package/dist/esm/runner/in_memory_runner.js +13 -2
  106. package/dist/esm/runner/runner.js +141 -84
  107. package/dist/esm/sessions/base_session_service.js +6 -1
  108. package/dist/esm/sessions/database_session_service.js +24 -7
  109. package/dist/esm/sessions/vertex_ai_session_service.js +17 -3
  110. package/dist/esm/skills/loader.js +2 -2
  111. package/dist/esm/tools/base_toolset.js +1 -1
  112. package/dist/esm/tools/consolidate_context_tool.js +51 -0
  113. package/dist/esm/tools/enterprise_web_search_tool.js +55 -0
  114. package/dist/esm/tools/example_tool.js +42 -0
  115. package/dist/esm/tools/forwarding_artifact_service.js +16 -28
  116. package/dist/esm/tools/load_web_page.js +221 -0
  117. package/dist/esm/tools/mcp/load_mcp_resource_tool.js +114 -0
  118. package/dist/esm/tools/mcp/mcp_toolset.js +63 -0
  119. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -22
  120. package/dist/esm/tools/skill/run_skill_inline_script_tool.js +53 -4
  121. package/dist/esm/tools/skill/skill_toolset.js +4 -2
  122. package/dist/esm/utils/async_hooks_shim.js +24 -0
  123. package/dist/esm/utils/branch_trie.js +13 -0
  124. package/dist/esm/utils/client_labels.js +38 -2
  125. package/dist/esm/utils/env_aware_utils.js +10 -1
  126. package/dist/esm/utils/streaming_utils.js +11 -5
  127. package/dist/esm/utils/task.js +34 -0
  128. package/dist/esm/version.js +1 -1
  129. package/dist/types/a2a/a2a_remote_agent.d.ts +5 -1
  130. package/dist/types/a2a/agent_to_a2a.d.ts +38 -0
  131. package/dist/types/agents/active_streaming_tool.d.ts +3 -4
  132. package/dist/types/agents/base_agent.d.ts +29 -1
  133. package/dist/types/agents/functions.d.ts +12 -17
  134. package/dist/types/agents/invocation_context.d.ts +7 -3
  135. package/dist/types/agents/llm_agent.d.ts +5 -1
  136. package/dist/types/agents/loop_agent.d.ts +2 -2
  137. package/dist/types/agents/processors/content_processor_utils.d.ts +8 -0
  138. package/dist/types/agents/processors/interactions_request_processor.d.ts +17 -0
  139. package/dist/types/agents/routed_agent.d.ts +24 -1
  140. package/dist/types/agents/run_config.d.ts +1 -1
  141. package/dist/types/apps/app.d.ts +52 -0
  142. package/dist/types/apps/resumability_config.d.ts +27 -0
  143. package/dist/types/artifacts/base_artifact_service.d.ts +6 -36
  144. package/dist/types/artifacts/gcs_artifact_service.d.ts +2 -1
  145. package/dist/types/artifacts/scoped_artifact_service.d.ts +25 -0
  146. package/dist/types/artifacts/session_artifact_service.d.ts +25 -0
  147. package/dist/types/auth/oauth2/oauth2_discovery.d.ts +11 -0
  148. package/dist/types/common.d.ts +29 -5
  149. package/dist/types/context/agent_controlled_context_compactor.d.ts +24 -0
  150. package/dist/types/context/anchored_context_compactor.d.ts +35 -0
  151. package/dist/types/context/base_context_compactor.d.ts +3 -0
  152. package/dist/types/context/compaction_utils.d.ts +15 -0
  153. package/dist/types/context/token_based_context_compactor.d.ts +6 -1
  154. package/dist/types/context/trajectory_thought_pruning_compactor.d.ts +27 -0
  155. package/dist/types/events/compacted_event.d.ts +10 -0
  156. package/dist/types/events/event.d.ts +21 -0
  157. package/dist/types/index.d.ts +3 -2
  158. package/dist/types/models/google_llm.d.ts +15 -1
  159. package/dist/types/models/interactions_utils.d.ts +92 -0
  160. package/dist/types/models/llm_request.d.ts +4 -0
  161. package/dist/types/models/llm_response.d.ts +4 -0
  162. package/dist/types/plugins/base_plugin.d.ts +2 -1
  163. package/dist/types/plugins/global_instruction_plugin.d.ts +38 -0
  164. package/dist/types/runner/in_memory_runner.d.ts +7 -1
  165. package/dist/types/runner/runner.d.ts +44 -10
  166. package/dist/types/sessions/base_session_service.d.ts +3 -16
  167. package/dist/types/sessions/session.d.ts +11 -0
  168. package/dist/types/sessions/vertex_ai_session_service.d.ts +9 -1
  169. package/dist/types/tools/consolidate_context_tool.d.ts +19 -0
  170. package/dist/types/tools/enterprise_web_search_tool.d.ts +26 -0
  171. package/dist/types/tools/example_tool.d.ts +21 -0
  172. package/dist/types/tools/forwarding_artifact_service.d.ts +3 -2
  173. package/dist/types/tools/load_web_page.d.ts +33 -0
  174. package/dist/types/tools/mcp/load_mcp_resource_tool.d.ts +26 -0
  175. package/dist/types/tools/mcp/mcp_toolset.d.ts +27 -0
  176. package/dist/types/tools/skill/run_skill_inline_script_tool.d.ts +25 -0
  177. package/dist/types/tools/skill/skill_toolset.d.ts +9 -0
  178. package/dist/types/utils/async_hooks_shim.d.ts +10 -0
  179. package/dist/types/utils/branch_trie.d.ts +14 -0
  180. package/dist/types/utils/client_labels.d.ts +10 -0
  181. package/dist/types/utils/env_aware_utils.d.ts +3 -3
  182. package/dist/types/utils/task.d.ts +24 -0
  183. package/dist/types/version.d.ts +1 -1
  184. package/dist/web/a2a/agent_to_a2a.js +18 -2
  185. package/dist/web/a2a/event_converter_utils.js +8 -4
  186. package/dist/web/a2a/metadata_converter_utils.js +1 -1
  187. package/dist/web/agents/active_streaming_tool.js +6 -1
  188. package/dist/web/agents/base_agent.js +39 -0
  189. package/dist/web/agents/context.js +1 -11
  190. package/dist/web/agents/functions.js +43 -32
  191. package/dist/web/agents/instructions.js +23 -5
  192. package/dist/web/agents/invocation_context.js +2 -5
  193. package/dist/web/agents/llm_agent.js +12 -9
  194. package/dist/web/agents/loop_agent.js +27 -3
  195. package/dist/web/agents/processors/code_execution_request_processor.js +0 -3
  196. package/dist/web/agents/processors/content_processor_utils.js +16 -3
  197. package/dist/web/agents/processors/context_compactor_request_processor.js +4 -2
  198. package/dist/web/agents/processors/interactions_request_processor.js +52 -0
  199. package/dist/web/agents/routed_agent.js +31 -0
  200. package/dist/web/agents/run_config.js +8 -3
  201. package/dist/web/apps/app.js +49 -0
  202. package/dist/web/apps/resumability_config.js +31 -0
  203. package/dist/web/artifacts/file_artifact_service.js +14 -1
  204. package/dist/web/artifacts/gcs_artifact_service.js +55 -15
  205. package/dist/web/artifacts/in_memory_artifact_service.js +12 -1
  206. package/dist/web/artifacts/scoped_artifact_service.js +86 -0
  207. package/dist/web/artifacts/session_artifact_service.js +7 -0
  208. package/dist/web/auth/oauth2/oauth2_discovery.js +14 -4
  209. package/dist/web/auth/oauth2/oauth2_utils.js +12 -1
  210. package/dist/web/common.js +67 -3
  211. package/dist/web/context/agent_controlled_context_compactor.js +81 -0
  212. package/dist/web/context/anchored_context_compactor.js +117 -0
  213. package/dist/web/context/compaction_utils.js +27 -0
  214. package/dist/web/context/token_based_context_compactor.js +52 -33
  215. package/dist/web/context/trajectory_thought_pruning_compactor.js +43 -0
  216. package/dist/web/events/compacted_event.js +7 -2
  217. package/dist/web/events/event.js +44 -0
  218. package/dist/web/index.js +6 -1
  219. package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
  220. package/dist/web/models/google_llm.js +54 -9
  221. package/dist/web/models/interactions_utils.js +728 -0
  222. package/dist/web/plugins/base_plugin.js +1 -0
  223. package/dist/web/plugins/global_instruction_plugin.js +67 -0
  224. package/dist/web/runner/in_memory_runner.js +13 -2
  225. package/dist/web/runner/runner.js +157 -84
  226. package/dist/web/sessions/base_session_service.js +6 -1
  227. package/dist/web/sessions/database_session_service.js +24 -7
  228. package/dist/web/sessions/vertex_ai_session_service.js +17 -3
  229. package/dist/web/skills/loader.js +2 -2
  230. package/dist/web/tools/base_toolset.js +1 -1
  231. package/dist/web/tools/consolidate_context_tool.js +51 -0
  232. package/dist/web/tools/enterprise_web_search_tool.js +55 -0
  233. package/dist/web/tools/example_tool.js +42 -0
  234. package/dist/web/tools/forwarding_artifact_service.js +16 -28
  235. package/dist/web/tools/load_web_page.js +221 -0
  236. package/dist/web/tools/mcp/load_mcp_resource_tool.js +107 -0
  237. package/dist/web/tools/mcp/mcp_toolset.js +63 -0
  238. package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +15 -22
  239. package/dist/web/tools/skill/run_skill_inline_script_tool.js +51 -4
  240. package/dist/web/tools/skill/skill_toolset.js +4 -2
  241. package/dist/web/utils/async_hooks_shim.js +24 -0
  242. package/dist/web/utils/branch_trie.js +13 -0
  243. package/dist/web/utils/client_labels.js +38 -2
  244. package/dist/web/utils/env_aware_utils.js +10 -1
  245. package/dist/web/utils/streaming_utils.js +11 -5
  246. package/dist/web/utils/task.js +34 -0
  247. package/dist/web/version.js +1 -1
  248. package/package.json +2 -2
@@ -77,6 +77,10 @@ export interface LlmResponse {
77
77
  * Audio transcription of model output.
78
78
  */
79
79
  outputTranscription?: Transcription;
80
+ /**
81
+ * The interaction ID returned by the model, if any.
82
+ */
83
+ interactionId?: string;
80
84
  /** The model version used to generate the response. */
81
85
  modelVersion?: string;
82
86
  /** The session ID of the Live session. */
@@ -16,7 +16,8 @@ import { BaseTool } from '../tools/base_tool.js';
16
16
  */
17
17
  export declare enum ContextCompactionTrigger {
18
18
  Manual = "Manual",
19
- Auto = "Auto"
19
+ Auto = "Auto",
20
+ AgentControlled = "AgentControlled"
20
21
  }
21
22
  /**
22
23
  * Base class for creating plugins.
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Context } from '../agents/context.js';
7
+ import { InstructionProvider } from '../agents/llm_agent.js';
8
+ import { LlmRequest } from '../models/llm_request.js';
9
+ import { LlmResponse } from '../models/llm_response.js';
10
+ import { BasePlugin } from './base_plugin.js';
11
+ /**
12
+ * Plugin that provides global instructions functionality at the App level.
13
+ *
14
+ * This plugin replaces the deprecated globalInstruction field on LlmAgent.
15
+ * Global instructions are applied to all agents in the application, providing
16
+ * a consistent way to set application-wide instructions, identity, or
17
+ * personality.
18
+ *
19
+ * The plugin operates through the beforeModelCallback, allowing it to modify
20
+ * LLM requests before they are sent to the model.
21
+ */
22
+ export declare class GlobalInstructionPlugin extends BasePlugin {
23
+ private readonly globalInstruction?;
24
+ /**
25
+ * Initializes the GlobalInstructionPlugin.
26
+ *
27
+ * @param globalInstruction The instruction to apply globally. Can be a string
28
+ * or an InstructionProvider function that takes ReadonlyContext and
29
+ * returns a string (sync or async).
30
+ * @param name The name of the plugin (defaults to 'global_instruction').
31
+ */
32
+ constructor(globalInstruction?: string | InstructionProvider, name?: string);
33
+ beforeModelCallback(params: {
34
+ callbackContext: Context;
35
+ llmRequest: LlmRequest;
36
+ }): Promise<LlmResponse | undefined>;
37
+ private resolveGlobalInstruction;
38
+ }
@@ -4,6 +4,8 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { BaseAgent } from '../agents/base_agent.js';
7
+ import { App } from '../apps/app.js';
8
+ import { ResumabilityConfig } from '../apps/resumability_config.js';
7
9
  import { BasePlugin } from '../plugins/base_plugin.js';
8
10
  import { Runner } from './runner.js';
9
11
  /**
@@ -30,13 +32,17 @@ export declare class InMemoryRunner extends Runner {
30
32
  * Creates a new InMemoryRunner instance.
31
33
  *
32
34
  * @param params The configuration for the runner.
35
+ * @param params.app An optional application instance to run.
33
36
  * @param params.agent The root agent to run.
34
37
  * @param params.appName The application name. Defaults to `'InMemoryRunner'`.
35
38
  * @param params.plugins An optional list of plugins.
39
+ * @param params.resumabilityConfig An optional resumability configuration.
36
40
  */
37
41
  constructor(params: {
38
- agent: BaseAgent;
42
+ app?: App;
43
+ agent?: BaseAgent;
39
44
  appName?: string;
40
45
  plugins?: BasePlugin[];
46
+ resumabilityConfig?: ResumabilityConfig;
41
47
  });
42
48
  }
@@ -6,6 +6,8 @@
6
6
  import { Content } from '@google/genai';
7
7
  import { BaseAgent } from '../agents/base_agent.js';
8
8
  import { RunConfig } from '../agents/run_config.js';
9
+ import { App } from '../apps/app.js';
10
+ import { ResumabilityConfig } from '../apps/resumability_config.js';
9
11
  import { BaseArtifactService } from '../artifacts/base_artifact_service.js';
10
12
  import { BaseCredentialService } from '../auth/credential_service/base_credential_service.js';
11
13
  import { Event } from '../events/event.js';
@@ -13,18 +15,23 @@ import { BaseMemoryService } from '../memory/base_memory_service.js';
13
15
  import { BasePlugin } from '../plugins/base_plugin.js';
14
16
  import { PluginManager } from '../plugins/plugin_manager.js';
15
17
  import { BaseSessionService } from '../sessions/base_session_service.js';
18
+ import { Session } from '../sessions/session.js';
16
19
  /**
17
20
  * The configuration parameters for the Runner.
18
21
  */
19
22
  export interface RunnerConfig {
20
23
  /**
21
- * The application name.
24
+ * The application object. If provided, `appName`, `agent`, and `plugins` will default from this app.
22
25
  */
23
- appName: string;
26
+ app?: App;
24
27
  /**
25
- * The agent to run.
28
+ * The application name. Required if `app` is not provided.
26
29
  */
27
- agent: BaseAgent;
30
+ appName?: string;
31
+ /**
32
+ * The agent to run. Required if `app` is not provided.
33
+ */
34
+ agent?: BaseAgent;
28
35
  /**
29
36
  * An optional list of plugins to apply globally across all agents.
30
37
  */
@@ -45,6 +52,10 @@ export interface RunnerConfig {
45
52
  * An optional service for managing authentication credentials.
46
53
  */
47
54
  credentialService?: BaseCredentialService;
55
+ /**
56
+ * An optional resumability configuration applied to the runner.
57
+ */
58
+ resumabilityConfig?: ResumabilityConfig;
48
59
  }
49
60
  /**
50
61
  * A unique symbol to identify ADK agent classes.
@@ -91,6 +102,7 @@ export declare class Runner {
91
102
  readonly sessionService: BaseSessionService;
92
103
  readonly memoryService?: BaseMemoryService;
93
104
  readonly credentialService?: BaseCredentialService;
105
+ readonly resumabilityConfig?: ResumabilityConfig;
94
106
  /**
95
107
  * Creates a new Runner instance.
96
108
  *
@@ -135,7 +147,7 @@ export declare class Runner {
135
147
  }): AsyncGenerator<Event, void, undefined>;
136
148
  /**
137
149
  * Saves artifacts from the message parts and replaces the inline data with
138
- * a file name placeholder.
150
+ * a file name placeholder and optional file reference.
139
151
  *
140
152
  * @param invocationId The current invocation ID.
141
153
  * @param userId The user ID of the session.
@@ -147,18 +159,40 @@ export declare class Runner {
147
159
  * Determines the next agent to run to continue the session. This is primarily
148
160
  * used for session resumption.
149
161
  */
162
+ /**
163
+ * Determines the next agent to run to continue the session. This is primarily
164
+ * used for session resumption across tool and LRO boundaries.
165
+ */
150
166
  private determineAgentForResumption;
151
167
  /**
152
168
  * Whether the agent to run can transfer to any other agent in the agent tree.
153
169
  *
154
- * An agent is transferable if:
155
- * - It is an instance of `LlmAgent`.
156
- * - All its ancestors are also transferable (i.e., they have
157
- * `disallowTransferToParent` set to false).
158
- *
159
170
  * @param agentToRun The agent to check for transferability.
160
171
  * @returns True if the agent can transfer, False otherwise.
161
172
  */
162
173
  private isRoutableLlmAgent;
163
174
  }
175
+ /**
176
+ * Determines the next agent to run to continue the session. This is primarily
177
+ * used for session resumption across tool and LRO boundaries.
178
+ */
179
+ export declare function determineAgentForResumption(session: Session, rootAgent: BaseAgent, resumabilityConfig?: ResumabilityConfig): BaseAgent;
180
+ /**
181
+ * Whether the agent to run can transfer to any other agent in the agent tree.
182
+ *
183
+ * An agent is transferable if:
184
+ * - It is an instance of `LlmAgent`.
185
+ * - All its ancestors are also transferable (i.e., they have
186
+ * `disallowTransferToParent` set to false).
187
+ *
188
+ * @param agentToRun The agent to check for transferability.
189
+ * @returns True if the agent can transfer, False otherwise.
190
+ */
191
+ export declare function isRoutableLlmAgent(agentToRun: BaseAgent): boolean;
192
+ /**
193
+ * It iterates through the events in reverse order, and returns the event
194
+ * containing a function call with a functionCall.id matching the
195
+ * functionResponse.id from the last event in the session.
196
+ */
197
+ export declare function findEventByLastFunctionResponseId(events: Event[]): Event | null;
164
198
  export {};
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { Event } from '../events/event.js';
7
- import { Session } from './session.js';
7
+ import { CompositeSessionKey, Session } from './session.js';
8
8
  /**
9
9
  * The configuration of getting a session.
10
10
  */
@@ -30,13 +30,7 @@ export interface CreateSessionRequest {
30
30
  /**
31
31
  * The parameters for `getSession`.
32
32
  */
33
- export interface GetSessionRequest {
34
- /** The name of the application. */
35
- appName: string;
36
- /** The ID of the user. */
37
- userId: string;
38
- /** The ID of the session. */
39
- sessionId: string;
33
+ export interface GetSessionRequest extends CompositeSessionKey {
40
34
  /** The configurations for getting the session. */
41
35
  config?: GetSessionConfig;
42
36
  }
@@ -60,14 +54,7 @@ export interface ListSessionsRequest {
60
54
  /**
61
55
  * The parameters for `deleteSession`.
62
56
  */
63
- export interface DeleteSessionRequest {
64
- /** The name of the application. */
65
- appName: string;
66
- /** The ID of the user. */
67
- userId: string;
68
- /** The ID of the session. */
69
- sessionId: string;
70
- }
57
+ export type DeleteSessionRequest = CompositeSessionKey;
71
58
  /**
72
59
  * The parameters for `appendEvent`.
73
60
  */
@@ -4,6 +4,17 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { Event } from '../events/event.js';
7
+ /**
8
+ * Represents a unified composite session key grouping application, user, and session identifiers.
9
+ */
10
+ export interface CompositeSessionKey {
11
+ /** The name of the application. */
12
+ appName: string;
13
+ /** The ID of the user. */
14
+ userId: string;
15
+ /** The ID of the session. */
16
+ sessionId: string;
17
+ }
7
18
  /**
8
19
  * Represents a session in a conversation between agents and users.
9
20
  */
@@ -11,6 +11,14 @@ import { Session } from './session.js';
11
11
  * Checks if the given URI is a Vertex AI session service URI.
12
12
  */
13
13
  export declare function isVertexAiConnectionString(uri?: string): boolean;
14
+ /**
15
+ * Quotes a value for safe use as a Google AIP-160 filter string literal.
16
+ *
17
+ * Backslashes are escaped first, then double quotes, so that caller-controlled
18
+ * input stays inside the quoted value and cannot break out to inject additional
19
+ * filter predicates. See https://google.aip.dev/160.
20
+ */
21
+ export declare function quoteFilterLiteral(value: string): string;
14
22
  export interface VertexAiSessionServiceOptions {
15
23
  projectId?: string;
16
24
  location?: string;
@@ -32,6 +40,6 @@ export declare class VertexAiSessionService extends BaseSessionService {
32
40
  createSession({ appName, userId, state, sessionId, }: CreateSessionRequest): Promise<Session>;
33
41
  getSession({ appName, userId, sessionId, config, }: GetSessionRequest): Promise<Session | undefined>;
34
42
  listSessions({ appName, userId, limit, offset, page, order, }: ListSessionsRequest): Promise<ListSessionsResponse>;
35
- deleteSession({ appName, userId: _userId, sessionId, }: DeleteSessionRequest): Promise<void>;
43
+ deleteSession({ appName, userId, sessionId, }: DeleteSessionRequest): Promise<void>;
36
44
  appendEvent({ session, event, }: AppendEventRequest): Promise<Event>;
37
45
  }
@@ -0,0 +1,19 @@
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
+ /**
9
+ * Tool for requesting context consolidation (compaction).
10
+ *
11
+ * When called by an LLM agent, this tool sets the state flags
12
+ * `temp:consolidate_context` and optionally `temp:consolidate_context_detail`,
13
+ * signalling the context compactor to trigger compaction.
14
+ */
15
+ export declare class ConsolidateContextTool extends BaseTool {
16
+ constructor();
17
+ _getDeclaration(): FunctionDeclaration;
18
+ runAsync({ args, toolContext, }: RunAsyncToolRequest): Promise<unknown>;
19
+ }
@@ -0,0 +1,26 @@
1
+ import { LlmRequest } from '../models/llm_request.js';
2
+ import { BaseTool, ToolProcessLlmRequest } from './base_tool.js';
3
+ /**
4
+ * Appends the Enterprise Web Search built-in tool to the LLM request when the
5
+ * target model supports it.
6
+ *
7
+ * NOTE: This is NOT Vertex AI Search (formerly "Enterprise Search"). See
8
+ * https://cloud.google.com/vertex-ai/generative-ai/docs/grounding/web-grounding-enterprise
9
+ */
10
+ export declare function applyEnterpriseWebSearch(llmRequest: LlmRequest): void;
11
+ /**
12
+ * A Gemini 2+ built-in tool that grounds responses on public web data via
13
+ * Vertex AI Search with Enterprise (Sec4) compliance.
14
+ *
15
+ * This tool operates internally within the model and does not require or
16
+ * perform local code execution.
17
+ */
18
+ export declare class EnterpriseWebSearchTool extends BaseTool {
19
+ constructor();
20
+ runAsync(): Promise<unknown>;
21
+ processLlmRequest({ llmRequest, }: ToolProcessLlmRequest): Promise<void>;
22
+ }
23
+ /**
24
+ * A global instance of {@link EnterpriseWebSearchTool}.
25
+ */
26
+ export declare const ENTERPRISE_WEB_SEARCH: EnterpriseWebSearchTool;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { BaseExampleProvider } from '../examples/base_example_provider.js';
7
+ import { Example } from '../examples/example.js';
8
+ import { BaseTool, RunAsyncToolRequest, ToolProcessLlmRequest } from './base_tool.js';
9
+ /**
10
+ * A tool that adds (few-shot) examples to the LLM request.
11
+ *
12
+ * This tool is executed for each LLM request and is never called by the model;
13
+ * it only mutates the outgoing request by appending few-shot instructions built
14
+ * from the latest user query.
15
+ */
16
+ export declare class ExampleTool extends BaseTool {
17
+ readonly examples: Example[] | BaseExampleProvider;
18
+ constructor(examples: Example[] | BaseExampleProvider);
19
+ runAsync(_request: RunAsyncToolRequest): Promise<unknown>;
20
+ processLlmRequest({ toolContext, llmRequest, }: ToolProcessLlmRequest): Promise<void>;
21
+ }
@@ -4,7 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { Part } from '@google/genai';
7
- import { ArtifactVersion, BaseArtifactService, DeleteArtifactRequest, ListVersionsRequest, LoadArtifactRequest, SaveArtifactRequest } from '../artifacts/base_artifact_service.js';
7
+ import { ArtifactVersion, BaseArtifactService, DeleteArtifactRequest, ListArtifactKeysRequest, ListVersionsRequest, LoadArtifactRequest, SaveArtifactRequest } from '../artifacts/base_artifact_service.js';
8
8
  import { Context } from '../agents/context.js';
9
9
  /**
10
10
  * Artifact service that forwards to the parent tool context.
@@ -15,7 +15,8 @@ export declare class ForwardingArtifactService implements BaseArtifactService {
15
15
  constructor(toolContext: Context);
16
16
  saveArtifact(request: SaveArtifactRequest): Promise<number>;
17
17
  loadArtifact(request: LoadArtifactRequest): Promise<Part | undefined>;
18
- listArtifactKeys(): Promise<string[]>;
18
+ listArtifactKeys(_request: ListArtifactKeysRequest): Promise<string[]>;
19
+ private getArtifactService;
19
20
  deleteArtifact(request: DeleteArtifactRequest): Promise<void>;
20
21
  listVersions(request: ListVersionsRequest): Promise<number[]>;
21
22
  listArtifactVersions(request: ListVersionsRequest): Promise<ArtifactVersion[]>;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { z } from 'zod';
7
+ import { FunctionTool } from './function_tool.js';
8
+ /** Options for {@link loadWebPage}. */
9
+ export interface LoadWebPageOptions {
10
+ /** Request timeout in milliseconds. Defaults to 30_000 (30s). */
11
+ timeoutMs?: number;
12
+ }
13
+ /**
14
+ * Fetches the content at `url` and returns its extracted, readable text.
15
+ *
16
+ * Hardened against SSRF: only `http`/`https` URLs are fetched, the host is
17
+ * resolved and rejected up front if it is `localhost`-style or resolves to a
18
+ * private / loopback / link-local / shared / reserved / multicast address, and
19
+ * redirects are never followed. Never throws for expected failures (bad scheme,
20
+ * blocked host, non-200, timeout, network error); returns
21
+ * `Failed to fetch url: <url>` instead.
22
+ *
23
+ * Known limitation: global `fetch` performs its own DNS resolution at connect
24
+ * time, so a residual time-of-check/time-of-use (DNS-rebinding) window exists
25
+ * between this pre-flight lookup and fetch's own lookup. Full connection
26
+ * IP-pinning (e.g. an `undici` Agent with a custom `lookup`) is a possible
27
+ * future hardening.
28
+ */
29
+ export declare function loadWebPage(url: string, options?: LoadWebPageOptions): Promise<string>;
30
+ /** A global {@link FunctionTool} exposing {@link loadWebPage} to the model. */
31
+ export declare const LOAD_WEB_PAGE: FunctionTool<z.ZodObject<{
32
+ url: z.ZodString;
33
+ }, z.core.$strip>>;
@@ -0,0 +1,26 @@
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, ToolProcessLlmRequest } from '../base_tool.js';
8
+ import { MCPToolset } from './mcp_toolset.js';
9
+ /**
10
+ * A tool that loads MCP server resources and adds them to the session.
11
+ *
12
+ * This mirrors the in-repo `LoadArtifactsTool` idiom: the model calls
13
+ * `load_mcp_resource` with the names of the resources it wants, and on the next
14
+ * turn {@link processLlmRequest} reads those resources over the MCP session and
15
+ * appends their contents (text and base64-encoded binary) to the request
16
+ * context.
17
+ */
18
+ export declare class LoadMcpResourceTool extends BaseTool {
19
+ private readonly mcpToolset;
20
+ constructor(mcpToolset: MCPToolset);
21
+ _getDeclaration(): FunctionDeclaration;
22
+ runAsync({ args }: RunAsyncToolRequest): Promise<unknown>;
23
+ processLlmRequest(request: ToolProcessLlmRequest): Promise<void>;
24
+ private appendResourcesToLlmRequest;
25
+ private mcpContentToPart;
26
+ }
@@ -3,6 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { BlobResourceContents, Resource, TextResourceContents } from '@modelcontextprotocol/sdk/types.js';
6
7
  import { ReadonlyContext } from '../../agents/readonly_context.js';
7
8
  import { BaseTool } from '../base_tool.js';
8
9
  import { BaseToolset, ToolPredicate } from '../base_toolset.js';
@@ -40,5 +41,31 @@ export declare class MCPToolset extends BaseToolset {
40
41
  private readonly mcpSessionManager;
41
42
  constructor(connectionParams: MCPConnectionParams, toolFilter?: ToolPredicate | string[], prefix?: string);
42
43
  getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
44
+ /**
45
+ * Lists the names of the resources advertised by the MCP server.
46
+ *
47
+ * @return The resource names available on the server.
48
+ */
49
+ listResources(): Promise<string[]>;
50
+ /**
51
+ * Returns metadata for the resource whose name matches `name`.
52
+ *
53
+ * @param name The advertised name of the resource.
54
+ * @return The matching MCP `Resource`.
55
+ * @throws If no resource with the given name is advertised by the server.
56
+ */
57
+ getResourceInfo(name: string): Promise<Resource>;
58
+ /**
59
+ * Reads the contents of the named resource from the MCP server.
60
+ *
61
+ * The resource name is resolved to a URI via {@link getResourceInfo} before
62
+ * reading. Binary contents are returned base64-encoded, exactly as provided
63
+ * by the server (never decoded and re-encoded).
64
+ *
65
+ * @param name The advertised name of the resource to read.
66
+ * @return The resource contents (text and/or base64-encoded binary).
67
+ * @throws If the resource is unknown or has no URI.
68
+ */
69
+ readResource(name: string): Promise<Array<TextResourceContents | BlobResourceContents>>;
43
70
  close(): Promise<void>;
44
71
  }
@@ -6,9 +6,34 @@
6
6
  import { FunctionDeclaration } from '@google/genai';
7
7
  import { BaseTool, RunAsyncToolRequest } from '../base_tool.js';
8
8
  import { SkillToolset } from './skill_toolset.js';
9
+ /**
10
+ * Error codes returned by {@link RunSkillInlineScriptTool} when a call cannot
11
+ * be completed. The string values are part of the tool's response contract and
12
+ * must remain stable.
13
+ */
14
+ export declare enum RunSkillInlineScriptErrorCode {
15
+ MISSING_SCRIPT_CONTENT = "MISSING_SCRIPT_CONTENT",
16
+ MISSING_LANGUAGE = "MISSING_LANGUAGE",
17
+ NO_CODE_EXECUTOR = "NO_CODE_EXECUTOR",
18
+ EXECUTION_ERROR = "EXECUTION_ERROR",
19
+ CONFIRMATION_REJECTED = "CONFIRMATION_REJECTED"
20
+ }
9
21
  export declare class RunSkillInlineScriptTool extends BaseTool {
10
22
  private toolset;
11
23
  constructor(toolset: SkillToolset);
12
24
  _getDeclaration(): FunctionDeclaration;
13
25
  runAsync({ args, toolContext, }: RunAsyncToolRequest): Promise<unknown>;
26
+ /**
27
+ * Enforces a human-in-the-loop confirmation gate before executing an inline
28
+ * script, using the repo's standard tool-confirmation mechanism.
29
+ *
30
+ * - When no confirmation has been provided yet, a confirmation is requested
31
+ * (surfacing the language and script that would run) and an intermediate
32
+ * result is returned so the tool call pauses until the client responds.
33
+ * - When a confirmation exists but was not confirmed, a rejection error is
34
+ * returned and execution is refused.
35
+ * - When the confirmation is confirmed, `undefined` is returned to allow the
36
+ * caller to proceed with execution.
37
+ */
38
+ private enforceConfirmation;
14
39
  }
@@ -23,6 +23,15 @@ export declare class SkillToolset extends BaseToolset {
23
23
  codeExecutor?: BaseCodeExecutor;
24
24
  additionalTools?: Array<BaseTool | BaseToolset>;
25
25
  registry?: SkillRegistry;
26
+ /**
27
+ * Whether to expose the `run_skill_inline_script` tool, which executes
28
+ * model-provided script content in the configured code executor. This is
29
+ * disabled by default because arbitrary inline-script execution is a
30
+ * sensitive capability; opt in explicitly by setting this to `true`.
31
+ * Execution additionally remains gated behind a human-in-the-loop
32
+ * confirmation.
33
+ */
34
+ allowInlineScripts?: boolean;
26
35
  });
27
36
  getTools(context?: ReadonlyContext): Promise<BaseTool[]>;
28
37
  close(): Promise<void>;
@@ -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,14 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Checks whether targetBranch is equal to or an ancestor of currentBranch
8
+ * by verifying segment-by-segment matching without substring false positives.
9
+ *
10
+ * @param currentBranch The branch being evaluated.
11
+ * @param targetBranch The candidate prefix or ancestor branch.
12
+ * @returns true if targetBranch equals currentBranch or is an ancestor of currentBranch.
13
+ */
14
+ export declare function isSegmentPrefix(currentBranch: string, targetBranch: string): boolean;
@@ -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,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.3.0";
6
+ export declare const version = "1.5.0";