@sudocode-ai/local-server 0.1.10 → 0.1.11
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/execution/executors/agent-executor-wrapper.d.ts.map +1 -1
- package/dist/execution/executors/agent-executor-wrapper.js +57 -2
- package/dist/execution/executors/agent-executor-wrapper.js.map +1 -1
- package/dist/execution/process/builders/claude.d.ts.map +1 -1
- package/dist/execution/process/builders/claude.js +32 -1
- package/dist/execution/process/builders/claude.js.map +1 -1
- package/dist/execution/worktree/git-cli.d.ts +48 -0
- package/dist/execution/worktree/git-cli.d.ts.map +1 -1
- package/dist/execution/worktree/git-cli.js +81 -0
- package/dist/execution/worktree/git-cli.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -4
- package/dist/index.js.map +1 -1
- package/dist/public/assets/index-Nz4IjDwB.css +1 -0
- package/dist/public/assets/index-Z8yftXvD.js +824 -0
- package/dist/public/assets/index-Z8yftXvD.js.map +1 -0
- package/dist/public/assets/{react-vendor-DiL5hC7l.js → react-vendor-5f1Wq1qs.js} +5 -5
- package/dist/public/assets/{react-vendor-DiL5hC7l.js.map → react-vendor-5f1Wq1qs.js.map} +1 -1
- package/dist/public/assets/{ui-vendor-B4WMPEfa.js → ui-vendor-BDDPoYki.js} +2 -2
- package/dist/public/assets/{ui-vendor-B4WMPEfa.js.map → ui-vendor-BDDPoYki.js.map} +1 -1
- package/dist/public/index.html +4 -4
- package/dist/routes/workflows.d.ts +8 -0
- package/dist/routes/workflows.d.ts.map +1 -0
- package/dist/routes/workflows.js +1729 -0
- package/dist/routes/workflows.js.map +1 -0
- package/dist/services/execution-event-callbacks.d.ts +73 -0
- package/dist/services/execution-event-callbacks.d.ts.map +1 -0
- package/dist/services/execution-event-callbacks.js +82 -0
- package/dist/services/execution-event-callbacks.js.map +1 -0
- package/dist/services/execution-lifecycle.d.ts +36 -0
- package/dist/services/execution-lifecycle.d.ts.map +1 -1
- package/dist/services/execution-lifecycle.js +87 -0
- package/dist/services/execution-lifecycle.js.map +1 -1
- package/dist/services/execution-service.d.ts +31 -3
- package/dist/services/execution-service.d.ts.map +1 -1
- package/dist/services/execution-service.js +161 -34
- package/dist/services/execution-service.js.map +1 -1
- package/dist/services/executions.d.ts +1 -0
- package/dist/services/executions.d.ts.map +1 -1
- package/dist/services/executions.js +4 -0
- package/dist/services/executions.js.map +1 -1
- package/dist/services/project-context.d.ts +25 -0
- package/dist/services/project-context.d.ts.map +1 -1
- package/dist/services/project-context.js +53 -3
- package/dist/services/project-context.js.map +1 -1
- package/dist/services/project-manager.d.ts +7 -0
- package/dist/services/project-manager.d.ts.map +1 -1
- package/dist/services/project-manager.js +90 -1
- package/dist/services/project-manager.js.map +1 -1
- package/dist/services/websocket.d.ts +10 -2
- package/dist/services/websocket.d.ts.map +1 -1
- package/dist/services/websocket.js +18 -0
- package/dist/services/websocket.js.map +1 -1
- package/dist/services/workflow-broadcast-service.d.ts +43 -0
- package/dist/services/workflow-broadcast-service.d.ts.map +1 -0
- package/dist/services/workflow-broadcast-service.js +145 -0
- package/dist/services/workflow-broadcast-service.js.map +1 -0
- package/dist/workflow/base-workflow-engine.d.ts +186 -0
- package/dist/workflow/base-workflow-engine.d.ts.map +1 -0
- package/dist/workflow/base-workflow-engine.js +549 -0
- package/dist/workflow/base-workflow-engine.js.map +1 -0
- package/dist/workflow/dependency-analyzer.d.ts +78 -0
- package/dist/workflow/dependency-analyzer.d.ts.map +1 -0
- package/dist/workflow/dependency-analyzer.js +264 -0
- package/dist/workflow/dependency-analyzer.js.map +1 -0
- package/dist/workflow/engines/orchestrator-engine.d.ts +237 -0
- package/dist/workflow/engines/orchestrator-engine.d.ts.map +1 -0
- package/dist/workflow/engines/orchestrator-engine.js +749 -0
- package/dist/workflow/engines/orchestrator-engine.js.map +1 -0
- package/dist/workflow/engines/sequential-engine.d.ts +276 -0
- package/dist/workflow/engines/sequential-engine.d.ts.map +1 -0
- package/dist/workflow/engines/sequential-engine.js +1110 -0
- package/dist/workflow/engines/sequential-engine.js.map +1 -0
- package/dist/workflow/index.d.ts +15 -0
- package/dist/workflow/index.d.ts.map +1 -0
- package/dist/workflow/index.js +22 -0
- package/dist/workflow/index.js.map +1 -0
- package/dist/workflow/mcp/api-client.d.ts +103 -0
- package/dist/workflow/mcp/api-client.d.ts.map +1 -0
- package/dist/workflow/mcp/api-client.js +193 -0
- package/dist/workflow/mcp/api-client.js.map +1 -0
- package/dist/workflow/mcp/index.d.ts +16 -0
- package/dist/workflow/mcp/index.d.ts.map +1 -0
- package/dist/workflow/mcp/index.js +114 -0
- package/dist/workflow/mcp/index.js.map +1 -0
- package/dist/workflow/mcp/server.d.ts +85 -0
- package/dist/workflow/mcp/server.d.ts.map +1 -0
- package/dist/workflow/mcp/server.js +520 -0
- package/dist/workflow/mcp/server.js.map +1 -0
- package/dist/workflow/mcp/tools/escalation.d.ts +36 -0
- package/dist/workflow/mcp/tools/escalation.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/escalation.js +47 -0
- package/dist/workflow/mcp/tools/escalation.js.map +1 -0
- package/dist/workflow/mcp/tools/execution.d.ts +59 -0
- package/dist/workflow/mcp/tools/execution.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/execution.js +67 -0
- package/dist/workflow/mcp/tools/execution.js.map +1 -0
- package/dist/workflow/mcp/tools/inspection.d.ts +82 -0
- package/dist/workflow/mcp/tools/inspection.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/inspection.js +57 -0
- package/dist/workflow/mcp/tools/inspection.js.map +1 -0
- package/dist/workflow/mcp/tools/workflow.d.ts +59 -0
- package/dist/workflow/mcp/tools/workflow.d.ts.map +1 -0
- package/dist/workflow/mcp/tools/workflow.js +40 -0
- package/dist/workflow/mcp/tools/workflow.js.map +1 -0
- package/dist/workflow/mcp/types.d.ts +345 -0
- package/dist/workflow/mcp/types.d.ts.map +1 -0
- package/dist/workflow/mcp/types.js +7 -0
- package/dist/workflow/mcp/types.js.map +1 -0
- package/dist/workflow/services/prompt-builder.d.ts +36 -0
- package/dist/workflow/services/prompt-builder.d.ts.map +1 -0
- package/dist/workflow/services/prompt-builder.js +329 -0
- package/dist/workflow/services/prompt-builder.js.map +1 -0
- package/dist/workflow/services/wakeup-service.d.ts +262 -0
- package/dist/workflow/services/wakeup-service.d.ts.map +1 -0
- package/dist/workflow/services/wakeup-service.js +809 -0
- package/dist/workflow/services/wakeup-service.js.map +1 -0
- package/dist/workflow/workflow-engine.d.ts +221 -0
- package/dist/workflow/workflow-engine.d.ts.map +1 -0
- package/dist/workflow/workflow-engine.js +94 -0
- package/dist/workflow/workflow-engine.js.map +1 -0
- package/dist/workflow/workflow-event-emitter.d.ts +278 -0
- package/dist/workflow/workflow-event-emitter.d.ts.map +1 -0
- package/dist/workflow/workflow-event-emitter.js +259 -0
- package/dist/workflow/workflow-event-emitter.js.map +1 -0
- package/package.json +8 -6
- package/dist/public/assets/index-CQoCSnhl.css +0 -1
- package/dist/public/assets/index-iWE3gSYw.js +0 -758
- package/dist/public/assets/index-iWE3gSYw.js.map +0 -1
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency Graph Analyzer for Workflow System
|
|
3
|
+
*
|
|
4
|
+
* Analyzes issue dependencies using blocks/depends-on relationships
|
|
5
|
+
* to determine execution order and detect cycles.
|
|
6
|
+
*/
|
|
7
|
+
import { getOutgoingRelationships } from "@sudocode-ai/cli/dist/operations/relationships.js";
|
|
8
|
+
// =============================================================================
|
|
9
|
+
// Graph Building
|
|
10
|
+
// =============================================================================
|
|
11
|
+
/**
|
|
12
|
+
* Build a dependency graph from issue relationships.
|
|
13
|
+
*
|
|
14
|
+
* Examines `blocks` and `depends-on` relationships between issues
|
|
15
|
+
* to create an adjacency list representation.
|
|
16
|
+
*
|
|
17
|
+
* @param db - Database connection
|
|
18
|
+
* @param issueIds - Issue IDs to include in the graph
|
|
19
|
+
* @returns Internal graph representation
|
|
20
|
+
*/
|
|
21
|
+
export function buildDependencyGraph(db, issueIds) {
|
|
22
|
+
// Deduplicate and create a set for fast lookup
|
|
23
|
+
const issueIdSet = new Set(issueIds);
|
|
24
|
+
const uniqueIssueIds = Array.from(issueIdSet);
|
|
25
|
+
// Initialize data structures
|
|
26
|
+
const edges = [];
|
|
27
|
+
const adjacencyList = new Map();
|
|
28
|
+
const inDegree = new Map();
|
|
29
|
+
// Initialize all nodes with empty adjacency and zero in-degree
|
|
30
|
+
for (const id of uniqueIssueIds) {
|
|
31
|
+
adjacencyList.set(id, []);
|
|
32
|
+
inDegree.set(id, 0);
|
|
33
|
+
}
|
|
34
|
+
// Process each issue to find its relationships
|
|
35
|
+
for (const issueId of uniqueIssueIds) {
|
|
36
|
+
// Get outgoing "blocks" relationships: this issue blocks others
|
|
37
|
+
// Edge direction: blocker -> blocked
|
|
38
|
+
const blocksRels = getOutgoingRelationships(db, issueId, "issue", "blocks");
|
|
39
|
+
for (const rel of blocksRels) {
|
|
40
|
+
// Only include edges where both ends are in our issue set
|
|
41
|
+
if (issueIdSet.has(rel.to_id)) {
|
|
42
|
+
edges.push([issueId, rel.to_id]);
|
|
43
|
+
adjacencyList.get(issueId).push(rel.to_id);
|
|
44
|
+
inDegree.set(rel.to_id, (inDegree.get(rel.to_id) ?? 0) + 1);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
// Get incoming "depends-on" relationships: this issue depends on others
|
|
48
|
+
// If A depends-on B, then B blocks A, so edge is B -> A
|
|
49
|
+
const dependsOnRels = getOutgoingRelationships(db, issueId, "issue", "depends-on");
|
|
50
|
+
for (const rel of dependsOnRels) {
|
|
51
|
+
// rel.to_id is what this issue depends on (the blocker)
|
|
52
|
+
// Edge direction: blocker (rel.to_id) -> blocked (issueId)
|
|
53
|
+
if (issueIdSet.has(rel.to_id)) {
|
|
54
|
+
// Avoid duplicate edges
|
|
55
|
+
const existingEdges = adjacencyList.get(rel.to_id) ?? [];
|
|
56
|
+
if (!existingEdges.includes(issueId)) {
|
|
57
|
+
edges.push([rel.to_id, issueId]);
|
|
58
|
+
adjacencyList.get(rel.to_id).push(issueId);
|
|
59
|
+
inDegree.set(issueId, (inDegree.get(issueId) ?? 0) + 1);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
issueIds: uniqueIssueIds,
|
|
66
|
+
edges,
|
|
67
|
+
adjacencyList,
|
|
68
|
+
inDegree,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
// =============================================================================
|
|
72
|
+
// Topological Sort (Kahn's Algorithm)
|
|
73
|
+
// =============================================================================
|
|
74
|
+
/**
|
|
75
|
+
* Perform topological sort using Kahn's algorithm.
|
|
76
|
+
*
|
|
77
|
+
* Returns issues in a valid execution order where all dependencies
|
|
78
|
+
* come before dependents. Detects cycles if present.
|
|
79
|
+
*
|
|
80
|
+
* @param adjacencyList - Map of issueId -> issues it blocks
|
|
81
|
+
* @param inDegree - Map of issueId -> number of blockers
|
|
82
|
+
* @returns Sorted order and cycle information
|
|
83
|
+
*/
|
|
84
|
+
export function topologicalSort(adjacencyList, inDegree) {
|
|
85
|
+
const sorted = [];
|
|
86
|
+
// Create a working copy of in-degrees (we'll modify this)
|
|
87
|
+
const workingInDegree = new Map(inDegree);
|
|
88
|
+
// Initialize queue with all nodes having in-degree 0 (no blockers)
|
|
89
|
+
const queue = [];
|
|
90
|
+
for (const [id, degree] of workingInDegree) {
|
|
91
|
+
if (degree === 0) {
|
|
92
|
+
queue.push(id);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
// Process nodes in topological order
|
|
96
|
+
while (queue.length > 0) {
|
|
97
|
+
const current = queue.shift();
|
|
98
|
+
sorted.push(current);
|
|
99
|
+
// For each issue that this one blocks, decrement their in-degree
|
|
100
|
+
const neighbors = adjacencyList.get(current) ?? [];
|
|
101
|
+
for (const neighbor of neighbors) {
|
|
102
|
+
const newDegree = (workingInDegree.get(neighbor) ?? 0) - 1;
|
|
103
|
+
workingInDegree.set(neighbor, newDegree);
|
|
104
|
+
// If neighbor now has no blockers, it's ready to process
|
|
105
|
+
if (newDegree === 0) {
|
|
106
|
+
queue.push(neighbor);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Check if we processed all nodes
|
|
111
|
+
const totalNodes = adjacencyList.size;
|
|
112
|
+
if (sorted.length === totalNodes) {
|
|
113
|
+
return { sorted, cycles: null, valid: true };
|
|
114
|
+
}
|
|
115
|
+
// Cycles exist - find them
|
|
116
|
+
const cycles = findCycles(adjacencyList, workingInDegree);
|
|
117
|
+
return { sorted, cycles, valid: false };
|
|
118
|
+
}
|
|
119
|
+
// =============================================================================
|
|
120
|
+
// Cycle Detection
|
|
121
|
+
// =============================================================================
|
|
122
|
+
/**
|
|
123
|
+
* Find all cycles in the graph using DFS.
|
|
124
|
+
*
|
|
125
|
+
* Called when topological sort fails to process all nodes,
|
|
126
|
+
* indicating cycles exist.
|
|
127
|
+
*
|
|
128
|
+
* @param adjacencyList - Map of issueId -> issues it blocks
|
|
129
|
+
* @param remainingInDegree - In-degrees after partial topo sort
|
|
130
|
+
* @returns Array of cycles, each cycle is an array of issue IDs
|
|
131
|
+
*/
|
|
132
|
+
function findCycles(adjacencyList, remainingInDegree) {
|
|
133
|
+
const cycles = [];
|
|
134
|
+
// Nodes still in cycles have remaining in-degree > 0
|
|
135
|
+
const nodesInCycles = new Set();
|
|
136
|
+
for (const [id, degree] of remainingInDegree) {
|
|
137
|
+
if (degree > 0) {
|
|
138
|
+
nodesInCycles.add(id);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
if (nodesInCycles.size === 0) {
|
|
142
|
+
return cycles;
|
|
143
|
+
}
|
|
144
|
+
// Use DFS to find individual cycles
|
|
145
|
+
const visited = new Set();
|
|
146
|
+
const recursionStack = new Set();
|
|
147
|
+
const path = [];
|
|
148
|
+
function dfs(node) {
|
|
149
|
+
if (recursionStack.has(node)) {
|
|
150
|
+
// Found a cycle - extract it from the path
|
|
151
|
+
const cycleStart = path.indexOf(node);
|
|
152
|
+
if (cycleStart !== -1) {
|
|
153
|
+
const cycle = path.slice(cycleStart);
|
|
154
|
+
cycle.push(node); // Complete the cycle
|
|
155
|
+
cycles.push(cycle);
|
|
156
|
+
}
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
if (visited.has(node) || !nodesInCycles.has(node)) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
visited.add(node);
|
|
163
|
+
recursionStack.add(node);
|
|
164
|
+
path.push(node);
|
|
165
|
+
const neighbors = adjacencyList.get(node) ?? [];
|
|
166
|
+
for (const neighbor of neighbors) {
|
|
167
|
+
if (nodesInCycles.has(neighbor)) {
|
|
168
|
+
dfs(neighbor);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
path.pop();
|
|
172
|
+
recursionStack.delete(node);
|
|
173
|
+
}
|
|
174
|
+
// Start DFS from each unvisited node in cycles
|
|
175
|
+
for (const node of nodesInCycles) {
|
|
176
|
+
if (!visited.has(node)) {
|
|
177
|
+
dfs(node);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return cycles;
|
|
181
|
+
}
|
|
182
|
+
// =============================================================================
|
|
183
|
+
// Parallel Groups
|
|
184
|
+
// =============================================================================
|
|
185
|
+
/**
|
|
186
|
+
* Group issues by topological level for parallel execution.
|
|
187
|
+
*
|
|
188
|
+
* Issues at the same level have no dependencies between them
|
|
189
|
+
* and can be executed concurrently.
|
|
190
|
+
*
|
|
191
|
+
* @param sortedIds - Issue IDs in topological order
|
|
192
|
+
* @param adjacencyList - Map of issueId -> issues it blocks
|
|
193
|
+
* @param inDegree - Original in-degrees
|
|
194
|
+
* @returns Array of groups, each group can run in parallel
|
|
195
|
+
*/
|
|
196
|
+
export function findParallelGroups(sortedIds, adjacencyList, inDegree) {
|
|
197
|
+
if (sortedIds.length === 0) {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
const groups = [];
|
|
201
|
+
// Track the level (distance from root) for each node
|
|
202
|
+
const level = new Map();
|
|
203
|
+
// Nodes with in-degree 0 are at level 0
|
|
204
|
+
for (const id of sortedIds) {
|
|
205
|
+
if ((inDegree.get(id) ?? 0) === 0) {
|
|
206
|
+
level.set(id, 0);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
// Process in topological order to compute levels
|
|
210
|
+
for (const id of sortedIds) {
|
|
211
|
+
const currentLevel = level.get(id) ?? 0;
|
|
212
|
+
// Update levels of nodes this one blocks
|
|
213
|
+
const neighbors = adjacencyList.get(id) ?? [];
|
|
214
|
+
for (const neighbor of neighbors) {
|
|
215
|
+
const neighborLevel = level.get(neighbor) ?? 0;
|
|
216
|
+
// Neighbor's level is at least current + 1
|
|
217
|
+
level.set(neighbor, Math.max(neighborLevel, currentLevel + 1));
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
// Group nodes by level
|
|
221
|
+
const maxLevel = Math.max(...Array.from(level.values()), 0);
|
|
222
|
+
for (let l = 0; l <= maxLevel; l++) {
|
|
223
|
+
const group = [];
|
|
224
|
+
for (const id of sortedIds) {
|
|
225
|
+
if (level.get(id) === l) {
|
|
226
|
+
group.push(id);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
if (group.length > 0) {
|
|
230
|
+
groups.push(group);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
return groups;
|
|
234
|
+
}
|
|
235
|
+
// =============================================================================
|
|
236
|
+
// Public API
|
|
237
|
+
// =============================================================================
|
|
238
|
+
/**
|
|
239
|
+
* Analyze dependencies between issues and return a complete dependency graph.
|
|
240
|
+
*
|
|
241
|
+
* This is the main entry point for workflow dependency analysis.
|
|
242
|
+
*
|
|
243
|
+
* @param db - Database connection
|
|
244
|
+
* @param issueIds - Issue IDs to analyze
|
|
245
|
+
* @returns Complete dependency graph with topological order and parallel groups
|
|
246
|
+
*/
|
|
247
|
+
export function analyzeDependencies(db, issueIds) {
|
|
248
|
+
// Build the graph
|
|
249
|
+
const graph = buildDependencyGraph(db, issueIds);
|
|
250
|
+
// Perform topological sort
|
|
251
|
+
const sortResult = topologicalSort(graph.adjacencyList, graph.inDegree);
|
|
252
|
+
// Compute parallel groups (only if no cycles)
|
|
253
|
+
const parallelGroups = sortResult.valid
|
|
254
|
+
? findParallelGroups(sortResult.sorted, graph.adjacencyList, graph.inDegree)
|
|
255
|
+
: [];
|
|
256
|
+
return {
|
|
257
|
+
issueIds: graph.issueIds,
|
|
258
|
+
edges: graph.edges,
|
|
259
|
+
topologicalOrder: sortResult.sorted,
|
|
260
|
+
cycles: sortResult.cycles,
|
|
261
|
+
parallelGroups,
|
|
262
|
+
};
|
|
263
|
+
}
|
|
264
|
+
//# sourceMappingURL=dependency-analyzer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dependency-analyzer.js","sourceRoot":"","sources":["../../src/workflow/dependency-analyzer.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAC;AAgC7F,gFAAgF;AAChF,iBAAiB;AACjB,gFAAgF;AAEhF;;;;;;;;;GASG;AACH,MAAM,UAAU,oBAAoB,CAClC,EAAqB,EACrB,QAAkB;IAElB,+CAA+C;IAC/C,MAAM,UAAU,GAAG,IAAI,GAAG,CAAC,QAAQ,CAAC,CAAC;IACrC,MAAM,cAAc,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAE9C,6BAA6B;IAC7B,MAAM,KAAK,GAA4B,EAAE,CAAC;IAC1C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAoB,CAAC;IAClD,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE3C,+DAA+D;IAC/D,KAAK,MAAM,EAAE,IAAI,cAAc,EAAE,CAAC;QAChC,aAAa,CAAC,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;QAC1B,QAAQ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cAAc;KACf,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Orchestrator Workflow Engine
|
|
3
|
+
*
|
|
4
|
+
* Agent-managed workflow execution. The orchestrator is itself an execution
|
|
5
|
+
* (Claude Code agent) that controls workflow steps via MCP tools.
|
|
6
|
+
*
|
|
7
|
+
* Key differences from SequentialWorkflowEngine:
|
|
8
|
+
* - No internal execution loop - orchestrator agent handles execution
|
|
9
|
+
* - Wakeup mechanism - events trigger follow-up executions
|
|
10
|
+
* - MCP tools for step control - orchestrator uses workflow_* and execute_* tools
|
|
11
|
+
*/
|
|
12
|
+
import type Database from "better-sqlite3";
|
|
13
|
+
import type { Workflow, WorkflowSource, WorkflowConfig } from "@sudocode-ai/types";
|
|
14
|
+
import { BaseWorkflowEngine } from "../base-workflow-engine.js";
|
|
15
|
+
import type { WorkflowEventEmitter } from "../workflow-event-emitter.js";
|
|
16
|
+
import type { ExecutionService } from "../../services/execution-service.js";
|
|
17
|
+
import type { ExecutionLifecycleService } from "../../services/execution-lifecycle.js";
|
|
18
|
+
import type { WorkflowWakeupService } from "../services/wakeup-service.js";
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for the orchestrator engine.
|
|
21
|
+
*/
|
|
22
|
+
export interface OrchestratorEngineConfig {
|
|
23
|
+
/** Path to the repository root */
|
|
24
|
+
repoPath: string;
|
|
25
|
+
/** Path to the database file */
|
|
26
|
+
dbPath: string;
|
|
27
|
+
/** Path to the MCP server entry point */
|
|
28
|
+
mcpServerPath?: string;
|
|
29
|
+
/** Base URL of the server for MCP API calls (e.g., http://localhost:3000) */
|
|
30
|
+
serverUrl: string;
|
|
31
|
+
/** Project ID for API calls */
|
|
32
|
+
projectId: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Orchestrator Workflow Engine implementation.
|
|
36
|
+
*
|
|
37
|
+
* This engine spawns an orchestrator agent (Claude Code execution) that controls
|
|
38
|
+
* the workflow using MCP tools. The orchestrator makes decisions about:
|
|
39
|
+
* - Which issues to execute
|
|
40
|
+
* - How to handle failures
|
|
41
|
+
* - When to escalate to the user
|
|
42
|
+
*
|
|
43
|
+
* Events from step executions trigger "wakeups" - follow-up messages to the
|
|
44
|
+
* orchestrator that inform it of completed work.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const engine = new OrchestratorWorkflowEngine({
|
|
49
|
+
* db,
|
|
50
|
+
* executionService,
|
|
51
|
+
* wakeupService,
|
|
52
|
+
* config: {
|
|
53
|
+
* repoPath: '/path/to/repo',
|
|
54
|
+
* dbPath: '/path/to/.sudocode/cache.db',
|
|
55
|
+
* },
|
|
56
|
+
* });
|
|
57
|
+
*
|
|
58
|
+
* // Create workflow from a goal
|
|
59
|
+
* const workflow = await engine.createWorkflow({
|
|
60
|
+
* type: "goal",
|
|
61
|
+
* goal: "Implement user authentication with OAuth"
|
|
62
|
+
* });
|
|
63
|
+
*
|
|
64
|
+
* // Start orchestrator
|
|
65
|
+
* await engine.startWorkflow(workflow.id);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
export declare class OrchestratorWorkflowEngine extends BaseWorkflowEngine {
|
|
69
|
+
private executionService;
|
|
70
|
+
private lifecycleService;
|
|
71
|
+
private wakeupService;
|
|
72
|
+
private promptBuilder;
|
|
73
|
+
private config;
|
|
74
|
+
private unregisterExecutionCallback?;
|
|
75
|
+
constructor(deps: {
|
|
76
|
+
db: Database.Database;
|
|
77
|
+
executionService: ExecutionService;
|
|
78
|
+
lifecycleService: ExecutionLifecycleService;
|
|
79
|
+
wakeupService: WorkflowWakeupService;
|
|
80
|
+
eventEmitter?: WorkflowEventEmitter;
|
|
81
|
+
config: OrchestratorEngineConfig;
|
|
82
|
+
});
|
|
83
|
+
/**
|
|
84
|
+
* Update the server URL after dynamic port discovery.
|
|
85
|
+
* Called by ProjectContext when the actual server port is known.
|
|
86
|
+
*/
|
|
87
|
+
setServerUrl(serverUrl: string): void;
|
|
88
|
+
/**
|
|
89
|
+
* Get the wakeup service for registering await conditions.
|
|
90
|
+
* Used by the API endpoint for await_events MCP tool.
|
|
91
|
+
*/
|
|
92
|
+
getWakeupService(): WorkflowWakeupService;
|
|
93
|
+
/**
|
|
94
|
+
* Set up callbacks to record workflow events when executions complete/fail.
|
|
95
|
+
*
|
|
96
|
+
* When an execution that belongs to a workflow completes or fails, we need to:
|
|
97
|
+
* 1. Find the corresponding workflow step
|
|
98
|
+
* 2. Update the step status
|
|
99
|
+
* 3. Record a workflow event (step_completed or step_failed)
|
|
100
|
+
* 4. Trigger a wakeup so the orchestrator can react
|
|
101
|
+
*/
|
|
102
|
+
private setupExecutionCallbacks;
|
|
103
|
+
/**
|
|
104
|
+
* Clean up the execution callback when the engine is disposed.
|
|
105
|
+
*/
|
|
106
|
+
dispose(): void;
|
|
107
|
+
/**
|
|
108
|
+
* Create a new workflow from a source definition.
|
|
109
|
+
*
|
|
110
|
+
* For orchestrator workflows, goal-based sources create empty workflows
|
|
111
|
+
* that the orchestrator populates dynamically.
|
|
112
|
+
*
|
|
113
|
+
* @param source - How to determine workflow scope (spec, issues, root_issue, or goal)
|
|
114
|
+
* @param config - Optional configuration overrides
|
|
115
|
+
* @returns The created workflow
|
|
116
|
+
* @throws WorkflowCycleError if dependency cycles are detected
|
|
117
|
+
*/
|
|
118
|
+
createWorkflow(source: WorkflowSource, config?: Partial<WorkflowConfig>): Promise<Workflow>;
|
|
119
|
+
/**
|
|
120
|
+
* Start executing a pending workflow.
|
|
121
|
+
*
|
|
122
|
+
* Spawns an orchestrator execution (Claude Code agent) with workflow MCP tools.
|
|
123
|
+
* The orchestrator will use these tools to control step execution.
|
|
124
|
+
*
|
|
125
|
+
* @param workflowId - The workflow to start
|
|
126
|
+
* @throws WorkflowNotFoundError if workflow doesn't exist
|
|
127
|
+
* @throws WorkflowStateError if workflow is not in pending state
|
|
128
|
+
*/
|
|
129
|
+
startWorkflow(workflowId: string): Promise<void>;
|
|
130
|
+
/**
|
|
131
|
+
* Pause a running workflow.
|
|
132
|
+
*
|
|
133
|
+
* Sets pause status and records an event. The orchestrator will be notified
|
|
134
|
+
* via wakeup when it checks workflow status.
|
|
135
|
+
*
|
|
136
|
+
* @param workflowId - The workflow to pause
|
|
137
|
+
* @throws WorkflowNotFoundError if workflow doesn't exist
|
|
138
|
+
* @throws WorkflowStateError if workflow is not running
|
|
139
|
+
*/
|
|
140
|
+
pauseWorkflow(workflowId: string): Promise<void>;
|
|
141
|
+
/**
|
|
142
|
+
* Resume a paused workflow.
|
|
143
|
+
*
|
|
144
|
+
* Uses Claude Code's session resume to continue the orchestrator from where it left off.
|
|
145
|
+
* This preserves the full conversation history and context.
|
|
146
|
+
*
|
|
147
|
+
* @param workflowId - The workflow to resume
|
|
148
|
+
* @param message - Optional message to send with the resume (defaults to "Workflow resumed. Continue execution.")
|
|
149
|
+
* @throws WorkflowNotFoundError if workflow doesn't exist
|
|
150
|
+
* @throws WorkflowStateError if workflow is not paused
|
|
151
|
+
*/
|
|
152
|
+
resumeWorkflow(workflowId: string, message?: string): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Cancel a workflow, stopping the orchestrator and any running executions.
|
|
155
|
+
*
|
|
156
|
+
* @param workflowId - The workflow to cancel
|
|
157
|
+
* @throws WorkflowNotFoundError if workflow doesn't exist
|
|
158
|
+
* @throws WorkflowStateError if workflow is already completed/failed/cancelled
|
|
159
|
+
*/
|
|
160
|
+
cancelWorkflow(workflowId: string): Promise<void>;
|
|
161
|
+
/**
|
|
162
|
+
* Retry a failed step.
|
|
163
|
+
*
|
|
164
|
+
* Records an event for the orchestrator to handle.
|
|
165
|
+
* The orchestrator decides how to actually retry.
|
|
166
|
+
*
|
|
167
|
+
* @param workflowId - The workflow containing the step
|
|
168
|
+
* @param stepId - The step to retry
|
|
169
|
+
* @throws WorkflowNotFoundError if workflow doesn't exist
|
|
170
|
+
* @throws WorkflowStepNotFoundError if step doesn't exist
|
|
171
|
+
*/
|
|
172
|
+
retryStep(workflowId: string, stepId: string): Promise<void>;
|
|
173
|
+
/**
|
|
174
|
+
* Skip a step.
|
|
175
|
+
*
|
|
176
|
+
* Records an event for the orchestrator to handle.
|
|
177
|
+
* The orchestrator decides how to handle dependents.
|
|
178
|
+
*
|
|
179
|
+
* @param workflowId - The workflow containing the step
|
|
180
|
+
* @param stepId - The step to skip
|
|
181
|
+
* @param reason - Optional reason for skipping
|
|
182
|
+
* @throws WorkflowNotFoundError if workflow doesn't exist
|
|
183
|
+
* @throws WorkflowStepNotFoundError if step doesn't exist
|
|
184
|
+
*/
|
|
185
|
+
skipStep(workflowId: string, stepId: string, reason?: string): Promise<void>;
|
|
186
|
+
/**
|
|
187
|
+
* Trigger a wakeup for an escalation response.
|
|
188
|
+
*
|
|
189
|
+
* Called by the API when a user responds to an escalation.
|
|
190
|
+
* Immediately triggers the orchestrator to resume with the response.
|
|
191
|
+
*
|
|
192
|
+
* @param workflowId - The workflow to wake up
|
|
193
|
+
*/
|
|
194
|
+
triggerEscalationWakeup(workflowId: string): Promise<void>;
|
|
195
|
+
/**
|
|
196
|
+
* Spawn an orchestrator execution (Claude Code agent).
|
|
197
|
+
*
|
|
198
|
+
* The orchestrator is given:
|
|
199
|
+
* - Workflow MCP tools for control
|
|
200
|
+
* - Initial prompt with workflow context
|
|
201
|
+
* - Access to sudocode MCP tools for issue management
|
|
202
|
+
*/
|
|
203
|
+
private spawnOrchestrator;
|
|
204
|
+
/**
|
|
205
|
+
* Build the orchestrator agent configuration.
|
|
206
|
+
*
|
|
207
|
+
* Configures MCP servers for workflow control and sudocode access.
|
|
208
|
+
* Enables dangerouslySkipPermissions for automated workflow execution.
|
|
209
|
+
*/
|
|
210
|
+
private buildOrchestratorConfig;
|
|
211
|
+
/**
|
|
212
|
+
* Get issues for the workflow (for initial prompt).
|
|
213
|
+
*/
|
|
214
|
+
private getIssuesForWorkflow;
|
|
215
|
+
/**
|
|
216
|
+
* Cancel ALL running executions for a workflow.
|
|
217
|
+
* This includes:
|
|
218
|
+
* 1. The entire orchestrator execution chain (root + all follow-ups)
|
|
219
|
+
* 2. All step executions linked to this workflow
|
|
220
|
+
*/
|
|
221
|
+
private cancelAllWorkflowExecutions;
|
|
222
|
+
/**
|
|
223
|
+
* Recover orphaned workflows on server restart.
|
|
224
|
+
*
|
|
225
|
+
* Finds workflows in 'running' status whose orchestrator execution
|
|
226
|
+
* is no longer running, and triggers a wakeup to resume them.
|
|
227
|
+
*/
|
|
228
|
+
recoverOrphanedWorkflows(): Promise<void>;
|
|
229
|
+
/**
|
|
230
|
+
* Mark stale running executions as failed.
|
|
231
|
+
*
|
|
232
|
+
* Called during recovery to clean up executions that were running
|
|
233
|
+
* when the server crashed.
|
|
234
|
+
*/
|
|
235
|
+
markStaleExecutionsAsFailed(): Promise<void>;
|
|
236
|
+
}
|
|
237
|
+
//# sourceMappingURL=orchestrator-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orchestrator-engine.d.ts","sourceRoot":"","sources":["../../../src/workflow/engines/orchestrator-engine.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,OAAO,KAAK,QAAQ,MAAM,gBAAgB,CAAC;AAI3C,OAAO,KAAK,EACV,QAAQ,EAER,cAAc,EACd,cAAc,EAIf,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAMhE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AACzE,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AACvF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAY3E;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,kCAAkC;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,gCA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