@google/adk 1.4.0 → 1.6.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 (213) hide show
  1. package/dist/cjs/a2a/a2a_remote_agent.js +12 -2
  2. package/dist/cjs/a2a/agent_to_a2a.js +18 -3
  3. package/dist/cjs/a2a/auth.js +65 -0
  4. package/dist/cjs/a2a/event_converter_utils.js +47 -18
  5. package/dist/cjs/a2a/metadata_converter_utils.js +1 -1
  6. package/dist/cjs/agents/base_agent.js +39 -0
  7. package/dist/cjs/agents/functions.js +26 -28
  8. package/dist/cjs/agents/llm_agent.js +4 -2
  9. package/dist/cjs/agents/loop_agent.js +15 -3
  10. package/dist/cjs/agents/processors/basic_llm_request_processor.js +3 -2
  11. package/dist/cjs/agents/processors/content_processor_utils.js +2 -1
  12. package/dist/cjs/agents/processors/content_request_processor.js +2 -21
  13. package/dist/cjs/agents/processors/instructions_llm_request_processor.js +3 -1
  14. package/dist/cjs/agents/routed_agent.js +31 -0
  15. package/dist/cjs/agents/run_config.js +3 -2
  16. package/dist/cjs/artifacts/in_memory_artifact_service.js +17 -9
  17. package/dist/cjs/auth/credential_service/in_memory_credential_service.js +14 -3
  18. package/dist/cjs/code_executors/unsafe_local_code_executor.js +23 -12
  19. package/dist/cjs/common.js +35 -0
  20. package/dist/cjs/context/agent_controlled_context_compactor.js +2 -11
  21. package/dist/cjs/context/anchored_context_compactor.js +127 -0
  22. package/dist/cjs/context/compaction_utils.js +64 -0
  23. package/dist/cjs/context/token_based_context_compactor.js +13 -44
  24. package/dist/cjs/events/compacted_event.js +9 -3
  25. package/dist/cjs/events/event.js +28 -0
  26. package/dist/cjs/index.js +7 -0
  27. package/dist/cjs/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
  28. package/dist/cjs/memory/in_memory_memory_service.js +13 -2
  29. package/dist/cjs/memory/vertex_ai_memory_bank_service.js +3 -0
  30. package/dist/cjs/plugins/base_plugin.js +4 -2
  31. package/dist/cjs/plugins/global_instruction_plugin.js +97 -0
  32. package/dist/cjs/runner/runner.js +69 -23
  33. package/dist/cjs/sessions/base_session_service.js +8 -3
  34. package/dist/cjs/sessions/in_memory_session_service.js +8 -8
  35. package/dist/cjs/sessions/vertex_ai_session_service.js +22 -10
  36. package/dist/cjs/skills/loader.js +40 -6
  37. package/dist/cjs/tools/enterprise_web_search_tool.js +81 -0
  38. package/dist/cjs/tools/example_tool.js +68 -0
  39. package/dist/cjs/tools/get_user_choice_tool.js +53 -0
  40. package/dist/cjs/tools/load_web_page.js +250 -0
  41. package/dist/cjs/tools/mcp/load_mcp_resource_tool.js +140 -0
  42. package/dist/cjs/tools/mcp/mcp_session_manager.js +35 -21
  43. package/dist/cjs/tools/mcp/mcp_toolset.js +63 -0
  44. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +13 -10
  45. package/dist/cjs/tools/request_input_tool.js +54 -0
  46. package/dist/cjs/tools/skill/run_skill_inline_script_tool.js +54 -4
  47. package/dist/cjs/tools/skill/skill_toolset.js +4 -2
  48. package/dist/cjs/utils/branch_trie.js +41 -0
  49. package/dist/cjs/utils/crypto_shim.js +43 -0
  50. package/dist/cjs/utils/env_aware_utils.js +15 -13
  51. package/dist/cjs/utils/error_utils.js +120 -0
  52. package/dist/cjs/utils/file_utils.js +5 -2
  53. package/dist/cjs/utils/output_schema_utils.js +43 -0
  54. package/dist/cjs/utils/streaming_utils.js +5 -5
  55. package/dist/cjs/utils/vertex_ai_utils.js +3 -0
  56. package/dist/cjs/version.js +1 -1
  57. package/dist/esm/a2a/a2a_remote_agent.js +12 -2
  58. package/dist/esm/a2a/agent_to_a2a.js +18 -3
  59. package/dist/esm/a2a/auth.js +37 -0
  60. package/dist/esm/a2a/event_converter_utils.js +47 -18
  61. package/dist/esm/a2a/metadata_converter_utils.js +1 -1
  62. package/dist/esm/agents/base_agent.js +39 -0
  63. package/dist/esm/agents/functions.js +27 -24
  64. package/dist/esm/agents/llm_agent.js +6 -4
  65. package/dist/esm/agents/loop_agent.js +15 -3
  66. package/dist/esm/agents/processors/basic_llm_request_processor.js +3 -2
  67. package/dist/esm/agents/processors/content_processor_utils.js +2 -1
  68. package/dist/esm/agents/processors/content_request_processor.js +2 -21
  69. package/dist/esm/agents/processors/instructions_llm_request_processor.js +3 -1
  70. package/dist/esm/agents/routed_agent.js +31 -0
  71. package/dist/esm/agents/run_config.js +3 -2
  72. package/dist/esm/artifacts/in_memory_artifact_service.js +17 -9
  73. package/dist/esm/auth/credential_service/in_memory_credential_service.js +14 -3
  74. package/dist/esm/code_executors/unsafe_local_code_executor.js +22 -11
  75. package/dist/esm/common.js +29 -1
  76. package/dist/esm/context/agent_controlled_context_compactor.js +2 -11
  77. package/dist/esm/context/anchored_context_compactor.js +99 -0
  78. package/dist/esm/context/compaction_utils.js +38 -0
  79. package/dist/esm/context/token_based_context_compactor.js +16 -44
  80. package/dist/esm/events/compacted_event.js +7 -2
  81. package/dist/esm/events/event.js +24 -0
  82. package/dist/esm/index.js +8 -1
  83. package/dist/esm/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
  84. package/dist/esm/memory/in_memory_memory_service.js +13 -2
  85. package/dist/esm/memory/vertex_ai_memory_bank_service.js +7 -1
  86. package/dist/esm/plugins/base_plugin.js +4 -2
  87. package/dist/esm/plugins/global_instruction_plugin.js +69 -0
  88. package/dist/esm/runner/runner.js +69 -23
  89. package/dist/esm/sessions/base_session_service.js +8 -3
  90. package/dist/esm/sessions/in_memory_session_service.js +8 -8
  91. package/dist/esm/sessions/vertex_ai_session_service.js +26 -11
  92. package/dist/esm/skills/loader.js +40 -6
  93. package/dist/esm/tools/enterprise_web_search_tool.js +55 -0
  94. package/dist/esm/tools/example_tool.js +42 -0
  95. package/dist/esm/tools/get_user_choice_tool.js +25 -0
  96. package/dist/esm/tools/load_web_page.js +221 -0
  97. package/dist/esm/tools/mcp/load_mcp_resource_tool.js +114 -0
  98. package/dist/esm/tools/mcp/mcp_session_manager.js +35 -21
  99. package/dist/esm/tools/mcp/mcp_toolset.js +63 -0
  100. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +13 -10
  101. package/dist/esm/tools/request_input_tool.js +26 -0
  102. package/dist/esm/tools/skill/run_skill_inline_script_tool.js +53 -4
  103. package/dist/esm/tools/skill/skill_toolset.js +4 -2
  104. package/dist/esm/utils/branch_trie.js +13 -0
  105. package/dist/esm/utils/crypto_shim.js +15 -0
  106. package/dist/esm/utils/env_aware_utils.js +15 -13
  107. package/dist/esm/utils/error_utils.js +92 -0
  108. package/dist/esm/utils/file_utils.js +5 -2
  109. package/dist/esm/utils/output_schema_utils.js +15 -0
  110. package/dist/esm/utils/streaming_utils.js +1 -1
  111. package/dist/esm/utils/vertex_ai_utils.js +2 -0
  112. package/dist/esm/version.js +1 -1
  113. package/dist/types/a2a/a2a_remote_agent.d.ts +5 -1
  114. package/dist/types/a2a/agent_to_a2a.d.ts +38 -0
  115. package/dist/types/a2a/auth.d.ts +30 -0
  116. package/dist/types/a2a/event_converter_utils.d.ts +4 -1
  117. package/dist/types/agents/base_agent.d.ts +29 -1
  118. package/dist/types/agents/functions.d.ts +1 -9
  119. package/dist/types/agents/llm_agent.d.ts +5 -1
  120. package/dist/types/agents/loop_agent.d.ts +2 -2
  121. package/dist/types/agents/routed_agent.d.ts +24 -1
  122. package/dist/types/agents/run_config.d.ts +1 -1
  123. package/dist/types/auth/credential_service/in_memory_credential_service.d.ts +11 -0
  124. package/dist/types/code_executors/unsafe_local_code_executor.d.ts +5 -1
  125. package/dist/types/common.d.ts +11 -2
  126. package/dist/types/context/agent_controlled_context_compactor.d.ts +0 -1
  127. package/dist/types/context/anchored_context_compactor.d.ts +35 -0
  128. package/dist/types/context/compaction_utils.d.ts +23 -0
  129. package/dist/types/context/token_based_context_compactor.d.ts +0 -1
  130. package/dist/types/events/compacted_event.d.ts +10 -0
  131. package/dist/types/events/event.d.ts +13 -0
  132. package/dist/types/index.d.ts +5 -3
  133. package/dist/types/memory/in_memory_memory_service.d.ts +11 -0
  134. package/dist/types/plugins/base_plugin.d.ts +4 -2
  135. package/dist/types/plugins/global_instruction_plugin.d.ts +38 -0
  136. package/dist/types/runner/runner.d.ts +1 -1
  137. package/dist/types/sessions/base_session_service.d.ts +8 -0
  138. package/dist/types/sessions/in_memory_session_service.d.ts +9 -0
  139. package/dist/types/sessions/vertex_ai_session_service.d.ts +19 -1
  140. package/dist/types/skills/loader.d.ts +5 -0
  141. package/dist/types/tools/enterprise_web_search_tool.d.ts +26 -0
  142. package/dist/types/tools/example_tool.d.ts +21 -0
  143. package/dist/types/tools/get_user_choice_tool.d.ts +14 -0
  144. package/dist/types/tools/load_web_page.d.ts +33 -0
  145. package/dist/types/tools/mcp/load_mcp_resource_tool.d.ts +26 -0
  146. package/dist/types/tools/mcp/mcp_toolset.d.ts +27 -0
  147. package/dist/types/tools/request_input_tool.d.ts +15 -0
  148. package/dist/types/tools/skill/run_skill_inline_script_tool.d.ts +25 -0
  149. package/dist/types/tools/skill/skill_toolset.d.ts +9 -0
  150. package/dist/types/utils/branch_trie.d.ts +14 -0
  151. package/dist/types/utils/crypto_shim.d.ts +16 -0
  152. package/dist/types/utils/env_aware_utils.d.ts +23 -0
  153. package/dist/types/utils/error_utils.d.ts +18 -0
  154. package/dist/types/utils/output_schema_utils.d.ts +18 -0
  155. package/dist/types/utils/vertex_ai_utils.d.ts +1 -0
  156. package/dist/types/version.d.ts +1 -1
  157. package/dist/web/a2a/a2a_remote_agent.js +12 -2
  158. package/dist/web/a2a/agent_to_a2a.js +18 -3
  159. package/dist/web/a2a/auth.js +37 -0
  160. package/dist/web/a2a/event_converter_utils.js +47 -18
  161. package/dist/web/a2a/metadata_converter_utils.js +1 -1
  162. package/dist/web/agents/base_agent.js +39 -0
  163. package/dist/web/agents/functions.js +27 -24
  164. package/dist/web/agents/llm_agent.js +6 -4
  165. package/dist/web/agents/loop_agent.js +27 -3
  166. package/dist/web/agents/processors/basic_llm_request_processor.js +3 -2
  167. package/dist/web/agents/processors/content_processor_utils.js +2 -1
  168. package/dist/web/agents/processors/content_request_processor.js +2 -21
  169. package/dist/web/agents/processors/instructions_llm_request_processor.js +3 -1
  170. package/dist/web/agents/routed_agent.js +31 -0
  171. package/dist/web/agents/run_config.js +8 -3
  172. package/dist/web/artifacts/in_memory_artifact_service.js +17 -9
  173. package/dist/web/auth/credential_service/in_memory_credential_service.js +14 -3
  174. package/dist/web/code_executors/unsafe_local_code_executor.js +22 -11
  175. package/dist/web/common.js +29 -1
  176. package/dist/web/context/agent_controlled_context_compactor.js +2 -11
  177. package/dist/web/context/anchored_context_compactor.js +117 -0
  178. package/dist/web/context/compaction_utils.js +38 -0
  179. package/dist/web/context/token_based_context_compactor.js +16 -44
  180. package/dist/web/events/compacted_event.js +7 -2
  181. package/dist/web/events/event.js +24 -0
  182. package/dist/web/index.js +8 -1
  183. package/dist/web/integrations/agent_registry/agent_registry_mcp_toolset.js +9 -1
  184. package/dist/web/memory/in_memory_memory_service.js +13 -2
  185. package/dist/web/memory/vertex_ai_memory_bank_service.js +7 -1
  186. package/dist/web/plugins/base_plugin.js +4 -2
  187. package/dist/web/plugins/global_instruction_plugin.js +67 -0
  188. package/dist/web/runner/runner.js +65 -22
  189. package/dist/web/sessions/base_session_service.js +8 -3
  190. package/dist/web/sessions/in_memory_session_service.js +8 -8
  191. package/dist/web/sessions/vertex_ai_session_service.js +24 -11
  192. package/dist/web/skills/loader.js +40 -6
  193. package/dist/web/tools/enterprise_web_search_tool.js +55 -0
  194. package/dist/web/tools/example_tool.js +42 -0
  195. package/dist/web/tools/get_user_choice_tool.js +25 -0
  196. package/dist/web/tools/load_web_page.js +221 -0
  197. package/dist/web/tools/mcp/load_mcp_resource_tool.js +107 -0
  198. package/dist/web/tools/mcp/mcp_session_manager.js +35 -21
  199. package/dist/web/tools/mcp/mcp_toolset.js +63 -0
  200. package/dist/web/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +13 -10
  201. package/dist/web/tools/request_input_tool.js +26 -0
  202. package/dist/web/tools/skill/run_skill_inline_script_tool.js +51 -4
  203. package/dist/web/tools/skill/skill_toolset.js +4 -2
  204. package/dist/web/utils/branch_trie.js +13 -0
  205. package/dist/web/utils/crypto_shim.js +15 -0
  206. package/dist/web/utils/env_aware_utils.js +15 -13
  207. package/dist/web/utils/error_utils.js +92 -0
  208. package/dist/web/utils/file_utils.js +5 -2
  209. package/dist/web/utils/output_schema_utils.js +15 -0
  210. package/dist/web/utils/streaming_utils.js +1 -1
  211. package/dist/web/utils/vertex_ai_utils.js +2 -0
  212. package/dist/web/version.js +1 -1
  213. package/package.json +1 -1
