@google/adk 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. package/dist/cjs/agents/agent_engine_client.js +172 -0
  2. package/dist/cjs/agents/base_agent.js +20 -4
  3. package/dist/cjs/agents/functions.js +28 -0
  4. package/dist/cjs/agents/instructions.js +2 -1
  5. package/dist/cjs/agents/llm_agent.js +19 -6
  6. package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
  7. package/dist/cjs/agents/processors/code_execution_request_processor.js +8 -0
  8. package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
  9. package/dist/cjs/agents/processors/content_request_processor.js +34 -2
  10. package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
  11. package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
  12. package/dist/cjs/cli/utils/logs.js +6 -6
  13. package/dist/cjs/code_executors/container_code_executor.js +27 -16
  14. package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
  15. package/dist/cjs/common.js +9 -20
  16. package/dist/cjs/errors/input_validation_error.js +3 -2
  17. package/dist/cjs/index.js +9 -2
  18. package/dist/cjs/plugins/base_plugin.js +13 -23
  19. package/dist/cjs/sessions/base_session_service.js +14 -8
  20. package/dist/cjs/sessions/database_session_service.js +50 -28
  21. package/dist/cjs/sessions/stale_session_error.js +59 -0
  22. package/dist/cjs/skills/loader.js +52 -18
  23. package/dist/cjs/telemetry/setup.js +0 -1
  24. package/dist/cjs/telemetry/tracing.js +53 -10
  25. package/dist/cjs/tools/apihub_tool/apihub_toolset.js +18 -23
  26. package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +120 -42
  27. package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +163 -95
  28. package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +13 -9
  29. package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -0
  30. package/dist/cjs/tools/google_api_tool/google_api_tool.js +4 -1
  31. package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
  32. package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
  33. package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +2 -2
  34. package/dist/cjs/tools/google_api_tool/index.js +20 -23
  35. package/dist/cjs/tools/load_artifacts_tool.js +12 -6
  36. package/dist/cjs/tools/load_memory_tool.js +12 -10
  37. package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
  38. package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
  39. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
  40. package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
  41. package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
  42. package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
  43. package/dist/cjs/tools/toolbox_toolset.js +174 -0
  44. package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
  45. package/dist/cjs/utils/client_labels.js +19 -2
  46. package/dist/cjs/utils/failover_utils.js +1 -1
  47. package/dist/cjs/utils/gemini_schema_util.js +24 -6
  48. package/dist/cjs/utils/logger_node.js +4 -0
  49. package/dist/cjs/utils/output_schema_utils.js +5 -2
  50. package/dist/cjs/utils/task.js +1 -1
  51. package/dist/cjs/version.js +1 -1
  52. package/dist/esm/agents/agent_engine_client.js +144 -0
  53. package/dist/esm/agents/base_agent.js +20 -4
  54. package/dist/esm/agents/functions.js +28 -0
  55. package/dist/esm/agents/instructions.js +2 -1
  56. package/dist/esm/agents/llm_agent.js +19 -6
  57. package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
  58. package/dist/esm/agents/processors/code_execution_request_processor.js +8 -0
  59. package/dist/esm/agents/processors/content_processor_utils.js +38 -10
  60. package/dist/esm/agents/processors/content_request_processor.js +34 -2
  61. package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
  62. package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
  63. package/dist/esm/cli/utils/logs.js +4 -4
  64. package/dist/esm/code_executors/container_code_executor.js +27 -16
  65. package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
  66. package/dist/esm/common.js +10 -13
  67. package/dist/esm/errors/input_validation_error.js +3 -2
  68. package/dist/esm/index.js +17 -3
  69. package/dist/esm/plugins/base_plugin.js +13 -23
  70. package/dist/esm/sessions/base_session_service.js +12 -7
  71. package/dist/esm/sessions/database_session_service.js +49 -28
  72. package/dist/esm/sessions/stale_session_error.js +31 -0
  73. package/dist/esm/skills/loader.js +51 -17
  74. package/dist/esm/telemetry/setup.js +1 -2
  75. package/dist/esm/telemetry/tracing.js +57 -11
  76. package/dist/esm/tools/apihub_tool/apihub_toolset.js +17 -22
  77. package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +124 -42
  78. package/dist/esm/tools/application_integration_tool/clients/connections_client.js +163 -95
  79. package/dist/esm/tools/application_integration_tool/clients/integration_client.js +13 -9
  80. package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -0
  81. package/dist/esm/tools/google_api_tool/google_api_tool.js +4 -1
  82. package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
  83. package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
  84. package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +2 -2
  85. package/dist/esm/tools/google_api_tool/index.js +18 -20
  86. package/dist/esm/tools/load_artifacts_tool.js +10 -5
  87. package/dist/esm/tools/load_memory_tool.js +12 -10
  88. package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
  89. package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
  90. package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
  91. package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
  92. package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
  93. package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
  94. package/dist/esm/tools/toolbox_toolset.js +148 -0
  95. package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
  96. package/dist/esm/utils/client_labels.js +19 -2
  97. package/dist/esm/utils/failover_utils.js +1 -1
  98. package/dist/esm/utils/gemini_schema_util.js +23 -6
  99. package/dist/esm/utils/logger_node.js +4 -0
  100. package/dist/esm/utils/output_schema_utils.js +5 -2
  101. package/dist/esm/utils/task.js +1 -1
  102. package/dist/esm/version.js +1 -1
  103. package/dist/types/agents/agent_engine_client.d.ts +37 -0
  104. package/dist/types/agents/base_agent.d.ts +12 -0
  105. package/dist/types/agents/llm_agent.d.ts +5 -1
  106. package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
  107. package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
  108. package/dist/types/cli/utils/logs.d.ts +1 -1
  109. package/dist/types/code_executors/container_code_executor.d.ts +17 -5
  110. package/dist/types/common.d.ts +5 -9
  111. package/dist/types/errors/input_validation_error.d.ts +2 -1
  112. package/dist/types/index.d.ts +4 -2
  113. package/dist/types/plugins/base_plugin.d.ts +0 -10
  114. package/dist/types/sessions/base_session_service.d.ts +5 -0
  115. package/dist/types/sessions/database_session_service.d.ts +17 -1
  116. package/dist/types/sessions/stale_session_error.d.ts +21 -0
  117. package/dist/types/skills/loader.d.ts +3 -2
  118. package/dist/types/telemetry/tracing.d.ts +17 -3
  119. package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +14 -21
  120. package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +32 -9
  121. package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +22 -8
  122. package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +3 -3
  123. package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
  124. package/dist/types/tools/base_toolset.d.ts +6 -5
  125. package/dist/types/tools/google_api_tool/google_api_tool.d.ts +10 -3
  126. package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
  127. package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
  128. package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +5 -4
  129. package/dist/types/tools/google_api_tool/index.d.ts +4 -5
  130. package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
  131. package/dist/types/tools/load_memory_tool.d.ts +23 -1
  132. package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
  133. package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
  134. package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
  135. package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
  136. package/dist/types/tools/toolbox_toolset.d.ts +159 -0
  137. package/dist/types/utils/client_labels.d.ts +2 -1
  138. package/dist/types/utils/gemini_schema_util.d.ts +8 -0
  139. package/dist/types/utils/output_schema_utils.d.ts +3 -2
  140. package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
  141. package/dist/types/version.d.ts +1 -1
  142. package/dist/web/index_web.js +74 -66
  143. package/dist/web/index_web.js.map +4 -4
  144. package/package.json +34 -27
  145. package/dist/cjs/agents/remote_agent.js +0 -187
  146. package/dist/cjs/tools/crewai_tool.js +0 -132
  147. package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +0 -226
  148. package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +0 -58
  149. package/dist/cjs/tools/langchain_tool.js +0 -172
  150. package/dist/cjs/tools/toolbox_tool.js +0 -108
  151. package/dist/esm/agents/remote_agent.js +0 -164
  152. package/dist/esm/tools/crewai_tool.js +0 -107
  153. package/dist/esm/tools/google_api_tool/google_api_tool_set.js +0 -188
  154. package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +0 -24
  155. package/dist/esm/tools/langchain_tool.js +0 -148
  156. package/dist/esm/tools/toolbox_tool.js +0 -80
  157. package/dist/types/agents/remote_agent.d.ts +0 -68
  158. package/dist/types/tools/crewai_tool.d.ts +0 -85
  159. package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +0 -78
  160. package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +0 -33
  161. package/dist/types/tools/langchain_tool.d.ts +0 -103
  162. package/dist/types/tools/toolbox_tool.d.ts +0 -73
