@google/adk 2.1.0 → 2.2.1

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 (166) hide show
  1. package/dist/cjs/a2a/agent_card.js +8 -0
  2. package/dist/cjs/a2a/agent_executor.js +8 -3
  3. package/dist/cjs/a2a/event_converter_utils.js +5 -1
  4. package/dist/cjs/a2a/metadata_converter_utils.js +2 -1
  5. package/dist/cjs/agents/llm_agent.js +15 -1
  6. package/dist/cjs/agents/processors/content_processor_utils.js +10 -2
  7. package/dist/cjs/agents/processors/nl_planning_processor.js +114 -0
  8. package/dist/cjs/artifacts/gcs_artifact_service.js +13 -7
  9. package/dist/cjs/auth/auth_credential.js +12 -2
  10. package/dist/cjs/code_executors/code_execution_utils.js +3 -3
  11. package/dist/cjs/common.js +63 -0
  12. package/dist/cjs/events/abort_events.js +135 -0
  13. package/dist/cjs/events/internal_metadata.js +131 -0
  14. package/dist/cjs/examples/example.js +92 -0
  15. package/dist/cjs/examples/example_util.js +28 -4
  16. package/dist/cjs/examples/index.js +39 -0
  17. package/dist/cjs/examples/vertex_ai_example_store.js +39 -0
  18. package/dist/cjs/index.js +46 -0
  19. package/dist/cjs/memory/vertex_ai_memory_bank_service.js +17 -5
  20. package/dist/cjs/models/base_llm.js +1 -6
  21. package/dist/cjs/models/chrome_prompt_llm.js +16 -2
  22. package/dist/cjs/models/chrome_prompt_utils.js +54 -2
  23. package/dist/cjs/models/gemini_continuation.js +232 -0
  24. package/dist/cjs/models/gemini_llm_connection.js +5 -4
  25. package/dist/cjs/planners/base_planner.js +56 -0
  26. package/dist/cjs/planners/built_in_planner.js +85 -0
  27. package/dist/cjs/planners/plan_re_act_planner.js +172 -0
  28. package/dist/cjs/plugins/base_plugin.js +46 -61
  29. package/dist/cjs/plugins/debug_logging_plugin.js +653 -0
  30. package/dist/cjs/plugins/plugin_manager.js +1 -1
  31. package/dist/cjs/plugins/tool_call_integrity_plugin.js +364 -0
  32. package/dist/cjs/runner/runner.js +17 -3
  33. package/dist/cjs/tools/example_tool.js +1 -1
  34. package/dist/cjs/tools/mcp/mcp_session_manager.js +14 -8
  35. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +281 -2
  36. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
  37. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +70 -0
  38. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +120 -0
  39. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -10
  40. package/dist/cjs/tools/openapi_tool/common/common.js +139 -0
  41. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
  42. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +73 -13
  43. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -34
  44. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +14 -2
  45. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +90 -28
  46. package/dist/cjs/tools/skill/skill_toolset.js +2 -0
  47. package/dist/cjs/tools/tool_context.js +41 -0
  48. package/dist/cjs/tools/webmcp/index.js +37 -0
  49. package/dist/cjs/tools/webmcp/webmcp_tool.js +156 -0
  50. package/dist/cjs/tools/webmcp/webmcp_toolset.js +116 -0
  51. package/dist/cjs/tools/webmcp/webmcp_types.js +50 -0
  52. package/dist/cjs/utils/case_utils.js +52 -2
  53. package/dist/cjs/utils/client_labels.js +67 -0
  54. package/dist/cjs/utils/gemini_schema_util.js +103 -3
  55. package/dist/cjs/utils/hash_utils.js +73 -0
  56. package/dist/cjs/utils/live_connection_utils.js +10 -9
  57. package/dist/cjs/utils/model_name.js +17 -2
  58. package/dist/cjs/utils/simple_zod_to_json.js +5 -0
  59. package/dist/cjs/version.js +1 -1
  60. package/dist/esm/a2a/agent_card.js +8 -0
  61. package/dist/esm/a2a/agent_executor.js +8 -3
  62. package/dist/esm/a2a/event_converter_utils.js +5 -1
  63. package/dist/esm/a2a/metadata_converter_utils.js +2 -1
  64. package/dist/esm/agents/llm_agent.js +18 -1
  65. package/dist/esm/agents/processors/content_processor_utils.js +10 -2
  66. package/dist/esm/agents/processors/nl_planning_processor.js +87 -0
  67. package/dist/esm/artifacts/gcs_artifact_service.js +13 -7
  68. package/dist/esm/auth/auth_credential.js +11 -1
  69. package/dist/esm/code_executors/code_execution_utils.js +3 -3
  70. package/dist/esm/common.js +58 -2
  71. package/dist/esm/events/abort_events.js +110 -0
  72. package/dist/esm/events/internal_metadata.js +97 -0
  73. package/dist/esm/examples/example.js +85 -0
  74. package/dist/esm/examples/example_util.js +25 -3
  75. package/dist/esm/examples/index.js +11 -0
  76. package/dist/esm/examples/vertex_ai_example_store.js +11 -0
  77. package/dist/esm/index.js +51 -1
  78. package/dist/esm/memory/vertex_ai_memory_bank_service.js +17 -5
  79. package/dist/esm/models/base_llm.js +2 -7
  80. package/dist/esm/models/chrome_prompt_llm.js +20 -3
  81. package/dist/esm/models/chrome_prompt_utils.js +51 -2
  82. package/dist/esm/models/gemini_continuation.js +205 -0
  83. package/dist/esm/models/gemini_llm_connection.js +6 -5
  84. package/dist/esm/planners/base_planner.js +28 -0
  85. package/dist/esm/planners/built_in_planner.js +57 -0
  86. package/dist/esm/planners/plan_re_act_planner.js +145 -0
  87. package/dist/esm/plugins/base_plugin.js +46 -61
  88. package/dist/esm/plugins/debug_logging_plugin.js +615 -0
  89. package/dist/esm/plugins/plugin_manager.js +1 -1
  90. package/dist/esm/plugins/tool_call_integrity_plugin.js +339 -0
  91. package/dist/esm/runner/runner.js +20 -3
  92. package/dist/esm/tools/example_tool.js +1 -1
  93. package/dist/esm/tools/mcp/mcp_session_manager.js +14 -8
  94. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +272 -1
  95. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
  96. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +43 -0
  97. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +93 -0
  98. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -12
  99. package/dist/esm/tools/openapi_tool/common/common.js +112 -0
  100. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
  101. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +80 -13
  102. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -33
  103. package/dist/esm/tools/openapi_tool/openapi_toolset.js +14 -2
  104. package/dist/esm/tools/openapi_tool/rest_api_tool.js +89 -28
  105. package/dist/esm/tools/skill/skill_toolset.js +2 -0
  106. package/dist/esm/tools/tool_context.js +15 -0
  107. package/dist/esm/tools/webmcp/index.js +10 -0
  108. package/dist/esm/tools/webmcp/webmcp_tool.js +131 -0
  109. package/dist/esm/tools/webmcp/webmcp_toolset.js +89 -0
  110. package/dist/esm/tools/webmcp/webmcp_types.js +22 -0
  111. package/dist/esm/utils/case_utils.js +49 -1
  112. package/dist/esm/utils/client_labels.js +65 -0
  113. package/dist/esm/utils/gemini_schema_util.js +102 -3
  114. package/dist/esm/utils/hash_utils.js +45 -0
  115. package/dist/esm/utils/live_connection_utils.js +11 -10
  116. package/dist/esm/utils/model_name.js +15 -2
  117. package/dist/esm/utils/simple_zod_to_json.js +5 -0
  118. package/dist/esm/version.js +1 -1
  119. package/dist/types/agents/llm_agent.d.ts +12 -1
  120. package/dist/types/agents/processors/nl_planning_processor.d.ts +30 -0
  121. package/dist/types/auth/auth_credential.d.ts +9 -0
  122. package/dist/types/common.d.ts +19 -4
  123. package/dist/types/events/abort_events.d.ts +43 -0
  124. package/dist/types/events/internal_metadata.d.ts +78 -0
  125. package/dist/types/examples/base_example_provider.d.ts +2 -2
  126. package/dist/types/examples/example.d.ts +75 -0
  127. package/dist/types/examples/example_util.d.ts +13 -2
  128. package/dist/types/examples/index.d.ts +18 -0
  129. package/dist/types/examples/vertex_ai_example_store.d.ts +7 -0
  130. package/dist/types/index.d.ts +12 -3
  131. package/dist/types/memory/memory_entry.d.ts +15 -0
  132. package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +9 -0
  133. package/dist/types/models/chrome_prompt_utils.d.ts +29 -0
  134. package/dist/types/models/gemini_continuation.d.ts +59 -0
  135. package/dist/types/planners/base_planner.d.ts +50 -0
  136. package/dist/types/planners/built_in_planner.d.ts +53 -0
  137. package/dist/types/planners/plan_re_act_planner.d.ts +21 -0
  138. package/dist/types/plugins/base_plugin.d.ts +52 -52
  139. package/dist/types/plugins/debug_logging_plugin.d.ts +157 -0
  140. package/dist/types/plugins/tool_call_integrity_plugin.d.ts +116 -0
  141. package/dist/types/skills/skill_registry.d.ts +8 -0
  142. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +110 -1
  143. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +32 -2
  144. package/dist/types/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.d.ts +35 -0
  145. package/dist/types/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.d.ts +54 -0
  146. package/dist/types/tools/openapi_tool/common/common.d.ts +60 -0
  147. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +7 -0
  148. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +56 -2
  149. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +73 -5
  150. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +11 -0
  151. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +42 -8
  152. package/dist/types/tools/tool_context.d.ts +19 -0
  153. package/dist/types/tools/webmcp/index.d.ts +12 -0
  154. package/dist/types/tools/webmcp/webmcp_tool.d.ts +47 -0
  155. package/dist/types/tools/webmcp/webmcp_toolset.d.ts +67 -0
  156. package/dist/types/tools/webmcp/webmcp_types.d.ts +69 -0
  157. package/dist/types/utils/case_utils.d.ts +36 -0
  158. package/dist/types/utils/client_labels.d.ts +33 -0
  159. package/dist/types/utils/gemini_schema_util.d.ts +13 -0
  160. package/dist/types/utils/hash_utils.d.ts +25 -0
  161. package/dist/types/utils/logger.d.ts +10 -2
  162. package/dist/types/utils/model_name.d.ts +30 -2
  163. package/dist/types/version.d.ts +1 -1
  164. package/dist/web/index_web.js +113 -80
  165. package/dist/web/index_web.js.map +4 -4
  166. package/package.json +8 -2
