@stackmemoryai/stackmemory 0.3.22 → 0.3.24

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.
Files changed (39) hide show
  1. package/dist/cli/commands/ralph.js +294 -0
  2. package/dist/cli/commands/ralph.js.map +7 -0
  3. package/dist/cli/index.js +2 -0
  4. package/dist/cli/index.js.map +2 -2
  5. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +586 -0
  6. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +7 -0
  7. package/dist/integrations/ralph/context/context-budget-manager.js +297 -0
  8. package/dist/integrations/ralph/context/context-budget-manager.js.map +7 -0
  9. package/dist/integrations/ralph/context/stackmemory-context-loader.js +356 -0
  10. package/dist/integrations/ralph/context/stackmemory-context-loader.js.map +7 -0
  11. package/dist/integrations/ralph/index.js +14 -0
  12. package/dist/integrations/ralph/index.js.map +7 -0
  13. package/dist/integrations/ralph/learning/pattern-learner.js +397 -0
  14. package/dist/integrations/ralph/learning/pattern-learner.js.map +7 -0
  15. package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js +444 -0
  16. package/dist/integrations/ralph/lifecycle/iteration-lifecycle.js.map +7 -0
  17. package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js +459 -0
  18. package/dist/integrations/ralph/orchestration/multi-loop-orchestrator.js.map +7 -0
  19. package/dist/integrations/ralph/performance/performance-optimizer.js +354 -0
  20. package/dist/integrations/ralph/performance/performance-optimizer.js.map +7 -0
  21. package/dist/integrations/ralph/ralph-integration-demo.js +178 -0
  22. package/dist/integrations/ralph/ralph-integration-demo.js.map +7 -0
  23. package/dist/integrations/ralph/state/state-reconciler.js +400 -0
  24. package/dist/integrations/ralph/state/state-reconciler.js.map +7 -0
  25. package/dist/integrations/ralph/swarm/swarm-coordinator.js +487 -0
  26. package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +7 -0
  27. package/dist/integrations/ralph/types.js +1 -0
  28. package/dist/integrations/ralph/types.js.map +7 -0
  29. package/dist/integrations/ralph/visualization/ralph-debugger.js +581 -0
  30. package/dist/integrations/ralph/visualization/ralph-debugger.js.map +7 -0
  31. package/package.json +1 -1
  32. package/scripts/deploy-ralph-swarm.sh +365 -0
  33. package/scripts/ralph-integration-test.js +274 -0
  34. package/scripts/ralph-loop-implementation.js +404 -0
  35. package/scripts/swarm-monitor.js +509 -0
  36. package/scripts/test-parallel-swarms.js +443 -0
  37. package/scripts/testing/ralph-cli-test.js +88 -0
  38. package/scripts/testing/ralph-integration-validation.js +727 -0
  39. package/scripts/testing/ralph-swarm-test-scenarios.js +613 -0