@@ -29,15 +29,27 @@ const VALID_SCHEMA_TYPES = /* @__PURE__ */ new Set([
29
29
  "string"
30
30
  ]);
31
31
  let OpenApiSpecParser = class {
32
+ /**
33
+ * @param options.preservePropertyNames Keeps the original parameter and
34
+ * function names instead of converting them to snake_case.
35
+ * @param options.unconstrainedObjectBodyAsParameter Emits a whole-body
36
+ * parameter named `body` when an object request body schema has no
37
+ * properties. Defaults to `false`.
38
+ * @deprecated Retained for backwards compatibility; empty object schemas
39
+ * produce no parameters by default. This option will be removed in a
40
+ * future release.
41
+ */
32
42
  constructor(options = {}) {
33
- var _a;
43
+ var _a, _b;
34
44
  this.preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
45
+ this.unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
35
46
  }
36
47
  parse(openapiSpec) {
37
48
  const resolvedSpec = resolveReferences(openapiSpec);
38
49
  const sanitizedSpec = sanitizeSchemaTypes(resolvedSpec);
39
50
  return collectOperations(sanitizedSpec, {
40
- preservePropertyNames: this.preservePropertyNames
51
+ preservePropertyNames: this.preservePropertyNames,
52
+ unconstrainedObjectBodyAsParameter: this.unconstrainedObjectBodyAsParameter
41
53
  });
42
54
  }
43
55
  };
