@dexto/agent-management 1.3.0 → 1.5.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/AgentFactory.cjs +152 -0
- package/dist/AgentFactory.d.ts +121 -0
- package/dist/AgentFactory.d.ts.map +1 -0
- package/dist/AgentFactory.js +132 -0
- package/dist/AgentManager.cjs +226 -0
- package/dist/AgentManager.d.ts +191 -0
- package/dist/AgentManager.d.ts.map +1 -0
- package/dist/AgentManager.js +192 -0
- package/dist/config/config-enrichment.cjs +23 -3
- package/dist/config/config-enrichment.d.ts +20 -5
- package/dist/config/config-enrichment.d.ts.map +1 -1
- package/dist/config/config-enrichment.js +22 -3
- package/dist/config/config-manager.cjs +340 -3
- package/dist/config/config-manager.d.ts +158 -7
- package/dist/config/config-manager.d.ts.map +1 -1
- package/dist/config/config-manager.js +325 -3
- package/dist/config/discover-prompts.cjs +103 -0
- package/dist/config/discover-prompts.d.ts +28 -0
- package/dist/config/discover-prompts.d.ts.map +1 -0
- package/dist/config/discover-prompts.js +73 -0
- package/dist/config/errors.cjs +2 -2
- package/dist/config/errors.js +2 -2
- package/dist/config/index.cjs +14 -2
- package/dist/config/index.d.ts +2 -2
- package/dist/config/index.d.ts.map +1 -1
- package/dist/config/index.js +21 -3
- package/dist/index.cjs +109 -6
- package/dist/index.d.ts +9 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +111 -6
- package/dist/installation.cjs +239 -0
- package/dist/installation.d.ts +72 -0
- package/dist/installation.d.ts.map +1 -0
- package/dist/installation.js +202 -0
- package/dist/models/custom-models.cjs +157 -0
- package/dist/models/custom-models.d.ts +94 -0
- package/dist/models/custom-models.d.ts.map +1 -0
- package/dist/models/custom-models.js +117 -0
- package/dist/models/index.cjs +89 -0
- package/dist/models/index.d.ts +11 -0
- package/dist/models/index.d.ts.map +1 -0
- package/dist/models/index.js +68 -0
- package/dist/models/path-resolver.cjs +154 -0
- package/dist/models/path-resolver.d.ts +77 -0
- package/dist/models/path-resolver.d.ts.map +1 -0
- package/dist/models/path-resolver.js +108 -0
- package/dist/models/state-manager.cjs +220 -0
- package/dist/models/state-manager.d.ts +138 -0
- package/dist/models/state-manager.d.ts.map +1 -0
- package/dist/models/state-manager.js +184 -0
- package/dist/preferences/error-codes.cjs +2 -0
- package/dist/preferences/error-codes.d.ts +3 -1
- package/dist/preferences/error-codes.d.ts.map +1 -1
- package/dist/preferences/error-codes.js +2 -0
- package/dist/preferences/index.d.ts +1 -1
- package/dist/preferences/index.d.ts.map +1 -1
- package/dist/preferences/loader.cjs +32 -6
- package/dist/preferences/loader.d.ts +23 -4
- package/dist/preferences/loader.d.ts.map +1 -1
- package/dist/preferences/loader.js +32 -6
- package/dist/preferences/schemas.cjs +21 -3
- package/dist/preferences/schemas.d.ts +52 -24
- package/dist/preferences/schemas.d.ts.map +1 -1
- package/dist/preferences/schemas.js +28 -4
- package/dist/registry/registry.cjs +28 -45
- package/dist/registry/registry.d.ts +8 -6
- package/dist/registry/registry.d.ts.map +1 -1
- package/dist/registry/registry.js +26 -44
- package/dist/registry/types.d.ts +11 -13
- package/dist/registry/types.d.ts.map +1 -1
- package/dist/resolver.cjs +82 -43
- package/dist/resolver.d.ts +7 -5
- package/dist/resolver.d.ts.map +1 -1
- package/dist/resolver.js +83 -44
- package/dist/utils/api-key-resolver.cjs +19 -1
- package/dist/utils/api-key-resolver.d.ts.map +1 -1
- package/dist/utils/api-key-resolver.js +19 -1
- package/dist/utils/api-key-store.cjs +46 -0
- package/dist/utils/api-key-store.d.ts +27 -0
- package/dist/utils/api-key-store.d.ts.map +1 -1
- package/dist/utils/api-key-store.js +44 -0
- package/dist/utils/env-file.cjs +20 -68
- package/dist/utils/env-file.d.ts +2 -1
- package/dist/utils/env-file.d.ts.map +1 -1
- package/dist/utils/env-file.js +20 -68
- package/dist/writer.cjs +20 -2
- package/dist/writer.d.ts +1 -0
- package/dist/writer.d.ts.map +1 -1
- package/dist/writer.js +20 -2
- package/package.json +2 -2
- package/dist/AgentOrchestrator.cjs +0 -263
- package/dist/AgentOrchestrator.d.ts +0 -191
- package/dist/AgentOrchestrator.d.ts.map +0 -1
- package/dist/AgentOrchestrator.js +0 -239
|
@@ -3,8 +3,6 @@ import { promises as fs } from "fs";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import { logger } from "@dexto/core";
|
|
5
5
|
import { resolveBundledScript, getDextoGlobalPath, copyDirectory } from "../utils/path.js";
|
|
6
|
-
import { loadGlobalPreferences } from "../preferences/loader.js";
|
|
7
|
-
import { writePreferencesToAgent } from "../writer.js";
|
|
8
6
|
import {
|
|
9
7
|
RegistrySchema,
|
|
10
8
|
normalizeRegistryJson
|
|
@@ -16,6 +14,7 @@ import {
|
|
|
16
14
|
removeAgentFromUserRegistry,
|
|
17
15
|
addAgentToUserRegistry
|
|
18
16
|
} from "./user-registry.js";
|
|
17
|
+
import { loadGlobalPreferences } from "../preferences/loader.js";
|
|
19
18
|
let cachedRegistry = null;
|
|
20
19
|
class LocalAgentRegistry {
|
|
21
20
|
_registry = null;
|
|
@@ -141,12 +140,15 @@ class LocalAgentRegistry {
|
|
|
141
140
|
return configPath;
|
|
142
141
|
}
|
|
143
142
|
}
|
|
143
|
+
// TODO: Consider removing install/uninstall methods from LocalAgentRegistry class.
|
|
144
|
+
// Installing/uninstalling from registry to local agents/ is better suited as a CLI command.
|
|
145
|
+
// A bundler/opinionated project structure should help - agents/ will by default be their registry.
|
|
146
|
+
// For now these methods remain for backward compatibility.
|
|
144
147
|
/**
|
|
145
148
|
* Install agent atomically using temp + rename pattern
|
|
146
149
|
* @param agentId ID of the agent to install
|
|
147
|
-
* @param injectPreferences Whether to inject global preferences into installed agent (default: true)
|
|
148
150
|
*/
|
|
149
|
-
async installAgent(agentId
|
|
151
|
+
async installAgent(agentId) {
|
|
150
152
|
logger.info(`Installing agent: ${agentId}`);
|
|
151
153
|
const registry = this.getRegistry();
|
|
152
154
|
const agentData = registry.agents[agentId];
|
|
@@ -184,24 +186,6 @@ class LocalAgentRegistry {
|
|
|
184
186
|
}
|
|
185
187
|
await fs.rename(tempDir, targetDir);
|
|
186
188
|
logger.info(`\u2713 Installed agent '${agentId}' to ${targetDir}`);
|
|
187
|
-
if (injectPreferences) {
|
|
188
|
-
try {
|
|
189
|
-
const preferences = await loadGlobalPreferences();
|
|
190
|
-
await writePreferencesToAgent(targetDir, preferences);
|
|
191
|
-
logger.info(`\u2713 Applied global preferences to installed agent '${agentId}'`);
|
|
192
|
-
} catch (error) {
|
|
193
|
-
logger.warn(
|
|
194
|
-
`Failed to inject preferences to '${agentId}': ${error instanceof Error ? error.message : String(error)}`
|
|
195
|
-
);
|
|
196
|
-
console.log(
|
|
197
|
-
`\u26A0\uFE0F Warning: Could not apply preferences to '${agentId}' - agent will use bundled settings`
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
} else {
|
|
201
|
-
logger.info(
|
|
202
|
-
`Skipped preference injection for '${agentId}' (injectPreferences=false)`
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
189
|
return this.resolveMainConfig(targetDir, agentId);
|
|
206
190
|
} catch (error) {
|
|
207
191
|
try {
|
|
@@ -224,10 +208,9 @@ class LocalAgentRegistry {
|
|
|
224
208
|
* @param agentId Unique identifier for the custom agent
|
|
225
209
|
* @param sourcePath Absolute path to agent YAML file or directory
|
|
226
210
|
* @param metadata Agent metadata (name for display, description, author, tags, main)
|
|
227
|
-
* @param injectPreferences Whether to inject global preferences (default: true)
|
|
228
211
|
* @returns Path to the installed agent's main config file
|
|
229
212
|
*/
|
|
230
|
-
async installCustomAgentFromPath(agentId, sourcePath, metadata
|
|
213
|
+
async installCustomAgentFromPath(agentId, sourcePath, metadata) {
|
|
231
214
|
logger.info(`Installing custom agent '${agentId}' from ${sourcePath}`);
|
|
232
215
|
this.validateCustomAgentId(agentId);
|
|
233
216
|
if (!existsSync(sourcePath)) {
|
|
@@ -301,20 +284,6 @@ class LocalAgentRegistry {
|
|
|
301
284
|
}
|
|
302
285
|
throw registryError;
|
|
303
286
|
}
|
|
304
|
-
if (injectPreferences) {
|
|
305
|
-
try {
|
|
306
|
-
const preferences = await loadGlobalPreferences();
|
|
307
|
-
await writePreferencesToAgent(targetDir, preferences);
|
|
308
|
-
logger.info(`\u2713 Applied global preferences to custom agent '${agentId}'`);
|
|
309
|
-
} catch (error) {
|
|
310
|
-
logger.warn(
|
|
311
|
-
`Failed to inject preferences to '${agentId}': ${error instanceof Error ? error.message : String(error)}`
|
|
312
|
-
);
|
|
313
|
-
console.log(
|
|
314
|
-
`\u26A0\uFE0F Warning: Could not apply preferences to '${agentId}' - agent will use default settings`
|
|
315
|
-
);
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
287
|
return mainConfigPath;
|
|
319
288
|
} catch (error) {
|
|
320
289
|
try {
|
|
@@ -338,9 +307,8 @@ class LocalAgentRegistry {
|
|
|
338
307
|
* Handles installing agent if needed
|
|
339
308
|
* @param agentId ID of the agent to resolve
|
|
340
309
|
* @param autoInstall Whether to automatically install missing agents from registry (default: true)
|
|
341
|
-
* @param injectPreferences Whether to inject preferences during auto-installation (default: true)
|
|
342
310
|
*/
|
|
343
|
-
async resolveAgent(agentId, autoInstall = true
|
|
311
|
+
async resolveAgent(agentId, autoInstall = true) {
|
|
344
312
|
logger.debug(`Resolving registry agent: ${agentId}`);
|
|
345
313
|
const globalAgentsDir = getDextoGlobalPath("agents");
|
|
346
314
|
const installedPath = path.resolve(globalAgentsDir, agentId);
|
|
@@ -357,7 +325,7 @@ class LocalAgentRegistry {
|
|
|
357
325
|
if (this.hasAgent(agentId)) {
|
|
358
326
|
if (autoInstall) {
|
|
359
327
|
logger.info(`Installing agent '${agentId}' from registry...`);
|
|
360
|
-
return await this.installAgent(agentId
|
|
328
|
+
return await this.installAgent(agentId);
|
|
361
329
|
} else {
|
|
362
330
|
const registry2 = this.getRegistry();
|
|
363
331
|
const available2 = Object.keys(registry2.agents);
|
|
@@ -393,8 +361,8 @@ class LocalAgentRegistry {
|
|
|
393
361
|
const defaultAgent = preferences.defaults.defaultAgent;
|
|
394
362
|
return agentId !== defaultAgent;
|
|
395
363
|
} catch {
|
|
396
|
-
logger.warn("Could not load preferences, using fallback protection for
|
|
397
|
-
return agentId !== "
|
|
364
|
+
logger.warn("Could not load preferences, using fallback protection for coding-agent");
|
|
365
|
+
return agentId !== "coding-agent";
|
|
398
366
|
}
|
|
399
367
|
}
|
|
400
368
|
/**
|
|
@@ -446,7 +414,21 @@ function getAgentRegistry() {
|
|
|
446
414
|
}
|
|
447
415
|
return cachedRegistry;
|
|
448
416
|
}
|
|
417
|
+
function loadBundledRegistryAgents() {
|
|
418
|
+
try {
|
|
419
|
+
const registryPath = resolveBundledScript("agents/agent-registry.json");
|
|
420
|
+
const content = readFileSync(registryPath, "utf-8");
|
|
421
|
+
const registry = JSON.parse(content);
|
|
422
|
+
return registry.agents || {};
|
|
423
|
+
} catch (error) {
|
|
424
|
+
logger.warn(
|
|
425
|
+
`Could not load bundled registry: ${error instanceof Error ? error.message : String(error)}`
|
|
426
|
+
);
|
|
427
|
+
return {};
|
|
428
|
+
}
|
|
429
|
+
}
|
|
449
430
|
export {
|
|
450
431
|
LocalAgentRegistry,
|
|
451
|
-
getAgentRegistry
|
|
432
|
+
getAgentRegistry,
|
|
433
|
+
loadBundledRegistryAgents
|
|
452
434
|
};
|
package/dist/registry/types.d.ts
CHANGED
|
@@ -13,17 +13,17 @@ export declare const AgentRegistryEntrySchema: z.ZodObject<{
|
|
|
13
13
|
main: z.ZodOptional<z.ZodString>;
|
|
14
14
|
type: z.ZodDefault<z.ZodEnum<["builtin", "custom"]>>;
|
|
15
15
|
}, "strict", z.ZodTypeAny, {
|
|
16
|
-
name: string;
|
|
17
|
-
type: "custom" | "builtin";
|
|
18
16
|
id: string;
|
|
17
|
+
name: string;
|
|
19
18
|
description: string;
|
|
20
19
|
author: string;
|
|
21
20
|
tags: string[];
|
|
21
|
+
type: "custom" | "builtin";
|
|
22
22
|
source: string;
|
|
23
23
|
main?: string | undefined;
|
|
24
24
|
}, {
|
|
25
|
-
name: string;
|
|
26
25
|
id: string;
|
|
26
|
+
name: string;
|
|
27
27
|
description: string;
|
|
28
28
|
author: string;
|
|
29
29
|
tags: string[];
|
|
@@ -47,17 +47,17 @@ export declare const RegistrySchema: z.ZodObject<{
|
|
|
47
47
|
main: z.ZodOptional<z.ZodString>;
|
|
48
48
|
type: z.ZodDefault<z.ZodEnum<["builtin", "custom"]>>;
|
|
49
49
|
}, "strict", z.ZodTypeAny, {
|
|
50
|
-
name: string;
|
|
51
|
-
type: "custom" | "builtin";
|
|
52
50
|
id: string;
|
|
51
|
+
name: string;
|
|
53
52
|
description: string;
|
|
54
53
|
author: string;
|
|
55
54
|
tags: string[];
|
|
55
|
+
type: "custom" | "builtin";
|
|
56
56
|
source: string;
|
|
57
57
|
main?: string | undefined;
|
|
58
58
|
}, {
|
|
59
|
-
name: string;
|
|
60
59
|
id: string;
|
|
60
|
+
name: string;
|
|
61
61
|
description: string;
|
|
62
62
|
author: string;
|
|
63
63
|
tags: string[];
|
|
@@ -68,20 +68,20 @@ export declare const RegistrySchema: z.ZodObject<{
|
|
|
68
68
|
}, "strict", z.ZodTypeAny, {
|
|
69
69
|
version: string;
|
|
70
70
|
agents: Record<string, {
|
|
71
|
-
name: string;
|
|
72
|
-
type: "custom" | "builtin";
|
|
73
71
|
id: string;
|
|
72
|
+
name: string;
|
|
74
73
|
description: string;
|
|
75
74
|
author: string;
|
|
76
75
|
tags: string[];
|
|
76
|
+
type: "custom" | "builtin";
|
|
77
77
|
source: string;
|
|
78
78
|
main?: string | undefined;
|
|
79
79
|
}>;
|
|
80
80
|
}, {
|
|
81
81
|
version: string;
|
|
82
82
|
agents: Record<string, {
|
|
83
|
-
name: string;
|
|
84
83
|
id: string;
|
|
84
|
+
name: string;
|
|
85
85
|
description: string;
|
|
86
86
|
author: string;
|
|
87
87
|
tags: string[];
|
|
@@ -115,10 +115,9 @@ export interface AgentRegistry {
|
|
|
115
115
|
/**
|
|
116
116
|
* Installs an agent from the registry by ID
|
|
117
117
|
* @param agentId - Unique agent identifier
|
|
118
|
-
* @param injectPreferences - Whether to inject global preferences (default: true)
|
|
119
118
|
* @returns Path to the installed agent config
|
|
120
119
|
*/
|
|
121
|
-
installAgent(agentId: string
|
|
120
|
+
installAgent(agentId: string): Promise<string>;
|
|
122
121
|
/**
|
|
123
122
|
* Uninstalls an agent by ID
|
|
124
123
|
* @param agentId - Unique agent identifier
|
|
@@ -133,10 +132,9 @@ export interface AgentRegistry {
|
|
|
133
132
|
* Resolves an agent ID or path and optionally auto-installs if needed
|
|
134
133
|
* @param idOrPath - Agent ID from registry or filesystem path
|
|
135
134
|
* @param autoInstall - Whether to auto-install from registry (default: true)
|
|
136
|
-
* @param injectPreferences - Whether to inject preferences during install (default: true)
|
|
137
135
|
* @returns Path to the agent config file
|
|
138
136
|
*/
|
|
139
|
-
resolveAgent(idOrPath: string, autoInstall?: boolean
|
|
137
|
+
resolveAgent(idOrPath: string, autoInstall?: boolean): Promise<string>;
|
|
140
138
|
}
|
|
141
139
|
export {};
|
|
142
140
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWxB,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKd,CAAC;AAEd,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAEvD,KAAK,WAAW,GAAG;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAsC/D;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACzD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAMtD;AAED;;GAEG;AACH,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWxB,CAAC;AAEd,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,wBAAwB,CAAC,CAAC;AAE3E;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKd,CAAC;AAEd,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,MAAM,CAAC,OAAO,cAAc,CAAC,CAAC;AAEvD,KAAK,WAAW,GAAG;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;CAC9C,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,OAAO,GAAG,WAAW,CAsC/D;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC1B;;OAEG;IACH,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC;;OAEG;IACH,kBAAkB,IAAI,MAAM,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IACzD;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAC/C;;;;OAIG;IACH,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAChE;;OAEG;IACH,kBAAkB,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACxC;;;;;OAKG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC1E"}
|
package/dist/resolver.cjs
CHANGED
|
@@ -39,7 +39,10 @@ var import_execution_context = require("./utils/execution-context.js");
|
|
|
39
39
|
var import_core = require("@dexto/core");
|
|
40
40
|
var import_loader = require("./preferences/loader.js");
|
|
41
41
|
var import_config = require("./config/index.js");
|
|
42
|
-
|
|
42
|
+
var import_errors = require("./registry/errors.js");
|
|
43
|
+
var import_AgentManager = require("./AgentManager.js");
|
|
44
|
+
var import_installation = require("./installation.js");
|
|
45
|
+
async function resolveAgentPath(nameOrPath, autoInstall = true) {
|
|
43
46
|
if (nameOrPath && (0, import_path2.isPath)(nameOrPath)) {
|
|
44
47
|
const resolved = import_path.default.resolve(nameOrPath);
|
|
45
48
|
try {
|
|
@@ -53,32 +56,67 @@ async function resolveAgentPath(nameOrPath, autoInstall = true, injectPreference
|
|
|
53
56
|
}
|
|
54
57
|
}
|
|
55
58
|
if (nameOrPath) {
|
|
56
|
-
|
|
57
|
-
const registry = getAgentRegistry();
|
|
58
|
-
return await registry.resolveAgent(nameOrPath, autoInstall, injectPreferences);
|
|
59
|
+
return await resolveAgentByName(nameOrPath, autoInstall);
|
|
59
60
|
}
|
|
60
|
-
return await resolveDefaultAgentByContext(autoInstall
|
|
61
|
+
return await resolveDefaultAgentByContext(autoInstall);
|
|
61
62
|
}
|
|
62
|
-
async function
|
|
63
|
+
async function resolveAgentByName(agentId, autoInstall) {
|
|
64
|
+
const agentsDir = (0, import_path2.getDextoGlobalPath)("agents");
|
|
65
|
+
const installedRegistryPath = import_path.default.join(agentsDir, "registry.json");
|
|
66
|
+
try {
|
|
67
|
+
const manager = new import_AgentManager.AgentManager(installedRegistryPath);
|
|
68
|
+
await manager.loadRegistry();
|
|
69
|
+
if (manager.hasAgent(agentId)) {
|
|
70
|
+
const agentPath = await getAgentConfigPath(agentId);
|
|
71
|
+
return agentPath;
|
|
72
|
+
}
|
|
73
|
+
} catch (error) {
|
|
74
|
+
import_core.logger.debug(`Agent '${agentId}' not found in installed registry: ${error}`);
|
|
75
|
+
}
|
|
76
|
+
if (autoInstall) {
|
|
77
|
+
try {
|
|
78
|
+
import_core.logger.info(`Auto-installing agent '${agentId}' from bundled registry`);
|
|
79
|
+
const configPath = await (0, import_installation.installBundledAgent)(agentId);
|
|
80
|
+
return configPath;
|
|
81
|
+
} catch (error) {
|
|
82
|
+
import_core.logger.debug(`Failed to auto-install agent '${agentId}': ${error}`);
|
|
83
|
+
throw import_errors.RegistryError.agentNotFound(agentId, []);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
throw import_errors.RegistryError.agentNotInstalledAutoInstallDisabled(agentId, []);
|
|
87
|
+
}
|
|
88
|
+
async function getAgentConfigPath(agentId) {
|
|
89
|
+
const agentsDir = (0, import_path2.getDextoGlobalPath)("agents");
|
|
90
|
+
const installedRegistryPath = import_path.default.join(agentsDir, "registry.json");
|
|
91
|
+
const registryContent = await import_fs.promises.readFile(installedRegistryPath, "utf-8");
|
|
92
|
+
const registry = JSON.parse(registryContent);
|
|
93
|
+
const agentEntry = registry.agents.find((a) => a.id === agentId);
|
|
94
|
+
if (!agentEntry) {
|
|
95
|
+
const available = registry.agents.map((a) => a.id);
|
|
96
|
+
throw import_errors.RegistryError.agentNotFound(agentId, available);
|
|
97
|
+
}
|
|
98
|
+
return import_path.default.resolve(import_path.default.dirname(installedRegistryPath), agentEntry.configPath);
|
|
99
|
+
}
|
|
100
|
+
async function resolveDefaultAgentByContext(autoInstall = true) {
|
|
63
101
|
const executionContext = (0, import_execution_context.getExecutionContext)();
|
|
64
102
|
switch (executionContext) {
|
|
65
103
|
case "dexto-source":
|
|
66
|
-
return await resolveDefaultAgentForDextoSource(autoInstall
|
|
104
|
+
return await resolveDefaultAgentForDextoSource(autoInstall);
|
|
67
105
|
case "dexto-project":
|
|
68
|
-
return await resolveDefaultAgentForDextoProject(autoInstall
|
|
106
|
+
return await resolveDefaultAgentForDextoProject(autoInstall);
|
|
69
107
|
case "global-cli":
|
|
70
|
-
return await resolveDefaultAgentForGlobalCLI(autoInstall
|
|
108
|
+
return await resolveDefaultAgentForGlobalCLI(autoInstall);
|
|
71
109
|
default:
|
|
72
110
|
throw import_config.ConfigError.unknownContext(executionContext);
|
|
73
111
|
}
|
|
74
112
|
}
|
|
75
|
-
async function resolveDefaultAgentForDextoSource(autoInstall = true
|
|
113
|
+
async function resolveDefaultAgentForDextoSource(autoInstall = true) {
|
|
76
114
|
import_core.logger.debug("Resolving default agent for dexto source context");
|
|
77
115
|
const sourceRoot = (0, import_execution_context.findDextoSourceRoot)();
|
|
78
116
|
if (!sourceRoot) {
|
|
79
117
|
throw import_config.ConfigError.bundledNotFound("dexto source directory not found");
|
|
80
118
|
}
|
|
81
|
-
const repoConfigPath = import_path.default.join(sourceRoot, "agents", "
|
|
119
|
+
const repoConfigPath = import_path.default.join(sourceRoot, "agents", "coding-agent", "coding-agent.yml");
|
|
82
120
|
const isDevMode = process.env.DEXTO_DEV_MODE === "true";
|
|
83
121
|
if (isDevMode) {
|
|
84
122
|
import_core.logger.debug("Dev mode: using repository config file");
|
|
@@ -95,13 +133,7 @@ async function resolveDefaultAgentForDextoSource(autoInstall = true, injectPrefe
|
|
|
95
133
|
if (preferences.setup.completed) {
|
|
96
134
|
import_core.logger.debug("Using user preferences in dexto-source context");
|
|
97
135
|
const preferredAgentName = preferences.defaults.defaultAgent;
|
|
98
|
-
|
|
99
|
-
const registry = getAgentRegistry();
|
|
100
|
-
return await registry.resolveAgent(
|
|
101
|
-
preferredAgentName,
|
|
102
|
-
autoInstall,
|
|
103
|
-
injectPreferences
|
|
104
|
-
);
|
|
136
|
+
return await resolveAgentByName(preferredAgentName, autoInstall);
|
|
105
137
|
}
|
|
106
138
|
} catch (error) {
|
|
107
139
|
import_core.logger.warn(`Failed to load preferences, falling back to repo config: ${error}`);
|
|
@@ -115,16 +147,16 @@ async function resolveDefaultAgentForDextoSource(autoInstall = true, injectPrefe
|
|
|
115
147
|
throw import_config.ConfigError.bundledNotFound(repoConfigPath);
|
|
116
148
|
}
|
|
117
149
|
}
|
|
118
|
-
async function resolveDefaultAgentForDextoProject(autoInstall = true
|
|
150
|
+
async function resolveDefaultAgentForDextoProject(autoInstall = true) {
|
|
119
151
|
import_core.logger.debug("Resolving default agent for dexto project context");
|
|
120
152
|
const projectRoot = (0, import_execution_context.findDextoProjectRoot)();
|
|
121
153
|
if (!projectRoot) {
|
|
122
154
|
throw import_config.ConfigError.unknownContext("dexto-project: project root not found");
|
|
123
155
|
}
|
|
124
156
|
const candidatePaths = [
|
|
125
|
-
import_path.default.join(projectRoot, "
|
|
126
|
-
import_path.default.join(projectRoot, "agents", "
|
|
127
|
-
import_path.default.join(projectRoot, "src", "dexto", "agents", "
|
|
157
|
+
import_path.default.join(projectRoot, "coding-agent.yml"),
|
|
158
|
+
import_path.default.join(projectRoot, "agents", "coding-agent.yml"),
|
|
159
|
+
import_path.default.join(projectRoot, "src", "dexto", "agents", "coding-agent.yml")
|
|
128
160
|
];
|
|
129
161
|
for (const p of candidatePaths) {
|
|
130
162
|
try {
|
|
@@ -133,7 +165,7 @@ async function resolveDefaultAgentForDextoProject(autoInstall = true, injectPref
|
|
|
133
165
|
} catch {
|
|
134
166
|
}
|
|
135
167
|
}
|
|
136
|
-
import_core.logger.debug(`No project-local
|
|
168
|
+
import_core.logger.debug(`No project-local coding-agent.yml found in ${projectRoot}`);
|
|
137
169
|
if (!(0, import_loader.globalPreferencesExist)()) {
|
|
138
170
|
throw import_config.ConfigError.noProjectDefault(projectRoot);
|
|
139
171
|
}
|
|
@@ -142,11 +174,9 @@ async function resolveDefaultAgentForDextoProject(autoInstall = true, injectPref
|
|
|
142
174
|
throw import_config.ConfigError.setupIncomplete();
|
|
143
175
|
}
|
|
144
176
|
const preferredAgentName = preferences.defaults.defaultAgent;
|
|
145
|
-
|
|
146
|
-
const registry = getAgentRegistry();
|
|
147
|
-
return await registry.resolveAgent(preferredAgentName, autoInstall, injectPreferences);
|
|
177
|
+
return await resolveAgentByName(preferredAgentName, autoInstall);
|
|
148
178
|
}
|
|
149
|
-
async function resolveDefaultAgentForGlobalCLI(autoInstall = true
|
|
179
|
+
async function resolveDefaultAgentForGlobalCLI(autoInstall = true) {
|
|
150
180
|
import_core.logger.debug("Resolving default agent for global CLI context");
|
|
151
181
|
if (!(0, import_loader.globalPreferencesExist)()) {
|
|
152
182
|
throw import_config.ConfigError.noGlobalPreferences();
|
|
@@ -156,24 +186,33 @@ async function resolveDefaultAgentForGlobalCLI(autoInstall = true, injectPrefere
|
|
|
156
186
|
throw import_config.ConfigError.setupIncomplete();
|
|
157
187
|
}
|
|
158
188
|
const preferredAgentName = preferences.defaults.defaultAgent;
|
|
159
|
-
|
|
160
|
-
const registry = getAgentRegistry();
|
|
161
|
-
return await registry.resolveAgent(preferredAgentName, autoInstall, injectPreferences);
|
|
189
|
+
return await resolveAgentByName(preferredAgentName, autoInstall);
|
|
162
190
|
}
|
|
163
191
|
async function updateDefaultAgentPreference(agentName) {
|
|
164
|
-
const
|
|
165
|
-
const
|
|
166
|
-
const
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
192
|
+
const agentsDir = (0, import_path2.getDextoGlobalPath)("agents");
|
|
193
|
+
const installedRegistryPath = import_path.default.join(agentsDir, "registry.json");
|
|
194
|
+
const bundledRegistryPath = (0, import_path2.resolveBundledScript)("agents/agent-registry.json");
|
|
195
|
+
const registriesToCheck = [
|
|
196
|
+
{ path: installedRegistryPath, name: "installed" },
|
|
197
|
+
{ path: bundledRegistryPath, name: "bundled" }
|
|
198
|
+
];
|
|
199
|
+
for (const registry of registriesToCheck) {
|
|
200
|
+
try {
|
|
201
|
+
const manager = new import_AgentManager.AgentManager(registry.path);
|
|
202
|
+
await manager.loadRegistry();
|
|
203
|
+
if (manager.hasAgent(agentName)) {
|
|
204
|
+
const { updateGlobalPreferences } = await import("./preferences/loader.js");
|
|
205
|
+
await updateGlobalPreferences({
|
|
206
|
+
defaults: { defaultAgent: agentName }
|
|
207
|
+
});
|
|
208
|
+
import_core.logger.info(`Updated default agent preference to: ${agentName}`);
|
|
209
|
+
return;
|
|
210
|
+
}
|
|
211
|
+
} catch (error) {
|
|
212
|
+
import_core.logger.debug(`Agent '${agentName}' not found in ${registry.name} registry: ${error}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
throw import_errors.RegistryError.agentNotFound(agentName, []);
|
|
177
216
|
}
|
|
178
217
|
// Annotate the CommonJS export names for ESM import in node:
|
|
179
218
|
0 && (module.exports = {
|
package/dist/resolver.d.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Resolve agent path with
|
|
2
|
+
* Resolve agent path with automatic installation if needed
|
|
3
3
|
* @param nameOrPath Optional agent name or explicit path
|
|
4
|
-
* @param autoInstall Whether to automatically install missing agents from registry (default: true)
|
|
5
|
-
* @param injectPreferences Whether to inject preferences during auto-installation (default: true)
|
|
4
|
+
* @param autoInstall Whether to automatically install missing agents from bundled registry (default: true)
|
|
6
5
|
* @returns Resolved absolute path to agent config
|
|
7
|
-
* @throws
|
|
6
|
+
* @throws {ConfigError} For path/config issues (file not found, unknown context, setup incomplete)
|
|
7
|
+
* @throws {RegistryError} For agent lookup failures (agent not found, not installed)
|
|
8
8
|
*/
|
|
9
|
-
export declare function resolveAgentPath(nameOrPath?: string, autoInstall?: boolean
|
|
9
|
+
export declare function resolveAgentPath(nameOrPath?: string, autoInstall?: boolean): Promise<string>;
|
|
10
10
|
/**
|
|
11
11
|
* Update default agent preference
|
|
12
|
+
* @param agentName The agent name to set as the new default
|
|
13
|
+
* @throws {RegistryError} If the agent is not found in installed or bundled registry
|
|
12
14
|
*/
|
|
13
15
|
export declare function updateDefaultAgentPreference(agentName: string): Promise<void>;
|
|
14
16
|
//# sourceMappingURL=resolver.d.ts.map
|
package/dist/resolver.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAoCA;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CAClC,UAAU,CAAC,EAAE,MAAM,EACnB,WAAW,GAAE,OAAc,GAC5B,OAAO,CAAC,MAAM,CAAC,CAuBjB;AAiMD;;;;GAIG;AACH,wBAAsB,4BAA4B,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CA+BnF"}
|