@dexto/agent-management 1.2.5
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/LICENSE +44 -0
- package/dist/AgentOrchestrator.cjs +263 -0
- package/dist/AgentOrchestrator.d.ts +191 -0
- package/dist/AgentOrchestrator.d.ts.map +1 -0
- package/dist/AgentOrchestrator.js +239 -0
- package/dist/config/config-enrichment.cjs +117 -0
- package/dist/config/config-enrichment.d.ts +31 -0
- package/dist/config/config-enrichment.d.ts.map +1 -0
- package/dist/config/config-enrichment.js +82 -0
- package/dist/config/config-manager.cjs +57 -0
- package/dist/config/config-manager.d.ts +51 -0
- package/dist/config/config-manager.d.ts.map +1 -0
- package/dist/config/config-manager.js +32 -0
- package/dist/config/error-codes.cjs +39 -0
- package/dist/config/error-codes.d.ts +16 -0
- package/dist/config/error-codes.d.ts.map +1 -0
- package/dist/config/error-codes.js +15 -0
- package/dist/config/errors.cjs +125 -0
- package/dist/config/errors.d.ts +34 -0
- package/dist/config/errors.d.ts.map +1 -0
- package/dist/config/errors.js +101 -0
- package/dist/config/index.cjs +44 -0
- package/dist/config/index.d.ts +6 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +14 -0
- package/dist/config/loader.cjs +118 -0
- package/dist/config/loader.d.ts +18 -0
- package/dist/config/loader.d.ts.map +1 -0
- package/dist/config/loader.js +84 -0
- package/dist/index.cjs +132 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +104 -0
- package/dist/preferences/constants.cjs +28 -0
- package/dist/preferences/constants.d.ts +2 -0
- package/dist/preferences/constants.d.ts.map +1 -0
- package/dist/preferences/constants.js +4 -0
- package/dist/preferences/error-codes.cjs +35 -0
- package/dist/preferences/error-codes.d.ts +8 -0
- package/dist/preferences/error-codes.d.ts.map +1 -0
- package/dist/preferences/error-codes.js +11 -0
- package/dist/preferences/errors.cjs +74 -0
- package/dist/preferences/errors.d.ts +18 -0
- package/dist/preferences/errors.d.ts.map +1 -0
- package/dist/preferences/errors.js +49 -0
- package/dist/preferences/index.cjs +55 -0
- package/dist/preferences/index.d.ts +6 -0
- package/dist/preferences/index.d.ts.map +1 -0
- package/dist/preferences/index.js +31 -0
- package/dist/preferences/loader.cjs +138 -0
- package/dist/preferences/loader.d.ts +50 -0
- package/dist/preferences/loader.d.ts.map +1 -0
- package/dist/preferences/loader.js +109 -0
- package/dist/preferences/schemas.cjs +75 -0
- package/dist/preferences/schemas.d.ts +110 -0
- package/dist/preferences/schemas.d.ts.map +1 -0
- package/dist/preferences/schemas.js +48 -0
- package/dist/registry/error-codes.cjs +44 -0
- package/dist/registry/error-codes.d.ts +21 -0
- package/dist/registry/error-codes.d.ts.map +1 -0
- package/dist/registry/error-codes.js +20 -0
- package/dist/registry/errors.cjs +187 -0
- package/dist/registry/errors.d.ts +63 -0
- package/dist/registry/errors.d.ts.map +1 -0
- package/dist/registry/errors.js +163 -0
- package/dist/registry/registry.cjs +479 -0
- package/dist/registry/registry.d.ts +130 -0
- package/dist/registry/registry.d.ts.map +1 -0
- package/dist/registry/registry.js +452 -0
- package/dist/registry/types.cjs +74 -0
- package/dist/registry/types.d.ts +142 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/types.js +47 -0
- package/dist/registry/user-registry.cjs +140 -0
- package/dist/registry/user-registry.d.ts +34 -0
- package/dist/registry/user-registry.d.ts.map +1 -0
- package/dist/registry/user-registry.js +104 -0
- package/dist/resolver.cjs +182 -0
- package/dist/resolver.d.ts +14 -0
- package/dist/resolver.d.ts.map +1 -0
- package/dist/resolver.js +151 -0
- package/dist/utils/api-key-resolver.cjs +62 -0
- package/dist/utils/api-key-resolver.d.ts +21 -0
- package/dist/utils/api-key-resolver.d.ts.map +1 -0
- package/dist/utils/api-key-resolver.js +36 -0
- package/dist/utils/api-key-store.cjs +56 -0
- package/dist/utils/api-key-store.d.ts +18 -0
- package/dist/utils/api-key-store.d.ts.map +1 -0
- package/dist/utils/api-key-store.js +30 -0
- package/dist/utils/env-file.cjs +118 -0
- package/dist/utils/env-file.d.ts +5 -0
- package/dist/utils/env-file.d.ts.map +1 -0
- package/dist/utils/env-file.js +84 -0
- package/dist/utils/execution-context.cjs +85 -0
- package/dist/utils/execution-context.d.ts +20 -0
- package/dist/utils/execution-context.d.ts.map +1 -0
- package/dist/utils/execution-context.js +49 -0
- package/dist/utils/fs-walk.cjs +52 -0
- package/dist/utils/fs-walk.d.ts +8 -0
- package/dist/utils/fs-walk.d.ts.map +1 -0
- package/dist/utils/fs-walk.js +18 -0
- package/dist/utils/path.cjs +205 -0
- package/dist/utils/path.d.ts +58 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +167 -0
- package/dist/writer.cjs +182 -0
- package/dist/writer.d.ts +34 -0
- package/dist/writer.d.ts.map +1 -0
- package/dist/writer.js +146 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Elastic License 2.0 (ELv2)
|
|
2
|
+
|
|
3
|
+
**Acceptance**
|
|
4
|
+
By using the software, you agree to all of the terms and conditions below.
|
|
5
|
+
|
|
6
|
+
**Copyright License**
|
|
7
|
+
The licensor grants you a non-exclusive, royalty-free, worldwide, non-sublicensable, non-transferable license to use, copy, distribute, make available, and prepare derivative works of the software, in each case subject to the limitations and conditions below
|
|
8
|
+
|
|
9
|
+
**Limitations**
|
|
10
|
+
You may not provide the software to third parties as a hosted or managed service, where the service provides users with access to any substantial set of the features or functionality of the software.
|
|
11
|
+
|
|
12
|
+
You may not move, change, disable, or circumvent the license key functionality in the software, and you may not remove or obscure any functionality in the software that is protected by the license key.
|
|
13
|
+
|
|
14
|
+
You may not alter, remove, or obscure any licensing, copyright, or other notices of the licensor in the software. Any use of the licensor’s trademarks is subject to applicable law.
|
|
15
|
+
|
|
16
|
+
**Patents**
|
|
17
|
+
The licensor grants you a license, under any patent claims the licensor can license, or becomes able to license, to make, have made, use, sell, offer for sale, import and have imported the software, in each case subject to the limitations and conditions in this license. This license does not cover any patent claims that you cause to be infringed by modifications or additions to the software. If you or your company make any written claim that the software infringes or contributes to infringement of any patent, your patent license for the software granted under these terms ends immediately. If your company makes such a claim, your patent license ends immediately for work on behalf of your company.
|
|
18
|
+
|
|
19
|
+
**Notices**
|
|
20
|
+
You must ensure that anyone who gets a copy of any part of the software from you also gets a copy of these terms.
|
|
21
|
+
|
|
22
|
+
If you modify the software, you must include in any modified copies of the software prominent notices stating that you have modified the software.
|
|
23
|
+
|
|
24
|
+
**No Other Rights**
|
|
25
|
+
These terms do not imply any licenses other than those expressly granted in these terms.
|
|
26
|
+
|
|
27
|
+
**Termination**
|
|
28
|
+
If you use the software in violation of these terms, such use is not licensed, and your licenses will automatically terminate. If the licensor provides you with a notice of your violation, and you cease all violation of this license no later than 30 days after you receive that notice, your licenses will be reinstated retroactively. However, if you violate these terms after such reinstatement, any additional violation of these terms will cause your licenses to terminate automatically and permanently.
|
|
29
|
+
|
|
30
|
+
**No Liability**
|
|
31
|
+
As far as the law allows, the software comes as is, without any warranty or condition, and the licensor will not be liable to you for any damages arising out of these terms or the use or nature of the software, under any kind of legal claim.
|
|
32
|
+
|
|
33
|
+
**Definitions**
|
|
34
|
+
The _licensor_ is the entity offering these terms, and the _software_ is the software the licensor makes available under these terms, including any portion of it.
|
|
35
|
+
|
|
36
|
+
_you_ refers to the individual or entity agreeing to these terms.
|
|
37
|
+
|
|
38
|
+
_your company_ is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. _control_ means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect.
|
|
39
|
+
|
|
40
|
+
_your licenses_ are all the licenses granted to you for the software under these terms.
|
|
41
|
+
|
|
42
|
+
_use_ means anything you do with the software requiring one of your licenses.
|
|
43
|
+
|
|
44
|
+
_trademark_ means trademarks, service marks, and similar rights.
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var AgentOrchestrator_exports = {};
|
|
20
|
+
__export(AgentOrchestrator_exports, {
|
|
21
|
+
AgentOrchestrator: () => AgentOrchestrator
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(AgentOrchestrator_exports);
|
|
24
|
+
var import_core = require("@dexto/core");
|
|
25
|
+
var import_config = require("./config/index.js");
|
|
26
|
+
var import_registry = require("./registry/registry.js");
|
|
27
|
+
var import_types = require("./registry/types.js");
|
|
28
|
+
var import_zod = require("zod");
|
|
29
|
+
var import_core2 = require("@dexto/core");
|
|
30
|
+
class AgentOrchestrator {
|
|
31
|
+
/**
|
|
32
|
+
* Lists available and installed agents from the registry.
|
|
33
|
+
* Returns a structured object containing both installed and available agents,
|
|
34
|
+
* along with metadata like descriptions, authors, and tags.
|
|
35
|
+
*
|
|
36
|
+
* @returns Promise resolving to object with installed and available agent lists
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const agents = await AgentOrchestrator.listAgents();
|
|
41
|
+
* console.log(agents.installed); // ['default', 'my-custom-agent']
|
|
42
|
+
* console.log(agents.available); // [{ name: 'productivity', description: '...', ... }]
|
|
43
|
+
* console.log(agents.current?.name); // 'default'
|
|
44
|
+
* ```
|
|
45
|
+
*/
|
|
46
|
+
static async listAgents() {
|
|
47
|
+
const agentRegistry = (0, import_registry.getAgentRegistry)();
|
|
48
|
+
const availableMap = agentRegistry.getAvailableAgents();
|
|
49
|
+
const installedNames = await agentRegistry.getInstalledAgents();
|
|
50
|
+
const installed = await Promise.all(
|
|
51
|
+
installedNames.map(async (agentId) => {
|
|
52
|
+
const registryEntry = availableMap[agentId];
|
|
53
|
+
if (registryEntry) {
|
|
54
|
+
return {
|
|
55
|
+
id: agentId,
|
|
56
|
+
name: registryEntry.name,
|
|
57
|
+
description: registryEntry.description,
|
|
58
|
+
author: registryEntry.author,
|
|
59
|
+
tags: registryEntry.tags,
|
|
60
|
+
type: registryEntry.type
|
|
61
|
+
};
|
|
62
|
+
} else {
|
|
63
|
+
try {
|
|
64
|
+
const config = await (0, import_config.loadAgentConfig)(agentId);
|
|
65
|
+
const author = config.agentCard?.provider?.organization;
|
|
66
|
+
const result = {
|
|
67
|
+
id: agentId,
|
|
68
|
+
name: typeof config.agentCard?.name === "string" ? config.agentCard.name : (0, import_types.deriveDisplayName)(agentId),
|
|
69
|
+
description: config.agentCard?.description || "Local agent",
|
|
70
|
+
tags: [],
|
|
71
|
+
type: "custom"
|
|
72
|
+
// Assume custom if not in registry
|
|
73
|
+
};
|
|
74
|
+
if (author) {
|
|
75
|
+
result.author = author;
|
|
76
|
+
}
|
|
77
|
+
return result;
|
|
78
|
+
} catch {
|
|
79
|
+
const result = {
|
|
80
|
+
id: agentId,
|
|
81
|
+
name: (0, import_types.deriveDisplayName)(agentId),
|
|
82
|
+
description: "Local agent (config unavailable)",
|
|
83
|
+
tags: [],
|
|
84
|
+
type: "custom"
|
|
85
|
+
// Assume custom if not in registry
|
|
86
|
+
};
|
|
87
|
+
return result;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
})
|
|
91
|
+
);
|
|
92
|
+
const available = Object.entries(availableMap).filter(([agentId]) => !installedNames.includes(agentId)).map(([agentId, entry]) => ({
|
|
93
|
+
id: agentId,
|
|
94
|
+
name: entry.name,
|
|
95
|
+
description: entry.description,
|
|
96
|
+
author: entry.author,
|
|
97
|
+
tags: entry.tags,
|
|
98
|
+
type: entry.type
|
|
99
|
+
}));
|
|
100
|
+
return {
|
|
101
|
+
installed,
|
|
102
|
+
available,
|
|
103
|
+
current: { id: null, name: null }
|
|
104
|
+
// TODO: Track current agent name
|
|
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 async installAgent(agentName) {
|
|
123
|
+
const agentRegistry = (0, import_registry.getAgentRegistry)();
|
|
124
|
+
if (!agentRegistry.hasAgent(agentName)) {
|
|
125
|
+
throw import_core.AgentError.apiValidationError(`Agent '${agentName}' not found in registry`);
|
|
126
|
+
}
|
|
127
|
+
try {
|
|
128
|
+
await agentRegistry.installAgent(agentName, true);
|
|
129
|
+
import_core.logger.info(`Successfully installed agent: ${agentName}`);
|
|
130
|
+
} catch (error) {
|
|
131
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
132
|
+
import_core.logger.error(`Failed to install agent ${agentName}: ${errorMessage}`);
|
|
133
|
+
throw import_core.AgentError.apiValidationError(
|
|
134
|
+
`Installation failed for agent '${agentName}'`,
|
|
135
|
+
error
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Installs a custom agent from a local file or directory path.
|
|
141
|
+
* Creates a new custom agent entry in the user registry with provided metadata.
|
|
142
|
+
*
|
|
143
|
+
* @param agentName The name to use for the custom agent (must be unique)
|
|
144
|
+
* @param sourcePath Absolute path to the agent YAML file or directory
|
|
145
|
+
* @param metadata Agent metadata (description, author, tags, main config file)
|
|
146
|
+
* @param injectPreferences Whether to inject global preferences into agent config (default: true)
|
|
147
|
+
* @returns Promise resolving to the path of the installed main config file
|
|
148
|
+
*
|
|
149
|
+
* @throws {AgentError} When name conflicts with existing agent or installation fails
|
|
150
|
+
*
|
|
151
|
+
* @example
|
|
152
|
+
* ```typescript
|
|
153
|
+
* await AgentOrchestrator.installCustomAgent('my-coding-agent', '/path/to/agent.yml', {
|
|
154
|
+
* description: 'Custom coding assistant',
|
|
155
|
+
* author: 'John Doe',
|
|
156
|
+
* tags: ['coding', 'custom']
|
|
157
|
+
* });
|
|
158
|
+
* console.log('Custom agent installed successfully');
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
static async installCustomAgent(agentName, sourcePath, metadata, injectPreferences = true) {
|
|
162
|
+
const agentRegistry = (0, import_registry.getAgentRegistry)();
|
|
163
|
+
try {
|
|
164
|
+
const mainConfigPath = await agentRegistry.installCustomAgentFromPath(
|
|
165
|
+
agentName,
|
|
166
|
+
sourcePath,
|
|
167
|
+
metadata,
|
|
168
|
+
injectPreferences
|
|
169
|
+
);
|
|
170
|
+
import_core.logger.info(`Successfully installed custom agent: ${agentName}`);
|
|
171
|
+
return mainConfigPath;
|
|
172
|
+
} catch (error) {
|
|
173
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
174
|
+
import_core.logger.error(`Failed to install custom agent ${agentName}: ${errorMessage}`);
|
|
175
|
+
throw import_core.AgentError.apiValidationError(
|
|
176
|
+
`Installation failed for custom agent '${agentName}'`,
|
|
177
|
+
error
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Uninstalls an agent by removing its directory from disk.
|
|
183
|
+
* For custom agents: also removes from user registry.
|
|
184
|
+
* For builtin agents: only removes from disk (can be reinstalled).
|
|
185
|
+
*
|
|
186
|
+
* @param agentName The name of the agent to uninstall
|
|
187
|
+
* @param force Whether to force uninstall even if agent is protected (default: false)
|
|
188
|
+
* @returns Promise that resolves when uninstallation is complete
|
|
189
|
+
*
|
|
190
|
+
* @throws {AgentError} When agent is not installed or uninstallation fails
|
|
191
|
+
*
|
|
192
|
+
* @example
|
|
193
|
+
* ```typescript
|
|
194
|
+
* await AgentOrchestrator.uninstallAgent('my-custom-agent');
|
|
195
|
+
* console.log('Agent uninstalled successfully');
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
static async uninstallAgent(agentName, force = false) {
|
|
199
|
+
const agentRegistry = (0, import_registry.getAgentRegistry)();
|
|
200
|
+
try {
|
|
201
|
+
await agentRegistry.uninstallAgent(agentName, force);
|
|
202
|
+
import_core.logger.info(`Successfully uninstalled agent: ${agentName}`);
|
|
203
|
+
} catch (error) {
|
|
204
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
205
|
+
import_core.logger.error(`Failed to uninstall agent ${agentName}: ${errorMessage}`);
|
|
206
|
+
throw import_core.AgentError.apiValidationError(
|
|
207
|
+
`Uninstallation failed for agent '${agentName}'`,
|
|
208
|
+
error
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Creates a new agent instance for the specified agent name.
|
|
214
|
+
* This method resolves the agent (installing if needed), loads its configuration,
|
|
215
|
+
* and returns a new DextoAgent instance ready to be started.
|
|
216
|
+
*
|
|
217
|
+
* This is a factory method that doesn't affect any existing agent instances.
|
|
218
|
+
* The caller is responsible for managing the lifecycle of the returned agent.
|
|
219
|
+
*
|
|
220
|
+
* @param agentName The name of the agent to create
|
|
221
|
+
* @returns Promise resolving to a new DextoAgent instance (not started)
|
|
222
|
+
*
|
|
223
|
+
* @throws {AgentError} When agent is not found or creation fails
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* ```typescript
|
|
227
|
+
* const newAgent = await AgentOrchestrator.createAgent('productivity');
|
|
228
|
+
* await newAgent.start();
|
|
229
|
+
* ```
|
|
230
|
+
*/
|
|
231
|
+
static async createAgent(agentName) {
|
|
232
|
+
const agentRegistry = (0, import_registry.getAgentRegistry)();
|
|
233
|
+
try {
|
|
234
|
+
const agentPath = await agentRegistry.resolveAgent(agentName, true, true);
|
|
235
|
+
const config = await (0, import_config.loadAgentConfig)(agentPath);
|
|
236
|
+
const enrichedConfig = (0, import_config.enrichAgentConfig)(config, agentPath);
|
|
237
|
+
import_core.logger.info(`Creating agent: ${agentName}`);
|
|
238
|
+
const newAgent = new import_core.DextoAgent(enrichedConfig, agentPath);
|
|
239
|
+
import_core.logger.info(`Successfully created agent: ${agentName}`);
|
|
240
|
+
return newAgent;
|
|
241
|
+
} catch (error) {
|
|
242
|
+
if (error instanceof import_zod.ZodError) {
|
|
243
|
+
const issues = (0, import_core2.zodToIssues)(error, "error");
|
|
244
|
+
const formatted = issues.map((issue) => {
|
|
245
|
+
const path = Array.isArray(issue.path) ? issue.path.join(".") : String(issue.path);
|
|
246
|
+
return `${path}: ${issue.message}`;
|
|
247
|
+
});
|
|
248
|
+
const message = `Configuration validation failed for agent '${agentName}':
|
|
249
|
+
${formatted.join("\n")}`;
|
|
250
|
+
import_core.logger.error(message);
|
|
251
|
+
throw new import_core.DextoValidationError(issues);
|
|
252
|
+
}
|
|
253
|
+
import_core.logger.error(
|
|
254
|
+
`Failed to create agent '${agentName}': ${error instanceof Error ? error.message : String(error)}`
|
|
255
|
+
);
|
|
256
|
+
throw import_core.AgentError.apiValidationError(`Failed to create agent '${agentName}'`, error);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
261
|
+
0 && (module.exports = {
|
|
262
|
+
AgentOrchestrator
|
|
263
|
+
});
|
|
@@ -0,0 +1,191 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|