@@ -68,8 +68,12 @@ export interface RemoteA2AAgentConfig extends BaseAgentConfig {
68
68
  }
69
69
  /**
70
70
  * RemoteA2AAgent delegates execution to a remote agent using the A2A protocol.
71
+ *
72
+ * @remarks
73
+ * A cloned `RemoteA2AAgent` (via {@link BaseAgent.clone}) is a fresh,
74
+ * uninitialized instance that re-resolves its client and card on first use.
71
75
  */
72
- export declare class RemoteA2AAgent extends BaseAgent {
76
+ export declare class RemoteA2AAgent extends BaseAgent<RemoteA2AAgentConfig> {
73
77
  private readonly a2aConfig;
74
78
  private client?;
75
79
  private card?;
@@ -4,12 +4,25 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { AgentCard } from '@a2a-js/sdk';
7
+ import { UserBuilder } from '@a2a-js/sdk/server/express';
7
8
  import express from 'express';
8
9
  import { BaseAgent } from '../agents/base_agent.js';
9
10
  import { BaseArtifactService } from '../artifacts/base_artifact_service.js';
10
11
  import { BaseMemoryService } from '../memory/base_memory_service.js';
11
12
  import { Runner } from '../runner/runner.js';
12
13
  import { BaseSessionService } from '../sessions/base_session_service.js';
14
+ /**
15
+ * A request authenticator for the A2A surface.
16
+ *
17
+ * This is the `UserBuilder` hook from `@a2a-js/sdk`: an async function that
18
+ * receives the incoming Express request, validates its credentials (for
19
+ * example a bearer token or an OIDC ID token) and resolves to the
20
+ * authenticated `User`. Implementations should reject unauthenticated
21
+ * requests by throwing (or by resolving to a user whose `isAuthenticated` is
22
+ * `false`), which prevents the underlying agent and its tools from being
23
+ * invoked by anonymous callers.
24
+ */
25
+ export type A2aUserBuilder = UserBuilder;
13
26
  /**
14
27
  * Options for the `toA2a` function.
15
28
  */
@@ -34,6 +47,31 @@ export interface ToA2aOptions {
34
47
  artifactService?: BaseArtifactService;
35
48
  /** Optional existing express application */
36
49
  app?: express.Application;
50
+ /**
51
+ * Authenticator used to validate incoming A2A requests.
52
+ *
53
+ * A2A is the production-intended inter-agent surface: any network-reachable
54
+ * caller that can reach it can invoke the agent and its tools with arbitrary
55
+ * input and read the output. Provide a `UserBuilder` (from
56
+ * `@a2a-js/sdk/server/express`) that validates the request's credentials —
57
+ * for example a bearer token or an OIDC ID token — and it will be wired into
58
+ * both the REST and JSON-RPC handlers.
59
+ *
60
+ * When omitted, `toA2a` fails closed and throws unless
61
+ * {@link ToA2aOptions.allowUnauthenticated} is explicitly set to `true`.
62
+ */
63
+ authentication?: A2aUserBuilder;
64
+ /**
65
+ * Explicit escape hatch to mount the A2A surface WITHOUT authentication.
66
+ *
67
+ * This is intentionally insecure and must only be used for local, trusted
68
+ * development where the surface is not network reachable. When set to
69
+ * `true` (and no {@link ToA2aOptions.authentication} is provided), a loud
70
+ * warning is logged and the handlers are mounted with no authentication.
71
+ *
72
+ * Defaults to `false`, which makes `toA2a` fail closed.
73
+ */
74
+ allowUnauthenticated?: boolean;
37
75
  }
38
76
  /**
39
77
  * Converts an ADK agent to an Express application with A2A handlers.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { A2aUserBuilder } from './agent_to_a2a.js';
7
+ /**
8
+ * Builds an {@link A2aUserBuilder} that authenticates A2A requests against a
9
+ * shared bearer token.
10
+ *
11
+ * Callers must send `Authorization: Bearer <token>`; the credential is
12
+ * compared against `token` in constant time, and a request with a missing,
13
+ * malformed or incorrect one is rejected before the agent or any of its tools
14
+ * is invoked. Serve the surface over HTTPS, or the secret travels in clear
15
+ * text on every call.
16
+ *
17
+ * ```ts
18
+ * toA2a(agent, {authentication: bearerTokenUserBuilder(process.env.MY_TOKEN)});
19
+ * ```
20
+ *
21
+ * A rejected request surfaces as whatever the `@a2a-js/sdk` handler produces
22
+ * for a failing `UserBuilder`, which is an HTTP 500 rather than a 401. The
23
+ * guarantee here is that the agent is never reached, not that the caller gets
24
+ * a particular status code.
25
+ *
26
+ * @param token The shared secret callers must present; surrounding whitespace
27
+ * is trimmed, because HTTP strips it from header values anyway.
28
+ * @throws If `token` is empty or contains only whitespace.
29
+ */
30
+ export declare function bearerTokenUserBuilder(token: string): A2aUserBuilder;
@@ -27,7 +27,10 @@ export declare function toA2AMessage(event: AdkEvent, { appName, userId, session
27
27
  * status update).
28
28
  * @param invocationId - The ADK invocation ID to attach to the resulting event.
29
29
  * @param agentName - The name of the agent to use as the event author.
30
+ * @param branch - The local invocation's branch to attach to the resulting
31
+ * event. Must come from the caller's own `InvocationContext`, never from
32
+ * the A2A peer: see the comment on `createAdkEventFromMetadata` for why.
30
33
  * @returns The converted ADK event, or `undefined` if the A2A event type
31
34
  * produces no content.
32
35
  */
33
- export declare function toAdkEvent(event: A2AEvent, invocationId: string, agentName: string): AdkEvent | undefined;
36
+ export declare function toAdkEvent(event: A2AEvent, invocationId: string, agentName: string, branch?: string): AdkEvent | undefined;
@@ -45,12 +45,25 @@ declare const BASE_AGENT_SIGNATURE_SYMBOL: unique symbol;
45
45
  export declare function isBaseAgent(obj: unknown): obj is BaseAgent;
46
46
  /**
47
47
  * Base class for all agents in Agent Development Kit.
48
+ *
49
+ * The class is generic over its config type so that {@link clone} can be typed
50
+ * per subclass (e.g. `LlmAgent.clone({instruction})`). The default keeps bare
51
+ * `BaseAgent` references valid as `BaseAgent<BaseAgentConfig>`.
48
52
  */
49
- export declare abstract class BaseAgent {
53
+ export declare abstract class BaseAgent<TConfig extends BaseAgentConfig = BaseAgentConfig> {
50
54
  /**
51
55
  * A unique symbol to identify ADK agent classes.
52
56
  */
53
57
  readonly [BASE_AGENT_SIGNATURE_SYMBOL] = true;
58
+ /**
59
+ * The config this agent was constructed from.
60
+ *
61
+ * Stored so {@link clone} can rebuild the agent by re-running the concrete
62
+ * constructor with overrides applied, which re-derives all state correctly
63
+ * instead of copying an already-mutated instance. Shallow-copied so later
64
+ * external mutation of the caller's object does not leak into clones.
65
+ */
66
+ protected readonly config: TConfig;
54
67
  /**
55
68
  * The agent's name.
56
69
  * Agent name must be a JS identifier and unique within the agent tree.
@@ -112,6 +125,21 @@ export declare abstract class BaseAgent {
112
125
  */
113
126
  readonly afterAgentCallback: SingleAgentCallback[];
114
127
  constructor(config: BaseAgentConfig);
128
+ /**
129
+ * Creates a copy of this agent with the given config fields overridden.
130
+ *
131
+ * Mirrors adk-python's `BaseAgent.clone(update=...)`. The clone is a detached
132
+ * root: its `parentAgent` is always `undefined`. Sub-agents are recursively
133
+ * cloned (and re-parented to the clone) unless `subAgents` is overridden.
134
+ * Rebuilding via the concrete constructor re-derives all state, so a cloned
135
+ * `LlmAgent` gets a fresh `requestProcessors` array rather than sharing the
136
+ * original's. See google/adk-js#534.
137
+ *
138
+ * @param overrides Config fields to override on the clone. Overriding
139
+ * `parentAgent` is rejected, matching adk-python.
140
+ * @returns A new detached agent instance of the same concrete class.
141
+ */
142
+ clone(overrides?: Partial<TConfig>): this;
115
143
  /**
116
144
  * Entry method to run an agent via text-based conversation.
117
145
  *
@@ -9,7 +9,7 @@ import { Event } from '../events/event.js';
9
9
  import { BaseTool } from '../tools/base_tool.js';
10
10
  import { ToolConfirmation } from '../tools/tool_confirmation.js';
11
11
  import { SingleAfterToolCallback, SingleBeforeToolCallback } from './llm_agent.js';
12
- export declare const AF_FUNCTION_CALL_ID_PREFIX = "adk-";
12
+ export { AF_FUNCTION_CALL_ID_PREFIX, generateClientFunctionCallId, populateClientFunctionCallId, } from '../events/event.js';
13
13
  export declare const REQUEST_EUC_FUNCTION_CALL_NAME = "adk_request_credential";
14
14
  export declare const REQUEST_CONFIRMATION_FUNCTION_CALL_NAME = "adk_request_confirmation";
15
15
  export declare const functionsExportedForTestingOnly: {
@@ -17,14 +17,6 @@ export declare const functionsExportedForTestingOnly: {
17
17
  generateAuthEvent: typeof generateAuthEvent;
18
18
  generateRequestConfirmationEvent: typeof generateRequestConfirmationEvent;
19
19
  };
20
- export declare function generateClientFunctionCallId(): string;
21
- /**
22
- * Populates client-side function call IDs.
23
- *
24
- * It iterates through all function calls in the event and assigns a
25
- * unique client-side ID to each one that doesn't already have an ID.
26
- */
27
- export declare function populateClientFunctionCallId(modelResponseEvent: Event): void;
28
20
  /**
29
21
  * Returns a set of function call ids of the long running tools.
30
22
  */
@@ -130,6 +130,8 @@ export interface LlmAgentConfig extends BaseAgentConfig {
130
130
  *
131
131
  * For example: use globalInstruction to make all agents have a stable
132
132
  * identity or personality.
133
+ *
134
+ * @deprecated Use GlobalInstructionPlugin instead.
133
135
  */
134
136
  globalInstruction?: string | InstructionProvider;
135
137
  /** Tools available to this agent. */
@@ -224,11 +226,12 @@ export declare function isLlmAgent(obj: unknown): obj is LlmAgent;
224
226
  /**
225
227
  * An agent that uses a large language model to generate responses.
226
228
  */
227
- export declare class LlmAgent extends BaseAgent {
229
+ export declare class LlmAgent extends BaseAgent<LlmAgentConfig> {
228
230
  /** A unique symbol to identify ADK LLM agent class. */
229
231
  readonly [LLM_AGENT_SIGNATURE_SYMBOL] = true;
230
232
  model?: string | BaseLlm;
231
233
  instruction: string | InstructionProvider;
234
+ /** @deprecated Use GlobalInstructionPlugin instead. */
232
235
  globalInstruction: string | InstructionProvider;
233
236
  tools: ToolUnion[];
234
237
  generateContentConfig?: GenerateContentConfig;
@@ -270,6 +273,7 @@ export declare class LlmAgent extends BaseAgent {
270
273
  * This method is only for use by Agent Development Kit.
271
274
  * @param context The context to retrieve the session state.
272
275
  * @returns The resolved globalInstruction field.
276
+ * @deprecated Use GlobalInstructionPlugin instead.
273
277
  */
274
278
  canonicalGlobalInstruction(context: ReadonlyContext): Promise<{
275
279
  instruction: string;
@@ -34,7 +34,7 @@ export declare function isLoopAgent(obj: unknown): obj is LoopAgent;
34
34
  * When sub-agent generates an event with escalate or max_iterations are
35
35
  * reached, the loop agent will stop.
36
36
  */
37
- export declare class LoopAgent extends BaseAgent {
37
+ export declare class LoopAgent extends BaseAgent<LoopAgentConfig> {
38
38
  /**
39
39
  * A unique symbol to identify ADK loop agent class.
40
40
  */
@@ -42,6 +42,6 @@ export declare class LoopAgent extends BaseAgent {
42
42
  readonly maxIterations: number;
43
43
  constructor(config: LoopAgentConfig);
44
44
  protected runAsyncImpl(context: InvocationContext): AsyncGenerator<Event, void, void>;
45
- protected runLiveImpl(_context: InvocationContext): AsyncGenerator<Event, void, void>;
45
+ protected runLiveImpl(context: InvocationContext): AsyncGenerator<Event, void, void>;
46
46
  }
47
47
  export {};
@@ -41,12 +41,35 @@ export interface RoutedAgentConfig extends BaseAgentConfig {
41
41
  /**
42
42
  * A BaseAgent implementation that delegates to one of multiple agents based on a router function.
43
43
  * Routing is strictly limited to the agents passed in the config.
44
+ *
45
+ * @remarks
46
+ * Cloning is supported: {@link RoutedAgent.clone} deep-clones the routing
47
+ * targets from `config.agents` and re-parents the fresh copies onto the clone,
48
+ * so the clone is a detached root that routes identically to the original while
49
+ * leaving the original agent tree untouched.
44
50
  */
45
- export declare class RoutedAgent extends BaseAgent {
51
+ export declare class RoutedAgent extends BaseAgent<RoutedAgentConfig> {
46
52
  readonly [ROUTED_AGENT_SIGNATURE_SYMBOL] = true;
47
53
  private readonly agents;
48
54
  private readonly router;
49
55
  constructor(config: RoutedAgentConfig);
56
+ /**
57
+ * Creates a detached copy of this routed agent.
58
+ *
59
+ * The inherited {@link BaseAgent.clone} only deep-clones `subAgents`, but a
60
+ * `RoutedAgent` derives its routing targets from `config.agents`. Rebuilding
61
+ * through the base clone alone would re-read the already-parented original
62
+ * agents and throw "already has a parent agent". This override deep-clones the
63
+ * routing targets (unless the caller overrides `agents`) so the rebuilt
64
+ * constructor re-parents fresh, detached copies. The array-vs-record shape
65
+ * and, for records, the keys are preserved so the router keeps selecting the
66
+ * same targets.
67
+ *
68
+ * @param overrides Config fields to override on the clone. Overriding
69
+ * `parentAgent` is rejected by the base implementation.
70
+ * @returns A new detached `RoutedAgent` of the same concrete class.
71
+ */
72
+ clone(overrides?: Partial<RoutedAgentConfig>): this;
50
73
  /**
51
74
  * Runs the selected agent via text-based conversation.
52
75
  */
@@ -94,6 +94,7 @@ export interface RunConfig {
94
94
  * @throws {Error} When `params.maxLlmCalls` exceeds `Number.MAX_SAFE_INTEGER`.
95
95
  */
96
96
  export declare function createRunConfig(params?: Partial<RunConfig>): {
97
+ maxLlmCalls: number;
97
98
  speechConfig?: SpeechConfig | undefined;
98
99
  responseModalities?: Modality[] | undefined;
99
100
  saveInputBlobsAsArtifacts: boolean;
@@ -104,6 +105,5 @@ export declare function createRunConfig(params?: Partial<RunConfig>): {
104
105
  enableAffectiveDialog: boolean;
105
106
  proactivity?: ProactivityConfig | undefined;
106
107
  realtimeInputConfig?: RealtimeInputConfig | undefined;
107
- maxLlmCalls: number;
108
108
  pauseOnToolCalls: boolean;
109
109
  };
@@ -12,6 +12,17 @@ import { BaseCredentialService } from './base_credential_service.js';
12
12
  * implementation of credential service
13
13
  */
14
14
  export declare class InMemoryCredentialService implements BaseCredentialService {
15
+ /**
16
+ * A map from app name to a map from user ID to a map from credential key to
17
+ * credential.
18
+ *
19
+ * `appName`, `userId` and `credentialKey` are all attacker-influenced, so
20
+ * every level is created with `Object.create(null)`. On an ordinary `{}`
21
+ * literal a key of `__proto__` resolves to the inherited `__proto__`
22
+ * accessor rather than creating an own property, so nested assignment
23
+ * pollutes every object in the process, and a lookup of an inherited key
24
+ * such as `toString` returns a function instead of `undefined`.
25
+ */
15
26
  private readonly credentials;
16
27
  loadCredential(authConfig: AuthConfig, toolContext: Context): Promise<AuthCredential | undefined>;
17
28
  saveCredential(authConfig: AuthConfig, toolContext: Context): Promise<void>;
@@ -23,6 +23,10 @@ export interface UnsafeLocalCodeExecutorOptions {
23
23
  pythonCommandPath?: string;
24
24
  /**
25
25
  * The command to run Shell code. Default is `bash`.
26
+ *
27
+ * When it names `powershell` or `pwsh` (with or without `.exe`) the script
28
+ * is written as `.ps1` and run through PowerShell rather than as a bare
29
+ * shell script.
26
30
  */
27
31
  shellCommandPath?: string;
28
32
  }
@@ -33,7 +37,7 @@ export interface UnsafeLocalCodeExecutorOptions {
33
37
  * **Execution Details**:
34
38
  * - **JavaScript**: Executed via `node` (defaults to `process.execPath`).
35
39
  * - **Python**: Executed via `python3` on Unix, and `python` on Windows.
36
- * - **Shell**: Executed via `bash` on Unix, and defaults to `powershell` (injecting ExecutionPolicy Bypass) or `cmd.exe` on Windows.
40
+ * - **Shell**: Executed via `bash` on Unix, and defaults to `powershell` (injecting `-NoProfile` and `-ExecutionPolicy Bypass`) or `cmd.exe` (injecting `/D`) on Windows.
37
41
  *
38
42
  * WARNING: This executor runs code in the local environment without sandboxing or security restrictions.
39
43
  * Use with caution and only for trusted code.
@@ -58,6 +58,8 @@ export type { ExecuteCodeParams } from './code_executors/base_code_executor.js';
58
58
  export { BuiltInCodeExecutor } from './code_executors/built_in_code_executor.js';
59
59
  export { CodeExecutionLanguage, FileContentEncoding, type CodeExecutionInput, type CodeExecutionResult, type File, } from './code_executors/code_execution_utils.js';
60
60
  export { AgentControlledContextCompactor } from './context/agent_controlled_context_compactor.js';
61
+ export { AnchoredContextCompactor } from './context/anchored_context_compactor.js';
62
+ export type { AnchoredContextCompactorOptions } from './context/anchored_context_compactor.js';
61
63
  export type { BaseContextCompactor } from './context/base_context_compactor.js';
62
64
  export type { BaseSummarizer } from './context/summarizers/base_summarizer.js';
63
65
  export { LlmSummarizer } from './context/summarizers/llm_summarizer.js';
@@ -68,9 +70,9 @@ export { TrajectoryThoughtPruningCompactor } from './context/trajectory_thought_
68
70
  export type { TrajectoryThoughtPruningCompactorOptions } from './context/trajectory_thought_pruning_compactor.js';
69
71
  export { TruncatingContextCompactor } from './context/truncating_context_compactor.js';
70
72
  export type { TruncatingContextCompactorOptions } from './context/truncating_context_compactor.js';
71
- export { isCompactedEvent } from './events/compacted_event.js';
73
+ export { isCompactedEvent, isScratchpadEvent } from './events/compacted_event.js';
72
74
  export type { CompactedEvent } from './events/compacted_event.js';
73
- export { createEvent, getFunctionCalls, getFunctionResponses, hasTrailingCodeExecutionResult, isFinalResponse, stringifyContent, } from './events/event.js';
75
+ export { createEvent, generateClientFunctionCallId, getFunctionCalls, getFunctionResponses, hasThoughts, hasTrailingCodeExecutionResult, isFinalResponse, populateClientFunctionCallId, pruneThoughts, stringifyContent, } from './events/event.js';
74
76
  export type { Event } from './events/event.js';
75
77
  export { createEventActions } from './events/event_actions.js';
76
78
  export type { EventActions } from './events/event_actions.js';
@@ -96,6 +98,7 @@ export type { BaseLlmType } from './models/registry.js';
96
98
  export { RoutedLlm } from './models/routed_llm.js';
97
99
  export type { LlmRouter } from './models/routed_llm.js';
98
100
  export { BasePlugin, ContextCompactionTrigger } from './plugins/base_plugin.js';
101
+ export { GlobalInstructionPlugin } from './plugins/global_instruction_plugin.js';
99
102
  export { LoggingPlugin } from './plugins/logging_plugin.js';
100
103
  export { PluginManager } from './plugins/plugin_manager.js';
101
104
  export { InMemoryPolicyEngine, PolicyOutcome, REQUEST_CONFIRMATION_FUNCTION_CALL_NAME, SecurityPlugin, getAskUserConfirmationFunctionCalls, } from './plugins/security_plugin.js';
@@ -116,15 +119,21 @@ export type { BaseToolParams, RunAsyncToolRequest, ToolProcessLlmRequest, } from
116
119
  export { BaseToolset, isBaseToolset } from './tools/base_toolset.js';
117
120
  export type { ToolPredicate } from './tools/base_toolset.js';
118
121
  export { ConsolidateContextTool } from './tools/consolidate_context_tool.js';
122
+ export { ENTERPRISE_WEB_SEARCH, EnterpriseWebSearchTool, } from './tools/enterprise_web_search_tool.js';
123
+ export { ExampleTool } from './tools/example_tool.js';
119
124
  export { EXIT_LOOP, ExitLoopTool } from './tools/exit_loop_tool.js';
120
125
  export { FunctionTool, isFunctionTool } from './tools/function_tool.js';
121
126
  export type { ToolExecuteArgument, ToolExecuteFunction, ToolInputParameters, ToolOptions, } from './tools/function_tool.js';
127
+ export { getUserChoiceTool } from './tools/get_user_choice_tool.js';
122
128
  export { GOOGLE_MAPS_GROUNDING, GoogleMapsGroundingTool, } from './tools/google_maps_grounding_tool.js';
123
129
  export { GOOGLE_SEARCH, GoogleSearchTool } from './tools/google_search_tool.js';
124
130
  export { LOAD_ARTIFACTS, LoadArtifactsTool, } from './tools/load_artifacts_tool.js';
125
131
  export { LOAD_MEMORY, LoadMemoryTool } from './tools/load_memory_tool.js';
132
+ export { LOAD_WEB_PAGE, loadWebPage } from './tools/load_web_page.js';
133
+ export type { LoadWebPageOptions } from './tools/load_web_page.js';
126
134
  export { LongRunningFunctionTool } from './tools/long_running_tool.js';
127
135
  export { PRELOAD_MEMORY, PreloadMemoryTool, } from './tools/preload_memory_tool.js';
136
+ export { requestInputTool } from './tools/request_input_tool.js';
128
137
  export { ToolConfirmation } from './tools/tool_confirmation.js';
129
138
  export { URL_CONTEXT, UrlContextTool } from './tools/url_context_tool.js';
130
139
  export { VertexAiSearchTool } from './tools/vertex_ai_search_tool.js';
@@ -20,5 +20,4 @@ export declare class AgentControlledContextCompactor implements BaseContextCompa
20
20
  shouldCompact(invocationContext: InvocationContext): boolean;
21
21
  compact(invocationContext: InvocationContext): Promise<void>;
22
22
  private clearFlags;
23
- private getActiveEvents;
24
23
  }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { InvocationContext } from '../agents/invocation_context.js';
7
+ import { BaseContextCompactor } from './base_context_compactor.js';
8
+ import { BaseSummarizer } from './summarizers/base_summarizer.js';
9
+ export interface AnchoredContextCompactorOptions {
10
+ /** The maximum number of tokens to retain in the session history before compaction. */
11
+ tokenThreshold: number;
12
+ /**
13
+ * The minimum number of raw events to keep at the end of the session.
14
+ * Compaction will not affect these tail events (unless needed for tool splits).
15
+ */
16
+ eventRetentionSize: number;
17
+ /** The summarizer used to create the compacted event content. */
18
+ summarizer: BaseSummarizer;
19
+ }
20
+ /**
21
+ * A context compactor that maintains a single persistent 'Scratchpad' or
22
+ * 'State Tracker' event at the top of the context history.
23
+ *
24
+ * When compaction is triggered, it merges new raw events into the existing
25
+ * Scratchpad event and discards them from the active history view.
26
+ */
27
+ export declare class AnchoredContextCompactor implements BaseContextCompactor {
28
+ private readonly tokenThreshold;
29
+ private readonly eventRetentionSize;
30
+ private readonly summarizer;
31
+ constructor(options: AnchoredContextCompactorOptions);
32
+ private getActiveEvents;
33
+ shouldCompact(invocationContext: InvocationContext): boolean | Promise<boolean>;
34
+ compact(invocationContext: InvocationContext): Promise<void>;
35
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Event } from '../events/event.js';
7
+ /**
8
+ * Filters the events to return only the active events since the latest compaction.
9
+ * If no compaction has occurred, returns all events.
10
+ *
11
+ * @param events The full history of events.
12
+ * @returns The active events, starting with the latest CompactedEvent if present.
13
+ */
14
+ export declare function getActiveEvents(events: Event[]): Event[];
15
+ /**
16
+ * Determines the baseline index to retain from active raw events,
17
+ * ensuring we don't split between a function call and its response.
18
+ *
19
+ * @param rawEvents The active raw events to consider for compaction.
20
+ * @param eventRetentionSize The minimum number of raw events to keep at the end of the session.
21
+ * @returns The index in `rawEvents` at which to split. Events before this index will be compacted.
22
+ */
23
+ export declare function calculateRetainStartIndex(rawEvents: Event[], eventRetentionSize: number): number;
@@ -32,7 +32,6 @@ export declare class TokenBasedContextCompactor implements BaseContextCompactor
32
32
  private readonly eventRetentionSize;
33
33
  private readonly summarizer;
34
34
  constructor(options: TokenBasedContextCompactorOptions);
35
- private getActiveEvents;
36
35
  shouldCompact(invocationContext: InvocationContext): boolean | Promise<boolean>;
37
36
  compact(invocationContext: InvocationContext): Promise<void>;
38
37
  }
@@ -25,9 +25,19 @@ export interface CompactedEvent extends Event {
25
25
  * The summarized content of the compacted events.
26
26
  */
27
27
  compactedContent: string;
28
+ /**
29
+ * Identifies this compacted event as the persistent context scratchpad.
30
+ */
31
+ isScratchpad?: boolean;
28
32
  }
29
33
  /**
30
34
  * Type guard to check if an event is a CompactedEvent.
31
35
  */
32
36
  export declare function isCompactedEvent(event: Event): event is CompactedEvent;
37
+ /**
38
+ * Type guard to check if an event is a scratchpad CompactedEvent.
39
+ */
40
+ export declare function isScratchpadEvent(event: Event): event is CompactedEvent & {
41
+ isScratchpad: true;
42
+ };
33
43
  export declare function createCompactedEvent(params?: Partial<CompactedEvent>): CompactedEvent;
@@ -67,6 +67,15 @@ export declare function isFinalResponse(event: Event): boolean;
67
67
  * Returns the function calls in the event.
68
68
  */
69
69
  export declare function getFunctionCalls(event: Event): FunctionCall[];
70
+ export declare const AF_FUNCTION_CALL_ID_PREFIX = "adk-";
71
+ export declare function generateClientFunctionCallId(): string;
72
+ /**
73
+ * Populates client-side function call IDs.
74
+ *
75
+ * It iterates through all function calls in the event and assigns a
76
+ * unique client-side ID to each one that doesn't already have an ID.
77
+ */
78
+ export declare function populateClientFunctionCallId(modelResponseEvent: Event): void;
70
79
  /**
71
80
  * Returns the function responses in the event.
72
81
  */
@@ -82,6 +91,10 @@ export declare function hasTrailingCodeExecutionResult(event: Event): boolean;
82
91
  * @returns A single string with the combined text.
83
92
  */
84
93
  export declare function stringifyContent(event: Event): string;
94
+ /**
95
+ * Estimates the number of tokens in the event based on usage metadata or characters.
96
+ */
97
+ export declare function getEventTokens(event: Event): number;
85
98
  /**
86
99
  * Returns whether the event contains any thought parts.
87
100
  */
@@ -9,7 +9,8 @@ export { getA2AAgentCard } from './a2a/agent_card.js';
9
9
  export { A2AAgentExecutor } from './a2a/agent_executor.js';
10
10
  export type { AfterEventCallback, AfterExecuteCallback, AgentExecutorConfig, BeforeExecuteCallback, RunnerOrRunnerConfig, } from './a2a/agent_executor.js';
11
11
  export { toA2a } from './a2a/agent_to_a2a.js';
12
- export type { ToA2aOptions } from './a2a/agent_to_a2a.js';
12
+ export type { A2aUserBuilder, ToA2aOptions } from './a2a/agent_to_a2a.js';
13
+ export { bearerTokenUserBuilder } from './a2a/auth.js';
13
14
  export type { ExecutorContext } from './a2a/executor_context.js';
14
15
  export { InvocationContext } from './agents/invocation_context.js';
15
16
  export { FileArtifactService } from './artifacts/file_artifact_service.js';
@@ -22,13 +23,14 @@ export * from './common.js';
22
23
  export { DatabaseSessionService } from './sessions/database_session_service.js';
23
24
  export { getSessionServiceFromUri } from './sessions/registry.js';
24
25
  export { VertexAiSessionService } from './sessions/vertex_ai_session_service.js';
25
- export type { VertexAiSessionServiceOptions } from './sessions/vertex_ai_session_service.js';
26
+ export type { VertexAiCreateSessionRequest, VertexAiSessionServiceOptions, } from './sessions/vertex_ai_session_service.js';
26
27
  export { loadAllSkillsInDir, loadSkillFromDir, validateSkillDir, } from './skills/loader.js';
27
- export { RunSkillInlineScriptTool } from './tools/skill/run_skill_inline_script_tool.js';
28
+ export { RunSkillInlineScriptErrorCode, RunSkillInlineScriptTool, } from './tools/skill/run_skill_inline_script_tool.js';
28
29
  export { RunSkillScriptTool } from './tools/skill/run_skill_script_tool.js';
29
30
  export * from './integrations/agent_registry/agent_registry.js';
30
31
  export * from './telemetry/google_cloud.js';
31
32
  export * from './telemetry/setup.js';
33
+ export * from './tools/mcp/load_mcp_resource_tool.js';
32
34
  export * from './tools/mcp/mcp_session_manager.js';
33
35
  export * from './tools/mcp/mcp_tool.js';
34
36
  export * from './tools/mcp/mcp_toolset.js';
@@ -12,6 +12,17 @@ import { BaseMemoryService, SearchMemoryRequest, SearchMemoryResponse } from './
12
12
  */
13
13
  export declare class InMemoryMemoryService implements BaseMemoryService {
14
14
  private readonly memories;
15
+ /**
16
+ * A map from user key to a map from session ID to events.
17
+ *
18
+ * The inner map is keyed by `session.id`, which arrives off the request path
19
+ * and contains no `/`, so it can be exactly `__proto__`. On a plain object
20
+ * literal that key would reach the inherited `__proto__` setter and
21
+ * re-parent the map instead of creating an own property, silently dropping
22
+ * the session from the `Object.values` scan in `searchMemory`. The outer key
23
+ * always contains a `/` (see `getUserKey`) and cannot collide, but is
24
+ * created the same way for consistency.
25
+ */
15
26
  private readonly sessionEvents;
16
27
  addSessionToMemory(session: Session): Promise<void>;
17
28
  searchMemory(req: SearchMemoryRequest): Promise<SearchMemoryResponse>;
@@ -151,8 +151,10 @@ export declare abstract class BasePlugin {
151
151
  * @param params.invocationContext The context for the entire invocation.
152
152
  * @param params.event The event raised by the runner.
153
153
  * @returns An optional value. A non-`undefined` return may be used by the
154
- * framework to modify or replace the response. Returning `undefined`
155
- * allows the original response to be used.
154
+ * framework to modify or replace the response. Copy `params.event` when
155
+ * constructing a replacement to preserve fields that are not being
156
+ * modified, such as event actions. Returning `undefined` allows the
157
+ * original response to be used.
156
158
  */
157
159
  onEventCallback(params: {
158
160
  invocationContext: InvocationContext;
@@ -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
+ }
@@ -147,7 +147,7 @@ export declare class Runner {
147
147
  }): AsyncGenerator<Event, void, undefined>;
148
148
  /**
149
149
  * Saves artifacts from the message parts and replaces the inline data with
150
- * a file name placeholder.
150
+ * a file name placeholder and optional file reference.
151
151
  *
152
152
  * @param invocationId The current invocation ID.
153
153
  * @param userId The user ID of the session.
@@ -145,6 +145,14 @@ export declare abstract class BaseSessionService {
145
145
  export declare function trimTempDeltaState(event: Event): Event;
146
146
  /**
147
147
  * Removes temporary state keys from the state.
148
+ *
149
+ * The result is a null-prototype map. `state` comes straight off the request
150
+ * body on a dev server (`POST /apps/:appName/users/:userId/sessions/:sessionId`),
151
+ * and `JSON.parse` makes `__proto__` an own key, so copying it into a plain
152
+ * object literal would invoke the inherited `__proto__` setter: the entry is
153
+ * dropped and the new state object is re-parented onto the attacker's object.
154
+ * `State.get`/`State.has` use the `in` operator, so every key on that object
155
+ * would then read back as session state.
148
156
  */
149
157
  export declare function trimTempState(state: Record<string, unknown>): Record<string, unknown>;
150
158
  /**