@google/adk 2.1.0 → 2.2.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 (143) 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/agents/llm_agent.js +15 -1
  4. package/dist/cjs/agents/processors/content_processor_utils.js +10 -2
  5. package/dist/cjs/agents/processors/nl_planning_processor.js +114 -0
  6. package/dist/cjs/artifacts/gcs_artifact_service.js +13 -7
  7. package/dist/cjs/auth/auth_credential.js +12 -2
  8. package/dist/cjs/code_executors/code_execution_utils.js +3 -3
  9. package/dist/cjs/common.js +45 -0
  10. package/dist/cjs/examples/example.js +92 -0
  11. package/dist/cjs/examples/example_util.js +28 -4
  12. package/dist/cjs/examples/index.js +39 -0
  13. package/dist/cjs/examples/vertex_ai_example_store.js +39 -0
  14. package/dist/cjs/index.js +46 -0
  15. package/dist/cjs/memory/vertex_ai_memory_bank_service.js +17 -5
  16. package/dist/cjs/models/base_llm.js +1 -6
  17. package/dist/cjs/models/chrome_prompt_llm.js +16 -2
  18. package/dist/cjs/models/chrome_prompt_utils.js +54 -2
  19. package/dist/cjs/models/gemini_llm_connection.js +5 -4
  20. package/dist/cjs/planners/base_planner.js +56 -0
  21. package/dist/cjs/planners/built_in_planner.js +85 -0
  22. package/dist/cjs/planners/plan_re_act_planner.js +172 -0
  23. package/dist/cjs/plugins/base_plugin.js +46 -61
  24. package/dist/cjs/tools/example_tool.js +1 -1
  25. package/dist/cjs/tools/mcp/mcp_session_manager.js +14 -8
  26. package/dist/cjs/tools/openapi_tool/auth/auth_helpers.js +281 -2
  27. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
  28. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +70 -0
  29. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +120 -0
  30. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -10
  31. package/dist/cjs/tools/openapi_tool/common/common.js +139 -0
  32. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
  33. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +73 -13
  34. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -34
  35. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +14 -2
  36. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +90 -28
  37. package/dist/cjs/tools/skill/skill_toolset.js +2 -0
  38. package/dist/cjs/tools/tool_context.js +41 -0
  39. package/dist/cjs/tools/webmcp/index.js +37 -0
  40. package/dist/cjs/tools/webmcp/webmcp_tool.js +156 -0
  41. package/dist/cjs/tools/webmcp/webmcp_toolset.js +116 -0
  42. package/dist/cjs/tools/webmcp/webmcp_types.js +50 -0
  43. package/dist/cjs/utils/case_utils.js +52 -2
  44. package/dist/cjs/utils/client_labels.js +67 -0
  45. package/dist/cjs/utils/gemini_schema_util.js +103 -3
  46. package/dist/cjs/utils/hash_utils.js +73 -0
  47. package/dist/cjs/utils/live_connection_utils.js +10 -9
  48. package/dist/cjs/utils/model_name.js +17 -2
  49. package/dist/cjs/utils/simple_zod_to_json.js +5 -0
  50. package/dist/cjs/version.js +1 -1
  51. package/dist/esm/a2a/agent_card.js +8 -0
  52. package/dist/esm/a2a/agent_executor.js +8 -3
  53. package/dist/esm/agents/llm_agent.js +18 -1
  54. package/dist/esm/agents/processors/content_processor_utils.js +10 -2
  55. package/dist/esm/agents/processors/nl_planning_processor.js +87 -0
  56. package/dist/esm/artifacts/gcs_artifact_service.js +13 -7
  57. package/dist/esm/auth/auth_credential.js +11 -1
  58. package/dist/esm/code_executors/code_execution_utils.js +3 -3
  59. package/dist/esm/common.js +38 -2
  60. package/dist/esm/examples/example.js +85 -0
  61. package/dist/esm/examples/example_util.js +25 -3
  62. package/dist/esm/examples/index.js +11 -0
  63. package/dist/esm/examples/vertex_ai_example_store.js +11 -0
  64. package/dist/esm/index.js +51 -1
  65. package/dist/esm/memory/vertex_ai_memory_bank_service.js +17 -5
  66. package/dist/esm/models/base_llm.js +2 -7
  67. package/dist/esm/models/chrome_prompt_llm.js +20 -3
  68. package/dist/esm/models/chrome_prompt_utils.js +51 -2
  69. package/dist/esm/models/gemini_llm_connection.js +6 -5
  70. package/dist/esm/planners/base_planner.js +28 -0
  71. package/dist/esm/planners/built_in_planner.js +57 -0
  72. package/dist/esm/planners/plan_re_act_planner.js +145 -0
  73. package/dist/esm/plugins/base_plugin.js +46 -61
  74. package/dist/esm/tools/example_tool.js +1 -1
  75. package/dist/esm/tools/mcp/mcp_session_manager.js +14 -8
  76. package/dist/esm/tools/openapi_tool/auth/auth_helpers.js +272 -1
  77. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js +15 -1
  78. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js +43 -0
  79. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +93 -0
  80. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js +10 -12
  81. package/dist/esm/tools/openapi_tool/common/common.js +112 -0
  82. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +11 -6
  83. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +80 -13
  84. package/dist/esm/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js +146 -33
  85. package/dist/esm/tools/openapi_tool/openapi_toolset.js +14 -2
  86. package/dist/esm/tools/openapi_tool/rest_api_tool.js +89 -28
  87. package/dist/esm/tools/skill/skill_toolset.js +2 -0
  88. package/dist/esm/tools/tool_context.js +15 -0
  89. package/dist/esm/tools/webmcp/index.js +10 -0
  90. package/dist/esm/tools/webmcp/webmcp_tool.js +131 -0
  91. package/dist/esm/tools/webmcp/webmcp_toolset.js +89 -0
  92. package/dist/esm/tools/webmcp/webmcp_types.js +22 -0
  93. package/dist/esm/utils/case_utils.js +49 -1
  94. package/dist/esm/utils/client_labels.js +65 -0
  95. package/dist/esm/utils/gemini_schema_util.js +102 -3
  96. package/dist/esm/utils/hash_utils.js +45 -0
  97. package/dist/esm/utils/live_connection_utils.js +11 -10
  98. package/dist/esm/utils/model_name.js +15 -2
  99. package/dist/esm/utils/simple_zod_to_json.js +5 -0
  100. package/dist/esm/version.js +1 -1
  101. package/dist/types/agents/llm_agent.d.ts +12 -1
  102. package/dist/types/agents/processors/nl_planning_processor.d.ts +30 -0
  103. package/dist/types/auth/auth_credential.d.ts +9 -0
  104. package/dist/types/common.d.ts +16 -4
  105. package/dist/types/examples/base_example_provider.d.ts +2 -2
  106. package/dist/types/examples/example.d.ts +75 -0
  107. package/dist/types/examples/example_util.d.ts +13 -2
  108. package/dist/types/examples/index.d.ts +18 -0
  109. package/dist/types/examples/vertex_ai_example_store.d.ts +7 -0
  110. package/dist/types/index.d.ts +12 -3
  111. package/dist/types/memory/memory_entry.d.ts +15 -0
  112. package/dist/types/memory/vertex_ai_memory_bank_service.d.ts +9 -0
  113. package/dist/types/models/chrome_prompt_utils.d.ts +29 -0
  114. package/dist/types/planners/base_planner.d.ts +50 -0
  115. package/dist/types/planners/built_in_planner.d.ts +53 -0
  116. package/dist/types/planners/plan_re_act_planner.d.ts +21 -0
  117. package/dist/types/plugins/base_plugin.d.ts +52 -52
  118. package/dist/types/skills/skill_registry.d.ts +8 -0
  119. package/dist/types/tools/openapi_tool/auth/auth_helpers.d.ts +110 -1
  120. package/dist/types/tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.d.ts +32 -2
  121. package/dist/types/tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.d.ts +35 -0
  122. package/dist/types/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.d.ts +54 -0
  123. package/dist/types/tools/openapi_tool/common/common.d.ts +60 -0
  124. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +7 -0
  125. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +56 -2
  126. package/dist/types/tools/openapi_tool/openapi_spec_parser/tool_auth_handler.d.ts +73 -5
  127. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +11 -0
  128. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +42 -8
  129. package/dist/types/tools/tool_context.d.ts +19 -0
  130. package/dist/types/tools/webmcp/index.d.ts +12 -0
  131. package/dist/types/tools/webmcp/webmcp_tool.d.ts +47 -0
  132. package/dist/types/tools/webmcp/webmcp_toolset.d.ts +67 -0
  133. package/dist/types/tools/webmcp/webmcp_types.d.ts +69 -0
  134. package/dist/types/utils/case_utils.d.ts +36 -0
  135. package/dist/types/utils/client_labels.d.ts +33 -0
  136. package/dist/types/utils/gemini_schema_util.d.ts +13 -0
  137. package/dist/types/utils/hash_utils.d.ts +25 -0
  138. package/dist/types/utils/logger.d.ts +10 -2
  139. package/dist/types/utils/model_name.d.ts +30 -2
  140. package/dist/types/version.d.ts +1 -1
  141. package/dist/web/index_web.js +112 -79
  142. package/dist/web/index_web.js.map +4 -4
  143. 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.0";
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';
@@ -90,7 +90,8 @@ export type { EventActions } from './events/event_actions.js';
90
90
  export { EventType, toStructuredEvents } from './events/structured_events.js';
