@dexto/agent-management 1.5.8 → 1.6.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/AgentFactory.cjs +5 -9
- package/dist/AgentFactory.d.ts +6 -5
- package/dist/AgentFactory.d.ts.map +1 -1
- package/dist/AgentFactory.js +5 -9
- package/dist/AgentManager.cjs +2 -2
- package/dist/AgentManager.d.ts +1 -1
- package/dist/AgentManager.d.ts.map +1 -1
- package/dist/AgentManager.js +4 -4
- package/dist/agent-creation.cjs +95 -0
- package/dist/agent-creation.d.ts +15 -0
- package/dist/agent-creation.d.ts.map +1 -0
- package/dist/agent-creation.js +78 -0
- package/dist/config/config-enrichment.cjs +8 -14
- package/dist/config/config-enrichment.d.ts +7 -1
- package/dist/config/config-enrichment.d.ts.map +1 -1
- package/dist/config/config-enrichment.js +8 -14
- package/dist/config/config-manager.cjs +4 -4
- package/dist/config/config-manager.d.ts +1 -1
- package/dist/config/config-manager.d.ts.map +1 -1
- package/dist/config/config-manager.js +3 -1
- package/dist/config/loader.d.ts +3 -3
- package/dist/config/loader.d.ts.map +1 -1
- package/dist/images/image-store.cjs +256 -0
- package/dist/images/image-store.d.ts +70 -0
- package/dist/images/image-store.d.ts.map +1 -0
- package/dist/images/image-store.js +210 -0
- package/dist/index.cjs +32 -2
- package/dist/index.d.ts +3 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -1
- package/dist/plugins/discover-plugins.cjs +15 -31
- package/dist/plugins/discover-plugins.d.ts.map +1 -1
- package/dist/plugins/discover-plugins.js +15 -31
- package/dist/plugins/index.cjs +0 -2
- package/dist/plugins/index.d.ts +5 -6
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +0 -2
- package/dist/plugins/list-plugins.cjs +3 -1
- package/dist/plugins/list-plugins.d.ts.map +1 -1
- package/dist/plugins/list-plugins.js +3 -1
- package/dist/plugins/load-plugin.cjs +0 -13
- package/dist/plugins/load-plugin.d.ts +3 -5
- package/dist/plugins/load-plugin.d.ts.map +1 -1
- package/dist/plugins/load-plugin.js +0 -13
- package/dist/plugins/schemas.cjs +1 -11
- package/dist/plugins/schemas.d.ts +14 -69
- package/dist/plugins/schemas.d.ts.map +1 -1
- package/dist/plugins/schemas.js +1 -10
- package/dist/plugins/types.d.ts +2 -20
- package/dist/plugins/types.d.ts.map +1 -1
- package/dist/plugins/validate-plugin.cjs +7 -37
- package/dist/plugins/validate-plugin.d.ts +6 -24
- package/dist/plugins/validate-plugin.d.ts.map +1 -1
- package/dist/plugins/validate-plugin.js +8 -38
- package/dist/preferences/loader.cjs +21 -6
- package/dist/preferences/loader.d.ts +4 -0
- package/dist/preferences/loader.d.ts.map +1 -1
- package/dist/preferences/loader.js +21 -6
- package/dist/preferences/schemas.cjs +5 -1
- package/dist/preferences/schemas.d.ts +32 -0
- package/dist/preferences/schemas.d.ts.map +1 -1
- package/dist/preferences/schemas.js +5 -1
- package/dist/registry/registry.d.ts +4 -44
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/types.cjs +4 -0
- package/dist/registry/types.d.ts +8 -0
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/registry/types.js +4 -0
- package/dist/runtime/AgentPool.d.ts +2 -2
- package/dist/runtime/AgentPool.d.ts.map +1 -1
- package/dist/runtime/AgentRuntime.cjs +32 -19
- package/dist/runtime/AgentRuntime.d.ts +2 -2
- package/dist/runtime/AgentRuntime.d.ts.map +1 -1
- package/dist/runtime/AgentRuntime.js +32 -19
- package/dist/runtime/approval-delegation.cjs +6 -3
- package/dist/runtime/approval-delegation.d.ts +3 -2
- package/dist/runtime/approval-delegation.d.ts.map +1 -1
- package/dist/runtime/approval-delegation.js +6 -3
- package/dist/runtime/schemas.cjs +1 -1
- package/dist/runtime/schemas.d.ts +1 -1
- package/dist/runtime/schemas.js +1 -1
- package/dist/runtime/types.d.ts +3 -2
- package/dist/runtime/types.d.ts.map +1 -1
- package/dist/{tool-provider → tool-factories/agent-spawner}/error-codes.d.ts +1 -1
- package/dist/tool-factories/agent-spawner/error-codes.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/errors.d.ts +1 -1
- package/dist/tool-factories/agent-spawner/errors.d.ts.map +1 -0
- package/dist/tool-factories/agent-spawner/factory.cjs +327 -0
- package/dist/tool-factories/agent-spawner/factory.d.ts +4 -0
- package/dist/tool-factories/agent-spawner/factory.d.ts.map +1 -0
- package/dist/tool-factories/agent-spawner/factory.js +316 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/index.cjs +9 -9
- package/dist/{tool-provider → tool-factories/agent-spawner}/index.d.ts +3 -3
- package/dist/tool-factories/agent-spawner/index.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/index.js +4 -4
- package/dist/tool-factories/agent-spawner/llm-resolution.d.ts.map +1 -0
- package/dist/{tool-provider/runtime-service.cjs → tool-factories/agent-spawner/runtime.cjs} +149 -83
- package/dist/{tool-provider/runtime-service.d.ts → tool-factories/agent-spawner/runtime.d.ts} +11 -6
- package/dist/tool-factories/agent-spawner/runtime.d.ts.map +1 -0
- package/dist/{tool-provider/runtime-service.js → tool-factories/agent-spawner/runtime.js} +145 -79
- package/dist/{tool-provider → tool-factories/agent-spawner}/schemas.cjs +4 -4
- package/dist/{tool-provider → tool-factories/agent-spawner}/schemas.d.ts +5 -5
- package/dist/tool-factories/agent-spawner/schemas.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/schemas.js +4 -4
- package/dist/{tool-provider → tool-factories/agent-spawner}/spawn-agent-tool.cjs +17 -7
- package/dist/tool-factories/agent-spawner/spawn-agent-tool.d.ts +11 -0
- package/dist/tool-factories/agent-spawner/spawn-agent-tool.d.ts.map +1 -0
- package/dist/{tool-provider → tool-factories/agent-spawner}/spawn-agent-tool.js +17 -7
- package/dist/tool-factories/agent-spawner/types.d.ts.map +1 -0
- package/dist/utils/path.cjs +10 -1
- package/dist/utils/path.d.ts +5 -2
- package/dist/utils/path.d.ts.map +1 -1
- package/dist/utils/path.js +10 -1
- package/dist/writer.d.ts +2 -1
- package/dist/writer.d.ts.map +1 -1
- package/package.json +6 -4
- package/dist/tool-provider/error-codes.d.ts.map +0 -1
- package/dist/tool-provider/errors.d.ts.map +0 -1
- package/dist/tool-provider/index.d.ts.map +0 -1
- package/dist/tool-provider/llm-resolution.d.ts.map +0 -1
- package/dist/tool-provider/runtime-service.d.ts.map +0 -1
- package/dist/tool-provider/schemas.d.ts.map +0 -1
- package/dist/tool-provider/spawn-agent-tool.d.ts +0 -10
- package/dist/tool-provider/spawn-agent-tool.d.ts.map +0 -1
- package/dist/tool-provider/tool-provider.cjs +0 -197
- package/dist/tool-provider/tool-provider.d.ts +0 -30
- package/dist/tool-provider/tool-provider.d.ts.map +0 -1
- package/dist/tool-provider/tool-provider.js +0 -180
- package/dist/tool-provider/types.d.ts.map +0 -1
- /package/dist/{tool-provider → tool-factories/agent-spawner}/error-codes.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/error-codes.js +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/errors.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/errors.js +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/llm-resolution.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/llm-resolution.d.ts +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/llm-resolution.js +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/types.cjs +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/types.d.ts +0 -0
- /package/dist/{tool-provider → tool-factories/agent-spawner}/types.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,0DAA0D;IAC1D,WAAW,EAAE,WAAW,CAAC;IAEzB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC;;;OAGG;IACH,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/D;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,GAAG,OAAO,CAAC;AAE7F;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAEhB,8BAA8B;IAC9B,KAAK,EAAE,UAAU,CAAC;IAElB,kCAAkC;IAClC,MAAM,EAAE,WAAW,CAAC;IAEpB,mEAAmE;IACnE,SAAS,EAAE,OAAO,CAAC;IAEnB,kCAAkC;IAClC,SAAS,EAAE,IAAI,CAAC;IAEhB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAElB,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IAEjB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAEhB,+BAA+B;IAC/B,UAAU,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uBAAuB;IACvB,MAAM,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IAErC,+BAA+B;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-codes.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/error-codes.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,qBAAqB;IAE7B,iBAAiB,oCAAoC;IACrD,YAAY,+BAA+B;IAG3C,eAAe,kCAAkC;IAGjD,WAAW,8BAA8B;IAGzC,cAAc,iCAAiC;CAClD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAyB,MAAM,aAAa,CAAC;AAGvE;;GAEG;AACH,qBAAa,iBAAiB;IAC1B,MAAM,CAAC,gBAAgB;IAWvB,MAAM,CAAC,WAAW,CAAC,KAAK,EAAE,MAAM;;;IAWhC,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM;;;IAWpC,MAAM,CAAC,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;;;;IAWhD,MAAM,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM;CAUvC"}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var factory_exports = {};
|
|
20
|
+
__export(factory_exports, {
|
|
21
|
+
agentSpawnerToolsFactory: () => agentSpawnerToolsFactory
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(factory_exports);
|
|
24
|
+
var import_core = require("@dexto/core");
|
|
25
|
+
var import_core2 = require("@dexto/core");
|
|
26
|
+
var import_orchestration = require("@dexto/orchestration");
|
|
27
|
+
var import_schemas = require("./schemas.js");
|
|
28
|
+
var import_runtime = require("./runtime.js");
|
|
29
|
+
var import_spawn_agent_tool = require("./spawn-agent-tool.js");
|
|
30
|
+
function requireAgentContext(context) {
|
|
31
|
+
if (!context.agent) {
|
|
32
|
+
throw import_core2.ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.agent");
|
|
33
|
+
}
|
|
34
|
+
if (!context.services) {
|
|
35
|
+
throw import_core2.ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.services");
|
|
36
|
+
}
|
|
37
|
+
return { agent: context.agent, logger: context.logger, toolServices: context.services };
|
|
38
|
+
}
|
|
39
|
+
const agentSpawnerToolsFactory = {
|
|
40
|
+
configSchema: import_schemas.AgentSpawnerConfigSchema,
|
|
41
|
+
metadata: {
|
|
42
|
+
displayName: "Agent Spawner",
|
|
43
|
+
description: "Spawn sub-agents for task delegation",
|
|
44
|
+
category: "agents"
|
|
45
|
+
},
|
|
46
|
+
create: (config) => {
|
|
47
|
+
let state;
|
|
48
|
+
const attachTaskForker = (options) => {
|
|
49
|
+
const { toolServices, taskForker, logger } = options;
|
|
50
|
+
if (toolServices.taskForker !== taskForker) {
|
|
51
|
+
toolServices.taskForker = taskForker;
|
|
52
|
+
logger.debug(
|
|
53
|
+
"AgentSpawnerRuntime attached as taskForker for context:fork skill support"
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const ensureToolsInitialized = (context) => {
|
|
58
|
+
const { agent, logger, toolServices } = requireAgentContext(context);
|
|
59
|
+
if (state && state.agent === agent && !state.abortController.signal.aborted) {
|
|
60
|
+
attachTaskForker({ toolServices, taskForker: state.runtime, logger });
|
|
61
|
+
return state.tools;
|
|
62
|
+
}
|
|
63
|
+
if (state && !state.abortController.signal.aborted) {
|
|
64
|
+
state.abortController.abort();
|
|
65
|
+
}
|
|
66
|
+
if (state) {
|
|
67
|
+
state.runtime.cleanup().catch(() => void 0);
|
|
68
|
+
}
|
|
69
|
+
state = void 0;
|
|
70
|
+
const signalBus = new import_orchestration.SignalBus();
|
|
71
|
+
const taskRegistry = new import_orchestration.TaskRegistry(signalBus);
|
|
72
|
+
const conditionEngine = new import_orchestration.ConditionEngine(taskRegistry, signalBus, logger);
|
|
73
|
+
const spawnerRuntime = new import_runtime.AgentSpawnerRuntime(agent, config, logger);
|
|
74
|
+
attachTaskForker({ toolServices, taskForker: spawnerRuntime, logger });
|
|
75
|
+
const taskSessions = /* @__PURE__ */ new Map();
|
|
76
|
+
const emitTasksUpdate = (sessionId) => {
|
|
77
|
+
const tasks = taskRegistry.list({
|
|
78
|
+
status: ["running", "completed", "failed", "cancelled"]
|
|
79
|
+
});
|
|
80
|
+
const scopedTasks = sessionId ? tasks.filter((task) => taskSessions.get(task.taskId) === sessionId) : tasks;
|
|
81
|
+
const runningCount = scopedTasks.filter((task) => task.status === "running").length;
|
|
82
|
+
agent.emit("service:event", {
|
|
83
|
+
service: "orchestration",
|
|
84
|
+
event: "tasks-updated",
|
|
85
|
+
sessionId: sessionId ?? "",
|
|
86
|
+
data: {
|
|
87
|
+
runningCount,
|
|
88
|
+
tasks: scopedTasks.map((task) => ({
|
|
89
|
+
taskId: task.taskId,
|
|
90
|
+
status: task.status,
|
|
91
|
+
...task.description !== void 0 && {
|
|
92
|
+
description: task.description
|
|
93
|
+
}
|
|
94
|
+
}))
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
const triggerBackgroundCompletion = (taskId, sessionId) => {
|
|
99
|
+
if (!sessionId) {
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
agent.emit("tool:background-completed", {
|
|
103
|
+
toolCallId: taskId,
|
|
104
|
+
sessionId
|
|
105
|
+
});
|
|
106
|
+
const taskInfo = taskRegistry.getInfo(taskId);
|
|
107
|
+
const resultText = (() => {
|
|
108
|
+
if (taskInfo?.status === "failed") {
|
|
109
|
+
return taskInfo.error ?? "Unknown error.";
|
|
110
|
+
}
|
|
111
|
+
if (taskInfo?.result !== void 0) {
|
|
112
|
+
if (typeof taskInfo.result === "string") {
|
|
113
|
+
return taskInfo.result;
|
|
114
|
+
}
|
|
115
|
+
try {
|
|
116
|
+
return JSON.stringify(taskInfo.result, null, 2);
|
|
117
|
+
} catch {
|
|
118
|
+
return String(taskInfo.result ?? "<unserializable result>");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return "No result available.";
|
|
122
|
+
})();
|
|
123
|
+
const sanitizeCdata = (value) => value.replace(/\]\]>/g, "]]]]><![CDATA[>");
|
|
124
|
+
const safeDescription = taskInfo?.description ? sanitizeCdata(taskInfo.description) : null;
|
|
125
|
+
const safeResultText = sanitizeCdata(resultText);
|
|
126
|
+
const descriptionTag = safeDescription ? ` <description><![CDATA[${safeDescription}]]></description>
|
|
127
|
+
` : "";
|
|
128
|
+
const statusTag = taskInfo?.status ? ` <status>${taskInfo.status}</status>
|
|
129
|
+
` : "";
|
|
130
|
+
const content = [
|
|
131
|
+
{
|
|
132
|
+
type: "text",
|
|
133
|
+
text: `<background-task-completion>
|
|
134
|
+
<origin>task</origin>
|
|
135
|
+
<note>The following response was reported by the background task (not user input).</note>
|
|
136
|
+
<taskId>${taskId}</taskId>
|
|
137
|
+
` + statusTag + descriptionTag + ` <result><![CDATA[${safeResultText}]]></result>
|
|
138
|
+
</background-task-completion>`
|
|
139
|
+
}
|
|
140
|
+
];
|
|
141
|
+
agent.isSessionBusy(sessionId).then((isBusy) => {
|
|
142
|
+
if (isBusy) {
|
|
143
|
+
agent.queueMessage(sessionId, {
|
|
144
|
+
content,
|
|
145
|
+
kind: "background"
|
|
146
|
+
}).catch(() => void 0);
|
|
147
|
+
} else {
|
|
148
|
+
agent.emit("run:invoke", {
|
|
149
|
+
sessionId,
|
|
150
|
+
content,
|
|
151
|
+
source: "external",
|
|
152
|
+
metadata: { taskId }
|
|
153
|
+
});
|
|
154
|
+
agent.generate(content, sessionId).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
|
+
try {
|
|
168
|
+
taskRegistry.register(
|
|
169
|
+
{
|
|
170
|
+
type: "generic",
|
|
171
|
+
taskId,
|
|
172
|
+
description: event.description ?? `Tool ${event.toolName}`,
|
|
173
|
+
promise: event.promise
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
...event.timeoutMs !== void 0 && { timeout: event.timeoutMs },
|
|
177
|
+
...event.notifyOnComplete !== void 0 && {
|
|
178
|
+
notify: event.notifyOnComplete
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
taskSessions.delete(taskId);
|
|
184
|
+
event.promise.catch(() => void 0);
|
|
185
|
+
logger.warn(
|
|
186
|
+
`Failed to register background task ${taskId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
187
|
+
{ color: "yellow" }
|
|
188
|
+
);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
emitTasksUpdate(event.sessionId);
|
|
192
|
+
event.promise.finally(() => {
|
|
193
|
+
taskSessions.delete(taskId);
|
|
194
|
+
emitTasksUpdate(event.sessionId);
|
|
195
|
+
triggerBackgroundCompletion(taskId, event.sessionId);
|
|
196
|
+
});
|
|
197
|
+
};
|
|
198
|
+
const abortController = new AbortController();
|
|
199
|
+
agent.on("tool:background", handleBackground, {
|
|
200
|
+
signal: abortController.signal
|
|
201
|
+
});
|
|
202
|
+
agent.on(
|
|
203
|
+
"agent:stopped",
|
|
204
|
+
() => {
|
|
205
|
+
spawnerRuntime.cleanup().catch(() => void 0);
|
|
206
|
+
abortController.abort();
|
|
207
|
+
},
|
|
208
|
+
{ signal: abortController.signal }
|
|
209
|
+
);
|
|
210
|
+
const spawnAgentTool = (0, import_spawn_agent_tool.createSpawnAgentTool)(spawnerRuntime);
|
|
211
|
+
const waitForTool = (0, import_orchestration.createWaitForTool)(conditionEngine);
|
|
212
|
+
const checkTaskTool = (0, import_orchestration.createCheckTaskTool)(taskRegistry);
|
|
213
|
+
const listTasksTool = (0, import_orchestration.createListTasksTool)(taskRegistry);
|
|
214
|
+
const tools = {
|
|
215
|
+
spawnAgent: spawnAgentTool,
|
|
216
|
+
waitFor: waitForTool,
|
|
217
|
+
checkTask: checkTaskTool,
|
|
218
|
+
listTasks: listTasksTool
|
|
219
|
+
};
|
|
220
|
+
state = {
|
|
221
|
+
agent,
|
|
222
|
+
abortController,
|
|
223
|
+
runtime: spawnerRuntime,
|
|
224
|
+
tools
|
|
225
|
+
};
|
|
226
|
+
return tools;
|
|
227
|
+
};
|
|
228
|
+
return [
|
|
229
|
+
{
|
|
230
|
+
id: "spawn_agent",
|
|
231
|
+
description: "Spawn a sub-agent to handle a task and return its result.",
|
|
232
|
+
inputSchema: import_schemas.SpawnAgentInputSchema,
|
|
233
|
+
execute: (input, context) => ensureToolsInitialized(context).spawnAgent.execute(input, context),
|
|
234
|
+
presentation: {
|
|
235
|
+
describeHeader: (input) => {
|
|
236
|
+
const agentId = typeof input.agentId === "string" ? input.agentId : void 0;
|
|
237
|
+
const agentLabel = agentId ? agentId.replace(/-agent$/, "") : void 0;
|
|
238
|
+
const title = agentLabel ? agentLabel.charAt(0).toUpperCase() + agentLabel.slice(1) : "Agent";
|
|
239
|
+
const task = typeof input.task === "string" ? input.task : "";
|
|
240
|
+
const argsText = task ? (0, import_core.truncateForHeader)(task, 120) : void 0;
|
|
241
|
+
return (0, import_core.createLocalToolCallHeader)({
|
|
242
|
+
title,
|
|
243
|
+
...argsText ? { argsText } : {}
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
preview: async (input, context) => {
|
|
247
|
+
const tool = ensureToolsInitialized(context).spawnAgent;
|
|
248
|
+
const previewFn = tool.presentation?.preview;
|
|
249
|
+
if (!previewFn) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
return await previewFn(input, context);
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
id: "wait_for",
|
|
258
|
+
description: "Wait for background task(s) to complete.",
|
|
259
|
+
inputSchema: import_orchestration.WaitForInputSchema,
|
|
260
|
+
execute: (input, context) => ensureToolsInitialized(context).waitFor.execute(input, context),
|
|
261
|
+
presentation: {
|
|
262
|
+
describeHeader: (input) => {
|
|
263
|
+
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;
|
|
264
|
+
return (0, import_core.createLocalToolCallHeader)({
|
|
265
|
+
title: "Wait",
|
|
266
|
+
...argsText ? { argsText } : {}
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
preview: async (input, context) => {
|
|
270
|
+
const tool = ensureToolsInitialized(context).waitFor;
|
|
271
|
+
const previewFn = tool.presentation?.preview;
|
|
272
|
+
if (!previewFn) {
|
|
273
|
+
return null;
|
|
274
|
+
}
|
|
275
|
+
return await previewFn(input, context);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
},
|
|
279
|
+
{
|
|
280
|
+
id: "check_task",
|
|
281
|
+
description: "Check the status of a background task.",
|
|
282
|
+
inputSchema: import_orchestration.CheckTaskInputSchema,
|
|
283
|
+
execute: (input, context) => ensureToolsInitialized(context).checkTask.execute(input, context),
|
|
284
|
+
presentation: {
|
|
285
|
+
describeHeader: (input) => {
|
|
286
|
+
const argsText = (0, import_core.truncateForHeader)(input.taskId, 80);
|
|
287
|
+
return (0, import_core.createLocalToolCallHeader)({
|
|
288
|
+
title: "Check Task",
|
|
289
|
+
...argsText ? { argsText } : {}
|
|
290
|
+
});
|
|
291
|
+
},
|
|
292
|
+
preview: async (input, context) => {
|
|
293
|
+
const tool = ensureToolsInitialized(context).checkTask;
|
|
294
|
+
const previewFn = tool.presentation?.preview;
|
|
295
|
+
if (!previewFn) {
|
|
296
|
+
return null;
|
|
297
|
+
}
|
|
298
|
+
return await previewFn(input, context);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
id: "list_tasks",
|
|
304
|
+
description: "List background tasks and their statuses.",
|
|
305
|
+
inputSchema: import_orchestration.ListTasksInputSchema,
|
|
306
|
+
execute: (input, context) => ensureToolsInitialized(context).listTasks.execute(input, context),
|
|
307
|
+
presentation: {
|
|
308
|
+
describeHeader: () => (0, import_core.createLocalToolCallHeader)({
|
|
309
|
+
title: "List Tasks"
|
|
310
|
+
}),
|
|
311
|
+
preview: async (input, context) => {
|
|
312
|
+
const tool = ensureToolsInitialized(context).listTasks;
|
|
313
|
+
const previewFn = tool.presentation?.preview;
|
|
314
|
+
if (!previewFn) {
|
|
315
|
+
return null;
|
|
316
|
+
}
|
|
317
|
+
return await previewFn(input, context);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
];
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
325
|
+
0 && (module.exports = {
|
|
326
|
+
agentSpawnerToolsFactory
|
|
327
|
+
});
|
|
@@ -0,0 +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;AAiBvD,OAAO,EAGH,KAAK,kBAAkB,EAC1B,MAAM,cAAc,CAAC;AAqCtB,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,kBAAkB,CA8VpE,CAAC"}
|
|
@@ -0,0 +1,316 @@
|
|
|
1
|
+
import { createLocalToolCallHeader, truncateForHeader } from "@dexto/core";
|
|
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
|
+
import {
|
|
15
|
+
AgentSpawnerConfigSchema,
|
|
16
|
+
SpawnAgentInputSchema
|
|
17
|
+
} from "./schemas.js";
|
|
18
|
+
import { AgentSpawnerRuntime } from "./runtime.js";
|
|
19
|
+
import { createSpawnAgentTool } from "./spawn-agent-tool.js";
|
|
20
|
+
function requireAgentContext(context) {
|
|
21
|
+
if (!context.agent) {
|
|
22
|
+
throw ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.agent");
|
|
23
|
+
}
|
|
24
|
+
if (!context.services) {
|
|
25
|
+
throw ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.services");
|
|
26
|
+
}
|
|
27
|
+
return { agent: context.agent, logger: context.logger, toolServices: context.services };
|
|
28
|
+
}
|
|
29
|
+
const agentSpawnerToolsFactory = {
|
|
30
|
+
configSchema: AgentSpawnerConfigSchema,
|
|
31
|
+
metadata: {
|
|
32
|
+
displayName: "Agent Spawner",
|
|
33
|
+
description: "Spawn sub-agents for task delegation",
|
|
34
|
+
category: "agents"
|
|
35
|
+
},
|
|
36
|
+
create: (config) => {
|
|
37
|
+
let state;
|
|
38
|
+
const attachTaskForker = (options) => {
|
|
39
|
+
const { toolServices, taskForker, logger } = options;
|
|
40
|
+
if (toolServices.taskForker !== taskForker) {
|
|
41
|
+
toolServices.taskForker = taskForker;
|
|
42
|
+
logger.debug(
|
|
43
|
+
"AgentSpawnerRuntime attached as taskForker for context:fork skill support"
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const ensureToolsInitialized = (context) => {
|
|
48
|
+
const { agent, logger, toolServices } = requireAgentContext(context);
|
|
49
|
+
if (state && state.agent === agent && !state.abortController.signal.aborted) {
|
|
50
|
+
attachTaskForker({ toolServices, taskForker: state.runtime, logger });
|
|
51
|
+
return state.tools;
|
|
52
|
+
}
|
|
53
|
+
if (state && !state.abortController.signal.aborted) {
|
|
54
|
+
state.abortController.abort();
|
|
55
|
+
}
|
|
56
|
+
if (state) {
|
|
57
|
+
state.runtime.cleanup().catch(() => void 0);
|
|
58
|
+
}
|
|
59
|
+
state = void 0;
|
|
60
|
+
const signalBus = new SignalBus();
|
|
61
|
+
const taskRegistry = new TaskRegistry(signalBus);
|
|
62
|
+
const conditionEngine = new ConditionEngine(taskRegistry, signalBus, logger);
|
|
63
|
+
const spawnerRuntime = new AgentSpawnerRuntime(agent, config, logger);
|
|
64
|
+
attachTaskForker({ toolServices, taskForker: spawnerRuntime, logger });
|
|
65
|
+
const taskSessions = /* @__PURE__ */ new Map();
|
|
66
|
+
const emitTasksUpdate = (sessionId) => {
|
|
67
|
+
const tasks = taskRegistry.list({
|
|
68
|
+
status: ["running", "completed", "failed", "cancelled"]
|
|
69
|
+
});
|
|
70
|
+
const scopedTasks = sessionId ? tasks.filter((task) => taskSessions.get(task.taskId) === sessionId) : tasks;
|
|
71
|
+
const runningCount = scopedTasks.filter((task) => task.status === "running").length;
|
|
72
|
+
agent.emit("service:event", {
|
|
73
|
+
service: "orchestration",
|
|
74
|
+
event: "tasks-updated",
|
|
75
|
+
sessionId: sessionId ?? "",
|
|
76
|
+
data: {
|
|
77
|
+
runningCount,
|
|
78
|
+
tasks: scopedTasks.map((task) => ({
|
|
79
|
+
taskId: task.taskId,
|
|
80
|
+
status: task.status,
|
|
81
|
+
...task.description !== void 0 && {
|
|
82
|
+
description: task.description
|
|
83
|
+
}
|
|
84
|
+
}))
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const triggerBackgroundCompletion = (taskId, sessionId) => {
|
|
89
|
+
if (!sessionId) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
agent.emit("tool:background-completed", {
|
|
93
|
+
toolCallId: taskId,
|
|
94
|
+
sessionId
|
|
95
|
+
});
|
|
96
|
+
const taskInfo = taskRegistry.getInfo(taskId);
|
|
97
|
+
const resultText = (() => {
|
|
98
|
+
if (taskInfo?.status === "failed") {
|
|
99
|
+
return taskInfo.error ?? "Unknown error.";
|
|
100
|
+
}
|
|
101
|
+
if (taskInfo?.result !== void 0) {
|
|
102
|
+
if (typeof taskInfo.result === "string") {
|
|
103
|
+
return taskInfo.result;
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
return JSON.stringify(taskInfo.result, null, 2);
|
|
107
|
+
} catch {
|
|
108
|
+
return String(taskInfo.result ?? "<unserializable result>");
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return "No result available.";
|
|
112
|
+
})();
|
|
113
|
+
const sanitizeCdata = (value) => value.replace(/\]\]>/g, "]]]]><![CDATA[>");
|
|
114
|
+
const safeDescription = taskInfo?.description ? sanitizeCdata(taskInfo.description) : null;
|
|
115
|
+
const safeResultText = sanitizeCdata(resultText);
|
|
116
|
+
const descriptionTag = safeDescription ? ` <description><![CDATA[${safeDescription}]]></description>
|
|
117
|
+
` : "";
|
|
118
|
+
const statusTag = taskInfo?.status ? ` <status>${taskInfo.status}</status>
|
|
119
|
+
` : "";
|
|
120
|
+
const content = [
|
|
121
|
+
{
|
|
122
|
+
type: "text",
|
|
123
|
+
text: `<background-task-completion>
|
|
124
|
+
<origin>task</origin>
|
|
125
|
+
<note>The following response was reported by the background task (not user input).</note>
|
|
126
|
+
<taskId>${taskId}</taskId>
|
|
127
|
+
` + statusTag + descriptionTag + ` <result><![CDATA[${safeResultText}]]></result>
|
|
128
|
+
</background-task-completion>`
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
agent.isSessionBusy(sessionId).then((isBusy) => {
|
|
132
|
+
if (isBusy) {
|
|
133
|
+
agent.queueMessage(sessionId, {
|
|
134
|
+
content,
|
|
135
|
+
kind: "background"
|
|
136
|
+
}).catch(() => void 0);
|
|
137
|
+
} else {
|
|
138
|
+
agent.emit("run:invoke", {
|
|
139
|
+
sessionId,
|
|
140
|
+
content,
|
|
141
|
+
source: "external",
|
|
142
|
+
metadata: { taskId }
|
|
143
|
+
});
|
|
144
|
+
agent.generate(content, sessionId).catch(() => void 0);
|
|
145
|
+
}
|
|
146
|
+
}).catch(() => {
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
const handleBackground = (event) => {
|
|
150
|
+
const taskId = event.toolCallId;
|
|
151
|
+
if (taskRegistry.has(taskId)) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
if (event.sessionId) {
|
|
155
|
+
taskSessions.set(taskId, event.sessionId);
|
|
156
|
+
}
|
|
157
|
+
try {
|
|
158
|
+
taskRegistry.register(
|
|
159
|
+
{
|
|
160
|
+
type: "generic",
|
|
161
|
+
taskId,
|
|
162
|
+
description: event.description ?? `Tool ${event.toolName}`,
|
|
163
|
+
promise: event.promise
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
...event.timeoutMs !== void 0 && { timeout: event.timeoutMs },
|
|
167
|
+
...event.notifyOnComplete !== void 0 && {
|
|
168
|
+
notify: event.notifyOnComplete
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
} catch (error) {
|
|
173
|
+
taskSessions.delete(taskId);
|
|
174
|
+
event.promise.catch(() => void 0);
|
|
175
|
+
logger.warn(
|
|
176
|
+
`Failed to register background task ${taskId}: ${error instanceof Error ? error.message : String(error)}`,
|
|
177
|
+
{ color: "yellow" }
|
|
178
|
+
);
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
emitTasksUpdate(event.sessionId);
|
|
182
|
+
event.promise.finally(() => {
|
|
183
|
+
taskSessions.delete(taskId);
|
|
184
|
+
emitTasksUpdate(event.sessionId);
|
|
185
|
+
triggerBackgroundCompletion(taskId, event.sessionId);
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
const abortController = new AbortController();
|
|
189
|
+
agent.on("tool:background", handleBackground, {
|
|
190
|
+
signal: abortController.signal
|
|
191
|
+
});
|
|
192
|
+
agent.on(
|
|
193
|
+
"agent:stopped",
|
|
194
|
+
() => {
|
|
195
|
+
spawnerRuntime.cleanup().catch(() => void 0);
|
|
196
|
+
abortController.abort();
|
|
197
|
+
},
|
|
198
|
+
{ signal: abortController.signal }
|
|
199
|
+
);
|
|
200
|
+
const spawnAgentTool = createSpawnAgentTool(spawnerRuntime);
|
|
201
|
+
const waitForTool = createWaitForTool(conditionEngine);
|
|
202
|
+
const checkTaskTool = createCheckTaskTool(taskRegistry);
|
|
203
|
+
const listTasksTool = createListTasksTool(taskRegistry);
|
|
204
|
+
const tools = {
|
|
205
|
+
spawnAgent: spawnAgentTool,
|
|
206
|
+
waitFor: waitForTool,
|
|
207
|
+
checkTask: checkTaskTool,
|
|
208
|
+
listTasks: listTasksTool
|
|
209
|
+
};
|
|
210
|
+
state = {
|
|
211
|
+
agent,
|
|
212
|
+
abortController,
|
|
213
|
+
runtime: spawnerRuntime,
|
|
214
|
+
tools
|
|
215
|
+
};
|
|
216
|
+
return tools;
|
|
217
|
+
};
|
|
218
|
+
return [
|
|
219
|
+
{
|
|
220
|
+
id: "spawn_agent",
|
|
221
|
+
description: "Spawn a sub-agent to handle a task and return its result.",
|
|
222
|
+
inputSchema: SpawnAgentInputSchema,
|
|
223
|
+
execute: (input, context) => ensureToolsInitialized(context).spawnAgent.execute(input, context),
|
|
224
|
+
presentation: {
|
|
225
|
+
describeHeader: (input) => {
|
|
226
|
+
const agentId = typeof input.agentId === "string" ? input.agentId : void 0;
|
|
227
|
+
const agentLabel = agentId ? agentId.replace(/-agent$/, "") : void 0;
|
|
228
|
+
const title = agentLabel ? agentLabel.charAt(0).toUpperCase() + agentLabel.slice(1) : "Agent";
|
|
229
|
+
const task = typeof input.task === "string" ? input.task : "";
|
|
230
|
+
const argsText = task ? truncateForHeader(task, 120) : void 0;
|
|
231
|
+
return createLocalToolCallHeader({
|
|
232
|
+
title,
|
|
233
|
+
...argsText ? { argsText } : {}
|
|
234
|
+
});
|
|
235
|
+
},
|
|
236
|
+
preview: async (input, context) => {
|
|
237
|
+
const tool = ensureToolsInitialized(context).spawnAgent;
|
|
238
|
+
const previewFn = tool.presentation?.preview;
|
|
239
|
+
if (!previewFn) {
|
|
240
|
+
return null;
|
|
241
|
+
}
|
|
242
|
+
return await previewFn(input, context);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
id: "wait_for",
|
|
248
|
+
description: "Wait for background task(s) to complete.",
|
|
249
|
+
inputSchema: WaitForInputSchema,
|
|
250
|
+
execute: (input, context) => ensureToolsInitialized(context).waitFor.execute(input, context),
|
|
251
|
+
presentation: {
|
|
252
|
+
describeHeader: (input) => {
|
|
253
|
+
const argsText = input.taskId ? truncateForHeader(input.taskId, 80) : input.taskIds && input.taskIds.length > 0 ? truncateForHeader(`${input.taskIds.length} tasks`, 80) : void 0;
|
|
254
|
+
return createLocalToolCallHeader({
|
|
255
|
+
title: "Wait",
|
|
256
|
+
...argsText ? { argsText } : {}
|
|
257
|
+
});
|
|
258
|
+
},
|
|
259
|
+
preview: async (input, context) => {
|
|
260
|
+
const tool = ensureToolsInitialized(context).waitFor;
|
|
261
|
+
const previewFn = tool.presentation?.preview;
|
|
262
|
+
if (!previewFn) {
|
|
263
|
+
return null;
|
|
264
|
+
}
|
|
265
|
+
return await previewFn(input, context);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
id: "check_task",
|
|
271
|
+
description: "Check the status of a background task.",
|
|
272
|
+
inputSchema: CheckTaskInputSchema,
|
|
273
|
+
execute: (input, context) => ensureToolsInitialized(context).checkTask.execute(input, context),
|
|
274
|
+
presentation: {
|
|
275
|
+
describeHeader: (input) => {
|
|
276
|
+
const argsText = truncateForHeader(input.taskId, 80);
|
|
277
|
+
return createLocalToolCallHeader({
|
|
278
|
+
title: "Check Task",
|
|
279
|
+
...argsText ? { argsText } : {}
|
|
280
|
+
});
|
|
281
|
+
},
|
|
282
|
+
preview: async (input, context) => {
|
|
283
|
+
const tool = ensureToolsInitialized(context).checkTask;
|
|
284
|
+
const previewFn = tool.presentation?.preview;
|
|
285
|
+
if (!previewFn) {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
return await previewFn(input, context);
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
id: "list_tasks",
|
|
294
|
+
description: "List background tasks and their statuses.",
|
|
295
|
+
inputSchema: ListTasksInputSchema,
|
|
296
|
+
execute: (input, context) => ensureToolsInitialized(context).listTasks.execute(input, context),
|
|
297
|
+
presentation: {
|
|
298
|
+
describeHeader: () => createLocalToolCallHeader({
|
|
299
|
+
title: "List Tasks"
|
|
300
|
+
}),
|
|
301
|
+
preview: async (input, context) => {
|
|
302
|
+
const tool = ensureToolsInitialized(context).listTasks;
|
|
303
|
+
const previewFn = tool.presentation?.preview;
|
|
304
|
+
if (!previewFn) {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
return await previewFn(input, context);
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
];
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
export {
|
|
315
|
+
agentSpawnerToolsFactory
|
|
316
|
+
};
|