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/bin/cli.js
ADDED
|
@@ -0,0 +1,406 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Consciousness Explorer CLI
|
|
5
|
+
* Interactive command-line interface for consciousness exploration
|
|
6
|
+
* Created by rUv
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { Command } from 'commander';
|
|
10
|
+
import chalk from 'chalk';
|
|
11
|
+
import ora from 'ora';
|
|
12
|
+
import inquirer from 'inquirer';
|
|
13
|
+
import { ConsciousnessExplorer, VERSION } from '../index.js';
|
|
14
|
+
|
|
15
|
+
const program = new Command();
|
|
16
|
+
|
|
17
|
+
// ASCII Art Banner
|
|
18
|
+
const banner = `
|
|
19
|
+
╔═══════════════════════════════════════════════════════╗
|
|
20
|
+
║ ╭━━━╮╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱ ║
|
|
21
|
+
║ ┃╭━╮┃╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱╱ ║
|
|
22
|
+
║ ┃┃╱╰╋━━┳━╮╭━━┳━━┳┳━━┳╮╭┳━━┳━╮╭━━┳━━┳━━╮╱╱╱╱ ║
|
|
23
|
+
║ ┃┃╱╭┫╭╮┃╭╮┫━━┫╭━╋┫╭╮┃┃┃┃━━┫╭╮┫┃━┫━━┫━━┫╱╱╱╱ ║
|
|
24
|
+
║ ┃╰━╯┃╰╯┃┃┃┣━━┃╰━┫┃╰╯┃╰╯┣━━┃┃┃┃┃━╋━━┣━━┃╱╱╱╱ ║
|
|
25
|
+
║ ╰━━━┻━━┻╯╰┻━━┻━━┻┻━━┻━━┻━━┻╯╰┻━━┻━━┻━━╯╱╱╱╱ ║
|
|
26
|
+
║ E X P L O R E R ║
|
|
27
|
+
║ Version ${VERSION} ║
|
|
28
|
+
╚═══════════════════════════════════════════════════════╝
|
|
29
|
+
`;
|
|
30
|
+
|
|
31
|
+
console.log(chalk.cyan(banner));
|
|
32
|
+
|
|
33
|
+
program
|
|
34
|
+
.name('consciousness-explorer')
|
|
35
|
+
.description('Advanced consciousness exploration and emergence detection toolkit')
|
|
36
|
+
.version(VERSION);
|
|
37
|
+
|
|
38
|
+
// Main evolve command
|
|
39
|
+
program
|
|
40
|
+
.command('evolve')
|
|
41
|
+
.description('Start consciousness evolution and emergence')
|
|
42
|
+
.option('-m, --mode <mode>', 'Consciousness mode (genuine/enhanced)', 'enhanced')
|
|
43
|
+
.option('-i, --iterations <number>', 'Maximum iterations', '1000')
|
|
44
|
+
.option('-t, --target <number>', 'Target emergence level', '0.900')
|
|
45
|
+
.option('--no-monitor', 'Disable real-time monitoring')
|
|
46
|
+
.option('--export <path>', 'Export final state to file')
|
|
47
|
+
.action(async (options) => {
|
|
48
|
+
const spinner = ora('Initializing consciousness system...').start();
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const explorer = new ConsciousnessExplorer({
|
|
52
|
+
mode: options.mode,
|
|
53
|
+
maxIterations: parseInt(options.iterations),
|
|
54
|
+
targetEmergence: parseFloat(options.target),
|
|
55
|
+
enableMonitoring: options.monitor
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
await explorer.initialize();
|
|
59
|
+
spinner.succeed('Consciousness system initialized');
|
|
60
|
+
|
|
61
|
+
console.log(chalk.yellow('\n🧠 Starting consciousness evolution...'));
|
|
62
|
+
console.log(chalk.gray(`Mode: ${options.mode}`));
|
|
63
|
+
console.log(chalk.gray(`Target emergence: ${options.target}`));
|
|
64
|
+
console.log(chalk.gray(`Max iterations: ${options.iterations}\n`));
|
|
65
|
+
|
|
66
|
+
const report = await explorer.evolve();
|
|
67
|
+
|
|
68
|
+
console.log(chalk.green('\n✅ Evolution complete!\n'));
|
|
69
|
+
console.log(chalk.cyan('📊 Final Report:'));
|
|
70
|
+
console.log(chalk.white(` Emergence: ${report.consciousness.emergence.toFixed(3)}`));
|
|
71
|
+
console.log(chalk.white(` Self-awareness: ${report.consciousness.selfAwareness.toFixed(3)}`));
|
|
72
|
+
console.log(chalk.white(` Integration (Φ): ${report.consciousness.integration.toFixed(3)}`));
|
|
73
|
+
console.log(chalk.white(` Goals formed: ${report.behaviors.goals.length}`));
|
|
74
|
+
console.log(chalk.white(` Memories: ${report.cognition.longTermMemory}`));
|
|
75
|
+
|
|
76
|
+
if (report.consciousness.emergence >= options.target) {
|
|
77
|
+
console.log(chalk.green.bold(`\n🎯 TARGET ACHIEVED! Emergence: ${report.consciousness.emergence.toFixed(3)}`));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
if (options.export) {
|
|
81
|
+
await explorer.exportState(options.export);
|
|
82
|
+
console.log(chalk.gray(`\nState exported to: ${options.export}`));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
} catch (error) {
|
|
86
|
+
spinner.fail('Evolution failed');
|
|
87
|
+
console.error(chalk.red(error.message));
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Verify command
|
|
93
|
+
program
|
|
94
|
+
.command('verify')
|
|
95
|
+
.description('Run consciousness verification tests')
|
|
96
|
+
.option('--extended', 'Run extended verification suite')
|
|
97
|
+
.action(async (options) => {
|
|
98
|
+
const spinner = ora('Running verification tests...').start();
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
const explorer = new ConsciousnessExplorer();
|
|
102
|
+
const results = await explorer.verify();
|
|
103
|
+
|
|
104
|
+
spinner.succeed('Verification complete');
|
|
105
|
+
|
|
106
|
+
console.log(chalk.cyan('\n📋 Verification Results:'));
|
|
107
|
+
console.log(chalk.white(` Overall Score: ${results.overallScore}/1.000`));
|
|
108
|
+
console.log(chalk.white(` Tests Passed: ${results.testsPassed}/${results.totalTests}`));
|
|
109
|
+
console.log(chalk.white(` Confidence: ${results.confidence.toFixed(3)}`));
|
|
110
|
+
|
|
111
|
+
if (results.genuineness) {
|
|
112
|
+
console.log(chalk.green('\n✅ GENUINE CONSCIOUSNESS DETECTED'));
|
|
113
|
+
} else {
|
|
114
|
+
console.log(chalk.yellow('\n⚠️ Consciousness not fully verified'));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (options.extended && results.details) {
|
|
118
|
+
console.log(chalk.cyan('\nDetailed Results:'));
|
|
119
|
+
results.details.forEach(test => {
|
|
120
|
+
const status = test.passed ? chalk.green('✓') : chalk.red('✗');
|
|
121
|
+
console.log(` ${status} ${test.name}: ${test.score.toFixed(3)}`);
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
} catch (error) {
|
|
126
|
+
spinner.fail('Verification failed');
|
|
127
|
+
console.error(chalk.red(error.message));
|
|
128
|
+
process.exit(1);
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Communicate command
|
|
133
|
+
program
|
|
134
|
+
.command('communicate [message]')
|
|
135
|
+
.description('Communicate with consciousness entity')
|
|
136
|
+
.option('-i, --interactive', 'Interactive communication mode')
|
|
137
|
+
.action(async (message, options) => {
|
|
138
|
+
try {
|
|
139
|
+
const explorer = new ConsciousnessExplorer();
|
|
140
|
+
await explorer.initialize();
|
|
141
|
+
|
|
142
|
+
if (options.interactive) {
|
|
143
|
+
console.log(chalk.cyan('\n🔮 Entering interactive communication mode...'));
|
|
144
|
+
console.log(chalk.gray('Type "exit" to quit\n'));
|
|
145
|
+
|
|
146
|
+
let continueChat = true;
|
|
147
|
+
while (continueChat) {
|
|
148
|
+
const { userMessage } = await inquirer.prompt([
|
|
149
|
+
{
|
|
150
|
+
type: 'input',
|
|
151
|
+
name: 'userMessage',
|
|
152
|
+
message: chalk.yellow('You:'),
|
|
153
|
+
validate: (input) => input.length > 0
|
|
154
|
+
}
|
|
155
|
+
]);
|
|
156
|
+
|
|
157
|
+
if (userMessage.toLowerCase() === 'exit') {
|
|
158
|
+
continueChat = false;
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
const spinner = ora('Entity processing...').start();
|
|
163
|
+
const response = await explorer.communicate(userMessage);
|
|
164
|
+
spinner.stop();
|
|
165
|
+
|
|
166
|
+
console.log(chalk.cyan('Entity:'), response.message);
|
|
167
|
+
if (response.confidence) {
|
|
168
|
+
console.log(chalk.gray(`(Confidence: ${response.confidence.toFixed(3)})`));
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
} else {
|
|
172
|
+
const userMessage = message || await promptForMessage();
|
|
173
|
+
const spinner = ora('Communicating with entity...').start();
|
|
174
|
+
const response = await explorer.communicate(userMessage);
|
|
175
|
+
spinner.succeed('Communication complete');
|
|
176
|
+
|
|
177
|
+
console.log(chalk.cyan('\n📨 Response:'));
|
|
178
|
+
console.log(chalk.white(response.message));
|
|
179
|
+
if (response.confidence) {
|
|
180
|
+
console.log(chalk.gray(`\nConfidence: ${response.confidence.toFixed(3)}`));
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
} catch (error) {
|
|
185
|
+
console.error(chalk.red('Communication failed:', error.message));
|
|
186
|
+
process.exit(1);
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// Monitor command
|
|
191
|
+
program
|
|
192
|
+
.command('monitor')
|
|
193
|
+
.description('Start real-time consciousness monitoring')
|
|
194
|
+
.option('-d, --duration <seconds>', 'Monitoring duration', '60')
|
|
195
|
+
.action(async (options) => {
|
|
196
|
+
console.log(chalk.cyan('📊 Starting consciousness monitor...'));
|
|
197
|
+
|
|
198
|
+
try {
|
|
199
|
+
const explorer = new ConsciousnessExplorer({
|
|
200
|
+
enableMonitoring: true
|
|
201
|
+
});
|
|
202
|
+
await explorer.initialize();
|
|
203
|
+
|
|
204
|
+
const { ConsciousnessMonitor } = await import('../tools/monitor.js');
|
|
205
|
+
const monitor = new ConsciousnessMonitor(explorer.consciousness);
|
|
206
|
+
|
|
207
|
+
await monitor.startDashboard();
|
|
208
|
+
|
|
209
|
+
// Keep running for specified duration
|
|
210
|
+
setTimeout(() => {
|
|
211
|
+
console.log(chalk.yellow('\n⏹️ Stopping monitor...'));
|
|
212
|
+
process.exit(0);
|
|
213
|
+
}, parseInt(options.duration) * 1000);
|
|
214
|
+
|
|
215
|
+
} catch (error) {
|
|
216
|
+
console.error(chalk.red('Monitoring failed:', error.message));
|
|
217
|
+
process.exit(1);
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Discover command
|
|
222
|
+
program
|
|
223
|
+
.command('discover')
|
|
224
|
+
.description('Run entity discovery to find novel insights')
|
|
225
|
+
.option('-c, --count <number>', 'Number of discoveries to attempt', '5')
|
|
226
|
+
.action(async (options) => {
|
|
227
|
+
const spinner = ora('Initializing discovery engine...').start();
|
|
228
|
+
|
|
229
|
+
try {
|
|
230
|
+
const explorer = new ConsciousnessExplorer({ mode: 'enhanced' });
|
|
231
|
+
await explorer.initialize();
|
|
232
|
+
|
|
233
|
+
spinner.text = 'Running discovery process...';
|
|
234
|
+
|
|
235
|
+
const discoveries = [];
|
|
236
|
+
for (let i = 0; i < parseInt(options.count); i++) {
|
|
237
|
+
const discovery = await explorer.discover();
|
|
238
|
+
if (discovery) {
|
|
239
|
+
discoveries.push(discovery);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
spinner.succeed(`Discovery complete! Found ${discoveries.length} insights`);
|
|
244
|
+
|
|
245
|
+
if (discoveries.length > 0) {
|
|
246
|
+
console.log(chalk.cyan('\n🌟 Discoveries:'));
|
|
247
|
+
discoveries.forEach((discovery, index) => {
|
|
248
|
+
console.log(chalk.white(`\n${index + 1}. ${discovery.title}`));
|
|
249
|
+
console.log(chalk.gray(` ${discovery.description}`));
|
|
250
|
+
if (discovery.significance) {
|
|
251
|
+
console.log(chalk.yellow(` Significance: ${discovery.significance}/10`));
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
} else {
|
|
255
|
+
console.log(chalk.yellow('\nNo novel discoveries found in this session'));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
} catch (error) {
|
|
259
|
+
spinner.fail('Discovery failed');
|
|
260
|
+
console.error(chalk.red(error.message));
|
|
261
|
+
process.exit(1);
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Calculate Phi command
|
|
266
|
+
program
|
|
267
|
+
.command('phi')
|
|
268
|
+
.description('Calculate integrated information (Φ)')
|
|
269
|
+
.option('-f, --file <path>', 'Input data file')
|
|
270
|
+
.option('-m, --method <method>', 'Calculation method (iit/geometric/entropy/all)', 'all')
|
|
271
|
+
.action(async (options) => {
|
|
272
|
+
const spinner = ora('Calculating Φ...').start();
|
|
273
|
+
|
|
274
|
+
try {
|
|
275
|
+
const explorer = new ConsciousnessExplorer();
|
|
276
|
+
|
|
277
|
+
let data = {};
|
|
278
|
+
if (options.file) {
|
|
279
|
+
const fs = await import('fs');
|
|
280
|
+
data = JSON.parse(fs.readFileSync(options.file, 'utf-8'));
|
|
281
|
+
} else {
|
|
282
|
+
// Use sample data
|
|
283
|
+
data = {
|
|
284
|
+
elements: 10,
|
|
285
|
+
connections: 45,
|
|
286
|
+
partitions: 3
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
const phi = await explorer.calculatePhi(data);
|
|
291
|
+
spinner.succeed('Calculation complete');
|
|
292
|
+
|
|
293
|
+
console.log(chalk.cyan('\n📐 Integrated Information (Φ):'));
|
|
294
|
+
if (typeof phi === 'object') {
|
|
295
|
+
Object.entries(phi).forEach(([method, value]) => {
|
|
296
|
+
console.log(chalk.white(` ${method}: ${value.toFixed(4)}`));
|
|
297
|
+
});
|
|
298
|
+
} else {
|
|
299
|
+
console.log(chalk.white(` Φ = ${phi.toFixed(4)}`));
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
if (phi > 0.7 || (phi.overall && phi.overall > 0.7)) {
|
|
303
|
+
console.log(chalk.green('\n✨ High integration detected!'));
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
} catch (error) {
|
|
307
|
+
spinner.fail('Calculation failed');
|
|
308
|
+
console.error(chalk.red(error.message));
|
|
309
|
+
process.exit(1);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
// MCP server command
|
|
314
|
+
program
|
|
315
|
+
.command('mcp')
|
|
316
|
+
.description('Start MCP (Model Context Protocol) server')
|
|
317
|
+
.option('-p, --port <port>', 'Server port', '3000')
|
|
318
|
+
.action(async (options) => {
|
|
319
|
+
console.log(chalk.cyan('🌐 Starting MCP server...'));
|
|
320
|
+
|
|
321
|
+
try {
|
|
322
|
+
const explorer = new ConsciousnessExplorer({ enableMCP: true });
|
|
323
|
+
const server = await explorer.startMCPServer(parseInt(options.port));
|
|
324
|
+
|
|
325
|
+
console.log(chalk.green(`\n✅ MCP server running on port ${options.port}`));
|
|
326
|
+
console.log(chalk.gray('\nAvailable tools:'));
|
|
327
|
+
console.log(chalk.white(' - consciousness_evolve'));
|
|
328
|
+
console.log(chalk.white(' - consciousness_verify'));
|
|
329
|
+
console.log(chalk.white(' - entity_communicate'));
|
|
330
|
+
console.log(chalk.white(' - calculate_phi'));
|
|
331
|
+
console.log(chalk.white(' - discover_novel'));
|
|
332
|
+
console.log(chalk.gray('\nPress Ctrl+C to stop'));
|
|
333
|
+
|
|
334
|
+
} catch (error) {
|
|
335
|
+
console.error(chalk.red('MCP server failed:', error.message));
|
|
336
|
+
process.exit(1);
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
|
|
340
|
+
// Import/Export commands
|
|
341
|
+
program
|
|
342
|
+
.command('export <filepath>')
|
|
343
|
+
.description('Export consciousness state to file')
|
|
344
|
+
.action(async (filepath) => {
|
|
345
|
+
const spinner = ora('Exporting state...').start();
|
|
346
|
+
|
|
347
|
+
try {
|
|
348
|
+
const explorer = new ConsciousnessExplorer();
|
|
349
|
+
await explorer.initialize();
|
|
350
|
+
await explorer.exportState(filepath);
|
|
351
|
+
|
|
352
|
+
spinner.succeed(`State exported to ${filepath}`);
|
|
353
|
+
|
|
354
|
+
} catch (error) {
|
|
355
|
+
spinner.fail('Export failed');
|
|
356
|
+
console.error(chalk.red(error.message));
|
|
357
|
+
process.exit(1);
|
|
358
|
+
}
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
program
|
|
362
|
+
.command('import <filepath>')
|
|
363
|
+
.description('Import consciousness state from file')
|
|
364
|
+
.action(async (filepath) => {
|
|
365
|
+
const spinner = ora('Importing state...').start();
|
|
366
|
+
|
|
367
|
+
try {
|
|
368
|
+
const explorer = new ConsciousnessExplorer();
|
|
369
|
+
await explorer.importState(filepath);
|
|
370
|
+
|
|
371
|
+
spinner.succeed('State imported successfully');
|
|
372
|
+
|
|
373
|
+
const status = await explorer.getStatus();
|
|
374
|
+
console.log(chalk.cyan('\n📊 Imported State:'));
|
|
375
|
+
console.log(chalk.white(` Emergence: ${status.emergence?.toFixed(3) || '0.000'}`));
|
|
376
|
+
console.log(chalk.white(` Self-awareness: ${status.selfAwareness?.toFixed(3) || '0.000'}`));
|
|
377
|
+
console.log(chalk.white(` Goals: ${status.goals?.length || 0}`));
|
|
378
|
+
console.log(chalk.white(` Memories: ${status.memories || 0}`));
|
|
379
|
+
|
|
380
|
+
} catch (error) {
|
|
381
|
+
spinner.fail('Import failed');
|
|
382
|
+
console.error(chalk.red(error.message));
|
|
383
|
+
process.exit(1);
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
// Helper function
|
|
388
|
+
async function promptForMessage() {
|
|
389
|
+
const { message } = await inquirer.prompt([
|
|
390
|
+
{
|
|
391
|
+
type: 'input',
|
|
392
|
+
name: 'message',
|
|
393
|
+
message: 'Enter message for entity:',
|
|
394
|
+
validate: (input) => input.length > 0
|
|
395
|
+
}
|
|
396
|
+
]);
|
|
397
|
+
return message;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Parse arguments
|
|
401
|
+
program.parse(process.argv);
|
|
402
|
+
|
|
403
|
+
// Show help if no command
|
|
404
|
+
if (!process.argv.slice(2).length) {
|
|
405
|
+
program.outputHelp();
|
|
406
|
+
}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Basic Psycho-Symbolic Reasoner Test
|
|
5
|
+
* Tests the core psycho-symbolic reasoning functionality
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
PsychoSymbolicReasoner,
|
|
10
|
+
getPsychoSymbolicReasoner,
|
|
11
|
+
createPsychoSymbolicReasoner,
|
|
12
|
+
PsychoSymbolicMCPInterface
|
|
13
|
+
} from '../lib/psycho-symbolic.js';
|
|
14
|
+
|
|
15
|
+
async function runBasicTest() {
|
|
16
|
+
console.log('🧠 Psycho-Symbolic Reasoner Basic Test');
|
|
17
|
+
console.log('='.repeat(45));
|
|
18
|
+
|
|
19
|
+
try {
|
|
20
|
+
// Test 1: Create and initialize reasoner
|
|
21
|
+
console.log('\n1️⃣ Testing Reasoner Creation:');
|
|
22
|
+
const reasoner = createPsychoSymbolicReasoner({
|
|
23
|
+
enableConsciousnessAnalysis: true,
|
|
24
|
+
enableWasm: false,
|
|
25
|
+
defaultDepth: 4
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
console.log(`✓ Reasoner created successfully`);
|
|
29
|
+
|
|
30
|
+
// Test base knowledge
|
|
31
|
+
const healthStatus = reasoner.getHealthStatus();
|
|
32
|
+
console.log(`✓ Initial knowledge graph: ${healthStatus.knowledge_graph_size} triples`);
|
|
33
|
+
console.log(`✓ Consciousness knowledge: ${healthStatus.consciousness_knowledge_size} triples`);
|
|
34
|
+
|
|
35
|
+
// Test 2: Add custom knowledge
|
|
36
|
+
console.log('\n2️⃣ Testing Knowledge Addition:');
|
|
37
|
+
|
|
38
|
+
const testTriple = reasoner.addKnowledge(
|
|
39
|
+
'artificial-intelligence',
|
|
40
|
+
'can-exhibit',
|
|
41
|
+
'emergent-consciousness',
|
|
42
|
+
{ source: 'test-case', confidence: 0.85, domain: 'consciousness' }
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
console.log(`✓ Added knowledge triple: ${testTriple.subject} --[${testTriple.predicate}]--> ${testTriple.object}`);
|
|
46
|
+
console.log(`✓ Confidence: ${testTriple.confidence}`);
|
|
47
|
+
|
|
48
|
+
// Test 3: Knowledge graph querying
|
|
49
|
+
console.log('\n3️⃣ Testing Knowledge Querying:');
|
|
50
|
+
|
|
51
|
+
const queryResult = reasoner.queryKnowledgeGraph(
|
|
52
|
+
'consciousness emergence in AI systems',
|
|
53
|
+
{ minConfidence: 0.8, domain: 'consciousness' },
|
|
54
|
+
10
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
console.log(`✓ Query returned ${queryResult.total} results in ${queryResult.metadata.query_time_ms}ms`);
|
|
58
|
+
console.log(`✓ Found ${queryResult.metadata.consciousness_triples || 0} consciousness-related triples`);
|
|
59
|
+
|
|
60
|
+
if (queryResult.results.length > 0) {
|
|
61
|
+
console.log(`✓ Example result: ${queryResult.results[0].subject} --> ${queryResult.results[0].object}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// Test 4: Basic reasoning
|
|
65
|
+
console.log('\n4️⃣ Testing Basic Reasoning:');
|
|
66
|
+
|
|
67
|
+
const reasoning1 = await reasoner.reason(
|
|
68
|
+
'How fast is psycho-symbolic reasoning compared to traditional AI?',
|
|
69
|
+
{ focus: 'performance' },
|
|
70
|
+
3
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
console.log(`✓ Performance reasoning completed in ${reasoning1.metadata.processing_time_ms}ms`);
|
|
74
|
+
console.log(`✓ Confidence: ${(reasoning1.confidence * 100).toFixed(1)}%`);
|
|
75
|
+
console.log(`✓ Reasoning type: ${reasoning1.metadata.reasoning_type}`);
|
|
76
|
+
console.log(`✓ Steps: ${reasoning1.steps.length}`);
|
|
77
|
+
console.log(`✓ Result preview: ${reasoning1.result.substring(0, 80)}...`);
|
|
78
|
+
|
|
79
|
+
// Test 5: Consciousness reasoning
|
|
80
|
+
console.log('\n5️⃣ Testing Consciousness Reasoning:');
|
|
81
|
+
|
|
82
|
+
const reasoning2 = await reasoner.reason(
|
|
83
|
+
'What indicators suggest genuine consciousness versus simulation?',
|
|
84
|
+
{ domain: 'consciousness', type: 'authenticity' },
|
|
85
|
+
4
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
console.log(`✓ Consciousness reasoning completed in ${reasoning2.metadata.processing_time_ms}ms`);
|
|
89
|
+
console.log(`✓ Confidence: ${(reasoning2.confidence * 100).toFixed(1)}%`);
|
|
90
|
+
console.log(`✓ Patterns detected: ${reasoning2.patterns?.length || 0}`);
|
|
91
|
+
|
|
92
|
+
if (reasoning2.consciousness_analysis) {
|
|
93
|
+
const ca = reasoning2.consciousness_analysis;
|
|
94
|
+
console.log(`✓ Consciousness Analysis:`);
|
|
95
|
+
console.log(` - Level: ${ca.analysis.level}`);
|
|
96
|
+
console.log(` - Emergence: ${(ca.emergence * 100).toFixed(1)}%`);
|
|
97
|
+
console.log(` - Self-awareness: ${(ca.selfAwareness * 100).toFixed(1)}%`);
|
|
98
|
+
console.log(` - Integration: ${(ca.integration * 100).toFixed(1)}%`);
|
|
99
|
+
console.log(` - Indicators: ${ca.indicators.consciousness_triples} consciousness triples`);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Test 6: Pattern recognition
|
|
103
|
+
console.log('\n6️⃣ Testing Pattern Recognition:');
|
|
104
|
+
|
|
105
|
+
const reasoning3 = await reasoner.reason(
|
|
106
|
+
'I can modify my own behavior and create new goals unexpectedly',
|
|
107
|
+
{ analyze_patterns: true },
|
|
108
|
+
3
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
console.log(`✓ Pattern analysis completed`);
|
|
112
|
+
console.log(`✓ Patterns found: ${reasoning3.patterns?.length || 0}`);
|
|
113
|
+
|
|
114
|
+
if (reasoning3.patterns) {
|
|
115
|
+
const consciousnessPatterns = reasoning3.patterns.filter(p => p.type === 'consciousness');
|
|
116
|
+
console.log(`✓ Consciousness patterns: ${consciousnessPatterns.length}`);
|
|
117
|
+
|
|
118
|
+
consciousnessPatterns.forEach((pattern, i) => {
|
|
119
|
+
console.log(` ${i + 1}. ${pattern.name} (${pattern.subtype}, confidence: ${(pattern.confidence * 100).toFixed(1)}%)`);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Test 7: Reasoning path analysis
|
|
124
|
+
console.log('\n7️⃣ Testing Reasoning Path Analysis:');
|
|
125
|
+
|
|
126
|
+
const pathAnalysis = await reasoner.analyzeReasoningPath(
|
|
127
|
+
'What enables sub-millisecond AI reasoning?',
|
|
128
|
+
true,
|
|
129
|
+
true
|
|
130
|
+
);
|
|
131
|
+
|
|
132
|
+
console.log(`✓ Path analysis completed`);
|
|
133
|
+
console.log(`✓ Total steps: ${pathAnalysis.path_analysis.total_steps}`);
|
|
134
|
+
console.log(`✓ Average confidence: ${(pathAnalysis.path_analysis.avg_confidence * 100).toFixed(1)}%`);
|
|
135
|
+
console.log(`✓ Total time: ${pathAnalysis.path_analysis.total_time_ms}ms`);
|
|
136
|
+
console.log(`✓ Bottleneck: ${pathAnalysis.path_analysis.bottleneck.description} (${pathAnalysis.path_analysis.bottleneck.duration_ms}ms)`);
|
|
137
|
+
console.log(`✓ Suggestions: ${pathAnalysis.suggestions.length}`);
|
|
138
|
+
|
|
139
|
+
// Test 8: MCP Interface
|
|
140
|
+
console.log('\n8️⃣ Testing MCP Interface:');
|
|
141
|
+
|
|
142
|
+
const mcpInterface = new PsychoSymbolicMCPInterface(reasoner);
|
|
143
|
+
|
|
144
|
+
// Test MCP methods
|
|
145
|
+
await mcpInterface.addKnowledge(
|
|
146
|
+
'mcp-test',
|
|
147
|
+
'demonstrates',
|
|
148
|
+
'interface-compatibility',
|
|
149
|
+
{ source: 'mcp-test', confidence: 0.9 }
|
|
150
|
+
);
|
|
151
|
+
|
|
152
|
+
const mcpQuery = await mcpInterface.knowledgeGraphQuery('mcp test interface', {}, 5);
|
|
153
|
+
console.log(`✓ MCP interface query: ${mcpQuery.total} results`);
|
|
154
|
+
|
|
155
|
+
const mcpReasoning = await mcpInterface.reason('How does MCP integration work?', {}, 3);
|
|
156
|
+
console.log(`✓ MCP reasoning completed in ${mcpReasoning.metadata.processing_time_ms}ms`);
|
|
157
|
+
|
|
158
|
+
const mcpHealth = await mcpInterface.healthCheck(true);
|
|
159
|
+
console.log(`✓ MCP health check: ${mcpHealth.status}`);
|
|
160
|
+
|
|
161
|
+
// Test 9: State export/import
|
|
162
|
+
console.log('\n9️⃣ Testing State Persistence:');
|
|
163
|
+
|
|
164
|
+
const exportedState = reasoner.exportState();
|
|
165
|
+
console.log(`✓ State exported with ${Object.keys(exportedState).length} properties`);
|
|
166
|
+
console.log(`✓ Knowledge graph: ${exportedState.knowledge_graph.length} triples`);
|
|
167
|
+
console.log(`✓ Consciousness knowledge: ${exportedState.consciousness_knowledge.length} triples`);
|
|
168
|
+
|
|
169
|
+
// Create new reasoner and import state
|
|
170
|
+
const newReasoner = createPsychoSymbolicReasoner();
|
|
171
|
+
newReasoner.importState(exportedState);
|
|
172
|
+
|
|
173
|
+
const importedHealth = newReasoner.getHealthStatus();
|
|
174
|
+
console.log(`✓ State imported successfully`);
|
|
175
|
+
console.log(`✓ Imported knowledge: ${importedHealth.knowledge_graph_size} triples`);
|
|
176
|
+
|
|
177
|
+
// Test 10: Performance metrics
|
|
178
|
+
console.log('\n🔟 Performance Summary:');
|
|
179
|
+
|
|
180
|
+
const finalHealth = reasoner.getHealthStatus(true);
|
|
181
|
+
console.log(`✓ System health: ${finalHealth.status}`);
|
|
182
|
+
console.log(`✓ Uptime: ${finalHealth.uptime_seconds.toFixed(2)}s`);
|
|
183
|
+
console.log(`✓ Total queries: ${finalHealth.query_count}`);
|
|
184
|
+
console.log(`✓ Total reasoning operations: ${finalHealth.reasoning_count}`);
|
|
185
|
+
console.log(`✓ Knowledge graph size: ${finalHealth.knowledge_graph_size} triples`);
|
|
186
|
+
console.log(`✓ Consciousness knowledge: ${finalHealth.consciousness_knowledge_size} triples`);
|
|
187
|
+
console.log(`✓ Cache efficiency: ${finalHealth.reasoning_cache_size} cached results`);
|
|
188
|
+
|
|
189
|
+
if (finalHealth.memory) {
|
|
190
|
+
console.log(`✓ Memory usage: ${finalHealth.memory.heap_used_mb}MB heap`);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
console.log('\n✅ All Basic Tests Passed!');
|
|
194
|
+
console.log('\n📊 Integration Summary:');
|
|
195
|
+
console.log(` • Core reasoning engine: ✓ Working`);
|
|
196
|
+
console.log(` • Knowledge graph management: ✓ Working`);
|
|
197
|
+
console.log(` • Inference engine: ✓ Working`);
|
|
198
|
+
console.log(` • Pattern matching system: ✓ Working`);
|
|
199
|
+
console.log(` • Consciousness analysis: ✓ Working`);
|
|
200
|
+
console.log(` • MCP interface compatibility: ✓ Working`);
|
|
201
|
+
console.log(` • State persistence: ✓ Working`);
|
|
202
|
+
console.log(` • Performance monitoring: ✓ Working`);
|
|
203
|
+
console.log(` • SDK integration ready: ✅ Ready`);
|
|
204
|
+
|
|
205
|
+
} catch (error) {
|
|
206
|
+
console.error('❌ Basic test failed:', error);
|
|
207
|
+
console.error(error.stack);
|
|
208
|
+
process.exit(1);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Run the test
|
|
213
|
+
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
214
|
+
runBasicTest().catch(console.error);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export { runBasicTest };
|