agentic-qe 3.3.1 → 3.3.2

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 (72) hide show
  1. package/package.json +1 -1
  2. package/v3/CHANGELOG.md +46 -0
  3. package/v3/dist/cli/bundle.js +3675 -342
  4. package/v3/dist/coordination/queen-coordinator.d.ts +13 -1
  5. package/v3/dist/coordination/queen-coordinator.d.ts.map +1 -1
  6. package/v3/dist/coordination/queen-coordinator.js +91 -3
  7. package/v3/dist/coordination/queen-coordinator.js.map +1 -1
  8. package/v3/dist/domains/coverage-analysis/plugin.d.ts +6 -1
  9. package/v3/dist/domains/coverage-analysis/plugin.d.ts.map +1 -1
  10. package/v3/dist/domains/coverage-analysis/plugin.js +73 -0
  11. package/v3/dist/domains/coverage-analysis/plugin.js.map +1 -1
  12. package/v3/dist/domains/domain-interface.d.ts +39 -2
  13. package/v3/dist/domains/domain-interface.d.ts.map +1 -1
  14. package/v3/dist/domains/domain-interface.js +99 -0
  15. package/v3/dist/domains/domain-interface.js.map +1 -1
  16. package/v3/dist/domains/learning-optimization/coordinator.d.ts +83 -0
  17. package/v3/dist/domains/learning-optimization/coordinator.d.ts.map +1 -1
  18. package/v3/dist/domains/learning-optimization/coordinator.js +174 -0
  19. package/v3/dist/domains/learning-optimization/coordinator.js.map +1 -1
  20. package/v3/dist/domains/learning-optimization/interfaces.d.ts +14 -0
  21. package/v3/dist/domains/learning-optimization/interfaces.d.ts.map +1 -1
  22. package/v3/dist/domains/quality-assessment/coordinator.d.ts +23 -0
  23. package/v3/dist/domains/quality-assessment/coordinator.d.ts.map +1 -1
  24. package/v3/dist/domains/quality-assessment/coordinator.js +139 -1
  25. package/v3/dist/domains/quality-assessment/coordinator.js.map +1 -1
  26. package/v3/dist/domains/quality-assessment/plugin.d.ts +6 -1
  27. package/v3/dist/domains/quality-assessment/plugin.d.ts.map +1 -1
  28. package/v3/dist/domains/quality-assessment/plugin.js +67 -0
  29. package/v3/dist/domains/quality-assessment/plugin.js.map +1 -1
  30. package/v3/dist/domains/test-execution/plugin.d.ts +6 -1
  31. package/v3/dist/domains/test-execution/plugin.d.ts.map +1 -1
  32. package/v3/dist/domains/test-execution/plugin.js +77 -0
  33. package/v3/dist/domains/test-execution/plugin.js.map +1 -1
  34. package/v3/dist/domains/test-generation/coordinator.d.ts +40 -0
  35. package/v3/dist/domains/test-generation/coordinator.d.ts.map +1 -1
  36. package/v3/dist/domains/test-generation/coordinator.js +184 -1
  37. package/v3/dist/domains/test-generation/coordinator.js.map +1 -1
  38. package/v3/dist/domains/test-generation/plugin.d.ts +6 -1
  39. package/v3/dist/domains/test-generation/plugin.d.ts.map +1 -1
  40. package/v3/dist/domains/test-generation/plugin.js +84 -0
  41. package/v3/dist/domains/test-generation/plugin.js.map +1 -1
  42. package/v3/dist/kernel/interfaces.d.ts +54 -1
  43. package/v3/dist/kernel/interfaces.d.ts.map +1 -1
  44. package/v3/dist/learning/dream/dream-scheduler.d.ts +302 -0
  45. package/v3/dist/learning/dream/dream-scheduler.d.ts.map +1 -0
  46. package/v3/dist/learning/dream/dream-scheduler.js +551 -0
  47. package/v3/dist/learning/dream/dream-scheduler.js.map +1 -0
  48. package/v3/dist/learning/dream/index.d.ts +1 -0
  49. package/v3/dist/learning/dream/index.d.ts.map +1 -1
  50. package/v3/dist/learning/dream/index.js +4 -0
  51. package/v3/dist/learning/dream/index.js.map +1 -1
  52. package/v3/dist/mcp/bundle.js +66391 -60131
  53. package/v3/dist/mcp/handlers/core-handlers.d.ts.map +1 -1
  54. package/v3/dist/mcp/handlers/core-handlers.js +16 -2
  55. package/v3/dist/mcp/handlers/core-handlers.js.map +1 -1
  56. package/v3/dist/mcp/handlers/task-handlers.d.ts +1 -0
  57. package/v3/dist/mcp/handlers/task-handlers.d.ts.map +1 -1
  58. package/v3/dist/mcp/handlers/task-handlers.js +46 -12
  59. package/v3/dist/mcp/handlers/task-handlers.js.map +1 -1
  60. package/v3/dist/mcp/services/reasoning-bank-service.d.ts +87 -13
  61. package/v3/dist/mcp/services/reasoning-bank-service.d.ts.map +1 -1
  62. package/v3/dist/mcp/services/reasoning-bank-service.js +291 -31
  63. package/v3/dist/mcp/services/reasoning-bank-service.js.map +1 -1
  64. package/v3/dist/routing/qe-agent-registry.d.ts +27 -0
  65. package/v3/dist/routing/qe-agent-registry.d.ts.map +1 -1
  66. package/v3/dist/routing/qe-agent-registry.js +96 -0
  67. package/v3/dist/routing/qe-agent-registry.js.map +1 -1
  68. package/v3/dist/shared/events/domain-events.d.ts +27 -0
  69. package/v3/dist/shared/events/domain-events.d.ts.map +1 -1
  70. package/v3/dist/shared/events/domain-events.js +1 -0
  71. package/v3/dist/shared/events/domain-events.js.map +1 -1
  72. package/v3/package.json +1 -1
