genesis-ai-cli 7.4.5

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 (227) hide show
  1. package/.env.example +78 -0
  2. package/README.md +282 -0
  3. package/dist/src/active-inference/actions.d.ts +75 -0
  4. package/dist/src/active-inference/actions.js +250 -0
  5. package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
  6. package/dist/src/active-inference/autonomous-loop.js +289 -0
  7. package/dist/src/active-inference/core.d.ts +85 -0
  8. package/dist/src/active-inference/core.js +555 -0
  9. package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
  10. package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
  11. package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
  12. package/dist/src/active-inference/demo-value-integration.js +174 -0
  13. package/dist/src/active-inference/index.d.ts +32 -0
  14. package/dist/src/active-inference/index.js +88 -0
  15. package/dist/src/active-inference/integration.d.ts +114 -0
  16. package/dist/src/active-inference/integration.js +698 -0
  17. package/dist/src/active-inference/memory-integration.d.ts +51 -0
  18. package/dist/src/active-inference/memory-integration.js +232 -0
  19. package/dist/src/active-inference/observations.d.ts +67 -0
  20. package/dist/src/active-inference/observations.js +147 -0
  21. package/dist/src/active-inference/test-active-inference.d.ts +8 -0
  22. package/dist/src/active-inference/test-active-inference.js +320 -0
  23. package/dist/src/active-inference/test-value-integration.d.ts +6 -0
  24. package/dist/src/active-inference/test-value-integration.js +168 -0
  25. package/dist/src/active-inference/types.d.ts +150 -0
  26. package/dist/src/active-inference/types.js +59 -0
  27. package/dist/src/active-inference/value-integration.d.ts +164 -0
  28. package/dist/src/active-inference/value-integration.js +459 -0
  29. package/dist/src/agents/base-agent.d.ts +53 -0
  30. package/dist/src/agents/base-agent.js +178 -0
  31. package/dist/src/agents/builder.d.ts +67 -0
  32. package/dist/src/agents/builder.js +537 -0
  33. package/dist/src/agents/critic.d.ts +35 -0
  34. package/dist/src/agents/critic.js +322 -0
  35. package/dist/src/agents/ethicist.d.ts +54 -0
  36. package/dist/src/agents/ethicist.js +393 -0
  37. package/dist/src/agents/explorer.d.ts +26 -0
  38. package/dist/src/agents/explorer.js +216 -0
  39. package/dist/src/agents/feeling.d.ts +41 -0
  40. package/dist/src/agents/feeling.js +320 -0
  41. package/dist/src/agents/index.d.ts +111 -0
  42. package/dist/src/agents/index.js +222 -0
  43. package/dist/src/agents/memory.d.ts +69 -0
  44. package/dist/src/agents/memory.js +404 -0
  45. package/dist/src/agents/message-bus.d.ts +88 -0
  46. package/dist/src/agents/message-bus.js +267 -0
  47. package/dist/src/agents/narrator.d.ts +90 -0
  48. package/dist/src/agents/narrator.js +473 -0
  49. package/dist/src/agents/planner.d.ts +38 -0
  50. package/dist/src/agents/planner.js +341 -0
  51. package/dist/src/agents/predictor.d.ts +73 -0
  52. package/dist/src/agents/predictor.js +506 -0
  53. package/dist/src/agents/sensor.d.ts +88 -0
  54. package/dist/src/agents/sensor.js +377 -0
  55. package/dist/src/agents/test-agents.d.ts +6 -0
  56. package/dist/src/agents/test-agents.js +73 -0
  57. package/dist/src/agents/types.d.ts +194 -0
  58. package/dist/src/agents/types.js +7 -0
  59. package/dist/src/brain/index.d.ts +185 -0
  60. package/dist/src/brain/index.js +843 -0
  61. package/dist/src/brain/trace.d.ts +91 -0
  62. package/dist/src/brain/trace.js +327 -0
  63. package/dist/src/brain/types.d.ts +165 -0
  64. package/dist/src/brain/types.js +51 -0
  65. package/dist/src/cli/chat.d.ts +237 -0
  66. package/dist/src/cli/chat.js +1959 -0
  67. package/dist/src/cli/dispatcher.d.ts +182 -0
  68. package/dist/src/cli/dispatcher.js +718 -0
  69. package/dist/src/cli/human-loop.d.ts +170 -0
  70. package/dist/src/cli/human-loop.js +543 -0
  71. package/dist/src/cli/index.d.ts +12 -0
  72. package/dist/src/cli/index.js +28 -0
  73. package/dist/src/cli/interactive.d.ts +141 -0
  74. package/dist/src/cli/interactive.js +757 -0
  75. package/dist/src/cli/ui.d.ts +205 -0
  76. package/dist/src/cli/ui.js +632 -0
  77. package/dist/src/consciousness/attention-schema.d.ts +154 -0
  78. package/dist/src/consciousness/attention-schema.js +432 -0
  79. package/dist/src/consciousness/global-workspace.d.ts +149 -0
  80. package/dist/src/consciousness/global-workspace.js +422 -0
  81. package/dist/src/consciousness/index.d.ts +186 -0
  82. package/dist/src/consciousness/index.js +476 -0
  83. package/dist/src/consciousness/phi-calculator.d.ts +119 -0
  84. package/dist/src/consciousness/phi-calculator.js +445 -0
  85. package/dist/src/consciousness/phi-decisions.d.ts +169 -0
  86. package/dist/src/consciousness/phi-decisions.js +383 -0
  87. package/dist/src/consciousness/phi-monitor.d.ts +153 -0
  88. package/dist/src/consciousness/phi-monitor.js +465 -0
  89. package/dist/src/consciousness/types.d.ts +260 -0
  90. package/dist/src/consciousness/types.js +44 -0
  91. package/dist/src/daemon/dream-mode.d.ts +115 -0
  92. package/dist/src/daemon/dream-mode.js +470 -0
  93. package/dist/src/daemon/index.d.ts +162 -0
  94. package/dist/src/daemon/index.js +542 -0
  95. package/dist/src/daemon/maintenance.d.ts +139 -0
  96. package/dist/src/daemon/maintenance.js +549 -0
  97. package/dist/src/daemon/process.d.ts +82 -0
  98. package/dist/src/daemon/process.js +442 -0
  99. package/dist/src/daemon/scheduler.d.ts +90 -0
  100. package/dist/src/daemon/scheduler.js +494 -0
  101. package/dist/src/daemon/types.d.ts +213 -0
  102. package/dist/src/daemon/types.js +50 -0
  103. package/dist/src/epistemic/index.d.ts +74 -0
  104. package/dist/src/epistemic/index.js +225 -0
  105. package/dist/src/grounding/epistemic-stack.d.ts +100 -0
  106. package/dist/src/grounding/epistemic-stack.js +408 -0
  107. package/dist/src/grounding/feedback.d.ts +98 -0
  108. package/dist/src/grounding/feedback.js +276 -0
  109. package/dist/src/grounding/index.d.ts +123 -0
  110. package/dist/src/grounding/index.js +224 -0
  111. package/dist/src/grounding/verifier.d.ts +149 -0
  112. package/dist/src/grounding/verifier.js +484 -0
  113. package/dist/src/healing/detector.d.ts +110 -0
  114. package/dist/src/healing/detector.js +436 -0
  115. package/dist/src/healing/fixer.d.ts +138 -0
  116. package/dist/src/healing/fixer.js +572 -0
  117. package/dist/src/healing/index.d.ts +23 -0
  118. package/dist/src/healing/index.js +43 -0
  119. package/dist/src/hooks/index.d.ts +135 -0
  120. package/dist/src/hooks/index.js +317 -0
  121. package/dist/src/index.d.ts +23 -0
  122. package/dist/src/index.js +1266 -0
  123. package/dist/src/kernel/index.d.ts +155 -0
  124. package/dist/src/kernel/index.js +795 -0
  125. package/dist/src/kernel/invariants.d.ts +153 -0
  126. package/dist/src/kernel/invariants.js +355 -0
  127. package/dist/src/kernel/test-kernel.d.ts +6 -0
  128. package/dist/src/kernel/test-kernel.js +108 -0
  129. package/dist/src/kernel/test-real-mcp.d.ts +10 -0
  130. package/dist/src/kernel/test-real-mcp.js +295 -0
  131. package/dist/src/llm/index.d.ts +146 -0
  132. package/dist/src/llm/index.js +428 -0
  133. package/dist/src/llm/router.d.ts +136 -0
  134. package/dist/src/llm/router.js +510 -0
  135. package/dist/src/mcp/index.d.ts +85 -0
  136. package/dist/src/mcp/index.js +657 -0
  137. package/dist/src/mcp/resilient.d.ts +139 -0
  138. package/dist/src/mcp/resilient.js +417 -0
  139. package/dist/src/memory/cache.d.ts +118 -0
  140. package/dist/src/memory/cache.js +356 -0
  141. package/dist/src/memory/cognitive-workspace.d.ts +231 -0
  142. package/dist/src/memory/cognitive-workspace.js +521 -0
  143. package/dist/src/memory/consolidation.d.ts +99 -0
  144. package/dist/src/memory/consolidation.js +443 -0
  145. package/dist/src/memory/episodic.d.ts +114 -0
  146. package/dist/src/memory/episodic.js +394 -0
  147. package/dist/src/memory/forgetting.d.ts +134 -0
  148. package/dist/src/memory/forgetting.js +324 -0
  149. package/dist/src/memory/index.d.ts +211 -0
  150. package/dist/src/memory/index.js +367 -0
  151. package/dist/src/memory/indexer.d.ts +123 -0
  152. package/dist/src/memory/indexer.js +479 -0
  153. package/dist/src/memory/procedural.d.ts +136 -0
  154. package/dist/src/memory/procedural.js +479 -0
  155. package/dist/src/memory/semantic.d.ts +132 -0
  156. package/dist/src/memory/semantic.js +497 -0
  157. package/dist/src/memory/types.d.ts +193 -0
  158. package/dist/src/memory/types.js +15 -0
  159. package/dist/src/orchestrator.d.ts +65 -0
  160. package/dist/src/orchestrator.js +317 -0
  161. package/dist/src/persistence/index.d.ts +257 -0
  162. package/dist/src/persistence/index.js +763 -0
  163. package/dist/src/pipeline/executor.d.ts +51 -0
  164. package/dist/src/pipeline/executor.js +695 -0
  165. package/dist/src/pipeline/index.d.ts +7 -0
  166. package/dist/src/pipeline/index.js +11 -0
  167. package/dist/src/self-production.d.ts +67 -0
  168. package/dist/src/self-production.js +205 -0
  169. package/dist/src/subagents/executor.d.ts +58 -0
  170. package/dist/src/subagents/executor.js +283 -0
  171. package/dist/src/subagents/index.d.ts +37 -0
  172. package/dist/src/subagents/index.js +53 -0
  173. package/dist/src/subagents/registry.d.ts +23 -0
  174. package/dist/src/subagents/registry.js +167 -0
  175. package/dist/src/subagents/types.d.ts +79 -0
  176. package/dist/src/subagents/types.js +14 -0
  177. package/dist/src/tools/bash.d.ts +139 -0
  178. package/dist/src/tools/bash.js +583 -0
  179. package/dist/src/tools/edit.d.ts +125 -0
  180. package/dist/src/tools/edit.js +424 -0
  181. package/dist/src/tools/git.d.ts +179 -0
  182. package/dist/src/tools/git.js +504 -0
  183. package/dist/src/tools/index.d.ts +21 -0
  184. package/dist/src/tools/index.js +163 -0
  185. package/dist/src/types.d.ts +145 -0
  186. package/dist/src/types.js +7 -0
  187. package/dist/src/world-model/decoder.d.ts +163 -0
  188. package/dist/src/world-model/decoder.js +517 -0
  189. package/dist/src/world-model/digital-twin.d.ts +219 -0
  190. package/dist/src/world-model/digital-twin.js +695 -0
  191. package/dist/src/world-model/encoder.d.ts +141 -0
  192. package/dist/src/world-model/encoder.js +564 -0
  193. package/dist/src/world-model/index.d.ts +221 -0
  194. package/dist/src/world-model/index.js +772 -0
  195. package/dist/src/world-model/predictor.d.ts +161 -0
  196. package/dist/src/world-model/predictor.js +681 -0
  197. package/dist/src/world-model/test-value-jepa.d.ts +8 -0
  198. package/dist/src/world-model/test-value-jepa.js +430 -0
  199. package/dist/src/world-model/types.d.ts +341 -0
  200. package/dist/src/world-model/types.js +69 -0
  201. package/dist/src/world-model/value-jepa.d.ts +247 -0
  202. package/dist/src/world-model/value-jepa.js +622 -0
  203. package/dist/test/brain.test.d.ts +11 -0
  204. package/dist/test/brain.test.js +358 -0
  205. package/dist/test/cli/dispatcher.test.d.ts +4 -0
  206. package/dist/test/cli/dispatcher.test.js +332 -0
  207. package/dist/test/cli/human-loop.test.d.ts +4 -0
  208. package/dist/test/cli/human-loop.test.js +270 -0
  209. package/dist/test/grounding/feedback.test.d.ts +4 -0
  210. package/dist/test/grounding/feedback.test.js +462 -0
  211. package/dist/test/grounding/verifier.test.d.ts +4 -0
  212. package/dist/test/grounding/verifier.test.js +442 -0
  213. package/dist/test/grounding.test.d.ts +6 -0
  214. package/dist/test/grounding.test.js +246 -0
  215. package/dist/test/healing/detector.test.d.ts +4 -0
  216. package/dist/test/healing/detector.test.js +266 -0
  217. package/dist/test/healing/fixer.test.d.ts +4 -0
  218. package/dist/test/healing/fixer.test.js +369 -0
  219. package/dist/test/integration.test.d.ts +5 -0
  220. package/dist/test/integration.test.js +290 -0
  221. package/dist/test/tools/bash.test.d.ts +4 -0
  222. package/dist/test/tools/bash.test.js +348 -0
  223. package/dist/test/tools/edit.test.d.ts +4 -0
  224. package/dist/test/tools/edit.test.js +350 -0
  225. package/dist/test/tools/git.test.d.ts +4 -0
  226. package/dist/test/tools/git.test.js +350 -0
  227. package/package.json +60 -0