@@ -172,17 +184,18 @@ function resolveServerUrl(server) {
172
184
  }
173
185
  __name(resolveServerUrl, "resolveServerUrl");
174
186
  function collectOperations(spec, options = {}) {
175
- var _a, _b, _c;
187
+ var _a, _b, _c, _d;
176
188
  const preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
189
+ const unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
177
190
  const operations = [];
178
- const server = (_b = spec.servers) == null ? void 0 : _b[0];
191
+ const server = (_c = spec.servers) == null ? void 0 : _c[0];
179
192
  const baseUrl = server ? resolveServerUrl(server) : "";
180
193
  const globalSecurity = spec.security || [];
181
194
  let globalSchemeName;
182
195
  if (globalSecurity.length > 0) {
183
196
  globalSchemeName = Object.keys(globalSecurity[0])[0];
184
197
  }
185
- const authSchemes = ((_c = spec.components) == null ? void 0 : _c.securitySchemes) || {};
198
+ const authSchemes = ((_d = spec.components) == null ? void 0 : _d.securitySchemes) || {};
186
199
  for (const [path, pathItem] of Object.entries(spec.paths || {})) {
187
200
  if (!pathItem) continue;
188
201
  const methods = [
@@ -205,7 +218,8 @@ function collectOperations(spec, options = {}) {
205
218
  operation.operationId = toSnakeCaseName(`${path}_${method}`);
206
219
  }
207
220
  const parser = new OperationParser(operation, {
208
- preservePropertyNames
221
+ preservePropertyNames,
222
+ unconstrainedObjectBodyAsParameter
209
223
  });
210
224
  let authSchemeName;
211
225
  if (operation.security && operation.security.length > 0) {
@@ -34,13 +34,20 @@ let OperationParser = class {
34
34
  * function names instead of converting them to snake_case.
35
35
  * @param options.shouldParse Whether to parse the operation during
36
36
  * construction. Defaults to `true`.
37
+ * @param options.unconstrainedObjectBodyAsParameter Emits a whole-body
38
+ * parameter named `body` when an object request body schema has no
39
+ * properties. Defaults to `false`.
40
+ * @deprecated Retained for backwards compatibility; empty object schemas
41
+ * produce no parameters by default. This option will be removed in a
42
+ * future release.
37
43
  */
38
44
  constructor(operation, options = {}) {
39
45
  this.params = [];
40
- var _a, _b;
46
+ var _a, _b, _c;
41
47
  this.operation = typeof operation === "string" ? JSON.parse(operation) : operation;
42
48
  this.preservePropertyNames = (_a = options.preservePropertyNames) != null ? _a : false;
43
- if ((_b = options.shouldParse) != null ? _b : true) {
49
+ this.unconstrainedObjectBodyAsParameter = (_b = options.unconstrainedObjectBodyAsParameter) != null ? _b : false;
50
+ if ((_c = options.shouldParse) != null ? _c : true) {
44
51
  this.processOperationParameters();
45
52
  this.processRequestBody();
46
53
  this.returnValue = this.processReturnValue();
@@ -60,6 +67,7 @@ let OperationParser = class {
60
67
  return renameReservedKeywords(toSnakeCaseName(originalName));
61
68
  }
62
69
  processOperationParameters() {
70
+ var _a;
63
71
  const parameters = this.operation.parameters || [];
64
72
  for (const param of parameters) {
65
73
  if ("name" in param) {
@@ -70,9 +78,12 @@ let OperationParser = class {
70
78
  this.params.push({
71
79
  originalName,
72
80
  paramLocation: location,
73
- paramSchema: schema,
81
+ paramSchema: {
82
+ ...schema,
83
+ description: schema.description || description || void 0
84
+ },
74
85
  description,
75
- required: param.required || false,
86
+ required: (_a = param.required) != null ? _a : false,
76
87
  name: this.getParamName(originalName)
77
88
  });
78
89
  }
@@ -108,7 +119,7 @@ let OperationParser = class {
108
119
  });
109
120
  }
110
121
  }
111
- } else {
122
+ } else if (this.unconstrainedObjectBodyAsParameter) {
112
123
  this.params.push({
113
124
  originalName: "",
114
125
  paramLocation: "body",
@@ -129,7 +140,7 @@ let OperationParser = class {
129
140
  });
130
141
  } else {
131
142
  this.params.push({
132
- originalName: "body",
143
+ originalName: "",
133
144
  paramLocation: "body",
134
145
  paramSchema: schema,
135
146
  description,
@@ -16,7 +16,7 @@ var __decorateClass = (decorators, target, key, kind) => {
16
16
  * Copyright 2026 Google LLC
17
17
  * SPDX-License-Identifier: Apache-2.0
18
18
  */
19
- import yaml from "js-yaml";
19
+ import * as yaml from "js-yaml";
20
20
  import { experimental } from "../../utils/experimental.js";
21
21
  import { logger } from "../../utils/logger.js";
22
22
  import { BaseToolset } from "../base_toolset.js";
@@ -40,7 +40,8 @@ let OpenAPIToolset = class extends BaseToolset {
40
40
  throw new Error("Either specDict or specStr must be provided.");
41
41
  }
42
42
  const parser = new OpenApiSpecParser({
43
- preservePropertyNames: options.preservePropertyNames
43
+ preservePropertyNames: options.preservePropertyNames,
44
+ unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
44
45
  });
45
46
  const parsedOperations = parser.parse(spec);
46
47
  for (const op of parsedOperations) {
@@ -61,7 +62,8 @@ let OpenAPIToolset = class extends BaseToolset {
61
62
  {
62
63
  preservePropertyNames: options.preservePropertyNames,
63
64
  headerProvider: options.headerProvider,
64
- credentialKey: options.credentialKey
65
+ credentialKey: options.credentialKey,
66
+ unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
65
67
  }
66
68
  );
67
69
  this.tools.push(tool);
@@ -76,15 +78,7 @@ let OpenAPIToolset = class extends BaseToolset {
76
78
  }
77
79
  }
78
80
  async getTools(context) {
79
- return this.tools.filter((tool) => {
80
- if (Array.isArray(this.toolFilter) && this.toolFilter.length > 0) {
81
- return this.toolFilter.includes(tool.name);
82
- }
83
- if (context) {
84
- return this.isToolSelected(tool, context);
85
- }
86
- return true;
87
- });
81
+ return this.tools.filter((tool) => this.isToolSelected(tool, context));
88
82
  }
89
83
  getTool(toolName) {
90
84
  return this.tools.find((tool) => tool.name === toolName);
@@ -176,6 +176,22 @@ function encodePathParamValue(name, value) {
176
176
  return encodeURIComponent(value);
177
177
  }
178
178
  __name(encodePathParamValue, "encodePathParamValue");
179
+ function serializeQueryValue(value) {
180
+ return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
181
+ }
182
+ __name(serializeQueryValue, "serializeQueryValue");
183
+ function appendQueryParam(queryParams, name, value) {
184
+ if (!Array.isArray(value)) {
185
+ queryParams.append(name, serializeQueryValue(value));
186
+ return;
187
+ }
188
+ for (const item of value) {
189
+ if (item !== void 0 && item !== null) {
190
+ queryParams.append(name, serializeQueryValue(item));
191
+ }
192
+ }
193
+ }
194
+ __name(appendQueryParam, "appendQueryParam");
179
195
  function prepareRequestParams(endpoint, parameters, args) {
180
196
  const headers = {};
181
197
  const queryParams = new URLSearchParams();
@@ -196,7 +212,7 @@ function prepareRequestParams(endpoint, parameters, args) {
196
212
  );
197
213
  } else if (location === "query") {
198
214
  if (argValue !== void 0 && argValue !== null && argValue !== "") {
199
- queryParams.append(originalName, String(argValue));
215
+ appendQueryParam(queryParams, originalName, argValue);
200
216
  }
201
217
  } else if (location === "header") {
202
218
  headers[originalName] = String(argValue);
@@ -0,0 +1,148 @@
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
+ var _a, _b;
11
+ import { isBaseTool } from "./base_tool.js";
12
+ import { BaseToolset } from "./base_toolset.js";
13
+ import {
14
+ FunctionTool
15
+ } from "./function_tool.js";
16
+ const TOOLBOX_TOOLSET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
17
+ "google.adk.toolboxToolset"
18
+ );
19
+ function isToolboxToolset(obj) {
20
+ return typeof obj === "object" && obj !== null && TOOLBOX_TOOLSET_SIGNATURE_SYMBOL in obj && obj[TOOLBOX_TOOLSET_SIGNATURE_SYMBOL] === true;
21
+ }
22
+ __name(isToolboxToolset, "isToolboxToolset");
23
+ function createUnconfiguredToolboxToolsetClient(serverUrl) {
24
+ const throwMissingClient = /* @__PURE__ */ __name(() => {
25
+ throw new Error(
26
+ `ToolboxToolset requires a ToolboxToolsetClientLike instance (for endpoint "${serverUrl}"). Pass {serverUrl, client} to the ToolboxToolset constructor.`
27
+ );
28
+ }, "throwMissingClient");
29
+ return {
30
+ loadTool: throwMissingClient,
31
+ loadToolset: throwMissingClient,
32
+ close: /* @__PURE__ */ __name(() => {
33
+ }, "close")
34
+ };
35
+ }
36
+ __name(createUnconfiguredToolboxToolsetClient, "createUnconfiguredToolboxToolsetClient");
37
+ function isToolOptionsObject(value) {
38
+ return typeof value === "object" && value !== null && "execute" in value && typeof value.execute === "function";
39
+ }
40
+ __name(isToolOptionsObject, "isToolOptionsObject");
41
+ function wrapLoadedTool(rawTool, prefix) {
42
+ var _a2;
43
+ if (isBaseTool(rawTool)) {
44
+ if (!prefix) {
45
+ return rawTool;
46
+ }
47
+ return Object.assign(
48
+ Object.create(Object.getPrototypeOf(rawTool)),
49
+ rawTool,
50
+ { name: `${prefix}_${rawTool.name}` }
51
+ );
52
+ }
53
+ if (typeof rawTool === "function") {
54
+ const fn = rawTool;
55
+ const baseName = fn.name || "toolbox_tool";
56
+ const name = prefix ? `${prefix}_${baseName}` : baseName;
57
+ const description = (_a2 = fn.description) != null ? _a2 : "";
58
+ return new FunctionTool({
59
+ name,
60
+ description,
61
+ execute: fn
62
+ });
63
+ }
64
+ if (isToolOptionsObject(rawTool)) {
65
+ const baseTool = new FunctionTool(rawTool);
66
+ if (!prefix) {
67
+ return baseTool;
68
+ }
69
+ return new FunctionTool({
70
+ ...rawTool,
71
+ name: `${prefix}_${baseTool.name}`
72
+ });
73
+ }
74
+ throw new TypeError(
75
+ "Unsupported Toolbox tool shape: expected a BaseTool, ToolOptions object, or function."
76
+ );
77
+ }
78
+ __name(wrapLoadedTool, "wrapLoadedTool");
79
+ const _ToolboxToolset = class _ToolboxToolset extends (_b = BaseToolset, _a = TOOLBOX_TOOLSET_SIGNATURE_SYMBOL, _b) {
80
+ constructor(serverUrlOrOptions, extraOptions) {
81
+ var _a2, _b2, _c, _d;
82
+ const options = typeof serverUrlOrOptions === "string" ? { serverUrl: serverUrlOrOptions, ...extraOptions } : serverUrlOrOptions;
83
+ if ((!options.toolNames || options.toolNames.length === 0) && !options.toolsetName) {
84
+ throw new Error("toolNames and toolsetName cannot both be undefined.");
85
+ }
86
+ super((_a2 = options.toolFilter) != null ? _a2 : [], options.prefix);
87
+ /** A unique symbol to identify ADK ToolboxToolset class. */
88
+ this[_a] = true;
89
+ this.serverUrl = options.serverUrl;
90
+ this.toolsetName = options.toolsetName;
91
+ this.toolNames = options.toolNames;
92
+ this.authTokenGetters = (_b2 = options.authTokenGetters) != null ? _b2 : {};
93
+ this.boundParams = (_c = options.boundParams) != null ? _c : {};
94
+ this.toolboxClient = (_d = options.client) != null ? _d : createUnconfiguredToolboxToolsetClient(this.serverUrl);
95
+ }
96
+ /**
97
+ * Loads the configured toolset and/or individual tools from the Toolbox
98
+ * client and returns the selected {@link BaseTool} instances.
99
+ */
100
+ async getTools(context) {
101
+ var _a2, _b2, _c, _d, _e, _f;
102
+ const loadOptions = {
103
+ authTokenGetters: this.authTokenGetters,
104
+ boundParams: this.boundParams
105
+ };
106
+ const tools = [];
107
+ if (this.toolsetName) {
108
+ const loader = (_c = (_a2 = this.toolboxClient.loadToolset) == null ? void 0 : _a2.bind(this.toolboxClient)) != null ? _c : (_b2 = this.toolboxClient.load_toolset) == null ? void 0 : _b2.bind(this.toolboxClient);
109
+ if (!loader) {
110
+ throw new Error(
111
+ "ToolboxClient does not implement loadToolset or load_toolset."
112
+ );
113
+ }
114
+ const loadedToolset = await loader(this.toolsetName, loadOptions);
115
+ for (const rawTool of loadedToolset) {
116
+ tools.push(wrapLoadedTool(rawTool, this.prefix));
117
+ }
118
+ }
119
+ if (this.toolNames && this.toolNames.length > 0) {
120
+ const loader = (_f = (_d = this.toolboxClient.loadTool) == null ? void 0 : _d.bind(this.toolboxClient)) != null ? _f : (_e = this.toolboxClient.load_tool) == null ? void 0 : _e.bind(this.toolboxClient);
121
+ if (!loader) {
122
+ throw new Error(
123
+ "ToolboxClient does not implement loadTool or load_tool."
124
+ );
125
+ }
126
+ const loadedSingleTools = await Promise.all(
127
+ this.toolNames.map((toolName) => loader(toolName, loadOptions))
128
+ );
129
+ for (const rawTool of loadedSingleTools) {
130
+ tools.push(wrapLoadedTool(rawTool, this.prefix));
131
+ }
132
+ }
133
+ return tools.filter((tool) => this.isToolSelected(tool, context));
134
+ }
135
+ /**
136
+ * Closes the underlying Toolbox client.
137
+ */
138
+ async close() {
139
+ var _a2, _b2;
140
+ await ((_b2 = (_a2 = this.toolboxClient).close) == null ? void 0 : _b2.call(_a2));
141
+ }
142
+ };
143
+ __name(_ToolboxToolset, "ToolboxToolset");
144
+ let ToolboxToolset = _ToolboxToolset;
145
+ export {
146
+ ToolboxToolset,
147
+ isToolboxToolset
148
+ };
@@ -41,20 +41,7 @@ const _WebMCPToolset = class _WebMCPToolset extends BaseToolset {
41
41
  document: this.doc
42
42
  })
43
43
  );
44
- const filter = this.toolFilter;
45
- if (!filter || Array.isArray(filter) && filter.length === 0) {
46
- return tools;
47
- }
48
- if (Array.isArray(filter)) {
49
- return tools.filter((tool) => filter.includes(tool.name));
50
- }
51
- if (context) {
52
- return tools.filter((tool) => filter(tool, context));
53
- }
54
- logger.warn(
55
- "WebMCPToolset: a ToolPredicate toolFilter was provided but getTools() was called without a ReadonlyContext. The filter will not be applied."
56
- );
57
- return tools;
44
+ return tools.filter((tool) => this.isToolSelected(tool, context));
58
45
  }
59
46
  /**
60
47
  * Subscribes to the WebMCP `toolchange` event, which fires when the page
@@ -99,7 +99,8 @@ function headerEntries(headers) {
99
99
  __name(headerEntries, "headerEntries");
100
100
  function mergeTrackingHeaders(headers) {
101
101
  var _a, _b;
102
- const merged = {};
102
+ const otherHeaders = new Headers();
103
+ const originalNames = /* @__PURE__ */ new Map();
103
104
  const callerValues = /* @__PURE__ */ new Map();
104
105
  for (const [name, value] of headerEntries(headers)) {
105
106
  const lowerName = name.toLowerCase();
@@ -109,9 +110,25 @@ function mergeTrackingHeaders(headers) {
109
110
  value
110
111
  ]);
111
112
  } else {
112
- merged[name] = value;
113
+ if (!originalNames.has(lowerName)) {
114
+ originalNames.set(lowerName, name);
115
+ }
116
+ otherHeaders.append(name, value);
113
117
  }
114
118
  }
119
+ const normalizedEntries = [];
120
+ otherHeaders.forEach((value, name) => {
121
+ normalizedEntries.push([name, value]);
122
+ });
123
+ const merged = Object.fromEntries(
124
+ normalizedEntries.map(([name, value]) => {
125
+ var _a2;
126
+ return [
127
+ (_a2 = originalNames.get(name)) != null ? _a2 : name,
128
+ value
129
+ ];
130
+ })
131
+ );
115
132
  for (const [name, trackingValue] of Object.entries(getTrackingHeaders())) {
116
133
  const tokens = trackingValue.split(" ");
117
134
  for (const value of (_b = callerValues.get(name)) != null ? _b : []) {
@@ -21,9 +21,9 @@ async function* runWithRouting(items, context, router, runFn) {
21
21
  }
22
22
  const triedKeys = /* @__PURE__ */ new Set([selectedKey]);
23
23
  while (true) {
24
- const generatorOrPromise = runFn(selectedItem);
25
24
  let firstYielded = false;
26
25
  try {
26
+ const generatorOrPromise = runFn(selectedItem);
27
27
  if (isAsyncGenerator(generatorOrPromise)) {
28
28
  for await (const result2 of generatorOrPromise) {
29
29
  yield result2;
@@ -177,7 +177,6 @@ const GEMINI_REJECTED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
177
177
  "default",
178
178
  "format"
179
179
  ]);
180
- const EMPTY_OBJECT_PLACEHOLDER = "dummy_DO_NOT_GENERATE";
181
180
  function toGeminiSchemaField(key) {
182
181
  return toSnakeCaseName(key).replace(
183
182
  /_([a-z0-9])/g,
@@ -189,6 +188,23 @@ function isPlainObject(value) {
189
188
  return typeof value === "object" && value !== null && !Array.isArray(value);
190
189
  }
191
190
  __name(isPlainObject, "isPlainObject");
191
+ function normalizeJsonSchemaType(jsonSchemaType) {
192
+ if (typeof jsonSchemaType === "string") {
193
+ if (jsonSchemaType === "null") {
194
+ return [void 0, true];
195
+ }
196
+ return [jsonSchemaType, false];
197
+ }
198
+ if (Array.isArray(jsonSchemaType)) {
199
+ const nullable = jsonSchemaType.includes("null");
200
+ const nonNullTypes = jsonSchemaType.filter(
201
+ (t) => typeof t === "string" && t !== "null"
202
+ );
203
+ return [nonNullTypes[0], nullable];
204
+ }
205
+ return [void 0, false];
206
+ }
207
+ __name(normalizeJsonSchemaType, "normalizeJsonSchemaType");
192
208
  function convertSchemaField(field, value) {
193
209
  if (field === "type") {
194
210
  return toGeminiType(typeof value === "string" ? value : void 0);
@@ -218,14 +234,14 @@ function openApiSchemaToGeminiSchema(openApiSchema) {
218
234
  throw new TypeError("openapi_schema must be a dictionary");
219
235
  }
220
236
  const source = { ...openApiSchema };
237
+ const [schemaType, nullable] = normalizeJsonSchemaType(source["type"]);
238
+ source["type"] = schemaType;
239
+ if (nullable) {
240
+ source["nullable"] = true;
241
+ }
221
242
  if (!source["type"]) {
222
243
  source["type"] = "object";
223
244
  }
224
- const properties = source["properties"];
225
- const hasProperties = isPlainObject(properties) && Object.keys(properties).length > 0;
226
- if (source["type"] === "object" && !hasProperties) {
227
- source["properties"] = { [EMPTY_OBJECT_PLACEHOLDER]: { type: "string" } };
228
- }
229
245
  const converted = {};
230
246
  for (const [key, value] of Object.entries(source)) {
231
247
  const field = toGeminiSchemaField(key);
@@ -238,6 +254,7 @@ function openApiSchemaToGeminiSchema(openApiSchema) {
238
254
  }
239
255
  __name(openApiSchemaToGeminiSchema, "openApiSchemaToGeminiSchema");
240
256
  export {
257
+ normalizeJsonSchemaType,
241
258
  openApiSchemaToGeminiSchema,
242
259
  toGeminiSchema
243
260
  };
@@ -25,6 +25,10 @@ const _WinstonLogger = class _WinstonLogger {
25
25
  "warn": LogLevel.WARN,
26
26
  "error": LogLevel.ERROR
27
27
  },
28
+ // `levels` above inverts winston's npm ordering, so `error` (3) is the
29
+ // most permissive and leaves winston pass-through. Every method already
30
+ // gates on `this.logLevel`; a lower value here would double-gate and
31
+ // drop records.
28
32
  level: "error",
29
33
  format: winston.format.combine(
30
34
  winston.format.label({ label: "ADK" }),
@@ -7,10 +7,13 @@ 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 { isGemini } from "../models/google_llm.js";
10
11
  import { isGemini2OrAbove } from "./model_name.js";
11
12
  import { getGoogleLlmVariant, GoogleLLMVariant } from "./variant_utils.js";
12
- function canUseOutputSchemaWithTools(modelString) {
13
- return getGoogleLlmVariant() === GoogleLLMVariant.VERTEX_AI && isGemini2OrAbove(modelString);
13
+ function canUseOutputSchemaWithTools(model) {
14
+ const modelString = typeof model === "string" ? model : model.model;
15
+ const variant = isGemini(model) ? model.apiBackend : getGoogleLlmVariant();
16
+ return variant === GoogleLLMVariant.VERTEX_AI && isGemini2OrAbove(modelString);
14
17
  }
15
18
  __name(canUseOutputSchemaWithTools, "canUseOutputSchemaWithTools");
16
19
  export {
@@ -16,7 +16,7 @@ const _Task = class _Task {
16
16
  this.isDone = true;
17
17
  }, "markDone");
18
18
  this.promise = executable(this.abortController.signal);
19
- this.promise.then(markDone).catch(markDone);
19
+ this.promise.then(markDone, markDone);
20
20
  }
21
21
  /**
22
22
  * Cancels the task execution.
@@ -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.3.0";
8
+ const version = "2.4.0";
9
9
  export {
10
10
  version
11
11
  };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @license
3
+ * Copyright 2026 Google LLC
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+ export interface AgentEngineConfig {
7
+ project: string;
8
+ location: string;
9
+ reasoningEngineId: string;
10
+ }
11
+ export interface SessionConfig {
12
+ userId?: string;
13
+ sessionId?: string;
14
+ }
15
+ export interface QueryConfig extends SessionConfig {
16
+ message: unknown;
17
+ [key: string]: unknown;
18
+ }
19
+ export declare class AgentExecutionError extends Error {
20
+ readonly cause?: unknown | undefined;
21
+ constructor(message: string, cause?: unknown | undefined);
22
+ }
23
+ export declare class AgentEngineClient {
24
+ private client;
25
+ private reasoningEnginePath;
26
+ constructor(config: AgentEngineConfig);
27
+ /**
28
+ * Creates a remote session.
29
+ *
30
+ * @returns The `create_session` payload returned by the Agent Engine. When
31
+ * `config.sessionId` is omitted the engine generates one, and this is the
32
+ * only place the caller can read it back from.
33
+ */
34
+ createSession(config: SessionConfig): Promise<unknown>;
35
+ query(config: QueryConfig): Promise<unknown>;
36
+ streamQuery(config: QueryConfig): AsyncGenerator<unknown, void, unknown>;
37
+ }
@@ -224,6 +224,18 @@ export declare abstract class BaseAgent<TConfig extends BaseAgentConfig = BaseAg
224
224
  * @return The invocation context for this agent.
225
225
  */
226
226
  protected createInvocationContext(parentContext: InvocationContext): InvocationContext;
227
+ /**
228
+ * The resolved beforeAgentCallback field as a list of SingleAgentCallback.
229
+ *
230
+ * This method is only for use by Agent Development Kit.
231
+ */
232
+ get canonicalBeforeAgentCallbacks(): SingleAgentCallback[];
233
+ /**
234
+ * The resolved afterAgentCallback field as a list of SingleAgentCallback.
235
+ *
236
+ * This method is only for use by Agent Development Kit.
237
+ */
238
+ get canonicalAfterAgentCallbacks(): SingleAgentCallback[];
227
239
  /**
228
240
  * Runs the before agent callback if it exists.
229
241
  *
@@ -226,7 +226,11 @@ export interface LlmAgentConfig extends BaseAgentConfig {
226
226
  */
227
227
  contextCompactors?: BaseContextCompactor[];
228
228
  /**
229
- * Instructs the agent to make a plan and execute it step by step.
229
+ * Allows the agent to execute code blocks from model responses using the
230
+ * provided `BaseCodeExecutor`.
231
+ *
232
+ * NOTE: to use the model's built-in code executor, use the
233
+ * `BuiltInCodeExecutor`.
230
234
  */
231
235
  codeExecutor?: BaseCodeExecutor;
232
236
  /**
@@ -20,10 +20,12 @@ export declare function removeClientFunctionCallId(content: Content): void;
20
20
  * @param agentName: The name of the agent.
21
21
  * @param currentBranch: The current branch of the agent.
22
22
  * @param currentIsolationScope: The isolation scope of the current node, if any.
23
+ * @param preserveFunctionCallIds: Whether to preserve client-generated
24
+ * `adk-*` function call and response IDs instead of stripping them.
23
25
  *
24
26
  * @returns A list of processed contents.
25
27
  */
26
- export declare function getContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string): Content[];
28
+ export declare function getContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string, preserveFunctionCallIds?: boolean): Content[];
27
29
  /**
28
30
  * Get contents for the current turn only (no conversation history).
29
31
  *
@@ -42,7 +44,7 @@ export declare function getContents(events: Event[], agentName: string, currentB
42
44
  * @returns A list of contents for the current turn only, preserving context
43
45
  * needed for proper tool execution while excluding conversation history.
44
46
  */
45
- export declare function getCurrentTurnContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string): Content[];
47
+ export declare function getCurrentTurnContents(events: Event[], agentName: string, currentBranch?: string, currentIsolationScope?: string, preserveFunctionCallIds?: boolean): Content[];
46
48
  /**
47
49
  * Merges a list of function_response events into one event.
48
50
  *
@@ -19,7 +19,8 @@ export declare class NlPlanningRequestProcessor extends BaseLlmRequestProcessor
19
19
  runAsync(invocationContext: InvocationContext, llmRequest: LlmRequest): AsyncGenerator<Event, void, void>;
20
20
  }
21
21
  /**
22
- * Replaces the LLM response parts with the planner's processed parts.
22
+ * Replaces the LLM response parts with the planner's processed parts and emits
23
+ * a state-update event when the planner modifies session state.
23
24
  *
24
25
  * Partial responses are processed too.
25
26
  */
@@ -26,7 +26,7 @@ export interface LogToTmpFolderOptions {
26
26
  *
27
27
  * @param level The minimum `LogLevel` to emit. Defaults to `LogLevel.INFO`.
28
28
  */
29
- export declare function logToStderr(level?: LogLevel): void;
29
+ export declare function setupAdkLogger(level?: LogLevel): void;
30
30
  /**
31
31
  * Configures the global ADK logger to write formatted log records to a timestamped
32
32
  * file in the system temporary directory and updates the `<prefix>.latest.log`