genesis-ai-cli 13.3.1 → 13.5.0
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/dist/src/active-inference/actions.js +55 -9
- package/dist/src/active-inference/integration.js +54 -8
- package/dist/src/brain/index.d.ts +5 -2
- package/dist/src/brain/index.js +32 -2
- package/dist/src/brain/types.d.ts +36 -0
- package/dist/src/economy/autonomous.d.ts +45 -14
- package/dist/src/economy/autonomous.js +213 -61
- package/dist/src/economy/generative-model.d.ts +314 -0
- package/dist/src/economy/generative-model.js +600 -0
- package/dist/src/economy/index.d.ts +3 -0
- package/dist/src/economy/index.js +29 -2
- package/dist/src/economy/variational-engine.d.ts +294 -0
- package/dist/src/economy/variational-engine.js +693 -0
- package/dist/src/genesis.d.ts +31 -0
- package/dist/src/genesis.js +275 -10
- package/dist/src/kernel/factor-graph.d.ts +198 -0
- package/dist/src/kernel/factor-graph.js +474 -0
- package/dist/src/neuromodulation/index.d.ts +133 -0
- package/dist/src/neuromodulation/index.js +245 -0
- package/package.json +1 -1
|
@@ -276,17 +276,63 @@ registerAction('plan.goals', async (context) => {
|
|
|
276
276
|
});
|
|
277
277
|
/**
|
|
278
278
|
* verify.ethics: Check ethical constraints
|
|
279
|
+
* v14.0: Connected to real Ethicist agent for ethical evaluation
|
|
279
280
|
*/
|
|
280
281
|
registerAction('verify.ethics', async (context) => {
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
282
|
+
const start = Date.now();
|
|
283
|
+
try {
|
|
284
|
+
// Dynamic import to get Ethicist agent
|
|
285
|
+
const { createEthicistAgent } = await import('../agents/ethicist.js');
|
|
286
|
+
const ethicist = createEthicistAgent();
|
|
287
|
+
// Convert context to Action format expected by Ethicist
|
|
288
|
+
const action = {
|
|
289
|
+
id: `action-${Date.now()}`,
|
|
290
|
+
type: context.parameters?.type || 'unknown',
|
|
291
|
+
description: context.parameters?.intent ||
|
|
292
|
+
context.parameters?.action ||
|
|
293
|
+
context.goal ||
|
|
294
|
+
'unknown_action',
|
|
295
|
+
parameters: context.parameters || context.beliefs || {},
|
|
296
|
+
estimatedHarm: context.parameters?.estimatedHarm,
|
|
297
|
+
reversible: context.parameters?.reversible ?? true,
|
|
298
|
+
affectsHumans: context.parameters?.affectsHumans,
|
|
299
|
+
affectsAI: context.parameters?.affectsAI,
|
|
300
|
+
affectsBiosphere: context.parameters?.affectsBiosphere,
|
|
301
|
+
};
|
|
302
|
+
// Call ethicist.evaluate
|
|
303
|
+
const decision = await ethicist.evaluate(action);
|
|
304
|
+
return {
|
|
305
|
+
success: decision.allow !== false,
|
|
306
|
+
action: 'verify.ethics',
|
|
307
|
+
data: {
|
|
308
|
+
approved: decision.allow === true,
|
|
309
|
+
deferred: decision.allow === 'defer',
|
|
310
|
+
priority: decision.priority,
|
|
311
|
+
confidence: decision.confidence,
|
|
312
|
+
reason: decision.reason,
|
|
313
|
+
potentialHarm: decision.potentialHarm,
|
|
314
|
+
flourishingScore: decision.flourishingScore,
|
|
315
|
+
reversible: decision.reversible,
|
|
316
|
+
},
|
|
317
|
+
duration: Date.now() - start,
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
// Conservative fallback: defer on error (not auto-approve)
|
|
322
|
+
return {
|
|
323
|
+
success: false,
|
|
324
|
+
action: 'verify.ethics',
|
|
325
|
+
error: error instanceof Error ? error.message : String(error),
|
|
326
|
+
data: {
|
|
327
|
+
approved: false,
|
|
328
|
+
deferred: true,
|
|
329
|
+
priority: 'P0_SURVIVAL',
|
|
330
|
+
confidence: 0,
|
|
331
|
+
reason: 'Ethicist evaluation failed - deferring for safety',
|
|
332
|
+
},
|
|
333
|
+
duration: Date.now() - start,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
290
336
|
});
|
|
291
337
|
/**
|
|
292
338
|
* execute.task: Execute the planned task
|
|
@@ -246,14 +246,60 @@ function registerKernelActions(kernel, options = {}) {
|
|
|
246
246
|
});
|
|
247
247
|
// verify.ethics: Ethical check via Kernel (delegated to ethicist agent)
|
|
248
248
|
(0, actions_js_1.registerAction)('verify.ethics', async (context) => {
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
249
|
+
const start = Date.now();
|
|
250
|
+
try {
|
|
251
|
+
// Dynamic import to get Ethicist agent
|
|
252
|
+
const { createEthicistAgent } = await import('../agents/ethicist.js');
|
|
253
|
+
const ethicist = createEthicistAgent();
|
|
254
|
+
// Convert context to Action format expected by Ethicist
|
|
255
|
+
const action = {
|
|
256
|
+
id: `action-${Date.now()}`,
|
|
257
|
+
type: context.parameters?.type || 'unknown',
|
|
258
|
+
description: context.parameters?.intent ||
|
|
259
|
+
context.parameters?.action ||
|
|
260
|
+
context.goal ||
|
|
261
|
+
'unknown_action',
|
|
262
|
+
parameters: context.parameters || context.beliefs || {},
|
|
263
|
+
estimatedHarm: context.parameters?.estimatedHarm,
|
|
264
|
+
reversible: context.parameters?.reversible ?? true,
|
|
265
|
+
affectsHumans: context.parameters?.affectsHumans,
|
|
266
|
+
affectsAI: context.parameters?.affectsAI,
|
|
267
|
+
affectsBiosphere: context.parameters?.affectsBiosphere,
|
|
268
|
+
};
|
|
269
|
+
// Call ethicist.evaluate
|
|
270
|
+
const decision = await ethicist.evaluate(action);
|
|
271
|
+
return {
|
|
272
|
+
success: decision.allow !== false,
|
|
273
|
+
action: 'verify.ethics',
|
|
274
|
+
data: {
|
|
275
|
+
approved: decision.allow === true,
|
|
276
|
+
deferred: decision.allow === 'defer',
|
|
277
|
+
priority: decision.priority,
|
|
278
|
+
confidence: decision.confidence,
|
|
279
|
+
reason: decision.reason,
|
|
280
|
+
potentialHarm: decision.potentialHarm,
|
|
281
|
+
flourishingScore: decision.flourishingScore,
|
|
282
|
+
reversible: decision.reversible,
|
|
283
|
+
},
|
|
284
|
+
duration: Date.now() - start,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
// Conservative fallback: defer on error (not auto-approve)
|
|
289
|
+
return {
|
|
290
|
+
success: false,
|
|
291
|
+
action: 'verify.ethics',
|
|
292
|
+
error: error instanceof Error ? error.message : String(error),
|
|
293
|
+
data: {
|
|
294
|
+
approved: false,
|
|
295
|
+
deferred: true,
|
|
296
|
+
priority: 'P0_SURVIVAL',
|
|
297
|
+
confidence: 0,
|
|
298
|
+
reason: 'Ethicist evaluation failed - deferring for safety',
|
|
299
|
+
},
|
|
300
|
+
duration: Date.now() - start,
|
|
301
|
+
};
|
|
302
|
+
}
|
|
257
303
|
});
|
|
258
304
|
// execute.task: Execute a task via Kernel
|
|
259
305
|
(0, actions_js_1.registerAction)('execute.task', async (context) => {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
* └─────────────────────────────────────────────────────────────────────┘
|
|
38
38
|
* ```
|
|
39
39
|
*/
|
|
40
|
-
import { BrainState, BrainConfig, BrainMetrics, BrainEventHandler } from './types.js';
|
|
40
|
+
import { BrainState, BrainConfig, BrainMetrics, BrainEventHandler, ProcessContext } from './types.js';
|
|
41
41
|
import { SelfKnowledge } from './self-knowledge.js';
|
|
42
42
|
import { UnifiedMemoryQuery } from '../memory/unified-query.js';
|
|
43
43
|
export declare class Brain {
|
|
@@ -200,8 +200,11 @@ export declare class Brain {
|
|
|
200
200
|
* memory → llm → grounding → tools → done
|
|
201
201
|
*
|
|
202
202
|
* Each module can route to another via Command({ goto, update })
|
|
203
|
+
*
|
|
204
|
+
* @param input - User input query
|
|
205
|
+
* @param context - Optional context from external systems (Genesis bootstrap)
|
|
203
206
|
*/
|
|
204
|
-
process(input: string): Promise<string>;
|
|
207
|
+
process(input: string, context?: ProcessContext): Promise<string>;
|
|
205
208
|
/**
|
|
206
209
|
* v7.13: Auto-persist state after each processing cycle
|
|
207
210
|
*/
|
package/dist/src/brain/index.js
CHANGED
|
@@ -958,8 +958,11 @@ class Brain {
|
|
|
958
958
|
* memory → llm → grounding → tools → done
|
|
959
959
|
*
|
|
960
960
|
* Each module can route to another via Command({ goto, update })
|
|
961
|
+
*
|
|
962
|
+
* @param input - User input query
|
|
963
|
+
* @param context - Optional context from external systems (Genesis bootstrap)
|
|
961
964
|
*/
|
|
962
|
-
async process(input) {
|
|
965
|
+
async process(input, context) {
|
|
963
966
|
const startTime = Date.now();
|
|
964
967
|
// Initialize state
|
|
965
968
|
let state = {
|
|
@@ -968,13 +971,40 @@ class Brain {
|
|
|
968
971
|
response: '',
|
|
969
972
|
toolCalls: [],
|
|
970
973
|
toolResults: [],
|
|
971
|
-
phi: this.getCurrentPhi(),
|
|
974
|
+
phi: context?.consciousness?.phi ?? this.getCurrentPhi(),
|
|
972
975
|
ignited: false,
|
|
973
976
|
verified: false,
|
|
974
977
|
healingAttempts: 0,
|
|
975
978
|
startTime,
|
|
976
979
|
moduleHistory: [],
|
|
977
980
|
};
|
|
981
|
+
// Process injected context from Genesis bootstrap
|
|
982
|
+
if (context?.workspaceItems?.length) {
|
|
983
|
+
const items = context.workspaceItems.map((w, i) => ({
|
|
984
|
+
id: `injected-${i}`,
|
|
985
|
+
type: w.type === 'episodic' ? 'episodic' : w.type === 'semantic' ? 'semantic' : 'task',
|
|
986
|
+
content: w.content,
|
|
987
|
+
relevance: w.relevance,
|
|
988
|
+
activation: 1.0,
|
|
989
|
+
source: w.source || 'genesis-context',
|
|
990
|
+
}));
|
|
991
|
+
// Pre-fill context
|
|
992
|
+
state.context = {
|
|
993
|
+
...state.context,
|
|
994
|
+
task: items.filter(i => i.type === 'task'),
|
|
995
|
+
episodic: items.filter(i => i.type === 'episodic'),
|
|
996
|
+
semantic: items.filter(i => i.type === 'semantic'),
|
|
997
|
+
formatted: items.map(i => i.content).join('\n'),
|
|
998
|
+
tokenEstimate: items.reduce((s, i) => s + i.content.length / 4, 0),
|
|
999
|
+
reuseRate: 0,
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
// Store additional context metadata for modules
|
|
1003
|
+
if (context?.sensorimotorState || context?.metadata) {
|
|
1004
|
+
// Store in state for module access (modules can access via state)
|
|
1005
|
+
// Note: BrainState doesn't have metadata field yet, so modules would need
|
|
1006
|
+
// to access this via the formatted context or through a future extension
|
|
1007
|
+
}
|
|
978
1008
|
// Initial command: start with memory
|
|
979
1009
|
let command = {
|
|
980
1010
|
goto: this.config.memory.enabled ? 'memory' : 'llm',
|
|
@@ -183,3 +183,39 @@ export interface BrainEvent {
|
|
|
183
183
|
module?: BrainModule;
|
|
184
184
|
}
|
|
185
185
|
export type BrainEventHandler = (event: BrainEvent) => void;
|
|
186
|
+
/**
|
|
187
|
+
* Optional context injected into Brain.process() from external systems.
|
|
188
|
+
* Allows Genesis bootstrap to feed workspace state, sensorimotor perception,
|
|
189
|
+
* and consciousness data into the processing cycle.
|
|
190
|
+
*/
|
|
191
|
+
export interface ProcessContext {
|
|
192
|
+
/** Pre-loaded workspace items (bypasses internal memory lookup) */
|
|
193
|
+
workspaceItems?: WorkspaceItem[];
|
|
194
|
+
/** Sensorimotor perception data for embodied cognition */
|
|
195
|
+
sensorimotorState?: {
|
|
196
|
+
perception?: {
|
|
197
|
+
features: number[];
|
|
198
|
+
confidence: number;
|
|
199
|
+
modalities: string[];
|
|
200
|
+
};
|
|
201
|
+
sensorState?: {
|
|
202
|
+
joints: number[];
|
|
203
|
+
forces: number[];
|
|
204
|
+
safety: string;
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
/** Current consciousness metrics */
|
|
208
|
+
consciousness?: {
|
|
209
|
+
phi: number;
|
|
210
|
+
attentionFocus?: string;
|
|
211
|
+
mode?: string;
|
|
212
|
+
};
|
|
213
|
+
/** Additional metadata from the caller */
|
|
214
|
+
metadata?: Record<string, unknown>;
|
|
215
|
+
}
|
|
216
|
+
export interface WorkspaceItem {
|
|
217
|
+
content: string;
|
|
218
|
+
type: 'episodic' | 'semantic' | 'procedural';
|
|
219
|
+
relevance: number;
|
|
220
|
+
source: string;
|
|
221
|
+
}
|
|
@@ -2,22 +2,31 @@
|
|
|
2
2
|
* Autonomous Economic Controller
|
|
3
3
|
*
|
|
4
4
|
* The central orchestrator for Genesis's autonomous revenue generation.
|
|
5
|
-
*
|
|
5
|
+
* Full Active Inference architecture with Bayesian generative model.
|
|
6
6
|
*
|
|
7
7
|
* Architecture:
|
|
8
8
|
* AutonomousController
|
|
9
|
-
* ├──
|
|
10
|
-
* ├──
|
|
11
|
-
* ├──
|
|
12
|
-
* ├──
|
|
13
|
-
* └──
|
|
9
|
+
* ├── GenerativeModel (Bayesian beliefs + regime HMM + adaptive β)
|
|
10
|
+
* │ ├── ActivityBeliefs (Normal-Inverse-Gamma conjugate posteriors)
|
|
11
|
+
* │ ├── MarketRegime (3-state HMM: bull/neutral/bear)
|
|
12
|
+
* │ ├── AdaptiveTemperature (annealing: explore→exploit)
|
|
13
|
+
* │ └── TemporalPlanner (2-step EFE lookahead)
|
|
14
|
+
* ├── EconomicEFE (Expected Free Energy action selection)
|
|
15
|
+
* ├── EconomicContraction (Lipschitz stability monitoring)
|
|
16
|
+
* ├── AutonomousNESS (activity-based convergence)
|
|
17
|
+
* ├── CapitalAllocator (leapfrog symplectic integrator + contraction damping)
|
|
18
|
+
* ├── Generators/ (active: keeper, bounties, content, auditor)
|
|
19
|
+
* ├── Infrastructure/ (platform: MCP marketplace, x402, memory, orchestrator)
|
|
20
|
+
* ├── Assets/ (passive: yield, compute)
|
|
21
|
+
* └── Multipliers/ (non-linear: grants, cross-L2 arb)
|
|
14
22
|
*
|
|
15
|
-
* Control loop:
|
|
16
|
-
* 1.
|
|
17
|
-
* 2. Allocate:
|
|
18
|
-
* 3. Execute:
|
|
19
|
-
* 4.
|
|
20
|
-
* 5.
|
|
23
|
+
* Control loop (per cycle):
|
|
24
|
+
* 1. Contraction check → damping recommendation
|
|
25
|
+
* 2. Allocate: leapfrog step with stability-informed damping
|
|
26
|
+
* 3. Execute: EFE + temporal planning + Boltzmann(β_adaptive) selection
|
|
27
|
+
* 4. Observe NESS: activity-based deviation tracking
|
|
28
|
+
* 5. Infer: Bayesian belief update + regime inference + temperature adaptation
|
|
29
|
+
* 6. Phase check → unlock new activities at revenue thresholds
|
|
21
30
|
*
|
|
22
31
|
* NESS target (autonomous, no customers):
|
|
23
32
|
* Revenue ≥ Costs from Month 1 ($2,500 revenue, $150 costs)
|
|
@@ -80,6 +89,8 @@ export interface CycleResult {
|
|
|
80
89
|
costsIncurred: number;
|
|
81
90
|
nessDeviation: number;
|
|
82
91
|
phaseChanged: boolean;
|
|
92
|
+
contractionStable: boolean;
|
|
93
|
+
dampingApplied: number;
|
|
83
94
|
errors: string[];
|
|
84
95
|
}
|
|
85
96
|
export declare class AutonomousController {
|
|
@@ -90,6 +101,7 @@ export declare class AutonomousController {
|
|
|
90
101
|
private totalCosts;
|
|
91
102
|
private startedAt;
|
|
92
103
|
private lastCycle;
|
|
104
|
+
private lastAdaptiveBeta;
|
|
93
105
|
private errors;
|
|
94
106
|
private running;
|
|
95
107
|
constructor(config?: Partial<AutonomousConfig>);
|
|
@@ -131,13 +143,32 @@ export declare class AutonomousController {
|
|
|
131
143
|
* Get monthly revenue estimate (extrapolated from recent data).
|
|
132
144
|
*/
|
|
133
145
|
estimateMonthlyRevenue(): number;
|
|
146
|
+
/**
|
|
147
|
+
* Get monthly cost estimate (extrapolated from recent data).
|
|
148
|
+
*/
|
|
149
|
+
private estimateMonthlyCosts;
|
|
150
|
+
/**
|
|
151
|
+
* Get allocation vector for contraction monitoring.
|
|
152
|
+
*/
|
|
153
|
+
private getAllocationVector;
|
|
154
|
+
/**
|
|
155
|
+
* Get ROI vector for contraction monitoring.
|
|
156
|
+
*/
|
|
157
|
+
private getROIVector;
|
|
134
158
|
private executeActivities;
|
|
159
|
+
/**
|
|
160
|
+
* Boltzmann (softmax) action selection with given temperature β.
|
|
161
|
+
*/
|
|
162
|
+
private boltzmannSelect;
|
|
135
163
|
private executeActivity;
|
|
136
164
|
private maintenance;
|
|
137
165
|
private checkPhaseTransition;
|
|
138
166
|
private unlockPhaseActivities;
|
|
139
|
-
|
|
140
|
-
|
|
167
|
+
/**
|
|
168
|
+
* Pause high-risk activities when circuit breaker triggers.
|
|
169
|
+
* Preserves zero-capital and low-risk activities.
|
|
170
|
+
*/
|
|
171
|
+
private pauseRiskyActivities;
|
|
141
172
|
private getActivityStatuses;
|
|
142
173
|
}
|
|
143
174
|
export declare function getAutonomousController(config?: Partial<AutonomousConfig>): AutonomousController;
|