@dexto/agent-management 1.15.0-beta.2 → 1.16.0
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/index.cjs +0 -25
- package/dist/auth/index.d.ts +0 -6
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +0 -10
- package/dist/auth/model-auth-handlers.cjs +1 -3
- package/dist/auth/model-auth-handlers.d.ts +1 -6
- package/dist/auth/model-auth-handlers.d.ts.map +1 -1
- package/dist/auth/model-auth-handlers.js +1 -6
- package/dist/config/errors.cjs +6 -6
- package/dist/config/errors.js +6 -6
- package/dist/images/image-store.cjs +4 -2
- package/dist/images/image-store.d.ts.map +1 -1
- package/dist/images/image-store.js +4 -2
- package/dist/index.cjs +29 -40
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -9
- package/dist/installation.cjs +2 -2
- package/dist/installation.js +2 -2
- package/dist/plugins/discover-skills.cjs +2 -5
- package/dist/plugins/discover-skills.d.ts +2 -6
- package/dist/plugins/discover-skills.d.ts.map +1 -1
- package/dist/plugins/discover-skills.js +2 -5
- 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 +218 -1
- package/dist/tool-factories/agent-spawner/factory.d.ts.map +1 -1
- package/dist/tool-factories/agent-spawner/factory.js +228 -1
- package/dist/utils/dexto-auth.cjs +58 -3
- package/dist/utils/dexto-auth.d.ts +18 -4
- package/dist/utils/dexto-auth.d.ts.map +1 -1
- package/dist/utils/dexto-auth.js +57 -3
- package/package.json +6 -5
- package/dist/auth/dexto-accounts.cjs +0 -277
- package/dist/auth/dexto-accounts.d.ts +0 -144
- package/dist/auth/dexto-accounts.d.ts.map +0 -1
- package/dist/auth/dexto-accounts.js +0 -230
- package/dist/auth/dexto-cloud.cjs +0 -51
- package/dist/auth/dexto-cloud.d.ts +0 -9
- package/dist/auth/dexto-cloud.d.ts.map +0 -1
- package/dist/auth/dexto-cloud.js +0 -27
- package/dist/auth/dexto-gateway.cjs +0 -162
- package/dist/auth/dexto-gateway.d.ts +0 -55
- package/dist/auth/dexto-gateway.d.ts.map +0 -1
- package/dist/auth/dexto-gateway.js +0 -133
- package/dist/auth/dexto-mcp.cjs +0 -77
- package/dist/auth/dexto-mcp.d.ts +0 -23
- package/dist/auth/dexto-mcp.d.ts.map +0 -1
- package/dist/auth/dexto-mcp.js +0 -49
- package/dist/auth/dexto-sign-in.cjs +0 -345
- package/dist/auth/dexto-sign-in.d.ts +0 -86
- package/dist/auth/dexto-sign-in.d.ts.map +0 -1
- package/dist/auth/dexto-sign-in.js +0 -314
package/dist/installation.js
CHANGED
|
@@ -28,7 +28,7 @@ async function saveUserRegistry(registryPath, registry) {
|
|
|
28
28
|
async function installBundledAgent(agentId, options) {
|
|
29
29
|
const agentsDir = getAgentsDir(options);
|
|
30
30
|
const bundledRegistryPath = resolveBundledScript("agents/agent-registry.json");
|
|
31
|
-
logger.
|
|
31
|
+
logger.info(`Installing agent: ${agentId}`);
|
|
32
32
|
let bundledRegistry;
|
|
33
33
|
try {
|
|
34
34
|
const content = await fs.readFile(bundledRegistryPath, "utf-8");
|
|
@@ -64,7 +64,7 @@ async function installBundledAgent(agentId, options) {
|
|
|
64
64
|
await fs.copyFile(sourcePath, targetFile);
|
|
65
65
|
}
|
|
66
66
|
await fs.rename(tempDir, targetDir);
|
|
67
|
-
logger.
|
|
67
|
+
logger.info(`\u2713 Installed agent '${agentId}' to ${targetDir}`);
|
|
68
68
|
const userRegistryPath = getUserRegistryPath(agentsDir);
|
|
69
69
|
const userRegistry = await loadUserRegistry(userRegistryPath);
|
|
70
70
|
if (!userRegistry.agents.some((a) => a.id === agentId)) {
|
|
@@ -43,8 +43,7 @@ function getStandaloneSkillPaths(projectPath) {
|
|
|
43
43
|
project: path.join(cwd, ".agents", "skills"),
|
|
44
44
|
user: path.join(homeDir, ".agents", "skills"),
|
|
45
45
|
legacyProject: [path.join(cwd, "skills"), path.join(cwd, ".dexto", "skills")],
|
|
46
|
-
legacyUser: [path.join(homeDir, ".dexto", "skills")]
|
|
47
|
-
cloud: path.join(homeDir, ".dexto", "cloud-skills")
|
|
46
|
+
legacyUser: [path.join(homeDir, ".dexto", "skills")]
|
|
48
47
|
};
|
|
49
48
|
}
|
|
50
49
|
function discoverStandaloneSkills(projectPath) {
|
|
@@ -88,7 +87,6 @@ function discoverStandaloneSkills(projectPath) {
|
|
|
88
87
|
for (const legacyRoot of skillPaths.legacyUser) {
|
|
89
88
|
scanSkillsDir(legacyRoot, "user");
|
|
90
89
|
}
|
|
91
|
-
scanSkillsDir(skillPaths.cloud, "cloud");
|
|
92
90
|
return skills;
|
|
93
91
|
}
|
|
94
92
|
function getSkillSearchPaths(projectPath) {
|
|
@@ -97,8 +95,7 @@ function getSkillSearchPaths(projectPath) {
|
|
|
97
95
|
skillPaths.project,
|
|
98
96
|
...skillPaths.legacyProject,
|
|
99
97
|
skillPaths.user,
|
|
100
|
-
...skillPaths.legacyUser
|
|
101
|
-
skillPaths.cloud
|
|
98
|
+
...skillPaths.legacyUser
|
|
102
99
|
];
|
|
103
100
|
}
|
|
104
101
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -9,7 +9,6 @@
|
|
|
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)
|
|
13
12
|
* └── skill-name/
|
|
14
13
|
* ├── SKILL.md (required - skill instructions)
|
|
15
14
|
* ├── handlers/ (optional - workflow helper files)
|
|
@@ -29,8 +28,8 @@ export interface DiscoveredSkill {
|
|
|
29
28
|
path: string;
|
|
30
29
|
/** Absolute path to the SKILL.md file */
|
|
31
30
|
skillFile: string;
|
|
32
|
-
/** Source location
|
|
33
|
-
source: 'user' | 'project'
|
|
31
|
+
/** Source location */
|
|
32
|
+
source: 'user' | 'project';
|
|
34
33
|
/**
|
|
35
34
|
* Reserved for future discovery metadata.
|
|
36
35
|
*/
|
|
@@ -41,8 +40,6 @@ export interface StandaloneSkillPaths {
|
|
|
41
40
|
user: string;
|
|
42
41
|
legacyProject: readonly string[];
|
|
43
42
|
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;
|
|
46
43
|
}
|
|
47
44
|
/**
|
|
48
45
|
* Resolves the canonical standalone Skill roots used by discovery and creator tools.
|
|
@@ -54,7 +51,6 @@ export declare function getStandaloneSkillPaths(projectPath?: string): Standalon
|
|
|
54
51
|
* Search Locations:
|
|
55
52
|
* 1. <projectRoot>/.agents/skills/* (project)
|
|
56
53
|
* 2. ~/.agents/skills/* (user)
|
|
57
|
-
* 3. ~/.dexto/cloud-skills/* (cloud)
|
|
58
54
|
*
|
|
59
55
|
* @param projectPath Optional project path (defaults to cwd)
|
|
60
56
|
* @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;;;;;;;;;;;;;;;;;;;GAmBG;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,sBAAsB;IACtB,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B;;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;CACjC;AAED;;GAEG;AACH,wBAAgB,uBAAuB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,oBAAoB,CAUlF;AAED;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,eAAe,EAAE,CA+DhF;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,MAAM,EAAE,CAQlE"}
|
|
@@ -8,8 +8,7 @@ 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")]
|
|
12
|
-
cloud: path.join(homeDir, ".dexto", "cloud-skills")
|
|
11
|
+
legacyUser: [path.join(homeDir, ".dexto", "skills")]
|
|
13
12
|
};
|
|
14
13
|
}
|
|
15
14
|
function discoverStandaloneSkills(projectPath) {
|
|
@@ -53,7 +52,6 @@ function discoverStandaloneSkills(projectPath) {
|
|
|
53
52
|
for (const legacyRoot of skillPaths.legacyUser) {
|
|
54
53
|
scanSkillsDir(legacyRoot, "user");
|
|
55
54
|
}
|
|
56
|
-
scanSkillsDir(skillPaths.cloud, "cloud");
|
|
57
55
|
return skills;
|
|
58
56
|
}
|
|
59
57
|
function getSkillSearchPaths(projectPath) {
|
|
@@ -62,8 +60,7 @@ function getSkillSearchPaths(projectPath) {
|
|
|
62
60
|
skillPaths.project,
|
|
63
61
|
...skillPaths.legacyProject,
|
|
64
62
|
skillPaths.user,
|
|
65
|
-
...skillPaths.legacyUser
|
|
66
|
-
skillPaths.cloud
|
|
63
|
+
...skillPaths.legacyUser
|
|
67
64
|
];
|
|
68
65
|
}
|
|
69
66
|
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 `dexto plugin list` 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 `dexto plugin list` 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 `dexto plugin list` 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 `dexto plugin list` 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 `dexto plugin marketplace list` 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 `dexto plugin marketplace list` 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 `dexto plugin marketplace list` to see registered marketplaces, or `dexto plugin marketplace add` to register one"
|
|
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 `dexto plugin marketplace` 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 `dexto plugin marketplace list` 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 `dexto plugin marketplace list` 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 `dexto plugin marketplace list` to see registered marketplaces, or `dexto plugin marketplace add` to register one"
|
|
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 `dexto plugin marketplace` 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 setup` to create preferences"
|
|
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 setup` to create preferences"
|
|
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.info(`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.info(`\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.info(`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.info(`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.info(`\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.info(`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.info(`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.info(`Auto-installing agent '${agentId}' from bundled registry`);
|
|
53
53
|
const configPath = await installBundledAgent(agentId);
|
|
54
54
|
return configPath;
|
|
55
55
|
} catch (error) {
|
|
@@ -23,6 +23,7 @@ __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");
|
|
26
27
|
var import_schemas = require("./schemas.js");
|
|
27
28
|
var import_runtime = require("./runtime.js");
|
|
28
29
|
var import_spawn_agent_tool = require("./spawn-agent-tool.js");
|
|
@@ -68,10 +69,152 @@ const agentSpawnerToolsFactory = {
|
|
|
68
69
|
state.runtime.cleanup().catch(() => void 0);
|
|
69
70
|
}
|
|
70
71
|
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);
|
|
71
75
|
const spawnerRuntime = new import_runtime.AgentSpawnerRuntime(agent, config, logger);
|
|
72
76
|
updateWorkspaceRootHint(spawnerRuntime, context);
|
|
73
77
|
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
|
+
};
|
|
74
214
|
const abortController = new AbortController();
|
|
215
|
+
agent.on("tool:background", handleBackground, {
|
|
216
|
+
signal: abortController.signal
|
|
217
|
+
});
|
|
75
218
|
agent.on(
|
|
76
219
|
"agent:stopped",
|
|
77
220
|
() => {
|
|
@@ -81,8 +224,14 @@ const agentSpawnerToolsFactory = {
|
|
|
81
224
|
{ signal: abortController.signal }
|
|
82
225
|
);
|
|
83
226
|
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);
|
|
84
230
|
const tools = {
|
|
85
|
-
spawnAgent: spawnAgentTool
|
|
231
|
+
spawnAgent: spawnAgentTool,
|
|
232
|
+
waitFor: waitForTool,
|
|
233
|
+
checkTask: checkTaskTool,
|
|
234
|
+
listTasks: listTasksTool
|
|
86
235
|
};
|
|
87
236
|
state = {
|
|
88
237
|
agent,
|
|
@@ -127,6 +276,74 @@ const agentSpawnerToolsFactory = {
|
|
|
127
276
|
return await previewFn(input, context);
|
|
128
277
|
}
|
|
129
278
|
}
|
|
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
|
+
}
|
|
130
347
|
}
|
|
131
348
|
];
|
|
132
349
|
}
|
|
@@ -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;AAmBvD,OAAO,EAGH,KAAK,kBAAkB,EAE1B,MAAM,cAAc,CAAC;AAkCtB,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,kBAAkB,CAmYpE,CAAC"}
|