@nahisaho/musubix-agent-orchestrator 2.4.1
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/application/ContextManager.d.ts +90 -0
- package/dist/application/ContextManager.d.ts.map +1 -0
- package/dist/application/ContextManager.js +130 -0
- package/dist/application/ContextManager.js.map +1 -0
- package/dist/application/ParallelExecutor.d.ts +65 -0
- package/dist/application/ParallelExecutor.d.ts.map +1 -0
- package/dist/application/ParallelExecutor.js +149 -0
- package/dist/application/ParallelExecutor.js.map +1 -0
- package/dist/application/ResultAggregator.d.ts +107 -0
- package/dist/application/ResultAggregator.d.ts.map +1 -0
- package/dist/application/ResultAggregator.js +142 -0
- package/dist/application/ResultAggregator.js.map +1 -0
- package/dist/application/SubagentDispatcher.d.ts +80 -0
- package/dist/application/SubagentDispatcher.d.ts.map +1 -0
- package/dist/application/SubagentDispatcher.js +199 -0
- package/dist/application/SubagentDispatcher.js.map +1 -0
- package/dist/application/index.d.ts +8 -0
- package/dist/application/index.d.ts.map +1 -0
- package/dist/application/index.js +8 -0
- package/dist/application/index.js.map +1 -0
- package/dist/domain/entities/Artifact.d.ts +66 -0
- package/dist/domain/entities/Artifact.d.ts.map +1 -0
- package/dist/domain/entities/Artifact.js +58 -0
- package/dist/domain/entities/Artifact.js.map +1 -0
- package/dist/domain/entities/ExecutionContext.d.ts +79 -0
- package/dist/domain/entities/ExecutionContext.d.ts.map +1 -0
- package/dist/domain/entities/ExecutionContext.js +75 -0
- package/dist/domain/entities/ExecutionContext.js.map +1 -0
- package/dist/domain/entities/SubagentSpec.d.ts +100 -0
- package/dist/domain/entities/SubagentSpec.d.ts.map +1 -0
- package/dist/domain/entities/SubagentSpec.js +58 -0
- package/dist/domain/entities/SubagentSpec.js.map +1 -0
- package/dist/domain/entities/Task.d.ts +72 -0
- package/dist/domain/entities/Task.d.ts.map +1 -0
- package/dist/domain/entities/Task.js +41 -0
- package/dist/domain/entities/Task.js.map +1 -0
- package/dist/domain/entities/index.d.ts +8 -0
- package/dist/domain/entities/index.d.ts.map +1 -0
- package/dist/domain/entities/index.js +8 -0
- package/dist/domain/entities/index.js.map +1 -0
- package/dist/domain/index.d.ts +7 -0
- package/dist/domain/index.d.ts.map +1 -0
- package/dist/domain/index.js +7 -0
- package/dist/domain/index.js.map +1 -0
- package/dist/domain/services/ComplexityAnalyzer.d.ts +67 -0
- package/dist/domain/services/ComplexityAnalyzer.d.ts.map +1 -0
- package/dist/domain/services/ComplexityAnalyzer.js +129 -0
- package/dist/domain/services/ComplexityAnalyzer.js.map +1 -0
- package/dist/domain/services/DependencyAnalyzer.d.ts +69 -0
- package/dist/domain/services/DependencyAnalyzer.d.ts.map +1 -0
- package/dist/domain/services/DependencyAnalyzer.js +147 -0
- package/dist/domain/services/DependencyAnalyzer.js.map +1 -0
- package/dist/domain/services/index.d.ts +6 -0
- package/dist/domain/services/index.d.ts.map +1 -0
- package/dist/domain/services/index.js +6 -0
- package/dist/domain/services/index.js.map +1 -0
- package/dist/domain/value-objects/AgentRole.d.ts +53 -0
- package/dist/domain/value-objects/AgentRole.d.ts.map +1 -0
- package/dist/domain/value-objects/AgentRole.js +78 -0
- package/dist/domain/value-objects/AgentRole.js.map +1 -0
- package/dist/domain/value-objects/ComplexityFactor.d.ts +47 -0
- package/dist/domain/value-objects/ComplexityFactor.d.ts.map +1 -0
- package/dist/domain/value-objects/ComplexityFactor.js +53 -0
- package/dist/domain/value-objects/ComplexityFactor.js.map +1 -0
- package/dist/domain/value-objects/ComplexityScore.d.ts +44 -0
- package/dist/domain/value-objects/ComplexityScore.d.ts.map +1 -0
- package/dist/domain/value-objects/ComplexityScore.js +56 -0
- package/dist/domain/value-objects/ComplexityScore.js.map +1 -0
- package/dist/domain/value-objects/TaskPriority.d.ts +42 -0
- package/dist/domain/value-objects/TaskPriority.d.ts.map +1 -0
- package/dist/domain/value-objects/TaskPriority.js +39 -0
- package/dist/domain/value-objects/TaskPriority.js.map +1 -0
- package/dist/domain/value-objects/index.d.ts +8 -0
- package/dist/domain/value-objects/index.d.ts.map +1 -0
- package/dist/domain/value-objects/index.js +8 -0
- package/dist/domain/value-objects/index.js.map +1 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +37 -0
- package/dist/index.js.map +1 -0
- package/dist/infrastructure/SubagentAdapter.d.ts +40 -0
- package/dist/infrastructure/SubagentAdapter.d.ts.map +1 -0
- package/dist/infrastructure/SubagentAdapter.js +68 -0
- package/dist/infrastructure/SubagentAdapter.js.map +1 -0
- package/dist/infrastructure/YATAContextStore.d.ts +52 -0
- package/dist/infrastructure/YATAContextStore.d.ts.map +1 -0
- package/dist/infrastructure/YATAContextStore.js +87 -0
- package/dist/infrastructure/YATAContextStore.js.map +1 -0
- package/dist/infrastructure/index.d.ts +6 -0
- package/dist/infrastructure/index.d.ts.map +1 -0
- package/dist/infrastructure/index.js +6 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ResultAggregator Application Service
|
|
3
|
+
*
|
|
4
|
+
* Aggregates results from multiple subagents
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-PAD-003 - Result Aggregation
|
|
7
|
+
* @see DES-PAD-003 - ResultAggregator
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Create a result aggregator
|
|
11
|
+
*
|
|
12
|
+
* @param config - Optional configuration
|
|
13
|
+
* @returns IResultAggregator implementation
|
|
14
|
+
*/
|
|
15
|
+
export function createResultAggregator(config = {}) {
|
|
16
|
+
const enableConflictDetection = config.detectConflicts ?? true;
|
|
17
|
+
const contentSeparator = config.contentSeparator ?? '\n\n---\n\n';
|
|
18
|
+
/**
|
|
19
|
+
* Detect file conflicts
|
|
20
|
+
*/
|
|
21
|
+
function detectFileConflicts(results) {
|
|
22
|
+
const conflicts = [];
|
|
23
|
+
const fileMap = new Map();
|
|
24
|
+
// Group artifacts by file path
|
|
25
|
+
for (const result of results) {
|
|
26
|
+
if (!result.success)
|
|
27
|
+
continue;
|
|
28
|
+
for (const artifact of result.artifacts) {
|
|
29
|
+
const existing = fileMap.get(artifact.path) ?? [];
|
|
30
|
+
existing.push({ specId: result.specId, content: artifact.content });
|
|
31
|
+
fileMap.set(artifact.path, existing);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
// Check for conflicts
|
|
35
|
+
for (const [path, entries] of fileMap) {
|
|
36
|
+
if (entries.length > 1) {
|
|
37
|
+
// Check if contents differ
|
|
38
|
+
const contents = new Set(entries.map((e) => e.content));
|
|
39
|
+
if (contents.size > 1) {
|
|
40
|
+
conflicts.push({
|
|
41
|
+
specIds: entries.map((e) => e.specId),
|
|
42
|
+
filePath: path,
|
|
43
|
+
type: 'file',
|
|
44
|
+
description: `Multiple specs produced different content for ${path}`,
|
|
45
|
+
autoResolvable: false,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return conflicts;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Combine content from results
|
|
54
|
+
*/
|
|
55
|
+
function combineContent(results) {
|
|
56
|
+
return results
|
|
57
|
+
.filter((r) => r.success && r.content)
|
|
58
|
+
.map((r) => `## ${r.specId}\n\n${r.content}`)
|
|
59
|
+
.join(contentSeparator);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Calculate statistics
|
|
63
|
+
*/
|
|
64
|
+
function calculateStats(results, artifacts, conflicts) {
|
|
65
|
+
const succeeded = results.filter((r) => r.success).length;
|
|
66
|
+
const failed = results.length - succeeded;
|
|
67
|
+
const totalDurationMs = results.reduce((sum, r) => sum + r.durationMs, 0);
|
|
68
|
+
const averageDurationMs = results.length > 0 ? Math.round(totalDurationMs / results.length) : 0;
|
|
69
|
+
return {
|
|
70
|
+
totalSpecs: results.length,
|
|
71
|
+
succeeded,
|
|
72
|
+
failed,
|
|
73
|
+
totalDurationMs,
|
|
74
|
+
averageDurationMs,
|
|
75
|
+
artifactCount: artifacts.length,
|
|
76
|
+
conflictCount: conflicts.length,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
aggregate(results) {
|
|
81
|
+
const failures = results.filter((r) => !r.success);
|
|
82
|
+
const success = failures.length === 0;
|
|
83
|
+
const combinedContent = combineContent(results);
|
|
84
|
+
const artifacts = this.mergeArtifacts(results);
|
|
85
|
+
const conflicts = enableConflictDetection
|
|
86
|
+
? this.detectConflicts(results)
|
|
87
|
+
: [];
|
|
88
|
+
const stats = calculateStats(results, artifacts, conflicts);
|
|
89
|
+
return Object.freeze({
|
|
90
|
+
results: Object.freeze([...results]),
|
|
91
|
+
success: success && conflicts.length === 0,
|
|
92
|
+
combinedContent,
|
|
93
|
+
artifacts: Object.freeze(artifacts),
|
|
94
|
+
conflicts: Object.freeze(conflicts),
|
|
95
|
+
failures: Object.freeze(failures),
|
|
96
|
+
stats: Object.freeze(stats),
|
|
97
|
+
});
|
|
98
|
+
},
|
|
99
|
+
detectConflicts(results) {
|
|
100
|
+
return detectFileConflicts(results);
|
|
101
|
+
},
|
|
102
|
+
mergeArtifacts(results) {
|
|
103
|
+
const artifactMap = new Map();
|
|
104
|
+
for (const result of results) {
|
|
105
|
+
if (!result.success)
|
|
106
|
+
continue;
|
|
107
|
+
for (const artifact of result.artifacts) {
|
|
108
|
+
// Use path as key, later results override earlier ones
|
|
109
|
+
artifactMap.set(artifact.path, artifact);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return Array.from(artifactMap.values());
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Default conflict resolver - use latest artifact
|
|
118
|
+
*/
|
|
119
|
+
export const latestArtifactResolver = (conflict, artifacts) => {
|
|
120
|
+
const conflicting = artifacts.filter((a) => a.path === conflict.filePath);
|
|
121
|
+
return conflicting.length > 0 ? conflicting[conflicting.length - 1] : null;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Merge resolver - attempt to merge content
|
|
125
|
+
*/
|
|
126
|
+
export const mergeResolver = (conflict, artifacts) => {
|
|
127
|
+
if (conflict.type !== 'file') {
|
|
128
|
+
return latestArtifactResolver(conflict, artifacts);
|
|
129
|
+
}
|
|
130
|
+
const conflicting = artifacts.filter((a) => a.path === conflict.filePath);
|
|
131
|
+
if (conflicting.length === 0)
|
|
132
|
+
return null;
|
|
133
|
+
// Simple merge: concatenate with markers
|
|
134
|
+
const mergedContent = conflicting
|
|
135
|
+
.map((a) => `// === From spec ===\n${a.content}`)
|
|
136
|
+
.join('\n\n');
|
|
137
|
+
return {
|
|
138
|
+
...conflicting[0],
|
|
139
|
+
content: mergedContent,
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
//# sourceMappingURL=ResultAggregator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultAggregator.js","sourceRoot":"","sources":["../../src/application/ResultAggregator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAyFH;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAiC,EAAE;IAEnC,MAAM,uBAAuB,GAAG,MAAM,CAAC,eAAe,IAAI,IAAI,CAAC;IAC/D,MAAM,gBAAgB,GAAG,MAAM,CAAC,gBAAgB,IAAI,aAAa,CAAC;IAElE;;OAEG;IACH,SAAS,mBAAmB,CAAC,OAAyB;QACpD,MAAM,SAAS,GAAmB,EAAE,CAAC;QACrC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAiD,CAAC;QAEzE,+BAA+B;QAC/B,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC7B,IAAI,CAAC,MAAM,CAAC,OAAO;gBAAE,SAAS;YAE9B,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE,CAAC;gBACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAA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AAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1E,OAAO,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AAC7E,CAAC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,aAAa,GAAqB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE;IACrE,IAAI,QAAQ,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAC7B,OAAO,sBAAsB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IACrD,CAAC;IAED,MAAM,WAAW,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC1E,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAE1C,yCAAyC;IACzC,MAAM,aAAa,GAAG,WAAW;SAC9B,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,yBAAyB,CAAC,CAAC,OAAO,EAAE,CAAC;SAChD,IAAI,CAAC,MAAM,CAAC,CAAC;IAEhB,OAAO;QACL,GAAG,WAAW,CAAC,CAAC,CAAC;QACjB,OAAO,EAAE,aAAa;KACvB,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentDispatcher Application Service
|
|
3
|
+
*
|
|
4
|
+
* Dispatches tasks to specialized subagents
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-SDD-002 - Subagent Decomposition
|
|
7
|
+
* @see DES-SDD-002 - SubagentDispatcher
|
|
8
|
+
*/
|
|
9
|
+
import type { Task } from '../domain/entities/Task.js';
|
|
10
|
+
import type { ExecutionContext } from '../domain/entities/ExecutionContext.js';
|
|
11
|
+
import { type SubagentSpec, type SubagentResult } from '../domain/entities/SubagentSpec.js';
|
|
12
|
+
import { type AgentRole, type AgentRoleName } from '../domain/value-objects/AgentRole.js';
|
|
13
|
+
import type { ComplexityScore } from '../domain/value-objects/ComplexityScore.js';
|
|
14
|
+
/**
|
|
15
|
+
* Subagent dispatcher interface
|
|
16
|
+
*/
|
|
17
|
+
export interface ISubagentDispatcher {
|
|
18
|
+
/**
|
|
19
|
+
* Decompose task into subagent specs
|
|
20
|
+
* @param task - Task to decompose
|
|
21
|
+
* @param score - Complexity score
|
|
22
|
+
* @param context - Execution context
|
|
23
|
+
* @returns Subagent specifications
|
|
24
|
+
*/
|
|
25
|
+
decompose(task: Task, score: ComplexityScore, context: ExecutionContext): SubagentSpec[];
|
|
26
|
+
/**
|
|
27
|
+
* Generate prompt for a role
|
|
28
|
+
* @param role - Agent role
|
|
29
|
+
* @param task - Task to execute
|
|
30
|
+
* @param context - Execution context
|
|
31
|
+
* @returns Generated prompt
|
|
32
|
+
*/
|
|
33
|
+
generatePrompt(role: AgentRole, task: Task, context: ExecutionContext): string;
|
|
34
|
+
/**
|
|
35
|
+
* Get available roles
|
|
36
|
+
* @returns All available role names
|
|
37
|
+
*/
|
|
38
|
+
getAvailableRoles(): AgentRoleName[];
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Aggregated result from multiple subagents
|
|
42
|
+
*/
|
|
43
|
+
export interface AggregatedResult {
|
|
44
|
+
/** All results */
|
|
45
|
+
readonly results: readonly SubagentResult[];
|
|
46
|
+
/** Success status (all succeeded) */
|
|
47
|
+
readonly success: boolean;
|
|
48
|
+
/** Combined content */
|
|
49
|
+
readonly combinedContent: string;
|
|
50
|
+
/** Failed results */
|
|
51
|
+
readonly failures: readonly SubagentResult[];
|
|
52
|
+
/** Total duration */
|
|
53
|
+
readonly totalDurationMs: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Dispatcher configuration
|
|
57
|
+
*/
|
|
58
|
+
export interface SubagentDispatcherConfig {
|
|
59
|
+
/** Default timeout per subagent (ms) */
|
|
60
|
+
defaultTimeoutMs?: number;
|
|
61
|
+
/** Role selection strategy */
|
|
62
|
+
roleStrategy?: 'all' | 'minimal' | 'custom';
|
|
63
|
+
/** Custom roles to use (if roleStrategy is 'custom') */
|
|
64
|
+
customRoles?: AgentRoleName[];
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a subagent dispatcher
|
|
68
|
+
*
|
|
69
|
+
* @param config - Optional configuration
|
|
70
|
+
* @returns ISubagentDispatcher implementation
|
|
71
|
+
*/
|
|
72
|
+
export declare function createSubagentDispatcher(config?: SubagentDispatcherConfig): ISubagentDispatcher;
|
|
73
|
+
/**
|
|
74
|
+
* Aggregate results from multiple subagents
|
|
75
|
+
*
|
|
76
|
+
* @param results - Subagent results
|
|
77
|
+
* @returns Aggregated result
|
|
78
|
+
*/
|
|
79
|
+
export declare function aggregateResults(results: SubagentResult[]): AggregatedResult;
|
|
80
|
+
//# sourceMappingURL=SubagentDispatcher.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubagentDispatcher.d.ts","sourceRoot":"","sources":["../../src/application/SubagentDispatcher.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,4BAA4B,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC/E,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,cAAc,EAEpB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,KAAK,SAAS,EACd,KAAK,aAAa,EAGnB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAElF;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;;OAMG;IACH,SAAS,CACP,IAAI,EAAE,IAAI,EACV,KAAK,EAAE,eAAe,EACtB,OAAO,EAAE,gBAAgB,GACxB,YAAY,EAAE,CAAC;IAElB;;;;;;OAMG;IACH,cAAc,CACZ,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,IAAI,EACV,OAAO,EAAE,gBAAgB,GACxB,MAAM,CAAC;IAEV;;;OAGG;IACH,iBAAiB,IAAI,aAAa,EAAE,CAAC;CACtC;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,kBAAkB;IAClB,QAAQ,CAAC,OAAO,EAAE,SAAS,cAAc,EAAE,CAAC;IAC5C,qCAAqC;IACrC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,uBAAuB;IACvB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IACjC,qBAAqB;IACrB,QAAQ,CAAC,QAAQ,EAAE,SAAS,cAAc,EAAE,CAAC;IAC7C,qBAAqB;IACrB,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;CAClC;AAED;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,wCAAwC;IACxC,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,8BAA8B;IAC9B,YAAY,CAAC,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,CAAC;IAC5C,wDAAwD;IACxD,WAAW,CAAC,EAAE,aAAa,EAAE,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,GAAE,wBAA6B,GACpC,mBAAmB,CAsKrB;AAsBD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,cAAc,EAAE,GAAG,gBAAgB,CAiB5E"}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SubagentDispatcher Application Service
|
|
3
|
+
*
|
|
4
|
+
* Dispatches tasks to specialized subagents
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-SDD-002 - Subagent Decomposition
|
|
7
|
+
* @see DES-SDD-002 - SubagentDispatcher
|
|
8
|
+
*/
|
|
9
|
+
import { createSubagentSpec, } from '../domain/entities/SubagentSpec.js';
|
|
10
|
+
import { getAgentRole, getAllRoleNames, } from '../domain/value-objects/AgentRole.js';
|
|
11
|
+
/**
|
|
12
|
+
* Create a subagent dispatcher
|
|
13
|
+
*
|
|
14
|
+
* @param config - Optional configuration
|
|
15
|
+
* @returns ISubagentDispatcher implementation
|
|
16
|
+
*/
|
|
17
|
+
export function createSubagentDispatcher(config = {}) {
|
|
18
|
+
const defaultTimeoutMs = config.defaultTimeoutMs ?? 300000; // 5 minutes
|
|
19
|
+
const roleStrategy = config.roleStrategy ?? 'minimal';
|
|
20
|
+
/**
|
|
21
|
+
* Select roles based on task and strategy
|
|
22
|
+
*/
|
|
23
|
+
function selectRoles(task, _score) {
|
|
24
|
+
if (roleStrategy === 'custom' && config.customRoles) {
|
|
25
|
+
return config.customRoles;
|
|
26
|
+
}
|
|
27
|
+
if (roleStrategy === 'all') {
|
|
28
|
+
return getAllRoleNames();
|
|
29
|
+
}
|
|
30
|
+
// Minimal strategy: select based on task properties
|
|
31
|
+
const roles = [];
|
|
32
|
+
// Always need implementation
|
|
33
|
+
roles.push('implementation');
|
|
34
|
+
// Need tests if coverage required
|
|
35
|
+
if (task.testCoverageRequired > 0) {
|
|
36
|
+
roles.push('test');
|
|
37
|
+
}
|
|
38
|
+
// Need design if complex or has many dependencies
|
|
39
|
+
if (task.dependencyCount > 3 || task.estimatedScope > 3) {
|
|
40
|
+
roles.push('design');
|
|
41
|
+
}
|
|
42
|
+
// Need requirements if related requirements exist
|
|
43
|
+
if (task.relatedRequirements.length > 0) {
|
|
44
|
+
roles.push('requirements');
|
|
45
|
+
}
|
|
46
|
+
// Need review for high complexity
|
|
47
|
+
if (task.uncertaintyLevel > 5) {
|
|
48
|
+
roles.push('review');
|
|
49
|
+
}
|
|
50
|
+
return roles;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Generate spec ID
|
|
54
|
+
*/
|
|
55
|
+
function generateSpecId(taskId, role, index) {
|
|
56
|
+
return `${taskId}-${role}-${index.toString().padStart(3, '0')}`;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Determine dependencies between roles
|
|
60
|
+
*/
|
|
61
|
+
function getRoleDependencies(role, allRoles) {
|
|
62
|
+
const deps = [];
|
|
63
|
+
switch (role) {
|
|
64
|
+
case 'design':
|
|
65
|
+
if (allRoles.includes('requirements'))
|
|
66
|
+
deps.push('requirements');
|
|
67
|
+
break;
|
|
68
|
+
case 'implementation':
|
|
69
|
+
if (allRoles.includes('design'))
|
|
70
|
+
deps.push('design');
|
|
71
|
+
else if (allRoles.includes('requirements'))
|
|
72
|
+
deps.push('requirements');
|
|
73
|
+
break;
|
|
74
|
+
case 'test':
|
|
75
|
+
if (allRoles.includes('implementation'))
|
|
76
|
+
deps.push('implementation');
|
|
77
|
+
break;
|
|
78
|
+
case 'review':
|
|
79
|
+
if (allRoles.includes('implementation'))
|
|
80
|
+
deps.push('implementation');
|
|
81
|
+
if (allRoles.includes('test'))
|
|
82
|
+
deps.push('test');
|
|
83
|
+
break;
|
|
84
|
+
}
|
|
85
|
+
return deps;
|
|
86
|
+
}
|
|
87
|
+
return {
|
|
88
|
+
decompose(task, score, context) {
|
|
89
|
+
const selectedRoles = selectRoles(task, score);
|
|
90
|
+
const specs = [];
|
|
91
|
+
const specIdMap = new Map();
|
|
92
|
+
// First pass: create specs and map IDs
|
|
93
|
+
selectedRoles.forEach((roleName, idx) => {
|
|
94
|
+
const specId = generateSpecId(task.id, roleName, idx);
|
|
95
|
+
specIdMap.set(roleName, specId);
|
|
96
|
+
});
|
|
97
|
+
// Second pass: create specs with dependencies
|
|
98
|
+
selectedRoles.forEach((roleName) => {
|
|
99
|
+
const role = getAgentRole(roleName);
|
|
100
|
+
if (!role)
|
|
101
|
+
return;
|
|
102
|
+
const specId = specIdMap.get(roleName);
|
|
103
|
+
const prompt = this.generatePrompt(role, task, context);
|
|
104
|
+
// Map role dependencies to spec IDs
|
|
105
|
+
const roleDeps = getRoleDependencies(roleName, selectedRoles);
|
|
106
|
+
const dependencies = roleDeps
|
|
107
|
+
.map((depRole) => specIdMap.get(depRole))
|
|
108
|
+
.filter((id) => id !== undefined);
|
|
109
|
+
specs.push(createSubagentSpec({
|
|
110
|
+
id: specId,
|
|
111
|
+
role,
|
|
112
|
+
prompt,
|
|
113
|
+
inputContext: context,
|
|
114
|
+
outputExpectation: getOutputExpectation(roleName),
|
|
115
|
+
timeoutMs: defaultTimeoutMs,
|
|
116
|
+
dependencies,
|
|
117
|
+
}));
|
|
118
|
+
});
|
|
119
|
+
return specs;
|
|
120
|
+
},
|
|
121
|
+
generatePrompt(role, task, context) {
|
|
122
|
+
const basePrompt = `
|
|
123
|
+
## Task Information
|
|
124
|
+
- **ID**: ${task.id}
|
|
125
|
+
- **Title**: ${task.title}
|
|
126
|
+
- **Description**: ${task.description}
|
|
127
|
+
- **Priority**: ${task.priority.label}
|
|
128
|
+
|
|
129
|
+
## Your Role: ${role.name}
|
|
130
|
+
${role.description}
|
|
131
|
+
|
|
132
|
+
### Capabilities
|
|
133
|
+
${role.capabilities.map((c) => `- ${c}`).join('\n')}
|
|
134
|
+
|
|
135
|
+
### Constraints
|
|
136
|
+
${role.constraints.map((c) => `- ${c}`).join('\n')}
|
|
137
|
+
|
|
138
|
+
## Context
|
|
139
|
+
- Project Path: ${context.metadata.projectPath ?? 'Not specified'}
|
|
140
|
+
- Related Files: ${context.metadata.relatedFiles.join(', ') || 'None'}
|
|
141
|
+
- Tags: ${context.metadata.tags.join(', ') || 'None'}
|
|
142
|
+
|
|
143
|
+
## Related Traceability
|
|
144
|
+
- Requirements: ${task.relatedRequirements.join(', ') || 'None'}
|
|
145
|
+
- Designs: ${task.relatedDesigns.join(', ') || 'None'}
|
|
146
|
+
|
|
147
|
+
## Instructions
|
|
148
|
+
Please execute your role for this task following the capabilities and constraints above.
|
|
149
|
+
Ensure all outputs include appropriate traceability IDs.
|
|
150
|
+
`;
|
|
151
|
+
return basePrompt.trim();
|
|
152
|
+
},
|
|
153
|
+
getAvailableRoles() {
|
|
154
|
+
return getAllRoleNames();
|
|
155
|
+
},
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get expected output description for a role
|
|
160
|
+
*/
|
|
161
|
+
function getOutputExpectation(role) {
|
|
162
|
+
switch (role) {
|
|
163
|
+
case 'requirements':
|
|
164
|
+
return 'EARS-format requirements with REQ-* IDs';
|
|
165
|
+
case 'design':
|
|
166
|
+
return 'C4 model design with DES-* IDs';
|
|
167
|
+
case 'implementation':
|
|
168
|
+
return 'TypeScript code with traceability comments';
|
|
169
|
+
case 'test':
|
|
170
|
+
return 'Vitest test files with 80%+ coverage';
|
|
171
|
+
case 'review':
|
|
172
|
+
return 'Review report with findings and recommendations';
|
|
173
|
+
default:
|
|
174
|
+
return 'Task output';
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Aggregate results from multiple subagents
|
|
179
|
+
*
|
|
180
|
+
* @param results - Subagent results
|
|
181
|
+
* @returns Aggregated result
|
|
182
|
+
*/
|
|
183
|
+
export function aggregateResults(results) {
|
|
184
|
+
const failures = results.filter((r) => !r.success);
|
|
185
|
+
const success = failures.length === 0;
|
|
186
|
+
const totalDurationMs = results.reduce((sum, r) => sum + r.durationMs, 0);
|
|
187
|
+
const combinedContent = results
|
|
188
|
+
.filter((r) => r.success)
|
|
189
|
+
.map((r) => `## ${r.specId}\n\n${r.content}`)
|
|
190
|
+
.join('\n\n---\n\n');
|
|
191
|
+
return Object.freeze({
|
|
192
|
+
results: Object.freeze([...results]),
|
|
193
|
+
success,
|
|
194
|
+
combinedContent,
|
|
195
|
+
failures: Object.freeze(failures),
|
|
196
|
+
totalDurationMs,
|
|
197
|
+
});
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=SubagentDispatcher.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SubagentDispatcher.js","sour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application/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/application/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,yBAAyB,CAAC;AACxC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents an artifact produced during task execution
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-SDD-003 - Context Sharing
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Artifact type
|
|
10
|
+
*/
|
|
11
|
+
export type ArtifactType = 'requirement' | 'design' | 'code' | 'test' | 'document' | 'config';
|
|
12
|
+
/**
|
|
13
|
+
* Artifact entity
|
|
14
|
+
*/
|
|
15
|
+
export interface Artifact {
|
|
16
|
+
/** Unique artifact identifier */
|
|
17
|
+
readonly id: string;
|
|
18
|
+
/** Artifact type */
|
|
19
|
+
readonly type: ArtifactType;
|
|
20
|
+
/** File path (relative to project root) */
|
|
21
|
+
readonly path: string;
|
|
22
|
+
/** Artifact content */
|
|
23
|
+
readonly content: string;
|
|
24
|
+
/** Content hash for change detection */
|
|
25
|
+
readonly contentHash: string;
|
|
26
|
+
/** Producer (task or agent ID) */
|
|
27
|
+
readonly producerId: string;
|
|
28
|
+
/** Created timestamp */
|
|
29
|
+
readonly createdAt: Date;
|
|
30
|
+
/** Traceability IDs */
|
|
31
|
+
readonly traceabilityIds: readonly string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Artifact creation input
|
|
35
|
+
*/
|
|
36
|
+
export interface CreateArtifactInput {
|
|
37
|
+
id: string;
|
|
38
|
+
type: ArtifactType;
|
|
39
|
+
path: string;
|
|
40
|
+
content: string;
|
|
41
|
+
producerId: string;
|
|
42
|
+
traceabilityIds?: string[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Create an Artifact entity
|
|
46
|
+
*
|
|
47
|
+
* @param input - Creation input
|
|
48
|
+
* @returns Artifact entity
|
|
49
|
+
*/
|
|
50
|
+
export declare function createArtifact(input: CreateArtifactInput): Artifact;
|
|
51
|
+
/**
|
|
52
|
+
* Check if artifact has changed
|
|
53
|
+
*
|
|
54
|
+
* @param artifact - Artifact to check
|
|
55
|
+
* @param newContent - New content to compare
|
|
56
|
+
* @returns true if content has changed
|
|
57
|
+
*/
|
|
58
|
+
export declare function hasArtifactChanged(artifact: Artifact, newContent: string): boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Get artifact extension
|
|
61
|
+
*
|
|
62
|
+
* @param artifact - Artifact
|
|
63
|
+
* @returns File extension
|
|
64
|
+
*/
|
|
65
|
+
export declare function getArtifactExtension(artifact: Artifact): string;
|
|
66
|
+
//# sourceMappingURL=Artifact.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Artifact.d.ts","sourceRoot":"","sources":["../../../src/domain/entities/Artifact.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GACpB,aAAa,GACb,QAAQ,GACR,MAAM,GACN,MAAM,GACN,UAAU,GACV,QAAQ,CAAC;AAEb;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,iCAAiC;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,oBAAoB;IACpB,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,2CAA2C;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,uBAAuB;IACvB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,wCAAwC;IACxC,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,kCAAkC;IAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,wBAAwB;IACxB,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC;IACzB,uBAAuB;IACvB,QAAQ,CAAC,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAeD;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,mBAAmB,GAAG,QAAQ,CAWnE;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAElF;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,GAAG,MAAM,CAG/D"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Artifact Entity
|
|
3
|
+
*
|
|
4
|
+
* Represents an artifact produced during task execution
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-SDD-003 - Context Sharing
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Simple hash function for content
|
|
10
|
+
*/
|
|
11
|
+
function simpleHash(content) {
|
|
12
|
+
let hash = 0;
|
|
13
|
+
for (let i = 0; i < content.length; i++) {
|
|
14
|
+
const char = content.charCodeAt(i);
|
|
15
|
+
hash = ((hash << 5) - hash) + char;
|
|
16
|
+
hash = hash & hash; // Convert to 32bit integer
|
|
17
|
+
}
|
|
18
|
+
return Math.abs(hash).toString(16).padStart(8, '0');
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Create an Artifact entity
|
|
22
|
+
*
|
|
23
|
+
* @param input - Creation input
|
|
24
|
+
* @returns Artifact entity
|
|
25
|
+
*/
|
|
26
|
+
export function createArtifact(input) {
|
|
27
|
+
return Object.freeze({
|
|
28
|
+
id: input.id,
|
|
29
|
+
type: input.type,
|
|
30
|
+
path: input.path,
|
|
31
|
+
content: input.content,
|
|
32
|
+
contentHash: simpleHash(input.content),
|
|
33
|
+
producerId: input.producerId,
|
|
34
|
+
createdAt: new Date(),
|
|
35
|
+
traceabilityIds: Object.freeze([...(input.traceabilityIds ?? [])]),
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Check if artifact has changed
|
|
40
|
+
*
|
|
41
|
+
* @param artifact - Artifact to check
|
|
42
|
+
* @param newContent - New content to compare
|
|
43
|
+
* @returns true if content has changed
|
|
44
|
+
*/
|
|
45
|
+
export function hasArtifactChanged(artifact, newContent) {
|
|
46
|
+
return artifact.contentHash !== simpleHash(newContent);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get artifact extension
|
|
50
|
+
*
|
|
51
|
+
* @param artifact - Artifact
|
|
52
|
+
* @returns File extension
|
|
53
|
+
*/
|
|
54
|
+
export function getArtifactExtension(artifact) {
|
|
55
|
+
const parts = artifact.path.split('.');
|
|
56
|
+
return parts.length > 1 ? parts[parts.length - 1] : '';
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=Artifact.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Artifact.js","sourceRoot":"","sources":["../../../src/domain/entities/Artifact.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA+CH;;GAEG;AACH,SAAS,UAAU,CAAC,OAAe;IACjC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAA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