veryfront 0.1.282 → 0.1.283
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/esm/deno.js +1 -1
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +23 -0
- package/esm/src/agent/runtime/tool-helpers.d.ts +1 -0
- package/esm/src/agent/runtime/tool-helpers.d.ts.map +1 -1
- package/esm/src/agent/runtime/tool-helpers.js +21 -0
- package/esm/src/internal-agents/run-stream.d.ts.map +1 -1
- package/esm/src/internal-agents/run-stream.js +22 -0
- package/esm/src/utils/version-constant.d.ts +1 -1
- package/esm/src/utils/version-constant.js +1 -1
- package/package.json +1 -1
- package/src/deno.js +1 -1
- package/src/src/agent/runtime/index.ts +32 -1
- package/src/src/agent/runtime/tool-helpers.ts +32 -0
- package/src/src/internal-agents/run-stream.ts +34 -0
- package/src/src/utils/version-constant.ts +1 -1
package/esm/deno.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,aAAa,EAGlB,KAAK,OAAO,EACZ,KAAK,WAAW,EAEhB,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAgB,KAAK,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAU/D,OAAO,EACL,KAAK,eAAe,EAGpB,KAAK,iBAAiB,EACtB,KAAK,mBAAmB,EACzB,MAAM,0BAA0B,CAAC;AAUlC,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAC5E,OAAO,EACL,qBAAqB,EACrB,iBAAiB,EACjB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,mBAAmB,GACpB,MAAM,qBA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,CAAC;CAGnC"}
|
|
@@ -249,6 +249,25 @@ function getRuntimeAllowedRemoteTools(config) {
|
|
|
249
249
|
}
|
|
250
250
|
return raw.every((toolName) => typeof toolName === "string") ? raw : [];
|
|
251
251
|
}
|
|
252
|
+
function getRuntimeForwardedIntegrationToolDefs(config) {
|
|
253
|
+
const configWithFilters = config;
|
|
254
|
+
const raw = configWithFilters.__vfForwardedIntegrationToolDefs;
|
|
255
|
+
if (!Array.isArray(raw) || raw.length === 0)
|
|
256
|
+
return undefined;
|
|
257
|
+
return raw
|
|
258
|
+
.filter((def) => typeof def === "object" &&
|
|
259
|
+
def !== null &&
|
|
260
|
+
typeof def.name === "string" &&
|
|
261
|
+
typeof def.description === "string")
|
|
262
|
+
.map((def) => ({
|
|
263
|
+
name: def.name,
|
|
264
|
+
description: def.description,
|
|
265
|
+
parameters: typeof def.parameters === "object" && def.parameters !== null &&
|
|
266
|
+
!Array.isArray(def.parameters)
|
|
267
|
+
? def.parameters
|
|
268
|
+
: { type: "object", properties: {} },
|
|
269
|
+
}));
|
|
270
|
+
}
|
|
252
271
|
export class AgentRuntime {
|
|
253
272
|
id;
|
|
254
273
|
config;
|
|
@@ -446,6 +465,7 @@ export class AgentRuntime {
|
|
|
446
465
|
// Request-scoped skill policy (not class-level mutable state)
|
|
447
466
|
let activeSkillPolicy;
|
|
448
467
|
const allowedRemoteToolNames = getRuntimeAllowedRemoteTools(this.config);
|
|
468
|
+
const forwardedRemoteToolDefinitions = getRuntimeForwardedIntegrationToolDefs(this.config);
|
|
449
469
|
let currentSystemPrompt = systemPrompt;
|
|
450
470
|
let currentRuntimeContext = runtimeContext;
|
|
451
471
|
for (let step = 0; step < maxSteps; step++) {
|
|
@@ -458,6 +478,7 @@ export class AgentRuntime {
|
|
|
458
478
|
let tools = isLocal ? [] : await getAvailableTools(this.config.tools, {
|
|
459
479
|
includeSkillTools: Boolean(this.config.skills),
|
|
460
480
|
allowedRemoteToolNames,
|
|
481
|
+
forwardedRemoteToolDefinitions,
|
|
461
482
|
remoteToolSources: this.config.remoteTools,
|
|
462
483
|
remoteToolContext: toolContext,
|
|
463
484
|
});
|
|
@@ -650,6 +671,7 @@ export class AgentRuntime {
|
|
|
650
671
|
let finalFinishReason;
|
|
651
672
|
let latestAssistantText = "";
|
|
652
673
|
const allowedRemoteToolNames = getRuntimeAllowedRemoteTools(this.config);
|
|
674
|
+
const forwardedRemoteToolDefinitions = getRuntimeForwardedIntegrationToolDefs(this.config);
|
|
653
675
|
let currentSystemPrompt = systemPrompt;
|
|
654
676
|
let currentRuntimeContext = runtimeContext;
|
|
655
677
|
for (let step = 0; step < maxSteps; step++) {
|
|
@@ -663,6 +685,7 @@ export class AgentRuntime {
|
|
|
663
685
|
let tools = isLocalStreaming ? [] : await getAvailableTools(this.config.tools, {
|
|
664
686
|
includeSkillTools: Boolean(this.config.skills),
|
|
665
687
|
allowedRemoteToolNames,
|
|
688
|
+
forwardedRemoteToolDefinitions,
|
|
666
689
|
remoteToolSources: this.config.remoteTools,
|
|
667
690
|
remoteToolContext: toolContext,
|
|
668
691
|
});
|
|
@@ -41,6 +41,7 @@ export declare function getAvailableTools(toolsConfig: true | Record<string, Too
|
|
|
41
41
|
includeSkillTools?: boolean;
|
|
42
42
|
includeIntegrationTools?: boolean;
|
|
43
43
|
allowedRemoteToolNames?: string[];
|
|
44
|
+
forwardedRemoteToolDefinitions?: ToolDefinition[];
|
|
44
45
|
remoteToolSources?: RemoteToolSource[];
|
|
45
46
|
remoteToolContext?: ToolExecutionContext;
|
|
46
47
|
}): Promise<ToolDefinition[]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-helpers.d.ts","sourceRoot":"","sources":["../../../../src/src/agent/runtime/tool-helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAaxG;;GAEG;AACH,MAAM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O,CAAC,cAAc,EAAE,CAAC,CAyF3B"}
|
|
@@ -187,6 +187,25 @@ tool) {
|
|
|
187
187
|
logToolDefinition(name, def);
|
|
188
188
|
tools.push(def);
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Merge forwarded integration tool definitions into the remote defs array.
|
|
192
|
+
* Forwarded definitions are provided by the API when the runtime cannot
|
|
193
|
+
* fetch them directly (e.g., the runtime token lacks user auth).
|
|
194
|
+
* Only appends definitions not already present in the array.
|
|
195
|
+
*/
|
|
196
|
+
function appendForwardedToolDefinitions(remoteDefs, forwarded, allowedNames) {
|
|
197
|
+
if (!forwarded?.length)
|
|
198
|
+
return;
|
|
199
|
+
const existing = new Set(remoteDefs.map((def) => def.name));
|
|
200
|
+
for (const def of forwarded) {
|
|
201
|
+
if (existing.has(def.name))
|
|
202
|
+
continue;
|
|
203
|
+
if (allowedNames && !allowedNames.includes(def.name))
|
|
204
|
+
continue;
|
|
205
|
+
remoteDefs.push(def);
|
|
206
|
+
existing.add(def.name);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
190
209
|
/**
|
|
191
210
|
* Get available tools based on agent configuration.
|
|
192
211
|
* When tools === true, loads all tools from registry.
|
|
@@ -213,6 +232,7 @@ export async function getAvailableTools(toolsConfig, options) {
|
|
|
213
232
|
});
|
|
214
233
|
// Append remote integration tools (per-request, project-scoped)
|
|
215
234
|
const remoteDefs = await getRemoteToolDefinitions(options);
|
|
235
|
+
appendForwardedToolDefinitions(remoteDefs, options?.forwardedRemoteToolDefinitions, options?.allowedRemoteToolNames);
|
|
216
236
|
for (const def of remoteDefs) {
|
|
217
237
|
logToolDefinition(def.name, def);
|
|
218
238
|
}
|
|
@@ -221,6 +241,7 @@ export async function getAvailableTools(toolsConfig, options) {
|
|
|
221
241
|
}
|
|
222
242
|
const tools = [];
|
|
223
243
|
const remoteDefs = await getRemoteToolDefinitions(options);
|
|
244
|
+
appendForwardedToolDefinitions(remoteDefs, options?.forwardedRemoteToolDefinitions, options?.allowedRemoteToolNames);
|
|
224
245
|
const remoteToolNames = new Set(remoteDefs.map((def) => def.name));
|
|
225
246
|
const explicitlyRequestedRemoteToolNames = new Set();
|
|
226
247
|
const unresolvedConfiguredToolNames = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-stream.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/run-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,IAAI,OAAO,EAC5B,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"run-stream.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/run-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,YAAY,IAAI,OAAO,EAC5B,KAAK,aAAa,EAEnB,MAAM,mBAAmB,CAAC;AAY3B,OAAO,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAaxD,MAAM,WAAW,+BAA+B;IAC9C,cAAc,EAAE,sBAAsB,CAAC;IACvC,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,KAClC;QACH,MAAM,EAAE,CACN,QAAQ,EAAE,OAAO,EAAE,EACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,SAAS,CAAC,EAAE;YACV,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,IAAI,CAAC;SAC9C,EACD,aAAa,CAAC,EAAE,MAAM,EACtB,uBAAuB,CAAC,EAAE,MAAM,EAChC,WAAW,CAAC,EAAE,WAAW,KACtB,OAAO,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC;KAC1C,CAAC;CACH;AAyHD,wBAAsB,gCAAgC,CACpD,KAAK,EAAE,oBAAoB,EAC3B,KAAK,EAAE,KAAK,EACZ,IAAI,EAAE,+BAA+B,GACpC,OAAO,CAAC,QAAQ,CAAC,CAkPnB"}
|
|
@@ -68,6 +68,24 @@ function getAllowedRemoteToolNames(forwardedProps) {
|
|
|
68
68
|
}
|
|
69
69
|
return allowedTools.every((toolName) => typeof toolName === "string") ? allowedTools : [];
|
|
70
70
|
}
|
|
71
|
+
function getForwardedIntegrationToolDefinitions(forwardedProps) {
|
|
72
|
+
const runtimeOverrides = isRecord(forwardedProps?.runtimeOverrides)
|
|
73
|
+
? forwardedProps.runtimeOverrides
|
|
74
|
+
: null;
|
|
75
|
+
if (!runtimeOverrides)
|
|
76
|
+
return undefined;
|
|
77
|
+
const defs = runtimeOverrides.integrationToolDefinitions;
|
|
78
|
+
if (!Array.isArray(defs) || defs.length === 0)
|
|
79
|
+
return undefined;
|
|
80
|
+
return defs.filter((def) => typeof def === "object" &&
|
|
81
|
+
def !== null &&
|
|
82
|
+
typeof def.name === "string" &&
|
|
83
|
+
typeof def.description === "string").map((def) => ({
|
|
84
|
+
name: def.name,
|
|
85
|
+
description: def.description,
|
|
86
|
+
parameters: def.inputSchema ?? def.parameters ?? { type: "object", properties: {} },
|
|
87
|
+
}));
|
|
88
|
+
}
|
|
71
89
|
export async function createRuntimeAgentStreamResponse(input, agent, deps) {
|
|
72
90
|
logger.info("Starting internal agent runtime stream", {
|
|
73
91
|
runId: input.runId,
|
|
@@ -83,6 +101,7 @@ export async function createRuntimeAgentStreamResponse(input, agent, deps) {
|
|
|
83
101
|
});
|
|
84
102
|
const mergedTools = buildMergedTools(agent, input, deps.sessionManager);
|
|
85
103
|
const allowedRemoteToolNames = getAllowedRemoteToolNames(input.forwardedProps);
|
|
104
|
+
const forwardedIntegrationToolDefs = getForwardedIntegrationToolDefinitions(input.forwardedProps);
|
|
86
105
|
const runtimeAgent = {
|
|
87
106
|
...agent,
|
|
88
107
|
config: {
|
|
@@ -91,6 +110,9 @@ export async function createRuntimeAgentStreamResponse(input, agent, deps) {
|
|
|
91
110
|
...(allowedRemoteToolNames !== undefined
|
|
92
111
|
? { __vfAllowedRemoteTools: allowedRemoteToolNames }
|
|
93
112
|
: {}),
|
|
113
|
+
...(forwardedIntegrationToolDefs !== undefined
|
|
114
|
+
? { __vfForwardedIntegrationToolDefs: forwardedIntegrationToolDefs }
|
|
115
|
+
: {}),
|
|
94
116
|
},
|
|
95
117
|
};
|
|
96
118
|
const runtime = deps.createRuntime?.(runtimeAgent, mergedTools) ??
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.283";
|
|
2
2
|
//# sourceMappingURL=version-constant.d.ts.map
|
package/package.json
CHANGED
package/src/deno.js
CHANGED
|
@@ -47,7 +47,7 @@ import { repairToolCall } from "./repair-tool-call.js";
|
|
|
47
47
|
import { MiddlewareChain } from "../middleware/chain.js";
|
|
48
48
|
import { AGENT_DEFAULTS } from "../defaults.js";
|
|
49
49
|
import { tryGetCacheKeyContext } from "../../cache/cache-key-builder.js";
|
|
50
|
-
import type { ToolExecutionContext } from "../../tool/index.js";
|
|
50
|
+
import type { ToolDefinition, ToolExecutionContext } from "../../tool/index.js";
|
|
51
51
|
import { isLocalModelRuntime } from "../../provider/runtime-inspection.js";
|
|
52
52
|
import { generateText, streamText } from "../../runtime/runtime-bridge.js";
|
|
53
53
|
|
|
@@ -110,6 +110,9 @@ const LOAD_SKILL_TOOL_ID = "load-skill";
|
|
|
110
110
|
|
|
111
111
|
type RuntimeToolFilterConfig = AgentConfig & {
|
|
112
112
|
__vfAllowedRemoteTools?: string[];
|
|
113
|
+
__vfForwardedIntegrationToolDefs?: Array<
|
|
114
|
+
{ name: string; description: string; parameters: Record<string, unknown> }
|
|
115
|
+
>;
|
|
113
116
|
};
|
|
114
117
|
|
|
115
118
|
function isAbortError(error: unknown, abortSignal?: AbortSignal): boolean {
|
|
@@ -418,6 +421,30 @@ function getRuntimeAllowedRemoteTools(config: AgentConfig): string[] | undefined
|
|
|
418
421
|
return raw.every((toolName) => typeof toolName === "string") ? raw : [];
|
|
419
422
|
}
|
|
420
423
|
|
|
424
|
+
function getRuntimeForwardedIntegrationToolDefs(
|
|
425
|
+
config: AgentConfig,
|
|
426
|
+
): ToolDefinition[] | undefined {
|
|
427
|
+
const configWithFilters = config as RuntimeToolFilterConfig;
|
|
428
|
+
const raw = configWithFilters.__vfForwardedIntegrationToolDefs;
|
|
429
|
+
if (!Array.isArray(raw) || raw.length === 0) return undefined;
|
|
430
|
+
return raw
|
|
431
|
+
.filter(
|
|
432
|
+
(def): def is { name: string; description: string; parameters: Record<string, unknown> } =>
|
|
433
|
+
typeof def === "object" &&
|
|
434
|
+
def !== null &&
|
|
435
|
+
typeof def.name === "string" &&
|
|
436
|
+
typeof def.description === "string",
|
|
437
|
+
)
|
|
438
|
+
.map((def) => ({
|
|
439
|
+
name: def.name,
|
|
440
|
+
description: def.description,
|
|
441
|
+
parameters: typeof def.parameters === "object" && def.parameters !== null &&
|
|
442
|
+
!Array.isArray(def.parameters)
|
|
443
|
+
? def.parameters
|
|
444
|
+
: { type: "object", properties: {} },
|
|
445
|
+
}));
|
|
446
|
+
}
|
|
447
|
+
|
|
421
448
|
type ResolvedModelTransport = {
|
|
422
449
|
requestedModel: string;
|
|
423
450
|
resolvedModelString: string;
|
|
@@ -722,6 +749,7 @@ export class AgentRuntime {
|
|
|
722
749
|
// Request-scoped skill policy (not class-level mutable state)
|
|
723
750
|
let activeSkillPolicy: string[] | undefined;
|
|
724
751
|
const allowedRemoteToolNames = getRuntimeAllowedRemoteTools(this.config);
|
|
752
|
+
const forwardedRemoteToolDefinitions = getRuntimeForwardedIntegrationToolDefs(this.config);
|
|
725
753
|
let currentSystemPrompt = systemPrompt;
|
|
726
754
|
let currentRuntimeContext = runtimeContext;
|
|
727
755
|
|
|
@@ -743,6 +771,7 @@ export class AgentRuntime {
|
|
|
743
771
|
let tools = isLocal ? [] : await getAvailableTools(this.config.tools, {
|
|
744
772
|
includeSkillTools: Boolean(this.config.skills),
|
|
745
773
|
allowedRemoteToolNames,
|
|
774
|
+
forwardedRemoteToolDefinitions,
|
|
746
775
|
remoteToolSources: this.config.remoteTools,
|
|
747
776
|
remoteToolContext: toolContext,
|
|
748
777
|
});
|
|
@@ -1004,6 +1033,7 @@ export class AgentRuntime {
|
|
|
1004
1033
|
let finalFinishReason: string | undefined;
|
|
1005
1034
|
let latestAssistantText = "";
|
|
1006
1035
|
const allowedRemoteToolNames = getRuntimeAllowedRemoteTools(this.config);
|
|
1036
|
+
const forwardedRemoteToolDefinitions = getRuntimeForwardedIntegrationToolDefs(this.config);
|
|
1007
1037
|
let currentSystemPrompt = systemPrompt;
|
|
1008
1038
|
let currentRuntimeContext = runtimeContext;
|
|
1009
1039
|
|
|
@@ -1026,6 +1056,7 @@ export class AgentRuntime {
|
|
|
1026
1056
|
let tools = isLocalStreaming ? [] : await getAvailableTools(this.config.tools, {
|
|
1027
1057
|
includeSkillTools: Boolean(this.config.skills),
|
|
1028
1058
|
allowedRemoteToolNames,
|
|
1059
|
+
forwardedRemoteToolDefinitions,
|
|
1029
1060
|
remoteToolSources: this.config.remoteTools,
|
|
1030
1061
|
remoteToolContext: toolContext,
|
|
1031
1062
|
});
|
|
@@ -297,6 +297,27 @@ function addToolDefinition(
|
|
|
297
297
|
tools.push(def);
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
+
/**
|
|
301
|
+
* Merge forwarded integration tool definitions into the remote defs array.
|
|
302
|
+
* Forwarded definitions are provided by the API when the runtime cannot
|
|
303
|
+
* fetch them directly (e.g., the runtime token lacks user auth).
|
|
304
|
+
* Only appends definitions not already present in the array.
|
|
305
|
+
*/
|
|
306
|
+
function appendForwardedToolDefinitions(
|
|
307
|
+
remoteDefs: ToolDefinition[],
|
|
308
|
+
forwarded: ToolDefinition[] | undefined,
|
|
309
|
+
allowedNames: string[] | undefined,
|
|
310
|
+
): void {
|
|
311
|
+
if (!forwarded?.length) return;
|
|
312
|
+
const existing = new Set(remoteDefs.map((def) => def.name));
|
|
313
|
+
for (const def of forwarded) {
|
|
314
|
+
if (existing.has(def.name)) continue;
|
|
315
|
+
if (allowedNames && !allowedNames.includes(def.name)) continue;
|
|
316
|
+
remoteDefs.push(def);
|
|
317
|
+
existing.add(def.name);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
|
|
300
321
|
/**
|
|
301
322
|
* Get available tools based on agent configuration.
|
|
302
323
|
* When tools === true, loads all tools from registry.
|
|
@@ -311,6 +332,7 @@ export async function getAvailableTools(
|
|
|
311
332
|
includeSkillTools?: boolean;
|
|
312
333
|
includeIntegrationTools?: boolean;
|
|
313
334
|
allowedRemoteToolNames?: string[];
|
|
335
|
+
forwardedRemoteToolDefinitions?: ToolDefinition[];
|
|
314
336
|
remoteToolSources?: RemoteToolSource[];
|
|
315
337
|
remoteToolContext?: ToolExecutionContext;
|
|
316
338
|
},
|
|
@@ -333,6 +355,11 @@ export async function getAvailableTools(
|
|
|
333
355
|
|
|
334
356
|
// Append remote integration tools (per-request, project-scoped)
|
|
335
357
|
const remoteDefs = await getRemoteToolDefinitions(options);
|
|
358
|
+
appendForwardedToolDefinitions(
|
|
359
|
+
remoteDefs,
|
|
360
|
+
options?.forwardedRemoteToolDefinitions,
|
|
361
|
+
options?.allowedRemoteToolNames,
|
|
362
|
+
);
|
|
336
363
|
for (const def of remoteDefs) {
|
|
337
364
|
logToolDefinition(def.name, def);
|
|
338
365
|
}
|
|
@@ -343,6 +370,11 @@ export async function getAvailableTools(
|
|
|
343
370
|
|
|
344
371
|
const tools: ToolDefinition[] = [];
|
|
345
372
|
const remoteDefs = await getRemoteToolDefinitions(options);
|
|
373
|
+
appendForwardedToolDefinitions(
|
|
374
|
+
remoteDefs,
|
|
375
|
+
options?.forwardedRemoteToolDefinitions,
|
|
376
|
+
options?.allowedRemoteToolNames,
|
|
377
|
+
);
|
|
346
378
|
const remoteToolNames = new Set(remoteDefs.map((def) => def.name));
|
|
347
379
|
const explicitlyRequestedRemoteToolNames = new Set<string>();
|
|
348
380
|
const unresolvedConfiguredToolNames: string[] = [];
|
|
@@ -25,6 +25,7 @@ const logger = serverLogger.component("internal-agent-run-stream");
|
|
|
25
25
|
type RuntimeFilteredAgent = Agent & {
|
|
26
26
|
config: Agent["config"] & {
|
|
27
27
|
__vfAllowedRemoteTools?: string[];
|
|
28
|
+
__vfForwardedIntegrationToolDefs?: ForwardedToolDef[];
|
|
28
29
|
};
|
|
29
30
|
};
|
|
30
31
|
|
|
@@ -137,6 +138,35 @@ function getAllowedRemoteToolNames(
|
|
|
137
138
|
return allowedTools.every((toolName) => typeof toolName === "string") ? allowedTools : [];
|
|
138
139
|
}
|
|
139
140
|
|
|
141
|
+
interface ForwardedToolDef {
|
|
142
|
+
name: string;
|
|
143
|
+
description: string;
|
|
144
|
+
inputSchema?: Record<string, unknown>;
|
|
145
|
+
parameters?: Record<string, unknown>;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function getForwardedIntegrationToolDefinitions(
|
|
149
|
+
forwardedProps: RuntimeRunAgentInput["forwardedProps"],
|
|
150
|
+
): ForwardedToolDef[] | undefined {
|
|
151
|
+
const runtimeOverrides = isRecord(forwardedProps?.runtimeOverrides)
|
|
152
|
+
? forwardedProps.runtimeOverrides
|
|
153
|
+
: null;
|
|
154
|
+
if (!runtimeOverrides) return undefined;
|
|
155
|
+
const defs = runtimeOverrides.integrationToolDefinitions;
|
|
156
|
+
if (!Array.isArray(defs) || defs.length === 0) return undefined;
|
|
157
|
+
return defs.filter(
|
|
158
|
+
(def): def is ForwardedToolDef =>
|
|
159
|
+
typeof def === "object" &&
|
|
160
|
+
def !== null &&
|
|
161
|
+
typeof def.name === "string" &&
|
|
162
|
+
typeof def.description === "string",
|
|
163
|
+
).map((def) => ({
|
|
164
|
+
name: def.name,
|
|
165
|
+
description: def.description,
|
|
166
|
+
parameters: def.inputSchema ?? def.parameters ?? { type: "object", properties: {} },
|
|
167
|
+
}));
|
|
168
|
+
}
|
|
169
|
+
|
|
140
170
|
export async function createRuntimeAgentStreamResponse(
|
|
141
171
|
input: RuntimeRunAgentInput,
|
|
142
172
|
agent: Agent,
|
|
@@ -157,6 +187,7 @@ export async function createRuntimeAgentStreamResponse(
|
|
|
157
187
|
|
|
158
188
|
const mergedTools = buildMergedTools(agent, input, deps.sessionManager);
|
|
159
189
|
const allowedRemoteToolNames = getAllowedRemoteToolNames(input.forwardedProps);
|
|
190
|
+
const forwardedIntegrationToolDefs = getForwardedIntegrationToolDefinitions(input.forwardedProps);
|
|
160
191
|
const runtimeAgent: RuntimeFilteredAgent = {
|
|
161
192
|
...agent,
|
|
162
193
|
config: {
|
|
@@ -165,6 +196,9 @@ export async function createRuntimeAgentStreamResponse(
|
|
|
165
196
|
...(allowedRemoteToolNames !== undefined
|
|
166
197
|
? { __vfAllowedRemoteTools: allowedRemoteToolNames }
|
|
167
198
|
: {}),
|
|
199
|
+
...(forwardedIntegrationToolDefs !== undefined
|
|
200
|
+
? { __vfForwardedIntegrationToolDefs: forwardedIntegrationToolDefs }
|
|
201
|
+
: {}),
|
|
168
202
|
},
|
|
169
203
|
};
|
|
170
204
|
const runtime = deps.createRuntime?.(runtimeAgent, mergedTools) ??
|