@@ -8,6 +8,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
8
8
  * SPDX-License-Identifier: Apache-2.0
9
9
  */
10
10
  import { Type } from "@google/genai";
11
+ import { toSnakeCaseName } from "./case_utils.js";
11
12
  function toGeminiType(mcpType) {
12
13
  if (!mcpType) return Type.TYPE_UNSPECIFIED;
13
14
  switch (mcpType.toLowerCase()) {
@@ -48,10 +49,18 @@ function toGeminiSchema(mcpSchema) {
48
49
  let isNullable = false;
49
50
  let nonNullTypes;
50
51
  if (Array.isArray(sourceType)) {
51
- nonNullTypes = sourceType.filter(
52
+ const fromAnyOf = Boolean(mcp.anyOf);
53
+ const branches = sourceType.map(
54
+ (branch) => {
55
+ if (typeof branch !== "boolean") return branch;
56
+ return fromAnyOf ? { type: "object" } : "object";
57
+ }
58
+ );
59
+ mcp = fromAnyOf ? { ...mcp, anyOf: branches } : { ...mcp, type: branches };
60
+ nonNullTypes = branches.filter(
52
61
  (t) => getTypeFromArrayItem(t) !== "null"
53
62
  );
54
- isNullable = sourceType.some(
63
+ isNullable = branches.some(
55
64
  (t) => getTypeFromArrayItem(t) === "null"
56
65
  );
57
66
  if (nonNullTypes.length === 1) {
@@ -108,7 +117,7 @@ function toGeminiSchema(mcpSchema) {
108
117
  geminiSchema.description = mcp.description;
109
118
  }
110
119
  if (mcp.enum) {
111
- geminiSchema.enum = mcp.enum.map(String);
120
+ geminiSchema.enum = mcp.enum.filter((v) => v != null).map(String);
112
121
  }
113
122
  if (isNullable && mcp.type !== "null") {
114
123
  geminiSchema.nullable = true;
@@ -136,6 +145,96 @@ function toGeminiSchema(mcpSchema) {
136
145
  return recursiveConvert(mcpSchema);
137
146
  }
138
147
  __name(toGeminiSchema, "toGeminiSchema");
148
+ const GEMINI_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
149
+ "anyOf",
150
+ "default",
151
+ "description",
152
+ "enum",
153
+ "example",
154
+ "format",
155
+ "items",
156
+ "maxItems",
157
+ "maxLength",
158
+ "maxProperties",
159
+ "maximum",
160
+ "minItems",
161
+ "minLength",
162
+ "minProperties",
163
+ "minimum",
164
+ "nullable",
165
+ "pattern",
166
+ "properties",
167
+ "propertyOrdering",
168
+ "required",
169
+ "title",
170
+ "type"
171
+ ]);
172
+ const GEMINI_REJECTED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
173
+ "title",
174
+ "default",
175
+ "format"
176
+ ]);
177
+ const EMPTY_OBJECT_PLACEHOLDER = "dummy_DO_NOT_GENERATE";
178
+ function toGeminiSchemaField(key) {
179
+ return toSnakeCaseName(key).replace(
180
+ /_([a-z0-9])/g,
181
+ (_match, letter) => letter.toUpperCase()
182
+ );
183
+ }
184
+ __name(toGeminiSchemaField, "toGeminiSchemaField");
185
+ function isPlainObject(value) {
186
+ return typeof value === "object" && value !== null && !Array.isArray(value);
187
+ }
188
+ __name(isPlainObject, "isPlainObject");
189
+ function convertSchemaField(field, value) {
190
+ if (field === "type") {
191
+ return toGeminiType(typeof value === "string" ? value : void 0);
192
+ }
193
+ if (field === "properties" && isPlainObject(value)) {
194
+ return Object.fromEntries(
195
+ Object.entries(value).map(([name, property]) => [
196
+ name,
197
+ openApiSchemaToGeminiSchema(property)
198
+ ])
199
+ );
200
+ }
201
+ if (field === "items" && isPlainObject(value)) {
202
+ return openApiSchemaToGeminiSchema(value);
203
+ }
204
+ if (field === "anyOf" && Array.isArray(value)) {
205
+ return value.map((item) => openApiSchemaToGeminiSchema(item));
206
+ }
207
+ return value;
208
+ }
209
+ __name(convertSchemaField, "convertSchemaField");
210
+ function openApiSchemaToGeminiSchema(openApiSchema) {
211
+ if (openApiSchema === void 0 || openApiSchema === null) {
212
+ return void 0;
213
+ }
214
+ if (!isPlainObject(openApiSchema)) {
215
+ throw new TypeError("openapi_schema must be a dictionary");
216
+ }
217
+ const source = { ...openApiSchema };
218
+ if (!source["type"]) {
219
+ source["type"] = "object";
220
+ }
221
+ const properties = source["properties"];
222
+ const hasProperties = isPlainObject(properties) && Object.keys(properties).length > 0;
223
+ if (source["type"] === "object" && !hasProperties) {
224
+ source["properties"] = { [EMPTY_OBJECT_PLACEHOLDER]: { type: "string" } };
225
+ }
226
+ const converted = {};
227
+ for (const [key, value] of Object.entries(source)) {
228
+ const field = toGeminiSchemaField(key);
229
+ if (!GEMINI_SCHEMA_FIELDS.has(field) || GEMINI_REJECTED_SCHEMA_FIELDS.has(field)) {
230
+ continue;
231
+ }
232
+ converted[field] = convertSchemaField(field, value);
233
+ }
234
+ return converted;
235
+ }
236
+ __name(openApiSchemaToGeminiSchema, "openApiSchemaToGeminiSchema");
139
237
  export {
238
+ openApiSchemaToGeminiSchema,
140
239
  toGeminiSchema
141
240
  };
@@ -0,0 +1,45 @@
1
+ import {createRequire as topLevelCreateRequire} from 'module';
2
+ const require = topLevelCreateRequire(import.meta.url);
3
+ var __defProp = Object.defineProperty;
4
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
5
+ /**
6
+ * @license
7
+ * Copyright 2026 Google LLC
8
+ * SPDX-License-Identifier: Apache-2.0
9
+ */
10
+ const FNV_OFFSET_BASIS = 2166136261;
11
+ const FNV_PRIME = 16777619;
12
+ function stableStringify(value) {
13
+ var _a;
14
+ return (_a = JSON.stringify(sortKeysDeep(value))) != null ? _a : "undefined";
15
+ }
16
+ __name(stableStringify, "stableStringify");
17
+ function stableHash(value) {
18
+ const text = stableStringify(value);
19
+ let hash = FNV_OFFSET_BASIS;
20
+ for (let i = 0; i < text.length; i++) {
21
+ hash ^= text.charCodeAt(i);
22
+ hash = Math.imul(hash, FNV_PRIME);
23
+ }
24
+ return (hash >>> 0).toString(16);
25
+ }
26
+ __name(stableHash, "stableHash");
27
+ function sortKeysDeep(value) {
28
+ if (Array.isArray(value)) {
29
+ return value.map(sortKeysDeep);
30
+ }
31
+ if (value === null || typeof value !== "object") {
32
+ return value;
33
+ }
34
+ const source = value;
35
+ const sorted = {};
36
+ for (const key of Object.keys(source).sort()) {
37
+ sorted[key] = sortKeysDeep(source[key]);
38
+ }
39
+ return sorted;
40
+ }
41
+ __name(sortKeysDeep, "sortKeysDeep");
42
+ export {
43
+ stableHash,
44
+ stableStringify
45
+ };
@@ -7,7 +7,7 @@ var __name = (target, value) => __defProp(target, "name", { value, configurable:
7
7
  * Copyright 2026 Google LLC
8
8
  * SPDX-License-Identifier: Apache-2.0
9
9
  */
10
- import { isGemini3xFlashLive } from "./model_name.js";
10
+ import { isGemini3xLive } from "./model_name.js";
11
11
  const _LiveResponseAggregator = class _LiveResponseAggregator {
12
12
  constructor(modelVersion) {
13
13
  this.modelVersion = modelVersion;
@@ -69,18 +69,19 @@ const _LiveResponseAggregator = class _LiveResponseAggregator {
69
69
  yield llmResponse;
70
70
  }
71
71
  if (serverContent.inputTranscription) {
72
- if (serverContent.inputTranscription.text) {
73
- this.inputTranscriptionText += serverContent.inputTranscription.text;
72
+ const isGemini3x = isGemini3xLive(this.modelVersion);
73
+ const { text, finished } = serverContent.inputTranscription;
74
+ if (text) {
75
+ if (!isGemini3x) {
76
+ this.inputTranscriptionText += text;
77
+ }
74
78
  yield {
75
- inputTranscription: {
76
- text: serverContent.inputTranscription.text,
77
- finished: false
78
- },
79
- partial: true,
79
+ inputTranscription: { text, finished: isGemini3x },
80
+ partial: !isGemini3x,
80
81
  ...this.modelVersion ? { modelVersion: this.modelVersion } : {}
81
82
  };
82
83
  }
83
- if (serverContent.inputTranscription.finished) {
84
+ if (finished && !isGemini3x) {
84
85
  yield {
85
86
  inputTranscription: {
86
87
  text: this.inputTranscriptionText,
@@ -198,7 +199,7 @@ const _LiveResponseAggregator = class _LiveResponseAggregator {
198
199
  }))
199
200
  );
200
201
  }
201
- const isGemini3x = isGemini3xFlashLive(this.modelVersion);
202
+ const isGemini3x = isGemini3xLive(this.modelVersion);
202
203
  if (isGemini3x && this.toolCallParts.length > 0) {
203
204
  yield {
204
205
  content: { role: "model", parts: this.toolCallParts },
@@ -53,12 +53,23 @@ function isGemini2OrAbove(modelString) {
53
53
  return parsedVersion.valid && parsedVersion.major >= 2;
54
54
  }
55
55
  __name(isGemini2OrAbove, "isGemini2OrAbove");
56
- function isGemini3xFlashLive(modelString) {
56
+ function isGemini3xLive(modelString) {
57
57
  if (!modelString) {
58
58
  return false;
59
59
  }
60
60
  const modelName = extractModelName(modelString);
61
- return modelName.startsWith("gemini-3.") && modelName.includes("-flash-live");
61
+ return modelName.startsWith("gemini-3.") && modelName.includes("-live") && !isGemini35LiveTranslate(modelString);
62
+ }
63
+ __name(isGemini3xLive, "isGemini3xLive");
64
+ function isGemini35LiveTranslate(modelString) {
65
+ if (!modelString) {
66
+ return false;
67
+ }
68
+ return extractModelName(modelString).startsWith("gemini-3.5-live-translate");
69
+ }
70
+ __name(isGemini35LiveTranslate, "isGemini35LiveTranslate");
71
+ function isGemini3xFlashLive(modelString) {
72
+ return isGemini3xLive(modelString);
62
73
  }
63
74
  __name(isGemini3xFlashLive, "isGemini3xFlashLive");
64
75
  function isGeminiModelIdCheckDisabled() {
@@ -69,7 +80,9 @@ export {
69
80
  extractModelName,
70
81
  isGemini1Model,
71
82
  isGemini2OrAbove,
83
+ isGemini35LiveTranslate,
72
84
  isGemini3xFlashLive,
85
+ isGemini3xLive,
73
86
  isGeminiModel,
74
87
  isGeminiModelIdCheckDisabled
75
88
  };
@@ -86,6 +86,11 @@ function zodObjectToSchema(schema) {
86
86
  if (isZodV3Schema(schema)) {
87
87
  return toJSONSchemaV3(schema, {
88
88
  target: "openApi3",
89
+ // The genai `Schema` type has no `$ref`, so a pointer back at an earlier
90
+ // occurrence of a reused sub-schema reaches the model as an untyped
91
+ // parameter. Inline every occurrence instead. A cycle has no finite
92
+ // inlining and degrades to an unconstrained schema.
93
+ $refStrategy: "none",
89
94
  emailStrategy: "format:email",
90
95
  postProcess: /* @__PURE__ */ __name((jsonSchema) => {
91
96
  var _a, _b, _c, _d, _e, _f, _g;
@@ -5,7 +5,7 @@ const require = topLevelCreateRequire(import.meta.url);
5
5
  * Copyright 2025 Google LLC
6
6
  * SPDX-License-Identifier: Apache-2.0
7
7
  */
8
- const version = "2.1.0";
8
+ const version = "2.2.1";
9
9
  export {
10
10
  version
11
11
  };
@@ -16,6 +16,7 @@ import { Example } from '../examples/example.js';
16
16
  import { BaseLlm } from '../models/base_llm.js';
17
17
  import { LlmRequest } from '../models/llm_request.js';
18
18
  import { LlmResponse } from '../models/llm_response.js';
19
+ import type { BasePlanner } from '../planners/base_planner.js';
19
20
  import { BaseTool } from '../tools/base_tool.js';
20
21
  import { BaseToolset } from '../tools/base_toolset.js';
21
22
  import { Context } from './context.js';
@@ -146,7 +147,9 @@ export interface LlmAgentConfig extends BaseAgentConfig {
146
147
  * Three fields are rejected by the constructor, because the agent owns them:
147
148
  * `tools` (set them through `tools`), `systemInstruction` (through
148
149
  * `instruction`) and `responseSchema` (through `outputSchema`). Every other
149
- * field is forwarded to the model as given — `thinkingConfig` included.
150
+ * field is forwarded to the model as given. That includes `thinkingConfig`,
151
+ * unless `planner` is a `BuiltInPlanner` with its own `thinkingConfig`: the
152
+ * planner's `thinkingConfig` then takes precedence.
150
153
  *
151
154
  * For example: use this config to adjust model temperature, configure safety
152
155
  * settings, etc.
@@ -226,6 +229,13 @@ export interface LlmAgentConfig extends BaseAgentConfig {
226
229
  * Instructs the agent to make a plan and execute it step by step.
227
230
  */
228
231
  codeExecutor?: BaseCodeExecutor;
232
+ /**
233
+ * Instructs the agent to make a plan and execute it step by step.
234
+ *
235
+ * NOTE: to use the model's built-in thinking features, set `thinkingConfig`
236
+ * on a `BuiltInPlanner`.
237
+ */
238
+ planner?: BasePlanner;
229
239
  }
230
240
  /**
231
241
  * A unique symbol to identify ADK agent classes.
@@ -288,6 +298,7 @@ export declare class LlmAgent extends BaseAgent<LlmAgentConfig> {
288
298
  requestProcessors: BaseLlmRequestProcessor[];
289
299
  responseProcessors: BaseLlmResponseProcessor[];
290
300
  codeExecutor?: BaseCodeExecutor;
301
+ planner?: BasePlanner;
291
302
  constructor(config: LlmAgentConfig);
292
303
  /**
293
304
  * The resolved BaseLlm instance.
@@ -0,0 +1,30 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Event } from '../../events/event.js';
7
+ import { LlmRequest } from '../../models/llm_request.js';
8
+ import { LlmResponse } from '../../models/llm_response.js';
9
+ import { InvocationContext } from '../invocation_context.js';
10
+ import { BaseLlmRequestProcessor, BaseLlmResponseProcessor } from './base_llm_processor.js';
11
+ /**
12
+ * Prepares the LLM request for the agent's planner.
13
+ *
14
+ * Applies a `BuiltInPlanner`'s thinking config, appends the planner's
15
+ * planning instruction, and clears the `thought` flag on every request part
16
+ * so that earlier planning output goes back to the model as plain text.
17
+ */
18
+ export declare class NlPlanningRequestProcessor extends BaseLlmRequestProcessor {
19
+ runAsync(invocationContext: InvocationContext, llmRequest: LlmRequest): AsyncGenerator<Event, void, void>;
20
+ }
21
+ /**
22
+ * Replaces the LLM response parts with the planner's processed parts.
23
+ *
24
+ * Partial responses are processed too.
25
+ */
26
+ export declare class NlPlanningResponseProcessor extends BaseLlmResponseProcessor {
27
+ runAsync(invocationContext: InvocationContext, llmResponse: LlmResponse): AsyncGenerator<Event, void, void>;
28
+ }
29
+ export declare const NL_PLANNING_REQUEST_PROCESSOR: NlPlanningRequestProcessor;
30
+ export declare const NL_PLANNING_RESPONSE_PROCESSOR: NlPlanningResponseProcessor;
@@ -247,3 +247,12 @@ export interface AuthCredential {
247
247
  serviceAccount?: ServiceAccount;
248
248
  oauth2?: OAuth2Auth;
249
249
  }
250
+ /**
251
+ * Reports whether `value` is an {@link AuthCredential}.
252
+ *
253
+ * Use it on a value that crossed a boundary where the type was lost, such as a
254
+ * credential read back out of session state. The check is a shallow one on
255
+ * `authType`, because the payload members are all optional and the type they
256
+ * carry depends on the scheme.
257
+ */
258
+ export declare function isAuthCredential(value: unknown): value is AuthCredential;
@@ -39,7 +39,7 @@ export { InMemoryArtifactService } from './artifacts/in_memory_artifact_service.
39
39
  export { ScopedArtifactService } from './artifacts/scoped_artifact_service.js';
40
40
  export { isSessionArtifactService } from './artifacts/session_artifact_service.js';
41
41
  export type { SessionArtifactService, SessionLoadArtifactRequest, SessionSaveArtifactRequest, } from './artifacts/session_artifact_service.js';
42
- export { AuthCredentialTypes } from './auth/auth_credential.js';
42
+ export { AuthCredentialTypes, isAuthCredential } from './auth/auth_credential.js';
43
43
  export type { AuthCredential, HttpAuth, HttpCredentials, OAuth2Auth, ServiceAccount, ServiceAccountCredential, } from './auth/auth_credential.js';
44
44
  export { AuthHandler } from './auth/auth_handler.js';
45
45
  export { AUTH_PREPROCESSOR, AuthPreprocessor } from './auth/auth_preprocessor.js';
@@ -87,10 +87,12 @@ export { createEvent, generateClientFunctionCallId, getFunctionCalls, getFunctio
87
87
  export type { CreateEventParams, Event, NodeInfo, Route, RouteKey, } from './events/event.js';
88
88
  export { createEventActions } from './events/event_actions.js';
89
89
  export type { EventActions } from './events/event_actions.js';
90
+ export { INTERNAL_METADATA_PREFIX, RESTORED_EVENT_KEY, markRestored, publicEvent, publicMetadata, publicSession, } from './events/internal_metadata.js';
90
91
  export { EventType, toStructuredEvents } from './events/structured_events.js';
91
92
  export type { ActivityEvent, CallCodeEvent, CodeResultEvent, ContentEvent, ErrorEvent, FinishedEvent, StructuredEvent, ThoughtEvent, ToolCallEvent, ToolConfirmationEvent, ToolResultEvent, } from './events/structured_events.js';
92
93
  export { BaseExampleProvider, isBaseExampleProvider, } from './examples/base_example_provider.js';
93
- export type { Example } from './examples/example.js';
94
+ export { VertexAiExampleStore } from './examples/example.js';
95
+ export type { Example, ExampleStoreApiClient, SearchExamplesRequest, SearchExamplesResponse, SearchExamplesResult, StoredContentsExample, } from './examples/example.js';
94
96
  export type { BaseMemoryService, SearchMemoryRequest, SearchMemoryResponse, } from './memory/base_memory_service.js';
95
97
  export { InMemoryMemoryService } from './memory/in_memory_memory_service.js';
96
98
  export type { MemoryEntry } from './memory/memory_entry.js';
@@ -108,6 +110,9 @@ export { LLMRegistry } from './models/registry.js';
108
110
  export type { BaseLlmType } from './models/registry.js';
109
111
  export { RoutedLlm } from './models/routed_llm.js';
110
112
  export type { LlmRouter } from './models/routed_llm.js';
113
+ export { BasePlanner, isBasePlanner } from './planners/base_planner.js';
114
+ export { BuiltInPlanner, isBuiltInPlanner } from './planners/built_in_planner.js';
115
+ export { PlanReActPlanner } from './planners/plan_re_act_planner.js';
111
116
  export { GLOBAL_SCOPE_KEY, REFLECT_AND_RETRY_RESPONSE_TYPE, ScopedFailureTracker, TrackingScope, resolveScopeKey, type PerItemFailuresCounter, type ToolFailureResponse, } from './plugins/_reflect_retry_utils.js';
112
117
  export { BasePlugin, ContextCompactionTrigger } from './plugins/base_plugin.js';
113
118
  export { GlobalInstructionPlugin } from './plugins/global_instruction_plugin.js';
@@ -117,6 +122,8 @@ export { ADK_HANDLE_MODEL_ERROR_TOOL_NAME, RESERVED_TOOL_CALL_ERROR_TYPE, Reflec
117
122
  export { ReflectAndRetryToolPlugin, type ReflectAndRetryToolPluginOptions, } from './plugins/reflect_retry_tool_plugin.js';
118
123
  export { InMemoryPolicyEngine, PolicyOutcome, SecurityPlugin, getAskUserConfirmationFunctionCalls, } from './plugins/security_plugin.js';
119
124
  export type { BasePolicyEngine, PolicyCheckResult, ToolCallPolicyContext, } from './plugins/security_plugin.js';
125
+ export { ToolCallIntegrityError, ToolCallIntegrityPlugin, } from './plugins/tool_call_integrity_plugin.js';
126
+ export type { ToolCallIntegrityPluginOptions } from './plugins/tool_call_integrity_plugin.js';
120
127
  export { InMemoryRunner } from './runner/in_memory_runner.js';
121
128
  export { Runner, determineAgentForResumption, findEventByLastFunctionResponseId, isRoutableLlmAgent, isRunner, } from './runner/runner.js';
122
129
  export type { RunnerConfig } from './runner/runner.js';
@@ -155,15 +162,23 @@ export { LlamaIndexRetrieval } from './tools/retrieval/llama_index_retrieval.js'
155
162
  export type { LlamaIndexNode, LlamaIndexNodeWithScore, LlamaIndexRetrievalParams, LlamaIndexRetriever, } from './tools/retrieval/llama_index_retrieval.js';
156
163
  export { IntentMismatchError, ToolConfirmation, isIntentMismatchError, } from './tools/tool_confirmation.js';
157
164
  export type { IntentMismatchReason } from './tools/tool_confirmation.js';
165
+ export { CallbackContext, ToolContext } from './tools/tool_context.js';
158
166
  export { URL_CONTEXT, UrlContextTool } from './tools/url_context_tool.js';
159
167
  export { VertexAiSearchTool } from './tools/vertex_ai_search_tool.js';
160
168
  export type { DataStoreParams, SearchEngineParams, VertexAISearchConfig, VertexAISearchDataStoreSpec, VertexAiSearchToolParams, } from './tools/vertex_ai_search_tool.js';
161
169
  export { VertexRagRetrievalTool } from './tools/vertex_rag_retrieval_tool.js';
170
+ export { WebMCPTool } from './tools/webmcp/webmcp_tool.js';
171
+ export type { WebMCPToolParams } from './tools/webmcp/webmcp_tool.js';
172
+ export { WebMCPToolset } from './tools/webmcp/webmcp_toolset.js';
173
+ export type { WebMCPToolsetOptions } from './tools/webmcp/webmcp_toolset.js';
174
+ export { getModelContext, isWebMCPSupported, } from './tools/webmcp/webmcp_types.js';
175
+ export type { WebMCPDocument, WebMCPExecuteToolOptions, WebMCPGetToolsOptions, WebMCPModelContext, WebMCPRegisteredTool, WebMCPToolAnnotations, } from './tools/webmcp/webmcp_types.js';
162
176
  export { AsyncQueue } from './utils/async_queue.js';
177
+ export { renameReservedKeywords, toSnakeCaseName } from './utils/case_utils.js';
163
178
  export { getClientLabels, runWithClientLabel } from './utils/client_labels.js';
164
- export { LogLevel, getLogger, resetLogger, setLogLevel, setLogger, } from './utils/logger.js';
179
+ export { LogLevel, getLogger, logger, resetLogger, setLogLevel, setLogger, } from './utils/logger.js';
165
180
  export type { Logger } from './utils/logger.js';
166
- export { isGemini2OrAbove, isGemini3xFlashLive } from './utils/model_name.js';
181
+ export { isGemini2OrAbove, isGemini35LiveTranslate, isGemini3xFlashLive, isGemini3xLive, } from './utils/model_name.js';
167
182
  export type { SchemaLike } from './utils/schema.js';
168
183
  export { zodObjectToSchema } from './utils/simple_zod_to_json.js';
169
184
  export { Task } from './utils/task.js';
@@ -0,0 +1,43 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ import { Event } from './event.js';
7
+ export declare const INVOCATION_ABORTED = "INVOCATION_ABORTED";
8
+ export declare const ABORT_MESSAGE = "Invocation was aborted by client.";
9
+ /**
10
+ * Returns whether `event` was synthesized to seal an aborted invocation.
11
+ */
12
+ export declare function isAbortEvent(event: Event): boolean;
13
+ /** Parameters for {@link buildAbortEvents}. */
14
+ export interface BuildAbortEventsParams {
15
+ /** The session history, in chronological order. */
16
+ events: Event[];
17
+ /** The aborted invocation; only its events are considered. */
18
+ invocationId: string;
19
+ /** Author of the abort event returned when nothing is dangling. */
20
+ rootAgentName: string;
21
+ /**
22
+ * Branch for calls whose event has no branch, and for the abort event
23
+ * returned when nothing is dangling.
24
+ */
25
+ branch?: string;
26
+ }
27
+ /**
28
+ * Returns the events that seal an aborted invocation.
29
+ *
30
+ * Each dangling function call gets a synthetic error response carrying the
31
+ * author, branch and isolation scope of the event that issued it, so the
32
+ * response pairs with its call in the issuing agent's own view. Calls sharing
33
+ * those three values are grouped into one event. If nothing is dangling, a
34
+ * single content-less abort event authored by the root agent is returned
35
+ * instead.
36
+ *
37
+ * Long-running calls (including confirmation and credential requests) are
38
+ * sealed too: the invocation that issued them is gone, so they are not left
39
+ * pending for a later turn.
40
+ *
41
+ * @returns The synthetic events, in the order they should be appended.
42
+ */
43
+ export declare function buildAbortEvents({ events, invocationId, rootAgentName, branch, }: BuildAbortEventsParams): Event[];
@@ -0,0 +1,78 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * `Event.customMetadata` keys that only ADK code may write.
8
+ *
9
+ * Mirrors adk-python's `google.adk.events._internal_metadata`.
10
+ */
11
+ import type { Session } from '../sessions/session.js';
12
+ import type { Event } from './event.js';
13
+ type Metadata = Record<string, unknown>;
14
+ /**
15
+ * Prefix of `customMetadata` keys that callers cannot set.
16
+ *
17
+ * Keys with this prefix are dropped from the `customMetadata` passed to
18
+ * `Runner.runAsync`, and from events that are restored into a session or
19
+ * received from a remote A2A agent. Stored events keep them, but they are
20
+ * removed from API responses, saved session files and A2A messages.
21
+ *
22
+ * The value matches adk-python so a session store shared between the two
23
+ * treats the same keys as internal.
24
+ */
25
+ export declare const INTERNAL_METADATA_PREFIX = "__adk_internal_";
26
+ /** Set on events that ADK restored into a session from outside it. */
27
+ export declare const RESTORED_EVENT_KEY = "__adk_internal_restored_event";
28
+ /**
29
+ * Returns `metadata` without keys that have the internal prefix.
30
+ *
31
+ * Use it where callers supply metadata. Dropped keys are logged at debug level,
32
+ * because a caller set a key it cannot set.
33
+ *
34
+ * @param metadata A `customMetadata` value. It is not modified.
35
+ * @returns A new object without internal keys. A value that is not a plain
36
+ * object, such as `undefined`, is returned unchanged.
37
+ */
38
+ export declare function withoutInternalMetadata<T>(metadata: T): T;
39
+ /**
40
+ * Returns `metadata` as callers see it, without internal keys.
41
+ *
42
+ * Use it where events leave ADK. Removal there is routine, so nothing is
43
+ * logged.
44
+ *
45
+ * @param metadata A `customMetadata` value. It is not modified.
46
+ * @returns A new object without internal keys, or `undefined` if nothing is
47
+ * left. A value that is not a plain object is returned unchanged.
48
+ */
49
+ export declare function publicMetadata<T>(metadata: T): T | undefined;
50
+ /** Returns only the keys of `metadata` that have the internal prefix. */
51
+ export declare function internalMetadata(metadata: unknown): Metadata;
52
+ /**
53
+ * Marks an event restored from outside the session, in place.
54
+ *
55
+ * Internal metadata carried by the event is removed first, so a caller cannot
56
+ * supply its own.
57
+ *
58
+ * @param event The event about to be appended to a new session.
59
+ * @returns The same event.
60
+ */
61
+ export declare function markRestored<T extends Event>(event: T): T;
62
+ /**
63
+ * Returns the event as callers see it, without internal metadata.
64
+ *
65
+ * @param event A stored event. It is not modified.
66
+ * @returns The same event if it has no internal keys. Otherwise a copy whose
67
+ * `customMetadata` drops them, or is `undefined` if nothing else is left.
68
+ */
69
+ export declare function publicEvent<T extends Event>(event: T): T;
70
+ /**
71
+ * Returns the session as callers see it, without internal metadata.
72
+ *
73
+ * @param session A stored session. It is not modified.
74
+ * @returns The same session if no event changes. Otherwise a copy whose events
75
+ * are passed through {@link publicEvent}.
76
+ */
77
+ export declare function publicSession<T extends Session>(session: T): T;
78
+ export {};
@@ -29,8 +29,8 @@ export declare abstract class BaseExampleProvider {
29
29
  * Returns a list of examples for a given query.
30
30
  *
31
31
  * @param query The query to get examples for.
32
- * @return A list of Example objects.
32
+ * @return A promise that resolves to a list of Example objects.
33
33
  */
34
- abstract getExamples(query: string): Example[];
34
+ abstract getExamples(query: string): Promise<Example[]>;
35
35
  }
36
36
  export {};
@@ -4,6 +4,7 @@
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
6
  import { Content } from '@google/genai';
7
+ import { BaseExampleProvider } from './base_example_provider.js';
7
8
  /**
8
9
  * A few-shot example.
9
10
  */
@@ -17,3 +18,77 @@ export interface Example {
17
18
  */
18
19
  output: Content[];
19
20
  }
21
+ /**
22
+ * Request payload for searching examples in Vertex AI Example Store.
23
+ */
24
+ export interface SearchExamplesRequest {
25
+ storedContentsExampleParameters: {
26
+ contentSearchKey: {
27
+ contents: Content[];
28
+ searchKeyGenerationMethod: {
29
+ lastEntry: Record<string, never>;
30
+ };
31
+ };
32
+ };
33
+ topK: number;
34
+ exampleStore: string;
35
+ }
36
+ /**
37
+ * A stored example returned inside a {@link SearchExamplesResult}.
38
+ */
39
+ export interface StoredContentsExample {
40
+ searchKey?: string;
41
+ contentsExample?: {
42
+ expectedContents?: Array<{
43
+ content?: Content;
44
+ }>;
45
+ };
46
+ }
47
+ /**
48
+ * Single result item returned by {@link ExampleStoreApiClient.searchExamples}.
49
+ */
50
+ export interface SearchExamplesResult {
51
+ similarityScore?: number;
52
+ example?: {
53
+ storedContentsExample?: StoredContentsExample;
54
+ };
55
+ }
56
+ /**
57
+ * Response returned by {@link ExampleStoreApiClient.searchExamples}.
58
+ */
59
+ export interface SearchExamplesResponse {
60
+ results?: SearchExamplesResult[];
61
+ }
62
+ /**
63
+ * API client interface for the Vertex AI Example Store.
64
+ *
65
+ * The Python SDK obtains this client from its bundled `vertexai` dependency.
66
+ * adk-js does not bundle that dependency, so the caller injects a client that
67
+ * reaches the Vertex AI Example Store API.
68
+ */
69
+ export interface ExampleStoreApiClient {
70
+ searchExamples(request: SearchExamplesRequest): Promise<SearchExamplesResponse>;
71
+ }
72
+ /**
73
+ * Provides examples from a Vertex AI Example Store.
74
+ */
75
+ export declare class VertexAiExampleStore extends BaseExampleProvider {
76
+ readonly examplesStoreName: string;
77
+ private readonly apiClient;
78
+ /**
79
+ * Initializes the VertexAiExampleStore.
80
+ *
81
+ * @param examplesStoreName The resource name of the vertex example store, in
82
+ * the format of
83
+ * `projects/{project}/locations/{location}/exampleStores/{example_store}`.
84
+ * @param apiClient A client that reaches the Vertex AI Example Store API.
85
+ * adk-js does not bundle the `vertexai` dependency the Python SDK relies
86
+ * on, so the caller supplies this client.
87
+ */
88
+ constructor(examplesStoreName: string, apiClient: ExampleStoreApiClient);
89
+ /**
90
+ * Retrieves relevant examples from the Vertex AI Example Store for the given
91
+ * query.
92
+ */
93
+ getExamples(query: string): Promise<Example[]>;
94
+ }