@dexto/agent-management 1.3.0 → 1.4.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.
Files changed (50) hide show
  1. package/dist/AgentFactory.cjs +153 -0
  2. package/dist/AgentFactory.d.ts +121 -0
  3. package/dist/AgentFactory.d.ts.map +1 -0
  4. package/dist/AgentFactory.js +133 -0
  5. package/dist/AgentManager.cjs +226 -0
  6. package/dist/AgentManager.d.ts +191 -0
  7. package/dist/AgentManager.d.ts.map +1 -0
  8. package/dist/AgentManager.js +192 -0
  9. package/dist/config/config-enrichment.cjs +22 -2
  10. package/dist/config/config-enrichment.d.ts +19 -4
  11. package/dist/config/config-enrichment.d.ts.map +1 -1
  12. package/dist/config/config-enrichment.js +21 -2
  13. package/dist/config/config-manager.cjs +340 -3
  14. package/dist/config/config-manager.d.ts +158 -7
  15. package/dist/config/config-manager.d.ts.map +1 -1
  16. package/dist/config/config-manager.js +325 -3
  17. package/dist/config/discover-prompts.cjs +103 -0
  18. package/dist/config/discover-prompts.d.ts +28 -0
  19. package/dist/config/discover-prompts.d.ts.map +1 -0
  20. package/dist/config/discover-prompts.js +73 -0
  21. package/dist/config/index.cjs +14 -2
  22. package/dist/config/index.d.ts +2 -2
  23. package/dist/config/index.d.ts.map +1 -1
  24. package/dist/config/index.js +21 -3
  25. package/dist/index.cjs +40 -6
  26. package/dist/index.d.ts +6 -4
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +40 -5
  29. package/dist/installation.cjs +252 -0
  30. package/dist/installation.d.ts +74 -0
  31. package/dist/installation.d.ts.map +1 -0
  32. package/dist/installation.js +215 -0
  33. package/dist/models/custom-models.cjs +116 -0
  34. package/dist/models/custom-models.d.ts +51 -0
  35. package/dist/models/custom-models.d.ts.map +1 -0
  36. package/dist/models/custom-models.js +77 -0
  37. package/dist/registry/registry.cjs +21 -2
  38. package/dist/registry/registry.d.ts +5 -0
  39. package/dist/registry/registry.d.ts.map +1 -1
  40. package/dist/registry/registry.js +19 -1
  41. package/dist/registry/types.d.ts +9 -9
  42. package/dist/resolver.cjs +68 -29
  43. package/dist/resolver.d.ts +6 -3
  44. package/dist/resolver.d.ts.map +1 -1
  45. package/dist/resolver.js +69 -30
  46. package/package.json +2 -2
  47. package/dist/AgentOrchestrator.cjs +0 -263
  48. package/dist/AgentOrchestrator.d.ts +0 -191
  49. package/dist/AgentOrchestrator.d.ts.map +0 -1
  50. package/dist/AgentOrchestrator.js +0 -239
