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.
- package/.env.example +78 -0
- package/README.md +282 -0
- package/dist/src/active-inference/actions.d.ts +75 -0
- package/dist/src/active-inference/actions.js +250 -0
- package/dist/src/active-inference/autonomous-loop.d.ts +103 -0
- package/dist/src/active-inference/autonomous-loop.js +289 -0
- package/dist/src/active-inference/core.d.ts +85 -0
- package/dist/src/active-inference/core.js +555 -0
- package/dist/src/active-inference/demo-autonomous-loop.d.ts +8 -0
- package/dist/src/active-inference/demo-autonomous-loop.js +338 -0
- package/dist/src/active-inference/demo-value-integration.d.ts +8 -0
- package/dist/src/active-inference/demo-value-integration.js +174 -0
- package/dist/src/active-inference/index.d.ts +32 -0
- package/dist/src/active-inference/index.js +88 -0
- package/dist/src/active-inference/integration.d.ts +114 -0
- package/dist/src/active-inference/integration.js +698 -0
- package/dist/src/active-inference/memory-integration.d.ts +51 -0
- package/dist/src/active-inference/memory-integration.js +232 -0
- package/dist/src/active-inference/observations.d.ts +67 -0
- package/dist/src/active-inference/observations.js +147 -0
- package/dist/src/active-inference/test-active-inference.d.ts +8 -0
- package/dist/src/active-inference/test-active-inference.js +320 -0
- package/dist/src/active-inference/test-value-integration.d.ts +6 -0
- package/dist/src/active-inference/test-value-integration.js +168 -0
- package/dist/src/active-inference/types.d.ts +150 -0
- package/dist/src/active-inference/types.js +59 -0
- package/dist/src/active-inference/value-integration.d.ts +164 -0
- package/dist/src/active-inference/value-integration.js +459 -0
- package/dist/src/agents/base-agent.d.ts +53 -0
- package/dist/src/agents/base-agent.js +178 -0
- package/dist/src/agents/builder.d.ts +67 -0
- package/dist/src/agents/builder.js +537 -0
- package/dist/src/agents/critic.d.ts +35 -0
- package/dist/src/agents/critic.js +322 -0
- package/dist/src/agents/ethicist.d.ts +54 -0
- package/dist/src/agents/ethicist.js +393 -0
- package/dist/src/agents/explorer.d.ts +26 -0
- package/dist/src/agents/explorer.js +216 -0
- package/dist/src/agents/feeling.d.ts +41 -0
- package/dist/src/agents/feeling.js +320 -0
- package/dist/src/agents/index.d.ts +111 -0
- package/dist/src/agents/index.js +222 -0
- package/dist/src/agents/memory.d.ts +69 -0
- package/dist/src/agents/memory.js +404 -0
- package/dist/src/agents/message-bus.d.ts +88 -0
- package/dist/src/agents/message-bus.js +267 -0
- package/dist/src/agents/narrator.d.ts +90 -0
- package/dist/src/agents/narrator.js +473 -0
- package/dist/src/agents/planner.d.ts +38 -0
- package/dist/src/agents/planner.js +341 -0
- package/dist/src/agents/predictor.d.ts +73 -0
- package/dist/src/agents/predictor.js +506 -0
- package/dist/src/agents/sensor.d.ts +88 -0
- package/dist/src/agents/sensor.js +377 -0
- package/dist/src/agents/test-agents.d.ts +6 -0
- package/dist/src/agents/test-agents.js +73 -0
- package/dist/src/agents/types.d.ts +194 -0
- package/dist/src/agents/types.js +7 -0
- package/dist/src/brain/index.d.ts +185 -0
- package/dist/src/brain/index.js +843 -0
- package/dist/src/brain/trace.d.ts +91 -0
- package/dist/src/brain/trace.js +327 -0
- package/dist/src/brain/types.d.ts +165 -0
- package/dist/src/brain/types.js +51 -0
- package/dist/src/cli/chat.d.ts +237 -0
- package/dist/src/cli/chat.js +1959 -0
- package/dist/src/cli/dispatcher.d.ts +182 -0
- package/dist/src/cli/dispatcher.js +718 -0
- package/dist/src/cli/human-loop.d.ts +170 -0
- package/dist/src/cli/human-loop.js +543 -0
- package/dist/src/cli/index.d.ts +12 -0
- package/dist/src/cli/index.js +28 -0
- package/dist/src/cli/interactive.d.ts +141 -0
- package/dist/src/cli/interactive.js +757 -0
- package/dist/src/cli/ui.d.ts +205 -0
- package/dist/src/cli/ui.js +632 -0
- package/dist/src/consciousness/attention-schema.d.ts +154 -0
- package/dist/src/consciousness/attention-schema.js +432 -0
- package/dist/src/consciousness/global-workspace.d.ts +149 -0
- package/dist/src/consciousness/global-workspace.js +422 -0
- package/dist/src/consciousness/index.d.ts +186 -0
- package/dist/src/consciousness/index.js +476 -0
- package/dist/src/consciousness/phi-calculator.d.ts +119 -0
- package/dist/src/consciousness/phi-calculator.js +445 -0
- package/dist/src/consciousness/phi-decisions.d.ts +169 -0
- package/dist/src/consciousness/phi-decisions.js +383 -0
- package/dist/src/consciousness/phi-monitor.d.ts +153 -0
- package/dist/src/consciousness/phi-monitor.js +465 -0
- package/dist/src/consciousness/types.d.ts +260 -0
- package/dist/src/consciousness/types.js +44 -0
- package/dist/src/daemon/dream-mode.d.ts +115 -0
- package/dist/src/daemon/dream-mode.js +470 -0
- package/dist/src/daemon/index.d.ts +162 -0
- package/dist/src/daemon/index.js +542 -0
- package/dist/src/daemon/maintenance.d.ts +139 -0
- package/dist/src/daemon/maintenance.js +549 -0
- package/dist/src/daemon/process.d.ts +82 -0
- package/dist/src/daemon/process.js +442 -0
- package/dist/src/daemon/scheduler.d.ts +90 -0
- package/dist/src/daemon/scheduler.js +494 -0
- package/dist/src/daemon/types.d.ts +213 -0
- package/dist/src/daemon/types.js +50 -0
- package/dist/src/epistemic/index.d.ts +74 -0
- package/dist/src/epistemic/index.js +225 -0
- package/dist/src/grounding/epistemic-stack.d.ts +100 -0
- package/dist/src/grounding/epistemic-stack.js +408 -0
- package/dist/src/grounding/feedback.d.ts +98 -0
- package/dist/src/grounding/feedback.js +276 -0
- package/dist/src/grounding/index.d.ts +123 -0
- package/dist/src/grounding/index.js +224 -0
- package/dist/src/grounding/verifier.d.ts +149 -0
- package/dist/src/grounding/verifier.js +484 -0
- package/dist/src/healing/detector.d.ts +110 -0
- package/dist/src/healing/detector.js +436 -0
- package/dist/src/healing/fixer.d.ts +138 -0
- package/dist/src/healing/fixer.js +572 -0
- package/dist/src/healing/index.d.ts +23 -0
- package/dist/src/healing/index.js +43 -0
- package/dist/src/hooks/index.d.ts +135 -0
- package/dist/src/hooks/index.js +317 -0
- package/dist/src/index.d.ts +23 -0
- package/dist/src/index.js +1266 -0
- package/dist/src/kernel/index.d.ts +155 -0
- package/dist/src/kernel/index.js +795 -0
- package/dist/src/kernel/invariants.d.ts +153 -0
- package/dist/src/kernel/invariants.js +355 -0
- package/dist/src/kernel/test-kernel.d.ts +6 -0
- package/dist/src/kernel/test-kernel.js +108 -0
- package/dist/src/kernel/test-real-mcp.d.ts +10 -0
- package/dist/src/kernel/test-real-mcp.js +295 -0
- package/dist/src/llm/index.d.ts +146 -0
- package/dist/src/llm/index.js +428 -0
- package/dist/src/llm/router.d.ts +136 -0
- package/dist/src/llm/router.js +510 -0
- package/dist/src/mcp/index.d.ts +85 -0
- package/dist/src/mcp/index.js +657 -0
- package/dist/src/mcp/resilient.d.ts +139 -0
- package/dist/src/mcp/resilient.js +417 -0
- package/dist/src/memory/cache.d.ts +118 -0
- package/dist/src/memory/cache.js +356 -0
- package/dist/src/memory/cognitive-workspace.d.ts +231 -0
- package/dist/src/memory/cognitive-workspace.js +521 -0
- package/dist/src/memory/consolidation.d.ts +99 -0
- package/dist/src/memory/consolidation.js +443 -0
- package/dist/src/memory/episodic.d.ts +114 -0
- package/dist/src/memory/episodic.js +394 -0
- package/dist/src/memory/forgetting.d.ts +134 -0
- package/dist/src/memory/forgetting.js +324 -0
- package/dist/src/memory/index.d.ts +211 -0
- package/dist/src/memory/index.js +367 -0
- package/dist/src/memory/indexer.d.ts +123 -0
- package/dist/src/memory/indexer.js +479 -0
- package/dist/src/memory/procedural.d.ts +136 -0
- package/dist/src/memory/procedural.js +479 -0
- package/dist/src/memory/semantic.d.ts +132 -0
- package/dist/src/memory/semantic.js +497 -0
- package/dist/src/memory/types.d.ts +193 -0
- package/dist/src/memory/types.js +15 -0
- package/dist/src/orchestrator.d.ts +65 -0
- package/dist/src/orchestrator.js +317 -0
- package/dist/src/persistence/index.d.ts +257 -0
- package/dist/src/persistence/index.js +763 -0
- package/dist/src/pipeline/executor.d.ts +51 -0
- package/dist/src/pipeline/executor.js +695 -0
- package/dist/src/pipeline/index.d.ts +7 -0
- package/dist/src/pipeline/index.js +11 -0
- package/dist/src/self-production.d.ts +67 -0
- package/dist/src/self-production.js +205 -0
- package/dist/src/subagents/executor.d.ts +58 -0
- package/dist/src/subagents/executor.js +283 -0
- package/dist/src/subagents/index.d.ts +37 -0
- package/dist/src/subagents/index.js +53 -0
- package/dist/src/subagents/registry.d.ts +23 -0
- package/dist/src/subagents/registry.js +167 -0
- package/dist/src/subagents/types.d.ts +79 -0
- package/dist/src/subagents/types.js +14 -0
- package/dist/src/tools/bash.d.ts +139 -0
- package/dist/src/tools/bash.js +583 -0
- package/dist/src/tools/edit.d.ts +125 -0
- package/dist/src/tools/edit.js +424 -0
- package/dist/src/tools/git.d.ts +179 -0
- package/dist/src/tools/git.js +504 -0
- package/dist/src/tools/index.d.ts +21 -0
- package/dist/src/tools/index.js +163 -0
- package/dist/src/types.d.ts +145 -0
- package/dist/src/types.js +7 -0
- package/dist/src/world-model/decoder.d.ts +163 -0
- package/dist/src/world-model/decoder.js +517 -0
- package/dist/src/world-model/digital-twin.d.ts +219 -0
- package/dist/src/world-model/digital-twin.js +695 -0
- package/dist/src/world-model/encoder.d.ts +141 -0
- package/dist/src/world-model/encoder.js +564 -0
- package/dist/src/world-model/index.d.ts +221 -0
- package/dist/src/world-model/index.js +772 -0
- package/dist/src/world-model/predictor.d.ts +161 -0
- package/dist/src/world-model/predictor.js +681 -0
- package/dist/src/world-model/test-value-jepa.d.ts +8 -0
- package/dist/src/world-model/test-value-jepa.js +430 -0
- package/dist/src/world-model/types.d.ts +341 -0
- package/dist/src/world-model/types.js +69 -0
- package/dist/src/world-model/value-jepa.d.ts +247 -0
- package/dist/src/world-model/value-jepa.js +622 -0
- package/dist/test/brain.test.d.ts +11 -0
- package/dist/test/brain.test.js +358 -0
- package/dist/test/cli/dispatcher.test.d.ts +4 -0
- package/dist/test/cli/dispatcher.test.js +332 -0
- package/dist/test/cli/human-loop.test.d.ts +4 -0
- package/dist/test/cli/human-loop.test.js +270 -0
- package/dist/test/grounding/feedback.test.d.ts +4 -0
- package/dist/test/grounding/feedback.test.js +462 -0
- package/dist/test/grounding/verifier.test.d.ts +4 -0
- package/dist/test/grounding/verifier.test.js +442 -0
- package/dist/test/grounding.test.d.ts +6 -0
- package/dist/test/grounding.test.js +246 -0
- package/dist/test/healing/detector.test.d.ts +4 -0
- package/dist/test/healing/detector.test.js +266 -0
- package/dist/test/healing/fixer.test.d.ts +4 -0
- package/dist/test/healing/fixer.test.js +369 -0
- package/dist/test/integration.test.d.ts +5 -0
- package/dist/test/integration.test.js +290 -0
- package/dist/test/tools/bash.test.d.ts +4 -0
- package/dist/test/tools/bash.test.js +348 -0
- package/dist/test/tools/edit.test.d.ts +4 -0
- package/dist/test/tools/edit.test.js +350 -0
- package/dist/test/tools/git.test.d.ts +4 -0
- package/dist/test/tools/git.test.js +350 -0
- package/package.json +60 -0
|
@@ -0,0 +1,341 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis 6.0 - World Model Types
|
|
3
|
+
*
|
|
4
|
+
* Types for the unified world model implementing:
|
|
5
|
+
* - JEPA-style latent space encoding
|
|
6
|
+
* - Predictive modeling and simulation
|
|
7
|
+
* - Digital twin capabilities
|
|
8
|
+
* - Dream mode consolidation
|
|
9
|
+
*
|
|
10
|
+
* Key concepts:
|
|
11
|
+
* - Latent space: Compressed representation of world state
|
|
12
|
+
* - Prediction: Single-step state transition
|
|
13
|
+
* - Simulation: Multi-step trajectory generation
|
|
14
|
+
* - Digital Twin: Real-time synchronized model
|
|
15
|
+
*
|
|
16
|
+
* References:
|
|
17
|
+
* - LeCun (2022). A Path Towards Autonomous Machine Intelligence
|
|
18
|
+
* - JEPA (Joint Embedding Predictive Architecture)
|
|
19
|
+
* - World Models (Ha & Schmidhuber, 2018)
|
|
20
|
+
*
|
|
21
|
+
* Key invariant: INV-008 - World model consistency
|
|
22
|
+
*/
|
|
23
|
+
/**
|
|
24
|
+
* Modality types that can be encoded
|
|
25
|
+
*/
|
|
26
|
+
export type Modality = 'text' | 'image' | 'code' | 'state' | 'audio' | 'sensor';
|
|
27
|
+
/**
|
|
28
|
+
* Input for encoding - multimodal
|
|
29
|
+
*/
|
|
30
|
+
export interface MultimodalInput {
|
|
31
|
+
modality: Modality;
|
|
32
|
+
data: unknown;
|
|
33
|
+
metadata?: Record<string, unknown>;
|
|
34
|
+
timestamp: Date;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Text input for encoding
|
|
38
|
+
*/
|
|
39
|
+
export interface TextInput extends MultimodalInput {
|
|
40
|
+
modality: 'text';
|
|
41
|
+
data: string;
|
|
42
|
+
language?: string;
|
|
43
|
+
context?: string;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Image input for encoding
|
|
47
|
+
*/
|
|
48
|
+
export interface ImageInput extends MultimodalInput {
|
|
49
|
+
modality: 'image';
|
|
50
|
+
data: string;
|
|
51
|
+
width?: number;
|
|
52
|
+
height?: number;
|
|
53
|
+
format?: 'png' | 'jpg' | 'webp';
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Code input for encoding
|
|
57
|
+
*/
|
|
58
|
+
export interface CodeInput extends MultimodalInput {
|
|
59
|
+
modality: 'code';
|
|
60
|
+
data: string;
|
|
61
|
+
language: string;
|
|
62
|
+
filePath?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* State input (agent/system state)
|
|
66
|
+
*/
|
|
67
|
+
export interface StateInput extends MultimodalInput {
|
|
68
|
+
modality: 'state';
|
|
69
|
+
data: Record<string, unknown>;
|
|
70
|
+
componentId?: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Sensor input (from MCP servers)
|
|
74
|
+
*/
|
|
75
|
+
export interface SensorInput extends MultimodalInput {
|
|
76
|
+
modality: 'sensor';
|
|
77
|
+
data: unknown;
|
|
78
|
+
sensorType: string;
|
|
79
|
+
source: string;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Latent state - compressed representation
|
|
83
|
+
*/
|
|
84
|
+
export interface LatentState {
|
|
85
|
+
vector: number[];
|
|
86
|
+
dimensions: number;
|
|
87
|
+
sourceModality: Modality;
|
|
88
|
+
sourceId: string;
|
|
89
|
+
timestamp: Date;
|
|
90
|
+
confidence: number;
|
|
91
|
+
entropy: number;
|
|
92
|
+
features?: LatentFeature[];
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Named feature in latent space
|
|
96
|
+
*/
|
|
97
|
+
export interface LatentFeature {
|
|
98
|
+
name: string;
|
|
99
|
+
indices: number[];
|
|
100
|
+
activation: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Encoder configuration
|
|
104
|
+
*/
|
|
105
|
+
export interface EncoderConfig {
|
|
106
|
+
latentDim: number;
|
|
107
|
+
modalityWeights: Record<Modality, number>;
|
|
108
|
+
useCompression: boolean;
|
|
109
|
+
compressionRatio: number;
|
|
110
|
+
normalizeOutput: boolean;
|
|
111
|
+
}
|
|
112
|
+
export declare const DEFAULT_ENCODER_CONFIG: EncoderConfig;
|
|
113
|
+
/**
|
|
114
|
+
* Action that can be taken in the world
|
|
115
|
+
*/
|
|
116
|
+
export interface Action {
|
|
117
|
+
id: string;
|
|
118
|
+
type: ActionType;
|
|
119
|
+
parameters: Record<string, unknown>;
|
|
120
|
+
agent: string;
|
|
121
|
+
timestamp: Date;
|
|
122
|
+
}
|
|
123
|
+
export type ActionType = 'observe' | 'query' | 'execute' | 'communicate' | 'transform' | 'create' | 'delete' | 'navigate';
|
|
124
|
+
/**
|
|
125
|
+
* Predicted state after action
|
|
126
|
+
*/
|
|
127
|
+
export interface PredictedState {
|
|
128
|
+
state: LatentState;
|
|
129
|
+
action: Action;
|
|
130
|
+
probability: number;
|
|
131
|
+
uncertainty: number;
|
|
132
|
+
alternativeStates: LatentState[];
|
|
133
|
+
predictionTime: number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Trajectory - sequence of states
|
|
137
|
+
*/
|
|
138
|
+
export interface Trajectory {
|
|
139
|
+
id: string;
|
|
140
|
+
initialState: LatentState;
|
|
141
|
+
actions: Action[];
|
|
142
|
+
states: PredictedState[];
|
|
143
|
+
totalProbability: number;
|
|
144
|
+
horizon: number;
|
|
145
|
+
simulationTime: number;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* World model configuration
|
|
149
|
+
*/
|
|
150
|
+
export interface WorldModelConfig {
|
|
151
|
+
maxHorizon: number;
|
|
152
|
+
uncertaintyThreshold: number;
|
|
153
|
+
branchingFactor: number;
|
|
154
|
+
updateIntervalMs: number;
|
|
155
|
+
consistencyCheckIntervalMs: number;
|
|
156
|
+
}
|
|
157
|
+
export declare const DEFAULT_WORLD_MODEL_CONFIG: WorldModelConfig;
|
|
158
|
+
/**
|
|
159
|
+
* Physics query for common sense reasoning
|
|
160
|
+
*/
|
|
161
|
+
export interface PhysicsQuery {
|
|
162
|
+
type: PhysicsQueryType;
|
|
163
|
+
objects: PhysicsObject[];
|
|
164
|
+
question: string;
|
|
165
|
+
constraints?: PhysicsConstraint[];
|
|
166
|
+
}
|
|
167
|
+
export type PhysicsQueryType = 'collision' | 'stability' | 'containment' | 'reachability' | 'causation' | 'trajectory';
|
|
168
|
+
export interface PhysicsObject {
|
|
169
|
+
id: string;
|
|
170
|
+
type: string;
|
|
171
|
+
position?: [number, number, number];
|
|
172
|
+
velocity?: [number, number, number];
|
|
173
|
+
mass?: number;
|
|
174
|
+
properties: Record<string, unknown>;
|
|
175
|
+
}
|
|
176
|
+
export interface PhysicsConstraint {
|
|
177
|
+
type: 'gravity' | 'friction' | 'boundary' | 'connection';
|
|
178
|
+
parameters: Record<string, unknown>;
|
|
179
|
+
}
|
|
180
|
+
export interface PhysicsAnswer {
|
|
181
|
+
query: PhysicsQuery;
|
|
182
|
+
answer: boolean | number | string;
|
|
183
|
+
confidence: number;
|
|
184
|
+
reasoning: string[];
|
|
185
|
+
visualization?: string;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Digital twin - synchronized model of real system
|
|
189
|
+
*/
|
|
190
|
+
export interface DigitalTwin {
|
|
191
|
+
id: string;
|
|
192
|
+
name: string;
|
|
193
|
+
realSystemId: string;
|
|
194
|
+
currentState: LatentState;
|
|
195
|
+
lastSync: Date;
|
|
196
|
+
syncDrift: number;
|
|
197
|
+
stateHistory: LatentState[];
|
|
198
|
+
historyLimit: number;
|
|
199
|
+
config: DigitalTwinConfig;
|
|
200
|
+
status: TwinStatus;
|
|
201
|
+
}
|
|
202
|
+
export interface DigitalTwinConfig {
|
|
203
|
+
syncIntervalMs: number;
|
|
204
|
+
maxDrift: number;
|
|
205
|
+
predictAhead: number;
|
|
206
|
+
trackMetrics: string[];
|
|
207
|
+
}
|
|
208
|
+
export declare const DEFAULT_DIGITAL_TWIN_CONFIG: DigitalTwinConfig;
|
|
209
|
+
export type TwinStatus = 'synced' | 'drifting' | 'disconnected' | 'initializing';
|
|
210
|
+
/**
|
|
211
|
+
* Dream cycle result
|
|
212
|
+
*/
|
|
213
|
+
export interface DreamResult {
|
|
214
|
+
startTime: Date;
|
|
215
|
+
endTime: Date;
|
|
216
|
+
duration: number;
|
|
217
|
+
slowWaveReplay: SlowWaveResult;
|
|
218
|
+
remAbstraction: REMResult;
|
|
219
|
+
consolidation: ConsolidationResult;
|
|
220
|
+
memoriesConsolidated: number;
|
|
221
|
+
patternsExtracted: number;
|
|
222
|
+
modelImproved: boolean;
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Slow-wave replay phase
|
|
226
|
+
* Replays recent experiences
|
|
227
|
+
*/
|
|
228
|
+
export interface SlowWaveResult {
|
|
229
|
+
experiencesReplayed: number;
|
|
230
|
+
strongestMemories: string[];
|
|
231
|
+
replayDuration: number;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* REM abstraction phase
|
|
235
|
+
* Extracts patterns and generalizations
|
|
236
|
+
*/
|
|
237
|
+
export interface REMResult {
|
|
238
|
+
patternsFound: Pattern[];
|
|
239
|
+
abstractionLevel: number;
|
|
240
|
+
creativeCombinations: number;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Pattern extracted during REM
|
|
244
|
+
*/
|
|
245
|
+
export interface Pattern {
|
|
246
|
+
id: string;
|
|
247
|
+
type: 'sequence' | 'structure' | 'causal' | 'analogy';
|
|
248
|
+
elements: string[];
|
|
249
|
+
confidence: number;
|
|
250
|
+
novelty: number;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Consolidation phase
|
|
254
|
+
* Integrates learnings into world model
|
|
255
|
+
*/
|
|
256
|
+
export interface ConsolidationResult {
|
|
257
|
+
modelUpdates: number;
|
|
258
|
+
pruned: number;
|
|
259
|
+
strengthened: number;
|
|
260
|
+
newConnections: number;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Dream mode configuration
|
|
264
|
+
*/
|
|
265
|
+
export interface DreamConfig {
|
|
266
|
+
slowWaveDuration: number;
|
|
267
|
+
remDuration: number;
|
|
268
|
+
consolidationDuration: number;
|
|
269
|
+
triggerThreshold: number;
|
|
270
|
+
minPendingMemories: number;
|
|
271
|
+
}
|
|
272
|
+
export declare const DEFAULT_DREAM_CONFIG: DreamConfig;
|
|
273
|
+
/**
|
|
274
|
+
* Entity in the world model
|
|
275
|
+
*/
|
|
276
|
+
export interface WorldEntity {
|
|
277
|
+
id: string;
|
|
278
|
+
type: EntityType;
|
|
279
|
+
name: string;
|
|
280
|
+
state: LatentState;
|
|
281
|
+
properties: Record<string, unknown>;
|
|
282
|
+
relations: EntityRelation[];
|
|
283
|
+
created: Date;
|
|
284
|
+
lastUpdated: Date;
|
|
285
|
+
confidence: number;
|
|
286
|
+
}
|
|
287
|
+
export type EntityType = 'agent' | 'object' | 'location' | 'event' | 'concept' | 'process';
|
|
288
|
+
/**
|
|
289
|
+
* Relation between entities
|
|
290
|
+
*/
|
|
291
|
+
export interface EntityRelation {
|
|
292
|
+
id: string;
|
|
293
|
+
type: RelationType;
|
|
294
|
+
source: string;
|
|
295
|
+
target: string;
|
|
296
|
+
strength: number;
|
|
297
|
+
bidirectional: boolean;
|
|
298
|
+
properties: Record<string, unknown>;
|
|
299
|
+
}
|
|
300
|
+
export type RelationType = 'contains' | 'part_of' | 'causes' | 'before' | 'similar' | 'opposite' | 'instance_of' | 'interacts' | 'depends_on';
|
|
301
|
+
/**
|
|
302
|
+
* Consistency check result
|
|
303
|
+
*/
|
|
304
|
+
export interface ConsistencyCheck {
|
|
305
|
+
id: string;
|
|
306
|
+
timestamp: Date;
|
|
307
|
+
passed: boolean;
|
|
308
|
+
checks: {
|
|
309
|
+
stateConsistency: boolean;
|
|
310
|
+
temporalConsistency: boolean;
|
|
311
|
+
causalConsistency: boolean;
|
|
312
|
+
entityConsistency: boolean;
|
|
313
|
+
};
|
|
314
|
+
issues: ConsistencyIssue[];
|
|
315
|
+
inconsistencyScore: number;
|
|
316
|
+
}
|
|
317
|
+
export interface ConsistencyIssue {
|
|
318
|
+
type: 'contradiction' | 'gap' | 'cycle' | 'orphan' | 'drift';
|
|
319
|
+
severity: 'low' | 'medium' | 'high' | 'critical';
|
|
320
|
+
description: string;
|
|
321
|
+
affectedEntities: string[];
|
|
322
|
+
suggestedFix?: string;
|
|
323
|
+
}
|
|
324
|
+
export type WorldModelEventType = 'state_predicted' | 'simulation_complete' | 'entity_created' | 'entity_updated' | 'entity_deleted' | 'relation_added' | 'relation_removed' | 'consistency_check' | 'consistency_violation' | 'dream_started' | 'dream_complete' | 'twin_synced' | 'twin_drifted';
|
|
325
|
+
export interface WorldModelEvent {
|
|
326
|
+
type: WorldModelEventType;
|
|
327
|
+
timestamp: Date;
|
|
328
|
+
data: unknown;
|
|
329
|
+
}
|
|
330
|
+
export type WorldModelEventHandler = (event: WorldModelEvent) => void;
|
|
331
|
+
export interface WorldModelSystemConfig {
|
|
332
|
+
encoder: Partial<EncoderConfig>;
|
|
333
|
+
predictor: Partial<WorldModelConfig>;
|
|
334
|
+
twin: Partial<DigitalTwinConfig>;
|
|
335
|
+
dream: Partial<DreamConfig>;
|
|
336
|
+
maxEntities: number;
|
|
337
|
+
entityTTL: number;
|
|
338
|
+
consistencyCheckEnabled: boolean;
|
|
339
|
+
autoRepairEnabled: boolean;
|
|
340
|
+
}
|
|
341
|
+
export declare const DEFAULT_WORLD_MODEL_SYSTEM_CONFIG: WorldModelSystemConfig;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Genesis 6.0 - World Model Types
|
|
4
|
+
*
|
|
5
|
+
* Types for the unified world model implementing:
|
|
6
|
+
* - JEPA-style latent space encoding
|
|
7
|
+
* - Predictive modeling and simulation
|
|
8
|
+
* - Digital twin capabilities
|
|
9
|
+
* - Dream mode consolidation
|
|
10
|
+
*
|
|
11
|
+
* Key concepts:
|
|
12
|
+
* - Latent space: Compressed representation of world state
|
|
13
|
+
* - Prediction: Single-step state transition
|
|
14
|
+
* - Simulation: Multi-step trajectory generation
|
|
15
|
+
* - Digital Twin: Real-time synchronized model
|
|
16
|
+
*
|
|
17
|
+
* References:
|
|
18
|
+
* - LeCun (2022). A Path Towards Autonomous Machine Intelligence
|
|
19
|
+
* - JEPA (Joint Embedding Predictive Architecture)
|
|
20
|
+
* - World Models (Ha & Schmidhuber, 2018)
|
|
21
|
+
*
|
|
22
|
+
* Key invariant: INV-008 - World model consistency
|
|
23
|
+
*/
|
|
24
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
+
exports.DEFAULT_WORLD_MODEL_SYSTEM_CONFIG = exports.DEFAULT_DREAM_CONFIG = exports.DEFAULT_DIGITAL_TWIN_CONFIG = exports.DEFAULT_WORLD_MODEL_CONFIG = exports.DEFAULT_ENCODER_CONFIG = void 0;
|
|
26
|
+
exports.DEFAULT_ENCODER_CONFIG = {
|
|
27
|
+
latentDim: 512,
|
|
28
|
+
modalityWeights: {
|
|
29
|
+
text: 1.0,
|
|
30
|
+
image: 1.0,
|
|
31
|
+
code: 1.0,
|
|
32
|
+
state: 1.0,
|
|
33
|
+
audio: 0.8,
|
|
34
|
+
sensor: 0.9,
|
|
35
|
+
},
|
|
36
|
+
useCompression: true,
|
|
37
|
+
compressionRatio: 0.1,
|
|
38
|
+
normalizeOutput: true,
|
|
39
|
+
};
|
|
40
|
+
exports.DEFAULT_WORLD_MODEL_CONFIG = {
|
|
41
|
+
maxHorizon: 100,
|
|
42
|
+
uncertaintyThreshold: 0.8,
|
|
43
|
+
branchingFactor: 3,
|
|
44
|
+
updateIntervalMs: 1000,
|
|
45
|
+
consistencyCheckIntervalMs: 5000,
|
|
46
|
+
};
|
|
47
|
+
exports.DEFAULT_DIGITAL_TWIN_CONFIG = {
|
|
48
|
+
syncIntervalMs: 1000,
|
|
49
|
+
maxDrift: 0.1,
|
|
50
|
+
predictAhead: 10,
|
|
51
|
+
trackMetrics: ['energy', 'health', 'performance'],
|
|
52
|
+
};
|
|
53
|
+
exports.DEFAULT_DREAM_CONFIG = {
|
|
54
|
+
slowWaveDuration: 10000, // 10 seconds
|
|
55
|
+
remDuration: 15000, // 15 seconds
|
|
56
|
+
consolidationDuration: 5000, // 5 seconds
|
|
57
|
+
triggerThreshold: 0.3,
|
|
58
|
+
minPendingMemories: 10,
|
|
59
|
+
};
|
|
60
|
+
exports.DEFAULT_WORLD_MODEL_SYSTEM_CONFIG = {
|
|
61
|
+
encoder: exports.DEFAULT_ENCODER_CONFIG,
|
|
62
|
+
predictor: exports.DEFAULT_WORLD_MODEL_CONFIG,
|
|
63
|
+
twin: exports.DEFAULT_DIGITAL_TWIN_CONFIG,
|
|
64
|
+
dream: exports.DEFAULT_DREAM_CONFIG,
|
|
65
|
+
maxEntities: 10000,
|
|
66
|
+
entityTTL: 3600000, // 1 hour
|
|
67
|
+
consistencyCheckEnabled: true,
|
|
68
|
+
autoRepairEnabled: true,
|
|
69
|
+
};
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Genesis 6.2 - Value-Guided JEPA (Joint Embedding Predictive Architecture)
|
|
3
|
+
*
|
|
4
|
+
* Extends the world model with value functions for decision-making.
|
|
5
|
+
*
|
|
6
|
+
* Scientific foundations:
|
|
7
|
+
* - LeCun (2022): JEPA - predict in latent space, not pixel space
|
|
8
|
+
* - Friston: Free Energy Principle - minimize expected free energy
|
|
9
|
+
* - Hafner (2019): Dreamer - value learning in world models
|
|
10
|
+
* - Schmidhuber: Curiosity-driven learning via prediction error
|
|
11
|
+
*
|
|
12
|
+
* The value function evaluates predicted states to guide:
|
|
13
|
+
* 1. Action selection (which action leads to best outcome?)
|
|
14
|
+
* 2. Trajectory planning (which path maximizes value?)
|
|
15
|
+
* 3. Dream consolidation (which memories are most valuable?)
|
|
16
|
+
*
|
|
17
|
+
* Integration with Active Inference:
|
|
18
|
+
* - G(π) = E[log P(o|s)] - KL[Q(s)||P(s)] + Value(s)
|
|
19
|
+
* - Expected Free Energy includes value term for goal-directedness
|
|
20
|
+
*/
|
|
21
|
+
import type { LatentState, Action, PredictedState, Trajectory } from './types.js';
|
|
22
|
+
/**
|
|
23
|
+
* Value function output for a latent state
|
|
24
|
+
*/
|
|
25
|
+
export interface ValueEstimate {
|
|
26
|
+
value: number;
|
|
27
|
+
components: {
|
|
28
|
+
survival: number;
|
|
29
|
+
integrity: number;
|
|
30
|
+
progress: number;
|
|
31
|
+
novelty: number;
|
|
32
|
+
efficiency: number;
|
|
33
|
+
};
|
|
34
|
+
valueUncertainty: number;
|
|
35
|
+
valueConfidence: number;
|
|
36
|
+
discount: number;
|
|
37
|
+
horizon: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Value-guided trajectory with cumulative value
|
|
41
|
+
*/
|
|
42
|
+
export interface ValuedTrajectory extends Trajectory {
|
|
43
|
+
totalValue: number;
|
|
44
|
+
expectedValue: number;
|
|
45
|
+
valueVariance: number;
|
|
46
|
+
stepValues: ValueEstimate[];
|
|
47
|
+
minValue: number;
|
|
48
|
+
maxValue: number;
|
|
49
|
+
riskAdjustedValue: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Action value (Q-value)
|
|
53
|
+
*/
|
|
54
|
+
export interface ActionValue {
|
|
55
|
+
action: Action;
|
|
56
|
+
qValue: number;
|
|
57
|
+
advantage: number;
|
|
58
|
+
qUncertainty: number;
|
|
59
|
+
predictedState: PredictedState;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Value function configuration
|
|
63
|
+
*/
|
|
64
|
+
export interface ValueFunctionConfig {
|
|
65
|
+
gamma: number;
|
|
66
|
+
weights: {
|
|
67
|
+
survival: number;
|
|
68
|
+
integrity: number;
|
|
69
|
+
progress: number;
|
|
70
|
+
novelty: number;
|
|
71
|
+
efficiency: number;
|
|
72
|
+
};
|
|
73
|
+
riskAversion: number;
|
|
74
|
+
curiosityBonus: number;
|
|
75
|
+
temperature: number;
|
|
76
|
+
horizon: number;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Free Energy components for Active Inference integration
|
|
80
|
+
*/
|
|
81
|
+
export interface FreeEnergyDecomposition {
|
|
82
|
+
expectedFreeEnergy: number;
|
|
83
|
+
ambiguity: number;
|
|
84
|
+
risk: number;
|
|
85
|
+
pragmaticValue: number;
|
|
86
|
+
epistemicValue: number;
|
|
87
|
+
instrumentalValue: number;
|
|
88
|
+
}
|
|
89
|
+
export declare const DEFAULT_VALUE_CONFIG: ValueFunctionConfig;
|
|
90
|
+
export declare class ValueFunction {
|
|
91
|
+
private config;
|
|
92
|
+
private survivalBasis;
|
|
93
|
+
private integrityBasis;
|
|
94
|
+
private progressBasis;
|
|
95
|
+
private valueStats;
|
|
96
|
+
constructor(config?: Partial<ValueFunctionConfig>);
|
|
97
|
+
/**
|
|
98
|
+
* Initialize basis functions for value estimation
|
|
99
|
+
*/
|
|
100
|
+
private initializeBasis;
|
|
101
|
+
/**
|
|
102
|
+
* Estimate value of a latent state
|
|
103
|
+
*/
|
|
104
|
+
estimate(state: LatentState, horizon?: number): ValueEstimate;
|
|
105
|
+
/**
|
|
106
|
+
* Compute individual value components
|
|
107
|
+
*/
|
|
108
|
+
private computeComponents;
|
|
109
|
+
/**
|
|
110
|
+
* Estimate uncertainty in value estimate
|
|
111
|
+
*/
|
|
112
|
+
private estimateUncertainty;
|
|
113
|
+
/**
|
|
114
|
+
* Compute novelty of state (how different from seen states)
|
|
115
|
+
*/
|
|
116
|
+
private computeNovelty;
|
|
117
|
+
/**
|
|
118
|
+
* Compute coherence of latent vector
|
|
119
|
+
*/
|
|
120
|
+
private computeCoherence;
|
|
121
|
+
/**
|
|
122
|
+
* Compute Q-value for state-action pair
|
|
123
|
+
*/
|
|
124
|
+
computeQValue(state: LatentState, action: Action, predictedState: PredictedState): ActionValue;
|
|
125
|
+
/**
|
|
126
|
+
* Rank actions by Q-value
|
|
127
|
+
*/
|
|
128
|
+
rankActions(actionValues: ActionValue[]): ActionValue[];
|
|
129
|
+
/**
|
|
130
|
+
* Sample action using softmax over Q-values
|
|
131
|
+
*/
|
|
132
|
+
sampleAction(actionValues: ActionValue[]): ActionValue;
|
|
133
|
+
/**
|
|
134
|
+
* Evaluate a trajectory with cumulative value
|
|
135
|
+
*/
|
|
136
|
+
evaluateTrajectory(trajectory: Trajectory): ValuedTrajectory;
|
|
137
|
+
/**
|
|
138
|
+
* Select best trajectory from candidates
|
|
139
|
+
*/
|
|
140
|
+
selectBestTrajectory(trajectories: Trajectory[]): ValuedTrajectory;
|
|
141
|
+
/**
|
|
142
|
+
* Compute Expected Free Energy for Active Inference
|
|
143
|
+
*
|
|
144
|
+
* G(π) = ambiguity + risk - pragmatic_value - epistemic_value + instrumental_value
|
|
145
|
+
*/
|
|
146
|
+
computeExpectedFreeEnergy(currentState: LatentState, policy: Action[], predictedStates: PredictedState[], preferences: LatentState): FreeEnergyDecomposition;
|
|
147
|
+
/**
|
|
148
|
+
* Ambiguity: Expected observation uncertainty
|
|
149
|
+
*/
|
|
150
|
+
private computeAmbiguity;
|
|
151
|
+
/**
|
|
152
|
+
* Risk: Divergence from preferred states
|
|
153
|
+
*/
|
|
154
|
+
private computeRisk;
|
|
155
|
+
/**
|
|
156
|
+
* Pragmatic Value: Alignment with preferences
|
|
157
|
+
*/
|
|
158
|
+
private computePragmaticValue;
|
|
159
|
+
/**
|
|
160
|
+
* Epistemic Value: Information gain from exploration
|
|
161
|
+
*/
|
|
162
|
+
private computeEpistemicValue;
|
|
163
|
+
/**
|
|
164
|
+
* Instrumental Value: V(s) contribution
|
|
165
|
+
*/
|
|
166
|
+
private computeInstrumentalValue;
|
|
167
|
+
/**
|
|
168
|
+
* Distance between two latent states
|
|
169
|
+
*/
|
|
170
|
+
private stateDistance;
|
|
171
|
+
/**
|
|
172
|
+
* Update value function from observed returns
|
|
173
|
+
*/
|
|
174
|
+
update(state: LatentState, observedReturn: number, learningRate?: number): void;
|
|
175
|
+
/**
|
|
176
|
+
* Update running statistics for normalization
|
|
177
|
+
*/
|
|
178
|
+
private updateStats;
|
|
179
|
+
private dotProduct;
|
|
180
|
+
private sigmoid;
|
|
181
|
+
private clamp;
|
|
182
|
+
getConfig(): ValueFunctionConfig;
|
|
183
|
+
getStats(): {
|
|
184
|
+
mean: number;
|
|
185
|
+
std: number;
|
|
186
|
+
min: number;
|
|
187
|
+
max: number;
|
|
188
|
+
count: number;
|
|
189
|
+
};
|
|
190
|
+
/**
|
|
191
|
+
* Set preference weights
|
|
192
|
+
*/
|
|
193
|
+
setWeights(weights: Partial<ValueFunctionConfig['weights']>): void;
|
|
194
|
+
}
|
|
195
|
+
export declare function createValueFunction(config?: Partial<ValueFunctionConfig>): ValueFunction;
|
|
196
|
+
export declare function getValueFunction(config?: Partial<ValueFunctionConfig>): ValueFunction;
|
|
197
|
+
export declare function resetValueFunction(): void;
|
|
198
|
+
import type { WorldModelPredictor } from './predictor.js';
|
|
199
|
+
/**
|
|
200
|
+
* Value-Guided JEPA Predictor
|
|
201
|
+
*
|
|
202
|
+
* Wraps the WorldModelPredictor with value-guided prediction
|
|
203
|
+
*/
|
|
204
|
+
export declare class ValueGuidedJEPA {
|
|
205
|
+
private predictor;
|
|
206
|
+
private valueFunction;
|
|
207
|
+
constructor(predictor: WorldModelPredictor, valueFn?: ValueFunction);
|
|
208
|
+
/**
|
|
209
|
+
* Predict next state and compute value
|
|
210
|
+
*/
|
|
211
|
+
predictWithValue(state: LatentState, action: Action): Promise<PredictedState & {
|
|
212
|
+
value: ValueEstimate;
|
|
213
|
+
}>;
|
|
214
|
+
/**
|
|
215
|
+
* Generate value-guided trajectory
|
|
216
|
+
*
|
|
217
|
+
* Uses rollout with value-based action selection
|
|
218
|
+
*/
|
|
219
|
+
planWithValue(initialState: LatentState, horizon: number, candidateActions: Action[][], // Actions to consider at each step
|
|
220
|
+
preferences?: LatentState): Promise<ValuedTrajectory>;
|
|
221
|
+
/**
|
|
222
|
+
* Select action via Expected Free Energy minimization
|
|
223
|
+
*
|
|
224
|
+
* This is the core Active Inference decision rule
|
|
225
|
+
*/
|
|
226
|
+
selectActionActiveInference(currentState: LatentState, candidateActions: Action[], preferences: LatentState, horizon?: number): Promise<{
|
|
227
|
+
action: Action;
|
|
228
|
+
freeEnergy: FreeEnergyDecomposition;
|
|
229
|
+
}>;
|
|
230
|
+
/**
|
|
231
|
+
* Dream-time consolidation with value-based prioritization
|
|
232
|
+
*
|
|
233
|
+
* Memories with higher value prediction error are replayed more
|
|
234
|
+
*/
|
|
235
|
+
dreamConsolidate(memories: Array<{
|
|
236
|
+
state: LatentState;
|
|
237
|
+
action: Action;
|
|
238
|
+
nextState: LatentState;
|
|
239
|
+
reward: number;
|
|
240
|
+
}>, epochs?: number): Promise<{
|
|
241
|
+
replayCount: number;
|
|
242
|
+
avgError: number;
|
|
243
|
+
}>;
|
|
244
|
+
getValueFunction(): ValueFunction;
|
|
245
|
+
getPredictor(): WorldModelPredictor;
|
|
246
|
+
}
|
|
247
|
+
export declare function createValueGuidedJEPA(valueFnConfig?: Partial<ValueFunctionConfig>): Promise<ValueGuidedJEPA>;
|