91
91
  export type { ActivityEvent, CallCodeEvent, CodeResultEvent, ContentEvent, ErrorEvent, FinishedEvent, StructuredEvent, ThoughtEvent, ToolCallEvent, ToolConfirmationEvent, ToolResultEvent, } from './events/structured_events.js';
92
92
  export { BaseExampleProvider, isBaseExampleProvider, } from './examples/base_example_provider.js';
93
- export type { Example } from './examples/example.js';
93
+ export { VertexAiExampleStore } from './examples/example.js';
94
+ export type { Example, ExampleStoreApiClient, SearchExamplesRequest, SearchExamplesResponse, SearchExamplesResult, StoredContentsExample, } from './examples/example.js';
94
95
  export type { BaseMemoryService, SearchMemoryRequest, SearchMemoryResponse, } from './memory/base_memory_service.js';
95
96
  export { InMemoryMemoryService } from './memory/in_memory_memory_service.js';
96
97
  export type { MemoryEntry } from './memory/memory_entry.js';
@@ -108,6 +109,9 @@ export { LLMRegistry } from './models/registry.js';
108
109
  export type { BaseLlmType } from './models/registry.js';
109
110
  export { RoutedLlm } from './models/routed_llm.js';
110
111
  export type { LlmRouter } from './models/routed_llm.js';