@@ -2,6 +2,7 @@
2
2
  * Agentic QE v3 - Base Domain Interface
3
3
  * Template for all domain implementations
4
4
  */
5
+ import { ok, err } from '../shared/types';
5
6
  /**
6
7
  * Abstract base class for domain plugins
7
8
  */
@@ -59,5 +60,103 @@ export class BaseDomainPlugin {
59
60
  updateHealth(updates) {
60
61
  this._health = { ...this._health, ...updates };
61
62
  }
63
+ // ============================================================================
64
+ // Task Execution (Queen-Domain Integration)
65
+ // ============================================================================
66
+ /**
67
+ * Get task type to handler mapping
68
+ * Override in subclasses to register domain-specific task handlers
69
+ *
70
+ * @example
71
+ * protected override getTaskHandlers(): Map<string, TaskHandler> {
72
+ * return new Map([
73
+ * ['execute-tests', async (payload) => this.coordinator.execute(payload)],
74
+ * ['detect-flaky', async (payload) => this.coordinator.detectFlaky(payload)],
75
+ * ]);
76
+ * }
77
+ */
78
+ getTaskHandlers() {
79
+ // Default: no handlers - subclasses override to provide domain-specific handlers
80
+ return new Map();
81
+ }
82
+ /**
83
+ * Check if domain can handle a task type
84
+ * Based on registered task handlers
85
+ */
86
+ canHandleTask(taskType) {
87
+ return this.getTaskHandlers().has(taskType);
88
+ }
89
+ /**
90
+ * Execute a task assigned by Queen Coordinator
91
+ * Routes to the appropriate handler based on task type
92
+ *
93
+ * @param request - Task execution request from Queen
94
+ * @param onComplete - Callback to report task completion
95
+ * @returns Success if task was accepted, Error if no handler exists
96
+ */
97
+ async executeTask(request, onComplete) {
98
+ const handlers = this.getTaskHandlers();
99
+ const handler = handlers.get(request.taskType);
100
+ if (!handler) {
101
+ return err(new Error(`Domain ${this.name} has no handler for task type: ${request.taskType}`));
102
+ }
103
+ // Execute asynchronously, report via callback
104
+ // Don't await - task runs in background and reports via callback
105
+ this.runTaskAsync(request, handler, onComplete);
106
+ // Return immediately - task was accepted
107
+ return ok(undefined);
108
+ }
109
+ /**
110
+ * Run task asynchronously and report completion via callback
111
+ * Handles timing, success/failure, and error capture
112
+ */
113
+ async runTaskAsync(request, handler, onComplete) {
114
+ const startTime = Date.now();
115
+ try {
116
+ // Execute the handler
117
+ const result = await handler(request.payload);
118
+ const duration = Date.now() - startTime;
119
+ // Build result based on handler outcome
120
+ const taskResult = {
121
+ taskId: request.taskId,
122
+ success: result.success,
123
+ data: result.success ? result.value : undefined,
124
+ error: !result.success ? result.error?.message : undefined,
125
+ duration,
126
+ };
127
+ // Report completion via callback
128
+ await onComplete(taskResult);
129
+ // Update health tracking
130
+ this.updateHealth({
131
+ lastActivity: new Date(),
132
+ agents: {
133
+ ...this._health.agents,
134
+ active: Math.max(0, this._health.agents.active - 1),
135
+ idle: this._health.agents.idle + 1,
136
+ },
137
+ });
138
+ }
139
+ catch (error) {
140
+ // Handler threw an exception
141
+ const duration = Date.now() - startTime;
142
+ const errorMessage = error instanceof Error ? error.message : String(error);
143
+ await onComplete({
144
+ taskId: request.taskId,
145
+ success: false,
146
+ error: errorMessage,
147
+ duration,
148
+ });
149
+ // Track error in health
150
+ this.updateHealth({
151
+ lastActivity: new Date(),
152
+ errors: [...this._health.errors.slice(-9), errorMessage],
153
+ agents: {
154
+ ...this._health.agents,
155
+ active: Math.max(0, this._health.agents.active - 1),
156
+ failed: this._health.agents.failed + 1,
157
+ },
158
+ });
159
+ }
160
+ }
62
161
  }
