@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
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
* skills/ (legacy project root, still discovered for compatibility)
|
|
10
10
|
* .dexto/skills/ (legacy project/user root, still discovered for compatibility)
|
|
11
11
|
* ~/.agents/skills/
|
|
12
|
+
* ~/.dexto/cloud-skills/ (the signed-in person's Cloud Skills, synced by the CLI)
|
|
12
13
|
* └── skill-name/
|
|
13
14
|
* ├── SKILL.md (required - skill instructions)
|
|
14
15
|
* ├── handlers/ (optional - workflow helper files)
|
|
@@ -28,8 +29,8 @@ export interface DiscoveredSkill {
|
|
|
28
29
|
path: string;
|
|
29
30
|
/** Absolute path to the SKILL.md file */
|
|
30
31
|
skillFile: string;
|
|
31
|
-
/** Source location */
|
|
32
|
-
source: 'user' | 'project';
|
|
32
|
+
/** Source location: the project, the person's own folders, or their synced Cloud library */
|
|
33
|
+
source: 'user' | 'project' | 'cloud';
|
|
33
34
|
/**
|
|
34
35
|
* Reserved for future discovery metadata.
|
|
35
36
|
*/
|
|
@@ -40,6 +41,8 @@ export interface StandaloneSkillPaths {
|
|
|
40
41
|
user: string;
|
|
41
42
|
legacyProject: readonly string[];
|
|
42
43
|
legacyUser: readonly string[];
|
|
44
|
+
/** The person's Cloud Skills, synced by `dexto skills sync`; any local Skill of the same name wins. */
|
|
45
|
+
cloud: string;
|
|
43
46
|
}
|
|
44
47
|
/**
|
|
45
48
|
* Resolves the canonical standalone Skill roots used by discovery and creator tools.
|
|
@@ -51,6 +54,7 @@ export declare function getStandaloneSkillPaths(projectPath?: string): Standalon
|
|
|
51
54
|
* Search Locations:
|
|
52
55
|
* 1. <projectRoot>/.agents/skills/* (project)
|
|
53
56
|
* 2. ~/.agents/skills/* (user)
|
|
57
|
+
* 3. ~/.dexto/cloud-skills/* (cloud)
|
|
54
58
|
*
|
|
55
59
|
* @param projectPath Optional project path (defaults to cwd)
|
|
56
60
|
* @returns Array of discovered skills
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discover-skills.d.ts","sourceRoot":"","sources":["../../src/plugins/discover-skills.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"discover-skills.d.ts","sourceRoot":"","sources":["../../src/plugins/discover-skills.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAMH;;GAEG;AACH,MAAM,WAAW,eAAe;IAC5B,yCAAyC;IACzC,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC;IAClB,4FAA4F;IAC5F,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC;IACrC;;OAEG;IACH,QAAQ,CAAC,EAAE,MAAM,EAAE,GAAG,SAAS,CAAC;CACnC;AAED,MAAM,WAAW,oBAAoB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,SAAS,MAAM,EAAE,CAAC;IACjC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IAC9B,uGAAuG;IACvG,KAAK,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAWlF;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CAiEhF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CASlE"}
|
|
@@ -8,7 +8,8 @@ function getStandaloneSkillPaths(projectPath) {
|
|
|
8
8
|
project: path.join(cwd, ".agents", "skills"),
|
|
9
9
|
user: path.join(homeDir, ".agents", "skills"),
|
|
10
10
|
legacyProject: [path.join(cwd, "skills"), path.join(cwd, ".dexto", "skills")],
|
|
11
|
-
legacyUser: [path.join(homeDir, ".dexto", "skills")]
|
|
11
|
+
legacyUser: [path.join(homeDir, ".dexto", "skills")],
|
|
12
|
+
cloud: path.join(homeDir, ".dexto", "cloud-skills")
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
function discoverStandaloneSkills(projectPath) {
|
|
@@ -52,6 +53,7 @@ function discoverStandaloneSkills(projectPath) {
|
|
|
52
53
|
for (const legacyRoot of skillPaths.legacyUser) {
|
|
53
54
|
scanSkillsDir(legacyRoot, "user");
|
|
54
55
|
}
|
|
56
|
+
scanSkillsDir(skillPaths.cloud, "cloud");
|
|
55
57
|
return skills;
|
|
56
58
|
}
|
|
57
59
|
function getSkillSearchPaths(projectPath) {
|
|
@@ -60,7 +62,8 @@ function getSkillSearchPaths(projectPath) {
|
|
|
60
62
|
skillPaths.project,
|
|
61
63
|
...skillPaths.legacyProject,
|
|
62
64
|
skillPaths.user,
|
|
63
|
-
...skillPaths.legacyUser
|
|
65
|
+
...skillPaths.legacyUser,
|
|
66
|
+
skillPaths.cloud
|
|
64
67
|
];
|
|
65
68
|
}
|
|
66
69
|
export {
|
package/dist/plugins/errors.cjs
CHANGED
|
@@ -135,7 +135,7 @@ class PluginError {
|
|
|
135
135
|
import_core.ErrorType.USER,
|
|
136
136
|
`Plugin '${pluginName}' not found`,
|
|
137
137
|
{ pluginName },
|
|
138
|
-
"Use `
|
|
138
|
+
"Use `/plugin` in the interactive CLI to see available plugins"
|
|
139
139
|
);
|
|
140
140
|
}
|
|
141
141
|
// Uninstallation errors
|
|
@@ -146,7 +146,7 @@ class PluginError {
|
|
|
146
146
|
import_core.ErrorType.USER,
|
|
147
147
|
`Plugin '${pluginName}' is not installed`,
|
|
148
148
|
{ pluginName },
|
|
149
|
-
hint || "Use `
|
|
149
|
+
hint || "Use `/plugin` in the interactive CLI to see installed plugins"
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
static uninstallDeleteFailed(pluginPath, cause) {
|
package/dist/plugins/errors.js
CHANGED
|
@@ -112,7 +112,7 @@ class PluginError {
|
|
|
112
112
|
ErrorType.USER,
|
|
113
113
|
`Plugin '${pluginName}' not found`,
|
|
114
114
|
{ pluginName },
|
|
115
|
-
"Use `
|
|
115
|
+
"Use `/plugin` in the interactive CLI to see available plugins"
|
|
116
116
|
);
|
|
117
117
|
}
|
|
118
118
|
// Uninstallation errors
|
|
@@ -123,7 +123,7 @@ class PluginError {
|
|
|
123
123
|
ErrorType.USER,
|
|
124
124
|
`Plugin '${pluginName}' is not installed`,
|
|
125
125
|
{ pluginName },
|
|
126
|
-
hint || "Use `
|
|
126
|
+
hint || "Use `/plugin` in the interactive CLI to see installed plugins"
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
static uninstallDeleteFailed(pluginPath, cause) {
|
|
@@ -94,7 +94,7 @@ class MarketplaceError {
|
|
|
94
94
|
import_core.ErrorType.USER,
|
|
95
95
|
`Marketplace '${name}' not found`,
|
|
96
96
|
{ name },
|
|
97
|
-
"Use `
|
|
97
|
+
"Use `/plugin` in the interactive CLI to see registered marketplaces"
|
|
98
98
|
);
|
|
99
99
|
}
|
|
100
100
|
static removeDeleteFailed(name, path, cause) {
|
|
@@ -115,7 +115,7 @@ class MarketplaceError {
|
|
|
115
115
|
import_core.ErrorType.USER,
|
|
116
116
|
`Marketplace '${name}' not found`,
|
|
117
117
|
{ name },
|
|
118
|
-
"Use `
|
|
118
|
+
"Use `/plugin` in the interactive CLI to see registered marketplaces"
|
|
119
119
|
);
|
|
120
120
|
}
|
|
121
121
|
static updatePullFailed(name, cause) {
|
|
@@ -146,7 +146,7 @@ class MarketplaceError {
|
|
|
146
146
|
import_core.ErrorType.USER,
|
|
147
147
|
`Marketplace '${marketplace}' not found`,
|
|
148
148
|
{ marketplace },
|
|
149
|
-
"Use `
|
|
149
|
+
"Use `/plugin` in the interactive CLI to see registered marketplaces"
|
|
150
150
|
);
|
|
151
151
|
}
|
|
152
152
|
static installPluginNotFound(pluginName, marketplace) {
|
|
@@ -157,7 +157,7 @@ class MarketplaceError {
|
|
|
157
157
|
import_core.ErrorType.USER,
|
|
158
158
|
`Plugin '${pluginName}' not found${marketplaceInfo}`,
|
|
159
159
|
{ pluginName, marketplace },
|
|
160
|
-
"Use `
|
|
160
|
+
"Use `/plugin` in the interactive CLI to browse available plugins"
|
|
161
161
|
);
|
|
162
162
|
}
|
|
163
163
|
static installCopyFailed(pluginName, cause) {
|
|
@@ -71,7 +71,7 @@ class MarketplaceError {
|
|
|
71
71
|
ErrorType.USER,
|
|
72
72
|
`Marketplace '${name}' not found`,
|
|
73
73
|
{ name },
|
|
74
|
-
"Use `
|
|
74
|
+
"Use `/plugin` in the interactive CLI to see registered marketplaces"
|
|
75
75
|
);
|
|
76
76
|
}
|
|
77
77
|
static removeDeleteFailed(name, path, cause) {
|
|
@@ -92,7 +92,7 @@ class MarketplaceError {
|
|
|
92
92
|
ErrorType.USER,
|
|
93
93
|
`Marketplace '${name}' not found`,
|
|
94
94
|
{ name },
|
|
95
|
-
"Use `
|
|
95
|
+
"Use `/plugin` in the interactive CLI to see registered marketplaces"
|
|
96
96
|
);
|
|
97
97
|
}
|
|
98
98
|
static updatePullFailed(name, cause) {
|
|
@@ -123,7 +123,7 @@ class MarketplaceError {
|
|
|
123
123
|
ErrorType.USER,
|
|
124
124
|
`Marketplace '${marketplace}' not found`,
|
|
125
125
|
{ marketplace },
|
|
126
|
-
"Use `
|
|
126
|
+
"Use `/plugin` in the interactive CLI to see registered marketplaces"
|
|
127
127
|
);
|
|
128
128
|
}
|
|
129
129
|
static installPluginNotFound(pluginName, marketplace) {
|
|
@@ -134,7 +134,7 @@ class MarketplaceError {
|
|
|
134
134
|
ErrorType.USER,
|
|
135
135
|
`Plugin '${pluginName}' not found${marketplaceInfo}`,
|
|
136
136
|
{ pluginName, marketplace },
|
|
137
|
-
"Use `
|
|
137
|
+
"Use `/plugin` in the interactive CLI to browse available plugins"
|
|
138
138
|
);
|
|
139
139
|
}
|
|
140
140
|
static installCopyFailed(pluginName, cause) {
|
|
@@ -33,7 +33,7 @@ class PreferenceError {
|
|
|
33
33
|
import_core.ErrorType.USER,
|
|
34
34
|
`Preferences file not found: ${preferencesPath}`,
|
|
35
35
|
{ preferencesPath },
|
|
36
|
-
"Run `dexto
|
|
36
|
+
"Run `dexto login` or set a provider key"
|
|
37
37
|
);
|
|
38
38
|
}
|
|
39
39
|
static fileReadError(preferencesPath, cause) {
|
|
@@ -9,7 +9,7 @@ class PreferenceError {
|
|
|
9
9
|
ErrorType.USER,
|
|
10
10
|
`Preferences file not found: ${preferencesPath}`,
|
|
11
11
|
{ preferencesPath },
|
|
12
|
-
"Run `dexto
|
|
12
|
+
"Run `dexto login` or set a provider key"
|
|
13
13
|
);
|
|
14
14
|
}
|
|
15
15
|
static fileReadError(preferencesPath, cause) {
|
|
@@ -176,7 +176,7 @@ class LocalAgentRegistry {
|
|
|
176
176
|
* @param agentId ID of the agent to install
|
|
177
177
|
*/
|
|
178
178
|
async installAgent(agentId) {
|
|
179
|
-
import_core.logger.
|
|
179
|
+
import_core.logger.debug(`Installing agent: ${agentId}`);
|
|
180
180
|
const registry = this.getRegistry();
|
|
181
181
|
const agentData = registry.agents[agentId];
|
|
182
182
|
if (!agentData) {
|
|
@@ -212,7 +212,7 @@ class LocalAgentRegistry {
|
|
|
212
212
|
throw import_errors.RegistryError.installationValidationFailed(agentId, mainConfigPath);
|
|
213
213
|
}
|
|
214
214
|
await import_fs2.promises.rename(tempDir, targetDir);
|
|
215
|
-
import_core.logger.
|
|
215
|
+
import_core.logger.debug(`\u2713 Installed agent '${agentId}' to ${targetDir}`);
|
|
216
216
|
return this.resolveMainConfig(targetDir, agentId);
|
|
217
217
|
} catch (error) {
|
|
218
218
|
try {
|
|
@@ -351,7 +351,7 @@ class LocalAgentRegistry {
|
|
|
351
351
|
import_core.logger.debug(`Agent '${agentId}' not found in installed path: ${installedPath}`);
|
|
352
352
|
if (this.hasAgent(agentId)) {
|
|
353
353
|
if (autoInstall) {
|
|
354
|
-
import_core.logger.
|
|
354
|
+
import_core.logger.debug(`Installing agent '${agentId}' from registry...`);
|
|
355
355
|
return await this.installAgent(agentId);
|
|
356
356
|
} else {
|
|
357
357
|
const registry2 = this.getRegistry();
|
|
@@ -149,7 +149,7 @@ class LocalAgentRegistry {
|
|
|
149
149
|
* @param agentId ID of the agent to install
|
|
150
150
|
*/
|
|
151
151
|
async installAgent(agentId) {
|
|
152
|
-
logger.
|
|
152
|
+
logger.debug(`Installing agent: ${agentId}`);
|
|
153
153
|
const registry = this.getRegistry();
|
|
154
154
|
const agentData = registry.agents[agentId];
|
|
155
155
|
if (!agentData) {
|
|
@@ -185,7 +185,7 @@ class LocalAgentRegistry {
|
|
|
185
185
|
throw RegistryError.installationValidationFailed(agentId, mainConfigPath);
|
|
186
186
|
}
|
|
187
187
|
await fs.rename(tempDir, targetDir);
|
|
188
|
-
logger.
|
|
188
|
+
logger.debug(`\u2713 Installed agent '${agentId}' to ${targetDir}`);
|
|
189
189
|
return this.resolveMainConfig(targetDir, agentId);
|
|
190
190
|
} catch (error) {
|
|
191
191
|
try {
|
|
@@ -324,7 +324,7 @@ class LocalAgentRegistry {
|
|
|
324
324
|
logger.debug(`Agent '${agentId}' not found in installed path: ${installedPath}`);
|
|
325
325
|
if (this.hasAgent(agentId)) {
|
|
326
326
|
if (autoInstall) {
|
|
327
|
-
logger.
|
|
327
|
+
logger.debug(`Installing agent '${agentId}' from registry...`);
|
|
328
328
|
return await this.installAgent(agentId);
|
|
329
329
|
} else {
|
|
330
330
|
const registry2 = this.getRegistry();
|
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"}
|