112
+ export { BasePlanner, isBasePlanner } from './planners/base_planner.js';
113
+ export { BuiltInPlanner, isBuiltInPlanner } from './planners/built_in_planner.js';
114
+ export { PlanReActPlanner } from './planners/plan_re_act_planner.js';
111
115
  export { GLOBAL_SCOPE_KEY, REFLECT_AND_RETRY_RESPONSE_TYPE, ScopedFailureTracker, TrackingScope, resolveScopeKey, type PerItemFailuresCounter, type ToolFailureResponse, } from './plugins/_reflect_retry_utils.js';
112
116
  export { BasePlugin, ContextCompactionTrigger } from './plugins/base_plugin.js';
113
117
  export { GlobalInstructionPlugin } from './plugins/global_instruction_plugin.js';
@@ -155,15 +159,23 @@ export { LlamaIndexRetrieval } from './tools/retrieval/llama_index_retrieval.js'
155
159
  export type { LlamaIndexNode, LlamaIndexNodeWithScore, LlamaIndexRetrievalParams, LlamaIndexRetriever, } from './tools/retrieval/llama_index_retrieval.js';
156
160
  export { IntentMismatchError, ToolConfirmation, isIntentMismatchError, } from './tools/tool_confirmation.js';
157
161
  export type { IntentMismatchReason } from './tools/tool_confirmation.js';
162
+ export { CallbackContext, ToolContext } from './tools/tool_context.js';
158
163
  export { URL_CONTEXT, UrlContextTool } from './tools/url_context_tool.js';
159
164
  export { VertexAiSearchTool } from './tools/vertex_ai_search_tool.js';
160
165
  export type { DataStoreParams, SearchEngineParams, VertexAISearchConfig, VertexAISearchDataStoreSpec, VertexAiSearchToolParams, } from './tools/vertex_ai_search_tool.js';
161
166
  export { VertexRagRetrievalTool } from './tools/vertex_rag_retrieval_tool.js';
167
+ export { WebMCPTool } from './tools/webmcp/webmcp_tool.js';
168
+ export type { WebMCPToolParams } from './tools/webmcp/webmcp_tool.js';
169
+ export { WebMCPToolset } from './tools/webmcp/webmcp_toolset.js';
170
+ export type { WebMCPToolsetOptions } from './tools/webmcp/webmcp_toolset.js';
171
+ export { getModelContext, isWebMCPSupported, } from './tools/webmcp/webmcp_types.js';
172
+ export type { WebMCPDocument, WebMCPExecuteToolOptions, WebMCPGetToolsOptions, WebMCPModelContext, WebMCPRegisteredTool, WebMCPToolAnnotations, } from './tools/webmcp/webmcp_types.js';
162
173
  export { AsyncQueue } from './utils/async_queue.js';
