@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.
- package/dist/cjs/agents/agent_engine_client.js +172 -0
- package/dist/cjs/agents/base_agent.js +20 -4
- package/dist/cjs/agents/functions.js +28 -0
- package/dist/cjs/agents/instructions.js +2 -1
- package/dist/cjs/agents/llm_agent.js +19 -6
- package/dist/cjs/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/cjs/agents/processors/content_processor_utils.js +38 -10
- package/dist/cjs/agents/processors/content_request_processor.js +34 -2
- package/dist/cjs/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/cjs/agents/processors/nl_planning_processor.js +12 -3
- package/dist/cjs/cli/utils/logs.js +6 -6
- package/dist/cjs/code_executors/container_code_executor.js +27 -16
- package/dist/cjs/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/cjs/common.js +9 -20
- package/dist/cjs/errors/input_validation_error.js +3 -2
- package/dist/cjs/index.js +9 -2
- package/dist/cjs/plugins/base_plugin.js +13 -23
- package/dist/cjs/sessions/base_session_service.js +14 -8
- package/dist/cjs/sessions/database_session_service.js +50 -28
- package/dist/cjs/sessions/stale_session_error.js +59 -0
- package/dist/cjs/skills/loader.js +52 -18
- package/dist/cjs/telemetry/setup.js +0 -1
- package/dist/cjs/telemetry/tracing.js +53 -10
- package/dist/cjs/tools/apihub_tool/apihub_toolset.js +18 -23
- package/dist/cjs/tools/application_integration_tool/application_integration_toolset.js +120 -42
- package/dist/cjs/tools/application_integration_tool/clients/connections_client.js +163 -95
- package/dist/cjs/tools/application_integration_tool/clients/integration_client.js +13 -9
- package/dist/cjs/tools/application_integration_tool/integration_connector_tool.js +184 -0
- package/dist/cjs/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/cjs/tools/google_api_tool/google_api_toolset.js +173 -0
- package/dist/cjs/tools/google_api_tool/google_api_toolsets.js +124 -0
- package/dist/cjs/tools/google_api_tool/googleapi_to_openapi_converter.js +2 -2
- package/dist/cjs/tools/google_api_tool/index.js +20 -23
- package/dist/cjs/tools/load_artifacts_tool.js +12 -6
- package/dist/cjs/tools/load_memory_tool.js +12 -10
- package/dist/cjs/tools/mcp/mcp_toolset.js +1 -14
- package/dist/cjs/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/cjs/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/cjs/tools/openapi_tool/openapi_toolset.js +7 -13
- package/dist/cjs/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/cjs/tools/toolbox_toolset.js +174 -0
- package/dist/cjs/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/cjs/utils/client_labels.js +19 -2
- package/dist/cjs/utils/failover_utils.js +1 -1
- package/dist/cjs/utils/gemini_schema_util.js +24 -6
- package/dist/cjs/utils/logger_node.js +4 -0
- package/dist/cjs/utils/output_schema_utils.js +5 -2
- package/dist/cjs/utils/task.js +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/agents/agent_engine_client.js +144 -0
- package/dist/esm/agents/base_agent.js +20 -4
- package/dist/esm/agents/functions.js +28 -0
- package/dist/esm/agents/instructions.js +2 -1
- package/dist/esm/agents/llm_agent.js +19 -6
- package/dist/esm/agents/processors/basic_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/code_execution_request_processor.js +8 -0
- package/dist/esm/agents/processors/content_processor_utils.js +38 -10
- package/dist/esm/agents/processors/content_request_processor.js +34 -2
- package/dist/esm/agents/processors/instructions_llm_request_processor.js +1 -1
- package/dist/esm/agents/processors/nl_planning_processor.js +12 -3
- package/dist/esm/cli/utils/logs.js +4 -4
- package/dist/esm/code_executors/container_code_executor.js +27 -16
- package/dist/esm/code_executors/unsafe_local_code_executor.js +6 -1
- package/dist/esm/common.js +10 -13
- package/dist/esm/errors/input_validation_error.js +3 -2
- package/dist/esm/index.js +17 -3
- package/dist/esm/plugins/base_plugin.js +13 -23
- package/dist/esm/sessions/base_session_service.js +12 -7
- package/dist/esm/sessions/database_session_service.js +49 -28
- package/dist/esm/sessions/stale_session_error.js +31 -0
- package/dist/esm/skills/loader.js +51 -17
- package/dist/esm/telemetry/setup.js +1 -2
- package/dist/esm/telemetry/tracing.js +57 -11
- package/dist/esm/tools/apihub_tool/apihub_toolset.js +17 -22
- package/dist/esm/tools/application_integration_tool/application_integration_toolset.js +124 -42
- package/dist/esm/tools/application_integration_tool/clients/connections_client.js +163 -95
- package/dist/esm/tools/application_integration_tool/clients/integration_client.js +13 -9
- package/dist/esm/tools/application_integration_tool/integration_connector_tool.js +158 -0
- package/dist/esm/tools/google_api_tool/google_api_tool.js +4 -1
- package/dist/esm/tools/google_api_tool/google_api_toolset.js +146 -0
- package/dist/esm/tools/google_api_tool/google_api_toolsets.js +94 -0
- package/dist/esm/tools/google_api_tool/googleapi_to_openapi_converter.js +2 -2
- package/dist/esm/tools/google_api_tool/index.js +18 -20
- package/dist/esm/tools/load_artifacts_tool.js +10 -5
- package/dist/esm/tools/load_memory_tool.js +12 -10
- package/dist/esm/tools/mcp/mcp_toolset.js +1 -14
- package/dist/esm/tools/openapi_tool/auth/credential_exchangers/oauth2_exchanger.js +2 -2
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.js +20 -6
- package/dist/esm/tools/openapi_tool/openapi_spec_parser/operation_parser.js +17 -6
- package/dist/esm/tools/openapi_tool/openapi_toolset.js +6 -12
- package/dist/esm/tools/openapi_tool/rest_api_tool.js +17 -1
- package/dist/esm/tools/toolbox_toolset.js +148 -0
- package/dist/esm/tools/webmcp/webmcp_toolset.js +1 -14
- package/dist/esm/utils/client_labels.js +19 -2
- package/dist/esm/utils/failover_utils.js +1 -1
- package/dist/esm/utils/gemini_schema_util.js +23 -6
- package/dist/esm/utils/logger_node.js +4 -0
- package/dist/esm/utils/output_schema_utils.js +5 -2
- package/dist/esm/utils/task.js +1 -1
- package/dist/esm/version.js +1 -1
- package/dist/types/agents/agent_engine_client.d.ts +37 -0
- package/dist/types/agents/base_agent.d.ts +12 -0
- package/dist/types/agents/llm_agent.d.ts +5 -1
- package/dist/types/agents/processors/content_processor_utils.d.ts +4 -2
- package/dist/types/agents/processors/nl_planning_processor.d.ts +2 -1
- package/dist/types/cli/utils/logs.d.ts +1 -1
- package/dist/types/code_executors/container_code_executor.d.ts +17 -5
- package/dist/types/common.d.ts +5 -9
- package/dist/types/errors/input_validation_error.d.ts +2 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/plugins/base_plugin.d.ts +0 -10
- package/dist/types/sessions/base_session_service.d.ts +5 -0
- package/dist/types/sessions/database_session_service.d.ts +17 -1
- package/dist/types/sessions/stale_session_error.d.ts +21 -0
- package/dist/types/skills/loader.d.ts +3 -2
- package/dist/types/telemetry/tracing.d.ts +17 -3
- package/dist/types/tools/apihub_tool/apihub_toolset.d.ts +14 -21
- package/dist/types/tools/application_integration_tool/application_integration_toolset.d.ts +32 -9
- package/dist/types/tools/application_integration_tool/clients/connections_client.d.ts +22 -8
- package/dist/types/tools/application_integration_tool/clients/integration_client.d.ts +3 -3
- package/dist/types/tools/application_integration_tool/integration_connector_tool.d.ts +70 -0
- package/dist/types/tools/base_toolset.d.ts +6 -5
- package/dist/types/tools/google_api_tool/google_api_tool.d.ts +10 -3
- package/dist/types/tools/google_api_tool/google_api_toolset.d.ts +55 -0
- package/dist/types/tools/google_api_tool/google_api_toolsets.d.ts +48 -0
- package/dist/types/tools/google_api_tool/googleapi_to_openapi_converter.d.ts +5 -4
- package/dist/types/tools/google_api_tool/index.d.ts +4 -5
- package/dist/types/tools/load_artifacts_tool.d.ts +14 -1
- package/dist/types/tools/load_memory_tool.d.ts +23 -1
- package/dist/types/tools/openapi_tool/openapi_spec_parser/openapi_spec_parser.d.ts +12 -0
- package/dist/types/tools/openapi_tool/openapi_spec_parser/operation_parser.d.ts +8 -0
- package/dist/types/tools/openapi_tool/openapi_toolset.d.ts +5 -0
- package/dist/types/tools/openapi_tool/rest_api_tool.d.ts +10 -0
- package/dist/types/tools/toolbox_toolset.d.ts +159 -0
- package/dist/types/utils/client_labels.d.ts +2 -1
- package/dist/types/utils/gemini_schema_util.d.ts +8 -0
- package/dist/types/utils/output_schema_utils.d.ts +3 -2
- package/dist/types/utils/simple_zod_to_json.d.ts +1 -2
- package/dist/types/version.d.ts +1 -1
- package/dist/web/index_web.js +74 -66
- package/dist/web/index_web.js.map +4 -4
- package/package.json +34 -27
- package/dist/cjs/agents/remote_agent.js +0 -187
- package/dist/cjs/tools/crewai_tool.js +0 -132
- package/dist/cjs/tools/google_api_tool/google_api_tool_set.js +0 -226
- package/dist/cjs/tools/google_api_tool/google_api_tool_sets.js +0 -58
- package/dist/cjs/tools/langchain_tool.js +0 -172
- package/dist/cjs/tools/toolbox_tool.js +0 -108
- package/dist/esm/agents/remote_agent.js +0 -164
- package/dist/esm/tools/crewai_tool.js +0 -107
- package/dist/esm/tools/google_api_tool/google_api_tool_set.js +0 -188
- package/dist/esm/tools/google_api_tool/google_api_tool_sets.js +0 -24
- package/dist/esm/tools/langchain_tool.js +0 -148
- package/dist/esm/tools/toolbox_tool.js +0 -80
- package/dist/types/agents/remote_agent.d.ts +0 -68
- package/dist/types/tools/crewai_tool.d.ts +0 -85
- package/dist/types/tools/google_api_tool/google_api_tool_set.d.ts +0 -78
- package/dist/types/tools/google_api_tool/google_api_tool_sets.d.ts +0 -33
- package/dist/types/tools/langchain_tool.d.ts +0 -103
- package/dist/types/tools/toolbox_tool.d.ts +0 -73
|
@@ -46,7 +46,7 @@ __export(openapi_toolset_exports, {
|
|
|
46
46
|
OpenAPIToolset: () => OpenAPIToolset
|
|
47
47
|
});
|
|
48
48
|
module.exports = __toCommonJS(openapi_toolset_exports);
|
|
49
|
-
var
|
|
49
|
+
var yaml = __toESM(require("js-yaml"), 1);
|
|
50
50
|
var import_experimental = require("../../utils/experimental.js");
|
|
51
51
|
var import_logger = require("../../utils/logger.js");
|
|
52
52
|
var import_base_toolset = require("../base_toolset.js");
|
|
@@ -64,7 +64,7 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
|
|
|
64
64
|
let spec = options.specDict;
|
|
65
65
|
if (!spec && options.specStr) {
|
|
66
66
|
if (options.specType === "yaml" || !options.specType && options.specStr.trim().startsWith("---")) {
|
|
67
|
-
spec =
|
|
67
|
+
spec = yaml.load(options.specStr);
|
|
68
68
|
} else if (options.specType === "json" || !options.specType) {
|
|
69
69
|
spec = JSON.parse(options.specStr);
|
|
70
70
|
} else {
|
|
@@ -75,7 +75,8 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
|
|
|
75
75
|
throw new Error("Either specDict or specStr must be provided.");
|
|
76
76
|
}
|
|
77
77
|
const parser = new import_openapi_spec_parser.OpenApiSpecParser({
|
|
78
|
-
preservePropertyNames: options.preservePropertyNames
|
|
78
|
+
preservePropertyNames: options.preservePropertyNames,
|
|
79
|
+
unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
|
|
79
80
|
});
|
|
80
81
|
const parsedOperations = parser.parse(spec);
|
|
81
82
|
for (const op of parsedOperations) {
|
|
@@ -96,7 +97,8 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
|
|
|
96
97
|
{
|
|
97
98
|
preservePropertyNames: options.preservePropertyNames,
|
|
98
99
|
headerProvider: options.headerProvider,
|
|
99
|
-
credentialKey: options.credentialKey
|
|
100
|
+
credentialKey: options.credentialKey,
|
|
101
|
+
unconstrainedObjectBodyAsParameter: options.unconstrainedObjectBodyAsParameter
|
|
100
102
|
}
|
|
101
103
|
);
|
|
102
104
|
this.tools.push(tool);
|
|
@@ -111,15 +113,7 @@ let OpenAPIToolset = class extends import_base_toolset.BaseToolset {
|
|
|
111
113
|
}
|
|
112
114
|
}
|
|
113
115
|
async getTools(context) {
|
|
114
|
-
return this.tools.filter((tool) =>
|
|
115
|
-
if (Array.isArray(this.toolFilter) && this.toolFilter.length > 0) {
|
|
116
|
-
return this.toolFilter.includes(tool.name);
|
|
117
|
-
}
|
|
118
|
-
if (context) {
|
|
119
|
-
return this.isToolSelected(tool, context);
|
|
120
|
-
}
|
|
121
|
-
return true;
|
|
122
|
-
});
|
|
116
|
+
return this.tools.filter((tool) => this.isToolSelected(tool, context));
|
|
123
117
|
}
|
|
124
118
|
getTool(toolName) {
|
|
125
119
|
return this.tools.find((tool) => tool.name === toolName);
|
|
@@ -203,6 +203,22 @@ function encodePathParamValue(name, value) {
|
|
|
203
203
|
return encodeURIComponent(value);
|
|
204
204
|
}
|
|
205
205
|
__name(encodePathParamValue, "encodePathParamValue");
|
|
206
|
+
function serializeQueryValue(value) {
|
|
207
|
+
return typeof value === "object" && value !== null ? JSON.stringify(value) : String(value);
|
|
208
|
+
}
|
|
209
|
+
__name(serializeQueryValue, "serializeQueryValue");
|
|
210
|
+
function appendQueryParam(queryParams, name, value) {
|
|
211
|
+
if (!Array.isArray(value)) {
|
|
212
|
+
queryParams.append(name, serializeQueryValue(value));
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
for (const item of value) {
|
|
216
|
+
if (item !== void 0 && item !== null) {
|
|
217
|
+
queryParams.append(name, serializeQueryValue(item));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
__name(appendQueryParam, "appendQueryParam");
|
|
206
222
|
function prepareRequestParams(endpoint, parameters, args) {
|
|
207
223
|
const headers = {};
|
|
208
224
|
const queryParams = new URLSearchParams();
|
|
@@ -223,7 +239,7 @@ function prepareRequestParams(endpoint, parameters, args) {
|
|
|
223
239
|
);
|
|
224
240
|
} else if (location === "query") {
|
|
225
241
|
if (argValue !== void 0 && argValue !== null && argValue !== "") {
|
|
226
|
-
queryParams
|
|
242
|
+
appendQueryParam(queryParams, originalName, argValue);
|
|
227
243
|
}
|
|
228
244
|
} else if (location === "header") {
|
|
229
245
|
headers[originalName] = String(argValue);
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
"use strict";
|
|
8
|
+
var __defProp = Object.defineProperty;
|
|
9
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
10
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
11
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
12
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
var toolbox_toolset_exports = {};
|
|
27
|
+
__export(toolbox_toolset_exports, {
|
|
28
|
+
ToolboxToolset: () => ToolboxToolset,
|
|
29
|
+
isToolboxToolset: () => isToolboxToolset
|
|
30
|
+
});
|
|
31
|
+
module.exports = __toCommonJS(toolbox_toolset_exports);
|
|
32
|
+
var import_base_tool = require("./base_tool.js");
|
|
33
|
+
var import_base_toolset = require("./base_toolset.js");
|
|
34
|
+
var import_function_tool = require("./function_tool.js");
|
|
35
|
+
/**
|
|
36
|
+
* @license
|
|
37
|
+
* Copyright 2026 Google LLC
|
|
38
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
39
|
+
*/
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const TOOLBOX_TOOLSET_SIGNATURE_SYMBOL = /* @__PURE__ */ Symbol.for(
|
|
42
|
+
"google.adk.toolboxToolset"
|
|
43
|
+
);
|
|
44
|
+
function isToolboxToolset(obj) {
|
|
45
|
+
return typeof obj === "object" && obj !== null && TOOLBOX_TOOLSET_SIGNATURE_SYMBOL in obj && obj[TOOLBOX_TOOLSET_SIGNATURE_SYMBOL] === true;
|
|
46
|
+
}
|
|
47
|
+
__name(isToolboxToolset, "isToolboxToolset");
|
|
48
|
+
function createUnconfiguredToolboxToolsetClient(serverUrl) {
|
|
49
|
+
const throwMissingClient = /* @__PURE__ */ __name(() => {
|
|
50
|
+
throw new Error(
|
|
51
|
+
`ToolboxToolset requires a ToolboxToolsetClientLike instance (for endpoint "${serverUrl}"). Pass {serverUrl, client} to the ToolboxToolset constructor.`
|
|
52
|
+
);
|
|
53
|
+
}, "throwMissingClient");
|
|
54
|
+
return {
|
|
55
|
+
loadTool: throwMissingClient,
|
|
56
|
+
loadToolset: throwMissingClient,
|
|
57
|
+
close: /* @__PURE__ */ __name(() => {
|
|
58
|
+
}, "close")
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
__name(createUnconfiguredToolboxToolsetClient, "createUnconfiguredToolboxToolsetClient");
|
|
62
|
+
function isToolOptionsObject(value) {
|
|
63
|
+
return typeof value === "object" && value !== null && "execute" in value && typeof value.execute === "function";
|
|
64
|
+
}
|
|
65
|
+
__name(isToolOptionsObject, "isToolOptionsObject");
|
|
66
|
+
function wrapLoadedTool(rawTool, prefix) {
|
|
67
|
+
var _a2;
|
|
68
|
+
if ((0, import_base_tool.isBaseTool)(rawTool)) {
|
|
69
|
+
if (!prefix) {
|
|
70
|
+
return rawTool;
|
|
71
|
+
}
|
|
72
|
+
return Object.assign(
|
|
73
|
+
Object.create(Object.getPrototypeOf(rawTool)),
|
|
74
|
+
rawTool,
|
|
75
|
+
{ name: `${prefix}_${rawTool.name}` }
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
if (typeof rawTool === "function") {
|
|
79
|
+
const fn = rawTool;
|
|
80
|
+
const baseName = fn.name || "toolbox_tool";
|
|
81
|
+
const name = prefix ? `${prefix}_${baseName}` : baseName;
|
|
82
|
+
const description = (_a2 = fn.description) != null ? _a2 : "";
|
|
83
|
+
return new import_function_tool.FunctionTool({
|
|
84
|
+
name,
|
|
85
|
+
description,
|
|
86
|
+
execute: fn
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
if (isToolOptionsObject(rawTool)) {
|
|
90
|
+
const baseTool = new import_function_tool.FunctionTool(rawTool);
|
|
91
|
+
if (!prefix) {
|
|
92
|
+
return baseTool;
|
|
93
|
+
}
|
|
94
|
+
return new import_function_tool.FunctionTool({
|
|
95
|
+
...rawTool,
|
|
96
|
+
name: `${prefix}_${baseTool.name}`
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
throw new TypeError(
|
|
100
|
+
"Unsupported Toolbox tool shape: expected a BaseTool, ToolOptions object, or function."
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
__name(wrapLoadedTool, "wrapLoadedTool");
|
|
104
|
+
const _ToolboxToolset = class _ToolboxToolset extends (_b = import_base_toolset.BaseToolset, _a = TOOLBOX_TOOLSET_SIGNATURE_SYMBOL, _b) {
|
|
105
|
+
constructor(serverUrlOrOptions, extraOptions) {
|
|
106
|
+
var _a2, _b2, _c, _d;
|
|
107
|
+
const options = typeof serverUrlOrOptions === "string" ? { serverUrl: serverUrlOrOptions, ...extraOptions } : serverUrlOrOptions;
|
|
108
|
+
if ((!options.toolNames || options.toolNames.length === 0) && !options.toolsetName) {
|
|
109
|
+
throw new Error("toolNames and toolsetName cannot both be undefined.");
|
|
110
|
+
}
|
|
111
|
+
super((_a2 = options.toolFilter) != null ? _a2 : [], options.prefix);
|
|
112
|
+
/** A unique symbol to identify ADK ToolboxToolset class. */
|
|
113
|
+
this[_a] = true;
|
|
114
|
+
this.serverUrl = options.serverUrl;
|
|
115
|
+
this.toolsetName = options.toolsetName;
|
|
116
|
+
this.toolNames = options.toolNames;
|
|
117
|
+
this.authTokenGetters = (_b2 = options.authTokenGetters) != null ? _b2 : {};
|
|
118
|
+
this.boundParams = (_c = options.boundParams) != null ? _c : {};
|
|
119
|
+
this.toolboxClient = (_d = options.client) != null ? _d : createUnconfiguredToolboxToolsetClient(this.serverUrl);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Loads the configured toolset and/or individual tools from the Toolbox
|
|
123
|
+
* client and returns the selected {@link BaseTool} instances.
|
|
124
|
+
*/
|
|
125
|
+
async getTools(context) {
|
|
126
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
127
|
+
const loadOptions = {
|
|
128
|
+
authTokenGetters: this.authTokenGetters,
|
|
129
|
+
boundParams: this.boundParams
|
|
130
|
+
};
|
|
131
|
+
const tools = [];
|
|
132
|
+
if (this.toolsetName) {
|
|
133
|
+
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);
|
|
134
|
+
if (!loader) {
|
|
135
|
+
throw new Error(
|
|
136
|
+
"ToolboxClient does not implement loadToolset or load_toolset."
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
const loadedToolset = await loader(this.toolsetName, loadOptions);
|
|
140
|
+
for (const rawTool of loadedToolset) {
|
|
141
|
+
tools.push(wrapLoadedTool(rawTool, this.prefix));
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (this.toolNames && this.toolNames.length > 0) {
|
|
145
|
+
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);
|
|
146
|
+
if (!loader) {
|
|
147
|
+
throw new Error(
|
|
148
|
+
"ToolboxClient does not implement loadTool or load_tool."
|
|
149
|
+
);
|
|
150
|
+
}
|
|
151
|
+
const loadedSingleTools = await Promise.all(
|
|
152
|
+
this.toolNames.map((toolName) => loader(toolName, loadOptions))
|
|
153
|
+
);
|
|
154
|
+
for (const rawTool of loadedSingleTools) {
|
|
155
|
+
tools.push(wrapLoadedTool(rawTool, this.prefix));
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return tools.filter((tool) => this.isToolSelected(tool, context));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Closes the underlying Toolbox client.
|
|
162
|
+
*/
|
|
163
|
+
async close() {
|
|
164
|
+
var _a2, _b2;
|
|
165
|
+
await ((_b2 = (_a2 = this.toolboxClient).close) == null ? void 0 : _b2.call(_a2));
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
__name(_ToolboxToolset, "ToolboxToolset");
|
|
169
|
+
let ToolboxToolset = _ToolboxToolset;
|
|
170
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
171
|
+
0 && (module.exports = {
|
|
172
|
+
ToolboxToolset,
|
|
173
|
+
isToolboxToolset
|
|
174
|
+
});
|
|
@@ -67,20 +67,7 @@ const _WebMCPToolset = class _WebMCPToolset extends import_base_toolset.BaseTool
|
|
|
67
67
|
document: this.doc
|
|
68
68
|
})
|
|
69
69
|
);
|
|
70
|
-
|
|
71
|
-
if (!filter || Array.isArray(filter) && filter.length === 0) {
|
|
72
|
-
return tools;
|
|
73
|
-
}
|
|
74
|
-
if (Array.isArray(filter)) {
|
|
75
|
-
return tools.filter((tool) => filter.includes(tool.name));
|
|
76
|
-
}
|
|
77
|
-
if (context) {
|
|
78
|
-
return tools.filter((tool) => filter(tool, context));
|
|
79
|
-
}
|
|
80
|
-
import_logger.logger.warn(
|
|
81
|
-
"WebMCPToolset: a ToolPredicate toolFilter was provided but getTools() was called without a ReadonlyContext. The filter will not be applied."
|
|
82
|
-
);
|
|
83
|
-
return tools;
|
|
70
|
+
return tools.filter((tool) => this.isToolSelected(tool, context));
|
|
84
71
|
}
|
|
85
72
|
/**
|
|
86
73
|
* Subscribes to the WebMCP `toolchange` event, which fires when the page
|
|
@@ -129,7 +129,8 @@ function headerEntries(headers) {
|
|
|
129
129
|
__name(headerEntries, "headerEntries");
|
|
130
130
|
function mergeTrackingHeaders(headers) {
|
|
131
131
|
var _a, _b;
|
|
132
|
-
const
|
|
132
|
+
const otherHeaders = new Headers();
|
|
133
|
+
const originalNames = /* @__PURE__ */ new Map();
|
|
133
134
|
const callerValues = /* @__PURE__ */ new Map();
|
|
134
135
|
for (const [name, value] of headerEntries(headers)) {
|
|
135
136
|
const lowerName = name.toLowerCase();
|
|
@@ -139,9 +140,25 @@ function mergeTrackingHeaders(headers) {
|
|
|
139
140
|
value
|
|
140
141
|
]);
|
|
141
142
|
} else {
|
|
142
|
-
|
|
143
|
+
if (!originalNames.has(lowerName)) {
|
|
144
|
+
originalNames.set(lowerName, name);
|
|
145
|
+
}
|
|
146
|
+
otherHeaders.append(name, value);
|
|
143
147
|
}
|
|
144
148
|
}
|
|
149
|
+
const normalizedEntries = [];
|
|
150
|
+
otherHeaders.forEach((value, name) => {
|
|
151
|
+
normalizedEntries.push([name, value]);
|
|
152
|
+
});
|
|
153
|
+
const merged = Object.fromEntries(
|
|
154
|
+
normalizedEntries.map(([name, value]) => {
|
|
155
|
+
var _a2;
|
|
156
|
+
return [
|
|
157
|
+
(_a2 = originalNames.get(name)) != null ? _a2 : name,
|
|
158
|
+
value
|
|
159
|
+
];
|
|
160
|
+
})
|
|
161
|
+
);
|
|
145
162
|
for (const [name, trackingValue] of Object.entries(getTrackingHeaders())) {
|
|
146
163
|
const tokens = trackingValue.split(" ");
|
|
147
164
|
for (const value of (_b = callerValues.get(name)) != null ? _b : []) {
|
|
@@ -47,9 +47,9 @@ async function* runWithRouting(items, context, router, runFn) {
|
|
|
47
47
|
}
|
|
48
48
|
const triedKeys = /* @__PURE__ */ new Set([selectedKey]);
|
|
49
49
|
while (true) {
|
|
50
|
-
const generatorOrPromise = runFn(selectedItem);
|
|
51
50
|
let firstYielded = false;
|
|
52
51
|
try {
|
|
52
|
+
const generatorOrPromise = runFn(selectedItem);
|
|
53
53
|
if (isAsyncGenerator(generatorOrPromise)) {
|
|
54
54
|
for await (const result2 of generatorOrPromise) {
|
|
55
55
|
yield result2;
|
|
@@ -25,6 +25,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
25
25
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
26
|
var gemini_schema_util_exports = {};
|
|
27
27
|
__export(gemini_schema_util_exports, {
|
|
28
|
+
normalizeJsonSchemaType: () => normalizeJsonSchemaType,
|
|
28
29
|
openApiSchemaToGeminiSchema: () => openApiSchemaToGeminiSchema,
|
|
29
30
|
toGeminiSchema: () => toGeminiSchema
|
|
30
31
|
});
|
|
@@ -204,7 +205,6 @@ const GEMINI_REJECTED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
|
|
|
204
205
|
"default",
|
|
205
206
|
"format"
|
|
206
207
|
]);
|
|
207
|
-
const EMPTY_OBJECT_PLACEHOLDER = "dummy_DO_NOT_GENERATE";
|
|
208
208
|
function toGeminiSchemaField(key) {
|
|
209
209
|
return (0, import_case_utils.toSnakeCaseName)(key).replace(
|
|
210
210
|
/_([a-z0-9])/g,
|
|
@@ -216,6 +216,23 @@ function isPlainObject(value) {
|
|
|
216
216
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
217
217
|
}
|
|
218
218
|
__name(isPlainObject, "isPlainObject");
|
|
219
|
+
function normalizeJsonSchemaType(jsonSchemaType) {
|
|
220
|
+
if (typeof jsonSchemaType === "string") {
|
|
221
|
+
if (jsonSchemaType === "null") {
|
|
222
|
+
return [void 0, true];
|
|
223
|
+
}
|
|
224
|
+
return [jsonSchemaType, false];
|
|
225
|
+
}
|
|
226
|
+
if (Array.isArray(jsonSchemaType)) {
|
|
227
|
+
const nullable = jsonSchemaType.includes("null");
|
|
228
|
+
const nonNullTypes = jsonSchemaType.filter(
|
|
229
|
+
(t) => typeof t === "string" && t !== "null"
|
|
230
|
+
);
|
|
231
|
+
return [nonNullTypes[0], nullable];
|
|
232
|
+
}
|
|
233
|
+
return [void 0, false];
|
|
234
|
+
}
|
|
235
|
+
__name(normalizeJsonSchemaType, "normalizeJsonSchemaType");
|
|
219
236
|
function convertSchemaField(field, value) {
|
|
220
237
|
if (field === "type") {
|
|
221
238
|
return toGeminiType(typeof value === "string" ? value : void 0);
|
|
@@ -245,14 +262,14 @@ function openApiSchemaToGeminiSchema(openApiSchema) {
|
|
|
245
262
|
throw new TypeError("openapi_schema must be a dictionary");
|
|
246
263
|
}
|
|
247
264
|
const source = { ...openApiSchema };
|
|
265
|
+
const [schemaType, nullable] = normalizeJsonSchemaType(source["type"]);
|
|
266
|
+
source["type"] = schemaType;
|
|
267
|
+
if (nullable) {
|
|
268
|
+
source["nullable"] = true;
|
|
269
|
+
}
|
|
248
270
|
if (!source["type"]) {
|
|
249
271
|
source["type"] = "object";
|
|
250
272
|
}
|
|
251
|
-
const properties = source["properties"];
|
|
252
|
-
const hasProperties = isPlainObject(properties) && Object.keys(properties).length > 0;
|
|
253
|
-
if (source["type"] === "object" && !hasProperties) {
|
|
254
|
-
source["properties"] = { [EMPTY_OBJECT_PLACEHOLDER]: { type: "string" } };
|
|
255
|
-
}
|
|
256
273
|
const converted = {};
|
|
257
274
|
for (const [key, value] of Object.entries(source)) {
|
|
258
275
|
const field = toGeminiSchemaField(key);
|
|
@@ -266,6 +283,7 @@ function openApiSchemaToGeminiSchema(openApiSchema) {
|
|
|
266
283
|
__name(openApiSchemaToGeminiSchema, "openApiSchemaToGeminiSchema");
|
|
267
284
|
// Annotate the CommonJS export names for ESM import in node:
|
|
268
285
|
0 && (module.exports = {
|
|
286
|
+
normalizeJsonSchemaType,
|
|
269
287
|
openApiSchemaToGeminiSchema,
|
|
270
288
|
toGeminiSchema
|
|
271
289
|
});
|
|
@@ -62,6 +62,10 @@ const _WinstonLogger = class _WinstonLogger {
|
|
|
62
62
|
"warn": import_logger.LogLevel.WARN,
|
|
63
63
|
"error": import_logger.LogLevel.ERROR
|
|
64
64
|
},
|
|
65
|
+
// `levels` above inverts winston's npm ordering, so `error` (3) is the
|
|
66
|
+
// most permissive and leaves winston pass-through. Every method already
|
|
67
|
+
// gates on `this.logLevel`; a lower value here would double-gate and
|
|
68
|
+
// drop records.
|
|
65
69
|
level: "error",
|
|
66
70
|
format: winston.format.combine(
|
|
67
71
|
winston.format.label({ label: "ADK" }),
|
|
@@ -28,6 +28,7 @@ __export(output_schema_utils_exports, {
|
|
|
28
28
|
canUseOutputSchemaWithTools: () => canUseOutputSchemaWithTools
|
|
29
29
|
});
|
|
30
30
|
module.exports = __toCommonJS(output_schema_utils_exports);
|
|
31
|
+
var import_google_llm = require("../models/google_llm.js");
|
|
31
32
|
var import_model_name = require("./model_name.js");
|
|
32
33
|
var import_variant_utils = require("./variant_utils.js");
|
|
33
34
|
/**
|
|
@@ -35,8 +36,10 @@ var import_variant_utils = require("./variant_utils.js");
|
|
|
35
36
|
* Copyright 2026 Google LLC
|
|
36
37
|
* SPDX-License-Identifier: Apache-2.0
|
|
37
38
|
*/
|
|
38
|
-
function canUseOutputSchemaWithTools(
|
|
39
|
-
|
|
39
|
+
function canUseOutputSchemaWithTools(model) {
|
|
40
|
+
const modelString = typeof model === "string" ? model : model.model;
|
|
41
|
+
const variant = (0, import_google_llm.isGemini)(model) ? model.apiBackend : (0, import_variant_utils.getGoogleLlmVariant)();
|
|
42
|
+
return variant === import_variant_utils.GoogleLLMVariant.VERTEX_AI && (0, import_model_name.isGemini2OrAbove)(modelString);
|
|
40
43
|
}
|
|
41
44
|
__name(canUseOutputSchemaWithTools, "canUseOutputSchemaWithTools");
|
|
42
45
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/utils/task.js
CHANGED
|
@@ -42,7 +42,7 @@ const _Task = class _Task {
|
|
|
42
42
|
this.isDone = true;
|
|
43
43
|
}, "markDone");
|
|
44
44
|
this.promise = executable(this.abortController.signal);
|
|
45
|
-
this.promise.then(markDone
|
|
45
|
+
this.promise.then(markDone, markDone);
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
48
|
* Cancels the task execution.
|
package/dist/cjs/version.js
CHANGED
|
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(version_exports);
|
|
|
32
32
|
* Copyright 2025 Google LLC
|
|
33
33
|
* SPDX-License-Identifier: Apache-2.0
|
|
34
34
|
*/
|
|
35
|
-
const version = "2.
|
|
35
|
+
const version = "2.4.0";
|
|
36
36
|
// Annotate the CommonJS export names for ESM import in node:
|
|
37
37
|
0 && (module.exports = {
|
|
38
38
|
version
|
|
@@ -0,0 +1,144 @@
|
|
|
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
|
+
import { helpers, v1 } from "@google-cloud/aiplatform";
|
|
11
|
+
const _AgentExecutionError = class _AgentExecutionError extends Error {
|
|
12
|
+
constructor(message, cause) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.cause = cause;
|
|
15
|
+
this.name = "AgentExecutionError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
__name(_AgentExecutionError, "AgentExecutionError");
|
|
19
|
+
let AgentExecutionError = _AgentExecutionError;
|
|
20
|
+
function buildInputStruct(config) {
|
|
21
|
+
var _a;
|
|
22
|
+
const value = helpers.toValue(config);
|
|
23
|
+
return (_a = value == null ? void 0 : value.structValue) != null ? _a : void 0;
|
|
24
|
+
}
|
|
25
|
+
__name(buildInputStruct, "buildInputStruct");
|
|
26
|
+
function parseOutput(output) {
|
|
27
|
+
return helpers.fromValue(output);
|
|
28
|
+
}
|
|
29
|
+
__name(parseOutput, "parseOutput");
|
|
30
|
+
function parseFragment(line) {
|
|
31
|
+
const trimmed = line.trim();
|
|
32
|
+
if (!trimmed) return void 0;
|
|
33
|
+
const payload = trimmed.startsWith("data:") ? trimmed.slice(5).trim() : trimmed;
|
|
34
|
+
if (payload === "[DONE]") return void 0;
|
|
35
|
+
try {
|
|
36
|
+
return JSON.parse(payload);
|
|
37
|
+
} catch (e) {
|
|
38
|
+
throw new AgentExecutionError(
|
|
39
|
+
`Failed to parse stream fragment: ${payload}`,
|
|
40
|
+
e
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
__name(parseFragment, "parseFragment");
|
|
45
|
+
async function* parseStream(stream) {
|
|
46
|
+
let buffer = "";
|
|
47
|
+
for await (const chunk of stream) {
|
|
48
|
+
const chunkData = chunk == null ? void 0 : chunk.data;
|
|
49
|
+
if (chunkData === void 0) {
|
|
50
|
+
if (typeof chunk === "object" && chunk !== null) {
|
|
51
|
+
yield chunk;
|
|
52
|
+
}
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
const dataStr = chunkData instanceof Uint8Array ? new TextDecoder().decode(chunkData) : String(chunkData);
|
|
56
|
+
buffer += dataStr;
|
|
57
|
+
const lines = buffer.split("\n");
|
|
58
|
+
buffer = lines.pop() || "";
|
|
59
|
+
for (const line of lines) {
|
|
60
|
+
const fragment = parseFragment(line);
|
|
61
|
+
if (fragment !== void 0) {
|
|
62
|
+
yield fragment;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const last = parseFragment(buffer);
|
|
67
|
+
if (last !== void 0) {
|
|
68
|
+
yield last;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
__name(parseStream, "parseStream");
|
|
72
|
+
const _AgentEngineClient = class _AgentEngineClient {
|
|
73
|
+
constructor(config) {
|
|
74
|
+
this.client = new v1.ReasoningEngineExecutionServiceClient({
|
|
75
|
+
apiEndpoint: `${config.location}-aiplatform.googleapis.com`
|
|
76
|
+
});
|
|
77
|
+
this.reasoningEnginePath = this.client.reasoningEnginePath(
|
|
78
|
+
config.project,
|
|
79
|
+
config.location,
|
|
80
|
+
config.reasoningEngineId
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Creates a remote session.
|
|
85
|
+
*
|
|
86
|
+
* @returns The `create_session` payload returned by the Agent Engine. When
|
|
87
|
+
* `config.sessionId` is omitted the engine generates one, and this is the
|
|
88
|
+
* only place the caller can read it back from.
|
|
89
|
+
*/
|
|
90
|
+
async createSession(config) {
|
|
91
|
+
try {
|
|
92
|
+
const [response] = await this.client.queryReasoningEngine({
|
|
93
|
+
name: this.reasoningEnginePath,
|
|
94
|
+
classMethod: "create_session",
|
|
95
|
+
input: buildInputStruct(config)
|
|
96
|
+
});
|
|
97
|
+
return response.output ? parseOutput(response.output) : void 0;
|
|
98
|
+
} catch (err) {
|
|
99
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
100
|
+
throw new AgentExecutionError(
|
|
101
|
+
`Failed to create session: ${message}`,
|
|
102
|
+
err
|
|
103
|
+
);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
async query(config) {
|
|
107
|
+
try {
|
|
108
|
+
const [response] = await this.client.queryReasoningEngine({
|
|
109
|
+
name: this.reasoningEnginePath,
|
|
110
|
+
classMethod: "query",
|
|
111
|
+
input: buildInputStruct(config)
|
|
112
|
+
});
|
|
113
|
+
return response.output ? parseOutput(response.output) : void 0;
|
|
114
|
+
} catch (err) {
|
|
115
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
116
|
+
throw new AgentExecutionError(`Failed to execute query: ${message}`, err);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
async *streamQuery(config) {
|
|
120
|
+
try {
|
|
121
|
+
const stream = this.client.streamQueryReasoningEngine({
|
|
122
|
+
name: this.reasoningEnginePath,
|
|
123
|
+
classMethod: "query",
|
|
124
|
+
input: buildInputStruct(config)
|
|
125
|
+
});
|
|
126
|
+
yield* parseStream(stream);
|
|
127
|
+
} catch (err) {
|
|
128
|
+
if (err instanceof AgentExecutionError) {
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
132
|
+
throw new AgentExecutionError(
|
|
133
|
+
`Failed to execute stream query: ${message}`,
|
|
134
|
+
err
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
__name(_AgentEngineClient, "AgentEngineClient");
|
|
140
|
+
let AgentEngineClient = _AgentEngineClient;
|
|
141
|
+
export {
|
|
142
|
+
AgentEngineClient,
|
|
143
|
+
AgentExecutionError
|
|
144
|
+
};
|
|
@@ -235,6 +235,22 @@ const _BaseAgent = class _BaseAgent extends (_b = BaseNode, _a = BASE_AGENT_SIGN
|
|
|
235
235
|
agent: this
|
|
236
236
|
});
|
|
237
237
|
}
|
|
238
|
+
/**
|
|
239
|
+
* The resolved beforeAgentCallback field as a list of SingleAgentCallback.
|
|
240
|
+
*
|
|
241
|
+
* This method is only for use by Agent Development Kit.
|
|
242
|
+
*/
|
|
243
|
+
get canonicalBeforeAgentCallbacks() {
|
|
244
|
+
return this.beforeAgentCallback;
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* The resolved afterAgentCallback field as a list of SingleAgentCallback.
|
|
248
|
+
*
|
|
249
|
+
* This method is only for use by Agent Development Kit.
|
|
250
|
+
*/
|
|
251
|
+
get canonicalAfterAgentCallbacks() {
|
|
252
|
+
return this.afterAgentCallback;
|
|
253
|
+
}
|
|
238
254
|
/**
|
|
239
255
|
* Runs the before agent callback if it exists.
|
|
240
256
|
*
|
|
@@ -244,11 +260,11 @@ const _BaseAgent = class _BaseAgent extends (_b = BaseNode, _a = BASE_AGENT_SIGN
|
|
|
244
260
|
*/
|
|
245
261
|
async handleBeforeAgentCallback(invocationContext) {
|
|
246
262
|
var _a2;
|
|
247
|
-
if (this.
|
|
263
|
+
if (this.canonicalBeforeAgentCallbacks.length === 0) {
|
|
248
264
|
return void 0;
|
|
249
265
|
}
|
|
250
266
|
const callbackContext = new Context({ invocationContext });
|
|
251
|
-
for (const callback of this.
|
|
267
|
+
for (const callback of this.canonicalBeforeAgentCallbacks) {
|
|
252
268
|
const content = await callback(callbackContext);
|
|
253
269
|
if ((_a2 = invocationContext.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
254
270
|
return;
|
|
@@ -283,11 +299,11 @@ const _BaseAgent = class _BaseAgent extends (_b = BaseNode, _a = BASE_AGENT_SIGN
|
|
|
283
299
|
*/
|
|
284
300
|
async handleAfterAgentCallback(invocationContext) {
|
|
285
301
|
var _a2;
|
|
286
|
-
if (this.
|
|
302
|
+
if (this.canonicalAfterAgentCallbacks.length === 0) {
|
|
287
303
|
return void 0;
|
|
288
304
|
}
|
|
289
305
|
const callbackContext = new Context({ invocationContext });
|
|
290
|
-
for (const callback of this.
|
|
306
|
+
for (const callback of this.canonicalAfterAgentCallbacks) {
|
|
291
307
|
const content = await callback(callbackContext);
|
|
292
308
|
if ((_a2 = invocationContext.abortSignal) == null ? void 0 : _a2.aborted) {
|
|
293
309
|
return;
|