@@ -1,191 +0,0 @@
1
- import { DextoAgent } from '@dexto/core';
2
- /**
3
- * AgentOrchestrator - Main orchestrator class for managing Dexto agents
4
- *
5
- * This class serves as the primary entry point for agent lifecycle management,
6
- * including installation, creation, and coordination of multiple agent instances.
7
- *
8
- * ## Current Features
9
- * - **Agent Discovery**: List available and installed agents
10
- * - **Agent Installation**: Install agents from registry or custom sources
11
- * - **Agent Creation**: Factory methods for creating agent instances
12
- * - **Agent Removal**: Uninstall agents from the system
13
- *
14
- * ## Future Orchestration Features (Planned)
15
- * The following features are planned for future releases to enable advanced
16
- * multi-agent orchestration and coordination:
17
- *
18
- * ### Multi-Agent Instance Management
19
- * - Manage multiple concurrent agent instances with different configurations
20
- * - Track agent lifecycle states (created, started, stopped, errored)
21
- * - Provide APIs for listing and querying active agent instances
22
- *
23
- * ### Agent Switching & Routing
24
- * - Switch between active agents dynamically during runtime
25
- * - Route requests to appropriate agents based on context or capabilities
26
- * - Maintain conversation continuity across agent switches
27
- *
28
- * ### Cross-Agent Coordination
29
- * - Enable agents to collaborate on complex tasks requiring specialized skills
30
- * - Delegate sub-tasks from one agent to another
31
- * - Aggregate results from multiple agents working in parallel
32
- *
33
- * ### Global Event Bus
34
- * - Centralized event bus for cross-agent communication
35
- * - Subscribe to events from any managed agent instance
36
- * - Coordinate state synchronization across agent boundaries
37
- *
38
- * ### Resource Management
39
- * - Shared resource pools (API keys, rate limits, connection pools)
40
- * - Resource allocation and quota management across agents
41
- * - Prevent resource conflicts between concurrent agent instances
42
- *
43
- * ### Agent Persistence & Sessions
44
- * - Save and restore agent instances with their full state
45
- * - Support for long-running agent workflows that span multiple sessions
46
- * - Checkpoint and resume capabilities for complex agent operations
47
- *
48
- * @example
49
- * ```typescript
50
- * // List available agents
51
- * const agents = await AgentOrchestrator.listAgents();
52
- * console.log(agents.installed, agents.available);
53
- *
54
- * // Install agent
55
- * await AgentOrchestrator.installAgent('productivity');
56
- *
57
- * // Create and start agent
58
- * const agent = await AgentOrchestrator.createAgent('productivity');
59
- * await agent.start();
60
- *
61
- * // Install custom agent
62
- * await AgentOrchestrator.installCustomAgent('my-agent', '/path/to/config.yml', {
63
- * description: 'My custom agent',
64
- * author: 'John Doe',
65
- * tags: ['custom', 'specialized']
66
- * });
67
- * ```
68
- */
69
- export declare class AgentOrchestrator {
70
- /**
71
- * Lists available and installed agents from the registry.
72
- * Returns a structured object containing both installed and available agents,
73
- * along with metadata like descriptions, authors, and tags.
74
- *
75
- * @returns Promise resolving to object with installed and available agent lists
76
- *
77
- * @example
78
- * ```typescript
79
- * const agents = await AgentOrchestrator.listAgents();
80
- * console.log(agents.installed); // ['default', 'my-custom-agent']
81
- * console.log(agents.available); // [{ name: 'productivity', description: '...', ... }]
82
- * console.log(agents.current?.name); // 'default'
83
- * ```
84
- */
85
- static listAgents(): Promise<{
86
- installed: Array<{
87
- id: string;
88
- name: string;
89
- description: string;
90
- author?: string;
91
- tags?: string[];
92
- type: 'builtin' | 'custom';
93
- }>;
94
- available: Array<{
95
- id: string;
96
- name: string;
97
- description: string;
98
- author?: string;
99
- tags?: string[];
100
- type: 'builtin' | 'custom';
101
- }>;
102
- current?: {
103
- id?: string | null;
104
- name?: string | null;
105
- };
106
- }>;
107
- /**
108
- * Installs an agent from the registry.
109
- * Downloads and sets up the specified agent, making it available for use.
110
- *
111
- * @param agentName The name of the agent to install from the registry
112
- * @returns Promise that resolves when installation is complete
113
- *
114
- * @throws {AgentError} When agent is not found in registry or installation fails
115
- *
116
- * @example
117
- * ```typescript
118
- * await AgentOrchestrator.installAgent('productivity');
119
- * console.log('Productivity agent installed successfully');
120
- * ```
121
- */
122
- static installAgent(agentName: string): Promise<void>;
123
- /**
124
- * Installs a custom agent from a local file or directory path.
125
- * Creates a new custom agent entry in the user registry with provided metadata.
126
- *
127
- * @param agentName The name to use for the custom agent (must be unique)
128
- * @param sourcePath Absolute path to the agent YAML file or directory
129
- * @param metadata Agent metadata (description, author, tags, main config file)
130
- * @param injectPreferences Whether to inject global preferences into agent config (default: true)
131
- * @returns Promise resolving to the path of the installed main config file
132
- *
133
- * @throws {AgentError} When name conflicts with existing agent or installation fails
134
- *
135
- * @example
136
- * ```typescript
137
- * await AgentOrchestrator.installCustomAgent('my-coding-agent', '/path/to/agent.yml', {
138
- * description: 'Custom coding assistant',
139
- * author: 'John Doe',
140
- * tags: ['coding', 'custom']
141
- * });
142
- * console.log('Custom agent installed successfully');
143
- * ```
144
- */
145
- static installCustomAgent(agentName: string, sourcePath: string, metadata: {
146
- name?: string;
147
- description: string;
148
- author: string;
149
- tags: string[];
150
- main?: string;
151
- }, injectPreferences?: boolean): Promise<string>;
152
- /**
153
- * Uninstalls an agent by removing its directory from disk.
154
- * For custom agents: also removes from user registry.
155
- * For builtin agents: only removes from disk (can be reinstalled).
156
- *
157
- * @param agentName The name of the agent to uninstall
158
- * @param force Whether to force uninstall even if agent is protected (default: false)
159
- * @returns Promise that resolves when uninstallation is complete
160
- *
161
- * @throws {AgentError} When agent is not installed or uninstallation fails
162
- *
163
- * @example
164
- * ```typescript
165
- * await AgentOrchestrator.uninstallAgent('my-custom-agent');
166
- * console.log('Agent uninstalled successfully');
167
- * ```
168
- */
169
- static uninstallAgent(agentName: string, force?: boolean): Promise<void>;
170
- /**
171
- * Creates a new agent instance for the specified agent name.
172
- * This method resolves the agent (installing if needed), loads its configuration,
173
- * and returns a new DextoAgent instance ready to be started.
174
- *
175
- * This is a factory method that doesn't affect any existing agent instances.
176
- * The caller is responsible for managing the lifecycle of the returned agent.
177
- *
178
- * @param agentName The name of the agent to create
179
- * @returns Promise resolving to a new DextoAgent instance (not started)
180
- *
181
- * @throws {AgentError} When agent is not found or creation fails
182
- *
183
- * @example
184
- * ```typescript
185
- * const newAgent = await AgentOrchestrator.createAgent('productivity');
186
- * await newAgent.start();
187
- * ```
188
- */
189
- static createAgent(agentName: string): Promise<DextoAgent>;
190
- }
191
- //# sourceMappingURL=AgentOrchestrator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AgentOrchestrator.d.ts","sourceRoot":"","sources":["../src/AgentOrchestrator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,UAAU,EAAwB,MAAM,aAAa,CAAC;AAOnF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkEG;AACH,qBAAa,iBAAiB;IAC1B;;;;;;;;;;;;;;OAcG;WACiB,UAAU,IAAI,OAAO,CAAC;QACtC,SAAS,EAAE,KAAK,CAAC;YACb,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,MAAM,CAAC;YACb,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;YAChB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;SAC9B,CAAC,CAAC;QACH,SAAS,EAAE,KAAK,CAAC;YACb,EAAE,EAAE,MAAM,CAAC;YACX,IAAI,EAAE,MAAM,CAAC;YACb,WAAW,EAAE,MAAM,CAAC;YACpB,MAAM,CAAC,EAAE,MAAM,CAAC;YAChB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;YAChB,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;SAC9B,CAAC,CAAC;QACH,OAAO,CAAC,EAAE;YAAE,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;SAAE,CAAC;KAC1D,CAAC;IAoFF;;;;;;;;;;;;;;OAcG;WACiB,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBlE;;;;;;;;;;;;;;;;;;;;;OAqBG;WACiB,kBAAkB,CAClC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE;QACN,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,EAAE,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;KACjB,EACD,iBAAiB,GAAE,OAAc,GAClC,OAAO,CAAC,MAAM,CAAC;IAsBlB;;;;;;;;;;;;;;;;OAgBG;WACiB,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,GAAE,OAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB5F;;;;;;;;;;;;;;;;;;OAkBG;WACiB,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;CA2C1E"}
@@ -1,239 +0,0 @@
1
- import { logger, AgentError, DextoAgent, DextoValidationError } from "@dexto/core";
2
- import { loadAgentConfig, enrichAgentConfig } from "./config/index.js";
3
- import { getAgentRegistry } from "./registry/registry.js";
4
- import { deriveDisplayName } from "./registry/types.js";
5
- import { ZodError } from "zod";
6
- import { zodToIssues } from "@dexto/core";
7
- class AgentOrchestrator {
8
- /**
9
- * Lists available and installed agents from the registry.
10
- * Returns a structured object containing both installed and available agents,
11
- * along with metadata like descriptions, authors, and tags.
12
- *
13
- * @returns Promise resolving to object with installed and available agent lists
14
- *
15
- * @example
16
- * ```typescript
17
- * const agents = await AgentOrchestrator.listAgents();
18
- * console.log(agents.installed); // ['default', 'my-custom-agent']
19
- * console.log(agents.available); // [{ name: 'productivity', description: '...', ... }]
20
- * console.log(agents.current?.name); // 'default'
21
- * ```
22
- */
23
- static async listAgents() {
24
- const agentRegistry = getAgentRegistry();
25
- const availableMap = agentRegistry.getAvailableAgents();
26
- const installedNames = await agentRegistry.getInstalledAgents();
27
- const installed = await Promise.all(
28
- installedNames.map(async (agentId) => {
29
- const registryEntry = availableMap[agentId];
30
- if (registryEntry) {
31
- return {
32
- id: agentId,
33
- name: registryEntry.name,
34
- description: registryEntry.description,
35
- author: registryEntry.author,
36
- tags: registryEntry.tags,
37
- type: registryEntry.type
38
- };
39
- } else {
40
- try {
41
- const config = await loadAgentConfig(agentId);
42
- const author = config.agentCard?.provider?.organization;
43
- const result = {
44
- id: agentId,
45
- name: typeof config.agentCard?.name === "string" ? config.agentCard.name : deriveDisplayName(agentId),
46
- description: config.agentCard?.description || "Local agent",
47
- tags: [],
48
- type: "custom"
49
- // Assume custom if not in registry
50
- };
51
- if (author) {
52
- result.author = author;
53
- }
54
- return result;
55
- } catch {
56
- const result = {
57
- id: agentId,
58
- name: deriveDisplayName(agentId),
59
- description: "Local agent (config unavailable)",
60
- tags: [],
61
- type: "custom"
62
- // Assume custom if not in registry
63
- };
64
- return result;
65
- }
66
- }
67
- })
68
- );
69
- const available = Object.entries(availableMap).filter(([agentId]) => !installedNames.includes(agentId)).map(([agentId, entry]) => ({
70
- id: agentId,
71
- name: entry.name,
72
- description: entry.description,
73
- author: entry.author,
74
- tags: entry.tags,
75
- type: entry.type
76
- }));
77
- return {
78
- installed,
79
- available,
80
- current: { id: null, name: null }
81
- // TODO: Track current agent name
82
- };
83
- }
84
- /**
85
- * Installs an agent from the registry.
86
- * Downloads and sets up the specified agent, making it available for use.
87
- *
88
- * @param agentName The name of the agent to install from the registry
89
- * @returns Promise that resolves when installation is complete
90
- *
91
- * @throws {AgentError} When agent is not found in registry or installation fails
92
- *
93
- * @example
94
- * ```typescript
95
- * await AgentOrchestrator.installAgent('productivity');
96
- * console.log('Productivity agent installed successfully');
97
- * ```
98
- */
99
- static async installAgent(agentName) {
100
- const agentRegistry = getAgentRegistry();
101
- if (!agentRegistry.hasAgent(agentName)) {
102
- throw AgentError.apiValidationError(`Agent '${agentName}' not found in registry`);
103
- }
104
- try {
105
- await agentRegistry.installAgent(agentName, true);
106
- logger.info(`Successfully installed agent: ${agentName}`);
107
- } catch (error) {
108
- const errorMessage = error instanceof Error ? error.message : String(error);
109
- logger.error(`Failed to install agent ${agentName}: ${errorMessage}`);
110
- throw AgentError.apiValidationError(
111
- `Installation failed for agent '${agentName}'`,
112
- error
113
- );
114
- }
115
- }
116
- /**
117
- * Installs a custom agent from a local file or directory path.
118
- * Creates a new custom agent entry in the user registry with provided metadata.
119
- *
120
- * @param agentName The name to use for the custom agent (must be unique)
121
- * @param sourcePath Absolute path to the agent YAML file or directory
122
- * @param metadata Agent metadata (description, author, tags, main config file)
123
- * @param injectPreferences Whether to inject global preferences into agent config (default: true)
124
- * @returns Promise resolving to the path of the installed main config file
125
- *
126
- * @throws {AgentError} When name conflicts with existing agent or installation fails
127
- *
128
- * @example
129
- * ```typescript
130
- * await AgentOrchestrator.installCustomAgent('my-coding-agent', '/path/to/agent.yml', {
131
- * description: 'Custom coding assistant',
132
- * author: 'John Doe',
133
- * tags: ['coding', 'custom']
134
- * });
135
- * console.log('Custom agent installed successfully');
136
- * ```
137
- */
138
- static async installCustomAgent(agentName, sourcePath, metadata, injectPreferences = true) {
139
- const agentRegistry = getAgentRegistry();
140
- try {
141
- const mainConfigPath = await agentRegistry.installCustomAgentFromPath(
142
- agentName,
143
- sourcePath,
144
- metadata,
145
- injectPreferences
146
- );
147
- logger.info(`Successfully installed custom agent: ${agentName}`);
148
- return mainConfigPath;
149
- } catch (error) {
150
- const errorMessage = error instanceof Error ? error.message : String(error);
151
- logger.error(`Failed to install custom agent ${agentName}: ${errorMessage}`);
152
- throw AgentError.apiValidationError(
153
- `Installation failed for custom agent '${agentName}'`,
154
- error
155
- );
156
- }
157
- }
158
- /**
159
- * Uninstalls an agent by removing its directory from disk.
160
- * For custom agents: also removes from user registry.
161
- * For builtin agents: only removes from disk (can be reinstalled).
162
- *
163
- * @param agentName The name of the agent to uninstall
164
- * @param force Whether to force uninstall even if agent is protected (default: false)
165
- * @returns Promise that resolves when uninstallation is complete
166
- *
167
- * @throws {AgentError} When agent is not installed or uninstallation fails
168
- *
169
- * @example
170
- * ```typescript
171
- * await AgentOrchestrator.uninstallAgent('my-custom-agent');
172
- * console.log('Agent uninstalled successfully');
173
- * ```
174
- */
175
- static async uninstallAgent(agentName, force = false) {
176
- const agentRegistry = getAgentRegistry();
177
- try {
178
- await agentRegistry.uninstallAgent(agentName, force);
179
- logger.info(`Successfully uninstalled agent: ${agentName}`);
180
- } catch (error) {
181
- const errorMessage = error instanceof Error ? error.message : String(error);
182
- logger.error(`Failed to uninstall agent ${agentName}: ${errorMessage}`);
183
- throw AgentError.apiValidationError(
184
- `Uninstallation failed for agent '${agentName}'`,
185
- error
186
- );
187
- }
188
- }
189
- /**
190
- * Creates a new agent instance for the specified agent name.
191
- * This method resolves the agent (installing if needed), loads its configuration,
192
- * and returns a new DextoAgent instance ready to be started.
193
- *
194
- * This is a factory method that doesn't affect any existing agent instances.
195
- * The caller is responsible for managing the lifecycle of the returned agent.
196
- *
197
- * @param agentName The name of the agent to create
198
- * @returns Promise resolving to a new DextoAgent instance (not started)
199
- *
200
- * @throws {AgentError} When agent is not found or creation fails
201
- *
202
- * @example
203
- * ```typescript
204
- * const newAgent = await AgentOrchestrator.createAgent('productivity');
205
- * await newAgent.start();
206
- * ```
207
- */
208
- static async createAgent(agentName) {
209
- const agentRegistry = getAgentRegistry();
210
- try {
211
- const agentPath = await agentRegistry.resolveAgent(agentName, true, true);
212
- const config = await loadAgentConfig(agentPath);
213
- const enrichedConfig = enrichAgentConfig(config, agentPath);
214
- logger.info(`Creating agent: ${agentName}`);
215
- const newAgent = new DextoAgent(enrichedConfig, agentPath);
216
- logger.info(`Successfully created agent: ${agentName}`);
217
- return newAgent;
218
- } catch (error) {
219
- if (error instanceof ZodError) {
220
- const issues = zodToIssues(error, "error");
221
- const formatted = issues.map((issue) => {
222
- const path = Array.isArray(issue.path) ? issue.path.join(".") : String(issue.path);
223
- return `${path}: ${issue.message}`;
224
- });
225
- const message = `Configuration validation failed for agent '${agentName}':
226
- ${formatted.join("\n")}`;
227
- logger.error(message);
228
- throw new DextoValidationError(issues);
229
- }
230
- logger.error(
231
- `Failed to create agent '${agentName}': ${error instanceof Error ? error.message : String(error)}`
232
- );
233
- throw AgentError.apiValidationError(`Failed to create agent '${agentName}'`, error);
234
- }
235
- }
236
- }
237
- export {
238
- AgentOrchestrator
239
- };