@stackmemoryai/stackmemory 0.4.2 → 0.5.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.
Files changed (49) hide show
  1. package/dist/cli/commands/ralph.js +305 -0
  2. package/dist/cli/commands/ralph.js.map +2 -2
  3. package/dist/cli/streamlined-cli.js +144 -0
  4. package/dist/cli/streamlined-cli.js.map +7 -0
  5. package/dist/core/events/event-bus.js +110 -0
  6. package/dist/core/events/event-bus.js.map +7 -0
  7. package/dist/core/plugins/plugin-interface.js +87 -0
  8. package/dist/core/plugins/plugin-interface.js.map +7 -0
  9. package/dist/core/storage/simplified-storage.js +328 -0
  10. package/dist/core/storage/simplified-storage.js.map +7 -0
  11. package/dist/integrations/claude-code/agent-bridge.js +764 -0
  12. package/dist/integrations/claude-code/agent-bridge.js.map +7 -0
  13. package/dist/integrations/claude-code/task-coordinator.js +356 -0
  14. package/dist/integrations/claude-code/task-coordinator.js.map +7 -0
  15. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js +33 -11
  16. package/dist/integrations/ralph/bridge/ralph-stackmemory-bridge.js.map +2 -2
  17. package/dist/integrations/ralph/monitoring/swarm-registry.js +10 -1
  18. package/dist/integrations/ralph/monitoring/swarm-registry.js.map +2 -2
  19. package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js +396 -0
  20. package/dist/integrations/ralph/patterns/compounding-engineering-pattern.js.map +7 -0
  21. package/dist/integrations/ralph/patterns/extended-coherence-sessions.js +469 -0
  22. package/dist/integrations/ralph/patterns/extended-coherence-sessions.js.map +7 -0
  23. package/dist/integrations/ralph/patterns/oracle-worker-pattern.js +384 -0
  24. package/dist/integrations/ralph/patterns/oracle-worker-pattern.js.map +7 -0
  25. package/dist/integrations/ralph/swarm/git-workflow-manager.js +71 -18
  26. package/dist/integrations/ralph/swarm/git-workflow-manager.js.map +2 -2
  27. package/dist/integrations/ralph/swarm/swarm-coordinator.js +243 -49
  28. package/dist/integrations/ralph/swarm/swarm-coordinator.js.map +2 -2
  29. package/dist/plugins/linear/index.js +166 -0
  30. package/dist/plugins/linear/index.js.map +7 -0
  31. package/dist/plugins/loader.js +57 -0
  32. package/dist/plugins/loader.js.map +7 -0
  33. package/dist/plugins/plugin-interface.js +67 -0
  34. package/dist/plugins/plugin-interface.js.map +7 -0
  35. package/dist/plugins/ralph/simple-ralph-plugin.js +305 -0
  36. package/dist/plugins/ralph/simple-ralph-plugin.js.map +7 -0
  37. package/dist/plugins/ralph/use-cases/code-generator.js +151 -0
  38. package/dist/plugins/ralph/use-cases/code-generator.js.map +7 -0
  39. package/dist/plugins/ralph/use-cases/test-generator.js +201 -0
  40. package/dist/plugins/ralph/use-cases/test-generator.js.map +7 -0
  41. package/package.json +1 -8
  42. package/scripts/simple-swarm-demo.ts +114 -0
  43. package/scripts/test-ralph-iterations.ts +164 -0
  44. package/scripts/test-swarm-fixes.ts +161 -0
  45. package/scripts/testing/ab-test-runner.ts +4 -2
  46. package/scripts/testing/collect-metrics.ts +2 -2
  47. package/scripts/testing/real-performance-test.js +1 -1
  48. package/scripts/testing/run-effectiveness-tests.sh +1 -1
  49. package/scripts/testing/simple-effectiveness-test.js +1 -1
