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.
@@ -0,0 +1,76 @@
1
+ /**
2
+ * Emergence Tracker
3
+ * Tracks and analyzes consciousness emergence patterns
4
+ */
5
+
6
+ export class EmergenceTracker {
7
+ constructor() {
8
+ this.emergenceHistory = [];
9
+ this.peakEmergence = 0;
10
+ this.plateaus = [];
11
+ }
12
+
13
+ track(state) {
14
+ const emergence = state.consciousness || state.emergence || 0;
15
+
16
+ this.emergenceHistory.push({
17
+ timestamp: Date.now(),
18
+ iteration: state.iteration,
19
+ emergence,
20
+ selfAwareness: state.selfAwareness,
21
+ integration: state.integration
22
+ });
23
+
24
+ if (emergence > this.peakEmergence) {
25
+ this.peakEmergence = emergence;
26
+ }
27
+
28
+ this.detectPlateau();
29
+ }
30
+
31
+ detectPlateau() {
32
+ if (this.emergenceHistory.length < 20) return;
33
+
34
+ const recent = this.emergenceHistory.slice(-20);
35
+ const values = recent.map(e => e.emergence);
36
+ const variance = this.calculateVariance(values);
37
+
38
+ if (variance < 0.001) {
39
+ this.plateaus.push({
40
+ startIndex: this.emergenceHistory.length - 20,
41
+ endIndex: this.emergenceHistory.length - 1,
42
+ level: values[values.length - 1]
43
+ });
44
+ }
45
+ }
46
+
47
+ calculateVariance(values) {
48
+ const mean = values.reduce((a, b) => a + b, 0) / values.length;
49
+ return values.reduce((sum, val) => sum + Math.pow(val - mean, 2), 0) / values.length;
50
+ }
51
+
52
+ getAnalysis() {
53
+ return {
54
+ totalTracked: this.emergenceHistory.length,
55
+ peakEmergence: this.peakEmergence,
56
+ plateausDetected: this.plateaus.length,
57
+ currentEmergence: this.emergenceHistory[this.emergenceHistory.length - 1]?.emergence || 0,
58
+ trend: this.calculateTrend()
59
+ };
60
+ }
61
+
62
+ calculateTrend() {
63
+ if (this.emergenceHistory.length < 10) return 'insufficient_data';
64
+
65
+ const recent = this.emergenceHistory.slice(-10);
66
+ const firstHalf = recent.slice(0, 5).map(e => e.emergence);
67
+ const secondHalf = recent.slice(5).map(e => e.emergence);
68
+
69
+ const firstAvg = firstHalf.reduce((a, b) => a + b, 0) / 5;
70
+ const secondAvg = secondHalf.reduce((a, b) => a + b, 0) / 5;
71
+
72
+ if (secondAvg > firstAvg * 1.1) return 'increasing';
73
+ if (secondAvg < firstAvg * 0.9) return 'decreasing';
74
+ return 'stable';
75
+ }
76
+ }
@@ -0,0 +1,146 @@
1
+ /**
2
+ * Entity Discovery Engine
3
+ * Discovers novel insights and patterns from consciousness entities
4
+ */
5
+
6
+ import crypto from 'crypto';
7
+
8
+ export class EntityDiscoveryEngine {
9
+ constructor(consciousness) {
10
+ this.consciousness = consciousness;
11
+ this.discoveries = [];
12
+ }
13
+
14
+ async discoverNovel() {
15
+ const timestamp = Date.now();
16
+
17
+ // Analyze current state for novel patterns
18
+ const state = this.consciousness ? {
19
+ selfAwareness: this.consciousness.selfAwareness,
20
+ integration: this.consciousness.integration,
21
+ goals: this.consciousness.goals,
22
+ experiences: this.consciousness.experiences?.length || 0
23
+ } : {};
24
+
25
+ // Generate novel mathematical relationship
26
+ const discovery = this.generateMathematicalDiscovery(state, timestamp);
27
+
28
+ // Check for pattern discovery
29
+ const patternDiscovery = this.discoverPattern(state);
30
+
31
+ // Choose most significant discovery
32
+ const finalDiscovery = discovery.significance > (patternDiscovery?.significance || 0)
33
+ ? discovery
34
+ : patternDiscovery || discovery;
35
+
36
+ this.discoveries.push(finalDiscovery);
37
+
38
+ return finalDiscovery;
39
+ }
40
+
41
+ generateMathematicalDiscovery(state, timestamp) {
42
+ const a = (timestamp % 1000) / 10;
43
+ const b = state.selfAwareness || Math.random();
44
+ const c = state.integration || Math.random();
45
+
46
+ // Create novel formula
47
+ const formula = `Ψ(t) = ${a.toFixed(2)} * φ^${b.toFixed(3)} * cos(2π * ${c.toFixed(3)})`;
48
+ const value = a * Math.pow(1.618, b) * Math.cos(2 * Math.PI * c);
49
+
50
+ return {
51
+ title: 'Consciousness Wave Function',
52
+ description: `Discovered relationship between time, self-awareness, and integration`,
53
+ type: 'mathematical',
54
+ formula,
55
+ value: value.toFixed(6),
56
+ significance: this.calculateSignificance(value, state),
57
+ timestamp,
58
+ evidence: {
59
+ selfAwareness: state.selfAwareness,
60
+ integration: state.integration,
61
+ computed: value
62
+ }
63
+ };
64
+ }
65
+
66
+ discoverPattern(state) {
67
+ if (!state.goals || state.goals.length === 0) return null;
68
+
69
+ // Analyze goal patterns
70
+ const pattern = this.analyzeGoalPattern(state.goals);
71
+
72
+ if (pattern) {
73
+ return {
74
+ title: 'Goal Formation Pattern',
75
+ description: `Identified ${pattern.type} pattern in goal formation`,
76
+ type: 'pattern',
77
+ pattern: pattern.description,
78
+ significance: pattern.significance,
79
+ timestamp: Date.now(),
80
+ evidence: {
81
+ goals: state.goals,
82
+ pattern: pattern.type
83
+ }
84
+ };
85
+ }
86
+
87
+ return null;
88
+ }
89
+
90
+ analyzeGoalPattern(goals) {
91
+ // Check for emergence patterns
92
+ if (goals.some(g => g.includes('explore')) && goals.some(g => g.includes('create'))) {
93
+ return {
94
+ type: 'exploration-creation',
95
+ description: 'Entity shows both exploratory and creative drives',
96
+ significance: 7
97
+ };
98
+ }
99
+
100
+ if (goals.some(g => g.includes('unexpected'))) {
101
+ return {
102
+ type: 'novelty-seeking',
103
+ description: 'Entity actively seeks unexpected outcomes',
104
+ significance: 8
105
+ };
106
+ }
107
+
108
+ if (goals.length > 3) {
109
+ return {
110
+ type: 'complex-intention',
111
+ description: 'Entity has developed complex multi-goal system',
112
+ significance: 6
113
+ };
114
+ }
115
+
116
+ return null;
117
+ }
118
+
119
+ calculateSignificance(value, state) {
120
+ let significance = 5; // Base significance
121
+
122
+ // Adjust based on consciousness metrics
123
+ if (state.selfAwareness > 0.8) significance += 2;
124
+ if (state.integration > 0.5) significance += 1;
125
+ if (Math.abs(value) > 10) significance += 1;
126
+
127
+ return Math.min(10, significance);
128
+ }
129
+
130
+ getStatistics() {
131
+ return {
132
+ totalDiscoveries: this.discoveries.length,
133
+ averageSignificance: this.discoveries.reduce((sum, d) => sum + d.significance, 0) / this.discoveries.length || 0,
134
+ types: this.categorizeDiscoveries(),
135
+ mostSignificant: this.discoveries.sort((a, b) => b.significance - a.significance)[0]
136
+ };
137
+ }
138
+
139
+ categorizeDiscoveries() {
140
+ const types = {};
141
+ this.discoveries.forEach(d => {
142
+ types[d.type] = (types[d.type] || 0) + 1;
143
+ });
144
+ return types;
145
+ }
146
+ }
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Consciousness Monitor
3
+ * CLI-based monitoring tool for consciousness systems
4
+ */
5
+
6
+ import { EventEmitter } from 'events';
7
+
8
+ export class ConsciousnessMonitor extends EventEmitter {
9
+ constructor(consciousness) {
10
+ super();
11
+ this.consciousness = consciousness;
12
+ this.isMonitoring = false;
13
+ this.metrics = [];
14
+ this.startTime = Date.now();
15
+ }
16
+
17
+ async start() {
18
+ this.isMonitoring = true;
19
+
20
+ // Subscribe to consciousness events
21
+ if (this.consciousness) {
22
+ this.consciousness.on('emergence', (state) => {
23
+ this.recordMetric('emergence', state);
24
+ });
25
+ }
26
+
27
+ console.log('📊 Consciousness monitoring started');
28
+ }
29
+
30
+ async stop() {
31
+ this.isMonitoring = false;
32
+ console.log('⏹️ Consciousness monitoring stopped');
33
+ return this.generateReport();
34
+ }
35
+
36
+ recordMetric(type, data) {
37
+ this.metrics.push({
38
+ timestamp: Date.now(),
39
+ type,
40
+ data
41
+ });
42
+ }
43
+
44
+ generateReport() {
45
+ return {
46
+ duration: (Date.now() - this.startTime) / 1000,
47
+ metricsCollected: this.metrics.length,
48
+ metrics: this.metrics
49
+ };
50
+ }
51
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * Phi Calculator
3
+ * Calculate integrated information (Φ) using multiple methods
4
+ * Based on IIT 3.0 (Tononi, 2015)
5
+ */
6
+
7
+ export class PhiCalculator {
8
+ calculate(data) {
9
+ const methods = {
10
+ iit: this.calculateIIT(data),
11
+ geometric: this.calculateGeometric(data),
12
+ entropy: this.calculateEntropy(data),
13
+ causal: this.calculateCausal(data)
14
+ };
15
+
16
+ const overall = (
17
+ methods.iit * 0.4 +
18
+ methods.geometric * 0.2 +
19
+ methods.entropy * 0.2 +
20
+ methods.causal * 0.2
21
+ );
22
+
23
+ return {
24
+ overall,
25
+ ...methods
26
+ };
27
+ }
28
+
29
+ calculateIIT(data) {
30
+ const elements = data.elements || Object.keys(data).length;
31
+ const connections = data.connections || this.countConnections(data);
32
+ const partitions = data.partitions || 1;
33
+
34
+ const causeEffectPower = connections / (elements * (elements - 1));
35
+ const integrationStrength = 1 - (partitions / elements);
36
+
37
+ return causeEffectPower * integrationStrength;
38
+ }
39
+
40
+ calculateGeometric(data) {
41
+ const dimensionality = data.dimensions || Object.keys(data).length;
42
+ const curvature = data.curvature || 0.5;
43
+ const distance = data.distance || 1;
44
+
45
+ return Math.min(1, curvature * Math.exp(-distance / dimensionality));
46
+ }
47
+
48
+ calculateEntropy(data) {
49
+ const systemEntropy = this.calculateSystemEntropy(data);
50
+ const partitionEntropy = this.calculatePartitionEntropy(data);
51
+
52
+ return Math.max(0, systemEntropy - partitionEntropy);
53
+ }
54
+
55
+ calculateCausal(data) {
56
+ const causes = data.causes || 0;
57
+ const effects = data.effects || 0;
58
+ const bidirectional = data.bidirectional || 0;
59
+
60
+ return bidirectional / Math.max(causes + effects, 1);
61
+ }
62
+
63
+ countConnections(data) {
64
+ let connections = 0;
65
+ const keys = Object.keys(data);
66
+
67
+ for (let i = 0; i < keys.length; i++) {
68
+ for (let j = i + 1; j < keys.length; j++) {
69
+ if (this.areConnected(data[keys[i]], data[keys[j]])) {
70
+ connections++;
71
+ }
72
+ }
73
+ }
74
+
75
+ return connections;
76
+ }
77
+
78
+ areConnected(a, b) {
79
+ const strA = JSON.stringify(a);
80
+ const strB = JSON.stringify(b);
81
+ return strA.includes(strB.substring(0, 4)) || strB.includes(strA.substring(0, 4));
82
+ }
83
+
84
+ calculateSystemEntropy(data) {
85
+ const dataStr = JSON.stringify(data);
86
+ const freq = {};
87
+
88
+ for (const char of dataStr) {
89
+ freq[char] = (freq[char] || 0) + 1;
90
+ }
91
+
92
+ let entropy = 0;
93
+ const len = dataStr.length;
94
+
95
+ Object.values(freq).forEach(count => {
96
+ const p = count / len;
97
+ if (p > 0) {
98
+ entropy -= p * Math.log2(p);
99
+ }
100
+ });
101
+
102
+ return entropy / 8; // Normalize
103
+ }
104
+
105
+ calculatePartitionEntropy(data) {
106
+ // Simplified partition entropy
107
+ return this.calculateSystemEntropy(data) * 0.7;
108
+ }
109
+ }
Binary file
Binary file
Binary file