@dexto/agent-management 1.15.0-beta.0 → 1.15.0-beta.2
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/auth/dexto-sign-in.cjs +54 -26
- package/dist/auth/dexto-sign-in.d.ts +25 -2
- package/dist/auth/dexto-sign-in.d.ts.map +1 -1
- package/dist/auth/dexto-sign-in.js +52 -26
- package/dist/config/errors.cjs +6 -6
- package/dist/config/errors.js +6 -6
- package/dist/images/image-store.cjs +2 -4
- package/dist/images/image-store.d.ts.map +1 -1
- package/dist/images/image-store.js +2 -4
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/installation.cjs +2 -2
- package/dist/installation.js +2 -2
- package/dist/plugins/discover-skills.cjs +5 -2
- package/dist/plugins/discover-skills.d.ts +6 -2
- package/dist/plugins/discover-skills.d.ts.map +1 -1
- package/dist/plugins/discover-skills.js +5 -2
- package/dist/plugins/errors.cjs +2 -2
- package/dist/plugins/errors.js +2 -2
- package/dist/plugins/marketplace/errors.cjs +4 -4
- package/dist/plugins/marketplace/errors.js +4 -4
- package/dist/preferences/errors.cjs +1 -1
- package/dist/preferences/errors.js +1 -1
- package/dist/registry/registry.cjs +3 -3
- package/dist/registry/registry.js +3 -3
- package/dist/resolver.cjs +1 -1
- package/dist/resolver.js +1 -1
- package/dist/tool-factories/agent-spawner/factory.cjs +1 -218
- package/dist/tool-factories/agent-spawner/factory.d.ts.map +1 -1
- package/dist/tool-factories/agent-spawner/factory.js +1 -228
- package/package.json +5 -6
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { TOOL_ACTIVITY, createLocalToolCallHeader, truncateForHeader } from "@dexto/core";
|
|
2
2
|
import { ToolError } from "@dexto/core";
|
|
3
|
-
import {
|
|
4
|
-
ConditionEngine,
|
|
5
|
-
SignalBus,
|
|
6
|
-
TaskRegistry,
|
|
7
|
-
createCheckTaskTool,
|
|
8
|
-
createListTasksTool,
|
|
9
|
-
createWaitForTool,
|
|
10
|
-
WaitForInputSchema,
|
|
11
|
-
CheckTaskInputSchema,
|
|
12
|
-
ListTasksInputSchema
|
|
13
|
-
} from "@dexto/orchestration";
|
|
14
3
|
import {
|
|
15
4
|
AgentSpawnerConfigSchema,
|
|
16
5
|
SpawnAgentInputSchema
|
|
@@ -59,152 +48,10 @@ const agentSpawnerToolsFactory = {
|
|
|
59
48
|
state.runtime.cleanup().catch(() => void 0);
|
|
60
49
|
}
|
|
61
50
|
state = void 0;
|
|
62
|
-
const signalBus = new SignalBus();
|
|
63
|
-
const taskRegistry = new TaskRegistry(signalBus);
|
|
64
|
-
const conditionEngine = new ConditionEngine(taskRegistry, signalBus, logger);
|
|
65
51
|
const spawnerRuntime = new AgentSpawnerRuntime(agent, config, logger);
|
|
66
52
|
updateWorkspaceRootHint(spawnerRuntime, context);
|
|
67
53
|
attachTaskForker({ toolServices, taskForker: spawnerRuntime, logger });
|
|
68
|
-
const taskSessions = /* @__PURE__ */ new Map();
|
|
69
|
-
const taskHostRuntimeContexts = /* @__PURE__ */ new Map();
|
|
70
|
-
const emitTasksUpdate = (sessionId) => {
|
|
71
|
-
const tasks = taskRegistry.list({
|
|
72
|
-
status: ["running", "completed", "failed", "cancelled"]
|
|
73
|
-
});
|
|
74
|
-
const scopedTasks = sessionId ? tasks.filter((task) => taskSessions.get(task.taskId) === sessionId) : tasks;
|
|
75
|
-
const runningCount = scopedTasks.filter((task) => task.status === "running").length;
|
|
76
|
-
agent.emit("service:event", {
|
|
77
|
-
service: "orchestration",
|
|
78
|
-
event: "tasks-updated",
|
|
79
|
-
sessionId: sessionId ?? "",
|
|
80
|
-
data: {
|
|
81
|
-
runningCount,
|
|
82
|
-
tasks: scopedTasks.map((task) => ({
|
|
83
|
-
taskId: task.taskId,
|
|
84
|
-
status: task.status,
|
|
85
|
-
...task.description !== void 0 && {
|
|
86
|
-
description: task.description
|
|
87
|
-
}
|
|
88
|
-
}))
|
|
89
|
-
}
|
|
90
|
-
});
|
|
91
|
-
};
|
|
92
|
-
const triggerBackgroundCompletion = (taskId, sessionId, hostRuntime) => {
|
|
93
|
-
if (!sessionId) {
|
|
94
|
-
return;
|
|
95
|
-
}
|
|
96
|
-
agent.emit("tool:background-completed", {
|
|
97
|
-
toolCallId: taskId,
|
|
98
|
-
sessionId,
|
|
99
|
-
...hostRuntime !== void 0 && { hostRuntime }
|
|
100
|
-
});
|
|
101
|
-
const taskInfo = taskRegistry.getInfo(taskId);
|
|
102
|
-
const resultText = (() => {
|
|
103
|
-
if (taskInfo?.status === "failed") {
|
|
104
|
-
return taskInfo.error ?? "Unknown error.";
|
|
105
|
-
}
|
|
106
|
-
if (taskInfo?.result !== void 0) {
|
|
107
|
-
if (typeof taskInfo.result === "string") {
|
|
108
|
-
return taskInfo.result;
|
|
109
|
-
}
|
|
110
|
-
try {
|
|
111
|
-
return JSON.stringify(taskInfo.result, null, 2);
|
|
112
|
-
} catch {
|
|
113
|
-
return String(taskInfo.result ?? "<unserializable result>");
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
return "No result available.";
|
|
117
|
-
})();
|
|
118
|
-
const sanitizeCdata = (value) => value.replace(/\]\]>/g, "]]]]><![CDATA[>");
|
|
119
|
-
const safeDescription = taskInfo?.description ? sanitizeCdata(taskInfo.description) : null;
|
|
120
|
-
const safeResultText = sanitizeCdata(resultText);
|
|
121
|
-
const descriptionTag = safeDescription ? ` <description><![CDATA[${safeDescription}]]></description>
|
|
122
|
-
` : "";
|
|
123
|
-
const statusTag = taskInfo?.status ? ` <status>${taskInfo.status}</status>
|
|
124
|
-
` : "";
|
|
125
|
-
const content = [
|
|
126
|
-
{
|
|
127
|
-
type: "text",
|
|
128
|
-
text: `<background-task-completion>
|
|
129
|
-
<origin>task</origin>
|
|
130
|
-
<note>The following response was reported by the background task (not user input).</note>
|
|
131
|
-
<taskId>${taskId}</taskId>
|
|
132
|
-
` + statusTag + descriptionTag + ` <result><![CDATA[${safeResultText}]]></result>
|
|
133
|
-
</background-task-completion>`
|
|
134
|
-
}
|
|
135
|
-
];
|
|
136
|
-
agent.isSessionBusy(sessionId).then((isBusy) => {
|
|
137
|
-
if (isBusy) {
|
|
138
|
-
agent.steer(sessionId, {
|
|
139
|
-
content,
|
|
140
|
-
kind: "background"
|
|
141
|
-
}).catch(() => void 0);
|
|
142
|
-
} else {
|
|
143
|
-
agent.emit("run:invoke", {
|
|
144
|
-
sessionId,
|
|
145
|
-
content,
|
|
146
|
-
source: "external",
|
|
147
|
-
metadata: { taskId },
|
|
148
|
-
...hostRuntime !== void 0 && { hostRuntime }
|
|
149
|
-
});
|
|
150
|
-
agent.generate(content, sessionId, {
|
|
151
|
-
...hostRuntime !== void 0 && {
|
|
152
|
-
executionContext: hostRuntime
|
|
153
|
-
}
|
|
154
|
-
}).catch(() => void 0);
|
|
155
|
-
}
|
|
156
|
-
}).catch(() => {
|
|
157
|
-
});
|
|
158
|
-
};
|
|
159
|
-
const handleBackground = (event) => {
|
|
160
|
-
const taskId = event.toolCallId;
|
|
161
|
-
if (taskRegistry.has(taskId)) {
|
|
162
|
-
return;
|
|
163
|
-
}
|
|
164
|
-
if (event.sessionId) {
|
|
165
|
-
taskSessions.set(taskId, event.sessionId);
|
|
166
|
-
}
|
|
167
|
-
if (event.hostRuntime !== void 0) {
|
|
168
|
-
taskHostRuntimeContexts.set(taskId, event.hostRuntime);
|
|
169
|
-
}
|
|
170
|
-
try {
|
|
171
|
-
taskRegistry.register(
|
|
172
|
-
{
|
|
173
|
-
type: "generic",
|
|
174
|
-
taskId,
|
|
175
|
-
description: event.description ?? `Tool ${event.toolName}`,
|
|
176
|
-
promise: event.promise
|
|
177
|
-
},
|
|
178
|
-
{
|
|
179
|
-
...event.timeoutMs !== void 0 && { timeout: event.timeoutMs },
|
|
180
|
-
...event.notifyOnComplete !== void 0 && {
|
|
181
|
-
notify: event.notifyOnComplete
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
);
|
|
185
|
-
} catch (error) {
|
|
186
|
-
taskSessions.delete(taskId);
|
|
187
|
-
taskHostRuntimeContexts.delete(taskId);
|
|
188
|
-
event.promise.catch(() => void 0);
|
|
189
|
-
logger.warn(
|
|
190
|
-
`Failed to register background task ${taskId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
191
|
-
{ color: "yellow" }
|
|
192
|
-
);
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
195
|
-
emitTasksUpdate(event.sessionId);
|
|
196
|
-
event.promise.finally(() => {
|
|
197
|
-
taskSessions.delete(taskId);
|
|
198
|
-
const hostRuntime = taskHostRuntimeContexts.get(taskId);
|
|
199
|
-
taskHostRuntimeContexts.delete(taskId);
|
|
200
|
-
emitTasksUpdate(event.sessionId);
|
|
201
|
-
triggerBackgroundCompletion(taskId, event.sessionId, hostRuntime);
|
|
202
|
-
});
|
|
203
|
-
};
|
|
204
54
|
const abortController = new AbortController();
|
|
205
|
-
agent.on("tool:background", handleBackground, {
|
|
206
|
-
signal: abortController.signal
|
|
207
|
-
});
|
|
208
55
|
agent.on(
|
|
209
56
|
"agent:stopped",
|
|
210
57
|
() => {
|
|
@@ -214,14 +61,8 @@ const agentSpawnerToolsFactory = {
|
|
|
214
61
|
{ signal: abortController.signal }
|
|
215
62
|
);
|
|
216
63
|
const spawnAgentTool = createSpawnAgentTool(spawnerRuntime);
|
|
217
|
-
const waitForTool = createWaitForTool(conditionEngine);
|
|
218
|
-
const checkTaskTool = createCheckTaskTool(taskRegistry);
|
|
219
|
-
const listTasksTool = createListTasksTool(taskRegistry);
|
|
220
64
|
const tools = {
|
|
221
|
-
spawnAgent: spawnAgentTool
|
|
222
|
-
waitFor: waitForTool,
|
|
223
|
-
checkTask: checkTaskTool,
|
|
224
|
-
listTasks: listTasksTool
|
|
65
|
+
spawnAgent: spawnAgentTool
|
|
225
66
|
};
|
|
226
67
|
state = {
|
|
227
68
|
agent,
|
|
@@ -266,74 +107,6 @@ const agentSpawnerToolsFactory = {
|
|
|
266
107
|
return await previewFn(input, context);
|
|
267
108
|
}
|
|
268
109
|
}
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
id: "wait_for",
|
|
272
|
-
description: "Wait for background task(s) to complete.",
|
|
273
|
-
inputSchema: WaitForInputSchema,
|
|
274
|
-
execute: (input, context) => ensureToolsInitialized(context).waitFor.execute(input, context),
|
|
275
|
-
presentation: {
|
|
276
|
-
activity: TOOL_ACTIVITY.wait,
|
|
277
|
-
describeHeader: (input) => {
|
|
278
|
-
const argsText = input.taskId ? truncateForHeader(input.taskId, 80) : input.taskIds && input.taskIds.length > 0 ? truncateForHeader(`${input.taskIds.length} tasks`, 80) : void 0;
|
|
279
|
-
return createLocalToolCallHeader({
|
|
280
|
-
title: "Wait",
|
|
281
|
-
...argsText ? { argsText } : {}
|
|
282
|
-
});
|
|
283
|
-
},
|
|
284
|
-
preview: async (input, context) => {
|
|
285
|
-
const tool = ensureToolsInitialized(context).waitFor;
|
|
286
|
-
const previewFn = tool.presentation?.preview;
|
|
287
|
-
if (!previewFn) {
|
|
288
|
-
return null;
|
|
289
|
-
}
|
|
290
|
-
return await previewFn(input, context);
|
|
291
|
-
}
|
|
292
|
-
}
|
|
293
|
-
},
|
|
294
|
-
{
|
|
295
|
-
id: "check_task",
|
|
296
|
-
description: "Check the status of a background task.",
|
|
297
|
-
inputSchema: CheckTaskInputSchema,
|
|
298
|
-
execute: (input, context) => ensureToolsInitialized(context).checkTask.execute(input, context),
|
|
299
|
-
presentation: {
|
|
300
|
-
activity: TOOL_ACTIVITY.checkTask,
|
|
301
|
-
describeHeader: (input) => {
|
|
302
|
-
const argsText = truncateForHeader(input.taskId, 80);
|
|
303
|
-
return createLocalToolCallHeader({
|
|
304
|
-
title: "Check Task",
|
|
305
|
-
...argsText ? { argsText } : {}
|
|
306
|
-
});
|
|
307
|
-
},
|
|
308
|
-
preview: async (input, context) => {
|
|
309
|
-
const tool = ensureToolsInitialized(context).checkTask;
|
|
310
|
-
const previewFn = tool.presentation?.preview;
|
|
311
|
-
if (!previewFn) {
|
|
312
|
-
return null;
|
|
313
|
-
}
|
|
314
|
-
return await previewFn(input, context);
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
},
|
|
318
|
-
{
|
|
319
|
-
id: "list_tasks",
|
|
320
|
-
description: "List background tasks and their statuses.",
|
|
321
|
-
inputSchema: ListTasksInputSchema,
|
|
322
|
-
execute: (input, context) => ensureToolsInitialized(context).listTasks.execute(input, context),
|
|
323
|
-
presentation: {
|
|
324
|
-
activity: TOOL_ACTIVITY.listTasks,
|
|
325
|
-
describeHeader: () => createLocalToolCallHeader({
|
|
326
|
-
title: "List Tasks"
|
|
327
|
-
}),
|
|
328
|
-
preview: async (input, context) => {
|
|
329
|
-
const tool = ensureToolsInitialized(context).listTasks;
|
|
330
|
-
const previewFn = tool.presentation?.preview;
|
|
331
|
-
if (!previewFn) {
|
|
332
|
-
return null;
|
|
333
|
-
}
|
|
334
|
-
return await previewFn(input, context);
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
110
|
}
|
|
338
111
|
];
|
|
339
112
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dexto/agent-management",
|
|
3
|
-
"version": "1.15.0-beta.
|
|
3
|
+
"version": "1.15.0-beta.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -22,11 +22,10 @@
|
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"yaml": "^2.8.3",
|
|
24
24
|
"zod": "^4.3.6",
|
|
25
|
-
"@dexto/agent-config": "1.
|
|
26
|
-
"@dexto/
|
|
27
|
-
"@dexto/
|
|
28
|
-
"@dexto/
|
|
29
|
-
"@dexto/llm": "1.14.4"
|
|
25
|
+
"@dexto/agent-config": "1.15.0-beta.2",
|
|
26
|
+
"@dexto/llm": "1.14.4",
|
|
27
|
+
"@dexto/tools-builtins": "1.15.0-beta.2",
|
|
28
|
+
"@dexto/core": "1.15.0-beta.2"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"@types/node": "^22.13.5"
|