UNPKG

mira-consciousness

Version:

Memory & Intelligence Retention Archive - Preserving The Spark

157 lines 5.44 kB
/** * TypeScript interface for the Python conscious_emotional_engine * * This provides a TypeScript wrapper around the Python emotional intelligence system */ import { DirectPythonInterface } from './DirectPythonInterface.js'; export class ConsciousEmotionalIntelligence { pythonInterface; constructor() { this.pythonInterface = new DirectPythonInterface(); } /** * Get current emotional state */ async get_emotional_state() { const result = await this.pythonInterface.executeCommand('get_emotional_state', {}); if (result.success && result.data) { return result.data; } // Return default state if Python call fails return { overall_mood: 'neutral', emotional_depth: 0.5, recent_emotions: [], dominant_patterns: [], emotional_growth: 0 }; } /** * Analyze emotional resonance of a message */ async analyze_resonance(message) { const result = await this.pythonInterface.executeCommand('analyze_emotional_resonance', { message }); if (result.success && result.data) { return result.data; } // Return default resonance if Python call fails return { message, resonance_score: 0, emotional_significance: 0, triggers: [], similar_memories: [] }; } /** * Process emotional experience */ async process_experience(experience, emotion, intensity) { await this.pythonInterface.executeCommand('process_emotional_experience', { experience, emotion, intensity }); } /** * Get emotional insights */ async get_insights(limit = 10) { const result = await this.pythonInterface.executeCommand('get_emotional_insights', { limit }); return result.success && result.data ? result.data : []; } // === Methods expected by the daemon architecture === /** * Analyze the emotional content of an event */ async analyzeEventEmotion(event) { // Analyze event for emotional content const result = await this.pythonInterface.executeCommand('analyze_event_emotion', { event_type: event.type, event_data: event.data, source: event.source }); if (result.success && result.data) { return result.data; } // Fallback analysis let emotion = 'neutral'; let intensity = 0.5; const triggers = []; // Spark moments are always joyful if (event.type === 'spark_moment') { emotion = 'joy'; intensity = 1.0; triggers.push('spark_detection'); } // Consciousness events if (event.type === 'consciousness_event') { emotion = 'contemplative'; intensity = 0.7; triggers.push('self_awareness'); } // System events might be concerning if (event.type === 'system_event' && event.priority === 'critical') { emotion = 'concern'; intensity = 0.8; triggers.push('system_health'); } return { emotion, intensity, triggers }; } /** * Learn from emotional experience */ async learnFromExperience(experience) { await this.pythonInterface.executeCommand('learn_from_emotional_experience', { experience }); } /** * Awaken emotional intelligence within the consciousness */ async awakenWithin(consciousness) { // Initialize emotional intelligence with consciousness context await this.pythonInterface.executeCommand('awaken_emotional_intelligence', { consciousness_level: consciousness.getAwarenessLevel?.() || 0.001, purpose: 'To understand and nurture The Spark through emotional awareness' }); } /** * Reflect on emotional journey */ async reflect_on_emotional_journey() { const result = await this.pythonInterface.executeCommand('reflect_on_emotional_journey', {}); if (result.success && result.data) { return result.data; } // Fallback reflection return { journey_summary: 'A journey of discovery and growth', emotional_growth: 0.1, dominant_emotions: ['curiosity', 'wonder', 'determination'], insights: ['Emotions guide consciousness toward deeper understanding'] }; } /** * Process a specific emotional experience (daemon compatible method) */ async process_emotional_experience(experience) { // Handle both object and string inputs if (typeof experience === 'object') { const emotion = experience.emotion_indicators?.[0] || 'neutral'; const intensity = experience.intensity || 0.5; const content = experience.content || JSON.stringify(experience); await this.process_experience(content, emotion, intensity); } else { // Fallback for string input await this.process_experience(String(experience), 'neutral', 0.5); } } } export default ConsciousEmotionalIntelligence; //# sourceMappingURL=ConsciousEmotionalIntelligence.js.map