veryfront 0.1.143 → 0.1.145
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/cli/shared/config.js +1 -1
- package/esm/deno.js +1 -1
- package/esm/src/agent/ag-ui-handler.d.ts +77 -0
- package/esm/src/agent/ag-ui-handler.d.ts.map +1 -0
- package/esm/src/agent/ag-ui-handler.js +331 -0
- package/esm/src/agent/index.d.ts +2 -1
- package/esm/src/agent/index.d.ts.map +1 -1
- package/esm/src/agent/index.js +2 -1
- package/esm/src/agent/runtime/index.d.ts +2 -0
- package/esm/src/agent/runtime/index.d.ts.map +1 -1
- package/esm/src/agent/runtime/index.js +15 -7
- package/esm/src/agent/runtime/resume-session.d.ts +61 -0
- package/esm/src/agent/runtime/resume-session.d.ts.map +1 -0
- package/esm/src/agent/runtime/resume-session.js +232 -0
- package/esm/src/agent/runtime/tool-helpers.d.ts +4 -2
- package/esm/src/agent/runtime/tool-helpers.d.ts.map +1 -1
- package/esm/src/agent/runtime/tool-helpers.js +57 -4
- package/esm/src/agent/types.d.ts +2 -1
- package/esm/src/agent/types.d.ts.map +1 -1
- package/esm/src/internal-agents/session-manager.d.ts +8 -24
- package/esm/src/internal-agents/session-manager.d.ts.map +1 -1
- package/esm/src/internal-agents/session-manager.js +55 -178
- package/esm/src/mcp/index.d.ts +2 -0
- package/esm/src/mcp/index.d.ts.map +1 -1
- package/esm/src/mcp/index.js +2 -0
- package/esm/src/mcp/server.d.ts +1 -0
- package/esm/src/mcp/server.d.ts.map +1 -1
- package/esm/src/mcp/server.js +47 -8
- package/esm/src/mcp/session.d.ts +9 -0
- package/esm/src/mcp/session.d.ts.map +1 -0
- package/esm/src/mcp/session.js +25 -0
- package/esm/src/mcp/sse.d.ts +8 -0
- package/esm/src/mcp/sse.d.ts.map +1 -0
- package/esm/src/mcp/sse.js +17 -0
- package/esm/src/platform/cloud/resolver.d.ts.map +1 -1
- package/esm/src/platform/cloud/resolver.js +13 -3
- package/esm/src/provider/index.d.ts +2 -0
- package/esm/src/provider/index.d.ts.map +1 -1
- package/esm/src/provider/index.js +1 -0
- package/esm/src/provider/veryfront-cloud/context.d.ts +10 -0
- package/esm/src/provider/veryfront-cloud/context.d.ts.map +1 -0
- package/esm/src/provider/veryfront-cloud/context.js +11 -0
- package/esm/src/tool/index.d.ts +3 -1
- package/esm/src/tool/index.d.ts.map +1 -1
- package/esm/src/tool/index.js +1 -0
- package/esm/src/tool/remote-mcp.d.ts +14 -0
- package/esm/src/tool/remote-mcp.d.ts.map +1 -0
- package/esm/src/tool/remote-mcp.js +176 -0
- package/esm/src/tool/types.d.ts +12 -0
- package/esm/src/tool/types.d.ts.map +1 -1
- 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/cli/shared/config.ts +1 -1
- package/src/deno.js +1 -1
- package/src/src/agent/ag-ui-handler.ts +451 -0
- package/src/src/agent/index.ts +21 -1
- package/src/src/agent/runtime/index.ts +28 -3
- package/src/src/agent/runtime/resume-session.ts +319 -0
- package/src/src/agent/runtime/tool-helpers.ts +89 -6
- package/src/src/agent/types.ts +2 -1
- package/src/src/internal-agents/session-manager.ts +69 -243
- package/src/src/mcp/index.ts +3 -0
- package/src/src/mcp/server.ts +54 -9
- package/src/src/mcp/session.ts +31 -0
- package/src/src/mcp/sse.ts +19 -0
- package/src/src/platform/cloud/resolver.ts +15 -3
- package/src/src/provider/index.ts +5 -0
- package/src/src/provider/veryfront-cloud/context.ts +28 -0
- package/src/src/tool/index.ts +9 -1
- package/src/src/tool/remote-mcp.ts +261 -0
- package/src/src/tool/types.ts +17 -0
- package/src/src/utils/version-constant.ts +1 -1
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
import * as dntShim from "../../../_dnt.shims.js";
|
|
2
|
+
export class RunCancelledError extends Error {
|
|
3
|
+
constructor(message = "Run cancelled") {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = "RunCancelledError";
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
export class RunAlreadyExistsError extends Error {
|
|
9
|
+
constructor(runId) {
|
|
10
|
+
super(`Run "${runId}" is already active`);
|
|
11
|
+
this.name = "RunAlreadyExistsError";
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export class RunNotActiveError extends Error {
|
|
15
|
+
constructor(runId) {
|
|
16
|
+
super(`Run "${runId}" is not active`);
|
|
17
|
+
this.name = "RunNotActiveError";
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
export class WaitNotPendingError extends Error {
|
|
21
|
+
constructor(runId, waitKey) {
|
|
22
|
+
super(`Run "${runId}" is not waiting for "${waitKey}"`);
|
|
23
|
+
this.name = "WaitNotPendingError";
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export class WaitConflictError extends Error {
|
|
27
|
+
constructor(runId, waitKey) {
|
|
28
|
+
super(`Conflicting resume value for run "${runId}" and wait key "${waitKey}"`);
|
|
29
|
+
this.name = "WaitConflictError";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const DEFAULT_WAITING_TTL_MS = 5 * 60 * 1000;
|
|
33
|
+
const DEFAULT_MAX_CONCURRENT_SESSIONS = 100;
|
|
34
|
+
function defaultConflictKey(value) {
|
|
35
|
+
return JSON.stringify(value);
|
|
36
|
+
}
|
|
37
|
+
export class RunResumeSessionManager {
|
|
38
|
+
options;
|
|
39
|
+
sessions = new Map();
|
|
40
|
+
constructor(options = {}) {
|
|
41
|
+
this.options = options;
|
|
42
|
+
}
|
|
43
|
+
get waitingTtlMs() {
|
|
44
|
+
return this.options.waitingTtlMs ?? DEFAULT_WAITING_TTL_MS;
|
|
45
|
+
}
|
|
46
|
+
get sessionTtlMs() {
|
|
47
|
+
return this.options.sessionTtlMs ?? null;
|
|
48
|
+
}
|
|
49
|
+
get maxConcurrentSessions() {
|
|
50
|
+
return this.options.maxConcurrentSessions ?? DEFAULT_MAX_CONCURRENT_SESSIONS;
|
|
51
|
+
}
|
|
52
|
+
get setTimeoutFn() {
|
|
53
|
+
return this.options.setTimeoutFn ?? dntShim.dntGlobalThis.setTimeout.bind(dntShim.dntGlobalThis);
|
|
54
|
+
}
|
|
55
|
+
get clearTimeoutFn() {
|
|
56
|
+
return this.options.clearTimeoutFn ?? globalThis.clearTimeout.bind(dntShim.dntGlobalThis);
|
|
57
|
+
}
|
|
58
|
+
getConflictKey(value) {
|
|
59
|
+
const createConflictKey = this.options.getConflictKey ?? defaultConflictKey;
|
|
60
|
+
return createConflictKey(value);
|
|
61
|
+
}
|
|
62
|
+
clearWaitingTimeout(session) {
|
|
63
|
+
if (session.waitingTimeoutId === null)
|
|
64
|
+
return;
|
|
65
|
+
this.clearTimeoutFn(session.waitingTimeoutId);
|
|
66
|
+
session.waitingTimeoutId = null;
|
|
67
|
+
}
|
|
68
|
+
clearSessionTimeout(session) {
|
|
69
|
+
if (session.sessionTimeoutId === null)
|
|
70
|
+
return;
|
|
71
|
+
this.clearTimeoutFn(session.sessionTimeoutId);
|
|
72
|
+
session.sessionTimeoutId = null;
|
|
73
|
+
}
|
|
74
|
+
scheduleSessionTimeout(session) {
|
|
75
|
+
if (this.sessionTtlMs === null)
|
|
76
|
+
return;
|
|
77
|
+
this.clearSessionTimeout(session);
|
|
78
|
+
session.sessionTimeoutId = this.setTimeoutFn(() => {
|
|
79
|
+
this.cancelRun(session.runId);
|
|
80
|
+
}, this.sessionTtlMs);
|
|
81
|
+
}
|
|
82
|
+
scheduleWaitingTimeout(session) {
|
|
83
|
+
this.clearWaitingTimeout(session);
|
|
84
|
+
session.waitingTimeoutId = this.setTimeoutFn(() => {
|
|
85
|
+
this.cancelRun(session.runId);
|
|
86
|
+
}, this.waitingTtlMs);
|
|
87
|
+
}
|
|
88
|
+
touchSession(session) {
|
|
89
|
+
if (session.status === "running" || session.status === "waiting") {
|
|
90
|
+
this.scheduleSessionTimeout(session);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
finalizeSession(session, status) {
|
|
94
|
+
session.status = status;
|
|
95
|
+
this.clearWaitingTimeout(session);
|
|
96
|
+
this.clearSessionTimeout(session);
|
|
97
|
+
session.waitingState = null;
|
|
98
|
+
this.sessions.delete(session.runId);
|
|
99
|
+
}
|
|
100
|
+
startRun(input) {
|
|
101
|
+
const existing = this.sessions.get(input.runId);
|
|
102
|
+
if (existing && (existing.status === "running" || existing.status === "waiting")) {
|
|
103
|
+
throw new RunAlreadyExistsError(input.runId);
|
|
104
|
+
}
|
|
105
|
+
if (this.sessions.size >= this.maxConcurrentSessions) {
|
|
106
|
+
throw new Error(`Maximum concurrent sessions (${this.maxConcurrentSessions}) reached`);
|
|
107
|
+
}
|
|
108
|
+
const session = {
|
|
109
|
+
runId: input.runId,
|
|
110
|
+
status: "running",
|
|
111
|
+
abortController: new AbortController(),
|
|
112
|
+
waitingState: null,
|
|
113
|
+
submittedValues: new Map(),
|
|
114
|
+
waitingTimeoutId: null,
|
|
115
|
+
sessionTimeoutId: null,
|
|
116
|
+
};
|
|
117
|
+
this.sessions.set(input.runId, session);
|
|
118
|
+
this.touchSession(session);
|
|
119
|
+
return session.abortController.signal;
|
|
120
|
+
}
|
|
121
|
+
async waitForSignal(runId, waitKey) {
|
|
122
|
+
const session = this.sessions.get(runId);
|
|
123
|
+
if (!session || session.status === "completed" || session.status === "failed") {
|
|
124
|
+
throw new RunNotActiveError(runId);
|
|
125
|
+
}
|
|
126
|
+
if (session.abortController.signal.aborted || session.status === "cancelled") {
|
|
127
|
+
throw new RunCancelledError();
|
|
128
|
+
}
|
|
129
|
+
const existingValue = session.submittedValues.get(waitKey);
|
|
130
|
+
if (existingValue) {
|
|
131
|
+
session.status = "running";
|
|
132
|
+
this.touchSession(session);
|
|
133
|
+
return existingValue.value;
|
|
134
|
+
}
|
|
135
|
+
if (session.waitingState && session.waitingState.waitKey !== waitKey) {
|
|
136
|
+
throw new WaitNotPendingError(runId, waitKey);
|
|
137
|
+
}
|
|
138
|
+
session.status = "waiting";
|
|
139
|
+
this.scheduleWaitingTimeout(session);
|
|
140
|
+
this.touchSession(session);
|
|
141
|
+
return await new Promise((resolve, reject) => {
|
|
142
|
+
const abortHandler = () => {
|
|
143
|
+
this.clearWaitingTimeout(session);
|
|
144
|
+
session.waitingState = null;
|
|
145
|
+
session.status = "cancelled";
|
|
146
|
+
reject(new RunCancelledError());
|
|
147
|
+
};
|
|
148
|
+
session.abortController.signal.addEventListener("abort", abortHandler, { once: true });
|
|
149
|
+
session.waitingState = {
|
|
150
|
+
waitKey,
|
|
151
|
+
resolve: (value) => {
|
|
152
|
+
session.abortController.signal.removeEventListener("abort", abortHandler);
|
|
153
|
+
this.clearWaitingTimeout(session);
|
|
154
|
+
session.waitingState = null;
|
|
155
|
+
session.status = "running";
|
|
156
|
+
this.touchSession(session);
|
|
157
|
+
resolve(value.value);
|
|
158
|
+
},
|
|
159
|
+
reject: (reason) => {
|
|
160
|
+
session.abortController.signal.removeEventListener("abort", abortHandler);
|
|
161
|
+
this.clearWaitingTimeout(session);
|
|
162
|
+
session.waitingState = null;
|
|
163
|
+
reject(reason);
|
|
164
|
+
},
|
|
165
|
+
};
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
submitSignal(runId, input) {
|
|
169
|
+
const session = this.sessions.get(runId);
|
|
170
|
+
if (!session) {
|
|
171
|
+
throw new RunNotActiveError(runId);
|
|
172
|
+
}
|
|
173
|
+
const normalized = {
|
|
174
|
+
value: input.value,
|
|
175
|
+
key: this.getConflictKey(input.value),
|
|
176
|
+
};
|
|
177
|
+
const existingValue = session.submittedValues.get(input.waitKey);
|
|
178
|
+
if (existingValue) {
|
|
179
|
+
if (existingValue.key === normalized.key) {
|
|
180
|
+
return { accepted: true, duplicate: true };
|
|
181
|
+
}
|
|
182
|
+
throw new WaitConflictError(runId, input.waitKey);
|
|
183
|
+
}
|
|
184
|
+
if (session.status === "completed" || session.status === "failed" ||
|
|
185
|
+
session.status === "cancelled") {
|
|
186
|
+
throw new RunNotActiveError(runId);
|
|
187
|
+
}
|
|
188
|
+
if (!session.waitingState || session.waitingState.waitKey !== input.waitKey) {
|
|
189
|
+
throw new WaitNotPendingError(runId, input.waitKey);
|
|
190
|
+
}
|
|
191
|
+
session.submittedValues.set(input.waitKey, normalized);
|
|
192
|
+
this.touchSession(session);
|
|
193
|
+
session.waitingState.resolve(normalized);
|
|
194
|
+
return { accepted: true };
|
|
195
|
+
}
|
|
196
|
+
cancelRun(runId) {
|
|
197
|
+
const session = this.sessions.get(runId);
|
|
198
|
+
if (!session)
|
|
199
|
+
return false;
|
|
200
|
+
if (session.status === "completed" || session.status === "failed" ||
|
|
201
|
+
session.status === "cancelled") {
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
const waitingState = session.waitingState;
|
|
205
|
+
session.abortController.abort(new RunCancelledError());
|
|
206
|
+
waitingState?.reject(new RunCancelledError());
|
|
207
|
+
this.finalizeSession(session, "cancelled");
|
|
208
|
+
return true;
|
|
209
|
+
}
|
|
210
|
+
completeRun(runId) {
|
|
211
|
+
const session = this.sessions.get(runId);
|
|
212
|
+
if (!session)
|
|
213
|
+
return;
|
|
214
|
+
this.finalizeSession(session, "completed");
|
|
215
|
+
}
|
|
216
|
+
failRun(runId) {
|
|
217
|
+
const session = this.sessions.get(runId);
|
|
218
|
+
if (!session)
|
|
219
|
+
return;
|
|
220
|
+
this.finalizeSession(session, "failed");
|
|
221
|
+
}
|
|
222
|
+
getRunStatus(runId) {
|
|
223
|
+
return this.sessions.get(runId)?.status ?? null;
|
|
224
|
+
}
|
|
225
|
+
reset() {
|
|
226
|
+
for (const session of this.sessions.values()) {
|
|
227
|
+
this.clearWaitingTimeout(session);
|
|
228
|
+
this.clearSessionTimeout(session);
|
|
229
|
+
}
|
|
230
|
+
this.sessions.clear();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*
|
|
6
6
|
* @module ai/agent/runtime/tool-helpers
|
|
7
7
|
*/
|
|
8
|
-
import type { Tool, ToolDefinition, ToolExecutionContext } from "../../tool/index.js";
|
|
8
|
+
import type { RemoteToolSource, Tool, ToolDefinition, ToolExecutionContext } from "../../tool/index.js";
|
|
9
9
|
/**
|
|
10
10
|
* Result of parsing tool arguments.
|
|
11
11
|
*/
|
|
@@ -28,7 +28,7 @@ export declare function isDynamicTool(name: string): boolean;
|
|
|
28
28
|
*/
|
|
29
29
|
export type ToolConfigEntry = Tool<any, any> | boolean;
|
|
30
30
|
export declare function resolveConfiguredTool(toolsConfig: true | Record<string, ToolConfigEntry> | undefined, toolName: string): Tool | null;
|
|
31
|
-
export declare function executeConfiguredTool(toolName: string, input: Record<string, unknown>, toolsConfig: true | Record<string, ToolConfigEntry> | undefined, context?: ToolExecutionContext, allowedRemoteToolNames?: string[]): Promise<unknown>;
|
|
31
|
+
export declare function executeConfiguredTool(toolName: string, input: Record<string, unknown>, toolsConfig: true | Record<string, ToolConfigEntry> | undefined, context?: ToolExecutionContext, allowedRemoteToolNames?: string[], remoteToolSources?: RemoteToolSource[]): Promise<unknown>;
|
|
32
32
|
/**
|
|
33
33
|
* Get available tools based on agent configuration.
|
|
34
34
|
* When tools === true, loads all tools from registry.
|
|
@@ -41,5 +41,7 @@ export declare function getAvailableTools(toolsConfig: true | Record<string, Too
|
|
|
41
41
|
includeSkillTools?: boolean;
|
|
42
42
|
includeIntegrationTools?: boolean;
|
|
43
43
|
allowedRemoteToolNames?: string[];
|
|
44
|
+
remoteToolSources?: RemoteToolSource[];
|
|
45
|
+
remoteToolContext?: ToolExecutionContext;
|
|
44
46
|
}): Promise<ToolDefinition[]>;
|
|
45
47
|
//# sourceMappingURL=tool-helpers.d.ts.map
|
|
@@ -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,IAAI,EAAE,cAAc,EAAE,oBAAoB,EA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GAAG,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,EAC/D,OAAO,CAAC,EAAE;IACR,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,sBAAsB,CAAC,EAAE,MAAM,EAAE,CAAC;IAClC,iBAAiB,CAAC,EAAE,gBAAgB,EAAE,CAAC;IACvC,iBAAiB,CAAC,EAAE,oBAAoB,CAAC;CAC1C,GACA,OAAO,CAAC,cAAc,EAAE,CAAC,CA+E3B"}
|
|
@@ -61,16 +61,65 @@ function throwUnknownConfiguredToolsError(unknownToolNames, availableLocalToolNa
|
|
|
61
61
|
}));
|
|
62
62
|
}
|
|
63
63
|
async function getRemoteToolDefinitions(options) {
|
|
64
|
+
const remoteToolContext = options?.remoteToolContext;
|
|
65
|
+
const definitions = [];
|
|
66
|
+
const seenToolNames = new Set();
|
|
67
|
+
const addDefinition = (definition) => {
|
|
68
|
+
if (seenToolNames.has(definition.name)) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
if (options?.allowedRemoteToolNames &&
|
|
72
|
+
!options.allowedRemoteToolNames.includes(definition.name)) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
seenToolNames.add(definition.name);
|
|
76
|
+
definitions.push(definition);
|
|
77
|
+
};
|
|
78
|
+
for (const source of options?.remoteToolSources ?? []) {
|
|
79
|
+
try {
|
|
80
|
+
const sourceDefs = await source.listTools(remoteToolContext);
|
|
81
|
+
for (const def of sourceDefs) {
|
|
82
|
+
addDefinition(def);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
catch (error) {
|
|
86
|
+
logger.warn("Failed to fetch remote tool definitions from source", {
|
|
87
|
+
sourceId: source.id,
|
|
88
|
+
error: error instanceof Error ? error.message : String(error),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
64
92
|
if (options?.includeIntegrationTools === false) {
|
|
65
|
-
return
|
|
93
|
+
return definitions;
|
|
66
94
|
}
|
|
67
95
|
try {
|
|
68
96
|
const { getRemoteIntegrationToolDefinitions } = await import("../../integrations/remote-tools.js");
|
|
69
|
-
|
|
97
|
+
for (const def of await getRemoteIntegrationToolDefinitions()) {
|
|
98
|
+
addDefinition(def);
|
|
99
|
+
}
|
|
70
100
|
}
|
|
71
101
|
catch {
|
|
72
|
-
return
|
|
102
|
+
return definitions;
|
|
103
|
+
}
|
|
104
|
+
return definitions;
|
|
105
|
+
}
|
|
106
|
+
async function sourceHasTool(source, toolName, context) {
|
|
107
|
+
return (await source.listTools(context)).some((definition) => definition.name === toolName);
|
|
108
|
+
}
|
|
109
|
+
async function executeRemoteToolFromSources(toolName, input, context, allowedRemoteToolNames, remoteToolSources) {
|
|
110
|
+
for (const source of remoteToolSources ?? []) {
|
|
111
|
+
if (!(await sourceHasTool(source, toolName, context))) {
|
|
112
|
+
continue;
|
|
113
|
+
}
|
|
114
|
+
if (allowedRemoteToolNames && !allowedRemoteToolNames.includes(toolName)) {
|
|
115
|
+
throw new Error(`Tool "${toolName}" is not allowed for this run`);
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
handled: true,
|
|
119
|
+
result: await source.executeTool(toolName, input, context),
|
|
120
|
+
};
|
|
73
121
|
}
|
|
122
|
+
return { handled: false };
|
|
74
123
|
}
|
|
75
124
|
export function resolveConfiguredTool(toolsConfig, toolName) {
|
|
76
125
|
if (!toolsConfig) {
|
|
@@ -88,7 +137,7 @@ export function resolveConfiguredTool(toolsConfig, toolName) {
|
|
|
88
137
|
}
|
|
89
138
|
return null;
|
|
90
139
|
}
|
|
91
|
-
export async function executeConfiguredTool(toolName, input, toolsConfig, context, allowedRemoteToolNames) {
|
|
140
|
+
export async function executeConfiguredTool(toolName, input, toolsConfig, context, allowedRemoteToolNames, remoteToolSources) {
|
|
92
141
|
const configuredTool = resolveConfiguredTool(toolsConfig, toolName);
|
|
93
142
|
if (configuredTool) {
|
|
94
143
|
return await configuredTool.execute(input, context);
|
|
@@ -98,6 +147,10 @@ export async function executeConfiguredTool(toolName, input, toolsConfig, contex
|
|
|
98
147
|
if (registryTool) {
|
|
99
148
|
return await registryTool.execute(input, context);
|
|
100
149
|
}
|
|
150
|
+
const remoteSourceResult = await executeRemoteToolFromSources(toolName, input, context, allowedRemoteToolNames, remoteToolSources);
|
|
151
|
+
if (remoteSourceResult.handled) {
|
|
152
|
+
return remoteSourceResult.result;
|
|
153
|
+
}
|
|
101
154
|
// Fall back to remote execution for integration tools (e.g., github:list-repos)
|
|
102
155
|
if (isRemoteIntegrationTool(toolName)) {
|
|
103
156
|
if (allowedRemoteToolNames && !allowedRemoteToolNames.includes(toolName)) {
|
package/esm/src/agent/types.d.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* Agent type definitions
|
|
3
3
|
**************************/
|
|
4
4
|
import * as dntShim from "../../_dnt.shims.js";
|
|
5
|
-
import type { Tool } from "../tool/index.js";
|
|
5
|
+
import type { RemoteToolSource, Tool } from "../tool/index.js";
|
|
6
6
|
import type { Memory } from "./memory/memory-interface.js";
|
|
7
7
|
export type { AgentContext, AgentResponse, AgentStatus, EdgeConfig, MemoryConfig, Message, MessagePart, ModelProvider, StreamToolCall, ToolCall, ToolCallPart, ToolCallPartWithArgs, ToolCallPartWithInput, ToolResultPart, } from "./schemas/index.js";
|
|
8
8
|
import type { Message, MessagePart, ToolCall, ToolCallPart, ToolCallPartWithArgs, ToolCallPartWithInput } from "./schemas/index.js";
|
|
@@ -42,6 +42,7 @@ export interface AgentConfig {
|
|
|
42
42
|
model?: ModelString;
|
|
43
43
|
system: string | (() => string) | (() => Promise<string>);
|
|
44
44
|
tools?: true | Record<string, Tool | boolean>;
|
|
45
|
+
remoteTools?: RemoteToolSource[];
|
|
45
46
|
maxSteps?: number;
|
|
46
47
|
streaming?: boolean;
|
|
47
48
|
memory?: MemoryConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/agent/types.ts"],"names":[],"mappings":"AAAA;;4BAE4B;AAC5B,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAG/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/src/agent/types.ts"],"names":[],"mappings":"AAAA;;4BAE4B;AAC5B,OAAO,KAAK,OAAO,MAAM,qBAAqB,CAAC;AAG/C,OAAO,KAAK,EAAE,gBAAgB,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAG3D,YAAY,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,UAAU,EACV,YAAY,EACZ,OAAO,EACP,WAAW,EACX,aAAa,EACb,cAAc,EACd,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACrB,cAAc,GACf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,KAAK,EACV,OAAO,EACP,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,oBAAoB,EACpB,qBAAqB,EACtB,MAAM,oBAAoB,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC;AAGjC,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEnE,MAAM,MAAM,eAAe,GACvB;IACA,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;CAChB,GACC;IACA,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,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;QACrG,KAAK,CAAC,EAAE,WAAW,CAAC;QACpB,iEAAiE;QACjE,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,CAAC;QAC1C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;KACnC,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;IAE/B,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAE7D,SAAS,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC;IAE7B,cAAc,IAAI,OAAO,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,eAAe,EAAE,MAAM,CAAC;QACxB,IAAI,EAAE,MAAM,CAAC;KACd,CAAC,CAAC;IAEH,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B"}
|
|
@@ -1,24 +1,20 @@
|
|
|
1
1
|
import * as dntShim from "../../_dnt.shims.js";
|
|
2
|
-
|
|
2
|
+
import { RunAlreadyExistsError, RunCancelledError, RunNotActiveError, type RunSessionStatus, type SubmitResumeValueOutcome, WaitConflictError, WaitNotPendingError } from "../agent/runtime/resume-session.js";
|
|
3
|
+
export { RunNotActiveError };
|
|
4
|
+
export declare class AgentRunCancelledError extends RunCancelledError {
|
|
3
5
|
constructor(message?: string);
|
|
4
6
|
}
|
|
5
|
-
export declare class AgentRunAlreadyExistsError extends
|
|
7
|
+
export declare class AgentRunAlreadyExistsError extends RunAlreadyExistsError {
|
|
6
8
|
constructor(runId: string);
|
|
7
9
|
}
|
|
8
|
-
export declare class
|
|
9
|
-
constructor(runId: string);
|
|
10
|
-
}
|
|
11
|
-
export declare class ToolResultNotWaitingError extends Error {
|
|
10
|
+
export declare class ToolResultNotWaitingError extends WaitNotPendingError {
|
|
12
11
|
constructor(runId: string, toolCallId: string);
|
|
13
12
|
}
|
|
14
|
-
export declare class ToolResultConflictError extends
|
|
13
|
+
export declare class ToolResultConflictError extends WaitConflictError {
|
|
15
14
|
constructor(runId: string, toolCallId: string);
|
|
16
15
|
}
|
|
17
|
-
type SessionStatus =
|
|
18
|
-
export
|
|
19
|
-
accepted: true;
|
|
20
|
-
duplicate?: true;
|
|
21
|
-
}
|
|
16
|
+
export type SessionStatus = RunSessionStatus;
|
|
17
|
+
export type SubmitToolResultOutcome = SubmitResumeValueOutcome;
|
|
22
18
|
export declare class AgentRunSessionManager {
|
|
23
19
|
private readonly options;
|
|
24
20
|
private readonly sessions;
|
|
@@ -29,17 +25,6 @@ export declare class AgentRunSessionManager {
|
|
|
29
25
|
setTimeoutFn?: typeof dntShim.setTimeout;
|
|
30
26
|
clearTimeoutFn?: typeof clearTimeout;
|
|
31
27
|
});
|
|
32
|
-
private get waitingForToolTtlMs();
|
|
33
|
-
private get sessionTtlMs();
|
|
34
|
-
private get setTimeoutFn();
|
|
35
|
-
private get clearTimeoutFn();
|
|
36
|
-
private clearWaitingTimeout;
|
|
37
|
-
private clearSessionTimeout;
|
|
38
|
-
private scheduleSessionTimeout;
|
|
39
|
-
private scheduleWaitingTimeout;
|
|
40
|
-
private touchSession;
|
|
41
|
-
private finalizeSession;
|
|
42
|
-
private get maxConcurrentSessions();
|
|
43
28
|
startRun(input: {
|
|
44
29
|
runId: string;
|
|
45
30
|
threadId: string;
|
|
@@ -61,5 +46,4 @@ export declare class AgentRunSessionManager {
|
|
|
61
46
|
}
|
|
62
47
|
export declare function _resetGlobalAgentRunSessionManagerForTesting(): void;
|
|
63
48
|
export declare const agentRunSessionManager: AgentRunSessionManager;
|
|
64
|
-
export {};
|
|
65
49
|
//# sourceMappingURL=session-manager.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"session-manager.d.ts","sourceRoot":"","sources":["../../../src/src/internal-agents/session-manager.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,qBA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