@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,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContextManager Application Service
|
|
3
|
+
*
|
|
4
|
+
* Manages execution contexts for task sharing
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-SDD-003 - Context Sharing
|
|
7
|
+
* @see DES-SDD-003 - ContextManager
|
|
8
|
+
*/
|
|
9
|
+
import { type ExecutionContext } from '../domain/entities/ExecutionContext.js';
|
|
10
|
+
import type { Artifact } from '../domain/entities/Artifact.js';
|
|
11
|
+
/**
|
|
12
|
+
* Context manager interface
|
|
13
|
+
*/
|
|
14
|
+
export interface IContextManager {
|
|
15
|
+
/**
|
|
16
|
+
* Create a new execution context
|
|
17
|
+
* @param taskId - Task ID
|
|
18
|
+
* @param parent - Optional parent context
|
|
19
|
+
* @returns New execution context
|
|
20
|
+
*/
|
|
21
|
+
create(taskId: string, parent?: ExecutionContext): ExecutionContext;
|
|
22
|
+
/**
|
|
23
|
+
* Share knowledge in context
|
|
24
|
+
* @param context - Context to update
|
|
25
|
+
* @param key - Knowledge key
|
|
26
|
+
* @param value - Knowledge value
|
|
27
|
+
* @returns Updated context (immutable)
|
|
28
|
+
*/
|
|
29
|
+
share(context: ExecutionContext, key: string, value: unknown): ExecutionContext;
|
|
30
|
+
/**
|
|
31
|
+
* Add artifact to context
|
|
32
|
+
* @param context - Context to update
|
|
33
|
+
* @param artifact - Artifact to add
|
|
34
|
+
* @returns Updated context (immutable)
|
|
35
|
+
*/
|
|
36
|
+
addArtifact(context: ExecutionContext, artifact: Artifact): ExecutionContext;
|
|
37
|
+
/**
|
|
38
|
+
* Merge multiple contexts
|
|
39
|
+
* @param contexts - Contexts to merge
|
|
40
|
+
* @returns Merged context
|
|
41
|
+
*/
|
|
42
|
+
merge(contexts: ExecutionContext[]): ExecutionContext;
|
|
43
|
+
/**
|
|
44
|
+
* Get value from context (including parents)
|
|
45
|
+
* @param context - Context to search
|
|
46
|
+
* @param key - Knowledge key
|
|
47
|
+
* @returns Value or undefined
|
|
48
|
+
*/
|
|
49
|
+
get<T>(context: ExecutionContext, key: string): T | undefined;
|
|
50
|
+
/**
|
|
51
|
+
* Get all artifacts from context (including parents)
|
|
52
|
+
* @param context - Context to search
|
|
53
|
+
* @returns All artifacts
|
|
54
|
+
*/
|
|
55
|
+
getArtifacts(context: ExecutionContext): Artifact[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Context manager configuration
|
|
59
|
+
*/
|
|
60
|
+
export interface ContextManagerConfig {
|
|
61
|
+
/** Default project path */
|
|
62
|
+
defaultProjectPath?: string;
|
|
63
|
+
/** Default source */
|
|
64
|
+
defaultSource?: 'user' | 'agent' | 'system';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a context manager
|
|
68
|
+
*
|
|
69
|
+
* @param config - Optional configuration
|
|
70
|
+
* @returns IContextManager implementation
|
|
71
|
+
*/
|
|
72
|
+
export declare function createContextManager(config?: ContextManagerConfig): IContextManager;
|
|
73
|
+
/**
|
|
74
|
+
* Context snapshot for serialization
|
|
75
|
+
*/
|
|
76
|
+
export interface ContextSnapshot {
|
|
77
|
+
taskId: string;
|
|
78
|
+
knowledge: Record<string, unknown>;
|
|
79
|
+
artifactIds: string[];
|
|
80
|
+
metadata: ExecutionContext['metadata'];
|
|
81
|
+
timestamp: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Create a snapshot of context for persistence
|
|
85
|
+
*
|
|
86
|
+
* @param context - Context to snapshot
|
|
87
|
+
* @returns Serializable snapshot
|
|
88
|
+
*/
|
|
89
|
+
export declare function createContextSnapshot(context: ExecutionContext): ContextSnapshot;
|
|
90
|
+
//# sourceMappingURL=ContextManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextManager.d.ts","sourceRoot":"","sources":["../../src/application/ContextManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,gBAAgB,EAKtB,MAAM,wCAAwC,CAAC;AAChD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAE/D;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,gBAAgB,GAAG,gBAAgB,CAAC;IAEpE;;;;;;OAMG;IACH,KAAK,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,gBAAgB,CAAC;IAEhF;;;;;OAKG;IACH,WAAW,CAAC,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,GAAG,gBAAgB,CAAC;IAE7E;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,gBAAgB,EAAE,GAAG,gBAAgB,CAAC;IAEtD;;;;;OAKG;IACH,GAAG,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAE9D;;;;OAIG;IACH,YAAY,CAAC,OAAO,EAAE,gBAAgB,GAAG,QAAQ,EAAE,CAAC;CACrD;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,2BAA2B;IAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,qBAAqB;IACrB,aAAa,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;CAC7C;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAClC,MAAM,GAAE,oBAAyB,GAChC,eAAe,CA6GjB;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,EAAE,CAAC;IACtB,QAAQ,EAAE,gBAAgB,CAAC,UAAU,CAAC,CAAC;IACvC,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,eAAe,CAahF"}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ContextManager Application Service
|
|
3
|
+
*
|
|
4
|
+
* Manages execution contexts for task sharing
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-SDD-003 - Context Sharing
|
|
7
|
+
* @see DES-SDD-003 - ContextManager
|
|
8
|
+
*/
|
|
9
|
+
import { createExecutionContext, getFromContext, getAllArtifacts, } from '../domain/entities/ExecutionContext.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create a context manager
|
|
12
|
+
*
|
|
13
|
+
* @param config - Optional configuration
|
|
14
|
+
* @returns IContextManager implementation
|
|
15
|
+
*/
|
|
16
|
+
export function createContextManager(config = {}) {
|
|
17
|
+
const defaultSource = config.defaultSource ?? 'system';
|
|
18
|
+
return {
|
|
19
|
+
create(taskId, parent) {
|
|
20
|
+
const input = {
|
|
21
|
+
taskId,
|
|
22
|
+
parentContext: parent,
|
|
23
|
+
metadata: {
|
|
24
|
+
source: defaultSource,
|
|
25
|
+
projectPath: config.defaultProjectPath,
|
|
26
|
+
relatedFiles: [],
|
|
27
|
+
tags: [],
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
return createExecutionContext(input);
|
|
31
|
+
},
|
|
32
|
+
share(context, key, value) {
|
|
33
|
+
// Create new Map with existing knowledge plus new entry
|
|
34
|
+
const newKnowledge = new Map(context.sharedKnowledge);
|
|
35
|
+
newKnowledge.set(key, value);
|
|
36
|
+
return createExecutionContext({
|
|
37
|
+
taskId: context.taskId,
|
|
38
|
+
parentContext: context.parentContext,
|
|
39
|
+
sharedKnowledge: newKnowledge,
|
|
40
|
+
artifacts: [...context.artifacts],
|
|
41
|
+
metadata: context.metadata,
|
|
42
|
+
});
|
|
43
|
+
},
|
|
44
|
+
addArtifact(context, artifact) {
|
|
45
|
+
return createExecutionContext({
|
|
46
|
+
taskId: context.taskId,
|
|
47
|
+
parentContext: context.parentContext,
|
|
48
|
+
sharedKnowledge: new Map(context.sharedKnowledge),
|
|
49
|
+
artifacts: [...context.artifacts, artifact],
|
|
50
|
+
metadata: context.metadata,
|
|
51
|
+
});
|
|
52
|
+
},
|
|
53
|
+
merge(contexts) {
|
|
54
|
+
if (contexts.length === 0) {
|
|
55
|
+
throw new Error('Cannot merge empty context array');
|
|
56
|
+
}
|
|
57
|
+
if (contexts.length === 1) {
|
|
58
|
+
return contexts[0];
|
|
59
|
+
}
|
|
60
|
+
// Merge all knowledge
|
|
61
|
+
const mergedKnowledge = new Map();
|
|
62
|
+
for (const ctx of contexts) {
|
|
63
|
+
for (const [key, value] of ctx.sharedKnowledge) {
|
|
64
|
+
// Later contexts override earlier ones
|
|
65
|
+
mergedKnowledge.set(key, value);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// Merge all artifacts (deduplicate by ID)
|
|
69
|
+
const artifactMap = new Map();
|
|
70
|
+
for (const ctx of contexts) {
|
|
71
|
+
for (const artifact of getAllArtifacts(ctx)) {
|
|
72
|
+
artifactMap.set(artifact.id, artifact);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// Merge related files
|
|
76
|
+
const relatedFilesSet = new Set();
|
|
77
|
+
for (const ctx of contexts) {
|
|
78
|
+
for (const file of ctx.metadata.relatedFiles) {
|
|
79
|
+
relatedFilesSet.add(file);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Merge tags
|
|
83
|
+
const tagsSet = new Set();
|
|
84
|
+
for (const ctx of contexts) {
|
|
85
|
+
for (const tag of ctx.metadata.tags) {
|
|
86
|
+
tagsSet.add(tag);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
// Use first context's taskId as merged ID
|
|
90
|
+
const mergedTaskId = `merged-${contexts.map((c) => c.taskId).join('-')}`;
|
|
91
|
+
return createExecutionContext({
|
|
92
|
+
taskId: mergedTaskId,
|
|
93
|
+
sharedKnowledge: mergedKnowledge,
|
|
94
|
+
artifacts: Array.from(artifactMap.values()),
|
|
95
|
+
metadata: {
|
|
96
|
+
source: 'system',
|
|
97
|
+
projectPath: contexts[0].metadata.projectPath,
|
|
98
|
+
relatedFiles: Array.from(relatedFilesSet),
|
|
99
|
+
tags: Array.from(tagsSet),
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
},
|
|
103
|
+
get(context, key) {
|
|
104
|
+
return getFromContext(context, key);
|
|
105
|
+
},
|
|
106
|
+
getArtifacts(context) {
|
|
107
|
+
return getAllArtifacts(context);
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a snapshot of context for persistence
|
|
113
|
+
*
|
|
114
|
+
* @param context - Context to snapshot
|
|
115
|
+
* @returns Serializable snapshot
|
|
116
|
+
*/
|
|
117
|
+
export function createContextSnapshot(context) {
|
|
118
|
+
const knowledge = {};
|
|
119
|
+
for (const [key, value] of context.sharedKnowledge) {
|
|
120
|
+
knowledge[key] = value;
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
taskId: context.taskId,
|
|
124
|
+
knowledge,
|
|
125
|
+
artifactIds: context.artifacts.map((a) => a.id),
|
|
126
|
+
metadata: context.metadata,
|
|
127
|
+
timestamp: context.timestamp.toISOString(),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=ContextManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextManager.js","sourceRoot":"","sources":["../../src/application/ContextManager.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAGL,sBAAsB,EACtB,cAAc,EACd,eAAe,GAChB,MAAM,wCAAwC,CAAC;AAiEhD;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAA+B,EAAE;IAEjC,MAAM,aAAa,GAAG,MAAM,CAAC,aAAa,IAAI,QAAQ,CAAC;IAEvD,OAAO;QACL,MAAM,CAAC,MAAc,EAAE,MAAyB;YAC9C,MAAM,KAAK,GAAgC;gBACzC,MAAM;gBACN,aAAa,EAAE,MAAM;gBACrB,QAAQ,EAAE;oBACR,MAAM,EAAE,aAAa;oBACrB,WAAW,EAAE,MAAM,CAAC,kBAAkB;oBACtC,YAAY,EAAE,EAAE;oBAChB,IAAI,EAAE,EAAE;iBACT;aACF,CAAC;YAEF,OAAO,sBAAsB,CAAC,KAAK,CAAC,CAAC;QACvC,CAAC;QAED,KAAK,CAAC,OAAyB,EAAE,GAAW,EAAE,KAAc;YAC1D,wDAAwD;YACxD,MAAM,YAAY,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;YACtD,YAAY,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;YAE7B,OAAO,sBAAsB,CAAC;gBAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,aAAa,EAAE,OAAO,CAAC,aAAa;gBACpC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W;YAC3C,OAAO,cAAc,CAAI,OAAO,EAAE,GAAG,CAAC,CAAC;QACzC,CAAC;QAED,YAAY,CAAC,OAAyB;YACpC,OAAO,eAAe,CAAC,OAAO,CAAC,CAAC;QAClC,CAAC;KACF,CAAC;AACJ,CAAC;AAaD;;;;;GAKG;AACH,MAAM,UAAU,qBAAqB,CAAC,OAAyB;IAC7D,MAAM,SAAS,GAA4B,EAAE,CAAC;IAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;QACnD,SAAS,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IACzB,CAAC;IAED,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS;QACT,WAAW,EAAE,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC/C,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,WAAW,EAAE;KAC3C,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParallelExecutor Application Service
|
|
3
|
+
*
|
|
4
|
+
* Executes independent tasks in parallel
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-PAD-002 - Parallel Execution
|
|
7
|
+
* @see DES-PAD-002 - ParallelExecutor
|
|
8
|
+
*/
|
|
9
|
+
import type { SubagentSpec, SubagentResult } from '../domain/entities/SubagentSpec.js';
|
|
10
|
+
import type { DependencyGraph } from '../domain/services/DependencyAnalyzer.js';
|
|
11
|
+
/**
|
|
12
|
+
* Executor function type
|
|
13
|
+
*/
|
|
14
|
+
export type SubagentExecutor = (spec: SubagentSpec) => Promise<SubagentResult>;
|
|
15
|
+
/**
|
|
16
|
+
* Parallel executor interface
|
|
17
|
+
*/
|
|
18
|
+
export interface IParallelExecutor {
|
|
19
|
+
/**
|
|
20
|
+
* Execute specs in parallel respecting dependencies
|
|
21
|
+
* @param specs - Subagent specifications
|
|
22
|
+
* @param graph - Dependency graph
|
|
23
|
+
* @param executor - Executor function
|
|
24
|
+
* @returns All results
|
|
25
|
+
*/
|
|
26
|
+
execute(specs: SubagentSpec[], graph: DependencyGraph, executor: SubagentExecutor): Promise<SubagentResult[]>;
|
|
27
|
+
/**
|
|
28
|
+
* Execute specs in a single level (all parallel)
|
|
29
|
+
* @param specs - Subagent specifications
|
|
30
|
+
* @param executor - Executor function
|
|
31
|
+
* @returns Results
|
|
32
|
+
*/
|
|
33
|
+
executeLevel(specs: SubagentSpec[], executor: SubagentExecutor): Promise<SubagentResult[]>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Executor configuration
|
|
37
|
+
*/
|
|
38
|
+
export interface ParallelExecutorConfig {
|
|
39
|
+
/** Maximum concurrent executions (default: 5) */
|
|
40
|
+
maxConcurrency?: number;
|
|
41
|
+
/** Continue on error (default: true) */
|
|
42
|
+
continueOnError?: boolean;
|
|
43
|
+
/** Global timeout (ms) */
|
|
44
|
+
globalTimeoutMs?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a parallel executor
|
|
48
|
+
*
|
|
49
|
+
* @param config - Optional configuration
|
|
50
|
+
* @returns IParallelExecutor implementation
|
|
51
|
+
*/
|
|
52
|
+
export declare function createParallelExecutor(config?: ParallelExecutorConfig): IParallelExecutor;
|
|
53
|
+
/**
|
|
54
|
+
* Execution progress callback
|
|
55
|
+
*/
|
|
56
|
+
export type ProgressCallback = (completed: number, total: number, current: SubagentResult) => void;
|
|
57
|
+
/**
|
|
58
|
+
* Create executor with progress tracking
|
|
59
|
+
*
|
|
60
|
+
* @param config - Configuration
|
|
61
|
+
* @param onProgress - Progress callback
|
|
62
|
+
* @returns Executor with progress
|
|
63
|
+
*/
|
|
64
|
+
export declare function createProgressExecutor(config?: ParallelExecutorConfig, onProgress?: ProgressCallback): IParallelExecutor;
|
|
65
|
+
//# sourceMappingURL=ParallelExecutor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParallelExecutor.d.ts","sourceRoot":"","sources":["../../src/application/ParallelExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAEvF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAC;AAEhF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,IAAI,EAAE,YAAY,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,OAAO,CACL,KAAK,EAAE,YAAY,EAAE,EACrB,KAAK,EAAE,eAAe,EACtB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;IAE7B;;;;;OAKG;IACH,YAAY,CACV,KAAK,EAAE,YAAY,EAAE,EACrB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,cAAc,EAAE,CAAC,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,iDAAiD;IACjD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,wCAAwC;IACxC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,0BAA0B;IAC1B,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,GAAE,sBAA2B,GAClC,iBAAiB,CAyJnB;AAED;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,cAAc,KACpB,IAAI,CAAC;AAEV;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CACpC,MAAM,GAAE,sBAA2B,EACnC,UAAU,CAAC,EAAE,gBAAgB,GAC5B,iBAAiB,CAiCnB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ParallelExecutor Application Service
|
|
3
|
+
*
|
|
4
|
+
* Executes independent tasks in parallel
|
|
5
|
+
*
|
|
6
|
+
* @see REQ-PAD-002 - Parallel Execution
|
|
7
|
+
* @see DES-PAD-002 - ParallelExecutor
|
|
8
|
+
*/
|
|
9
|
+
import { createSubagentResult } from '../domain/entities/SubagentSpec.js';
|
|
10
|
+
/**
|
|
11
|
+
* Create a parallel executor
|
|
12
|
+
*
|
|
13
|
+
* @param config - Optional configuration
|
|
14
|
+
* @returns IParallelExecutor implementation
|
|
15
|
+
*/
|
|
16
|
+
export function createParallelExecutor(config = {}) {
|
|
17
|
+
const maxConcurrency = config.maxConcurrency ?? 5;
|
|
18
|
+
const continueOnError = config.continueOnError ?? true;
|
|
19
|
+
const globalTimeoutMs = config.globalTimeoutMs ?? 600000; // 10 minutes
|
|
20
|
+
/**
|
|
21
|
+
* Execute with concurrency limit
|
|
22
|
+
*/
|
|
23
|
+
async function executeWithLimit(items, fn, limit) {
|
|
24
|
+
const results = [];
|
|
25
|
+
const executing = [];
|
|
26
|
+
for (const item of items) {
|
|
27
|
+
const promise = fn(item).then((result) => {
|
|
28
|
+
results.push(result);
|
|
29
|
+
});
|
|
30
|
+
executing.push(promise);
|
|
31
|
+
if (executing.length >= limit) {
|
|
32
|
+
await Promise.race(executing);
|
|
33
|
+
// Remove completed promises
|
|
34
|
+
const completed = executing.filter((p) => p.settled);
|
|
35
|
+
for (const c of completed) {
|
|
36
|
+
const index = executing.indexOf(c);
|
|
37
|
+
if (index > -1)
|
|
38
|
+
executing.splice(index, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
await Promise.all(executing);
|
|
43
|
+
return results;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Execute single spec with timeout
|
|
47
|
+
*/
|
|
48
|
+
async function executeWithTimeout(spec, executor) {
|
|
49
|
+
const startTime = Date.now();
|
|
50
|
+
const timeoutPromise = new Promise((_, reject) => {
|
|
51
|
+
setTimeout(() => {
|
|
52
|
+
reject(new Error(`Timeout after ${spec.timeoutMs}ms`));
|
|
53
|
+
}, spec.timeoutMs);
|
|
54
|
+
});
|
|
55
|
+
try {
|
|
56
|
+
const result = await Promise.race([executor(spec), timeoutPromise]);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
const durationMs = Date.now() - startTime;
|
|
61
|
+
return createSubagentResult(spec.id, false, '', durationMs, [], error instanceof Error ? error.message : String(error));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
async execute(specs, graph, executor) {
|
|
66
|
+
if (graph.hasCircular) {
|
|
67
|
+
throw new Error(`Cannot execute: circular dependency detected: ${graph.circularPath?.join(' → ')}`);
|
|
68
|
+
}
|
|
69
|
+
const allResults = [];
|
|
70
|
+
const specMap = new Map(specs.map((s) => [s.id, s]));
|
|
71
|
+
const completedIds = new Set();
|
|
72
|
+
// Global timeout
|
|
73
|
+
const globalStart = Date.now();
|
|
74
|
+
// Execute level by level
|
|
75
|
+
for (const level of graph.levels) {
|
|
76
|
+
// Check global timeout
|
|
77
|
+
if (Date.now() - globalStart > globalTimeoutMs) {
|
|
78
|
+
// Create timeout results for remaining specs
|
|
79
|
+
for (const id of level) {
|
|
80
|
+
if (!completedIds.has(id)) {
|
|
81
|
+
allResults.push(createSubagentResult(id, false, '', 0, [], `Global timeout exceeded (${globalTimeoutMs}ms)`));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
// Get specs for this level
|
|
87
|
+
const levelSpecs = level
|
|
88
|
+
.map((id) => specMap.get(id))
|
|
89
|
+
.filter((s) => s !== undefined);
|
|
90
|
+
// Execute level in parallel
|
|
91
|
+
const levelResults = await this.executeLevel(levelSpecs, executor);
|
|
92
|
+
// Track results
|
|
93
|
+
for (const result of levelResults) {
|
|
94
|
+
allResults.push(result);
|
|
95
|
+
completedIds.add(result.specId);
|
|
96
|
+
// Check if we should stop on error
|
|
97
|
+
if (!result.success && !continueOnError) {
|
|
98
|
+
return allResults;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
return allResults;
|
|
103
|
+
},
|
|
104
|
+
async executeLevel(specs, executor) {
|
|
105
|
+
if (specs.length === 0) {
|
|
106
|
+
return [];
|
|
107
|
+
}
|
|
108
|
+
// Execute all specs in parallel with concurrency limit
|
|
109
|
+
const results = await executeWithLimit(specs, (spec) => executeWithTimeout(spec, executor), maxConcurrency);
|
|
110
|
+
return results;
|
|
111
|
+
},
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Create executor with progress tracking
|
|
116
|
+
*
|
|
117
|
+
* @param config - Configuration
|
|
118
|
+
* @param onProgress - Progress callback
|
|
119
|
+
* @returns Executor with progress
|
|
120
|
+
*/
|
|
121
|
+
export function createProgressExecutor(config = {}, onProgress) {
|
|
122
|
+
const baseExecutor = createParallelExecutor(config);
|
|
123
|
+
let completed = 0;
|
|
124
|
+
return {
|
|
125
|
+
async execute(specs, graph, executor) {
|
|
126
|
+
completed = 0;
|
|
127
|
+
const total = specs.length;
|
|
128
|
+
const wrappedExecutor = async (spec) => {
|
|
129
|
+
const result = await executor(spec);
|
|
130
|
+
completed++;
|
|
131
|
+
onProgress?.(completed, total, result);
|
|
132
|
+
return result;
|
|
133
|
+
};
|
|
134
|
+
return baseExecutor.execute(specs, graph, wrappedExecutor);
|
|
135
|
+
},
|
|
136
|
+
async executeLevel(specs, executor) {
|
|
137
|
+
const total = specs.length;
|
|
138
|
+
let levelCompleted = 0;
|
|
139
|
+
const wrappedExecutor = async (spec) => {
|
|
140
|
+
const result = await executor(spec);
|
|
141
|
+
levelCompleted++;
|
|
142
|
+
onProgress?.(levelCompleted, total, result);
|
|
143
|
+
return result;
|
|
144
|
+
};
|
|
145
|
+
return baseExecutor.executeLevel(specs, wrappedExecutor);
|
|
146
|
+
},
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=ParallelExecutor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ParallelExecutor.js","sourceRoot":"","sources":["../../src/application/ParallelExecutor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,oCAAoC,CAAC;AAiD1E;;;;;GAKG;AACH,MAAM,UAAU,sBAAsB,CACpC,SAAiC,EAAE;IAEnC,MAAM,cAAc,GAAG,MAAM,CAAC,cAAc,IAAI,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,IAAI,CAAC;IACvD,MAAM,eAAe,GAAG,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,CAAC,aAAa;IAEvE;;OAEG;IACH,KAAK,UAAU,gBAAgB,CAC7B,KAAU,EACV,EAAwC,EACxC,KAAa;QAEb,MAAM,OAAO,GAAqB,EAAE,CAAC;QACrC,MAAM,SAAS,GAAoB,EAAE,CAAC;QAEtC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE;gBACvC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;YAEH,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YAExB,IAAI,SAAS,CAAC,MAAM,IAAI,KAAK,EAAE,CAAC;gBAC9B,MAAM,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;gBAC9B,4BAA4B;gBAC5B,MAAM,SAAS,GAAG,SAAS,CAAC,MAAM,CAChC,CAAC,CAAC,EAAE,EAAE,CAAE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,EAAE;gBACvD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACpC,SAAS,EAAE,CAAC;gBACZ,UAAU,EAAE,CAAC,SAAS,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBACvC,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;YAEF,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE,KAAK,EAAE,eAAe,CAAC,CAAC;QAC7D,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,QAAQ;YAChC,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC;YAC3B,IAAI,cAAc,GAAG,CAAC,CAAC;YAEvB,MAAM,eAAe,GAAqB,KAAK,EAAE,IAAI,EAAE,EAAE;gBACvD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACpC,cAAc,EAAE,CAAC;gBACjB,UAAU,EAAE,CAAC,cAAc,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;gBAC5C,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;YAEF,OAAO,YAAY,CAAC,YAAY,CAAC,KAAK,EAAE,eAAe,CAAC,CAAC;QAC3D,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,107 @@
|
|
|
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
|
+
import type { SubagentResult, SubagentArtifact } from '../domain/entities/SubagentSpec.js';
|
|
10
|
+
/**
|
|
11
|
+
* Conflict detection result
|
|
12
|
+
*/
|
|
13
|
+
export interface ConflictInfo {
|
|
14
|
+
/** Conflicting spec IDs */
|
|
15
|
+
readonly specIds: readonly string[];
|
|
16
|
+
/** Conflicting file path */
|
|
17
|
+
readonly filePath: string;
|
|
18
|
+
/** Conflict type */
|
|
19
|
+
readonly type: 'file' | 'content' | 'semantic';
|
|
20
|
+
/** Description */
|
|
21
|
+
readonly description: string;
|
|
22
|
+
/** Can be auto-resolved */
|
|
23
|
+
readonly autoResolvable: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Aggregated output
|
|
27
|
+
*/
|
|
28
|
+
export interface AggregatedOutput {
|
|
29
|
+
/** All results */
|
|
30
|
+
readonly results: readonly SubagentResult[];
|
|
31
|
+
/** Overall success */
|
|
32
|
+
readonly success: boolean;
|
|
33
|
+
/** Combined content */
|
|
34
|
+
readonly combinedContent: string;
|
|
35
|
+
/** All artifacts (deduplicated) */
|
|
36
|
+
readonly artifacts: readonly SubagentArtifact[];
|
|
37
|
+
/** Detected conflicts */
|
|
38
|
+
readonly conflicts: readonly ConflictInfo[];
|
|
39
|
+
/** Failed results */
|
|
40
|
+
readonly failures: readonly SubagentResult[];
|
|
41
|
+
/** Statistics */
|
|
42
|
+
readonly stats: AggregationStats;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Aggregation statistics
|
|
46
|
+
*/
|
|
47
|
+
export interface AggregationStats {
|
|
48
|
+
readonly totalSpecs: number;
|
|
49
|
+
readonly succeeded: number;
|
|
50
|
+
readonly failed: number;
|
|
51
|
+
readonly totalDurationMs: number;
|
|
52
|
+
readonly averageDurationMs: number;
|
|
53
|
+
readonly artifactCount: number;
|
|
54
|
+
readonly conflictCount: number;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Result aggregator interface
|
|
58
|
+
*/
|
|
59
|
+
export interface IResultAggregator {
|
|
60
|
+
/**
|
|
61
|
+
* Aggregate results from multiple subagents
|
|
62
|
+
* @param results - Subagent results
|
|
63
|
+
* @returns Aggregated output
|
|
64
|
+
*/
|
|
65
|
+
aggregate(results: SubagentResult[]): AggregatedOutput;
|
|
66
|
+
/**
|
|
67
|
+
* Detect conflicts between results
|
|
68
|
+
* @param results - Subagent results
|
|
69
|
+
* @returns Detected conflicts
|
|
70
|
+
*/
|
|
71
|
+
detectConflicts(results: SubagentResult[]): ConflictInfo[];
|
|
72
|
+
/**
|
|
73
|
+
* Merge artifacts from results
|
|
74
|
+
* @param results - Subagent results
|
|
75
|
+
* @returns Merged artifacts
|
|
76
|
+
*/
|
|
77
|
+
mergeArtifacts(results: SubagentResult[]): SubagentArtifact[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Aggregator configuration
|
|
81
|
+
*/
|
|
82
|
+
export interface ResultAggregatorConfig {
|
|
83
|
+
/** Enable conflict detection (default: true) */
|
|
84
|
+
detectConflicts?: boolean;
|
|
85
|
+
/** Content separator for combining */
|
|
86
|
+
contentSeparator?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create a result aggregator
|
|
90
|
+
*
|
|
91
|
+
* @param config - Optional configuration
|
|
92
|
+
* @returns IResultAggregator implementation
|
|
93
|
+
*/
|
|
94
|
+
export declare function createResultAggregator(config?: ResultAggregatorConfig): IResultAggregator;
|
|
95
|
+
/**
|
|
96
|
+
* Create a conflict resolution strategy
|
|
97
|
+
*/
|
|
98
|
+
export type ConflictResolver = (conflict: ConflictInfo, artifacts: SubagentArtifact[]) => SubagentArtifact | null;
|
|
99
|
+
/**
|
|
100
|
+
* Default conflict resolver - use latest artifact
|
|
101
|
+
*/
|
|
102
|
+
export declare const latestArtifactResolver: ConflictResolver;
|
|
103
|
+
/**
|
|
104
|
+
* Merge resolver - attempt to merge content
|
|
105
|
+
*/
|
|
106
|
+
export declare const mergeResolver: ConflictResolver;
|
|
107
|
+
//# sourceMappingURL=ResultAggregator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResultAggregator.d.ts","sourceRoot":"","sources":["../../src/application/ResultAggregator.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,cAAc,EA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