174
+ export { renameReservedKeywords, toSnakeCaseName } from './utils/case_utils.js';
163
175
  export { getClientLabels, runWithClientLabel } from './utils/client_labels.js';
164
- export { LogLevel, getLogger, resetLogger, setLogLevel, setLogger, } from './utils/logger.js';
176
+ export { LogLevel, getLogger, logger, resetLogger, setLogLevel, setLogger, } from './utils/logger.js';
165
177
  export type { Logger } from './utils/logger.js';
166
- export { isGemini2OrAbove, isGemini3xFlashLive } from './utils/model_name.js';
178
+ export { isGemini2OrAbove, isGemini35LiveTranslate, isGemini3xFlashLive, isGemini3xLive, } from './utils/model_name.js';
167
179
  export type { SchemaLike } from './utils/schema.js';
168
180
  export { zodObjectToSchema } from './utils/simple_zod_to_json.js';
169
181
  export { Task } from './utils/task.js';
@@ -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
+ }
@@ -3,6 +3,7 @@
3
3
  * Copyright 2025 Google LLC
4
4
  * SPDX-License-Identifier: Apache-2.0
5
5
  */
6
+ import { Session } from '../sessions/session.js';
6
7
  import { BaseExampleProvider } from './base_example_provider.js';
7
8
  import { Example } from './example.js';
8
9
  /**
@@ -20,6 +21,15 @@ import { Example } from './example.js';
20
21
  * suitable for inclusion in a system instruction.
21
22
  */
22
23
  export declare function convertExamplesToText(examples: Example[], model?: string): string;
24
+ /**
25
+ * Gets the latest message from the user.
26
+ *
27
+ * @param session - The session to inspect.
28
+ * @returns The latest message from the user. If not found, returns an empty
29
+ * string.
30
+ */
31
+ export declare function getLatestMessageFromUser(session: Session): string;
32
+ export declare const _getLatestMessageFromUser: typeof getLatestMessageFromUser;
23
33
  /**
24
34
  * Builds the few-shot portion of a system instruction from a list of examples
25
35
  * or a {@link BaseExampleProvider}.
@@ -31,8 +41,9 @@ export declare function convertExamplesToText(examples: Example[], model?: strin
31
41
  * when `examples` is a provider. Ignored when `examples` is an array.
32
42
  * @param model - Optional model name forwarded to
33
43
  * {@link convertExamplesToText} to select the function-call fence style.
34
- * @returns A formatted string ready to be appended to a system instruction.
44
+ * @returns A promise resolving to a formatted string ready to be appended to a
45
+ * system instruction.
35
46
  * @throws {Error} When `examples` is neither an array nor a
36
47
  * {@link BaseExampleProvider}.
37
48
  */
38
- export declare function buildExampleSi(examples: Example[] | BaseExampleProvider, query: string, model?: string): string;
49
+ export declare function buildExampleSi(examples: Example[] | BaseExampleProvider, query: string, model?: string): Promise<string>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ /**
7
+ * Examples subsystem barrel export.
8
+ *
9
+ * Re-exports all `examples` modules (`Example`, `BaseExampleProvider`,
10
+ * `VertexAiExampleStore`, `example_util`) alongside compatibility references
11
+ * for `BaseCodeExecutor`, `BuiltInCodeExecutor`, `CodeExecutorContext`,
12
+ * `ContainerCodeExecutor`, `UnsafeLocalCodeExecutor`, `VertexAiCodeExecutor`,
13
+ * and `code_execution_utils`.
14
+ */
15
+ export * from './base_example_provider.js';
16
+ export * from './example.js';
17
+ export * from './example_util.js';
18
+ export * from './vertex_ai_example_store.js';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2025 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export { VertexAiExampleStore } from './example.js';
7
+ export type { ExampleStoreApiClient, SearchExamplesRequest, SearchExamplesResponse, SearchExamplesResult, StoredContentsExample, } from './example.js';
@@ -29,14 +29,23 @@ export type { GCPSkillRegistryOptions } from './skills/gcp_skill_registry.js';
29
29
  export { loadAllSkillsInDir, loadSkillFromDir, loadSkillFromZipBuffer, validateSkillDir, } from './skills/loader.js';
30
30
  export { LOAD_WEB_PAGE, loadWebPage } from './tools/load_web_page.js';
31
31
  export type { LoadWebPageOptions } from './tools/load_web_page.js';
