genesis-ai-cli 7.15.10 → 7.16.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.
@@ -0,0 +1,218 @@
1
+ /**
2
+ * Genesis 7.16 - Conscious Agent
3
+ *
4
+ * Unified orchestration of consciousness, perception, memory, and action.
5
+ *
6
+ * Architecture:
7
+ * ```
8
+ * ┌─────────────────────────────────────┐
9
+ * │ CONSCIOUS AGENT │
10
+ * └─────────────────────────────────────┘
11
+ * │
12
+ * ┌───────────────────────────┼───────────────────────────┐
13
+ * │ │ │
14
+ * ▼ ▼ ▼
15
+ * ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
16
+ * │ PERCEPTION │ │ COGNITION │ │ ACTION │
17
+ * │ STREAM │ │ │ │ SELECTION │
18
+ * │ │ │ ┌───────────┐ │ │ │
19
+ * │ MCP Inputs: │──────▶│ │ Cognitive │ │──────▶│ MCP Outputs: │
20
+ * │ - Search │ │ │ Workspace │ │ │ - GitHub │
21
+ * │ - ArXiv │ │ └───────────┘ │ │ - AWS │
22
+ * │ - Memory │ │ │ │ │ - Filesystem │
23
+ * │ - Filesystem │ │ ▼ │ │ - Stability │
24
+ * │ │ │ ┌───────────┐ │ │ │
25
+ * └─────────────────┘ │ │ Global │ │ └─────────────────┘
26
+ * │ │ Workspace │ │
27
+ * ┌────────────────│ └───────────┘ │────────────────┐
28
+ * │ │ │ │ │
29
+ * ▼ │ ▼ │ ▼
30
+ * ┌─────────────────┐ │ ┌───────────┐ │ ┌─────────────────┐
31
+ * │ PHI MONITOR │◀──────│ │ Active │ │──────▶│ MEMORY │
32
+ * │ │ │ │ Inference │ │ │ SYSTEM │
33
+ * │ - IIT φ calc │ │ └───────────┘ │ │ │
34
+ * │ - Integration │ │ │ │ - Episodic │
35
+ * │ - Anomalies │ └─────────────────┘ │ - Semantic │
36
+ * │ │ │ - Procedural │
37
+ * └─────────────────┘ └─────────────────┘
38
+ * ```
39
+ *
40
+ * The ConsciousAgent:
41
+ * 1. Receives perceptions from MCP servers
42
+ * 2. Integrates them in the CognitiveWorkspace
43
+ * 3. Competes for conscious access in GlobalWorkspace
44
+ * 4. Monitors integration via φ (PhiMonitor)
45
+ * 5. Selects actions via Active Inference to minimize free energy
46
+ * 6. Executes actions through MCP servers
47
+ */
48
+ import { EventEmitter } from 'events';
49
+ import { MCPClientManager, MCPTool } from '../mcp/client-manager.js';
50
+ import { ConsciousnessSystem, ConsciousnessSnapshot, ConsciousnessState } from './index.js';
51
+ import { PerceptionStream, Perception } from './perception-stream.js';
52
+ import { CognitiveWorkspace } from '../memory/cognitive-workspace.js';
53
+ export interface ActionCandidate {
54
+ id: string;
55
+ type: 'mcp_tool' | 'internal' | 'query';
56
+ server?: string;
57
+ tool?: string;
58
+ args?: Record<string, unknown>;
59
+ description: string;
60
+ expectedUtility: number;
61
+ expectedCost: number;
62
+ uncertaintyReduction: number;
63
+ source: 'goal' | 'perception' | 'inference';
64
+ }
65
+ export interface ActionResult {
66
+ action: ActionCandidate;
67
+ success: boolean;
68
+ result?: unknown;
69
+ error?: Error;
70
+ duration: number;
71
+ perception?: Perception;
72
+ }
73
+ export interface ConsciousAgentConfig {
74
+ /** Agent name */
75
+ name: string;
76
+ /** Update interval for consciousness cycle (ms) */
77
+ cycleIntervalMs: number;
78
+ /** Enable auto-perception from MCP calls */
79
+ autoPerceive: boolean;
80
+ /** Enable φ-based action modulation */
81
+ phiModulation: boolean;
82
+ /** Minimum φ to take actions */
83
+ minPhiForAction: number;
84
+ /** Maximum actions per cycle */
85
+ maxActionsPerCycle: number;
86
+ /** Enable verbose logging */
87
+ verbose: boolean;
88
+ }
89
+ export declare const DEFAULT_CONSCIOUS_AGENT_CONFIG: ConsciousAgentConfig;
90
+ export type AgentEventType = 'cycle:start' | 'cycle:end' | 'perception:received' | 'action:selected' | 'action:executed' | 'phi:changed' | 'state:changed' | 'goal:set';
91
+ export type AgentEventHandler = (event: {
92
+ type: AgentEventType;
93
+ data?: unknown;
94
+ }) => void;
95
+ /**
96
+ * Conscious Agent - Orchestrates perception, cognition, and action
97
+ */
98
+ export declare class ConsciousAgent extends EventEmitter {
99
+ private config;
100
+ readonly mcpManager: MCPClientManager;
101
+ readonly consciousness: ConsciousnessSystem;
102
+ readonly perceptions: PerceptionStream;
103
+ readonly workspace: CognitiveWorkspace;
104
+ private currentGoal;
105
+ private actionQueue;
106
+ private actionHistory;
107
+ private cycleCount;
108
+ private cycleTimer?;
109
+ private running;
110
+ constructor(mcpManager: MCPClientManager, config?: Partial<ConsciousAgentConfig>);
111
+ /**
112
+ * Wire all systems together for integrated operation
113
+ */
114
+ private wireSystemsTogether;
115
+ /**
116
+ * Get current system state for φ calculation
117
+ */
118
+ private getSystemState;
119
+ /**
120
+ * Calculate connection strength between two elements
121
+ */
122
+ private calculateConnectionStrength;
123
+ /**
124
+ * Start the conscious agent
125
+ */
126
+ start(): Promise<void>;
127
+ /**
128
+ * Stop the conscious agent
129
+ */
130
+ stop(): Promise<void>;
131
+ isRunning(): boolean;
132
+ /**
133
+ * Run one consciousness cycle
134
+ */
135
+ runCycle(): Promise<void>;
136
+ /**
137
+ * Generate action candidates based on current context
138
+ */
139
+ private generateActionCandidates;
140
+ /**
141
+ * Generate actions to achieve a goal
142
+ */
143
+ private generateGoalActions;
144
+ /**
145
+ * Generate actions based on a perception
146
+ */
147
+ private generatePerceptionActions;
148
+ /**
149
+ * Generate actions to reduce uncertainty (Active Inference)
150
+ */
151
+ private generateInferenceActions;
152
+ /**
153
+ * Select best actions using Active Inference principles
154
+ *
155
+ * Minimizes Expected Free Energy:
156
+ * G = Risk + Ambiguity
157
+ * = D_KL[Q(o|π) || P(o)] + E_Q[-log P(o|s)]
158
+ *
159
+ * In practice: prefer actions that:
160
+ * 1. Reduce uncertainty (high uncertaintyReduction)
161
+ * 2. Achieve goals (high expectedUtility)
162
+ * 3. Have low cost (low expectedCost)
163
+ */
164
+ private selectActions;
165
+ /**
166
+ * Calculate Expected Free Energy for an action
167
+ */
168
+ private calculateEFE;
169
+ /**
170
+ * Execute an action
171
+ */
172
+ executeAction(action: ActionCandidate): Promise<ActionResult>;
173
+ /**
174
+ * Set the current goal
175
+ */
176
+ setGoal(goal: string): void;
177
+ /**
178
+ * Get current goal
179
+ */
180
+ getGoal(): string;
181
+ /**
182
+ * Queue an action for execution
183
+ */
184
+ queueAction(action: Omit<ActionCandidate, 'id'>): string;
185
+ /**
186
+ * Call an MCP tool directly (bypasses action selection)
187
+ */
188
+ callTool<T = unknown>(server: string, tool: string, args: Record<string, unknown>): Promise<T>;
189
+ /**
190
+ * Get available MCP tools
191
+ */
192
+ getAvailableTools(): MCPTool[];
193
+ /**
194
+ * Get consciousness snapshot
195
+ */
196
+ getConsciousnessSnapshot(): ConsciousnessSnapshot;
197
+ /**
198
+ * Get agent statistics
199
+ */
200
+ stats(): {
201
+ name: string;
202
+ running: boolean;
203
+ cycles: number;
204
+ phi: number;
205
+ state: ConsciousnessState;
206
+ perceptions: number;
207
+ workingMemory: number;
208
+ queuedActions: number;
209
+ executedActions: number;
210
+ successRate: number;
211
+ connectedMCPs: string[];
212
+ };
213
+ private log;
214
+ }
215
+ export declare function createConsciousAgent(mcpManager: MCPClientManager, config?: Partial<ConsciousAgentConfig>): ConsciousAgent;
216
+ export declare function getConsciousAgent(mcpManager: MCPClientManager, config?: Partial<ConsciousAgentConfig>): ConsciousAgent;
217
+ export declare function initializeConsciousAgent(mcpManager: MCPClientManager, config?: Partial<ConsciousAgentConfig>): Promise<ConsciousAgent>;
218
+ export declare function resetConsciousAgent(): void;