@@ -0,0 +1,469 @@
1
+ import { v4 as uuidv4 } from "uuid";
2
+ import * as fs from "fs/promises";
3
+ import * as path from "path";
4
+ import { logger } from "../../../core/monitoring/logger.js";
5
+ import { RalphStackMemoryBridge } from "../bridge/ralph-stackmemory-bridge.js";
6
+ class ExtendedCoherenceManager {
7
+ activeSessions = /* @__PURE__ */ new Map();
8
+ baseDir;
9
+ monitoringInterval;
10
+ performanceHistory = /* @__PURE__ */ new Map();
11
+ constructor(baseDir = "./.coherence-sessions") {
12
+ this.baseDir = baseDir;
13
+ }
14
+ /**
15
+ * Initialize the coherence management system
16
+ */
17
+ async initialize() {
18
+ await fs.mkdir(this.baseDir, { recursive: true });
19
+ this.monitoringInterval = setInterval(
20
+ () => this.monitorActiveSessionsHealth(),
21
+ 6e4
22
+ // Check every minute
23
+ );
24
+ logger.info("Extended Coherence Manager initialized", {
25
+ baseDir: this.baseDir,
26
+ monitoringEnabled: true
27
+ });
28
+ }
29
+ /**
30
+ * Start an extended coherence work session
31
+ */
32
+ async startCoherenceSession(agentConfig, taskConfig, sessionConfig) {
33
+ const sessionId = uuidv4();
34
+ const defaultConfig = this.generateConfigForComplexity(taskConfig.complexity);
35
+ const config = { ...defaultConfig, ...sessionConfig };
36
+ const session = {
37
+ id: sessionId,
38
+ agent: agentConfig,
39
+ task: {
40
+ ...taskConfig,
41
+ breakpoints: taskConfig.breakpoints || this.generateBreakpoints(taskConfig)
42
+ },
43
+ config,
44
+ state: {
45
+ status: "active",
46
+ currentPhase: "initialization",
47
+ completedMilestones: [],
48
+ lastCheckpoint: Date.now(),
49
+ interventionCount: 0,
50
+ refreshCount: 0
51
+ },
52
+ metrics: [],
53
+ interventions: []
54
+ };
55
+ this.activeSessions.set(sessionId, session);
56
+ await this.initializeSessionWorkspace(session);
57
+ await this.launchAgentSession(session);
58
+ logger.info("Extended coherence session started", {
59
+ sessionId,
60
+ agent: agentConfig.role,
61
+ estimatedDuration: taskConfig.estimatedDuration,
62
+ maxDuration: config.maxDuration
63
+ });
64
+ return sessionId;
65
+ }
66
+ /**
67
+ * Generate configuration optimized for task complexity
68
+ */
69
+ generateConfigForComplexity(complexity) {
70
+ const configs = {
71
+ low: {
72
+ maxDuration: 60,
73
+ // 1 hour
74
+ coherenceThreshold: 0.7,
75
+ checkpointInterval: 15,
76
+ // 15 minutes
77
+ refreshStrategy: "checkpoint",
78
+ enableMemoryPalace: false,
79
+ enableProgressTracking: true,
80
+ enableAutoRefresh: false,
81
+ enableHealthMonitoring: true
82
+ },
83
+ medium: {
84
+ maxDuration: 180,
85
+ // 3 hours
86
+ coherenceThreshold: 0.8,
87
+ checkpointInterval: 10,
88
+ // 10 minutes
89
+ refreshStrategy: "context_refresh",
90
+ enableMemoryPalace: true,
91
+ enableProgressTracking: true,
92
+ enableAutoRefresh: true,
93
+ enableHealthMonitoring: true
94
+ },
95
+ high: {
96
+ maxDuration: 360,
97
+ // 6 hours
98
+ coherenceThreshold: 0.85,
99
+ checkpointInterval: 8,
100
+ // 8 minutes
101
+ refreshStrategy: "context_refresh",
102
+ enableMemoryPalace: true,
103
+ enableProgressTracking: true,
104
+ enableAutoRefresh: true,
105
+ enableHealthMonitoring: true
106
+ },
107
+ very_high: {
108
+ maxDuration: 720,
109
+ // 12 hours
110
+ coherenceThreshold: 0.9,
111
+ checkpointInterval: 5,
112
+ // 5 minutes
113
+ refreshStrategy: "full_restart",
114
+ enableMemoryPalace: true,
115
+ enableProgressTracking: true,
116
+ enableAutoRefresh: true,
117
+ enableHealthMonitoring: true
118
+ }
119
+ };
120
+ return configs[complexity];
121
+ }
122
+ /**
123
+ * Monitor active sessions for coherence degradation
124
+ */
125
+ async monitorActiveSessionsHealth() {
126
+ for (const [sessionId, session] of this.activeSessions) {
127
+ if (session.state.status === "active") {
128
+ await this.assessSessionCoherence(session);
129
+ }
130
+ }
131
+ }
132
+ /**
133
+ * Assess session coherence and intervene if necessary
134
+ */
135
+ async assessSessionCoherence(session) {
136
+ const metrics = await this.calculateCoherenceMetrics(session);
137
+ session.metrics.push(metrics);
138
+ if (session.metrics.length > 10) {
139
+ session.metrics.shift();
140
+ }
141
+ const overallCoherence = this.calculateOverallCoherence(metrics);
142
+ logger.debug("Session coherence assessment", {
143
+ sessionId: session.id,
144
+ coherence: overallCoherence,
145
+ threshold: session.config.coherenceThreshold,
146
+ duration: metrics.duration
147
+ });
148
+ if (overallCoherence < session.config.coherenceThreshold) {
149
+ await this.interventeInSession(session, "coherence_degradation", overallCoherence);
150
+ }
151
+ const timeSinceCheckpoint = Date.now() - session.state.lastCheckpoint;
152
+ const checkpointDue = timeSinceCheckpoint > session.config.checkpointInterval * 60 * 1e3;
153
+ if (checkpointDue) {
154
+ await this.checkpointSession(session);
155
+ }
156
+ }
157
+ /**
158
+ * Calculate comprehensive coherence metrics
159
+ */
160
+ async calculateCoherenceMetrics(session) {
161
+ const now = Date.now();
162
+ const duration = (now - session.metrics[0]?.startTime || now) / (1e3 * 60);
163
+ const recentOutputs = await this.getRecentAgentOutputs(session);
164
+ const outputQuality = this.assessOutputQuality(recentOutputs);
165
+ const contextRetention = this.assessContextRetention(recentOutputs, session.task);
166
+ const taskRelevance = this.assessTaskRelevance(recentOutputs, session.task);
167
+ const repetitionRate = this.calculateRepetitionRate(recentOutputs);
168
+ const divergenceRate = this.calculateDivergenceRate(recentOutputs, session.task);
169
+ const errorRate = this.calculateErrorRate(recentOutputs);
170
+ const progressRate = this.calculateProgressRate(session);
171
+ return {
172
+ sessionId: session.id,
173
+ startTime: session.metrics[0]?.startTime || now,
174
+ currentTime: now,
175
+ duration,
176
+ outputQuality,
177
+ contextRetention,
178
+ taskRelevance,
179
+ progressRate,
180
+ repetitionRate,
181
+ divergenceRate,
182
+ errorRate,
183
+ memoryUsage: await this.getMemoryUsage(session),
184
+ contextWindowUsage: await this.getContextWindowUsage(session),
185
+ stateCheckpoints: session.interventions.filter((i) => i.type === "checkpoint").length
186
+ };
187
+ }
188
+ /**
189
+ * Calculate overall coherence score
190
+ */
191
+ calculateOverallCoherence(metrics) {
192
+ const weights = {
193
+ outputQuality: 0.3,
194
+ contextRetention: 0.25,
195
+ taskRelevance: 0.25,
196
+ repetitionPenalty: 0.1,
197
+ // penalty for repetition
198
+ divergencePenalty: 0.1
199
+ // penalty for divergence
200
+ };
201
+ const baseScore = metrics.outputQuality * weights.outputQuality + metrics.contextRetention * weights.contextRetention + metrics.taskRelevance * weights.taskRelevance;
202
+ const penalties = metrics.repetitionRate * weights.repetitionPenalty + metrics.divergenceRate * weights.divergencePenalty;
203
+ return Math.max(0, baseScore - penalties);
204
+ }
205
+ /**
206
+ * Intervene in a session to restore coherence
207
+ */
208
+ async interventeInSession(session, reason, currentCoherence) {
209
+ logger.warn("Intervening in session due to coherence degradation", {
210
+ sessionId: session.id,
211
+ reason,
212
+ currentCoherence,
213
+ interventionCount: session.state.interventionCount
214
+ });
215
+ const intervention = {
216
+ timestamp: Date.now(),
217
+ type: session.config.refreshStrategy,
218
+ reason,
219
+ effectiveness: 0
220
+ // will be calculated later
221
+ };
222
+ switch (session.config.refreshStrategy) {
223
+ case "checkpoint":
224
+ await this.checkpointSession(session);
225
+ break;
226
+ case "context_refresh":
227
+ await this.refreshSessionContext(session);
228
+ break;
229
+ case "full_restart":
230
+ await this.restartSession(session);
231
+ break;
232
+ default:
233
+ await this.provideGuidance(session, reason);
234
+ intervention.type = "guidance";
235
+ }
236
+ session.interventions.push(intervention);
237
+ session.state.interventionCount++;
238
+ const previousStatus = session.state.status;
239
+ session.state.status = "degraded";
240
+ setTimeout(async () => {
241
+ const newMetrics = await this.calculateCoherenceMetrics(session);
242
+ const newCoherence = this.calculateOverallCoherence(newMetrics);
243
+ intervention.effectiveness = Math.max(0, newCoherence - currentCoherence);
244
+ if (newCoherence > session.config.coherenceThreshold) {
245
+ session.state.status = "active";
246
+ logger.info("Session coherence restored", {
247
+ sessionId: session.id,
248
+ newCoherence,
249
+ effectiveness: intervention.effectiveness
250
+ });
251
+ }
252
+ }, 12e4);
253
+ }
254
+ /**
255
+ * Create a checkpoint of session state
256
+ */
257
+ async checkpointSession(session) {
258
+ const checkpointPath = path.join(
259
+ this.baseDir,
260
+ session.id,
261
+ `checkpoint-${Date.now()}.json`
262
+ );
263
+ const checkpointData = {
264
+ timestamp: Date.now(),
265
+ state: session.state,
266
+ recentMetrics: session.metrics.slice(-3),
267
+ currentPhase: session.state.currentPhase,
268
+ completedMilestones: session.state.completedMilestones,
269
+ // Include recent agent context
270
+ contextSummary: await this.generateContextSummary(session)
271
+ };
272
+ await fs.writeFile(checkpointPath, JSON.stringify(checkpointData, null, 2));
273
+ session.state.lastCheckpoint = Date.now();
274
+ logger.info("Session checkpoint created", {
275
+ sessionId: session.id,
276
+ checkpointPath
277
+ });
278
+ }
279
+ /**
280
+ * Refresh session context to restore coherence
281
+ */
282
+ async refreshSessionContext(session) {
283
+ logger.info("Refreshing session context", { sessionId: session.id });
284
+ const refreshPrompt = await this.generateContextRefreshPrompt(session);
285
+ await this.applyContextRefresh(session, refreshPrompt);
286
+ session.state.refreshCount++;
287
+ }
288
+ /**
289
+ * Restart session from last good checkpoint
290
+ */
291
+ async restartSession(session) {
292
+ logger.info("Restarting session from checkpoint", { sessionId: session.id });
293
+ const checkpoint = await this.loadLatestCheckpoint(session);
294
+ if (checkpoint) {
295
+ session.state = { ...checkpoint.state };
296
+ await this.restartAgentFromCheckpoint(session, checkpoint);
297
+ } else {
298
+ await this.restartAgentFromBeginning(session);
299
+ }
300
+ }
301
+ /**
302
+ * Initialize workspace for a coherence session
303
+ */
304
+ async initializeSessionWorkspace(session) {
305
+ const sessionDir = path.join(this.baseDir, session.id);
306
+ await fs.mkdir(sessionDir, { recursive: true });
307
+ const manifest = {
308
+ sessionId: session.id,
309
+ agent: session.agent,
310
+ task: session.task,
311
+ config: session.config,
312
+ createdAt: Date.now()
313
+ };
314
+ await fs.writeFile(
315
+ path.join(sessionDir, "manifest.json"),
316
+ JSON.stringify(manifest, null, 2)
317
+ );
318
+ }
319
+ /**
320
+ * Launch the actual agent work session
321
+ */
322
+ async launchAgentSession(session) {
323
+ const sessionDir = path.join(this.baseDir, session.id);
324
+ const ralph = new RalphStackMemoryBridge({
325
+ baseDir: sessionDir,
326
+ maxIterations: Math.ceil(session.config.maxDuration / 5),
327
+ // ~5 min per iteration
328
+ useStackMemory: true
329
+ });
330
+ await ralph.initialize({
331
+ task: this.buildExtendedCoherencePrompt(session),
332
+ criteria: session.task.breakpoints.join("\n")
333
+ });
334
+ ralph.run().catch((error) => {
335
+ logger.error("Extended coherence session failed", {
336
+ sessionId: session.id,
337
+ error: error.message
338
+ });
339
+ session.state.status = "failed";
340
+ });
341
+ }
342
+ /**
343
+ * Build prompt optimized for extended coherence
344
+ */
345
+ buildExtendedCoherencePrompt(session) {
346
+ return `
347
+ # EXTENDED COHERENCE WORK SESSION
348
+
349
+ ## Your Mission
350
+ ${session.task.description}
351
+
352
+ ## Session Parameters
353
+ - Estimated Duration: ${session.task.estimatedDuration} minutes
354
+ - Maximum Duration: ${session.config.maxDuration} minutes
355
+ - Coherence Threshold: ${session.config.coherenceThreshold * 100}%
356
+
357
+ ## Coherence Guidelines
358
+ 1. **Maintain Focus**: Stay on task throughout the entire session
359
+ 2. **Track Progress**: Document incremental progress at each step
360
+ 3. **Context Awareness**: Reference previous work and maintain consistency
361
+ 4. **Quality Control**: Regularly assess your output quality
362
+ 5. **Milestone Reporting**: Report when you reach natural breakpoints
363
+
364
+ ## Breakpoints & Milestones
365
+ ${session.task.breakpoints.map((bp, i) => `${i + 1}. ${bp}`).join("\n")}
366
+
367
+ ## Extended Session Strategy
368
+ - Take regular checkpoint breaks (every ${session.config.checkpointInterval} minutes)
369
+ - Summarize your progress regularly
370
+ - Ask for context refresh if you feel you're losing focus
371
+ - Maintain awareness of the overall project goal
372
+ - Break complex tasks into smaller, manageable chunks
373
+
374
+ ## Memory Palace (if enabled)
375
+ ${session.config.enableMemoryPalace ? `
376
+ Use structured memory organization:
377
+ - **Project Context**: Overall goals and requirements
378
+ - **Current Status**: What's been completed and what's next
379
+ - **Working Memory**: Current task details and immediate context
380
+ - **Reference Memory**: Important patterns, decisions, and learnings
381
+ ` : ""}
382
+
383
+ ## Success Criteria
384
+ - Complete the task within the allocated time
385
+ - Maintain high output quality throughout
386
+ - Document progress and decisions clearly
387
+ - Stay coherent and focused for the entire session
388
+
389
+ Begin your extended coherence work session now.
390
+ `;
391
+ }
392
+ // Placeholder implementations for helper methods
393
+ async getRecentAgentOutputs(session) {
394
+ return [];
395
+ }
396
+ assessOutputQuality(outputs) {
397
+ return 0.8;
398
+ }
399
+ assessContextRetention(outputs, task) {
400
+ return 0.7;
401
+ }
402
+ assessTaskRelevance(outputs, task) {
403
+ return 0.9;
404
+ }
405
+ calculateRepetitionRate(outputs) {
406
+ return 0.1;
407
+ }
408
+ calculateDivergenceRate(outputs, task) {
409
+ return 0.05;
410
+ }
411
+ calculateErrorRate(outputs) {
412
+ return 0.02;
413
+ }
414
+ calculateProgressRate(session) {
415
+ return 2.5;
416
+ }
417
+ async getMemoryUsage(session) {
418
+ return 150;
419
+ }
420
+ async getContextWindowUsage(session) {
421
+ return 65;
422
+ }
423
+ generateBreakpoints(taskConfig) {
424
+ return [
425
+ "Initial analysis complete",
426
+ "Core implementation finished",
427
+ "Testing phase complete",
428
+ "Final review and cleanup done"
429
+ ];
430
+ }
431
+ async generateContextSummary(session) {
432
+ return `Session ${session.id} context summary`;
433
+ }
434
+ async generateContextRefreshPrompt(session) {
435
+ return "Context refresh prompt";
436
+ }
437
+ async applyContextRefresh(session, prompt) {
438
+ }
439
+ async loadLatestCheckpoint(session) {
440
+ return null;
441
+ }
442
+ async restartAgentFromCheckpoint(session, checkpoint) {
443
+ }
444
+ async restartAgentFromBeginning(session) {
445
+ }
446
+ async provideGuidance(session, reason) {
447
+ }
448
+ /**
449
+ * Get extended coherence capabilities
450
+ */
451
+ getCoherenceCapabilities() {
452
+ const activeSessions = Array.from(this.activeSessions.values());
453
+ return {
454
+ maxSessionDuration: Math.max(...activeSessions.map((s) => s.config.maxDuration)),
455
+ activeSessionCount: activeSessions.filter((s) => s.state.status === "active").length,
456
+ averageCoherence: activeSessions.reduce((sum, s) => {
457
+ const recent = s.metrics.slice(-1)[0];
458
+ return sum + (recent ? this.calculateOverallCoherence(recent) : 0);
459
+ }, 0) / activeSessions.length,
460
+ totalInterventions: activeSessions.reduce((sum, s) => sum + s.interventions.length, 0)
461
+ };
462
+ }
463
+ }
464
+ var extended_coherence_sessions_default = ExtendedCoherenceManager;
465
+ export {
466
+ ExtendedCoherenceManager,
467
+ extended_coherence_sessions_default as default
468
+ };
469
+ //# sourceMappingURL=extended-coherence-sessions.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../../src/integrations/ralph/patterns/extended-coherence-sessions.ts"],
4
+ "sourcesContent": ["/**\n * Extended Coherence Work Sessions Implementation\n * \n * Enables agents to work continuously for hours without performance degradation.\n * Maintains contextual awareness and high-quality output over extended periods.\n * \n * Addresses the challenge of AI agents losing coherence after short time periods.\n */\n\nimport { v4 as uuidv4 } from 'uuid';\nimport * as fs from 'fs/promises';\nimport * as path from 'path';\nimport { logger } from '../../../core/monitoring/logger.js';\nimport { RalphStackMemoryBridge } from '../bridge/ralph-stackmemory-bridge.js';\n\nexport interface CoherenceMetrics {\n sessionId: string;\n startTime: number;\n currentTime: number;\n duration: number; // in minutes\n \n // Performance indicators\n outputQuality: number; // 0-1 scale\n contextRetention: number; // 0-1 scale\n taskRelevance: number; // 0-1 scale\n progressRate: number; // tasks/hour\n \n // Coherence indicators\n repetitionRate: number; // how often agent repeats itself\n divergenceRate: number; // how often agent goes off-topic\n errorRate: number; // errors per iteration\n \n // State management\n memoryUsage: number; // MB\n contextWindowUsage: number; // percentage\n stateCheckpoints: number; // number of saves\n}\n\nexport interface CoherenceSession {\n id: string;\n agent: {\n id: string;\n role: string;\n model: string;\n };\n task: {\n description: string;\n complexity: 'low' | 'medium' | 'high' | 'very_high';\n estimatedDuration: number; // minutes\n breakpoints: string[]; // natural stopping points\n };\n \n // Session configuration\n config: {\n maxDuration: number; // minutes\n coherenceThreshold: number; // 0-1, below which to intervene\n checkpointInterval: number; // minutes\n refreshStrategy: 'none' | 'checkpoint' | 'context_refresh' | 'full_restart';\n \n // Advanced coherence features\n enableMemoryPalace: boolean; // structured memory system\n enableProgressTracking: boolean; // track incremental progress\n enableAutoRefresh: boolean; // automatic context refresh\n enableHealthMonitoring: boolean; // monitor agent health\n };\n \n // Runtime state\n state: {\n status: 'active' | 'paused' | 'degraded' | 'completed' | 'failed';\n currentPhase: string;\n completedMilestones: string[];\n lastCheckpoint: number;\n interventionCount: number;\n refreshCount: number;\n };\n \n // Historical data\n metrics: CoherenceMetrics[];\n interventions: {\n timestamp: number;\n type: 'checkpoint' | 'refresh' | 'restart' | 'guidance';\n reason: string;\n effectiveness: number; // 0-1\n }[];\n}\n\n/**\n * Extended Coherence Manager\n * Orchestrates long-running agent sessions with coherence preservation\n */\nexport class ExtendedCoherenceManager {\n private activeSessions: Map<string, CoherenceSession> = new Map();\n private baseDir: string;\n private monitoringInterval?: NodeJS.Timeout;\n private performanceHistory: Map<string, number[]> = new Map();\n \n constructor(baseDir: string = './.coherence-sessions') {\n this.baseDir = baseDir;\n }\n\n /**\n * Initialize the coherence management system\n */\n async initialize(): Promise<void> {\n await fs.mkdir(this.baseDir, { recursive: true });\n \n // Start monitoring loop\n this.monitoringInterval = setInterval(\n () => this.monitorActiveSessionsHealth(),\n 60000 // Check every minute\n );\n \n logger.info('Extended Coherence Manager initialized', {\n baseDir: this.baseDir,\n monitoringEnabled: true,\n });\n }\n\n /**\n * Start an extended coherence work session\n */\n async startCoherenceSession(\n agentConfig: { id: string; role: string; model: string },\n taskConfig: {\n description: string;\n complexity: 'low' | 'medium' | 'high' | 'very_high';\n estimatedDuration: number;\n breakpoints?: string[];\n },\n sessionConfig?: Partial<CoherenceSession['config']>\n ): Promise<string> {\n const sessionId = uuidv4();\n \n // Configure session based on task complexity\n const defaultConfig = this.generateConfigForComplexity(taskConfig.complexity);\n const config = { ...defaultConfig, ...sessionConfig };\n \n const session: CoherenceSession = {\n id: sessionId,\n agent: agentConfig,\n task: {\n ...taskConfig,\n breakpoints: taskConfig.breakpoints || this.generateBreakpoints(taskConfig),\n },\n config,\n state: {\n status: 'active',\n currentPhase: 'initialization',\n completedMilestones: [],\n lastCheckpoint: Date.now(),\n interventionCount: 0,\n refreshCount: 0,\n },\n metrics: [],\n interventions: [],\n };\n\n this.activeSessions.set(sessionId, session);\n \n // Initialize session workspace\n await this.initializeSessionWorkspace(session);\n \n // Start the actual agent work session\n await this.launchAgentSession(session);\n \n logger.info('Extended coherence session started', {\n sessionId,\n agent: agentConfig.role,\n estimatedDuration: taskConfig.estimatedDuration,\n maxDuration: config.maxDuration,\n });\n\n return sessionId;\n }\n\n /**\n * Generate configuration optimized for task complexity\n */\n private generateConfigForComplexity(\n complexity: 'low' | 'medium' | 'high' | 'very_high'\n ): CoherenceSession['config'] {\n const configs = {\n low: {\n maxDuration: 60, // 1 hour\n coherenceThreshold: 0.7,\n checkpointInterval: 15, // 15 minutes\n refreshStrategy: 'checkpoint' as const,\n enableMemoryPalace: false,\n enableProgressTracking: true,\n enableAutoRefresh: false,\n enableHealthMonitoring: true,\n },\n medium: {\n maxDuration: 180, // 3 hours\n coherenceThreshold: 0.8,\n checkpointInterval: 10, // 10 minutes\n refreshStrategy: 'context_refresh' as const,\n enableMemoryPalace: true,\n enableProgressTracking: true,\n enableAutoRefresh: true,\n enableHealthMonitoring: true,\n },\n high: {\n maxDuration: 360, // 6 hours\n coherenceThreshold: 0.85,\n checkpointInterval: 8, // 8 minutes\n refreshStrategy: 'context_refresh' as const,\n enableMemoryPalace: true,\n enableProgressTracking: true,\n enableAutoRefresh: true,\n enableHealthMonitoring: true,\n },\n very_high: {\n maxDuration: 720, // 12 hours\n coherenceThreshold: 0.9,\n checkpointInterval: 5, // 5 minutes\n refreshStrategy: 'full_restart' as const,\n enableMemoryPalace: true,\n enableProgressTracking: true,\n enableAutoRefresh: true,\n enableHealthMonitoring: true,\n },\n };\n\n return configs[complexity];\n }\n\n /**\n * Monitor active sessions for coherence degradation\n */\n private async monitorActiveSessionsHealth(): Promise<void> {\n for (const [sessionId, session] of this.activeSessions) {\n if (session.state.status === 'active') {\n await this.assessSessionCoherence(session);\n }\n }\n }\n\n /**\n * Assess session coherence and intervene if necessary\n */\n private async assessSessionCoherence(session: CoherenceSession): Promise<void> {\n const metrics = await this.calculateCoherenceMetrics(session);\n session.metrics.push(metrics);\n \n // Keep only last 10 metrics for performance\n if (session.metrics.length > 10) {\n session.metrics.shift();\n }\n\n const overallCoherence = this.calculateOverallCoherence(metrics);\n \n logger.debug('Session coherence assessment', {\n sessionId: session.id,\n coherence: overallCoherence,\n threshold: session.config.coherenceThreshold,\n duration: metrics.duration,\n });\n\n // Intervene if coherence drops below threshold\n if (overallCoherence < session.config.coherenceThreshold) {\n await this.interventeInSession(session, 'coherence_degradation', overallCoherence);\n }\n \n // Check if checkpoint is due\n const timeSinceCheckpoint = Date.now() - session.state.lastCheckpoint;\n const checkpointDue = timeSinceCheckpoint > (session.config.checkpointInterval * 60 * 1000);\n \n if (checkpointDue) {\n await this.checkpointSession(session);\n }\n }\n\n /**\n * Calculate comprehensive coherence metrics\n */\n private async calculateCoherenceMetrics(session: CoherenceSession): Promise<CoherenceMetrics> {\n const now = Date.now();\n const duration = (now - session.metrics[0]?.startTime || now) / (1000 * 60); // minutes\n \n // Load recent agent outputs for analysis\n const recentOutputs = await this.getRecentAgentOutputs(session);\n \n // Calculate various coherence indicators\n const outputQuality = this.assessOutputQuality(recentOutputs);\n const contextRetention = this.assessContextRetention(recentOutputs, session.task);\n const taskRelevance = this.assessTaskRelevance(recentOutputs, session.task);\n const repetitionRate = this.calculateRepetitionRate(recentOutputs);\n const divergenceRate = this.calculateDivergenceRate(recentOutputs, session.task);\n const errorRate = this.calculateErrorRate(recentOutputs);\n const progressRate = this.calculateProgressRate(session);\n\n return {\n sessionId: session.id,\n startTime: session.metrics[0]?.startTime || now,\n currentTime: now,\n duration,\n outputQuality,\n contextRetention,\n taskRelevance,\n progressRate,\n repetitionRate,\n divergenceRate,\n errorRate,\n memoryUsage: await this.getMemoryUsage(session),\n contextWindowUsage: await this.getContextWindowUsage(session),\n stateCheckpoints: session.interventions.filter(i => i.type === 'checkpoint').length,\n };\n }\n\n /**\n * Calculate overall coherence score\n */\n private calculateOverallCoherence(metrics: CoherenceMetrics): number {\n // Weighted average of coherence indicators\n const weights = {\n outputQuality: 0.3,\n contextRetention: 0.25,\n taskRelevance: 0.25,\n repetitionPenalty: 0.1, // penalty for repetition\n divergencePenalty: 0.1, // penalty for divergence\n };\n\n const baseScore = \n metrics.outputQuality * weights.outputQuality +\n metrics.contextRetention * weights.contextRetention +\n metrics.taskRelevance * weights.taskRelevance;\n \n const penalties = \n metrics.repetitionRate * weights.repetitionPenalty +\n metrics.divergenceRate * weights.divergencePenalty;\n\n return Math.max(0, baseScore - penalties);\n }\n\n /**\n * Intervene in a session to restore coherence\n */\n private async interventeInSession(\n session: CoherenceSession,\n reason: string,\n currentCoherence: number\n ): Promise<void> {\n logger.warn('Intervening in session due to coherence degradation', {\n sessionId: session.id,\n reason,\n currentCoherence,\n interventionCount: session.state.interventionCount,\n });\n\n const intervention = {\n timestamp: Date.now(),\n type: session.config.refreshStrategy,\n reason,\n effectiveness: 0, // will be calculated later\n };\n\n switch (session.config.refreshStrategy) {\n case 'checkpoint':\n await this.checkpointSession(session);\n break;\n \n case 'context_refresh':\n await this.refreshSessionContext(session);\n break;\n \n case 'full_restart':\n await this.restartSession(session);\n break;\n \n default:\n await this.provideGuidance(session, reason);\n intervention.type = 'guidance';\n }\n\n session.interventions.push(intervention);\n session.state.interventionCount++;\n \n // Mark session as temporarily degraded\n const previousStatus = session.state.status;\n session.state.status = 'degraded';\n \n // Schedule restoration check\n setTimeout(async () => {\n const newMetrics = await this.calculateCoherenceMetrics(session);\n const newCoherence = this.calculateOverallCoherence(newMetrics);\n \n // Calculate intervention effectiveness\n intervention.effectiveness = Math.max(0, newCoherence - currentCoherence);\n \n if (newCoherence > session.config.coherenceThreshold) {\n session.state.status = 'active';\n logger.info('Session coherence restored', {\n sessionId: session.id,\n newCoherence,\n effectiveness: intervention.effectiveness,\n });\n }\n }, 120000); // Check after 2 minutes\n }\n\n /**\n * Create a checkpoint of session state\n */\n private async checkpointSession(session: CoherenceSession): Promise<void> {\n const checkpointPath = path.join(\n this.baseDir,\n session.id,\n `checkpoint-${Date.now()}.json`\n );\n \n const checkpointData = {\n timestamp: Date.now(),\n state: session.state,\n recentMetrics: session.metrics.slice(-3),\n currentPhase: session.state.currentPhase,\n completedMilestones: session.state.completedMilestones,\n // Include recent agent context\n contextSummary: await this.generateContextSummary(session),\n };\n\n await fs.writeFile(checkpointPath, JSON.stringify(checkpointData, null, 2));\n session.state.lastCheckpoint = Date.now();\n \n logger.info('Session checkpoint created', {\n sessionId: session.id,\n checkpointPath,\n });\n }\n\n /**\n * Refresh session context to restore coherence\n */\n private async refreshSessionContext(session: CoherenceSession): Promise<void> {\n logger.info('Refreshing session context', { sessionId: session.id });\n \n // Generate context refresh prompt\n const refreshPrompt = await this.generateContextRefreshPrompt(session);\n \n // Apply refresh to the running agent\n await this.applyContextRefresh(session, refreshPrompt);\n \n session.state.refreshCount++;\n }\n\n /**\n * Restart session from last good checkpoint\n */\n private async restartSession(session: CoherenceSession): Promise<void> {\n logger.info('Restarting session from checkpoint', { sessionId: session.id });\n \n // Load last checkpoint\n const checkpoint = await this.loadLatestCheckpoint(session);\n \n if (checkpoint) {\n // Restore session state\n session.state = { ...checkpoint.state };\n \n // Restart agent with checkpoint context\n await this.restartAgentFromCheckpoint(session, checkpoint);\n } else {\n // No checkpoint available, restart from beginning\n await this.restartAgentFromBeginning(session);\n }\n }\n\n /**\n * Initialize workspace for a coherence session\n */\n private async initializeSessionWorkspace(session: CoherenceSession): Promise<void> {\n const sessionDir = path.join(this.baseDir, session.id);\n await fs.mkdir(sessionDir, { recursive: true });\n \n // Create session manifest\n const manifest = {\n sessionId: session.id,\n agent: session.agent,\n task: session.task,\n config: session.config,\n createdAt: Date.now(),\n };\n \n await fs.writeFile(\n path.join(sessionDir, 'manifest.json'),\n JSON.stringify(manifest, null, 2)\n );\n }\n\n /**\n * Launch the actual agent work session\n */\n private async launchAgentSession(session: CoherenceSession): Promise<void> {\n const sessionDir = path.join(this.baseDir, session.id);\n \n // Create enhanced Ralph bridge for extended sessions\n const ralph = new RalphStackMemoryBridge({\n baseDir: sessionDir,\n maxIterations: Math.ceil(session.config.maxDuration / 5), // ~5 min per iteration\n useStackMemory: true,\n });\n\n // Configure for extended coherence\n await ralph.initialize({\n task: this.buildExtendedCoherencePrompt(session),\n criteria: session.task.breakpoints.join('\\n'),\n });\n\n // Start the session (non-blocking)\n ralph.run().catch(error => {\n logger.error('Extended coherence session failed', {\n sessionId: session.id,\n error: error.message,\n });\n session.state.status = 'failed';\n });\n }\n\n /**\n * Build prompt optimized for extended coherence\n */\n private buildExtendedCoherencePrompt(session: CoherenceSession): string {\n return `\n# EXTENDED COHERENCE WORK SESSION\n\n## Your Mission\n${session.task.description}\n\n## Session Parameters\n- Estimated Duration: ${session.task.estimatedDuration} minutes\n- Maximum Duration: ${session.config.maxDuration} minutes \n- Coherence Threshold: ${session.config.coherenceThreshold * 100}%\n\n## Coherence Guidelines\n1. **Maintain Focus**: Stay on task throughout the entire session\n2. **Track Progress**: Document incremental progress at each step\n3. **Context Awareness**: Reference previous work and maintain consistency\n4. **Quality Control**: Regularly assess your output quality\n5. **Milestone Reporting**: Report when you reach natural breakpoints\n\n## Breakpoints & Milestones\n${session.task.breakpoints.map((bp, i) => `${i + 1}. ${bp}`).join('\\n')}\n\n## Extended Session Strategy\n- Take regular checkpoint breaks (every ${session.config.checkpointInterval} minutes)\n- Summarize your progress regularly\n- Ask for context refresh if you feel you're losing focus\n- Maintain awareness of the overall project goal\n- Break complex tasks into smaller, manageable chunks\n\n## Memory Palace (if enabled)\n${session.config.enableMemoryPalace ? `\nUse structured memory organization:\n- **Project Context**: Overall goals and requirements\n- **Current Status**: What's been completed and what's next\n- **Working Memory**: Current task details and immediate context\n- **Reference Memory**: Important patterns, decisions, and learnings\n` : ''}\n\n## Success Criteria\n- Complete the task within the allocated time\n- Maintain high output quality throughout\n- Document progress and decisions clearly\n- Stay coherent and focused for the entire session\n\nBegin your extended coherence work session now.\n `;\n }\n\n // Placeholder implementations for helper methods\n private async getRecentAgentOutputs(session: CoherenceSession): Promise<any[]> {\n // Implementation to retrieve recent agent outputs\n return [];\n }\n\n private assessOutputQuality(outputs: any[]): number {\n // Analyze output quality metrics\n return 0.8; // placeholder\n }\n\n private assessContextRetention(outputs: any[], task: any): number {\n // Measure how well agent retains context\n return 0.7; // placeholder \n }\n\n private assessTaskRelevance(outputs: any[], task: any): number {\n // Measure relevance to original task\n return 0.9; // placeholder\n }\n\n private calculateRepetitionRate(outputs: any[]): number {\n // Calculate how often agent repeats itself\n return 0.1; // placeholder\n }\n\n private calculateDivergenceRate(outputs: any[], task: any): number {\n // Calculate how often agent goes off-topic\n return 0.05; // placeholder\n }\n\n private calculateErrorRate(outputs: any[]): number {\n // Calculate errors per iteration\n return 0.02; // placeholder\n }\n\n private calculateProgressRate(session: CoherenceSession): number {\n // Calculate tasks completed per hour\n return 2.5; // placeholder\n }\n\n private async getMemoryUsage(session: CoherenceSession): Promise<number> {\n // Get current memory usage\n return 150; // MB placeholder\n }\n\n private async getContextWindowUsage(session: CoherenceSession): Promise<number> {\n // Get context window usage percentage\n return 65; // placeholder\n }\n\n private generateBreakpoints(taskConfig: any): string[] {\n // Generate natural stopping points based on task\n return [\n 'Initial analysis complete',\n 'Core implementation finished',\n 'Testing phase complete',\n 'Final review and cleanup done',\n ];\n }\n\n private async generateContextSummary(session: CoherenceSession): Promise<string> {\n return `Session ${session.id} context summary`;\n }\n\n private async generateContextRefreshPrompt(session: CoherenceSession): Promise<string> {\n return 'Context refresh prompt';\n }\n\n private async applyContextRefresh(session: CoherenceSession, prompt: string): Promise<void> {\n // Apply context refresh to running agent\n }\n\n private async loadLatestCheckpoint(session: CoherenceSession): Promise<any> {\n // Load most recent checkpoint\n return null;\n }\n\n private async restartAgentFromCheckpoint(session: CoherenceSession, checkpoint: any): Promise<void> {\n // Restart agent with checkpoint state\n }\n\n private async restartAgentFromBeginning(session: CoherenceSession): Promise<void> {\n // Restart agent from the beginning\n }\n\n private async provideGuidance(session: CoherenceSession, reason: string): Promise<void> {\n // Provide guidance to help agent refocus\n }\n\n /**\n * Get extended coherence capabilities\n */\n getCoherenceCapabilities(): {\n maxSessionDuration: number;\n activeSessionCount: number;\n averageCoherence: number;\n totalInterventions: number;\n } {\n const activeSessions = Array.from(this.activeSessions.values());\n \n return {\n maxSessionDuration: Math.max(...activeSessions.map(s => s.config.maxDuration)),\n activeSessionCount: activeSessions.filter(s => s.state.status === 'active').length,\n averageCoherence: activeSessions.reduce((sum, s) => {\n const recent = s.metrics.slice(-1)[0];\n return sum + (recent ? this.calculateOverallCoherence(recent) : 0);\n }, 0) / activeSessions.length,\n totalInterventions: activeSessions.reduce((sum, s) => sum + s.interventions.length, 0),\n };\n }\n}\n\nexport default ExtendedCoherenceManager;"],
5
+ "mappings": "AASA,SAAS,MAAM,cAAc;AAC7B,YAAY,QAAQ;AACpB,YAAY,UAAU;AACtB,SAAS,cAAc;AACvB,SAAS,8BAA8B;AA6EhC,MAAM,yBAAyB;AAAA,EAC5B,iBAAgD,oBAAI,IAAI;AAAA,EACxD;AAAA,EACA;AAAA,EACA,qBAA4C,oBAAI,IAAI;AAAA,EAE5D,YAAY,UAAkB,yBAAyB;AACrD,SAAK,UAAU;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,aAA4B;AAChC,UAAM,GAAG,MAAM,KAAK,SAAS,EAAE,WAAW,KAAK,CAAC;AAGhD,SAAK,qBAAqB;AAAA,MACxB,MAAM,KAAK,4BAA4B;AAAA,MACvC;AAAA;AAAA,IACF;AAEA,WAAO,KAAK,0CAA0C;AAAA,MACpD,SAAS,KAAK;AAAA,MACd,mBAAmB;AAAA,IACrB,CAAC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,sBACJ,aACA,YAMA,eACiB;AACjB,UAAM,YAAY,OAAO;AAGzB,UAAM,gBAAgB,KAAK,4BAA4B,WAAW,UAAU;AAC5E,UAAM,SAAS,EAAE,GAAG,eAAe,GAAG,cAAc;AAEpD,UAAM,UAA4B;AAAA,MAChC,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,MAAM;AAAA,QACJ,GAAG;AAAA,QACH,aAAa,WAAW,eAAe,KAAK,oBAAoB,UAAU;AAAA,MAC5E;AAAA,MACA;AAAA,MACA,OAAO;AAAA,QACL,QAAQ;AAAA,QACR,cAAc;AAAA,QACd,qBAAqB,C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