@dexto/agent-management 1.17.0 → 1.18.1
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-accounts.cjs +277 -0
- package/dist/auth/dexto-accounts.d.ts +144 -0
- package/dist/auth/dexto-accounts.d.ts.map +1 -0
- package/dist/auth/dexto-accounts.js +230 -0
- package/dist/auth/dexto-cloud.cjs +51 -0
- package/dist/auth/dexto-cloud.d.ts +9 -0
- package/dist/auth/dexto-cloud.d.ts.map +1 -0
- package/dist/auth/dexto-cloud.js +27 -0
- package/dist/auth/dexto-gateway.cjs +162 -0
- package/dist/auth/dexto-gateway.d.ts +55 -0
- package/dist/auth/dexto-gateway.d.ts.map +1 -0
- package/dist/auth/dexto-gateway.js +133 -0
- package/dist/auth/dexto-mcp.cjs +77 -0
- package/dist/auth/dexto-mcp.d.ts +23 -0
- package/dist/auth/dexto-mcp.d.ts.map +1 -0
- package/dist/auth/dexto-mcp.js +49 -0
- package/dist/auth/dexto-sign-in.cjs +345 -0
- package/dist/auth/dexto-sign-in.d.ts +86 -0
- package/dist/auth/dexto-sign-in.d.ts.map +1 -0
- package/dist/auth/dexto-sign-in.js +314 -0
- package/dist/auth/index.cjs +25 -0
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +10 -0
- package/dist/auth/model-auth-handlers.cjs +3 -1
- package/dist/auth/model-auth-handlers.d.ts +6 -1
- package/dist/auth/model-auth-handlers.d.ts.map +1 -1
- package/dist/auth/model-auth-handlers.js +6 -1
- 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 +40 -29
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -6
- 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/dist/utils/dexto-auth.cjs +3 -58
- package/dist/utils/dexto-auth.d.ts +4 -18
- package/dist/utils/dexto-auth.d.ts.map +1 -1
- package/dist/utils/dexto-auth.js +3 -57
- package/package.json +5 -6
package/dist/resolver.cjs
CHANGED
|
@@ -76,7 +76,7 @@ async function resolveAgentByName(agentId, autoInstall) {
|
|
|
76
76
|
}
|
|
77
77
|
if (autoInstall) {
|
|
78
78
|
try {
|
|
79
|
-
import_core.logger.
|
|
79
|
+
import_core.logger.debug(`Auto-installing agent '${agentId}' from bundled registry`);
|
|
80
80
|
const configPath = await (0, import_installation.installBundledAgent)(agentId);
|
|
81
81
|
return configPath;
|
|
82
82
|
} catch (error) {
|
package/dist/resolver.js
CHANGED
|
@@ -49,7 +49,7 @@ async function resolveAgentByName(agentId, autoInstall) {
|
|
|
49
49
|
}
|
|
50
50
|
if (autoInstall) {
|
|
51
51
|
try {
|
|
52
|
-
logger.
|
|
52
|
+
logger.debug(`Auto-installing agent '${agentId}' from bundled registry`);
|
|
53
53
|
const configPath = await installBundledAgent(agentId);
|
|
54
54
|
return configPath;
|
|
55
55
|
} catch (error) {
|
|
@@ -23,7 +23,6 @@ __export(factory_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(factory_exports);
|
|
24
24
|
var import_core = require("@dexto/core");
|
|
25
25
|
var import_core2 = require("@dexto/core");
|
|
26
|
-
var import_orchestration = require("@dexto/orchestration");
|
|
27
26
|
var import_schemas = require("./schemas.js");
|
|
28
27
|
var import_runtime = require("./runtime.js");
|
|
29
28
|
var import_spawn_agent_tool = require("./spawn-agent-tool.js");
|
|
@@ -69,152 +68,10 @@ const agentSpawnerToolsFactory = {
|
|
|
69
68
|
state.runtime.cleanup().catch(() => void 0);
|
|
70
69
|
}
|
|
71
70
|
state = void 0;
|
|
72
|
-
const signalBus = new import_orchestration.SignalBus();
|
|
73
|
-
const taskRegistry = new import_orchestration.TaskRegistry(signalBus);
|
|
74
|
-
const conditionEngine = new import_orchestration.ConditionEngine(taskRegistry, signalBus, logger);
|
|
75
71
|
const spawnerRuntime = new import_runtime.AgentSpawnerRuntime(agent, config, logger);
|
|
76
72
|
updateWorkspaceRootHint(spawnerRuntime, context);
|
|
77
73
|
attachTaskForker({ toolServices, taskForker: spawnerRuntime, logger });
|
|
78
|
-
const taskSessions = /* @__PURE__ */ new Map();
|
|
79
|
-
const taskHostRuntimeContexts = /* @__PURE__ */ new Map();
|
|
80
|
-
const emitTasksUpdate = (sessionId) => {
|
|
81
|
-
const tasks = taskRegistry.list({
|
|
82
|
-
status: ["running", "completed", "failed", "cancelled"]
|
|
83
|
-
});
|
|
84
|
-
const scopedTasks = sessionId ? tasks.filter((task) => taskSessions.get(task.taskId) === sessionId) : tasks;
|
|
85
|
-
const runningCount = scopedTasks.filter((task) => task.status === "running").length;
|
|
86
|
-
agent.emit("service:event", {
|
|
87
|
-
service: "orchestration",
|
|
88
|
-
event: "tasks-updated",
|
|
89
|
-
sessionId: sessionId ?? "",
|
|
90
|
-
data: {
|
|
91
|
-
runningCount,
|
|
92
|
-
tasks: scopedTasks.map((task) => ({
|
|
93
|
-
taskId: task.taskId,
|
|
94
|
-
status: task.status,
|
|
95
|
-
...task.description !== void 0 && {
|
|
96
|
-
description: task.description
|
|
97
|
-
}
|
|
98
|
-
}))
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
};
|
|
102
|
-
const triggerBackgroundCompletion = (taskId, sessionId, hostRuntime) => {
|
|
103
|
-
if (!sessionId) {
|
|
104
|
-
return;
|
|
105
|
-
}
|
|
106
|
-
agent.emit("tool:background-completed", {
|
|
107
|
-
toolCallId: taskId,
|
|
108
|
-
sessionId,
|
|
109
|
-
...hostRuntime !== void 0 && { hostRuntime }
|
|
110
|
-
});
|
|
111
|
-
const taskInfo = taskRegistry.getInfo(taskId);
|
|
112
|
-
const resultText = (() => {
|
|
113
|
-
if (taskInfo?.status === "failed") {
|
|
114
|
-
return taskInfo.error ?? "Unknown error.";
|
|
115
|
-
}
|
|
116
|
-
if (taskInfo?.result !== void 0) {
|
|
117
|
-
if (typeof taskInfo.result === "string") {
|
|
118
|
-
return taskInfo.result;
|
|
119
|
-
}
|
|
120
|
-
try {
|
|
121
|
-
return JSON.stringify(taskInfo.result, null, 2);
|
|
122
|
-
} catch {
|
|
123
|
-
return String(taskInfo.result ?? "<unserializable result>");
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
return "No result available.";
|
|
127
|
-
})();
|
|
128
|
-
const sanitizeCdata = (value) => value.replace(/\]\]>/g, "]]]]><![CDATA[>");
|
|
129
|
-
const safeDescription = taskInfo?.description ? sanitizeCdata(taskInfo.description) : null;
|
|
130
|
-
const safeResultText = sanitizeCdata(resultText);
|
|
131
|
-
const descriptionTag = safeDescription ? ` <description><![CDATA[${safeDescription}]]></description>
|
|
132
|
-
` : "";
|
|
133
|
-
const statusTag = taskInfo?.status ? ` <status>${taskInfo.status}</status>
|
|
134
|
-
` : "";
|
|
135
|
-
const content = [
|
|
136
|
-
{
|
|
137
|
-
type: "text",
|
|
138
|
-
text: `<background-task-completion>
|
|
139
|
-
<origin>task</origin>
|
|
140
|
-
<note>The following response was reported by the background task (not user input).</note>
|
|
141
|
-
<taskId>${taskId}</taskId>
|
|
142
|
-
` + statusTag + descriptionTag + ` <result><![CDATA[${safeResultText}]]></result>
|
|
143
|
-
</background-task-completion>`
|
|
144
|
-
}
|
|
145
|
-
];
|
|
146
|
-
agent.isSessionBusy(sessionId).then((isBusy) => {
|
|
147
|
-
if (isBusy) {
|
|
148
|
-
agent.steer(sessionId, {
|
|
149
|
-
content,
|
|
150
|
-
kind: "background"
|
|
151
|
-
}).catch(() => void 0);
|
|
152
|
-
} else {
|
|
153
|
-
agent.emit("run:invoke", {
|
|
154
|
-
sessionId,
|
|
155
|
-
content,
|
|
156
|
-
source: "external",
|
|
157
|
-
metadata: { taskId },
|
|
158
|
-
...hostRuntime !== void 0 && { hostRuntime }
|
|
159
|
-
});
|
|
160
|
-
agent.generate(content, sessionId, {
|
|
161
|
-
...hostRuntime !== void 0 && {
|
|
162
|
-
executionContext: hostRuntime
|
|
163
|
-
}
|
|
164
|
-
}).catch(() => void 0);
|
|
165
|
-
}
|
|
166
|
-
}).catch(() => {
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
const handleBackground = (event) => {
|
|
170
|
-
const taskId = event.toolCallId;
|
|
171
|
-
if (taskRegistry.has(taskId)) {
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (event.sessionId) {
|
|
175
|
-
taskSessions.set(taskId, event.sessionId);
|
|
176
|
-
}
|
|
177
|
-
if (event.hostRuntime !== void 0) {
|
|
178
|
-
taskHostRuntimeContexts.set(taskId, event.hostRuntime);
|
|
179
|
-
}
|
|
180
|
-
try {
|
|
181
|
-
taskRegistry.register(
|
|
182
|
-
{
|
|
183
|
-
type: "generic",
|
|
184
|
-
taskId,
|
|
185
|
-
description: event.description ?? `Tool ${event.toolName}`,
|
|
186
|
-
promise: event.promise
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
...event.timeoutMs !== void 0 && { timeout: event.timeoutMs },
|
|
190
|
-
...event.notifyOnComplete !== void 0 && {
|
|
191
|
-
notify: event.notifyOnComplete
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
);
|
|
195
|
-
} catch (error) {
|
|
196
|
-
taskSessions.delete(taskId);
|
|
197
|
-
taskHostRuntimeContexts.delete(taskId);
|
|
198
|
-
event.promise.catch(() => void 0);
|
|
199
|
-
logger.warn(
|
|
200
|
-
`Failed to register background task ${taskId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
201
|
-
{ color: "yellow" }
|
|
202
|
-
);
|
|
203
|
-
return;
|
|
204
|
-
}
|
|
205
|
-
emitTasksUpdate(event.sessionId);
|
|
206
|
-
event.promise.finally(() => {
|
|
207
|
-
taskSessions.delete(taskId);
|
|
208
|
-
const hostRuntime = taskHostRuntimeContexts.get(taskId);
|
|
209
|
-
taskHostRuntimeContexts.delete(taskId);
|
|
210
|
-
emitTasksUpdate(event.sessionId);
|
|
211
|
-
triggerBackgroundCompletion(taskId, event.sessionId, hostRuntime);
|
|
212
|
-
});
|
|
213
|
-
};
|
|
214
74
|
const abortController = new AbortController();
|
|
215
|
-
agent.on("tool:background", handleBackground, {
|
|
216
|
-
signal: abortController.signal
|
|
217
|
-
});
|
|
218
75
|
agent.on(
|
|
219
76
|
"agent:stopped",
|
|
220
77
|
() => {
|
|
@@ -224,14 +81,8 @@ const agentSpawnerToolsFactory = {
|
|
|
224
81
|
{ signal: abortController.signal }
|
|
225
82
|
);
|
|
226
83
|
const spawnAgentTool = (0, import_spawn_agent_tool.createSpawnAgentTool)(spawnerRuntime);
|
|
227
|
-
const waitForTool = (0, import_orchestration.createWaitForTool)(conditionEngine);
|
|
228
|
-
const checkTaskTool = (0, import_orchestration.createCheckTaskTool)(taskRegistry);
|
|
229
|
-
const listTasksTool = (0, import_orchestration.createListTasksTool)(taskRegistry);
|
|
230
84
|
const tools = {
|
|
231
|
-
spawnAgent: spawnAgentTool
|
|
232
|
-
waitFor: waitForTool,
|
|
233
|
-
checkTask: checkTaskTool,
|
|
234
|
-
listTasks: listTasksTool
|
|
85
|
+
spawnAgent: spawnAgentTool
|
|
235
86
|
};
|
|
236
87
|
state = {
|
|
237
88
|
agent,
|
|
@@ -276,74 +127,6 @@ const agentSpawnerToolsFactory = {
|
|
|
276
127
|
return await previewFn(input, context);
|
|
277
128
|
}
|
|
278
129
|
}
|
|
279
|
-
},
|
|
280
|
-
{
|
|
281
|
-
id: "wait_for",
|
|
282
|
-
description: "Wait for background task(s) to complete.",
|
|
283
|
-
inputSchema: import_orchestration.WaitForInputSchema,
|
|
284
|
-
execute: (input, context) => ensureToolsInitialized(context).waitFor.execute(input, context),
|
|
285
|
-
presentation: {
|
|
286
|
-
activity: import_core.TOOL_ACTIVITY.wait,
|
|
287
|
-
describeHeader: (input) => {
|
|
288
|
-
const argsText = input.taskId ? (0, import_core.truncateForHeader)(input.taskId, 80) : input.taskIds && input.taskIds.length > 0 ? (0, import_core.truncateForHeader)(`${input.taskIds.length} tasks`, 80) : void 0;
|
|
289
|
-
return (0, import_core.createLocalToolCallHeader)({
|
|
290
|
-
title: "Wait",
|
|
291
|
-
...argsText ? { argsText } : {}
|
|
292
|
-
});
|
|
293
|
-
},
|
|
294
|
-
preview: async (input, context) => {
|
|
295
|
-
const tool = ensureToolsInitialized(context).waitFor;
|
|
296
|
-
const previewFn = tool.presentation?.preview;
|
|
297
|
-
if (!previewFn) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
return await previewFn(input, context);
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
},
|
|
304
|
-
{
|
|
305
|
-
id: "check_task",
|
|
306
|
-
description: "Check the status of a background task.",
|
|
307
|
-
inputSchema: import_orchestration.CheckTaskInputSchema,
|
|
308
|
-
execute: (input, context) => ensureToolsInitialized(context).checkTask.execute(input, context),
|
|
309
|
-
presentation: {
|
|
310
|
-
activity: import_core.TOOL_ACTIVITY.checkTask,
|
|
311
|
-
describeHeader: (input) => {
|
|
312
|
-
const argsText = (0, import_core.truncateForHeader)(input.taskId, 80);
|
|
313
|
-
return (0, import_core.createLocalToolCallHeader)({
|
|
314
|
-
title: "Check Task",
|
|
315
|
-
...argsText ? { argsText } : {}
|
|
316
|
-
});
|
|
317
|
-
},
|
|
318
|
-
preview: async (input, context) => {
|
|
319
|
-
const tool = ensureToolsInitialized(context).checkTask;
|
|
320
|
-
const previewFn = tool.presentation?.preview;
|
|
321
|
-
if (!previewFn) {
|
|
322
|
-
return null;
|
|
323
|
-
}
|
|
324
|
-
return await previewFn(input, context);
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
},
|
|
328
|
-
{
|
|
329
|
-
id: "list_tasks",
|
|
330
|
-
description: "List background tasks and their statuses.",
|
|
331
|
-
inputSchema: import_orchestration.ListTasksInputSchema,
|
|
332
|
-
execute: (input, context) => ensureToolsInitialized(context).listTasks.execute(input, context),
|
|
333
|
-
presentation: {
|
|
334
|
-
activity: import_core.TOOL_ACTIVITY.listTasks,
|
|
335
|
-
describeHeader: () => (0, import_core.createLocalToolCallHeader)({
|
|
336
|
-
title: "List Tasks"
|
|
337
|
-
}),
|
|
338
|
-
preview: async (input, context) => {
|
|
339
|
-
const tool = ensureToolsInitialized(context).listTasks;
|
|
340
|
-
const previewFn = tool.presentation?.preview;
|
|
341
|
-
if (!previewFn) {
|
|
342
|
-
return null;
|
|
343
|
-
}
|
|
344
|
-
return await previewFn(input, context);
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
130
|
}
|
|
348
131
|
];
|
|
349
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,OAAO,EAGH,KAAK,kBAAkB,EAE1B,MAAM,cAAc,CAAC;AA+BtB,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,kBAAkB,CA4HpE,CAAC"}
|
|
@@ -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
|
}
|
|
@@ -19,73 +19,18 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var dexto_auth_exports = {};
|
|
20
20
|
__export(dexto_auth_exports, {
|
|
21
21
|
canUseDextoProvider: () => canUseDextoProvider,
|
|
22
|
-
getDextoApiKeyFromAuth: () => getDextoApiKeyFromAuth,
|
|
23
22
|
isDextoAuthenticated: () => isDextoAuthenticated
|
|
24
23
|
});
|
|
25
24
|
module.exports = __toCommonJS(dexto_auth_exports);
|
|
26
|
-
var
|
|
27
|
-
var import_zod = require("zod");
|
|
28
|
-
var import_core = require("@dexto/core");
|
|
29
|
-
const AUTH_CONFIG_FILE = "auth.json";
|
|
30
|
-
const AuthConfigSchema = import_zod.z.object({
|
|
31
|
-
token: import_zod.z.string().min(1).optional(),
|
|
32
|
-
refreshToken: import_zod.z.string().optional(),
|
|
33
|
-
expiresAt: import_zod.z.number().optional(),
|
|
34
|
-
createdAt: import_zod.z.number().optional(),
|
|
35
|
-
dextoApiKey: import_zod.z.string().optional(),
|
|
36
|
-
dextoKeyId: import_zod.z.string().optional(),
|
|
37
|
-
dextoApiKeySource: import_zod.z.enum(["provisioned", "user-supplied"]).optional()
|
|
38
|
-
}).refine((data) => data.token || data.dextoApiKey, {
|
|
39
|
-
message: "Either token or dextoApiKey is required"
|
|
40
|
-
});
|
|
41
|
-
async function loadAuthConfig() {
|
|
42
|
-
const authPath = (0, import_core.getDextoGlobalPath)("", AUTH_CONFIG_FILE);
|
|
43
|
-
if (!(0, import_fs.existsSync)(authPath)) {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
try {
|
|
47
|
-
const content = await import_fs.promises.readFile(authPath, "utf-8");
|
|
48
|
-
const config = JSON.parse(content);
|
|
49
|
-
const validated = AuthConfigSchema.safeParse(config);
|
|
50
|
-
if (!validated.success) {
|
|
51
|
-
return null;
|
|
52
|
-
}
|
|
53
|
-
const auth = validated.data;
|
|
54
|
-
if (auth.expiresAt && auth.expiresAt < Date.now()) {
|
|
55
|
-
if (!auth.refreshToken && !auth.dextoApiKey) {
|
|
56
|
-
return null;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return auth;
|
|
60
|
-
} catch {
|
|
61
|
-
return null;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
25
|
+
var import_dexto_gateway = require("../auth/dexto-gateway.js");
|
|
64
26
|
async function isDextoAuthenticated() {
|
|
65
|
-
return await
|
|
66
|
-
}
|
|
67
|
-
async function getDextoApiKeyFromAuth() {
|
|
68
|
-
const auth = await loadAuthConfig();
|
|
69
|
-
if (auth?.dextoApiKey?.trim()) {
|
|
70
|
-
const apiKey = auth.dextoApiKey.trim();
|
|
71
|
-
process.env.DEXTO_API_KEY = apiKey;
|
|
72
|
-
return apiKey;
|
|
73
|
-
}
|
|
74
|
-
if (process.env.DEXTO_API_KEY?.trim()) {
|
|
75
|
-
return process.env.DEXTO_API_KEY;
|
|
76
|
-
}
|
|
77
|
-
return null;
|
|
27
|
+
return (await (0, import_dexto_gateway.dextoModelAccess)((0, import_dexto_gateway.defaultDextoGatewayOptions)())).status !== "signed_out";
|
|
78
28
|
}
|
|
79
29
|
async function canUseDextoProvider() {
|
|
80
|
-
|
|
81
|
-
if (!authenticated) return false;
|
|
82
|
-
const apiKey = await getDextoApiKeyFromAuth();
|
|
83
|
-
if (!apiKey) return false;
|
|
84
|
-
return true;
|
|
30
|
+
return (await (0, import_dexto_gateway.dextoModelAccess)((0, import_dexto_gateway.defaultDextoGatewayOptions)())).status === "ready";
|
|
85
31
|
}
|
|
86
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
87
33
|
0 && (module.exports = {
|
|
88
34
|
canUseDextoProvider,
|
|
89
|
-
getDextoApiKeyFromAuth,
|
|
90
35
|
isDextoAuthenticated
|
|
91
36
|
});
|
|
@@ -1,23 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Dexto
|
|
3
|
-
*
|
|
4
|
-
* Provides functions to check dexto authentication status.
|
|
5
|
-
* Used by both CLI and server to determine if user can use dexto features.
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* Check if user is authenticated with Dexto.
|
|
9
|
-
* Returns true when auth.json contains usable Dexto auth state.
|
|
2
|
+
* Whether this machine can use Dexto: signed in (`dexto login`) or DEXTO_API_KEY. Used by the CLI
|
|
3
|
+
* and the local server's Web UI.
|
|
10
4
|
*/
|
|
5
|
+
/** Signed in to Dexto, or DEXTO_API_KEY is set. */
|
|
11
6
|
export declare function isDextoAuthenticated(): Promise<boolean>;
|
|
12
|
-
/**
|
|
13
|
-
* Get the dexto API key from auth config or environment.
|
|
14
|
-
*/
|
|
15
|
-
export declare function getDextoApiKeyFromAuth(): Promise<string | null>;
|
|
16
|
-
/**
|
|
17
|
-
* Check if user can use Dexto provider.
|
|
18
|
-
* Requires BOTH:
|
|
19
|
-
* 1. User has usable Dexto auth state (token, refresh-backed login, or stored API key)
|
|
20
|
-
* 2. Has DEXTO_API_KEY (from auth config or environment)
|
|
21
|
-
*/
|
|
7
|
+
/** Dexto models can run now: signed in with permission to spend credits, or DEXTO_API_KEY. */
|
|
22
8
|
export declare function canUseDextoProvider(): Promise<boolean>;
|
|
23
9
|
//# sourceMappingURL=dexto-auth.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dexto-auth.d.ts","sourceRoot":"","sources":["../../src/utils/dexto-auth.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"dexto-auth.d.ts","sourceRoot":"","sources":["../../src/utils/dexto-auth.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,mDAAmD;AACnD,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,OAAO,CAAC,CAE7D;AAED,8FAA8F;AAC9F,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,OAAO,CAAC,CAE5D"}
|