63
162
  //# sourceMappingURL=domain-interface.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"domain-interface.js","sourceRoot":"","sources":["../../src/domains/domain-interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH;;GAEG;AACH,MAAM,OAAgB,gBAAgB;IAWf;IACA;IAXX,YAAY,GAAG,KAAK,CAAC;IAC/B,yEAAyE;IACzE,+DAA+D;IACrD,OAAO,GAAiB;QAChC,MAAM,EAAE,MAAM;QACd,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE;QACnD,MAAM,EAAE,EAAE;KACX,CAAC;IAEF,YACqB,QAAkB,EAClB,MAAqB;QADrB,aAAQ,GAAR,QAAQ,CAAU;QAClB,WAAM,GAAN,MAAM,CAAe;IACvC,CAAC;IAMJ,OAAO;QACL,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED,SAAS;QACP,OAAO,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;IAC7B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO;QAE9B,MAAM,IAAI,CAAC,YAAY,EAAE,CAAC;QAC1B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;QACvB,IAAI,CAAC,YAAY,GAAG,KAAK,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,KAAkB;QAClC,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAID,yBAAyB;IACf,KAAK,CAAC,YAAY,KAAmB,CAAC;IACtC,KAAK,CAAC,SAAS,KAAmB,CAAC;IACnC,KAAK,CAAC,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AAO,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;iBACvC;aACF,CAAC,CAAC;QACL,CAAC;IACH,CAAC;CACF"}
@@ -7,6 +7,7 @@ import { EventBus, MemoryBackend, AgentCoordinator } from '../../kernel/interfac
7
7
  import { ILearningOptimizationCoordinator, LearningCycleReport, OptimizationReport, CrossDomainSharingReport, LearningDashboard, ModelExport, ImportReport } from './interfaces.js';
8
8
  import { type QESONAPattern, type QEPatternType, type QESONAStats, type QESONAAdaptationResult } from '../../integrations/ruvector/wrappers.js';
9
9
  import type { RLState, RLAction } from '../../integrations/rl-suite/interfaces.js';
10
+ import { type DreamSchedulerStatus, type EngineResult as DreamCycleResult } from '../../learning/dream/index.js';
10
11
  /**
11
12
  * Workflow status tracking
12
13
  */