@@ -0,0 +1,459 @@
1
+ import { v4 as uuidv4 } from "uuid";
2
+ import { logger } from "../../../core/monitoring/logger.js";
3
+ import { FrameManager } from "../../../core/context/frame-manager.js";
4
+ import { sessionManager } from "../../../core/session/index.js";
5
+ import { RalphStackMemoryBridge } from "../bridge/ralph-stackmemory-bridge.js";
6
+ class MultiLoopOrchestrator {
7
+ frameManager;
8
+ activeTasks = /* @__PURE__ */ new Map();
9
+ activeLoops = /* @__PURE__ */ new Map();
10
+ config;
11
+ constructor(config) {
12
+ this.config = {
13
+ maxConcurrentLoops: 3,
14
+ dependencyResolutionTimeout: 3e4,
15
+ // 30 seconds
16
+ enableAdaptivePlanning: true,
17
+ sharedContextEnabled: true,
18
+ fallbackStrategy: "sequential",
19
+ ...config
20
+ };
21
+ logger.info("Multi-loop orchestrator initialized", this.config);
22
+ }
23
+ async initialize() {
24
+ try {
25
+ await sessionManager.initialize();
26
+ const session = await sessionManager.getOrCreateSession({});
27
+ if (session.database) {
28
+ this.frameManager = new FrameManager(session.database, session.projectId);
29
+ }
30
+ logger.info("Orchestrator initialized successfully");
31
+ } catch (error) {
32
+ logger.error("Failed to initialize orchestrator", error);
33
+ throw error;
34
+ }
35
+ }
36
+ /**
37
+ * Break down complex task into manageable loops
38
+ */
39
+ async orchestrateComplexTask(description, criteria, options) {
40
+ logger.info("Orchestrating complex task", {
41
+ task: description.substring(0, 100),
42
+ criteriaCount: criteria.length,
43
+ maxLoops: options?.maxLoops || this.config.maxConcurrentLoops
44
+ });
45
+ const orchestrationId = uuidv4();
46
+ try {
47
+ const breakdown = options?.customBreakdown || await this.analyzeAndBreakdownTask(description, criteria);
48
+ const executionPlan = await this.createExecutionPlan(breakdown, options);
49
+ const dependencyErrors = this.validateDependencies(executionPlan);
50
+ if (dependencyErrors.length > 0) {
51
+ throw new Error(`Dependency errors: ${dependencyErrors.join(", ")}`);
52
+ }
53
+ const orchestratedTask = {
54
+ id: orchestrationId,
55
+ description,
56
+ breakdown,
57
+ executionPlan,
58
+ status: "planning",
59
+ startTime: Date.now(),
60
+ loops: /* @__PURE__ */ new Map(),
61
+ sharedContext: {}
62
+ };
63
+ this.activeTasks.set(orchestrationId, orchestratedTask);
64
+ const result = await this.executeOrchestration(orchestratedTask);
65
+ logger.info("Complex task orchestration completed", {
66
+ orchestrationId,
67
+ status: result.success ? "success" : "failure",
68
+ loopsExecuted: result.completedLoops.length,
69
+ duration: Date.now() - orchestratedTask.startTime
70
+ });
71
+ return result;
72
+ } catch (error) {
73
+ logger.error("Orchestration failed", error);
74
+ throw error;
75
+ } finally {
76
+ this.activeTasks.delete(orchestrationId);
77
+ }
78
+ }
79
+ /**
80
+ * Execute coordinated parallel loops
81
+ */
82
+ async executeParallelLoops(tasks, coordination) {
83
+ logger.info(`Executing ${tasks.length} parallel loops`);
84
+ const execution = {
85
+ id: uuidv4(),
86
+ tasks,
87
+ startTime: Date.now(),
88
+ results: /* @__PURE__ */ new Map(),
89
+ sharedState: coordination?.sharedState || {}
90
+ };
91
+ const promises = tasks.map((task) => this.executeParallelTask(task, execution));
92
+ try {
93
+ await Promise.allSettled(promises);
94
+ execution.endTime = Date.now();
95
+ execution.status = Array.from(execution.results.values()).every((r) => r.success) ? "success" : "partial";
96
+ return execution;
97
+ } catch (error) {
98
+ logger.error("Parallel execution failed", error);
99
+ execution.status = "failed";
100
+ execution.error = error.message;
101
+ return execution;
102
+ }
103
+ }
104
+ /**
105
+ * Analyze and break down complex task
106
+ */
107
+ async analyzeAndBreakdownTask(description, criteria) {
108
+ const complexity = this.assessTaskComplexity(description);
109
+ if (complexity.score < 5) {
110
+ return [{
111
+ id: uuidv4(),
112
+ title: description,
113
+ description,
114
+ criteria,
115
+ priority: 1,
116
+ estimatedIterations: 3,
117
+ dependencies: [],
118
+ type: "single"
119
+ }];
120
+ }
121
+ const subtasks = [];
122
+ if (this.needsSetup(description)) {
123
+ subtasks.push({
124
+ id: uuidv4(),
125
+ title: "Project Setup",
126
+ description: "Set up project structure and dependencies",
127
+ criteria: ["Project structure created", "Dependencies installed"],
128
+ priority: 1,
129
+ estimatedIterations: 2,
130
+ dependencies: [],
131
+ type: "setup"
132
+ });
133
+ }
134
+ const coreTask = this.extractCoreTask(description);
135
+ if (coreTask) {
136
+ subtasks.push({
137
+ id: uuidv4(),
138
+ title: "Core Implementation",
139
+ description: coreTask,
140
+ criteria: criteria.filter((c) => c.toLowerCase().includes("function") || c.toLowerCase().includes("implement")),
141
+ priority: 2,
142
+ estimatedIterations: 5,
143
+ dependencies: subtasks.length > 0 ? [subtasks[0].id] : [],
144
+ type: "implementation"
145
+ });
146
+ }
147
+ if (this.needsTesting(criteria)) {
148
+ subtasks.push({
149
+ id: uuidv4(),
150
+ title: "Testing Implementation",
151
+ description: "Create comprehensive tests",
152
+ criteria: criteria.filter((c) => c.toLowerCase().includes("test")),
153
+ priority: 3,
154
+ estimatedIterations: 3,
155
+ dependencies: subtasks.length > 0 ? [subtasks[subtasks.length - 1].id] : [],
156
+ type: "testing"
157
+ });
158
+ }
159
+ if (this.needsDocumentation(criteria)) {
160
+ subtasks.push({
161
+ id: uuidv4(),
162
+ title: "Documentation",
163
+ description: "Create documentation and examples",
164
+ criteria: criteria.filter((c) => c.toLowerCase().includes("doc")),
165
+ priority: 4,
166
+ estimatedIterations: 2,
167
+ dependencies: [],
168
+ type: "documentation"
169
+ });
170
+ }
171
+ return subtasks.length > 0 ? subtasks : [{
172
+ id: uuidv4(),
173
+ title: description,
174
+ description,
175
+ criteria,
176
+ priority: 1,
177
+ estimatedIterations: Math.min(8, Math.max(3, complexity.score)),
178
+ dependencies: [],
179
+ type: "single"
180
+ }];
181
+ }
182
+ /**
183
+ * Create execution plan from breakdown
184
+ */
185
+ async createExecutionPlan(breakdown, options) {
186
+ const plan = {
187
+ phases: [],
188
+ totalEstimatedTime: 0,
189
+ parallelizable: !options?.forceSequential && breakdown.length > 1
190
+ };
191
+ if (options?.forceSequential || !this.canExecuteInParallel(breakdown)) {
192
+ plan.phases = breakdown.map((task, index) => ({
193
+ id: `phase-${index + 1}`,
194
+ tasks: [task],
195
+ dependencies: index > 0 ? [`phase-${index}`] : [],
196
+ parallelExecution: false
197
+ }));
198
+ } else {
199
+ const phases = this.groupTasksByDependencies(breakdown);
200
+ plan.phases = phases;
201
+ }
202
+ plan.totalEstimatedTime = plan.phases.reduce(
203
+ (sum, phase) => sum + Math.max(...phase.tasks.map((t) => t.estimatedIterations)) * 3e4,
204
+ // 30s per iteration
205
+ 0
206
+ );
207
+ return plan;
208
+ }
209
+ /**
210
+ * Execute the orchestration plan
211
+ */
212
+ async executeOrchestration(task) {
213
+ const result = {
214
+ orchestrationId: task.id,
215
+ success: false,
216
+ completedLoops: [],
217
+ failedLoops: [],
218
+ totalDuration: 0,
219
+ insights: []
220
+ };
221
+ try {
222
+ task.status = "executing";
223
+ for (const phase of task.executionPlan.phases) {
224
+ logger.info(`Executing phase ${phase.id} with ${phase.tasks.length} tasks`);
225
+ if (phase.parallelExecution && phase.tasks.length > 1) {
226
+ const parallelResult = await this.executeParallelLoops(phase.tasks);
227
+ for (const [taskId, taskResult] of parallelResult.results) {
228
+ if (taskResult.success) {
229
+ result.completedLoops.push(taskResult.loopId);
230
+ } else {
231
+ result.failedLoops.push({ loopId: taskResult.loopId, error: taskResult.error || "Unknown error" });
232
+ }
233
+ }
234
+ } else {
235
+ for (const phaseTask of phase.tasks) {
236
+ const loopResult = await this.executeTaskLoop(phaseTask, task);
237
+ if (loopResult.success) {
238
+ result.completedLoops.push(loopResult.loopId);
239
+ if (this.config.sharedContextEnabled) {
240
+ await this.updateSharedContext(task, loopResult);
241
+ }
242
+ } else {
243
+ result.failedLoops.push({ loopId: loopResult.loopId, error: loopResult.error || "Unknown error" });
244
+ if (this.config.fallbackStrategy === "abort") {
245
+ throw new Error(`Task failed: ${loopResult.error}`);
246
+ }
247
+ }
248
+ }
249
+ }
250
+ }
251
+ task.status = "completed";
252
+ result.success = result.failedLoops.length === 0;
253
+ result.totalDuration = Date.now() - task.startTime;
254
+ result.insights = this.generateOrchestrationInsights(task, result);
255
+ return result;
256
+ } catch (error) {
257
+ task.status = "failed";
258
+ result.success = false;
259
+ result.error = error.message;
260
+ return result;
261
+ }
262
+ }
263
+ /**
264
+ * Execute a single task as a Ralph loop
265
+ */
266
+ async executeTaskLoop(taskBreakdown, orchestratedTask) {
267
+ try {
268
+ const bridge = new RalphStackMemoryBridge({
269
+ baseDir: `.ralph-${taskBreakdown.id}`,
270
+ maxIterations: taskBreakdown.estimatedIterations * 2,
271
+ // Allow extra iterations
272
+ useStackMemory: true
273
+ });
274
+ await bridge.initialize({
275
+ task: taskBreakdown.description,
276
+ criteria: taskBreakdown.criteria.join("\n")
277
+ });
278
+ this.activeLoops.set(taskBreakdown.id, bridge);
279
+ orchestratedTask.loops.set(taskBreakdown.id, {
280
+ bridge,
281
+ status: "running",
282
+ startTime: Date.now()
283
+ });
284
+ await bridge.run();
285
+ const loopInfo = orchestratedTask.loops.get(taskBreakdown.id);
286
+ if (loopInfo) {
287
+ loopInfo.status = "completed";
288
+ loopInfo.endTime = Date.now();
289
+ }
290
+ this.activeLoops.delete(taskBreakdown.id);
291
+ return { success: true, loopId: taskBreakdown.id };
292
+ } catch (error) {
293
+ logger.error(`Task loop failed: ${taskBreakdown.title}`, error);
294
+ const loopInfo = orchestratedTask.loops.get(taskBreakdown.id);
295
+ if (loopInfo) {
296
+ loopInfo.status = "failed";
297
+ loopInfo.error = error.message;
298
+ loopInfo.endTime = Date.now();
299
+ }
300
+ this.activeLoops.delete(taskBreakdown.id);
301
+ return { success: false, loopId: taskBreakdown.id, error: error.message };
302
+ }
303
+ }
304
+ /**
305
+ * Execute a task in parallel context
306
+ */
307
+ async executeParallelTask(task, execution) {
308
+ try {
309
+ const result = await this.executeTaskLoop(task, {
310
+ id: execution.id,
311
+ description: `Parallel task: ${task.title}`,
312
+ breakdown: [task],
313
+ executionPlan: { phases: [], totalEstimatedTime: 0, parallelizable: false },
314
+ status: "executing",
315
+ startTime: execution.startTime,
316
+ loops: /* @__PURE__ */ new Map(),
317
+ sharedContext: execution.sharedState
318
+ });
319
+ execution.results.set(task.id, result);
320
+ } catch (error) {
321
+ execution.results.set(task.id, {
322
+ success: false,
323
+ loopId: task.id,
324
+ error: error.message
325
+ });
326
+ }
327
+ }
328
+ /**
329
+ * Update shared context between tasks
330
+ */
331
+ async updateSharedContext(orchestratedTask, loopResult) {
332
+ logger.debug("Updating shared context", { orchestrationId: orchestratedTask.id, loopId: loopResult.loopId });
333
+ }
334
+ /**
335
+ * Generate insights from orchestration
336
+ */
337
+ generateOrchestrationInsights(task, result) {
338
+ const insights = [];
339
+ const avgLoopDuration = Array.from(task.loops.values()).filter((l) => l.endTime && l.startTime).map((l) => l.endTime - l.startTime).reduce((sum, duration) => sum + duration, 0) / task.loops.size;
340
+ if (avgLoopDuration > 0) {
341
+ insights.push(`Average loop duration: ${Math.round(avgLoopDuration / 1e3)}s`);
342
+ }
343
+ const successRate = result.completedLoops.length / (result.completedLoops.length + result.failedLoops.length);
344
+ insights.push(`Success rate: ${Math.round(successRate * 100)}%`);
345
+ if (task.breakdown.length > 3) {
346
+ insights.push("Complex task benefited from breakdown into multiple loops");
347
+ }
348
+ return insights;
349
+ }
350
+ // Helper methods for task analysis
351
+ assessTaskComplexity(description) {
352
+ const factors = [];
353
+ let score = 1;
354
+ if (description.length > 200) {
355
+ score += 2;
356
+ factors.push("long description");
357
+ }
358
+ if (description.includes("and")) {
359
+ score += 1;
360
+ factors.push("multiple requirements");
361
+ }
362
+ if (description.toLowerCase().includes("test")) {
363
+ score += 2;
364
+ factors.push("testing required");
365
+ }
366
+ if (description.toLowerCase().includes("document")) {
367
+ score += 1;
368
+ factors.push("documentation needed");
369
+ }
370
+ if (description.toLowerCase().includes("refactor")) {
371
+ score += 3;
372
+ factors.push("refactoring complexity");
373
+ }
374
+ return { score, factors };
375
+ }
376
+ needsSetup(description) {
377
+ const setupKeywords = ["project", "initialize", "setup", "scaffold", "create structure"];
378
+ return setupKeywords.some((keyword) => description.toLowerCase().includes(keyword));
379
+ }
380
+ needsTesting(criteria) {
381
+ return criteria.some((c) => c.toLowerCase().includes("test"));
382
+ }
383
+ needsDocumentation(criteria) {
384
+ return criteria.some((c) => c.toLowerCase().includes("doc"));
385
+ }
386
+ extractCoreTask(description) {
387
+ const sentences = description.split(".");
388
+ return sentences.find((s) => s.toLowerCase().includes("implement") || s.toLowerCase().includes("create") || s.toLowerCase().includes("add")) || null;
389
+ }
390
+ canExecuteInParallel(breakdown) {
391
+ return breakdown.some((task) => task.dependencies.length === 0);
392
+ }
393
+ groupTasksByDependencies(breakdown) {
394
+ const phases = [];
395
+ const processed = /* @__PURE__ */ new Set();
396
+ while (processed.size < breakdown.length) {
397
+ const readyTasks = breakdown.filter(
398
+ (task) => !processed.has(task.id) && task.dependencies.every((dep) => processed.has(dep))
399
+ );
400
+ if (readyTasks.length === 0) break;
401
+ phases.push({
402
+ id: `phase-${phases.length + 1}`,
403
+ tasks: readyTasks,
404
+ dependencies: phases.length > 0 ? [`phase-${phases.length}`] : [],
405
+ parallelExecution: readyTasks.length > 1
406
+ });
407
+ readyTasks.forEach((task) => processed.add(task.id));
408
+ }
409
+ return phases;
410
+ }
411
+ validateDependencies(plan) {
412
+ const errors = [];
413
+ const allTaskIds = new Set(
414
+ plan.phases.flatMap((phase) => phase.tasks.map((task) => task.id))
415
+ );
416
+ for (const phase of plan.phases) {
417
+ for (const task of phase.tasks) {
418
+ for (const dep of task.dependencies) {
419
+ if (!allTaskIds.has(dep)) {
420
+ errors.push(`Task ${task.id} depends on non-existent task ${dep}`);
421
+ }
422
+ }
423
+ }
424
+ }
425
+ return errors;
426
+ }
427
+ /**
428
+ * Monitor orchestration progress
429
+ */
430
+ getOrchestrationStatus(orchestrationId) {
431
+ return this.activeTasks.get(orchestrationId) || null;
432
+ }
433
+ /**
434
+ * Stop orchestration
435
+ */
436
+ async stopOrchestration(orchestrationId) {
437
+ const task = this.activeTasks.get(orchestrationId);
438
+ if (!task) return;
439
+ for (const [loopId, loopInfo] of task.loops) {
440
+ if (loopInfo.status === "running") {
441
+ try {
442
+ loopInfo.status = "stopped";
443
+ this.activeLoops.delete(loopId);
444
+ } catch (error) {
445
+ logger.error(`Failed to stop loop ${loopId}`, error);
446
+ }
447
+ }
448
+ }
449
+ task.status = "stopped";
450
+ this.activeTasks.delete(orchestrationId);
451
+ logger.info("Orchestration stopped", { orchestrationId });
452
+ }
453
+ }
454
+ const multiLoopOrchestrator = new MultiLoopOrchestrator();
455
+ export {
456
+ MultiLoopOrchestrator,
457
+ multiLoopOrchestrator
458
+ };
459
+ //# sourceMappingURL=multi-loop-orchestrator.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/integrations/ralph/orchestration/multi-loop-orchestrator.ts"],
4
+ "sourcesContent": ["/**\n * Multi-Loop Orchestrator for Complex Tasks\n * Manages multiple Ralph loops working together on large, complex tasks\n */\n\nimport { v4 as uuidv4 } from 'uuid';\nimport { logger } from '../../../core/monitoring/logger.js';\nimport { FrameManager } from '../../../core/context/frame-manager.js';\nimport { sessionManager } from '../../../core/session/index.js';\nimport { RalphStackMemoryBridge } from '../bridge/ralph-stackmemory-bridge.js';\nimport {\n OrchestratedTask,\n TaskDependency,\n LoopCoordination,\n ParallelExecution,\n TaskBreakdown,\n ExecutionPlan,\n OrchestrationResult\n} from '../types.js';\n\nexport interface OrchestrationConfig {\n maxConcurrentLoops: number;\n dependencyResolutionTimeout: number;\n enableAdaptivePlanning: boolean;\n sharedContextEnabled: boolean;\n fallbackStrategy: 'sequential' | 'abort' | 'manual';\n}\n\nexport class MultiLoopOrchestrator {\n private frameManager?: FrameManager;\n private activeTasks: Map<string, OrchestratedTask> = new Map();\n private activeLoops: Map<string, RalphStackMemoryBridge> = new Map();\n private config: OrchestrationConfig;\n\n constructor(config?: Partial<OrchestrationConfig>) {\n this.config = {\n maxConcurrentLoops: 3,\n dependencyResolutionTimeout: 30000, // 30 seconds\n enableAdaptivePlanning: true,\n sharedContextEnabled: true,\n fallbackStrategy: 'sequential',\n ...config\n };\n\n logger.info('Multi-loop orchestrator initialized', this.config);\n }\n\n async initialize(): Promise<void> {\n try {\n await sessionManager.initialize();\n\n const session = await sessionManager.getOrCreateSession({});\n if (session.database) {\n this.frameManager = new FrameManager(session.database, session.projectId);\n }\n\n logger.info('Orchestrator initialized successfully');\n } catch (error: unknown) {\n logger.error('Failed to initialize orchestrator', error as Error);\n throw error;\n }\n }\n\n /**\n * Break down complex task into manageable loops\n */\n async orchestrateComplexTask(\n description: string, \n criteria: string[], \n options?: {\n maxLoops?: number;\n forceSequential?: boolean;\n customBreakdown?: TaskBreakdown[];\n }\n ): Promise<OrchestrationResult> {\n logger.info('Orchestrating complex task', {\n task: description.substring(0, 100),\n criteriaCount: criteria.length,\n maxLoops: options?.maxLoops || this.config.maxConcurrentLoops\n });\n\n const orchestrationId = uuidv4();\n\n try {\n // 1. Break down task into subtasks\n const breakdown = options?.customBreakdown || \n await this.analyzeAndBreakdownTask(description, criteria);\n\n // 2. Create execution plan\n const executionPlan = await this.createExecutionPlan(breakdown, options);\n\n // 3. Validate dependencies\n const dependencyErrors = this.validateDependencies(executionPlan);\n if (dependencyErrors.length > 0) {\n throw new Error(`Dependency errors: ${dependencyErrors.join(', ')}`);\n }\n\n // 4. Create orchestrated task\n const orchestratedTask: OrchestratedTask = {\n id: orchestrationId,\n description,\n breakdown,\n executionPlan,\n status: 'planning',\n startTime: Date.now(),\n loops: new Map(),\n sharedContext: {}\n };\n\n this.activeTasks.set(orchestrationId, orchestratedTask);\n\n // 5. Execute the plan\n const result = await this.executeOrchestration(orchestratedTask);\n\n logger.info('Complex task orchestration completed', {\n orchestrationId,\n status: result.success ? 'success' : 'failure',\n loopsExecuted: result.completedLoops.length,\n duration: Date.now() - orchestratedTask.startTime\n });\n\n return result;\n\n } catch (error: unknown) {\n logger.error('Orchestration failed', error as Error);\n throw error;\n } finally {\n this.activeTasks.delete(orchestrationId);\n }\n }\n\n /**\n * Execute coordinated parallel loops\n */\n async executeParallelLoops(\n tasks: TaskBreakdown[],\n coordination?: LoopCoordination\n ): Promise<ParallelExecution> {\n logger.info(`Executing ${tasks.length} parallel loops`);\n\n const execution: ParallelExecution = {\n id: uuidv4(),\n tasks: tasks,\n startTime: Date.now(),\n results: new Map(),\n sharedState: coordination?.sharedState || {}\n };\n\n const promises = tasks.map(task => this.executeParallelTask(task, execution));\n \n try {\n await Promise.allSettled(promises);\n\n execution.endTime = Date.now();\n execution.status = Array.from(execution.results.values()).every(r => r.success) ? 'success' : 'partial';\n\n return execution;\n\n } catch (error: unknown) {\n logger.error('Parallel execution failed', error as Error);\n execution.status = 'failed';\n execution.error = (error as Error).message;\n return execution;\n }\n }\n\n /**\n * Analyze and break down complex task\n */\n private async analyzeAndBreakdownTask(\n description: string,\n criteria: string[]\n ): Promise<TaskBreakdown[]> {\n // Intelligent task breakdown using patterns and heuristics\n const complexity = this.assessTaskComplexity(description);\n \n if (complexity.score < 5) {\n // Simple task - no breakdown needed\n return [{\n id: uuidv4(),\n title: description,\n description,\n criteria: criteria,\n priority: 1,\n estimatedIterations: 3,\n dependencies: [],\n type: 'single'\n }];\n }\n\n // Complex task - break down by patterns\n const subtasks: TaskBreakdown[] = [];\n \n // Pattern 1: Setup/Foundation tasks\n if (this.needsSetup(description)) {\n subtasks.push({\n id: uuidv4(),\n title: 'Project Setup',\n description: 'Set up project structure and dependencies',\n criteria: ['Project structure created', 'Dependencies installed'],\n priority: 1,\n estimatedIterations: 2,\n dependencies: [],\n type: 'setup'\n });\n }\n\n // Pattern 2: Core implementation\n const coreTask = this.extractCoreTask(description);\n if (coreTask) {\n subtasks.push({\n id: uuidv4(),\n title: 'Core Implementation',\n description: coreTask,\n criteria: criteria.filter(c => c.toLowerCase().includes('function') || c.toLowerCase().includes('implement')),\n priority: 2,\n estimatedIterations: 5,\n dependencies: subtasks.length > 0 ? [subtasks[0].id] : [],\n type: 'implementation'\n });\n }\n\n // Pattern 3: Testing tasks\n if (this.needsTesting(criteria)) {\n subtasks.push({\n id: uuidv4(),\n title: 'Testing Implementation',\n description: 'Create comprehensive tests',\n criteria: criteria.filter(c => c.toLowerCase().includes('test')),\n priority: 3,\n estimatedIterations: 3,\n dependencies: subtasks.length > 0 ? [subtasks[subtasks.length - 1].id] : [],\n type: 'testing'\n });\n }\n\n // Pattern 4: Documentation tasks\n if (this.needsDocumentation(criteria)) {\n subtasks.push({\n id: uuidv4(),\n title: 'Documentation',\n description: 'Create documentation and examples',\n criteria: criteria.filter(c => c.toLowerCase().includes('doc')),\n priority: 4,\n estimatedIterations: 2,\n dependencies: [],\n type: 'documentation'\n });\n }\n\n return subtasks.length > 0 ? subtasks : [{\n id: uuidv4(),\n title: description,\n description,\n criteria,\n priority: 1,\n estimatedIterations: Math.min(8, Math.max(3, complexity.score)),\n dependencies: [],\n type: 'single'\n }];\n }\n\n /**\n * Create execution plan from breakdown\n */\n private async createExecutionPlan(\n breakdown: TaskBreakdown[],\n options?: { forceSequential?: boolean }\n ): Promise<ExecutionPlan> {\n const plan: ExecutionPlan = {\n phases: [],\n totalEstimatedTime: 0,\n parallelizable: !options?.forceSequential && breakdown.length > 1\n };\n\n if (options?.forceSequential || !this.canExecuteInParallel(breakdown)) {\n // Sequential execution\n plan.phases = breakdown.map((task, index) => ({\n id: `phase-${index + 1}`,\n tasks: [task],\n dependencies: index > 0 ? [`phase-${index}`] : [],\n parallelExecution: false\n }));\n } else {\n // Group tasks by dependencies for parallel execution\n const phases = this.groupTasksByDependencies(breakdown);\n plan.phases = phases;\n }\n\n plan.totalEstimatedTime = plan.phases.reduce(\n (sum, phase) => sum + Math.max(...phase.tasks.map(t => t.estimatedIterations)) * 30000, // 30s per iteration\n 0\n );\n\n return plan;\n }\n\n /**\n * Execute the orchestration plan\n */\n private async executeOrchestration(task: OrchestratedTask): Promise<OrchestrationResult> {\n const result: OrchestrationResult = {\n orchestrationId: task.id,\n success: false,\n completedLoops: [],\n failedLoops: [],\n totalDuration: 0,\n insights: []\n };\n\n try {\n task.status = 'executing';\n\n for (const phase of task.executionPlan.phases) {\n logger.info(`Executing phase ${phase.id} with ${phase.tasks.length} tasks`);\n\n if (phase.parallelExecution && phase.tasks.length > 1) {\n // Parallel execution\n const parallelResult = await this.executeParallelLoops(phase.tasks);\n \n for (const [taskId, taskResult] of parallelResult.results) {\n if (taskResult.success) {\n result.completedLoops.push(taskResult.loopId);\n } else {\n result.failedLoops.push({ loopId: taskResult.loopId, error: taskResult.error || 'Unknown error' });\n }\n }\n } else {\n // Sequential execution\n for (const phaseTask of phase.tasks) {\n const loopResult = await this.executeTaskLoop(phaseTask, task);\n \n if (loopResult.success) {\n result.completedLoops.push(loopResult.loopId);\n \n // Share learnings with other tasks\n if (this.config.sharedContextEnabled) {\n await this.updateSharedContext(task, loopResult);\n }\n } else {\n result.failedLoops.push({ loopId: loopResult.loopId, error: loopResult.error || 'Unknown error' });\n \n // Handle failure based on strategy\n if (this.config.fallbackStrategy === 'abort') {\n throw new Error(`Task failed: ${loopResult.error}`);\n }\n }\n }\n }\n }\n\n task.status = 'completed';\n result.success = result.failedLoops.length === 0;\n result.totalDuration = Date.now() - task.startTime;\n\n // Generate insights\n result.insights = this.generateOrchestrationInsights(task, result);\n\n return result;\n\n } catch (error: unknown) {\n task.status = 'failed';\n result.success = false;\n result.error = (error as Error).message;\n return result;\n }\n }\n\n /**\n * Execute a single task as a Ralph loop\n */\n private async executeTaskLoop(\n taskBreakdown: TaskBreakdown,\n orchestratedTask: OrchestratedTask\n ): Promise<{ success: boolean; loopId: string; error?: string }> {\n try {\n // Create Ralph loop with shared context\n const bridge = new RalphStackMemoryBridge({\n baseDir: `.ralph-${taskBreakdown.id}`,\n maxIterations: taskBreakdown.estimatedIterations * 2, // Allow extra iterations\n useStackMemory: true\n });\n\n await bridge.initialize({\n task: taskBreakdown.description,\n criteria: taskBreakdown.criteria.join('\\n')\n });\n\n // Store loop reference\n this.activeLoops.set(taskBreakdown.id, bridge);\n orchestratedTask.loops.set(taskBreakdown.id, {\n bridge,\n status: 'running',\n startTime: Date.now()\n });\n\n // Run the loop\n await bridge.run();\n\n // Check result\n const loopInfo = orchestratedTask.loops.get(taskBreakdown.id);\n if (loopInfo) {\n loopInfo.status = 'completed';\n loopInfo.endTime = Date.now();\n }\n\n this.activeLoops.delete(taskBreakdown.id);\n\n return { success: true, loopId: taskBreakdown.id };\n\n } catch (error: unknown) {\n logger.error(`Task loop failed: ${taskBreakdown.title}`, error as Error);\n \n const loopInfo = orchestratedTask.loops.get(taskBreakdown.id);\n if (loopInfo) {\n loopInfo.status = 'failed';\n loopInfo.error = (error as Error).message;\n loopInfo.endTime = Date.now();\n }\n\n this.activeLoops.delete(taskBreakdown.id);\n\n return { success: false, loopId: taskBreakdown.id, error: (error as Error).message };\n }\n }\n\n /**\n * Execute a task in parallel context\n */\n private async executeParallelTask(\n task: TaskBreakdown,\n execution: ParallelExecution\n ): Promise<void> {\n try {\n const result = await this.executeTaskLoop(task, {\n id: execution.id,\n description: `Parallel task: ${task.title}`,\n breakdown: [task],\n executionPlan: { phases: [], totalEstimatedTime: 0, parallelizable: false },\n status: 'executing',\n startTime: execution.startTime,\n loops: new Map(),\n sharedContext: execution.sharedState\n });\n\n execution.results.set(task.id, result);\n\n } catch (error: unknown) {\n execution.results.set(task.id, {\n success: false,\n loopId: task.id,\n error: (error as Error).message\n });\n }\n }\n\n /**\n * Update shared context between tasks\n */\n private async updateSharedContext(\n orchestratedTask: OrchestratedTask,\n loopResult: { loopId: string }\n ): Promise<void> {\n // Extract learnings from completed loop and share with other active loops\n // This would integrate with StackMemory's shared context layer\n logger.debug('Updating shared context', { orchestrationId: orchestratedTask.id, loopId: loopResult.loopId });\n }\n\n /**\n * Generate insights from orchestration\n */\n private generateOrchestrationInsights(\n task: OrchestratedTask,\n result: OrchestrationResult\n ): string[] {\n const insights: string[] = [];\n\n // Performance insights\n const avgLoopDuration = Array.from(task.loops.values())\n .filter(l => l.endTime && l.startTime)\n .map(l => l.endTime! - l.startTime)\n .reduce((sum, duration) => sum + duration, 0) / task.loops.size;\n\n if (avgLoopDuration > 0) {\n insights.push(`Average loop duration: ${Math.round(avgLoopDuration / 1000)}s`);\n }\n\n // Success rate insights\n const successRate = result.completedLoops.length / (result.completedLoops.length + result.failedLoops.length);\n insights.push(`Success rate: ${Math.round(successRate * 100)}%`);\n\n // Complexity insights\n if (task.breakdown.length > 3) {\n insights.push('Complex task benefited from breakdown into multiple loops');\n }\n\n return insights;\n }\n\n // Helper methods for task analysis\n private assessTaskComplexity(description: string): { score: number; factors: string[] } {\n const factors: string[] = [];\n let score = 1;\n\n if (description.length > 200) { score += 2; factors.push('long description'); }\n if (description.includes('and')) { score += 1; factors.push('multiple requirements'); }\n if (description.toLowerCase().includes('test')) { score += 2; factors.push('testing required'); }\n if (description.toLowerCase().includes('document')) { score += 1; factors.push('documentation needed'); }\n if (description.toLowerCase().includes('refactor')) { score += 3; factors.push('refactoring complexity'); }\n\n return { score, factors };\n }\n\n private needsSetup(description: string): boolean {\n const setupKeywords = ['project', 'initialize', 'setup', 'scaffold', 'create structure'];\n return setupKeywords.some(keyword => description.toLowerCase().includes(keyword));\n }\n\n private needsTesting(criteria: string[]): boolean {\n return criteria.some(c => c.toLowerCase().includes('test'));\n }\n\n private needsDocumentation(criteria: string[]): boolean {\n return criteria.some(c => c.toLowerCase().includes('doc'));\n }\n\n private extractCoreTask(description: string): string | null {\n // Extract the main implementation task from description\n const sentences = description.split('.');\n return sentences.find(s => s.toLowerCase().includes('implement') || s.toLowerCase().includes('create') || s.toLowerCase().includes('add')) || null;\n }\n\n private canExecuteInParallel(breakdown: TaskBreakdown[]): boolean {\n // Check if tasks can be executed in parallel based on dependencies\n return breakdown.some(task => task.dependencies.length === 0);\n }\n\n private groupTasksByDependencies(breakdown: TaskBreakdown[]): any[] {\n // Group tasks into phases based on dependencies\n const phases: any[] = [];\n const processed = new Set<string>();\n \n while (processed.size < breakdown.length) {\n const readyTasks = breakdown.filter(task => \n !processed.has(task.id) && \n task.dependencies.every(dep => processed.has(dep))\n );\n\n if (readyTasks.length === 0) break; // Circular dependency\n\n phases.push({\n id: `phase-${phases.length + 1}`,\n tasks: readyTasks,\n dependencies: phases.length > 0 ? [`phase-${phases.length}`] : [],\n parallelExecution: readyTasks.length > 1\n });\n\n readyTasks.forEach(task => processed.add(task.id));\n }\n\n return phases;\n }\n\n private validateDependencies(plan: ExecutionPlan): string[] {\n const errors: string[] = [];\n const allTaskIds = new Set(\n plan.phases.flatMap(phase => phase.tasks.map(task => task.id))\n );\n\n for (const phase of plan.phases) {\n for (const task of phase.tasks) {\n for (const dep of task.dependencies) {\n if (!allTaskIds.has(dep)) {\n errors.push(`Task ${task.id} depends on non-existent task ${dep}`);\n }\n }\n }\n }\n\n return errors;\n }\n\n /**\n * Monitor orchestration progress\n */\n getOrchestrationStatus(orchestrationId: string): OrchestratedTask | null {\n return this.activeTasks.get(orchestrationId) || null;\n }\n\n /**\n * Stop orchestration\n */\n async stopOrchestration(orchestrationId: string): Promise<void> {\n const task = this.activeTasks.get(orchestrationId);\n if (!task) return;\n\n // Stop all active loops\n for (const [loopId, loopInfo] of task.loops) {\n if (loopInfo.status === 'running') {\n try {\n // Signal stop to the loop\n loopInfo.status = 'stopped';\n this.activeLoops.delete(loopId);\n } catch (error: unknown) {\n logger.error(`Failed to stop loop ${loopId}`, error as Error);\n }\n }\n }\n\n task.status = 'stopped';\n this.activeTasks.delete(orchestrationId);\n\n logger.info('Orchestration stopped', { orchestrationId });\n }\n}\n\n// Export default instance\nexport const multiLoopOrchestrator = new MultiLoopOrchestrator();"],
5
+ "mappings": "AAKA,SAAS,MAAM,cAAc;AAC7B,SAAS,cAAc;AACvB,SAAS,oBAAoB;AAC7B,SAAS,sBAAsB;AAC/B,SAAS,8BAA8B;AAmBhC,MAAM,sBAAsB;AAAA,EACzB;AAAA,EACA,cAA6C,oBAAI,IAAI;AAAA,EACrD,cAAmD,oBAAI,IAAI;AAAA,EAC3D;AAAA,EAER,YAAY,QAAuC;AACjD,SAAK,SAAS;AAAA,MACZ,oBAAoB;AAAA,MACpB,6BAA6B;AAAA;AAAA,MAC7B,wBAAwB;AAAA,MACxB,sBAAsB;AAAA,MACtB,kBAAkB;AAAA,MAClB,GAAG;AAAA,IACL;AAEA,WAAO,KAAK,uCAAuC,KAAK,MAAM;AAAA,EAChE;AAAA,EAEA,MAAM,aAA4B;AAChC,QAAI;AACF,YAAM,eAAe,WAAW;AAEhC,YAAM,UAAU,MAAM,eAAe,mBAAmB,CAAC,CAAC;AAC1D,UAAI,QAAQ,UAAU;AACpB,aAAK,eAAe,IAAI,aAAa,QAAQ,UAAU,QAAQ,SAAS;AAAA,MAC1E;AAEA,aAAO,KAAK,uCAAuC;AAAA,IACrD,SAAS,OAAgB;AACvB,aAAO,MAAM,qCAAqC,KAAc;AAChE,YAAM;AAAA,IACR;AAAA,EACF;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,uBACJ,aACA,UACA,SAK8B;AAC9B,WAAO,KAAK,8BAA8B;AAAA,MACxC,MAAM,YAAY,UAAU,GAAG,GAAG;AAAA,MAClC,eAAe,SAAS;AAAA,MACxB,UAAU,SAAS,YAAY,KAAK,OAAO;AAAA,IAC7C,CAAC;AAED,UAAM,kBAAkB,OAAO;AAE/B,QAAI;AAEF,YAAM,YAAY,SAAS,mBACzB,MAAM,KAAK,wBAAwB,aAAa,QAAQ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