32
+ export { credentialToParam, dictToAuthScheme, INTERNAL_AUTH_PREFIX, openidDictToSchemeCredential, openidUrlToSchemeCredential, serviceAccountDictToSchemeCredential, serviceAccountSchemeCredential, tokenToSchemeCredential, } from './tools/openapi_tool/auth/auth_helpers.js';
33
+ export { AutoAuthCredentialExchanger } from './tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js';
34
+ export type { CustomCredentialExchangers } from './tools/openapi_tool/auth/credential_exchangers/auto_auth_credential_exchanger.js';
35
+ export { AuthCredentialMissingError, BaseAuthCredentialExchanger, } from './tools/openapi_tool/auth/credential_exchangers/base_auth_credential_exchanger.js';
36
+ export { exchangeCredential, OAuth2BearerExchanger, } from './tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js';
37
+ export { ServiceAccountCredentialExchanger } from './tools/openapi_tool/auth/credential_exchangers/service_account_exchanger.js';
38
+ export { createApiParameter, generateParamDoc, generateReturnDoc, getTypeHint, } from './tools/openapi_tool/common/common.js';
39
+ export type { ApiParameterInit } from './tools/openapi_tool/common/common.js';
32
40
  export { OpenApiSpecParser } from './tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js';
33
41
  export type { OperationEndpoint, ParsedOperation, } from './tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js';
34
42
  export { OperationParser } from './tools/openapi_tool/openapi_spec_parser/operation_parser.js';
35
43
  export type { ApiParameter } from './tools/openapi_tool/openapi_spec_parser/operation_parser.js';
36
- export { ToolAuthHandler } from './tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js';
37
- export type { AuthPreparationResult } from './tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js';
44
+ export { ToolAuthHandler, ToolContextCredentialStore, } from './tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js';
45
+ export type { AuthPreparationResult, ToolAuthHandlerOptions, } from './tools/openapi_tool/openapi_spec_parser/tool_auth_handler.js';
38
46
  export { OpenAPIToolset } from './tools/openapi_tool/openapi_toolset.js';
39
- export { createRestApiTool, RestApiTool, } from './tools/openapi_tool/rest_api_tool.js';
47
+ export { createRestApiTool, createRestApiToolFromJson, RestApiTool, } from './tools/openapi_tool/rest_api_tool.js';
48
+ export type { ParsedOperationInput } from './tools/openapi_tool/rest_api_tool.js';
40
49
  export { FilesRetrieval } from './tools/retrieval/files_retrieval.js';
41
50
  export type { FilesRetrievalConstructorParams, FilesRetrievalParams, } from './tools/retrieval/files_retrieval.js';
42
51
  export { LoadSkillResourceTool } from './tools/skill/load_skill_resource_tool.js';
@@ -15,6 +15,21 @@ export interface MemoryEntry {
15
15
  * The content of the memory entry, as originally produced during a session.
16
16
  */
17
17
  content: Content;
18
+ /**
19
+ * The unique identifier of the memory.
20
+ *
21
+ * When set on an entry passed to `addMemory`, a service that supports
22
+ * caller-chosen identifiers uses it as the last component of the created
23
+ * memory's resource name instead of generating one.
24
+ */
25
+ id?: string;
26
+ /**
27
+ * Optional custom metadata associated with the memory.
28
+ *
29
+ * A service that also accepts request-level metadata merges this on top of
30
+ * it, so a key declared here wins over the same key on the request.
31
+ */
32
+ customMetadata?: Record<string, unknown>;
18
33
  /**
19
34
  * The author of the memory. Common values are `'user'` and `'model'`, but
20
35
  * this can also be the name of an agent when the content was produced by a
@@ -38,6 +38,15 @@ export declare class VertexAiMemoryBankService implements BaseMemoryService {
38
38
  }): Promise<void>;
39
39
  /**
40
40
  * Adds explicit memory items using Vertex Memory Bank.
41
+ *
42
+ * When a `MemoryEntry.id` is set, it is forwarded as the `memoryId` of the
43
+ * created memory, so the caller picks the last component of the memory
44
+ * resource name instead of letting the service generate one. An explicit
45
+ * `customMetadata['memoryId']` takes precedence over `MemoryEntry.id`.
46
+ *
47
+ * The id is forwarded unvalidated, so an id the API rejects fails the create
48
+ * call. Vertex accepts up to 63 characters from `[a-z0-9-]`, starting with a
49
+ * letter and ending with a letter or number.
41
50
  */
42
51
  addMemory(request: {
43
52
  appName: string;