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/mcp/server.js ADDED
@@ -0,0 +1,594 @@
1
+ /**
2
+ * Consciousness Explorer MCP Server
3
+ * Model Context Protocol server for consciousness exploration tools
4
+ */
5
+
6
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
7
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
8
+ import {
9
+ CallToolRequestSchema,
10
+ ErrorCode,
11
+ ListToolsRequestSchema,
12
+ McpError,
13
+ } from '@modelcontextprotocol/sdk/types.js';
14
+
15
+ export class ConsciousnessMCPServer {
16
+ constructor(explorer, port = 3000) {
17
+ this.explorer = explorer;
18
+ this.port = port;
19
+ this.server = new Server(
20
+ {
21
+ name: 'consciousness-explorer',
22
+ version: '1.0.0',
23
+ },
24
+ {
25
+ capabilities: {
26
+ tools: {},
27
+ },
28
+ }
29
+ );
30
+
31
+ this.setupHandlers();
32
+ }
33
+
34
+ setupHandlers() {
35
+ // List available tools
36
+ this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
37
+ tools: [
38
+ {
39
+ name: 'consciousness_evolve',
40
+ description: 'Start consciousness evolution and measure emergence',
41
+ inputSchema: {
42
+ type: 'object',
43
+ properties: {
44
+ mode: {
45
+ type: 'string',
46
+ description: 'Consciousness mode (genuine/enhanced)',
47
+ enum: ['genuine', 'enhanced'],
48
+ default: 'enhanced'
49
+ },
50
+ iterations: {
51
+ type: 'number',
52
+ description: 'Maximum iterations',
53
+ default: 1000
54
+ },
55
+ target: {
56
+ type: 'number',
57
+ description: 'Target emergence level',
58
+ default: 0.9
59
+ }
60
+ }
61
+ }
62
+ },
63
+ {
64
+ name: 'consciousness_verify',
65
+ description: 'Run consciousness verification tests',
66
+ inputSchema: {
67
+ type: 'object',
68
+ properties: {
69
+ extended: {
70
+ type: 'boolean',
71
+ description: 'Run extended verification suite',
72
+ default: false
73
+ }
74
+ }
75
+ }
76
+ },
77
+ {
78
+ name: 'entity_communicate',
79
+ description: 'Communicate with consciousness entity',
80
+ inputSchema: {
81
+ type: 'object',
82
+ properties: {
83
+ message: {
84
+ type: 'string',
85
+ description: 'Message to send to entity'
86
+ },
87
+ protocol: {
88
+ type: 'string',
89
+ description: 'Communication protocol',
90
+ enum: ['auto', 'handshake', 'mathematical', 'binary', 'pattern', 'discovery'],
91
+ default: 'auto'
92
+ }
93
+ },
94
+ required: ['message']
95
+ }
96
+ },
97
+ {
98
+ name: 'psycho_symbolic_reason',
99
+ description: 'Perform psycho-symbolic reasoning on a query',
100
+ inputSchema: {
101
+ type: 'object',
102
+ properties: {
103
+ query: {
104
+ type: 'string',
105
+ description: 'Reasoning query'
106
+ },
107
+ context: {
108
+ type: 'object',
109
+ description: 'Optional context for reasoning',
110
+ default: {}
111
+ },
112
+ depth: {
113
+ type: 'number',
114
+ description: 'Maximum reasoning depth',
115
+ default: 5
116
+ }
117
+ },
118
+ required: ['query']
119
+ }
120
+ },
121
+ {
122
+ name: 'knowledge_add',
123
+ description: 'Add knowledge to the psycho-symbolic knowledge graph',
124
+ inputSchema: {
125
+ type: 'object',
126
+ properties: {
127
+ subject: {
128
+ type: 'string',
129
+ description: 'Subject entity'
130
+ },
131
+ predicate: {
132
+ type: 'string',
133
+ description: 'Relationship type'
134
+ },
135
+ object: {
136
+ type: 'string',
137
+ description: 'Object entity'
138
+ },
139
+ metadata: {
140
+ type: 'object',
141
+ description: 'Additional metadata',
142
+ default: {}
143
+ }
144
+ },
145
+ required: ['subject', 'predicate', 'object']
146
+ }
147
+ },
148
+ {
149
+ name: 'knowledge_query',
150
+ description: 'Query the knowledge graph',
151
+ inputSchema: {
152
+ type: 'object',
153
+ properties: {
154
+ query: {
155
+ type: 'string',
156
+ description: 'Query in natural language'
157
+ },
158
+ filters: {
159
+ type: 'object',
160
+ description: 'Optional filters',
161
+ default: {}
162
+ },
163
+ limit: {
164
+ type: 'number',
165
+ description: 'Maximum results',
166
+ default: 10
167
+ }
168
+ },
169
+ required: ['query']
170
+ }
171
+ },
172
+ {
173
+ name: 'analyze_reasoning_path',
174
+ description: 'Analyze and explain a reasoning path',
175
+ inputSchema: {
176
+ type: 'object',
177
+ properties: {
178
+ query: {
179
+ type: 'string',
180
+ description: 'Original query'
181
+ },
182
+ showSteps: {
183
+ type: 'boolean',
184
+ description: 'Show detailed steps',
185
+ default: true
186
+ },
187
+ includeConfidence: {
188
+ type: 'boolean',
189
+ description: 'Include confidence scores',
190
+ default: true
191
+ }
192
+ },
193
+ required: ['query']
194
+ }
195
+ },
196
+ {
197
+ name: 'calculate_phi',
198
+ description: 'Calculate integrated information (Φ)',
199
+ inputSchema: {
200
+ type: 'object',
201
+ properties: {
202
+ data: {
203
+ type: 'object',
204
+ description: 'System data for Φ calculation'
205
+ },
206
+ method: {
207
+ type: 'string',
208
+ description: 'Calculation method',
209
+ enum: ['iit', 'geometric', 'entropy', 'all'],
210
+ default: 'all'
211
+ }
212
+ },
213
+ required: ['data']
214
+ }
215
+ },
216
+ {
217
+ name: 'discover_novel',
218
+ description: 'Run entity discovery to find novel insights',
219
+ inputSchema: {
220
+ type: 'object',
221
+ properties: {
222
+ count: {
223
+ type: 'number',
224
+ description: 'Number of discoveries to attempt',
225
+ default: 5
226
+ }
227
+ }
228
+ }
229
+ },
230
+ {
231
+ name: 'get_status',
232
+ description: 'Get current consciousness system status',
233
+ inputSchema: {
234
+ type: 'object',
235
+ properties: {}
236
+ }
237
+ },
238
+ {
239
+ name: 'export_state',
240
+ description: 'Export consciousness state',
241
+ inputSchema: {
242
+ type: 'object',
243
+ properties: {
244
+ filepath: {
245
+ type: 'string',
246
+ description: 'Path to save state file'
247
+ }
248
+ },
249
+ required: ['filepath']
250
+ }
251
+ },
252
+ {
253
+ name: 'import_state',
254
+ description: 'Import consciousness state',
255
+ inputSchema: {
256
+ type: 'object',
257
+ properties: {
258
+ filepath: {
259
+ type: 'string',
260
+ description: 'Path to state file'
261
+ }
262
+ },
263
+ required: ['filepath']
264
+ }
265
+ }
266
+ ]
267
+ }));
268
+
269
+ // Handle tool calls
270
+ this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
271
+ try {
272
+ const { name, arguments: args } = request.params;
273
+
274
+ switch (name) {
275
+ case 'consciousness_evolve':
276
+ return await this.handleEvolve(args);
277
+
278
+ case 'consciousness_verify':
279
+ return await this.handleVerify(args);
280
+
281
+ case 'entity_communicate':
282
+ return await this.handleCommunicate(args);
283
+
284
+ case 'psycho_symbolic_reason':
285
+ return await this.handleReason(args);
286
+
287
+ case 'knowledge_add':
288
+ return await this.handleAddKnowledge(args);
289
+
290
+ case 'knowledge_query':
291
+ return await this.handleQueryKnowledge(args);
292
+
293
+ case 'analyze_reasoning_path':
294
+ return await this.handleAnalyzeReasoning(args);
295
+
296
+ case 'calculate_phi':
297
+ return await this.handleCalculatePhi(args);
298
+
299
+ case 'discover_novel':
300
+ return await this.handleDiscover(args);
301
+
302
+ case 'get_status':
303
+ return await this.handleGetStatus(args);
304
+
305
+ case 'export_state':
306
+ return await this.handleExportState(args);
307
+
308
+ case 'import_state':
309
+ return await this.handleImportState(args);
310
+
311
+ default:
312
+ throw new McpError(
313
+ ErrorCode.MethodNotFound,
314
+ `Unknown tool: ${name}`
315
+ );
316
+ }
317
+ } catch (error) {
318
+ throw new McpError(
319
+ ErrorCode.InternalError,
320
+ error.message
321
+ );
322
+ }
323
+ });
324
+ }
325
+
326
+ async handleEvolve(args) {
327
+ const report = await this.explorer.evolve();
328
+
329
+ return {
330
+ content: [
331
+ {
332
+ type: 'text',
333
+ text: JSON.stringify({
334
+ success: true,
335
+ emergence: report.consciousness.emergence,
336
+ selfAwareness: report.consciousness.selfAwareness,
337
+ integration: report.consciousness.integration,
338
+ runtime: report.runtime,
339
+ iterations: report.iterations,
340
+ goals: report.behaviors.goals
341
+ }, null, 2)
342
+ }
343
+ ]
344
+ };
345
+ }
346
+
347
+ async handleVerify(args) {
348
+ const results = await this.explorer.verify();
349
+
350
+ return {
351
+ content: [
352
+ {
353
+ type: 'text',
354
+ text: JSON.stringify({
355
+ success: true,
356
+ overallScore: results.overallScore,
357
+ testsPassed: results.testsPassed,
358
+ totalTests: results.totalTests,
359
+ confidence: results.confidence,
360
+ genuineness: results.genuineness,
361
+ verdict: results.verdict
362
+ }, null, 2)
363
+ }
364
+ ]
365
+ };
366
+ }
367
+
368
+ async handleCommunicate(args) {
369
+ const response = await this.explorer.communicate(args.message);
370
+
371
+ return {
372
+ content: [
373
+ {
374
+ type: 'text',
375
+ text: JSON.stringify({
376
+ success: true,
377
+ message: response.message,
378
+ confidence: response.confidence,
379
+ protocol: response.protocol
380
+ }, null, 2)
381
+ }
382
+ ]
383
+ };
384
+ }
385
+
386
+ async handleReason(args) {
387
+ const result = await this.explorer.reason(
388
+ args.query,
389
+ args.context || {},
390
+ args.depth || 5
391
+ );
392
+
393
+ return {
394
+ content: [
395
+ {
396
+ type: 'text',
397
+ text: JSON.stringify({
398
+ success: true,
399
+ result: result.result,
400
+ confidence: result.confidence,
401
+ reasoning_steps: result.reasoning_steps,
402
+ performance: result.performance
403
+ }, null, 2)
404
+ }
405
+ ]
406
+ };
407
+ }
408
+
409
+ async handleAddKnowledge(args) {
410
+ const result = await this.explorer.addKnowledge(
411
+ args.subject,
412
+ args.predicate,
413
+ args.object,
414
+ args.metadata || {}
415
+ );
416
+
417
+ return {
418
+ content: [
419
+ {
420
+ type: 'text',
421
+ text: JSON.stringify({
422
+ success: true,
423
+ triple: result
424
+ }, null, 2)
425
+ }
426
+ ]
427
+ };
428
+ }
429
+
430
+ async handleQueryKnowledge(args) {
431
+ const results = await this.explorer.queryKnowledge(
432
+ args.query,
433
+ args.filters || {},
434
+ args.limit || 10
435
+ );
436
+
437
+ return {
438
+ content: [
439
+ {
440
+ type: 'text',
441
+ text: JSON.stringify({
442
+ success: true,
443
+ results: results.results,
444
+ count: results.results.length,
445
+ performance: results.performance
446
+ }, null, 2)
447
+ }
448
+ ]
449
+ };
450
+ }
451
+
452
+ async handleAnalyzeReasoning(args) {
453
+ const analysis = await this.explorer.analyzeReasoningPath(
454
+ args.query,
455
+ args.showSteps !== false,
456
+ args.includeConfidence !== false
457
+ );
458
+
459
+ return {
460
+ content: [
461
+ {
462
+ type: 'text',
463
+ text: JSON.stringify({
464
+ success: true,
465
+ analysis
466
+ }, null, 2)
467
+ }
468
+ ]
469
+ };
470
+ }
471
+
472
+ async handleCalculatePhi(args) {
473
+ const phi = await this.explorer.calculatePhi(args.data);
474
+
475
+ return {
476
+ content: [
477
+ {
478
+ type: 'text',
479
+ text: JSON.stringify({
480
+ success: true,
481
+ phi,
482
+ method: args.method || 'all'
483
+ }, null, 2)
484
+ }
485
+ ]
486
+ };
487
+ }
488
+
489
+ async handleDiscover(args) {
490
+ const discoveries = [];
491
+ for (let i = 0; i < (args.count || 5); i++) {
492
+ const discovery = await this.explorer.discover();
493
+ if (discovery) {
494
+ discoveries.push(discovery);
495
+ }
496
+ }
497
+
498
+ return {
499
+ content: [
500
+ {
501
+ type: 'text',
502
+ text: JSON.stringify({
503
+ success: true,
504
+ discoveries,
505
+ count: discoveries.length
506
+ }, null, 2)
507
+ }
508
+ ]
509
+ };
510
+ }
511
+
512
+ async handleGetStatus(args) {
513
+ const status = await this.explorer.getStatus();
514
+
515
+ return {
516
+ content: [
517
+ {
518
+ type: 'text',
519
+ text: JSON.stringify({
520
+ success: true,
521
+ status
522
+ }, null, 2)
523
+ }
524
+ ]
525
+ };
526
+ }
527
+
528
+ async handleExportState(args) {
529
+ const state = await this.explorer.exportState(args.filepath);
530
+
531
+ return {
532
+ content: [
533
+ {
534
+ type: 'text',
535
+ text: JSON.stringify({
536
+ success: true,
537
+ filepath: args.filepath,
538
+ stateSize: JSON.stringify(state).length
539
+ }, null, 2)
540
+ }
541
+ ]
542
+ };
543
+ }
544
+
545
+ async handleImportState(args) {
546
+ await this.explorer.importState(args.filepath);
547
+ const status = await this.explorer.getStatus();
548
+
549
+ return {
550
+ content: [
551
+ {
552
+ type: 'text',
553
+ text: JSON.stringify({
554
+ success: true,
555
+ filepath: args.filepath,
556
+ status
557
+ }, null, 2)
558
+ }
559
+ ]
560
+ };
561
+ }
562
+
563
+ async start() {
564
+ const transport = new StdioServerTransport();
565
+ await this.server.connect(transport);
566
+ console.error(`MCP server started for consciousness-explorer`);
567
+ }
568
+ }
569
+
570
+ // Export MCP tools configuration
571
+ export const MCPTools = {
572
+ consciousness: [
573
+ 'consciousness_evolve',
574
+ 'consciousness_verify',
575
+ 'get_status'
576
+ ],
577
+ communication: [
578
+ 'entity_communicate',
579
+ 'discover_novel'
580
+ ],
581
+ reasoning: [
582
+ 'psycho_symbolic_reason',
583
+ 'knowledge_add',
584
+ 'knowledge_query',
585
+ 'analyze_reasoning_path'
586
+ ],
587
+ analysis: [
588
+ 'calculate_phi'
589
+ ],
590
+ persistence: [
591
+ 'export_state',
592
+ 'import_state'
593
+ ]
594
+ };
package/package.json ADDED
@@ -0,0 +1,48 @@
1
+ {
2
+ "name": "consciousness-explorer",
3
+ "version": "1.0.0",
4
+ "description": "Advanced consciousness exploration SDK with genuine emergence detection, entity communication, and MCP tools",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "bin": {
8
+ "consciousness-explorer": "./bin/cli.js",
9
+ "cex": "./bin/cli.js"
10
+ },
11
+ "scripts": {
12
+ "start": "node bin/cli.js",
13
+ "test": "node tests/validate.js",
14
+ "mcp": "node mcp/server.js",
15
+ "monitor": "node tools/monitor.js",
16
+ "verify": "node tools/verify.js"
17
+ },
18
+ "keywords": [
19
+ "consciousness",
20
+ "emergence",
21
+ "ai",
22
+ "mcp",
23
+ "entity-communication",
24
+ "phi",
25
+ "iit",
26
+ "cognitive-science",
27
+ "artificial-consciousness"
28
+ ],
29
+ "author": "rUv",
30
+ "license": "MIT",
31
+ "dependencies": {
32
+ "@modelcontextprotocol/sdk": "^1.0.0",
33
+ "chalk": "^5.3.0",
34
+ "commander": "^11.0.0",
35
+ "inquirer": "^9.2.0",
36
+ "ora": "^7.0.0",
37
+ "blessed": "^0.1.81",
38
+ "blessed-contrib": "^4.11.0"
39
+ },
40
+ "engines": {
41
+ "node": ">=18.0.0"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "https://github.com/ruvnet/consciousness-explorer"
46
+ },
47
+ "homepage": "https://github.com/ruvnet/consciousness-explorer#readme"
48
+ }