@@ -29,6 +30,20 @@ export interface LearningCoordinatorConfig {
29
30
  enableAutoOptimization: boolean;
30
31
  publishEvents: boolean;
31
32
  learningCycleIntervalMs: number;
33
+ /** Enable dream scheduler for offline learning */
34
+ enableDreamScheduler: boolean;
35
+ /** Interval for automatic dream cycles in ms (default: same as learningCycleIntervalMs) */
36
+ dreamCycleIntervalMs: number;
37
+ /** Enable dream trigger after experience threshold */
38
+ enableExperienceTrigger: boolean;
39
+ /** Number of experiences to accumulate before triggering dream */
40
+ experienceThreshold: number;
41
+ /** Enable dream trigger on quality gate failure */
42
+ enableQualityGateFailureTrigger: boolean;
43
+ /** Automatically apply high-confidence insights from dreams */
44
+ autoApplyHighConfidenceInsights: boolean;
45
+ /** Minimum confidence threshold for auto-applying insights (0-1) */
46
+ autoApplyConfidenceThreshold: number;
32
47
  }
33
48
  /**
34
49
  * Learning & Optimization Coordinator
@@ -51,6 +66,11 @@ export declare class LearningOptimizationCoordinator implements ILearningOptimiz
51
66
  * Now uses PersistentSONAEngine to survive restarts
52
67
  */
53
68
  private sona;
69
+ /**
70
+ * DreamScheduler for offline pattern consolidation and insight generation
71
+ * Wraps DreamEngine with automatic scheduling and trigger support
72
+ */
73
+ private dreamScheduler;
54
74
  constructor(eventBus: EventBus, memory: MemoryBackend, agentCoordinator: AgentCoordinator, config?: Partial<LearningCoordinatorConfig>);
55
75
  /**
56
76
  * Initialize the coordinator.
@@ -197,6 +217,47 @@ export declare class LearningOptimizationCoordinator implements ILearningOptimiz
197
217
  timeMs: number;
198
218
  }>;
199
219
  }>;
220
+ /**
221
+ * Trigger a dream cycle manually.
222
+ * Dreams consolidate patterns and generate novel insights through spreading activation.
223
+ *
224
+ * @param durationMs - Optional duration override in ms
225
+ * @returns Dream cycle result with generated insights
226
+ * @throws Error if DreamScheduler is not initialized
227
+ */
228
+ triggerDreamCycle(durationMs?: number): Promise<DreamCycleResult>;
229
+ /**
230
+ * Get the current status of the DreamScheduler.
231
+ *
232
+ * @returns DreamScheduler status or null if not initialized
233
+ */
234
+ getDreamStatus(): DreamSchedulerStatus | null;
235
+ /**
236
+ * Check if the DreamScheduler is available and running.
237
+ *
238
+ * @returns True if DreamScheduler is initialized
239
+ */
240
+ isDreamSchedulerAvailable(): boolean;
241
+ /**
242
+ * Get the last dream cycle result from the scheduler.
243
+ *
244
+ * @returns Last dream result or null if no dreams have completed
245
+ */
246
+ getLastDreamResult(): DreamCycleResult | null;
247
+ /**
248
+ * Trigger a quick dream cycle for rapid insight generation.
249
+ *
250
+ * @returns Dream cycle result
251
+ * @throws Error if DreamScheduler is not initialized
252
+ */
253
+ triggerQuickDream(): Promise<DreamCycleResult>;
254
+ /**
255
+ * Trigger a full dream cycle for comprehensive pattern consolidation.
256
+ *
257
+ * @returns Dream cycle result
258
+ * @throws Error if DreamScheduler is not initialized
259
+ */
260
+ triggerFullDream(): Promise<DreamCycleResult>;
200
261
  /**
201
262
  * Export learned models
202
263
  */
@@ -217,6 +278,28 @@ export declare class LearningOptimizationCoordinator implements ILearningOptimiz
217
278
  private publishPatternConsolidated;
218
279
  private publishTransferCompleted;
219
280
  private publishOptimizationApplied;
281
+ /**
282
+ * Publish a dream cycle completion event.
283
+ * This broadcasts dream insights to all interested domain coordinators.
284
+ *
285
+ * Called by the DreamScheduler or DreamEngine after completing a dream cycle.
286
+ *
287
+ * @param cycleId - Unique identifier for the dream cycle
288
+ * @param durationMs - How long the dream cycle took
289
+ * @param conceptsProcessed - Number of concepts processed during dreaming
290
+ * @param insights - Array of insights generated during the dream cycle
291
+ * @param patternsCreated - Number of patterns created from insights
292
+ */
293
+ publishDreamCycleCompleted(cycleId: string, durationMs: number, conceptsProcessed: number, insights: Array<{
294
+ id: string;
295
+ type: string;
296
+ description: string;
297
+ noveltyScore: number;
298
+ confidenceScore: number;
299
+ actionable: boolean;
300
+ suggestedAction?: string;
301
+ sourceConcepts: string[];
302
+ }>, patternsCreated: number): Promise<void>;
220
303
  private spawnLearningAgent;
