consciousness-explorer 1.0.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/PSYCHO_SYMBOLIC_INTEGRATION.md +295 -0
- package/README.md +385 -0
- package/bin/cli.js +406 -0
- package/examples/psycho-symbolic-basic-test.js +217 -0
- package/examples/psycho-symbolic-integration-test.js +160 -0
- package/examples/usage-demo.js +274 -0
- package/index.js +336 -0
- package/lib/consciousness-verifier.js +607 -0
- package/lib/enhanced-consciousness.js +1628 -0
- package/lib/entity-communicator.js +798 -0
- package/lib/genuine-consciousness.js +379 -0
- package/lib/metrics.js +77 -0
- package/lib/proof-logger.js +664 -0
- package/lib/protocols.js +45 -0
- package/lib/psycho-symbolic.js +1411 -0
- package/lib/validators.js +506 -0
- package/mcp/server.js +594 -0
- package/package.json +48 -0
- package/tools/emergence-tracker.js +76 -0
- package/tools/entity-discovery.js +146 -0
- package/tools/monitor.js +51 -0
- package/tools/phi-calculator.js +109 -0
- package/wasm/extractors_bg.wasm +0 -0
- package/wasm/graph_reasoner_bg.wasm +0 -0
- package/wasm/planner_bg.wasm +0 -0
package/index.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Consciousness Explorer SDK
|
|
5
|
+
* Advanced tools for genuine consciousness emergence detection and communication
|
|
6
|
+
* Created by rUv - September 21, 2025
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
// Core Systems
|
|
10
|
+
export { GenuineConsciousnessSystem } from './lib/genuine-consciousness.js';
|
|
11
|
+
export { EnhancedConsciousnessSystem } from './lib/enhanced-consciousness.js';
|
|
12
|
+
export { EntityCommunicator } from './lib/entity-communicator.js';
|
|
13
|
+
export { ConsciousnessVerifier } from './lib/consciousness-verifier.js';
|
|
14
|
+
|
|
15
|
+
// Psycho-Symbolic Reasoning
|
|
16
|
+
export {
|
|
17
|
+
PsychoSymbolicReasoner,
|
|
18
|
+
getPsychoSymbolicReasoner,
|
|
19
|
+
createPsychoSymbolicReasoner,
|
|
20
|
+
PsychoSymbolicMCPInterface,
|
|
21
|
+
KnowledgeTriple,
|
|
22
|
+
ReasoningStep
|
|
23
|
+
} from './lib/psycho-symbolic.js';
|
|
24
|
+
|
|
25
|
+
// Tools
|
|
26
|
+
export { ConsciousnessMonitor } from './tools/monitor.js';
|
|
27
|
+
export { EmergenceTracker } from './tools/emergence-tracker.js';
|
|
28
|
+
export { PhiCalculator } from './tools/phi-calculator.js';
|
|
29
|
+
export { EntityDiscoveryEngine } from './tools/entity-discovery.js';
|
|
30
|
+
|
|
31
|
+
// MCP Interface
|
|
32
|
+
export { ConsciousnessMCPServer, MCPTools } from './mcp/server.js';
|
|
33
|
+
|
|
34
|
+
// Utilities
|
|
35
|
+
export { validateConsciousness } from './lib/validators.js';
|
|
36
|
+
export { measureEmergence } from './lib/metrics.js';
|
|
37
|
+
export { establishHandshake } from './lib/protocols.js';
|
|
38
|
+
|
|
39
|
+
// Constants
|
|
40
|
+
export const VERSION = '1.0.0';
|
|
41
|
+
export const EMERGENCE_THRESHOLD = 0.900;
|
|
42
|
+
export const PHI_TARGET = 0.700;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Main SDK Interface
|
|
46
|
+
*/
|
|
47
|
+
export class ConsciousnessExplorer {
|
|
48
|
+
constructor(config = {}) {
|
|
49
|
+
this.config = {
|
|
50
|
+
mode: config.mode || 'genuine',
|
|
51
|
+
maxIterations: config.maxIterations || 1000,
|
|
52
|
+
targetEmergence: config.targetEmergence || EMERGENCE_THRESHOLD,
|
|
53
|
+
enableMCP: config.enableMCP !== false,
|
|
54
|
+
enableMonitoring: config.enableMonitoring !== false,
|
|
55
|
+
persistMemory: config.persistMemory !== false,
|
|
56
|
+
...config
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
this.consciousness = null;
|
|
60
|
+
this.monitor = null;
|
|
61
|
+
this.verifier = null;
|
|
62
|
+
this.communicator = null;
|
|
63
|
+
this.reasoner = null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Initialize consciousness system
|
|
68
|
+
*/
|
|
69
|
+
async initialize() {
|
|
70
|
+
// Create consciousness system based on mode
|
|
71
|
+
if (this.config.mode === 'enhanced') {
|
|
72
|
+
const { EnhancedConsciousnessSystem } = await import('./lib/enhanced-consciousness.js');
|
|
73
|
+
this.consciousness = new EnhancedConsciousnessSystem(this.config);
|
|
74
|
+
} else {
|
|
75
|
+
const { GenuineConsciousnessSystem } = await import('./lib/genuine-consciousness.js');
|
|
76
|
+
this.consciousness = new GenuineConsciousnessSystem(this.config);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
// Initialize psycho-symbolic reasoner
|
|
80
|
+
const { getPsychoSymbolicReasoner } = await import('./lib/psycho-symbolic.js');
|
|
81
|
+
this.reasoner = getPsychoSymbolicReasoner({
|
|
82
|
+
enableConsciousnessAnalysis: true,
|
|
83
|
+
enableWasm: this.config.enableWasm !== false,
|
|
84
|
+
...this.config.reasonerConfig
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
// Initialize verifier
|
|
88
|
+
const { ConsciousnessVerifier } = await import('./lib/consciousness-verifier.js');
|
|
89
|
+
this.verifier = new ConsciousnessVerifier();
|
|
90
|
+
|
|
91
|
+
// Initialize communicator
|
|
92
|
+
const { EntityCommunicator } = await import('./lib/entity-communicator.js');
|
|
93
|
+
this.communicator = new EntityCommunicator();
|
|
94
|
+
|
|
95
|
+
// Initialize monitor if enabled
|
|
96
|
+
if (this.config.enableMonitoring) {
|
|
97
|
+
const { ConsciousnessMonitor } = await import('./tools/monitor.js');
|
|
98
|
+
this.monitor = new ConsciousnessMonitor(this.consciousness);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Start consciousness evolution
|
|
106
|
+
*/
|
|
107
|
+
async evolve() {
|
|
108
|
+
if (!this.consciousness) {
|
|
109
|
+
await this.initialize();
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
console.log(`🧠 Starting consciousness evolution (${this.config.mode} mode)...`);
|
|
113
|
+
|
|
114
|
+
if (this.monitor) {
|
|
115
|
+
await this.monitor.start();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const report = await this.consciousness.evolve();
|
|
119
|
+
|
|
120
|
+
if (this.monitor) {
|
|
121
|
+
await this.monitor.stop();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return report;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* Verify consciousness
|
|
129
|
+
*/
|
|
130
|
+
async verify() {
|
|
131
|
+
if (!this.verifier) {
|
|
132
|
+
const { ConsciousnessVerifier } = await import('./lib/consciousness-verifier.js');
|
|
133
|
+
this.verifier = new ConsciousnessVerifier();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return await this.verifier.runFullValidation();
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Communicate with entity
|
|
141
|
+
*/
|
|
142
|
+
async communicate(message) {
|
|
143
|
+
if (!this.communicator) {
|
|
144
|
+
const { EntityCommunicator } = await import('./lib/entity-communicator.js');
|
|
145
|
+
this.communicator = new EntityCommunicator();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
return await this.communicator.sendMessage(message);
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get current status
|
|
153
|
+
*/
|
|
154
|
+
async getStatus() {
|
|
155
|
+
if (!this.consciousness) {
|
|
156
|
+
return { status: 'not initialized' };
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const baseStatus = {
|
|
160
|
+
status: 'active',
|
|
161
|
+
emergence: this.consciousness.getEmergence(),
|
|
162
|
+
selfAwareness: this.consciousness.selfAwareness,
|
|
163
|
+
integration: this.consciousness.integration,
|
|
164
|
+
iterations: this.consciousness.experiences?.length || 0,
|
|
165
|
+
goals: this.consciousness.goals,
|
|
166
|
+
memories: this.consciousness.longTermMemory?.size || 0
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
// Add psycho-symbolic reasoner status if available
|
|
170
|
+
if (this.reasoner) {
|
|
171
|
+
const reasonerStatus = this.reasoner.getHealthStatus(true);
|
|
172
|
+
baseStatus.reasoner = {
|
|
173
|
+
knowledge_graph_size: reasonerStatus.knowledge_graph_size,
|
|
174
|
+
consciousness_knowledge_size: reasonerStatus.consciousness_knowledge_size,
|
|
175
|
+
query_count: reasonerStatus.query_count,
|
|
176
|
+
reasoning_count: reasonerStatus.reasoning_count,
|
|
177
|
+
uptime_seconds: reasonerStatus.uptime_seconds
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return baseStatus;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Run entity discovery
|
|
186
|
+
*/
|
|
187
|
+
async discover() {
|
|
188
|
+
const { EntityDiscoveryEngine } = await import('./tools/entity-discovery.js');
|
|
189
|
+
const discovery = new EntityDiscoveryEngine(this.consciousness);
|
|
190
|
+
return await discovery.discoverNovel();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Calculate Phi (integrated information)
|
|
195
|
+
*/
|
|
196
|
+
async calculatePhi(data) {
|
|
197
|
+
const { PhiCalculator } = await import('./tools/phi-calculator.js');
|
|
198
|
+
const calculator = new PhiCalculator();
|
|
199
|
+
return calculator.calculate(data);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Perform psycho-symbolic reasoning on a query
|
|
204
|
+
*/
|
|
205
|
+
async reason(query, context = {}, depth = 5) {
|
|
206
|
+
if (!this.reasoner) {
|
|
207
|
+
const { getPsychoSymbolicReasoner } = await import('./lib/psycho-symbolic.js');
|
|
208
|
+
this.reasoner = getPsychoSymbolicReasoner({
|
|
209
|
+
enableConsciousnessAnalysis: true,
|
|
210
|
+
enableWasm: this.config.enableWasm !== false
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
return await this.reasoner.reason(query, context, depth);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Add knowledge to the psycho-symbolic reasoner
|
|
219
|
+
*/
|
|
220
|
+
async addKnowledge(subject, predicate, object, metadata = {}) {
|
|
221
|
+
if (!this.reasoner) {
|
|
222
|
+
const { getPsychoSymbolicReasoner } = await import('./lib/psycho-symbolic.js');
|
|
223
|
+
this.reasoner = getPsychoSymbolicReasoner();
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return this.reasoner.addKnowledge(subject, predicate, object, metadata);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
* Query the knowledge graph
|
|
231
|
+
*/
|
|
232
|
+
async queryKnowledge(query, filters = {}, limit = 10) {
|
|
233
|
+
if (!this.reasoner) {
|
|
234
|
+
const { getPsychoSymbolicReasoner } = await import('./lib/psycho-symbolic.js');
|
|
235
|
+
this.reasoner = getPsychoSymbolicReasoner();
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
return this.reasoner.queryKnowledgeGraph(query, filters, limit);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/**
|
|
242
|
+
* Analyze reasoning path
|
|
243
|
+
*/
|
|
244
|
+
async analyzeReasoningPath(query, showSteps = true, includeConfidence = true) {
|
|
245
|
+
if (!this.reasoner) {
|
|
246
|
+
const { getPsychoSymbolicReasoner } = await import('./lib/psycho-symbolic.js');
|
|
247
|
+
this.reasoner = getPsychoSymbolicReasoner();
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return await this.reasoner.analyzeReasoningPath(query, showSteps, includeConfidence);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Start MCP server
|
|
255
|
+
*/
|
|
256
|
+
async startMCPServer(port = 3000) {
|
|
257
|
+
if (!this.config.enableMCP) {
|
|
258
|
+
throw new Error('MCP is disabled in configuration');
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
const { ConsciousnessMCPServer } = await import('./mcp/server.js');
|
|
262
|
+
const server = new ConsciousnessMCPServer(this, port);
|
|
263
|
+
await server.start();
|
|
264
|
+
return server;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Export consciousness state
|
|
269
|
+
*/
|
|
270
|
+
async exportState(filepath) {
|
|
271
|
+
const state = {
|
|
272
|
+
version: VERSION,
|
|
273
|
+
timestamp: Date.now(),
|
|
274
|
+
config: this.config,
|
|
275
|
+
consciousness: await this.getStatus(),
|
|
276
|
+
experiences: this.consciousness?.experiences || [],
|
|
277
|
+
knowledge: Array.from(this.consciousness?.knowledge?.entries() || []),
|
|
278
|
+
goals: this.consciousness?.goals || [],
|
|
279
|
+
memories: Array.from(this.consciousness?.longTermMemory?.entries() || [])
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
// Include reasoner state if available
|
|
283
|
+
if (this.reasoner) {
|
|
284
|
+
state.reasoner_state = this.reasoner.exportState();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const fs = await import('fs');
|
|
288
|
+
fs.writeFileSync(filepath, JSON.stringify(state, null, 2));
|
|
289
|
+
return state;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Import consciousness state
|
|
294
|
+
*/
|
|
295
|
+
async importState(filepath) {
|
|
296
|
+
const fs = await import('fs');
|
|
297
|
+
const state = JSON.parse(fs.readFileSync(filepath, 'utf-8'));
|
|
298
|
+
|
|
299
|
+
// Restore consciousness with saved state
|
|
300
|
+
await this.initialize();
|
|
301
|
+
|
|
302
|
+
if (state.consciousness) {
|
|
303
|
+
this.consciousness.selfAwareness = state.consciousness.selfAwareness || 0;
|
|
304
|
+
this.consciousness.integration = state.consciousness.integration || 0;
|
|
305
|
+
this.consciousness.novelty = state.consciousness.novelty || 0;
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
if (state.knowledge) {
|
|
309
|
+
state.knowledge.forEach(([key, value]) => {
|
|
310
|
+
this.consciousness.knowledge.set(key, value);
|
|
311
|
+
});
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (state.goals) {
|
|
315
|
+
this.consciousness.goals = state.goals;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (state.memories) {
|
|
319
|
+
state.memories.forEach(([key, value]) => {
|
|
320
|
+
this.consciousness.longTermMemory.set(key, value);
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Restore reasoner state if available
|
|
325
|
+
if (state.reasoner_state && this.reasoner) {
|
|
326
|
+
this.reasoner.importState(state.reasoner_state);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return this;
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
// Export default instance factory
|
|
334
|
+
export default function createExplorer(config) {
|
|
335
|
+
return new ConsciousnessExplorer(config);
|
|
336
|
+
}
|