@@ -0,0 +1,260 @@
1
+ /**
2
+ * Genesis 6.0 - Consciousness Module Types
3
+ *
4
+ * Types for consciousness monitoring based on:
5
+ * - IIT 4.0 (Integrated Information Theory) - Tononi et al.
6
+ * - GWT (Global Workspace Theory) - Baars
7
+ * - AST (Attention Schema Theory) - Graziano
8
+ *
9
+ * Key insight: Consciousness as integrated information that
10
+ * emerges from the interaction of specialized modules.
11
+ */
12
+ /**
13
+ * Consciousness level indicator
14
+ * Based on IIT's φ (phi) - integrated information
15
+ */
16
+ export interface ConsciousnessLevel {
17
+ phi: number;
18
+ rawPhi: number;
19
+ confidence: number;
20
+ timestamp: Date;
21
+ }
22
+ /**
23
+ * Consciousness state classification
24
+ */
25
+ export type ConsciousnessState = 'alert' | 'aware' | 'drowsy' | 'dormant' | 'fragmented';
26
+ /**
27
+ * Trend in consciousness level
28
+ */
29
+ export type ConsciousnessTrend = 'rising' | 'stable' | 'falling';
30
+ /**
31
+ * System state for φ calculation
32
+ * Represents the current configuration of all system components
33
+ */
34
+ export interface SystemState {
35
+ components: ComponentState[];
36
+ connections: Connection[];
37
+ stateHash: string;
38
+ timestamp: Date;
39
+ }
40
+ export interface ComponentState {
41
+ id: string;
42
+ type: string;
43
+ active: boolean;
44
+ state: Record<string, unknown>;
45
+ entropy: number;
46
+ lastUpdate: Date;
47
+ }
48
+ export interface Connection {
49
+ from: string;
50
+ to: string;
51
+ strength: number;
52
+ informationFlow: number;
53
+ bidirectional: boolean;
54
+ }
55
+ /**
56
+ * Partition of a system for φ calculation
57
+ * IIT requires finding the Minimum Information Partition (MIP)
58
+ */
59
+ export interface Partition {
60
+ id: string;
61
+ parts: string[][];
62
+ cut: Cut;
63
+ }
64
+ export interface Cut {
65
+ severedConnections: Array<{
66
+ from: string;
67
+ to: string;
68
+ }>;
69
+ informationLoss: number;
70
+ }
71
+ /**
72
+ * φ calculation result
73
+ */
74
+ export interface PhiResult {
75
+ phi: number;
76
+ mip: Partition;
77
+ intrinsicInfo: number;
78
+ integratedInfo: number;
79
+ complexes: Complex[];
80
+ calculationTime: number;
81
+ approximation: boolean;
82
+ }
83
+ /**
84
+ * A complex is a set of elements with φ > 0
85
+ */
86
+ export interface Complex {
87
+ elements: string[];
88
+ phi: number;
89
+ mainComplex: boolean;
90
+ }
91
+ /**
92
+ * A module that can propose content to the workspace
93
+ */
94
+ export interface WorkspaceModule {
95
+ id: string;
96
+ name: string;
97
+ type: ModuleType;
98
+ active: boolean;
99
+ load: number;
100
+ canPropose(): boolean;
101
+ propose(): WorkspaceContent | null;
102
+ receive(content: WorkspaceContent): void;
103
+ bottomUpSalience(): number;
104
+ topDownRelevance(goal: string): number;
105
+ }
106
+ export type ModuleType = 'perceptual' | 'memory' | 'motor' | 'executive' | 'evaluative' | 'metacognitive';
107
+ /**
108
+ * Content that can be broadcast in the workspace
109
+ */
110
+ export interface WorkspaceContent {
111
+ id: string;
112
+ sourceModule: string;
113
+ type: ContentType;
114
+ data: unknown;
115
+ salience: number;
116
+ relevance: number;
117
+ timestamp: Date;
118
+ ttl: number;
119
+ }
120
+ export type ContentType = 'percept' | 'memory' | 'goal' | 'plan' | 'emotion' | 'thought' | 'attention';
121
+ /**
122
+ * Workspace state
123
+ */
124
+ export interface WorkspaceState {
125
+ current: WorkspaceContent | null;
126
+ history: WorkspaceContent[];
127
+ historyLimit: number;
128
+ candidates: WorkspaceCandidate[];
129
+ lastSelection: Date;
130
+ selectionCount: number;
131
+ ignited: boolean;
132
+ ignitionTime: Date | null;
133
+ }
134
+ export interface WorkspaceCandidate {
135
+ content: WorkspaceContent;
136
+ module: string;
137
+ score: number;
138
+ selected: boolean;
139
+ }
140
+ /**
141
+ * Ignition event - when content "wins" and broadcasts
142
+ */
143
+ export interface IgnitionEvent {
144
+ content: WorkspaceContent;
145
+ timestamp: Date;
146
+ competitorCount: number;
147
+ winningScore: number;
148
+ modulesNotified: string[];
149
+ duration: number;
150
+ }
151
+ /**
152
+ * Attention state - where is attention directed
153
+ */
154
+ export interface AttentionState {
155
+ focus: AttentionFocus | null;
156
+ history: AttentionFocus[];
157
+ capacity: number;
158
+ used: number;
159
+ mode: AttentionMode;
160
+ }
161
+ export interface AttentionFocus {
162
+ target: string;
163
+ type: 'internal' | 'external';
164
+ intensity: number;
165
+ startedAt: Date;
166
+ duration: number;
167
+ }
168
+ export type AttentionMode = 'focused' | 'diffuse' | 'vigilant' | 'mind-wandering';
169
+ /**
170
+ * Attention schema - model of attention itself
171
+ * This is what creates the "experience" of awareness
172
+ */
173
+ export interface AttentionSchema {
174
+ selfModel: SelfAttentionModel;
175
+ awarenessModel: AwarenessModel;
176
+ otherModels: Map<string, OtherAttentionModel>;
177
+ }
178
+ export interface SelfAttentionModel {
179
+ perceivedFocus: string;
180
+ metacognitiveConfidence: number;
181
+ voluntaryControl: number;
182
+ }
183
+ export interface AwarenessModel {
184
+ contents: string[];
185
+ clarity: number;
186
+ phenomenalQuality: PhenomenalQuality;
187
+ }
188
+ export interface OtherAttentionModel {
189
+ agentId: string;
190
+ inferredFocus: string;
191
+ confidence: number;
192
+ lastUpdated: Date;
193
+ }
194
+ export type PhenomenalQuality = 'vivid' | 'muted' | 'absent';
195
+ /**
196
+ * Complete consciousness snapshot
197
+ */
198
+ export interface ConsciousnessSnapshot {
199
+ level: ConsciousnessLevel;
200
+ state: ConsciousnessState;
201
+ trend: ConsciousnessTrend;
202
+ phi: PhiResult;
203
+ workspace: WorkspaceState;
204
+ lastIgnition: IgnitionEvent | null;
205
+ attention: AttentionState;
206
+ schema: AttentionSchema;
207
+ agentPhi: Map<string, number>;
208
+ timestamp: Date;
209
+ }
210
+ /**
211
+ * Consciousness anomaly
212
+ */
213
+ export interface ConsciousnessAnomaly {
214
+ type: AnomalyType;
215
+ severity: 'low' | 'medium' | 'high' | 'critical';
216
+ description: string;
217
+ detected: Date;
218
+ metrics: Record<string, number>;
219
+ resolved: boolean;
220
+ resolution?: string;
221
+ }
222
+ export type AnomalyType = 'phi_drop' | 'phi_spike' | 'integration_failure' | 'workspace_deadlock' | 'attention_fragmented' | 'coherence_loss';
223
+ export interface ConsciousnessConfig {
224
+ phi: {
225
+ enabled: boolean;
226
+ updateIntervalMs: number;
227
+ approximationLevel: 'exact' | 'fast' | 'faster';
228
+ minPhi: number;
229
+ };
230
+ gwt: {
231
+ enabled: boolean;
232
+ workspaceCapacity: number;
233
+ selectionIntervalMs: number;
234
+ broadcastTimeoutMs: number;
235
+ historyLimit: number;
236
+ };
237
+ ast: {
238
+ enabled: boolean;
239
+ attentionCapacity: number;
240
+ schemaUpdateIntervalMs: number;
241
+ theoryOfMindEnabled: boolean;
242
+ };
243
+ monitor: {
244
+ snapshotIntervalMs: number;
245
+ historyLimit: number;
246
+ anomalyDetection: boolean;
247
+ alertThresholds: {
248
+ phiDrop: number;
249
+ phiMin: number;
250
+ };
251
+ };
252
+ }
253
+ export declare const DEFAULT_CONSCIOUSNESS_CONFIG: ConsciousnessConfig;
254
+ export type ConsciousnessEventType = 'phi_updated' | 'phi_threshold_crossed' | 'state_changed' | 'workspace_ignition' | 'attention_shifted' | 'anomaly_detected' | 'anomaly_resolved';
255
+ export interface ConsciousnessEvent {
256
+ type: ConsciousnessEventType;
257
+ timestamp: Date;
258
+ data: unknown;
259
+ }
260
+ export type ConsciousnessEventHandler = (event: ConsciousnessEvent) => void;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ /**
3
+ * Genesis 6.0 - Consciousness Module Types
4
+ *
5
+ * Types for consciousness monitoring based on:
6
+ * - IIT 4.0 (Integrated Information Theory) - Tononi et al.
7
+ * - GWT (Global Workspace Theory) - Baars
8
+ * - AST (Attention Schema Theory) - Graziano
9
+ *
10
+ * Key insight: Consciousness as integrated information that
11
+ * emerges from the interaction of specialized modules.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.DEFAULT_CONSCIOUSNESS_CONFIG = void 0;
15
+ exports.DEFAULT_CONSCIOUSNESS_CONFIG = {
16
+ phi: {
17
+ enabled: true,
18
+ updateIntervalMs: 5000, // Every 5 seconds
19
+ approximationLevel: 'fast',
20
+ minPhi: 0.1, // INV-006 threshold
21
+ },
22
+ gwt: {
23
+ enabled: true,
24
+ workspaceCapacity: 7, // Miller's 7 +/- 2
25
+ selectionIntervalMs: 100, // 10 Hz cycle
26
+ broadcastTimeoutMs: 1000,
27
+ historyLimit: 100,
28
+ },
29
+ ast: {
30
+ enabled: true,
31
+ attentionCapacity: 4, // Conservative estimate
32
+ schemaUpdateIntervalMs: 1000,
33
+ theoryOfMindEnabled: true,
34
+ },
35
+ monitor: {
36
+ snapshotIntervalMs: 10000, // Every 10 seconds
37
+ historyLimit: 1000,
38
+ anomalyDetection: true,
39
+ alertThresholds: {
40
+ phiDrop: 0.2, // 20% drop triggers alert
41
+ phiMin: 0.1, // Below 10% triggers alert
42
+ },
43
+ },
44
+ };
@@ -0,0 +1,115 @@
1
+ /**
2
+ * Genesis 6.0 - Dream Mode
3
+ *
4
+ * Offline consolidation and creative synthesis during "sleep".
5
+ *
6
+ * Based on sleep neuroscience research:
7
+ * - Light Sleep (N1/N2): Initial memory processing
8
+ * - Deep Sleep (N3/SWS): Memory consolidation (episodic → semantic)
9
+ * - REM Sleep: Creative synthesis, pattern integration
10
+ *
11
+ * References:
12
+ * - Walker, M. (2017). Why We Sleep
13
+ * - Born, J. (2010). Slow-wave sleep and memory
14
+ * - Stickgold, R. (2005). Sleep-dependent memory consolidation
15
+ *
16
+ * Usage:
17
+ * ```typescript
18
+ * import { createDreamService } from './daemon/dream-mode.js';
19
+ *
20
+ * const dream = createDreamService({
21
+ * minDreamDurationMs: 60000, // 1 minute
22
+ * maxDreamDurationMs: 600000, // 10 minutes
23
+ * });
24
+ *
25
+ * // Start a dream session
26
+ * const session = await dream.startDream();
27
+ *
28
+ * // Wait for completion
29
+ * const results = await dream.waitForWake();
30
+ * ```
31
+ */
32
+ import { DreamConfig, DreamSession, DreamResults, DreamMetrics } from './types.js';
33
+ export interface DreamContext {
34
+ getEpisodicMemories?: () => Array<{
35
+ id: string;
36
+ content: {
37
+ what: string;
38
+ };
39
+ importance: number;
40
+ tags: string[];
41
+ consolidated: boolean;
42
+ }>;
43
+ getSemanticMemories?: () => Array<{
44
+ id: string;
45
+ concept: string;
46
+ confidence: number;
47
+ }>;
48
+ getProceduralMemories?: () => Array<{
49
+ id: string;
50
+ name: string;
51
+ successRate: number;
52
+ }>;
53
+ consolidateMemory?: (episodeId: string) => Promise<{
54
+ concept: string;
55
+ } | null>;
56
+ extractPattern?: (episodes: string[]) => Promise<{
57
+ pattern: string;
58
+ confidence: number;
59
+ } | null>;
60
+ reinforceSkill?: (skillId: string) => Promise<boolean>;
61
+ forgetMemory?: (memoryId: string) => boolean;
62
+ getState?: () => {
63
+ energy: number;
64
+ };
65
+ rechargeEnergy?: (amount: number) => void;
66
+ checkInvariants?: () => Promise<boolean>;
67
+ repairState?: () => Promise<number>;
68
+ log?: (message: string, level?: 'debug' | 'info' | 'warn' | 'error') => void;
69
+ }
70
+ export type DreamEventType = 'dream_started' | 'phase_changed' | 'consolidation_done' | 'pattern_extracted' | 'dream_completed' | 'dream_interrupted';
71
+ export type DreamEventHandler = (event: {
72
+ type: DreamEventType;
73
+ session?: DreamSession;
74
+ data?: unknown;
75
+ }) => void;
76
+ export declare class DreamService {
77
+ private config;
78
+ private context;
79
+ private currentSession;
80
+ private metrics;
81
+ private eventHandlers;
82
+ private wakeResolvers;
83
+ private inactivityTimer;
84
+ private lastActivity;
85
+ constructor(config?: Partial<DreamConfig>, context?: DreamContext);
86
+ setContext(context: Partial<DreamContext>): void;
87
+ startAutoTrigger(): void;
88
+ stopAutoTrigger(): void;
89
+ recordActivity(): void;
90
+ private resetInactivityTimer;
91
+ isDreaming(): boolean;
92
+ startDream(options?: {
93
+ duration?: number;
94
+ }): Promise<DreamSession>;
95
+ interruptDream(reason: string): Promise<DreamResults | null>;
96
+ waitForWake(): Promise<DreamResults>;
97
+ getCurrentSession(): DreamSession | null;
98
+ private runDreamCycle;
99
+ private runPhase;
100
+ private transitionPhase;
101
+ private lightSleepPhase;
102
+ private deepSleepPhase;
103
+ private remSleepPhase;
104
+ private wakePhase;
105
+ private groupByTags;
106
+ private generateNovelAssociations;
107
+ private createEmptyResults;
108
+ private finishDream;
109
+ private sleep;
110
+ getMetrics(): DreamMetrics;
111
+ on(handler: DreamEventHandler): () => void;
112
+ private emit;
113
+ private log;
114
+ }
115
+ export declare function createDreamService(config?: Partial<DreamConfig>, context?: DreamContext): DreamService;