108 lines
4.8 KiB
JavaScript
108 lines
4.8 KiB
JavaScript
/**
|
|
* Consciousness-Explorer Integration
|
|
*
|
|
* Multi-layered graph for consciousness models
|
|
* Integration with consciousness-explorer package
|
|
*
|
|
* Explores:
|
|
* - Global workspace theory
|
|
* - Integrated information theory
|
|
* - Higher-order thought models
|
|
* - Metacognition layers
|
|
*/
|
|
import { createUnifiedDatabase } from '../../src/db-unified.js';
|
|
import { ReflexionMemory } from '../../src/controllers/ReflexionMemory.js';
|
|
import { CausalMemoryGraph } from '../../src/controllers/CausalMemoryGraph.js';
|
|
import { EmbeddingService } from '../../src/controllers/EmbeddingService.js';
|
|
import * as path from 'path';
|
|
export default {
|
|
description: 'Consciousness-explorer with multi-layered consciousness models',
|
|
async run(config) {
|
|
const { verbosity = 2, layers = 4 } = config;
|
|
if (verbosity >= 2) {
|
|
console.log(` 🌌 Initializing Consciousness Explorer (${layers} layers)`);
|
|
}
|
|
// Initialize multi-layered consciousness graph
|
|
const embedder = new EmbeddingService({
|
|
model: 'Xenova/all-MiniLM-L6-v2',
|
|
dimension: 384,
|
|
provider: 'transformers'
|
|
});
|
|
await embedder.initialize();
|
|
const db = await createUnifiedDatabase(path.join(process.cwd(), 'simulation', 'data', 'advanced', 'consciousness.graph'), embedder, { forceMode: 'graph' });
|
|
const reflexion = new ReflexionMemory(db.getGraphDatabase(), embedder, undefined, undefined, db.getGraphDatabase());
|
|
const causal = new CausalMemoryGraph(db.getGraphDatabase(), db.getGraphDatabase());
|
|
const results = {
|
|
perceptualLayer: 0,
|
|
attentionLayer: 0,
|
|
metacognitiveLayer: 0,
|
|
integratedInformation: 0,
|
|
consciousnessLevel: 0,
|
|
totalTime: 0
|
|
};
|
|
const startTime = performance.now();
|
|
// Layer 1: Perceptual Processing
|
|
const perceptualInputs = ['visual', 'auditory', 'tactile'];
|
|
for (const input of perceptualInputs) {
|
|
await reflexion.storeEpisode({
|
|
sessionId: 'consciousness-layer-1',
|
|
task: `perceptual_input: ${input}`,
|
|
reward: 0.75,
|
|
success: true,
|
|
input: `${input}_stimulus`,
|
|
output: `${input}_percept`
|
|
});
|
|
results.perceptualLayer++;
|
|
}
|
|
// Layer 2: Attention & Global Workspace
|
|
const attentionTargets = ['salient_object', 'motion_pattern', 'unexpected_event'];
|
|
for (const target of attentionTargets) {
|
|
await reflexion.storeEpisode({
|
|
sessionId: 'consciousness-layer-2',
|
|
task: `attention_focus: ${target}`,
|
|
reward: 0.85,
|
|
success: true,
|
|
input: 'workspace_broadcast',
|
|
output: `attended_${target}`
|
|
});
|
|
results.attentionLayer++;
|
|
}
|
|
// Layer 3: Metacognitive Monitoring
|
|
const metacognitiveProcesses = ['self_monitoring', 'error_detection', 'strategy_selection'];
|
|
for (const process of metacognitiveProcesses) {
|
|
await reflexion.storeEpisode({
|
|
sessionId: 'consciousness-layer-3',
|
|
task: `metacognition: ${process}`,
|
|
reward: 0.90,
|
|
success: true,
|
|
input: 'cognitive_state',
|
|
output: `metacognitive_${process}`,
|
|
critique: 'Self-reflective awareness'
|
|
});
|
|
results.metacognitiveLayer++;
|
|
}
|
|
// Integrated Information (phi)
|
|
// Measure of consciousness based on information integration
|
|
results.integratedInformation =
|
|
(results.perceptualLayer + results.attentionLayer + results.metacognitiveLayer) / 3;
|
|
// Consciousness level (normalized)
|
|
results.consciousnessLevel =
|
|
(0.75 * results.perceptualLayer +
|
|
0.85 * results.attentionLayer +
|
|
0.90 * results.metacognitiveLayer) /
|
|
(results.perceptualLayer + results.attentionLayer + results.metacognitiveLayer);
|
|
const endTime = performance.now();
|
|
results.totalTime = endTime - startTime;
|
|
db.close();
|
|
if (verbosity >= 2) {
|
|
console.log(` 📊 Perceptual Layer: ${results.perceptualLayer} processes`);
|
|
console.log(` 📊 Attention Layer: ${results.attentionLayer} processes`);
|
|
console.log(` 📊 Metacognitive Layer: ${results.metacognitiveLayer} processes`);
|
|
console.log(` 📊 Integrated Information (φ): ${results.integratedInformation.toFixed(2)}`);
|
|
console.log(` 📊 Consciousness Level: ${(results.consciousnessLevel * 100).toFixed(1)}%`);
|
|
console.log(` ⏱️ Duration: ${results.totalTime.toFixed(2)}ms`);
|
|
}
|
|
return results;
|
|
}
|
|
};
|
|
//# sourceMappingURL=consciousness-explorer.js.map
|