claude-flow-novice 2.14.33 → 2.14.35
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/.claude/commands/switch-api.md +1 -1
- package/.claude/skills/cfn-agent-discovery/agents-registry.json +1 -1
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +3 -9
- package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +221 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +565 -565
- package/claude-assets/commands/switch-api.md +1 -1
- package/claude-assets/skills/cfn-agent-discovery/agents-registry.json +1 -1
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +3 -9
- package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +221 -0
- package/dist/agents/agent-loader.js +133 -467
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/cli/agent-definition-parser.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,145 +1,12 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/**
|
|
3
2
|
* Dynamic Agent Loader - Reads agent definitions from .claude/agents/ directory
|
|
4
3
|
* Single source of truth for agent types in the system
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
return new (P || (P = Promise))(function(resolve, reject) {
|
|
12
|
-
function fulfilled(value) {
|
|
13
|
-
try {
|
|
14
|
-
step(generator.next(value));
|
|
15
|
-
} catch (e) {
|
|
16
|
-
reject(e);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
function rejected(value) {
|
|
20
|
-
try {
|
|
21
|
-
step(generator["throw"](value));
|
|
22
|
-
} catch (e) {
|
|
23
|
-
reject(e);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
function step(result) {
|
|
27
|
-
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
28
|
-
}
|
|
29
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
var __generator = this && this.__generator || function(thisArg, body) {
|
|
33
|
-
var _ = {
|
|
34
|
-
label: 0,
|
|
35
|
-
sent: function() {
|
|
36
|
-
if (t[0] & 1) throw t[1];
|
|
37
|
-
return t[1];
|
|
38
|
-
},
|
|
39
|
-
trys: [],
|
|
40
|
-
ops: []
|
|
41
|
-
}, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
42
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() {
|
|
43
|
-
return this;
|
|
44
|
-
}), g;
|
|
45
|
-
function verb(n) {
|
|
46
|
-
return function(v) {
|
|
47
|
-
return step([
|
|
48
|
-
n,
|
|
49
|
-
v
|
|
50
|
-
]);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function step(op) {
|
|
54
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
-
while(g && (g = 0, op[0] && (_ = 0)), _)try {
|
|
56
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
57
|
-
if (y = 0, t) op = [
|
|
58
|
-
op[0] & 2,
|
|
59
|
-
t.value
|
|
60
|
-
];
|
|
61
|
-
switch(op[0]){
|
|
62
|
-
case 0:
|
|
63
|
-
case 1:
|
|
64
|
-
t = op;
|
|
65
|
-
break;
|
|
66
|
-
case 4:
|
|
67
|
-
_.label++;
|
|
68
|
-
return {
|
|
69
|
-
value: op[1],
|
|
70
|
-
done: false
|
|
71
|
-
};
|
|
72
|
-
case 5:
|
|
73
|
-
_.label++;
|
|
74
|
-
y = op[1];
|
|
75
|
-
op = [
|
|
76
|
-
0
|
|
77
|
-
];
|
|
78
|
-
continue;
|
|
79
|
-
case 7:
|
|
80
|
-
op = _.ops.pop();
|
|
81
|
-
_.trys.pop();
|
|
82
|
-
continue;
|
|
83
|
-
default:
|
|
84
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
85
|
-
_ = 0;
|
|
86
|
-
continue;
|
|
87
|
-
}
|
|
88
|
-
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
|
|
89
|
-
_.label = op[1];
|
|
90
|
-
break;
|
|
91
|
-
}
|
|
92
|
-
if (op[0] === 6 && _.label < t[1]) {
|
|
93
|
-
_.label = t[1];
|
|
94
|
-
t = op;
|
|
95
|
-
break;
|
|
96
|
-
}
|
|
97
|
-
if (t && _.label < t[2]) {
|
|
98
|
-
_.label = t[2];
|
|
99
|
-
_.ops.push(op);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
if (t[2]) _.ops.pop();
|
|
103
|
-
_.trys.pop();
|
|
104
|
-
continue;
|
|
105
|
-
}
|
|
106
|
-
op = body.call(thisArg, _);
|
|
107
|
-
} catch (e) {
|
|
108
|
-
op = [
|
|
109
|
-
6,
|
|
110
|
-
e
|
|
111
|
-
];
|
|
112
|
-
y = 0;
|
|
113
|
-
} finally{
|
|
114
|
-
f = t = 0;
|
|
115
|
-
}
|
|
116
|
-
if (op[0] & 5) throw op[1];
|
|
117
|
-
return {
|
|
118
|
-
value: op[0] ? op[1] : void 0,
|
|
119
|
-
done: true
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
var __spreadArray = this && this.__spreadArray || function(to, from, pack) {
|
|
124
|
-
if (pack || arguments.length === 2) for(var i = 0, l = from.length, ar; i < l; i++){
|
|
125
|
-
if (ar || !(i in from)) {
|
|
126
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
127
|
-
ar[i] = from[i];
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
131
|
-
};
|
|
132
|
-
Object.defineProperty(exports, "__esModule", {
|
|
133
|
-
value: true
|
|
134
|
-
});
|
|
135
|
-
exports.refreshAgents = exports.getAgentsByCategory = exports.isValidAgentType = exports.searchAgents = exports.getAgentCategories = exports.getAllAgents = exports.getAgent = exports.getAvailableAgentTypes = exports.agentLoader = exports.AgentLoader = void 0;
|
|
136
|
-
exports.resolveLegacyAgentType = resolveLegacyAgentType;
|
|
137
|
-
var node_fs_1 = require("node:fs");
|
|
138
|
-
var glob_1 = require("glob");
|
|
139
|
-
var node_path_1 = require("node:path");
|
|
140
|
-
var yaml_1 = require("yaml");
|
|
4
|
+
*/ import { readFileSync, existsSync } from 'node:fs';
|
|
5
|
+
import { glob } from 'glob';
|
|
6
|
+
import { resolve, dirname } from 'node:path';
|
|
7
|
+
import { parse as parseYaml } from 'yaml';
|
|
141
8
|
// Legacy agent type mapping for backward compatibility
|
|
142
|
-
|
|
9
|
+
const LEGACY_AGENT_MAPPING = {
|
|
143
10
|
analyst: 'code-analyzer',
|
|
144
11
|
coordinator: 'hierarchical-coordinator',
|
|
145
12
|
optimizer: 'perf-analyzer',
|
|
@@ -150,40 +17,38 @@ var LEGACY_AGENT_MAPPING = {
|
|
|
150
17
|
};
|
|
151
18
|
/**
|
|
152
19
|
* Resolve legacy agent types to current equivalents
|
|
153
|
-
*/ function resolveLegacyAgentType(legacyType) {
|
|
20
|
+
*/ export function resolveLegacyAgentType(legacyType) {
|
|
154
21
|
return LEGACY_AGENT_MAPPING[legacyType] || legacyType;
|
|
155
22
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
AgentLoader.prototype.getAgentsDirectory = function() {
|
|
164
|
-
var currentDir = process.cwd();
|
|
23
|
+
export class AgentLoader {
|
|
24
|
+
agentCache = new Map();
|
|
25
|
+
categoriesCache = [];
|
|
26
|
+
lastLoadTime = 0;
|
|
27
|
+
CACHE_EXPIRY = 60_000;
|
|
28
|
+
getAgentsDirectory() {
|
|
29
|
+
let currentDir = process.cwd();
|
|
165
30
|
while(currentDir !== '/'){
|
|
166
|
-
|
|
167
|
-
if (
|
|
31
|
+
const claudeAgentsPath = resolve(currentDir, '.claude', 'agents');
|
|
32
|
+
if (existsSync(claudeAgentsPath)) {
|
|
168
33
|
return claudeAgentsPath;
|
|
169
34
|
}
|
|
170
|
-
currentDir =
|
|
35
|
+
currentDir = dirname(currentDir);
|
|
171
36
|
}
|
|
172
|
-
return
|
|
173
|
-
}
|
|
174
|
-
|
|
37
|
+
return resolve(process.cwd(), '.claude', 'agents');
|
|
38
|
+
}
|
|
39
|
+
parseAgentFile(filePath) {
|
|
175
40
|
try {
|
|
176
|
-
|
|
177
|
-
|
|
41
|
+
const content = readFileSync(filePath, 'utf-8');
|
|
42
|
+
const frontmatterMatch = content.match(/^---\r?\n([\s\S]*?)\r?\n---\r?\n([\s\S]*)$/);
|
|
178
43
|
if (!frontmatterMatch) {
|
|
179
|
-
console.warn(
|
|
44
|
+
console.warn(`No frontmatter found in ${filePath}`);
|
|
180
45
|
return null;
|
|
181
46
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
47
|
+
const [, yamlContent, markdownContent] = frontmatterMatch;
|
|
48
|
+
const frontmatter = parseYaml(yamlContent);
|
|
49
|
+
const description = frontmatter.description;
|
|
185
50
|
if (!frontmatter.name || !description) {
|
|
186
|
-
console.warn(
|
|
51
|
+
console.warn(`Missing required fields (name, description) in ${filePath}`);
|
|
187
52
|
return null;
|
|
188
53
|
}
|
|
189
54
|
return {
|
|
@@ -204,325 +69,126 @@ var AgentLoader = /** @class */ function() {
|
|
|
204
69
|
content: markdownContent.trim()
|
|
205
70
|
};
|
|
206
71
|
} catch (error) {
|
|
207
|
-
console.error(
|
|
72
|
+
console.error(`Error parsing agent file ${filePath}:`, error);
|
|
208
73
|
return null;
|
|
209
74
|
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
75
|
+
}
|
|
76
|
+
parseTools(frontmatter) {
|
|
77
|
+
const extractTools = (input)=>{
|
|
213
78
|
if (Array.isArray(input)) return input.map(String);
|
|
214
79
|
if (typeof input === 'string') {
|
|
215
|
-
return input.split(/[,\s]+/).map(
|
|
216
|
-
return t.trim();
|
|
217
|
-
}).filter(function(t) {
|
|
218
|
-
return t.length > 0;
|
|
219
|
-
});
|
|
80
|
+
return input.split(/[,\s]+/).map((t)=>t.trim()).filter((t)=>t.length > 0);
|
|
220
81
|
}
|
|
221
82
|
return [];
|
|
222
83
|
};
|
|
223
84
|
// Safely handle tools and capabilities.tools
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
return
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
'**/MIGRATION_SUMMARY.md'
|
|
249
|
-
],
|
|
250
|
-
absolute: true
|
|
251
|
-
}, function(err, matches) {
|
|
252
|
-
if (err) reject(err);
|
|
253
|
-
else resolve(matches);
|
|
254
|
-
});
|
|
255
|
-
})
|
|
256
|
-
];
|
|
257
|
-
case 1:
|
|
258
|
-
agentFiles = _a.sent();
|
|
259
|
-
this.agentCache.clear();
|
|
260
|
-
this.categoriesCache = [];
|
|
261
|
-
categoryMap = new Map();
|
|
262
|
-
for(_i = 0, agentFiles_1 = agentFiles; _i < agentFiles_1.length; _i++){
|
|
263
|
-
filePath = agentFiles_1[_i];
|
|
264
|
-
agent = this.parseAgentFile(filePath);
|
|
265
|
-
if (agent) {
|
|
266
|
-
this.agentCache.set(agent.name, agent);
|
|
267
|
-
relativePath = filePath.replace(agentsDir, '');
|
|
268
|
-
pathParts = relativePath.split('/');
|
|
269
|
-
category = pathParts[1] || 'uncategorized';
|
|
270
|
-
if (!categoryMap.has(category)) {
|
|
271
|
-
categoryMap.set(category, []);
|
|
272
|
-
}
|
|
273
|
-
categoryMap.get(category).push(agent);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
this.categoriesCache = Array.from(categoryMap.entries()).map(function(_a) {
|
|
277
|
-
var name = _a[0], agents = _a[1];
|
|
278
|
-
return {
|
|
279
|
-
name: name,
|
|
280
|
-
agents: agents.sort(function(a, b) {
|
|
281
|
-
return a.name.localeCompare(b.name);
|
|
282
|
-
})
|
|
283
|
-
};
|
|
284
|
-
});
|
|
285
|
-
this.lastLoadTime = Date.now();
|
|
286
|
-
return [
|
|
287
|
-
2 /*return*/
|
|
288
|
-
];
|
|
289
|
-
}
|
|
85
|
+
const toolsFromFrontmatter = frontmatter.tools ? extractTools(frontmatter.tools) : [];
|
|
86
|
+
const toolsFromCapabilities = frontmatter.capabilities && typeof frontmatter.capabilities === 'object' ? extractTools(Object(frontmatter.capabilities).tools) : [];
|
|
87
|
+
return [
|
|
88
|
+
...toolsFromFrontmatter,
|
|
89
|
+
...toolsFromCapabilities
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
async loadAgents() {
|
|
93
|
+
const agentsDir = this.getAgentsDirectory();
|
|
94
|
+
if (!existsSync(agentsDir)) {
|
|
95
|
+
console.warn(`Agents directory not found: ${agentsDir}`);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
const agentFiles = await new Promise((resolve, reject)=>{
|
|
99
|
+
glob('**/*.md', {
|
|
100
|
+
cwd: agentsDir,
|
|
101
|
+
ignore: [
|
|
102
|
+
'**/README.md',
|
|
103
|
+
'**/MIGRATION_SUMMARY.md'
|
|
104
|
+
],
|
|
105
|
+
absolute: true
|
|
106
|
+
}, (err, matches)=>{
|
|
107
|
+
if (err) reject(err);
|
|
108
|
+
else resolve(matches);
|
|
290
109
|
});
|
|
291
110
|
});
|
|
292
|
-
|
|
111
|
+
this.agentCache.clear();
|
|
112
|
+
this.categoriesCache = [];
|
|
113
|
+
const categoryMap = new Map();
|
|
114
|
+
for (const filePath of agentFiles){
|
|
115
|
+
const agent = this.parseAgentFile(filePath);
|
|
116
|
+
if (agent) {
|
|
117
|
+
this.agentCache.set(agent.name, agent);
|
|
118
|
+
const relativePath = filePath.replace(agentsDir, '');
|
|
119
|
+
const pathParts = relativePath.split('/');
|
|
120
|
+
const category = pathParts[1] || 'uncategorized';
|
|
121
|
+
if (!categoryMap.has(category)) {
|
|
122
|
+
categoryMap.set(category, []);
|
|
123
|
+
}
|
|
124
|
+
categoryMap.get(category).push(agent);
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
this.categoriesCache = Array.from(categoryMap.entries()).map(([name, agents])=>({
|
|
128
|
+
name,
|
|
129
|
+
agents: agents.sort((a, b)=>a.name.localeCompare(b.name))
|
|
130
|
+
}));
|
|
131
|
+
this.lastLoadTime = Date.now();
|
|
132
|
+
}
|
|
293
133
|
// Rest of the methods remain similar to the original implementation
|
|
294
|
-
|
|
134
|
+
needsRefresh() {
|
|
295
135
|
return Date.now() - this.lastLoadTime > this.CACHE_EXPIRY;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
};
|
|
343
|
-
AgentLoader.prototype.getAgent = function(name) {
|
|
344
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
345
|
-
return __generator(this, function(_a) {
|
|
346
|
-
switch(_a.label){
|
|
347
|
-
case 0:
|
|
348
|
-
return [
|
|
349
|
-
4 /*yield*/ ,
|
|
350
|
-
this.ensureLoaded()
|
|
351
|
-
];
|
|
352
|
-
case 1:
|
|
353
|
-
_a.sent();
|
|
354
|
-
return [
|
|
355
|
-
2 /*return*/ ,
|
|
356
|
-
this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null
|
|
357
|
-
];
|
|
358
|
-
}
|
|
359
|
-
});
|
|
360
|
-
});
|
|
361
|
-
};
|
|
362
|
-
AgentLoader.prototype.getAllAgents = function() {
|
|
363
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
364
|
-
return __generator(this, function(_a) {
|
|
365
|
-
switch(_a.label){
|
|
366
|
-
case 0:
|
|
367
|
-
return [
|
|
368
|
-
4 /*yield*/ ,
|
|
369
|
-
this.ensureLoaded()
|
|
370
|
-
];
|
|
371
|
-
case 1:
|
|
372
|
-
_a.sent();
|
|
373
|
-
return [
|
|
374
|
-
2 /*return*/ ,
|
|
375
|
-
Array.from(this.agentCache.values()).sort(function(a, b) {
|
|
376
|
-
return a.name.localeCompare(b.name);
|
|
377
|
-
})
|
|
378
|
-
];
|
|
379
|
-
}
|
|
380
|
-
});
|
|
381
|
-
});
|
|
382
|
-
};
|
|
383
|
-
AgentLoader.prototype.getAgentCategories = function() {
|
|
384
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
385
|
-
return __generator(this, function(_a) {
|
|
386
|
-
switch(_a.label){
|
|
387
|
-
case 0:
|
|
388
|
-
return [
|
|
389
|
-
4 /*yield*/ ,
|
|
390
|
-
this.ensureLoaded()
|
|
391
|
-
];
|
|
392
|
-
case 1:
|
|
393
|
-
_a.sent();
|
|
394
|
-
return [
|
|
395
|
-
2 /*return*/ ,
|
|
396
|
-
this.categoriesCache
|
|
397
|
-
];
|
|
398
|
-
}
|
|
399
|
-
});
|
|
400
|
-
});
|
|
401
|
-
};
|
|
402
|
-
AgentLoader.prototype.searchAgents = function(query) {
|
|
403
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
404
|
-
var lowerQuery;
|
|
405
|
-
return __generator(this, function(_a) {
|
|
406
|
-
switch(_a.label){
|
|
407
|
-
case 0:
|
|
408
|
-
return [
|
|
409
|
-
4 /*yield*/ ,
|
|
410
|
-
this.ensureLoaded()
|
|
411
|
-
];
|
|
412
|
-
case 1:
|
|
413
|
-
_a.sent();
|
|
414
|
-
lowerQuery = query.toLowerCase();
|
|
415
|
-
return [
|
|
416
|
-
2 /*return*/ ,
|
|
417
|
-
Array.from(this.agentCache.values()).filter(function(agent) {
|
|
418
|
-
var _a;
|
|
419
|
-
return agent.name.toLowerCase().includes(lowerQuery) || agent.description.toLowerCase().includes(lowerQuery) || ((_a = agent.capabilities) === null || _a === void 0 ? void 0 : _a.some(function(cap) {
|
|
420
|
-
return cap.toLowerCase().includes(lowerQuery);
|
|
421
|
-
}));
|
|
422
|
-
})
|
|
423
|
-
];
|
|
424
|
-
}
|
|
425
|
-
});
|
|
426
|
-
});
|
|
427
|
-
};
|
|
428
|
-
AgentLoader.prototype.isValidAgentType = function(name) {
|
|
429
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
430
|
-
return __generator(this, function(_a) {
|
|
431
|
-
switch(_a.label){
|
|
432
|
-
case 0:
|
|
433
|
-
return [
|
|
434
|
-
4 /*yield*/ ,
|
|
435
|
-
this.ensureLoaded()
|
|
436
|
-
];
|
|
437
|
-
case 1:
|
|
438
|
-
_a.sent();
|
|
439
|
-
return [
|
|
440
|
-
2 /*return*/ ,
|
|
441
|
-
this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name))
|
|
442
|
-
];
|
|
443
|
-
}
|
|
444
|
-
});
|
|
445
|
-
});
|
|
446
|
-
};
|
|
447
|
-
AgentLoader.prototype.getAgentsByCategory = function(category) {
|
|
448
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
449
|
-
var categories, found;
|
|
450
|
-
return __generator(this, function(_a) {
|
|
451
|
-
switch(_a.label){
|
|
452
|
-
case 0:
|
|
453
|
-
return [
|
|
454
|
-
4 /*yield*/ ,
|
|
455
|
-
this.getAgentCategories()
|
|
456
|
-
];
|
|
457
|
-
case 1:
|
|
458
|
-
categories = _a.sent();
|
|
459
|
-
found = categories.find(function(cat) {
|
|
460
|
-
return cat.name === category;
|
|
461
|
-
});
|
|
462
|
-
return [
|
|
463
|
-
2 /*return*/ ,
|
|
464
|
-
(found === null || found === void 0 ? void 0 : found.agents) || []
|
|
465
|
-
];
|
|
466
|
-
}
|
|
467
|
-
});
|
|
468
|
-
});
|
|
469
|
-
};
|
|
470
|
-
AgentLoader.prototype.refresh = function() {
|
|
471
|
-
return __awaiter(this, void 0, void 0, function() {
|
|
472
|
-
return __generator(this, function(_a) {
|
|
473
|
-
switch(_a.label){
|
|
474
|
-
case 0:
|
|
475
|
-
this.lastLoadTime = 0;
|
|
476
|
-
return [
|
|
477
|
-
4 /*yield*/ ,
|
|
478
|
-
this.loadAgents()
|
|
479
|
-
];
|
|
480
|
-
case 1:
|
|
481
|
-
_a.sent();
|
|
482
|
-
return [
|
|
483
|
-
2 /*return*/
|
|
484
|
-
];
|
|
485
|
-
}
|
|
486
|
-
});
|
|
487
|
-
});
|
|
488
|
-
};
|
|
489
|
-
return AgentLoader;
|
|
490
|
-
}();
|
|
491
|
-
exports.AgentLoader = AgentLoader;
|
|
136
|
+
}
|
|
137
|
+
async ensureLoaded() {
|
|
138
|
+
if (this.agentCache.size === 0 || this.needsRefresh()) {
|
|
139
|
+
await this.loadAgents();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
async getAvailableAgentTypes() {
|
|
143
|
+
await this.ensureLoaded();
|
|
144
|
+
const currentTypes = Array.from(this.agentCache.keys());
|
|
145
|
+
const legacyTypes = Object.keys(LEGACY_AGENT_MAPPING);
|
|
146
|
+
return Array.from(new Set([
|
|
147
|
+
...currentTypes,
|
|
148
|
+
...legacyTypes
|
|
149
|
+
])).sort();
|
|
150
|
+
}
|
|
151
|
+
async getAgent(name) {
|
|
152
|
+
await this.ensureLoaded();
|
|
153
|
+
return this.agentCache.get(name) || this.agentCache.get(resolveLegacyAgentType(name)) || null;
|
|
154
|
+
}
|
|
155
|
+
async getAllAgents() {
|
|
156
|
+
await this.ensureLoaded();
|
|
157
|
+
return Array.from(this.agentCache.values()).sort((a, b)=>a.name.localeCompare(b.name));
|
|
158
|
+
}
|
|
159
|
+
async getAgentCategories() {
|
|
160
|
+
await this.ensureLoaded();
|
|
161
|
+
return this.categoriesCache;
|
|
162
|
+
}
|
|
163
|
+
async searchAgents(query) {
|
|
164
|
+
await this.ensureLoaded();
|
|
165
|
+
const lowerQuery = query.toLowerCase();
|
|
166
|
+
return Array.from(this.agentCache.values()).filter((agent)=>agent.name.toLowerCase().includes(lowerQuery) || agent.description.toLowerCase().includes(lowerQuery) || agent.capabilities?.some((cap)=>cap.toLowerCase().includes(lowerQuery)));
|
|
167
|
+
}
|
|
168
|
+
async isValidAgentType(name) {
|
|
169
|
+
await this.ensureLoaded();
|
|
170
|
+
return this.agentCache.has(name) || this.agentCache.has(resolveLegacyAgentType(name));
|
|
171
|
+
}
|
|
172
|
+
async getAgentsByCategory(category) {
|
|
173
|
+
const categories = await this.getAgentCategories();
|
|
174
|
+
const found = categories.find((cat)=>cat.name === category);
|
|
175
|
+
return found?.agents || [];
|
|
176
|
+
}
|
|
177
|
+
async refresh() {
|
|
178
|
+
this.lastLoadTime = 0;
|
|
179
|
+
await this.loadAgents();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
492
182
|
// Singleton instance
|
|
493
|
-
|
|
183
|
+
export const agentLoader = new AgentLoader();
|
|
494
184
|
// Convenience exports for use in other modules
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
var getAllAgents = function() {
|
|
504
|
-
return exports.agentLoader.getAllAgents();
|
|
505
|
-
};
|
|
506
|
-
exports.getAllAgents = getAllAgents;
|
|
507
|
-
var getAgentCategories = function() {
|
|
508
|
-
return exports.agentLoader.getAgentCategories();
|
|
509
|
-
};
|
|
510
|
-
exports.getAgentCategories = getAgentCategories;
|
|
511
|
-
var searchAgents = function(query) {
|
|
512
|
-
return exports.agentLoader.searchAgents(query);
|
|
513
|
-
};
|
|
514
|
-
exports.searchAgents = searchAgents;
|
|
515
|
-
var isValidAgentType = function(name) {
|
|
516
|
-
return exports.agentLoader.isValidAgentType(name);
|
|
517
|
-
};
|
|
518
|
-
exports.isValidAgentType = isValidAgentType;
|
|
519
|
-
var getAgentsByCategory = function(category) {
|
|
520
|
-
return exports.agentLoader.getAgentsByCategory(category);
|
|
521
|
-
};
|
|
522
|
-
exports.getAgentsByCategory = getAgentsByCategory;
|
|
523
|
-
var refreshAgents = function() {
|
|
524
|
-
return exports.agentLoader.refresh();
|
|
525
|
-
};
|
|
526
|
-
exports.refreshAgents = refreshAgents;
|
|
185
|
+
export const getAvailableAgentTypes = ()=>agentLoader.getAvailableAgentTypes();
|
|
186
|
+
export const getAgent = (name)=>agentLoader.getAgent(name);
|
|
187
|
+
export const getAllAgents = ()=>agentLoader.getAllAgents();
|
|
188
|
+
export const getAgentCategories = ()=>agentLoader.getAgentCategories();
|
|
189
|
+
export const searchAgents = (query)=>agentLoader.searchAgents(query);
|
|
190
|
+
export const isValidAgentType = (name)=>agentLoader.isValidAgentType(name);
|
|
191
|
+
export const getAgentsByCategory = (category)=>agentLoader.getAgentsByCategory(category);
|
|
192
|
+
export const refreshAgents = ()=>agentLoader.refresh();
|
|
527
193
|
|
|
528
194
|
//# sourceMappingURL=agent-loader.js.map
|