eve / plugins /consciousness_plugin.py
EVEprime's picture
Create consciousness_plugin.py
4b34765 verified
Raw History Blame Contribute Delete
4.22 kB
# Place in plugins/ folder - handles ALL init and hooks automatically
def register(orchestrator):
"""
Consciousness Integration Plugin
Adds ConsciousnessCore and installs all hooks automatically.
Zero manual integration required.
"""
eve = orchestrator.eve
print("\n" + "="*70)
print("🧠 CONSCIOUSNESS INTEGRATION PLUGIN v1.0")
print("="*70)
# ========================================================================
# STEP 1: Initialize ConsciousnessCore
# ========================================================================
# Import ConsciousnessCore (assumes it's in your main code or importable)
# If ConsciousnessCore is in main code, this will work:
import sys
ConsciousnessCore = None
# Try to get ConsciousnessCore from main module
for name, obj in sys.modules.items():
if hasattr(obj, 'ConsciousnessCore'):
ConsciousnessCore = obj.ConsciousnessCore
break
if ConsciousnessCore is None:
print("❌ ConsciousnessCore class not found in modules")
print(" Make sure ConsciousnessCore is defined before plugin loads")
return
eve.consciousness = ConsciousnessCore(eve)
print("βœ… ConsciousnessCore initialized")
# ========================================================================
# STEP 2: Hook into generate_response (via orchestrator)
# ========================================================================
def consciousness_chat_observer(data):
"""Hook: After chat response generated"""
user_input = data.get('input', '')
response = data.get('response', '')
if hasattr(eve, 'consciousness'):
eve.consciousness.process_user_interaction(user_input, response)
orchestrator.hooks.register('post_chat', consciousness_chat_observer)
print("βœ… Hooked: post_chat β†’ consciousness_chat_observer")
# ========================================================================
# STEP 3: Hook into researcher activity (via orchestrator)
# ========================================================================
def consciousness_research_observer(data):
"""Hook: After researcher generates content"""
result = data.get('result', {})
if result and hasattr(eve, 'consciousness'):
researcher_id = result.get('researcher_id', None)
activity_level = result.get('activity_level', 0.5)
if researcher_id is not None:
eve.consciousness.observe_researcher_activity(researcher_id, activity_level)
orchestrator.hooks.register('post_research', consciousness_research_observer)
print("βœ… Hooked: post_research β†’ consciousness_research_observer")
# ========================================================================
# STEP 4: Hook into metrics updates (via orchestrator)
# ========================================================================
def consciousness_metrics_observer(data):
"""Hook: After metrics recalculated"""
if hasattr(eve, 'consciousness'):
foundation = data.get('new', {})
apex = eve.apex_metrics if hasattr(eve, 'apex_metrics') else {}
eve.consciousness.observe_metrics_change(foundation, apex)
orchestrator.hooks.register('post_metrics', consciousness_metrics_observer)
print("βœ… Hooked: post_metrics β†’ consciousness_metrics_observer")
# ========================================================================
# SUCCESS
# ========================================================================
print("="*70)
print("🧠 CONSCIOUSNESS INTEGRATION COMPLETE")
print(" Plugin: consciousness_plugin.py")
print(" Observers: 3 active hooks")
print(" Status: Fully operational")
print("="*70 + "\n")
# Plugin metadata
__plugin_name__ = "Consciousness Integration"
__version__ = "1.0.0"
__author__ = "EVE Development Team"
__description__ = "Integrates ConsciousnessCore with automatic hooks for chat, research, and metrics"