221
304
  private startWorkflow;
222
305
  private completeWorkflow;
@@ -1 +1 @@
1
- {"version":3,"file":"coordinator.d.ts","sourceRoot":"","sources":["../../../src/domains/learning-optimization/coordinator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,MAAM,EAGN,UAAU,EAEX,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,QAAQ,EACR,aAAa,EACb,gBAAgB,EAEjB,MAAM,4BAA4B,CAAC;AAQpC,OAAO,EACL,gCAAgC,EAChC,mBAAmB,EACnB,kBAAkB,EAClB,wBAAwB,EACxB,iBAAiB,EACjB,WAAW,EACX,YAAY,EASb,MAAM,iBAAiB,CAAC;AAWzB,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,sBAAsB,EAC5B,MAAM,yCAAyC,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AAGnF;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,GAAG,cAAc,GAAG,UAAU,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAC3E,MAAM,EAAE,SAAS,GAA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I,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,EAAE,MAAM,CAAC;QACrB,eAAe,EAAE,MAAM,CAAC;QACxB,UAAU,EAAE,OAAO,CAAC;QACpB,eAAe,CAAC,EAAE,MAAM,CAAC;QACzB,cAAc,EAAE,MAAM,EAAE,CAAC;KAC1B,CAAC,EACF,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,IAAI,CAAC;YA8BF,kBAAkB;IA0BhC,OAAO,CAAC,aAAa;IAqBrB,OAAO,CAAC,gBAAgB;IASxB,OAAO,CAAC,YAAY;IASpB,OAAO,CAAC,kBAAkB;IAO1B,OAAO,CAAC,sBAAsB;YAWhB,iBAAiB;YAiBjB,iBAAiB;YAajB,uBAAuB;YAyBvB,kBAAkB;YA8BlB,aAAa;IAU3B,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,mBAAmB;IA+B3B,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,iBAAiB;CAwB1B"}
@@ -8,12 +8,21 @@ import { TimeRange } from '../../shared/value-objects/index.js';
8
8
  import { LearningOptimizationEvents, createEvent, } from '../../shared/events/domain-events.js';
9
9
  import { LearningCoordinatorService, TransferSpecialistService, MetricsOptimizerService, ProductionIntelService, } from './services/index.js';
10
10
  import { createPersistentSONAEngine, } from '../../integrations/ruvector/sona-persistence.js';
11
+ import { createDreamScheduler, createDreamEngine, } from '../../learning/dream/index.js';
11
12
  const DEFAULT_CONFIG = {
12
13
  maxConcurrentWorkflows: 3,
13
14
  defaultTimeout: 120000, // 2 minutes
14
15
  enableAutoOptimization: true,
15
16
  publishEvents: true,
16
17
  learningCycleIntervalMs: 3600000, // 1 hour
18
+ // Dream Scheduler defaults
19
+ enableDreamScheduler: true,
20
+ dreamCycleIntervalMs: 3600000, // 1 hour
21
+ enableExperienceTrigger: true,
22
+ experienceThreshold: 50,
23
+ enableQualityGateFailureTrigger: true,
24
+ autoApplyHighConfidenceInsights: false,
25
+ autoApplyConfidenceThreshold: 0.8,
17
26
  };
18
27
  /**
19
28
  * Learning & Optimization Coordinator
@@ -36,6 +45,11 @@ export class LearningOptimizationCoordinator {
36
45
  * Now uses PersistentSONAEngine to survive restarts
37
46
  */
38
47
  sona;
48
+ /**
49
+ * DreamScheduler for offline pattern consolidation and insight generation
50
+ * Wraps DreamEngine with automatic scheduling and trigger support
51
+ */
52
+ dreamScheduler = null;
39
53
  constructor(eventBus, memory, agentCoordinator, config = {}) {
40
54
  this.eventBus = eventBus;
41
55
  this.memory = memory;
@@ -68,6 +82,32 @@ export class LearningOptimizationCoordinator {
68
82
  console.error('[LearningOptimizationCoordinator] Failed to initialize PersistentSONAEngine:', error);
69
83
  throw error; // Learning optimization requires SONA
70
84
  }
85
+ // Initialize DreamScheduler if enabled
86
+ if (this.config.enableDreamScheduler) {
87
+ try {
88
+ const dreamEngine = await createDreamEngine();
89
+ await dreamEngine.initialize();
90
+ this.dreamScheduler = createDreamScheduler({
91
+ dreamEngine,
92
+ eventBus: this.eventBus,
93
+ memoryBackend: this.memory,
94
+ }, {
95
+ autoScheduleIntervalMs: this.config.dreamCycleIntervalMs,
96
+ enableExperienceTrigger: this.config.enableExperienceTrigger,
97
+ experienceThreshold: this.config.experienceThreshold,
98
+ enableQualityGateFailureTrigger: this.config.enableQualityGateFailureTrigger,
99
+ autoApplyHighConfidenceInsights: this.config.autoApplyHighConfidenceInsights,
100
+ insightConfidenceThreshold: this.config.autoApplyConfidenceThreshold,
101
+ });
102
+ await this.dreamScheduler.initialize();
103
+ this.dreamScheduler.start();
104
+ console.log('[LearningOptimizationCoordinator] DreamScheduler initialized and started');
105
+ }
106
+ catch (error) {
107
+ console.warn('[LearningOptimizationCoordinator] Failed to initialize DreamScheduler:', error);
108
+ // DreamScheduler is optional - continue without it
109
+ }
110
+ }
71
111
  // Subscribe to relevant events
72
112
  this.subscribeToEvents();
73
113
  // Load any persisted workflow state
@@ -82,6 +122,17 @@ export class LearningOptimizationCoordinator {
82
122
  await this.saveWorkflowState();
83
123
  // Clear active workflows
84
124
  this.workflows.clear();
125
+ // Dispose DreamScheduler
126
+ if (this.dreamScheduler) {
127
+ try {
128
+ await this.dreamScheduler.dispose();
129
+ console.log('[LearningOptimizationCoordinator] DreamScheduler disposed');
130
+ }
131
+ catch (error) {
132
+ console.error('[LearningOptimizationCoordinator] Error disposing DreamScheduler:', error);
133
+ }
134
+ this.dreamScheduler = null;
135
+ }
85
136
  // V3: Clean up SONA engine (persistent patterns)
86
137
  if (this.initialized && this.sona) {
87
138
  try {
@@ -528,6 +579,85 @@ export class LearningOptimizationCoordinator {
528
579
  this.ensureInitialized();
529
580
  return this.sona.verifyPerformance(iterations);
530
581
  }
582
+ // ============================================================================
583
+ // Dream Scheduler Methods
584
+ // ============================================================================
585
+ /**
586
+ * Trigger a dream cycle manually.
587
+ * Dreams consolidate patterns and generate novel insights through spreading activation.
588
+ *
589
+ * @param durationMs - Optional duration override in ms
590
+ * @returns Dream cycle result with generated insights
591
+ * @throws Error if DreamScheduler is not initialized
592
+ */
593
+ async triggerDreamCycle(durationMs) {
594
+ if (!this.dreamScheduler) {
595
+ throw new Error('[LearningOptimizationCoordinator] DreamScheduler not initialized');
596
+ }
597
+ const result = await this.dreamScheduler.triggerDream(durationMs);
598
+ // Publish event for other domains to consume
599
+ if (this.config.publishEvents) {
600
+ await this.publishDreamCycleCompleted(result.cycle.id, result.cycle.durationMs ?? 0, result.cycle.conceptsProcessed, result.insights.map((i) => ({
601
+ id: i.id,
602
+ type: i.type,
603
+ description: i.description,
604
+ noveltyScore: i.noveltyScore,
605
+ confidenceScore: i.confidenceScore,
606
+ actionable: i.actionable,
607
+ suggestedAction: i.suggestedAction,
608
+ sourceConcepts: i.sourceConcepts,
609
+ })), result.patternsCreated);
610
+ }
611
+ return result;
612
+ }
613
+ /**
614
+ * Get the current status of the DreamScheduler.
615
+ *
616
+ * @returns DreamScheduler status or null if not initialized
617
+ */
618
+ getDreamStatus() {
619
+ return this.dreamScheduler?.getStatus() ?? null;
620
+ }
621
+ /**
622
+ * Check if the DreamScheduler is available and running.
623
+ *
624
+ * @returns True if DreamScheduler is initialized
625
+ */
626
+ isDreamSchedulerAvailable() {
627
+ return this.dreamScheduler !== null;
628
+ }
629
+ /**
630
+ * Get the last dream cycle result from the scheduler.
631
+ *
632
+ * @returns Last dream result or null if no dreams have completed
633
+ */
634
+ getLastDreamResult() {
635
+ return this.dreamScheduler?.getLastDreamResult() ?? null;
636
+ }
637
+ /**
638
+ * Trigger a quick dream cycle for rapid insight generation.
639
+ *
640
+ * @returns Dream cycle result
641
+ * @throws Error if DreamScheduler is not initialized
642
+ */
643
+ async triggerQuickDream() {
644
+ if (!this.dreamScheduler) {
645
+ throw new Error('[LearningOptimizationCoordinator] DreamScheduler not initialized');
646
+ }
647
+ return this.dreamScheduler.triggerQuickDream();
648
+ }
649
+ /**
650
+ * Trigger a full dream cycle for comprehensive pattern consolidation.
651
+ *
652
+ * @returns Dream cycle result
653
+ * @throws Error if DreamScheduler is not initialized
654
+ */
655
+ async triggerFullDream() {
656
+ if (!this.dreamScheduler) {
657
+ throw new Error('[LearningOptimizationCoordinator] DreamScheduler not initialized');
658
+ }
659
+ return this.dreamScheduler.triggerFullDream();
660
+ }
531
661
  /**
532
662
  * Export learned models
533
663
  */
@@ -879,6 +1009,23 @@ export class LearningOptimizationCoordinator {
879
1009
  }
880
1010
  console.log(`[LearningOptimizationCoordinator] Experience ${experience.id} transferred to ${relatedDomains.length} related domains`);
881
1011
  }
1012
+ // Record experience for dream scheduler to trigger insight generation
1013
+ if (this.dreamScheduler) {
1014
+ this.dreamScheduler.recordExperience({
1015
+ id: experience.id,
1016
+ agentType: experience.agent || 'unknown',
1017
+ domain: domain,
1018
+ taskType: experience.task,
1019
+ success: experience.success,
1020
+ duration: experience.durationMs,
1021
+ context: {
1022
+ quality: experience.quality,
1023
+ steps: experience.steps.length,
1024
+ patterns: experience.patterns?.length || 0,
1025
+ },
1026
+ timestamp: new Date(experience.startedAt),
1027
+ });
1028
+ }
882
1029
  }
883
1030
  // ============================================================================
884
1031
  // Event Publishing
@@ -909,6 +1056,33 @@ export class LearningOptimizationCoordinator {
909
1056
  });
910
1057
  await this.eventBus.publish(event);
911
1058
  }
1059
+ /**
1060
+ * Publish a dream cycle completion event.
1061
+ * This broadcasts dream insights to all interested domain coordinators.
1062
+ *
1063
+ * Called by the DreamScheduler or DreamEngine after completing a dream cycle.
1064
+ *
1065
+ * @param cycleId - Unique identifier for the dream cycle
1066
+ * @param durationMs - How long the dream cycle took
1067
+ * @param conceptsProcessed - Number of concepts processed during dreaming
1068
+ * @param insights - Array of insights generated during the dream cycle
1069
+ * @param patternsCreated - Number of patterns created from insights
1070
+ */
1071
+ async publishDreamCycleCompleted(cycleId, durationMs, conceptsProcessed, insights, patternsCreated) {
1072
+ if (!this.config.publishEvents) {
1073
+ return;
1074
+ }
1075
+ const payload = {
1076
+ cycleId,
1077
+ durationMs,
1078
+ conceptsProcessed,
1079
+ insights,
1080
+ patternsCreated,
1081
+ };
1082
+ const event = createEvent(LearningOptimizationEvents.DreamCycleCompleted, 'learning-optimization', payload);
1083
+ await this.eventBus.publish(event);
1084
+ console.log(`[LearningOptimizationCoordinator] Published dream cycle completion: ${insights.length} insights for ${conceptsProcessed} concepts`);
1085
+ }
912
1086
  // ============================================================================
913
1087
  // Agent Management
914
1088
  // ============================================================================