universal-agent-memory 0.4.1 → 0.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/bin/cli.js +0 -0
- package/dist/coordination/capability-router.d.ts +79 -0
- package/dist/coordination/capability-router.d.ts.map +1 -0
- package/dist/coordination/capability-router.js +324 -0
- package/dist/coordination/capability-router.js.map +1 -0
- package/dist/coordination/deploy-batcher.d.ts +64 -1
- package/dist/coordination/deploy-batcher.d.ts.map +1 -1
- package/dist/coordination/deploy-batcher.js +203 -39
- package/dist/coordination/deploy-batcher.js.map +1 -1
- package/dist/coordination/index.d.ts +1 -0
- package/dist/coordination/index.d.ts.map +1 -1
- package/dist/coordination/index.js +1 -0
- package/dist/coordination/index.js.map +1 -1
- package/dist/generators/template-loader.d.ts +105 -0
- package/dist/generators/template-loader.d.ts.map +1 -0
- package/dist/generators/template-loader.js +291 -0
- package/dist/generators/template-loader.js.map +1 -0
- package/dist/memory/serverless-qdrant.d.ts +102 -0
- package/dist/memory/serverless-qdrant.d.ts.map +1 -0
- package/dist/memory/serverless-qdrant.js +369 -0
- package/dist/memory/serverless-qdrant.js.map +1 -0
- package/dist/types/config.d.ts +1220 -15
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/config.js +92 -1
- package/dist/types/config.js.map +1 -1
- package/dist/types/coordination.d.ts +4 -4
- package/package.json +1 -1
- package/templates/CLAUDE.template.md +310 -822
package/dist/bin/cli.js
CHANGED
|
File without changes
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { AgentRegistryEntry } from '../types/coordination.js';
|
|
2
|
+
import type { Task, TaskType } from '../tasks/types.js';
|
|
3
|
+
/**
|
|
4
|
+
* Agent capability definitions for intelligent task routing.
|
|
5
|
+
*/
|
|
6
|
+
export type AgentCapability = 'typescript' | 'javascript' | 'python' | 'rust' | 'go' | 'cpp' | 'java' | 'cli' | 'frontend' | 'backend' | 'database' | 'security' | 'performance' | 'documentation' | 'testing' | 'devops' | 'infrastructure' | 'code-review' | 'refactoring';
|
|
7
|
+
/**
|
|
8
|
+
* Droid/skill mapping for capability routing.
|
|
9
|
+
*/
|
|
10
|
+
export interface CapabilityMapping {
|
|
11
|
+
capability: AgentCapability;
|
|
12
|
+
droids: string[];
|
|
13
|
+
skills: string[];
|
|
14
|
+
filePatterns: string[];
|
|
15
|
+
taskTypes: TaskType[];
|
|
16
|
+
priority: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Default capability mappings for UAM droids and skills.
|
|
20
|
+
*/
|
|
21
|
+
export declare const DEFAULT_CAPABILITY_MAPPINGS: CapabilityMapping[];
|
|
22
|
+
export interface RoutingResult {
|
|
23
|
+
recommendedDroids: string[];
|
|
24
|
+
recommendedSkills: string[];
|
|
25
|
+
matchedCapabilities: AgentCapability[];
|
|
26
|
+
confidence: number;
|
|
27
|
+
reasoning: string;
|
|
28
|
+
}
|
|
29
|
+
export interface AgentMatch {
|
|
30
|
+
agent: AgentRegistryEntry;
|
|
31
|
+
matchedCapabilities: AgentCapability[];
|
|
32
|
+
score: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Capability-based router for intelligent task and agent routing.
|
|
36
|
+
*/
|
|
37
|
+
export declare class CapabilityRouter {
|
|
38
|
+
private mappings;
|
|
39
|
+
constructor(customMappings?: CapabilityMapping[]);
|
|
40
|
+
/**
|
|
41
|
+
* Route a task to the best droids/skills based on task content and affected files.
|
|
42
|
+
*/
|
|
43
|
+
routeTask(task: Task, affectedFiles?: string[]): RoutingResult;
|
|
44
|
+
/**
|
|
45
|
+
* Find the best agent for a task based on capabilities.
|
|
46
|
+
*/
|
|
47
|
+
findBestAgent(task: Task, availableAgents: AgentRegistryEntry[], affectedFiles?: string[]): AgentMatch | null;
|
|
48
|
+
/**
|
|
49
|
+
* Route files to appropriate capabilities.
|
|
50
|
+
*/
|
|
51
|
+
routeFiles(files: string[]): Map<AgentCapability, string[]>;
|
|
52
|
+
/**
|
|
53
|
+
* Get recommended parallel review droids for a set of files.
|
|
54
|
+
*/
|
|
55
|
+
getParallelReviewDroids(files: string[]): string[];
|
|
56
|
+
/**
|
|
57
|
+
* Match files against a glob-like pattern.
|
|
58
|
+
*/
|
|
59
|
+
private matchesPattern;
|
|
60
|
+
/**
|
|
61
|
+
* Convert glob pattern to regex.
|
|
62
|
+
*/
|
|
63
|
+
private patternToRegex;
|
|
64
|
+
/**
|
|
65
|
+
* Extract keywords from task for matching.
|
|
66
|
+
*/
|
|
67
|
+
private extractKeywords;
|
|
68
|
+
/**
|
|
69
|
+
* Add or update a capability mapping.
|
|
70
|
+
*/
|
|
71
|
+
addMapping(mapping: CapabilityMapping): void;
|
|
72
|
+
/**
|
|
73
|
+
* Get all registered mappings.
|
|
74
|
+
*/
|
|
75
|
+
getMappings(): CapabilityMapping[];
|
|
76
|
+
}
|
|
77
|
+
export declare function getCapabilityRouter(): CapabilityRouter;
|
|
78
|
+
export declare function setCapabilityRouter(router: CapabilityRouter): void;
|
|
79
|
+
//# sourceMappingURL=capability-router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-router.d.ts","sourceRoot":"","sources":["../../src/coordination/capability-router.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAExD;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,YAAY,GACZ,YAAY,GACZ,QAAQ,GACR,MAAM,GACN,IAAI,GACJ,KAAK,GACL,MAAM,GACN,KAAK,GACL,UAAU,GACV,SAAS,GACT,UAAU,GACV,UAAU,GACV,aAAa,GACb,eAAe,GACf,SAAS,GACT,QAAQ,GACR,gBAAgB,GAChB,aAAa,GACb,aAAa,CAAC;AAElB;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,eAAe,CAAC;IAC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AEG;IACH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAS5C;;OAEG;IACH,WAAW,IAAI,iBAAiB,EAAE;CAGnC;AAOD,wBAAgB,mBAAmB,IAAI,gBAAgB,CAKtD;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAElE"}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Default capability mappings for UAM droids and skills.
|
|
3
|
+
*/
|
|
4
|
+
export const DEFAULT_CAPABILITY_MAPPINGS = [
|
|
5
|
+
{
|
|
6
|
+
capability: 'typescript',
|
|
7
|
+
droids: ['typescript-node-expert', 'javascript-pro'],
|
|
8
|
+
skills: ['typescript-node-expert'],
|
|
9
|
+
filePatterns: ['*.ts', '*.tsx', '*.mts', '*.cts'],
|
|
10
|
+
taskTypes: ['task', 'feature', 'bug'],
|
|
11
|
+
priority: 10,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
capability: 'javascript',
|
|
15
|
+
droids: ['javascript-pro'],
|
|
16
|
+
skills: [],
|
|
17
|
+
filePatterns: ['*.js', '*.jsx', '*.mjs', '*.cjs'],
|
|
18
|
+
taskTypes: ['task', 'feature', 'bug'],
|
|
19
|
+
priority: 8,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
capability: 'cli',
|
|
23
|
+
droids: ['cli-design-expert'],
|
|
24
|
+
skills: ['cli-design-expert'],
|
|
25
|
+
filePatterns: ['**/cli/**', '**/bin/**', '**/commands/**'],
|
|
26
|
+
taskTypes: ['task', 'feature'],
|
|
27
|
+
priority: 9,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
capability: 'security',
|
|
31
|
+
droids: ['security-auditor', 'security-code-reviewer'],
|
|
32
|
+
skills: [],
|
|
33
|
+
filePatterns: ['**/auth/**', '**/security/**', '*.key', '*.pem'],
|
|
34
|
+
taskTypes: ['bug', 'task'],
|
|
35
|
+
priority: 10,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
capability: 'performance',
|
|
39
|
+
droids: ['performance-optimizer', 'performance-reviewer'],
|
|
40
|
+
skills: [],
|
|
41
|
+
filePatterns: ['**/perf/**', '**/benchmark/**'],
|
|
42
|
+
taskTypes: ['task', 'chore'],
|
|
43
|
+
priority: 8,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
capability: 'documentation',
|
|
47
|
+
droids: ['documentation-expert', 'documentation-accuracy-reviewer'],
|
|
48
|
+
skills: [],
|
|
49
|
+
filePatterns: ['*.md', '**/docs/**', 'README*', 'CHANGELOG*'],
|
|
50
|
+
taskTypes: ['task', 'chore'],
|
|
51
|
+
priority: 6,
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
capability: 'code-review',
|
|
55
|
+
droids: ['code-quality-guardian', 'code-quality-reviewer'],
|
|
56
|
+
skills: [],
|
|
57
|
+
filePatterns: ['*'],
|
|
58
|
+
taskTypes: ['task', 'chore'],
|
|
59
|
+
priority: 7,
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
capability: 'testing',
|
|
63
|
+
droids: ['test-coverage-reviewer', 'test-plan-writer'],
|
|
64
|
+
skills: [],
|
|
65
|
+
filePatterns: ['*.test.*', '*.spec.*', '**/tests/**', '**/__tests__/**'],
|
|
66
|
+
taskTypes: ['task', 'bug'],
|
|
67
|
+
priority: 8,
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
capability: 'infrastructure',
|
|
71
|
+
droids: [],
|
|
72
|
+
skills: [],
|
|
73
|
+
filePatterns: ['*.tf', '**/terraform/**', '**/k8s/**', '**/helm/**', 'Dockerfile*', 'docker-compose*'],
|
|
74
|
+
taskTypes: ['task', 'chore'],
|
|
75
|
+
priority: 9,
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
capability: 'python',
|
|
79
|
+
droids: ['python-pro'],
|
|
80
|
+
skills: [],
|
|
81
|
+
filePatterns: ['*.py', '**/python/**'],
|
|
82
|
+
taskTypes: ['task', 'feature', 'bug'],
|
|
83
|
+
priority: 10,
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
capability: 'rust',
|
|
87
|
+
droids: ['rust-pro'],
|
|
88
|
+
skills: [],
|
|
89
|
+
filePatterns: ['*.rs', 'Cargo.toml'],
|
|
90
|
+
taskTypes: ['task', 'feature', 'bug'],
|
|
91
|
+
priority: 10,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
capability: 'go',
|
|
95
|
+
droids: ['go-pro'],
|
|
96
|
+
skills: [],
|
|
97
|
+
filePatterns: ['*.go', 'go.mod', 'go.sum'],
|
|
98
|
+
taskTypes: ['task', 'feature', 'bug'],
|
|
99
|
+
priority: 10,
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
/**
|
|
103
|
+
* Capability-based router for intelligent task and agent routing.
|
|
104
|
+
*/
|
|
105
|
+
export class CapabilityRouter {
|
|
106
|
+
mappings;
|
|
107
|
+
constructor(customMappings) {
|
|
108
|
+
this.mappings = customMappings || DEFAULT_CAPABILITY_MAPPINGS;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Route a task to the best droids/skills based on task content and affected files.
|
|
112
|
+
*/
|
|
113
|
+
routeTask(task, affectedFiles) {
|
|
114
|
+
const matchedCapabilities = [];
|
|
115
|
+
const droidScores = new Map();
|
|
116
|
+
const skillScores = new Map();
|
|
117
|
+
const reasons = [];
|
|
118
|
+
// Match by file patterns
|
|
119
|
+
if (affectedFiles && affectedFiles.length > 0) {
|
|
120
|
+
for (const mapping of this.mappings) {
|
|
121
|
+
for (const pattern of mapping.filePatterns) {
|
|
122
|
+
const matches = this.matchesPattern(affectedFiles, pattern);
|
|
123
|
+
if (matches.length > 0) {
|
|
124
|
+
matchedCapabilities.push(mapping.capability);
|
|
125
|
+
for (const droid of mapping.droids) {
|
|
126
|
+
const current = droidScores.get(droid) || 0;
|
|
127
|
+
droidScores.set(droid, current + mapping.priority);
|
|
128
|
+
}
|
|
129
|
+
for (const skill of mapping.skills) {
|
|
130
|
+
const current = skillScores.get(skill) || 0;
|
|
131
|
+
skillScores.set(skill, current + mapping.priority);
|
|
132
|
+
}
|
|
133
|
+
reasons.push(`Files ${matches.slice(0, 2).join(', ')} match ${mapping.capability}`);
|
|
134
|
+
break; // Only count each mapping once per task
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
// Match by task type
|
|
140
|
+
for (const mapping of this.mappings) {
|
|
141
|
+
if (mapping.taskTypes.includes(task.type)) {
|
|
142
|
+
// Boost score slightly for type match
|
|
143
|
+
for (const droid of mapping.droids) {
|
|
144
|
+
const current = droidScores.get(droid) || 0;
|
|
145
|
+
droidScores.set(droid, current + 1);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
// Match by task title/labels keywords
|
|
150
|
+
const keywords = this.extractKeywords(task);
|
|
151
|
+
for (const mapping of this.mappings) {
|
|
152
|
+
if (keywords.some(kw => kw.includes(mapping.capability) || mapping.capability.includes(kw))) {
|
|
153
|
+
if (!matchedCapabilities.includes(mapping.capability)) {
|
|
154
|
+
matchedCapabilities.push(mapping.capability);
|
|
155
|
+
}
|
|
156
|
+
for (const droid of mapping.droids) {
|
|
157
|
+
const current = droidScores.get(droid) || 0;
|
|
158
|
+
droidScores.set(droid, current + mapping.priority / 2);
|
|
159
|
+
}
|
|
160
|
+
reasons.push(`Keywords match ${mapping.capability}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
// Sort by score and take top recommendations
|
|
164
|
+
const sortedDroids = [...droidScores.entries()]
|
|
165
|
+
.sort((a, b) => b[1] - a[1])
|
|
166
|
+
.map(([droid]) => droid);
|
|
167
|
+
const sortedSkills = [...skillScores.entries()]
|
|
168
|
+
.sort((a, b) => b[1] - a[1])
|
|
169
|
+
.map(([skill]) => skill);
|
|
170
|
+
// Calculate confidence
|
|
171
|
+
const maxPossibleScore = this.mappings.reduce((sum, m) => sum + m.priority, 0);
|
|
172
|
+
const actualScore = [...droidScores.values()].reduce((sum, s) => sum + s, 0);
|
|
173
|
+
const confidence = Math.min(1, actualScore / (maxPossibleScore / 2));
|
|
174
|
+
return {
|
|
175
|
+
recommendedDroids: sortedDroids.slice(0, 3),
|
|
176
|
+
recommendedSkills: sortedSkills.slice(0, 2),
|
|
177
|
+
matchedCapabilities: [...new Set(matchedCapabilities)],
|
|
178
|
+
confidence,
|
|
179
|
+
reasoning: reasons.length > 0 ? reasons.join('; ') : 'No specific matches, using general routing',
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Find the best agent for a task based on capabilities.
|
|
184
|
+
*/
|
|
185
|
+
findBestAgent(task, availableAgents, affectedFiles) {
|
|
186
|
+
if (availableAgents.length === 0)
|
|
187
|
+
return null;
|
|
188
|
+
const routing = this.routeTask(task, affectedFiles);
|
|
189
|
+
const agentMatches = [];
|
|
190
|
+
for (const agent of availableAgents) {
|
|
191
|
+
const agentCapabilities = (agent.capabilities || []);
|
|
192
|
+
const matchedCapabilities = agentCapabilities.filter(cap => routing.matchedCapabilities.includes(cap));
|
|
193
|
+
let score = matchedCapabilities.length * 10;
|
|
194
|
+
// Boost for agents with recommended droids in their name
|
|
195
|
+
if (routing.recommendedDroids.some(d => agent.name.includes(d))) {
|
|
196
|
+
score += 20;
|
|
197
|
+
}
|
|
198
|
+
// Boost for idle agents
|
|
199
|
+
if (agent.status === 'idle') {
|
|
200
|
+
score += 5;
|
|
201
|
+
}
|
|
202
|
+
// Penalty for agents with current tasks
|
|
203
|
+
if (agent.currentTask) {
|
|
204
|
+
score -= 10;
|
|
205
|
+
}
|
|
206
|
+
agentMatches.push({
|
|
207
|
+
agent,
|
|
208
|
+
matchedCapabilities,
|
|
209
|
+
score,
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
// Sort by score descending
|
|
213
|
+
agentMatches.sort((a, b) => b.score - a.score);
|
|
214
|
+
return agentMatches[0] || null;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Route files to appropriate capabilities.
|
|
218
|
+
*/
|
|
219
|
+
routeFiles(files) {
|
|
220
|
+
const result = new Map();
|
|
221
|
+
for (const mapping of this.mappings) {
|
|
222
|
+
for (const pattern of mapping.filePatterns) {
|
|
223
|
+
const matches = this.matchesPattern(files, pattern);
|
|
224
|
+
if (matches.length > 0) {
|
|
225
|
+
const existing = result.get(mapping.capability) || [];
|
|
226
|
+
result.set(mapping.capability, [...new Set([...existing, ...matches])]);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Get recommended parallel review droids for a set of files.
|
|
234
|
+
*/
|
|
235
|
+
getParallelReviewDroids(files) {
|
|
236
|
+
const routing = this.routeFiles(files);
|
|
237
|
+
const droids = new Set();
|
|
238
|
+
// Always include quality and security for any code change
|
|
239
|
+
droids.add('code-quality-guardian');
|
|
240
|
+
droids.add('security-auditor');
|
|
241
|
+
// Add capability-specific droids
|
|
242
|
+
for (const [capability] of routing) {
|
|
243
|
+
const mapping = this.mappings.find(m => m.capability === capability);
|
|
244
|
+
if (mapping) {
|
|
245
|
+
for (const droid of mapping.droids) {
|
|
246
|
+
droids.add(droid);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
// Add documentation reviewer if docs changed
|
|
251
|
+
if (routing.has('documentation')) {
|
|
252
|
+
droids.add('documentation-expert');
|
|
253
|
+
}
|
|
254
|
+
// Add performance reviewer for performance-critical areas
|
|
255
|
+
if (routing.has('performance') || routing.has('database')) {
|
|
256
|
+
droids.add('performance-optimizer');
|
|
257
|
+
}
|
|
258
|
+
return [...droids];
|
|
259
|
+
}
|
|
260
|
+
/**
|
|
261
|
+
* Match files against a glob-like pattern.
|
|
262
|
+
*/
|
|
263
|
+
matchesPattern(files, pattern) {
|
|
264
|
+
const regex = this.patternToRegex(pattern);
|
|
265
|
+
return files.filter(f => regex.test(f));
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Convert glob pattern to regex.
|
|
269
|
+
*/
|
|
270
|
+
patternToRegex(pattern) {
|
|
271
|
+
const escaped = pattern
|
|
272
|
+
.replace(/[.+^${}()|[\]\\]/g, '\\$&')
|
|
273
|
+
.replace(/\*\*/g, '{{GLOBSTAR}}')
|
|
274
|
+
.replace(/\*/g, '[^/]*')
|
|
275
|
+
.replace(/{{GLOBSTAR}}/g, '.*')
|
|
276
|
+
.replace(/\?/g, '.');
|
|
277
|
+
return new RegExp(`(^|/)${escaped}$`, 'i');
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Extract keywords from task for matching.
|
|
281
|
+
*/
|
|
282
|
+
extractKeywords(task) {
|
|
283
|
+
const keywords = [];
|
|
284
|
+
// From title
|
|
285
|
+
keywords.push(...task.title.toLowerCase().split(/\W+/).filter(w => w.length > 2));
|
|
286
|
+
// From labels
|
|
287
|
+
keywords.push(...task.labels.map(l => l.toLowerCase()));
|
|
288
|
+
// From type
|
|
289
|
+
keywords.push(task.type);
|
|
290
|
+
return keywords;
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Add or update a capability mapping.
|
|
294
|
+
*/
|
|
295
|
+
addMapping(mapping) {
|
|
296
|
+
const existingIndex = this.mappings.findIndex(m => m.capability === mapping.capability);
|
|
297
|
+
if (existingIndex >= 0) {
|
|
298
|
+
this.mappings[existingIndex] = mapping;
|
|
299
|
+
}
|
|
300
|
+
else {
|
|
301
|
+
this.mappings.push(mapping);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
/**
|
|
305
|
+
* Get all registered mappings.
|
|
306
|
+
*/
|
|
307
|
+
getMappings() {
|
|
308
|
+
return [...this.mappings];
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Singleton instance for global capability routing.
|
|
313
|
+
*/
|
|
314
|
+
let globalRouter = null;
|
|
315
|
+
export function getCapabilityRouter() {
|
|
316
|
+
if (!globalRouter) {
|
|
317
|
+
globalRouter = new CapabilityRouter();
|
|
318
|
+
}
|
|
319
|
+
return globalRouter;
|
|
320
|
+
}
|
|
321
|
+
export function setCapabilityRouter(router) {
|
|
322
|
+
globalRouter = router;
|
|
323
|
+
}
|
|
324
|
+
//# sourceMappingURL=capability-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"capability-router.js","sourceRoot":"","sources":["../../src/coordination/capability-router.ts"],"names":[],"mappings":"AAuCA;;GAEG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAwB;IAC9D;QACE,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE,CAAC,wBAAwB,EAAE,gBAAgB,CAAC;QACpD,MAAM,EAAE,CAAC,wBAAwB,CAAC;QAClC,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;QACjD,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC;QACrC,QAAQ,EAAE,EAAE;KACb;IACD;QACE,UAAU,EAAE,YAAY;QACxB,MAAM,EAAE,CAAC,gBAAgB,CAAC;QAC1B,MAAM,EAAE,EAAE;QACV,YAAY,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC;QACjD,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,KAAK,CAAC;QACrC,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,UAAU,EAAE,KAAK;QACjB,MAAM,EAAE,CAAC,mBAAmB,CAAC;QAC7B,MAAM,EAAE,CAAC,mBAAmB,CAAC;QAC7B,YAAY,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,gBAAgB,CAAC;QAC1D,SAAS,EAAE,CAAC,MAAM,EAAE,SAAS,CAAC;QAC9B,QAAQ,EAAE,CAAC;KACZ;IACD;QACE,UAAU,EAAE,UAAU;Q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AC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,mBAAmB,CAAC,MAAwB;IAC1D,YAAY,GAAG,MAAM,CAAC;AACxB,CAAC"}
|
|
@@ -1,29 +1,85 @@
|
|
|
1
1
|
import type { DeployBatch, BatchResult, DeployActionType } from '../types/coordination.js';
|
|
2
|
+
/**
|
|
3
|
+
* Dynamic batch window configuration based on action type.
|
|
4
|
+
* Optimizes for speed on time-sensitive operations while allowing
|
|
5
|
+
* batching for operations that benefit from grouping.
|
|
6
|
+
*/
|
|
7
|
+
export interface DynamicBatchWindows {
|
|
8
|
+
commit: number;
|
|
9
|
+
push: number;
|
|
10
|
+
merge: number;
|
|
11
|
+
workflow: number;
|
|
12
|
+
deploy: number;
|
|
13
|
+
}
|
|
2
14
|
export interface DeployBatcherConfig {
|
|
3
15
|
dbPath?: string;
|
|
4
16
|
batchWindowMs?: number;
|
|
17
|
+
dynamicWindows?: Partial<DynamicBatchWindows>;
|
|
5
18
|
maxBatchSize?: number;
|
|
6
19
|
dryRun?: boolean;
|
|
20
|
+
parallelExecution?: boolean;
|
|
21
|
+
maxParallelActions?: number;
|
|
7
22
|
}
|
|
8
23
|
export declare class DeployBatcher {
|
|
9
24
|
private db;
|
|
10
|
-
private
|
|
25
|
+
private dynamicWindows;
|
|
11
26
|
private maxBatchSize;
|
|
12
27
|
private dryRun;
|
|
28
|
+
private parallelExecution;
|
|
29
|
+
private maxParallelActions;
|
|
13
30
|
constructor(config?: DeployBatcherConfig);
|
|
31
|
+
/**
|
|
32
|
+
* Get the batch window for a specific action type.
|
|
33
|
+
*/
|
|
34
|
+
getBatchWindow(actionType: DeployActionType): number;
|
|
35
|
+
/**
|
|
36
|
+
* Update batch windows dynamically (useful for urgent operations).
|
|
37
|
+
*/
|
|
38
|
+
setUrgentMode(urgent: boolean): void;
|
|
39
|
+
/**
|
|
40
|
+
* Queue a deploy action with type-specific batching delay.
|
|
41
|
+
*/
|
|
14
42
|
queue(agentId: string, actionType: DeployActionType, target: string, payload?: Record<string, unknown>, options?: {
|
|
15
43
|
priority?: number;
|
|
16
44
|
dependencies?: string[];
|
|
45
|
+
urgent?: boolean;
|
|
17
46
|
}): Promise<number>;
|
|
47
|
+
/**
|
|
48
|
+
* Queue multiple actions atomically with optimized windows.
|
|
49
|
+
*/
|
|
50
|
+
queueBulk(agentId: string, actions: Array<{
|
|
51
|
+
actionType: DeployActionType;
|
|
52
|
+
target: string;
|
|
53
|
+
payload?: Record<string, unknown>;
|
|
54
|
+
priority?: number;
|
|
55
|
+
}>): Promise<number[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Synchronous queue for use in transactions.
|
|
58
|
+
*/
|
|
59
|
+
private queueSync;
|
|
18
60
|
private findSimilarAction;
|
|
19
61
|
private canMerge;
|
|
20
62
|
private mergeActions;
|
|
21
63
|
private mergePayloads;
|
|
64
|
+
/**
|
|
65
|
+
* Create a batch from ready actions.
|
|
66
|
+
*/
|
|
22
67
|
createBatch(): Promise<DeployBatch | null>;
|
|
23
68
|
private groupByTarget;
|
|
24
69
|
private squashActions;
|
|
25
70
|
private squashCommits;
|
|
71
|
+
/**
|
|
72
|
+
* Execute a batch with optional parallel execution for independent actions.
|
|
73
|
+
*/
|
|
26
74
|
executeBatch(batchId: string): Promise<BatchResult>;
|
|
75
|
+
/**
|
|
76
|
+
* Categorize actions into parallel-safe and sequential groups.
|
|
77
|
+
*/
|
|
78
|
+
private categorizeActions;
|
|
79
|
+
/**
|
|
80
|
+
* Execute actions in parallel with concurrency limit.
|
|
81
|
+
*/
|
|
82
|
+
private executeParallel;
|
|
27
83
|
private executeAction;
|
|
28
84
|
private executeCommit;
|
|
29
85
|
private executePush;
|
|
@@ -33,6 +89,13 @@ export declare class DeployBatcher {
|
|
|
33
89
|
private updateActionStatus;
|
|
34
90
|
getBatch(batchId: string): DeployBatch | null;
|
|
35
91
|
getPendingBatches(): DeployBatch[];
|
|
92
|
+
/**
|
|
93
|
+
* Force flush all pending deploys immediately.
|
|
94
|
+
*/
|
|
36
95
|
flushAll(): Promise<BatchResult[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Get current batch window configuration.
|
|
98
|
+
*/
|
|
99
|
+
getWindowConfig(): DynamicBatchWindows;
|
|
37
100
|
}
|
|
38
101
|
//# sourceMappingURL=deploy-batcher.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy-batcher.d.ts","sourceRoot":"","sources":["../../src/coordination/deploy-batcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAGvH,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy-batcher.d.ts","sourceRoot":"","sources":["../../src/coordination/deploy-batcher.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAgB,MAAM,0BAA0B,CAAC;AAGvH;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC9C,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kBAAkB,CAAC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