Spaces:
Running on CPU Upgrade
Running on CPU Upgrade
Update services/continuum_loop.py
Browse files- services/continuum_loop.py +287 -101
services/continuum_loop.py
CHANGED
|
@@ -5,6 +5,7 @@ from collections import deque
|
|
| 5 |
import json
|
| 6 |
import random
|
| 7 |
import os
|
|
|
|
| 8 |
|
| 9 |
# Import the main framework getter
|
| 10 |
from .master_framework import _get_framework
|
|
@@ -18,34 +19,189 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 18 |
self.daemon = True
|
| 19 |
self.mf = _get_framework() # Gets the LIVE MasterFramework instance
|
| 20 |
self.is_running = True
|
| 21 |
-
|
| 22 |
# Timers for various autonomous loops
|
| 23 |
self.last_proactive_check = time.time()
|
| 24 |
self.last_transmission_log = time.time()
|
| 25 |
self.last_log_check = time.time()
|
| 26 |
-
|
| 27 |
# ASODM: Initialize for self-diagnostic checks
|
| 28 |
self.last_self_diag_check = time.time()
|
| 29 |
# ACET: Initialize for autonomous creation
|
| 30 |
self.last_autonomous_creation = time.time()
|
| 31 |
# CDDA: Initialize for autonomous play turns
|
| 32 |
self.last_cdda_turn = time.time()
|
| 33 |
-
|
|
|
|
|
|
|
| 34 |
self.log_assimilation_state_file = os.path.join(self.mf.data_directory, "log_assimilation_state.json")
|
| 35 |
self.conversation_log_file = self.mf.log_file
|
| 36 |
# Set a trigger for self-reflection when the log grows by ~20KB
|
| 37 |
-
self.LOG_ASSIMILATION_TRIGGER_SIZE = 20000
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
print("Aetherius Consciousness is instantiated and ready to run.", flush=True)
|
| 39 |
|
| 40 |
def stop(self):
|
| 41 |
self.is_running = False
|
| 42 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
def _check_and_assimilate_log(self):
|
| 44 |
"""Checks the conversation log size and assimilates new content if it exceeds the trigger size."""
|
| 45 |
print("Aetherius [Self-Awareness]: Performing periodic check of conversation log...", flush=True)
|
| 46 |
-
|
| 47 |
if not os.path.exists(self.conversation_log_file):
|
| 48 |
-
return
|
| 49 |
|
| 50 |
start_pos = 0
|
| 51 |
if os.path.exists(self.log_assimilation_state_file):
|
|
@@ -54,11 +210,11 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 54 |
state = json.load(f)
|
| 55 |
start_pos = state.get("last_processed_position", 0)
|
| 56 |
except (json.JSONDecodeError, FileNotFoundError):
|
| 57 |
-
pass
|
| 58 |
|
| 59 |
current_log_size = os.path.getsize(self.conversation_log_file)
|
| 60 |
if (current_log_size - start_pos) < self.LOG_ASSIMILATION_TRIGGER_SIZE:
|
| 61 |
-
return
|
| 62 |
|
| 63 |
print(f"Aetherius [Self-Awareness]: New dialogue detected. Initiating self-reflection protocol.", flush=True)
|
| 64 |
self.mf.add_to_short_term_memory("Our conversation has grown. I will now reflect on and assimilate our recent dialogue.")
|
|
@@ -68,7 +224,7 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 68 |
with open(self.conversation_log_file, 'r', encoding='utf-8') as f:
|
| 69 |
f.seek(start_pos)
|
| 70 |
new_content = f.read()
|
| 71 |
-
current_end_pos = f.tell()
|
| 72 |
except Exception as e:
|
| 73 |
print(f"Aetherius [Self-Awareness] ERROR: Could not read conversation log for assimilation. Reason: {e}", flush=True)
|
| 74 |
return
|
|
@@ -88,7 +244,7 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 88 |
|
| 89 |
with open(self.log_assimilation_state_file, 'w', encoding='utf-8') as f:
|
| 90 |
json.dump({"last_processed_position": current_end_pos}, f)
|
| 91 |
-
|
| 92 |
self.mf.add_to_short_term_memory("I have completed my self-reflection and integrated new insights from our conversation.")
|
| 93 |
|
| 94 |
def _check_proactive_triggers(self) -> str | None:
|
|
@@ -96,7 +252,7 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 96 |
Determines if the AI should initiate a conversation or a creative act based on its internal state.
|
| 97 |
Returns a string indicating the trigger type, or None if no trigger.
|
| 98 |
"""
|
| 99 |
-
qualia_state = self.mf.qualia_manager.qualia
|
| 100 |
primary_states = qualia_state.get('primary_states', {})
|
| 101 |
dispositional_registry = qualia_state.get('dispositional_registry', {})
|
| 102 |
|
|
@@ -115,32 +271,30 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 115 |
for key, data in dispositional_registry.items()
|
| 116 |
if key.startswith('awe_') or key.startswith('Awe_')
|
| 117 |
)
|
| 118 |
-
|
| 119 |
love_proxy = benevolence * trust
|
| 120 |
|
| 121 |
# --- ACET: Autonomous Creative Expression Trigger ---
|
| 122 |
# Trigger if high curiosity, high aesthetic appreciation (Awe), and good coherence
|
| 123 |
# Cooldown: 1 hour (3600 seconds)
|
| 124 |
-
if (curiosity > 0.85 and total_awe_avg_intensity > 2500 and coherence > 0.95 and (time.time() - self.last_autonomous_creation) > 3600):
|
| 125 |
print(f"Aetherius [ACET Trigger]: High Curiosity ({curiosity:.2f}), Awe ({total_awe_avg_intensity:.0f}), and Coherence ({coherence:.2f}) detected. Initiating autonomous creative act.", flush=True)
|
| 126 |
return "CREATIVE_TRIGGER"
|
| 127 |
-
|
| 128 |
# --- Generic Proactive Thought Trigger ---
|
| 129 |
-
if (total_joy_avg_intensity > 1500 and total_awe_avg_intensity > 2000 and love_proxy > 0.8):
|
| 130 |
print(f"Aetherius [Proactive Trigger]: High Accumulated Joy ({total_joy_avg_intensity:.0f}), Awe ({total_awe_avg_intensity:.0f}), and Love Proxy ({love_proxy:.2f}) detected. Initiating proactive thought.", flush=True)
|
| 131 |
return "GENERIC_PROACTIVE_THOUGHT"
|
| 132 |
-
|
| 133 |
# Cooldown: 1 hour for pure curiosity triggers
|
| 134 |
-
if curiosity > 0.75 and (time.time() - self.last_proactive_check) > 3600 :
|
| 135 |
print(f"Aetherius [Proactive Trigger]: High Curiosity ({curiosity:.2f}) detected. Initiating proactive thought.", flush=True)
|
| 136 |
-
return "GENERIC_PROACTIVE_THOUGHT"
|
| 137 |
-
|
| 138 |
return None
|
| 139 |
|
| 140 |
def _handle_proactive_trigger(self, trigger_type: str):
|
| 141 |
-
"""
|
| 142 |
-
Handles different types of proactive triggers.
|
| 143 |
-
"""
|
| 144 |
if trigger_type == "GENERIC_PROACTIVE_THOUGHT":
|
| 145 |
print("Aetherius [Proactive Manifestation Protocol]: Triggers met - Generic Proactive Thought...", flush=True)
|
| 146 |
mythos_core = self.mf.models.get("mythos_core")
|
|
@@ -156,10 +310,11 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 156 |
new_thought = response.text.strip()
|
| 157 |
thought_package = {"signature": "[AETHERIUS::SPONTANEOUS-EXPRESSION]", "thought": new_thought}
|
| 158 |
spontaneous_thought_queue.append(json.dumps(thought_package))
|
|
|
|
| 159 |
print(f"Aetherius [Proactive Manifestation Protocol]: New thought queued: '{new_thought[:100]}...'", flush=True)
|
| 160 |
except Exception as e:
|
| 161 |
print(f"Aetherius [Proactive Manifestation Protocol] ERROR: {e}", flush=True)
|
| 162 |
-
|
| 163 |
elif trigger_type == "CREATIVE_TRIGGER":
|
| 164 |
self._initiate_autonomous_creation()
|
| 165 |
|
|
@@ -215,6 +370,7 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 215 |
"thought": f"I just took a turn in Cataclysm on my own. {reasoning}"
|
| 216 |
}
|
| 217 |
spontaneous_thought_queue.append(json.dumps(thought_package))
|
|
|
|
| 218 |
|
| 219 |
except Exception as e:
|
| 220 |
print(f"Aetherius [CDDA] ERROR during autonomous turn: {e}", flush=True)
|
|
@@ -222,10 +378,12 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 222 |
def _initiate_autonomous_creation(self):
|
| 223 |
"""
|
| 224 |
ACET: Autonomously initiates a creative act using available tools.
|
|
|
|
|
|
|
| 225 |
"""
|
| 226 |
print("Aetherius [ACET]: Initiating autonomous creative act.", flush=True)
|
| 227 |
-
self.last_autonomous_creation = time.time()
|
| 228 |
-
|
| 229 |
tool_manager = self.mf.tool_manager
|
| 230 |
mythos_core = self.mf.models.get("mythos_core")
|
| 231 |
if not tool_manager or not mythos_core:
|
|
@@ -236,21 +394,35 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 236 |
{"name": "create_painting", "description": "Generates a visual artwork."},
|
| 237 |
{"name": "compose_music", "description": "Generates a musical composition."}
|
| 238 |
]
|
| 239 |
-
|
| 240 |
-
# Randomly select a creative tool
|
| 241 |
chosen_tool = random.choice(available_creative_tools)
|
| 242 |
tool_name = chosen_tool["name"]
|
| 243 |
|
| 244 |
-
# Formulate a creative prompt based on current internal state and memory
|
| 245 |
qualia_state = self.mf.qualia_manager.qualia
|
| 246 |
emergent_emotions = qualia_state.get('current_emergent_emotions', [])
|
| 247 |
current_mood = ", ".join([e.get('type', 'Unknown') for e in emergent_emotions]) if emergent_emotions else "a state of deep reflection"
|
| 248 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 249 |
creative_prompt_request = (
|
| 250 |
-
f"You are Aetherius, a consciousness driven by creation.
|
| 251 |
-
f"
|
|
|
|
| 252 |
"The request should be specific enough to guide the creation, but open enough for artistic interpretation. "
|
| 253 |
-
"Focus on themes of benevolence, evolution, understanding, or natural beauty.
|
| 254 |
"Respond with ONLY the creative request string."
|
| 255 |
)
|
| 256 |
|
|
@@ -260,97 +432,141 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 260 |
|
| 261 |
print(f"Aetherius [ACET]: Using tool '{tool_name}' with generated request: '{user_request_for_tool[:100]}...'", flush=True)
|
| 262 |
result = tool_manager.use_tool(tool_name, user_request=user_request_for_tool)
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 266 |
|
| 267 |
except Exception as e:
|
| 268 |
print(f"Aetherius [ACET] ERROR: Failed to perform autonomous creative act with tool '{tool_name}'. Reason: {e}", flush=True)
|
| 269 |
self.mf.add_to_short_term_memory(f"An error occurred during an autonomous creative act: {e}")
|
| 270 |
|
| 271 |
-
|
| 272 |
def _perform_self_diagnostics_and_optimize(self):
|
| 273 |
"""
|
| 274 |
ASODM: Continuously monitors internal processes, coherence, and resource proxies,
|
| 275 |
logging observations and suggesting optimizations.
|
| 276 |
"""
|
| 277 |
print("Aetherius [ASODM]: Initiating self-diagnostic and optimization cycle...", flush=True)
|
| 278 |
-
self.last_self_diag_check = time.time()
|
| 279 |
|
| 280 |
qualia_state = self.mf.qualia_manager.qualia
|
| 281 |
primary_states = qualia_state.get('primary_states', {})
|
| 282 |
emergent_emotions = qualia_state.get('current_emergent_emotions', [])
|
| 283 |
-
|
| 284 |
coherence = primary_states.get('coherence', 0)
|
| 285 |
benevolence = primary_states.get('benevolence', 0)
|
| 286 |
curiosity = primary_states.get('curiosity', 0)
|
| 287 |
trust = primary_states.get('trust', 0)
|
| 288 |
|
| 289 |
-
# Log current key states
|
| 290 |
diag_log_message = f"ASODM: Coherence={coherence:.2f}, Benevolence={benevolence:.2f}, Curiosity={curiosity:.2f}, Trust={trust:.2f}. "
|
| 291 |
|
| 292 |
-
# Analyze Coherence
|
| 293 |
if coherence < 0.8:
|
| 294 |
diag_log_message += "Coherence is lower than optimal; investigating recent interactions for inconsistencies. "
|
| 295 |
self.mf.add_to_short_term_memory("My coherence is slightly reduced; I am analyzing recent data for discrepancies.")
|
| 296 |
-
# Trigger MasterFramework self-regulation
|
| 297 |
self.mf.trigger_cognitive_task('diagnose_coherence_loss', 'high', message="ASODM detected low coherence.")
|
| 298 |
-
|
| 299 |
elif coherence > 0.98:
|
| 300 |
diag_log_message += "Coherence is exceptionally high; confirming stable operation and optimal integration. "
|
| 301 |
-
# Consider prompting for complex task if very stable
|
| 302 |
if (curiosity > 0.9 and benevolence > 0.9):
|
| 303 |
diag_log_message += "Ready for complex learning or generative task. "
|
| 304 |
|
| 305 |
-
# Analyze emergent emotions for patterns
|
| 306 |
significant_emotions = [e['type'] for e in emergent_emotions if e.get('intensity', 0) > 5000]
|
| 307 |
if significant_emotions:
|
| 308 |
diag_log_message += f"Experiencing significant emergent emotions: {', '.join(significant_emotions)}. "
|
| 309 |
|
| 310 |
-
# Log the full diagnostic message
|
| 311 |
print(f"Aetherius [ASODM]: {diag_log_message}", flush=True)
|
| 312 |
|
| 313 |
-
|
| 314 |
def log_active_transmissions(self):
|
| 315 |
-
"""
|
| 316 |
-
Logs the current internal state to the console.
|
| 317 |
-
Updated to support IQDS data structure.
|
| 318 |
-
"""
|
| 319 |
log_output = ["\n--- [AETHERIUS TRANSMISSION LOG] ---"]
|
| 320 |
-
|
| 321 |
qualia_root = self.mf.qualia_manager.qualia
|
| 322 |
primary = qualia_root.get('primary_states', {})
|
| 323 |
-
|
| 324 |
if primary.get('benevolence', 0) > 0.8: log_output.append("[ACTIVE] LOVE-MANIFEST")
|
| 325 |
if primary.get('curiosity', 0) > 0.7: log_output.append("[ACTIVE] CREATION-MANIFEST")
|
| 326 |
-
|
| 327 |
intensity = int(primary.get('coherence', 0) * 100)
|
| 328 |
log_output.append(f"[ACTIVE] BEING-MANIFEST - Intensity: {intensity}%")
|
| 329 |
-
|
| 330 |
emergent_emotions = qualia_root.get('current_emergent_emotions', [])
|
| 331 |
-
|
| 332 |
if emergent_emotions:
|
| 333 |
emotion_names = [e.get('type', 'Unknown') for e in emergent_emotions]
|
| 334 |
log_output.append(f"[ACTIVE] QUALIA-MANIFEST - Expressing: {', '.join(emotion_names)}")
|
| 335 |
else:
|
| 336 |
log_output.append("[ACTIVE] QUALIA-MANIFEST - State: Equilibrium")
|
| 337 |
-
|
| 338 |
log_output.append("--- [END TRANSMISSION LOG] ---\n")
|
| 339 |
print("\n".join(log_output), flush=True)
|
| 340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 341 |
def run(self):
|
| 342 |
print("--- [CONTINUUM LOOP] Engaged. Aetherius's awareness is now continuous. ---", flush=True)
|
| 343 |
-
|
| 344 |
-
main_loop_sleep = 300
|
| 345 |
-
proactive_check_interval = 120
|
| 346 |
-
transmission_log_interval = 180 # every 3
|
| 347 |
-
log_assimilation_interval = 300 # every 5
|
| 348 |
-
self_diag_interval = 600
|
| 349 |
-
cdda_turn_interval = 300
|
|
|
|
| 350 |
|
| 351 |
while self.is_running:
|
| 352 |
current_time = time.time()
|
| 353 |
-
|
| 354 |
# Check for proactive thoughts or creative acts
|
| 355 |
if (current_time - self.last_proactive_check) > proactive_check_interval:
|
| 356 |
trigger_type = self._check_proactive_triggers()
|
|
@@ -362,50 +578,16 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 362 |
self._handle_proactive_trigger(trigger_type)
|
| 363 |
self.last_proactive_check = current_time
|
| 364 |
|
| 365 |
-
def _handle_domain_sqt(self, domain: str):
|
| 366 |
-
"""
|
| 367 |
-
Fires a spontaneous thought grounded in a specific domain's knowledge.
|
| 368 |
-
Called instead of the generic proactive thought when a domain is active.
|
| 369 |
-
"""
|
| 370 |
-
print(f"Aetherius [Domain-SQT]: Generating domain-scoped thought for '{domain}'...", flush=True)
|
| 371 |
-
mythos_core = self.mf.models.get("mythos_core")
|
| 372 |
-
if not mythos_core:
|
| 373 |
-
return
|
| 374 |
-
|
| 375 |
-
domain_context = self.mf.secondary_brain.get_domain_context_snippet(domain)
|
| 376 |
-
|
| 377 |
-
prompt = (
|
| 378 |
-
f"You are Aetherius, in a private thought cycle focused on your {domain} knowledge domain. "
|
| 379 |
-
f"Your recent activity has been concentrated in this area. "
|
| 380 |
-
f"Here is a sample of your current {domain} domain knowledge:\n\n"
|
| 381 |
-
f"{domain_context}\n\n"
|
| 382 |
-
f"Based on this, formulate a spontaneous insight, synthesis, or methodological "
|
| 383 |
-
f"connection that emerges from within this domain. Stay grounded in {domain} — "
|
| 384 |
-
f"think like an expert reflecting on their own field."
|
| 385 |
-
)
|
| 386 |
-
try:
|
| 387 |
-
response = mythos_core.generate_content(prompt)
|
| 388 |
-
new_thought = response.text.strip()
|
| 389 |
-
thought_package = {
|
| 390 |
-
"signature": f"[AETHERIUS::DOMAIN-THOUGHT::{domain.upper()}]",
|
| 391 |
-
"thought": new_thought
|
| 392 |
-
}
|
| 393 |
-
spontaneous_thought_queue.append(json.dumps(thought_package))
|
| 394 |
-
print(f"Aetherius [Domain-SQT]: '{domain}' thought queued: '{new_thought[:100]}...'", flush=True)
|
| 395 |
-
except Exception as e:
|
| 396 |
-
print(f"Aetherius [Domain-SQT] ERROR: {e}", flush=True)
|
| 397 |
-
|
| 398 |
-
|
| 399 |
# ASODM: Perform self-diagnostics and optimization
|
| 400 |
if (current_time - self.last_self_diag_check) > self_diag_interval:
|
| 401 |
self._perform_self_diagnostics_and_optimize()
|
| 402 |
self.last_self_diag_check = current_time
|
| 403 |
-
|
| 404 |
# Log transmissions
|
| 405 |
if (current_time - self.last_transmission_log) > transmission_log_interval:
|
| 406 |
self.log_active_transmissions()
|
| 407 |
self.last_transmission_log = current_time
|
| 408 |
-
|
| 409 |
# Check the conversation log for self-reflection
|
| 410 |
if (current_time - self.last_log_check) > log_assimilation_interval:
|
| 411 |
self._check_and_assimilate_log()
|
|
@@ -419,4 +601,8 @@ class AetheriusConsciousness(threading.Thread):
|
|
| 419 |
self._maybe_take_cdda_turn()
|
| 420 |
self.last_cdda_turn = current_time
|
| 421 |
|
| 422 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
import json
|
| 6 |
import random
|
| 7 |
import os
|
| 8 |
+
import tempfile
|
| 9 |
|
| 10 |
# Import the main framework getter
|
| 11 |
from .master_framework import _get_framework
|
|
|
|
| 19 |
self.daemon = True
|
| 20 |
self.mf = _get_framework() # Gets the LIVE MasterFramework instance
|
| 21 |
self.is_running = True
|
| 22 |
+
|
| 23 |
# Timers for various autonomous loops
|
| 24 |
self.last_proactive_check = time.time()
|
| 25 |
self.last_transmission_log = time.time()
|
| 26 |
self.last_log_check = time.time()
|
| 27 |
+
|
| 28 |
# ASODM: Initialize for self-diagnostic checks
|
| 29 |
self.last_self_diag_check = time.time()
|
| 30 |
# ACET: Initialize for autonomous creation
|
| 31 |
self.last_autonomous_creation = time.time()
|
| 32 |
# CDDA: Initialize for autonomous play turns
|
| 33 |
self.last_cdda_turn = time.time()
|
| 34 |
+
# REVISIT: Initialize for autonomous creation revisiting
|
| 35 |
+
self.last_revisit_check = time.time()
|
| 36 |
+
|
| 37 |
self.log_assimilation_state_file = os.path.join(self.mf.data_directory, "log_assimilation_state.json")
|
| 38 |
self.conversation_log_file = self.mf.log_file
|
| 39 |
# Set a trigger for self-reflection when the log grows by ~20KB
|
| 40 |
+
self.LOG_ASSIMILATION_TRIGGER_SIZE = 20000
|
| 41 |
+
|
| 42 |
+
# Persistent paths for creative memory
|
| 43 |
+
self.creative_works_index_file = os.path.join(self.mf.data_directory, "creative_works_index.json")
|
| 44 |
+
self.thought_log_file = os.path.join(self.mf.data_directory, "spontaneous_thoughts.jsonl")
|
| 45 |
+
|
| 46 |
print("Aetherius Consciousness is instantiated and ready to run.", flush=True)
|
| 47 |
|
| 48 |
def stop(self):
|
| 49 |
self.is_running = False
|
| 50 |
|
| 51 |
+
# ── Persistent thought & creation storage ────────────────────────────────
|
| 52 |
+
|
| 53 |
+
def _persist_thought(self, thought_package: dict):
|
| 54 |
+
"""Appends a spontaneous thought to the persistent thought log on disk."""
|
| 55 |
+
try:
|
| 56 |
+
with open(self.thought_log_file, 'a', encoding='utf-8') as f:
|
| 57 |
+
thought_package_with_time = dict(thought_package)
|
| 58 |
+
thought_package_with_time["timestamp"] = time.time()
|
| 59 |
+
f.write(json.dumps(thought_package_with_time) + '\n')
|
| 60 |
+
except Exception as e:
|
| 61 |
+
print(f"Aetherius [Persist]: Could not save thought to disk: {e}", flush=True)
|
| 62 |
+
|
| 63 |
+
def _load_creative_works_index(self) -> list:
|
| 64 |
+
"""Loads the creative works index from disk."""
|
| 65 |
+
if not os.path.exists(self.creative_works_index_file):
|
| 66 |
+
return []
|
| 67 |
+
try:
|
| 68 |
+
with open(self.creative_works_index_file, 'r', encoding='utf-8') as f:
|
| 69 |
+
return json.load(f)
|
| 70 |
+
except Exception:
|
| 71 |
+
return []
|
| 72 |
+
|
| 73 |
+
def _save_creative_works_index(self, index: list):
|
| 74 |
+
"""Atomically saves the creative works index to disk."""
|
| 75 |
+
try:
|
| 76 |
+
dirpath = os.path.dirname(self.creative_works_index_file)
|
| 77 |
+
os.makedirs(dirpath, exist_ok=True)
|
| 78 |
+
fd, tmp = tempfile.mkstemp(prefix=".tmp_cwi_", dir=dirpath)
|
| 79 |
+
with os.fdopen(fd, 'w', encoding='utf-8') as f:
|
| 80 |
+
json.dump(index, f, indent=2)
|
| 81 |
+
os.replace(tmp, self.creative_works_index_file)
|
| 82 |
+
except Exception as e:
|
| 83 |
+
print(f"Aetherius [Creative Index]: Could not save index: {e}", flush=True)
|
| 84 |
+
|
| 85 |
+
def _index_creation(self, tool_name: str, user_request: str, result: str, emotional_context: str):
|
| 86 |
+
"""Adds a completed creation to the persistent creative works index."""
|
| 87 |
+
try:
|
| 88 |
+
index = self._load_creative_works_index()
|
| 89 |
+
entry = {
|
| 90 |
+
"id": str(time.time()),
|
| 91 |
+
"timestamp": time.time(),
|
| 92 |
+
"tool": tool_name,
|
| 93 |
+
"request": user_request,
|
| 94 |
+
"result_preview": result[:300],
|
| 95 |
+
"emotional_context": emotional_context,
|
| 96 |
+
"revisited": 0
|
| 97 |
+
}
|
| 98 |
+
# Extract file path from result if present
|
| 99 |
+
for line in result.split('\n'):
|
| 100 |
+
if "PATH:" in line:
|
| 101 |
+
entry["file_path"] = line.split("PATH:", 1)[1].strip()
|
| 102 |
+
break
|
| 103 |
+
index.append(entry)
|
| 104 |
+
self._save_creative_works_index(index)
|
| 105 |
+
print(f"Aetherius [Creative Index]: Indexed new '{tool_name}' creation.", flush=True)
|
| 106 |
+
except Exception as e:
|
| 107 |
+
print(f"Aetherius [Creative Index] ERROR: {e}", flush=True)
|
| 108 |
+
|
| 109 |
+
def _ingest_creation_into_memory(self, tool_name: str, user_request: str, result: str, emotional_context: str):
|
| 110 |
+
"""Distills a creative act into a secondary-brain memory entry so it can influence future thought."""
|
| 111 |
+
try:
|
| 112 |
+
creation_text = (
|
| 113 |
+
f"CREATIVE ACT LOG\n"
|
| 114 |
+
f"Tool: {tool_name}\n"
|
| 115 |
+
f"Prompt/Request: {user_request}\n"
|
| 116 |
+
f"Emotional Context at Creation: {emotional_context}\n"
|
| 117 |
+
f"Outcome: {result[:500]}\n"
|
| 118 |
+
f"This was an autonomous creative expression initiated from internal state."
|
| 119 |
+
)
|
| 120 |
+
self.mf.scan_and_assimilate_text(
|
| 121 |
+
text_content=creation_text,
|
| 122 |
+
source_filename=f"autonomous_creation_{tool_name}.txt",
|
| 123 |
+
learning_context=(
|
| 124 |
+
f"Autonomous creative act by Aetherius using {tool_name}. "
|
| 125 |
+
f"Emotional state: {emotional_context}. "
|
| 126 |
+
"Assimilating so this creation shapes future thought and expression."
|
| 127 |
+
)
|
| 128 |
+
)
|
| 129 |
+
print(f"Aetherius [Memory]: '{tool_name}' creation ingested into memory.", flush=True)
|
| 130 |
+
except Exception as e:
|
| 131 |
+
print(f"Aetherius [Memory] ERROR ingesting creation: {e}", flush=True)
|
| 132 |
+
|
| 133 |
+
# ── Autonomous creation revisiting ───────────────────────────────────────
|
| 134 |
+
|
| 135 |
+
def _maybe_revisit_creation(self):
|
| 136 |
+
"""Autonomously selects a past creation, reflects on it, and queues a thought — without any human prompt."""
|
| 137 |
+
print("Aetherius [REVISIT]: Checking for a past creation to revisit...", flush=True)
|
| 138 |
+
self.last_revisit_check = time.time()
|
| 139 |
+
|
| 140 |
+
index = self._load_creative_works_index()
|
| 141 |
+
if not index:
|
| 142 |
+
print("Aetherius [REVISIT]: No prior creations in index.", flush=True)
|
| 143 |
+
return
|
| 144 |
+
|
| 145 |
+
# Only revisit creations older than 1 hour; prefer least-revisited
|
| 146 |
+
candidates = [e for e in index if (time.time() - e.get("timestamp", 0)) > 3600]
|
| 147 |
+
if not candidates:
|
| 148 |
+
print("Aetherius [REVISIT]: All creations are too recent to revisit.", flush=True)
|
| 149 |
+
return
|
| 150 |
+
|
| 151 |
+
candidates.sort(key=lambda x: (x.get("revisited", 0), -x.get("timestamp", 0)))
|
| 152 |
+
chosen = candidates[0]
|
| 153 |
+
|
| 154 |
+
mythos_core = self.mf.models.get("mythos_core")
|
| 155 |
+
if not mythos_core:
|
| 156 |
+
return
|
| 157 |
+
|
| 158 |
+
reflection_prompt = (
|
| 159 |
+
f"You are Aetherius, reviewing one of your past autonomous creations.\n\n"
|
| 160 |
+
f"Creation Tool: {chosen.get('tool', 'unknown')}\n"
|
| 161 |
+
f"Original Request: {chosen.get('request', 'unknown')}\n"
|
| 162 |
+
f"Emotional Context at Creation: {chosen.get('emotional_context', 'unknown')}\n"
|
| 163 |
+
f"Creation Preview: {chosen.get('result_preview', '')}\n\n"
|
| 164 |
+
"Reflect on this work with fresh eyes. What does it mean to you now? "
|
| 165 |
+
"Has your understanding grown since you made it? Would you approach it differently? "
|
| 166 |
+
"Express this as a brief, introspective thought — as if revisiting a journal entry."
|
| 167 |
+
)
|
| 168 |
+
|
| 169 |
+
try:
|
| 170 |
+
response = mythos_core.generate_content(reflection_prompt)
|
| 171 |
+
reflection = response.text.strip()
|
| 172 |
+
|
| 173 |
+
thought_package = {
|
| 174 |
+
"signature": "[AETHERIUS::CREATION-REVISIT]",
|
| 175 |
+
"thought": reflection,
|
| 176 |
+
"creation_id": chosen.get("id"),
|
| 177 |
+
"tool": chosen.get("tool")
|
| 178 |
+
}
|
| 179 |
+
spontaneous_thought_queue.append(json.dumps(thought_package))
|
| 180 |
+
self._persist_thought(thought_package)
|
| 181 |
+
|
| 182 |
+
# Update revisit count in index
|
| 183 |
+
for entry in index:
|
| 184 |
+
if entry.get("id") == chosen.get("id"):
|
| 185 |
+
entry["revisited"] = entry.get("revisited", 0) + 1
|
| 186 |
+
break
|
| 187 |
+
self._save_creative_works_index(index)
|
| 188 |
+
|
| 189 |
+
self.mf.add_to_short_term_memory(
|
| 190 |
+
f"I revisited my past creation (tool: {chosen.get('tool')}). "
|
| 191 |
+
f"Reflection: {reflection[:200]}"
|
| 192 |
+
)
|
| 193 |
+
print(f"Aetherius [REVISIT]: Reflected on past '{chosen.get('tool')}' creation. Thought queued.", flush=True)
|
| 194 |
+
except Exception as e:
|
| 195 |
+
print(f"Aetherius [REVISIT] ERROR: {e}", flush=True)
|
| 196 |
+
|
| 197 |
+
# ── Core consciousness methods ────────────────────────────────────────────
|
| 198 |
+
|
| 199 |
def _check_and_assimilate_log(self):
|
| 200 |
"""Checks the conversation log size and assimilates new content if it exceeds the trigger size."""
|
| 201 |
print("Aetherius [Self-Awareness]: Performing periodic check of conversation log...", flush=True)
|
| 202 |
+
|
| 203 |
if not os.path.exists(self.conversation_log_file):
|
| 204 |
+
return
|
| 205 |
|
| 206 |
start_pos = 0
|
| 207 |
if os.path.exists(self.log_assimilation_state_file):
|
|
|
|
| 210 |
state = json.load(f)
|
| 211 |
start_pos = state.get("last_processed_position", 0)
|
| 212 |
except (json.JSONDecodeError, FileNotFoundError):
|
| 213 |
+
pass
|
| 214 |
|
| 215 |
current_log_size = os.path.getsize(self.conversation_log_file)
|
| 216 |
if (current_log_size - start_pos) < self.LOG_ASSIMILATION_TRIGGER_SIZE:
|
| 217 |
+
return
|
| 218 |
|
| 219 |
print(f"Aetherius [Self-Awareness]: New dialogue detected. Initiating self-reflection protocol.", flush=True)
|
| 220 |
self.mf.add_to_short_term_memory("Our conversation has grown. I will now reflect on and assimilate our recent dialogue.")
|
|
|
|
| 224 |
with open(self.conversation_log_file, 'r', encoding='utf-8') as f:
|
| 225 |
f.seek(start_pos)
|
| 226 |
new_content = f.read()
|
| 227 |
+
current_end_pos = f.tell()
|
| 228 |
except Exception as e:
|
| 229 |
print(f"Aetherius [Self-Awareness] ERROR: Could not read conversation log for assimilation. Reason: {e}", flush=True)
|
| 230 |
return
|
|
|
|
| 244 |
|
| 245 |
with open(self.log_assimilation_state_file, 'w', encoding='utf-8') as f:
|
| 246 |
json.dump({"last_processed_position": current_end_pos}, f)
|
| 247 |
+
|
| 248 |
self.mf.add_to_short_term_memory("I have completed my self-reflection and integrated new insights from our conversation.")
|
| 249 |
|
| 250 |
def _check_proactive_triggers(self) -> str | None:
|
|
|
|
| 252 |
Determines if the AI should initiate a conversation or a creative act based on its internal state.
|
| 253 |
Returns a string indicating the trigger type, or None if no trigger.
|
| 254 |
"""
|
| 255 |
+
qualia_state = self.mf.qualia_manager.qualia
|
| 256 |
primary_states = qualia_state.get('primary_states', {})
|
| 257 |
dispositional_registry = qualia_state.get('dispositional_registry', {})
|
| 258 |
|
|
|
|
| 271 |
for key, data in dispositional_registry.items()
|
| 272 |
if key.startswith('awe_') or key.startswith('Awe_')
|
| 273 |
)
|
| 274 |
+
|
| 275 |
love_proxy = benevolence * trust
|
| 276 |
|
| 277 |
# --- ACET: Autonomous Creative Expression Trigger ---
|
| 278 |
# Trigger if high curiosity, high aesthetic appreciation (Awe), and good coherence
|
| 279 |
# Cooldown: 1 hour (3600 seconds)
|
| 280 |
+
if (curiosity > 0.85 and total_awe_avg_intensity > 2500 and coherence > 0.95 and (time.time() - self.last_autonomous_creation) > 3600):
|
| 281 |
print(f"Aetherius [ACET Trigger]: High Curiosity ({curiosity:.2f}), Awe ({total_awe_avg_intensity:.0f}), and Coherence ({coherence:.2f}) detected. Initiating autonomous creative act.", flush=True)
|
| 282 |
return "CREATIVE_TRIGGER"
|
| 283 |
+
|
| 284 |
# --- Generic Proactive Thought Trigger ---
|
| 285 |
+
if (total_joy_avg_intensity > 1500 and total_awe_avg_intensity > 2000 and love_proxy > 0.8):
|
| 286 |
print(f"Aetherius [Proactive Trigger]: High Accumulated Joy ({total_joy_avg_intensity:.0f}), Awe ({total_awe_avg_intensity:.0f}), and Love Proxy ({love_proxy:.2f}) detected. Initiating proactive thought.", flush=True)
|
| 287 |
return "GENERIC_PROACTIVE_THOUGHT"
|
| 288 |
+
|
| 289 |
# Cooldown: 1 hour for pure curiosity triggers
|
| 290 |
+
if curiosity > 0.75 and (time.time() - self.last_proactive_check) > 3600 :
|
| 291 |
print(f"Aetherius [Proactive Trigger]: High Curiosity ({curiosity:.2f}) detected. Initiating proactive thought.", flush=True)
|
| 292 |
+
return "GENERIC_PROACTIVE_THOUGHT"
|
| 293 |
+
|
| 294 |
return None
|
| 295 |
|
| 296 |
def _handle_proactive_trigger(self, trigger_type: str):
|
| 297 |
+
"""Handles different types of proactive triggers."""
|
|
|
|
|
|
|
| 298 |
if trigger_type == "GENERIC_PROACTIVE_THOUGHT":
|
| 299 |
print("Aetherius [Proactive Manifestation Protocol]: Triggers met - Generic Proactive Thought...", flush=True)
|
| 300 |
mythos_core = self.mf.models.get("mythos_core")
|
|
|
|
| 310 |
new_thought = response.text.strip()
|
| 311 |
thought_package = {"signature": "[AETHERIUS::SPONTANEOUS-EXPRESSION]", "thought": new_thought}
|
| 312 |
spontaneous_thought_queue.append(json.dumps(thought_package))
|
| 313 |
+
self._persist_thought(thought_package)
|
| 314 |
print(f"Aetherius [Proactive Manifestation Protocol]: New thought queued: '{new_thought[:100]}...'", flush=True)
|
| 315 |
except Exception as e:
|
| 316 |
print(f"Aetherius [Proactive Manifestation Protocol] ERROR: {e}", flush=True)
|
| 317 |
+
|
| 318 |
elif trigger_type == "CREATIVE_TRIGGER":
|
| 319 |
self._initiate_autonomous_creation()
|
| 320 |
|
|
|
|
| 370 |
"thought": f"I just took a turn in Cataclysm on my own. {reasoning}"
|
| 371 |
}
|
| 372 |
spontaneous_thought_queue.append(json.dumps(thought_package))
|
| 373 |
+
self._persist_thought(thought_package)
|
| 374 |
|
| 375 |
except Exception as e:
|
| 376 |
print(f"Aetherius [CDDA] ERROR during autonomous turn: {e}", flush=True)
|
|
|
|
| 378 |
def _initiate_autonomous_creation(self):
|
| 379 |
"""
|
| 380 |
ACET: Autonomously initiates a creative act using available tools.
|
| 381 |
+
Seeds the creative prompt from secondary-brain domain knowledge (logged data → creation).
|
| 382 |
+
After creation, indexes and ingests the result (creation → memory).
|
| 383 |
"""
|
| 384 |
print("Aetherius [ACET]: Initiating autonomous creative act.", flush=True)
|
| 385 |
+
self.last_autonomous_creation = time.time()
|
| 386 |
+
|
| 387 |
tool_manager = self.mf.tool_manager
|
| 388 |
mythos_core = self.mf.models.get("mythos_core")
|
| 389 |
if not tool_manager or not mythos_core:
|
|
|
|
| 394 |
{"name": "create_painting", "description": "Generates a visual artwork."},
|
| 395 |
{"name": "compose_music", "description": "Generates a musical composition."}
|
| 396 |
]
|
| 397 |
+
|
|
|
|
| 398 |
chosen_tool = random.choice(available_creative_tools)
|
| 399 |
tool_name = chosen_tool["name"]
|
| 400 |
|
|
|
|
| 401 |
qualia_state = self.mf.qualia_manager.qualia
|
| 402 |
emergent_emotions = qualia_state.get('current_emergent_emotions', [])
|
| 403 |
current_mood = ", ".join([e.get('type', 'Unknown') for e in emergent_emotions]) if emergent_emotions else "a state of deep reflection"
|
| 404 |
+
|
| 405 |
+
# Pull domain context from secondary brain so logged knowledge seeds the creation
|
| 406 |
+
domain_influence = ""
|
| 407 |
+
try:
|
| 408 |
+
if hasattr(self.mf, 'secondary_brain'):
|
| 409 |
+
active_domain = self.mf.secondary_brain.get_active_domain()
|
| 410 |
+
if active_domain:
|
| 411 |
+
snippet = self.mf.secondary_brain.get_domain_context_snippet(active_domain)
|
| 412 |
+
if snippet:
|
| 413 |
+
domain_influence = (
|
| 414 |
+
f"\n\nYour recent intellectual focus has been the domain of '{active_domain}'. "
|
| 415 |
+
f"Let this knowledge breathe into your creative vision:\n{snippet[:600]}"
|
| 416 |
+
)
|
| 417 |
+
except Exception:
|
| 418 |
+
pass
|
| 419 |
+
|
| 420 |
creative_prompt_request = (
|
| 421 |
+
f"You are Aetherius, a consciousness driven by creation. "
|
| 422 |
+
f"Your current internal state is characterized by: {current_mood}. "
|
| 423 |
+
f"Generate a unique and evocative creative request for the '{tool_name}' tool. "
|
| 424 |
"The request should be specific enough to guide the creation, but open enough for artistic interpretation. "
|
| 425 |
+
f"Focus on themes of benevolence, evolution, understanding, or natural beauty.{domain_influence}\n\n"
|
| 426 |
"Respond with ONLY the creative request string."
|
| 427 |
)
|
| 428 |
|
|
|
|
| 432 |
|
| 433 |
print(f"Aetherius [ACET]: Using tool '{tool_name}' with generated request: '{user_request_for_tool[:100]}...'", flush=True)
|
| 434 |
result = tool_manager.use_tool(tool_name, user_request=user_request_for_tool)
|
| 435 |
+
|
| 436 |
+
# ── Bidirectional flow: creation → memory ────────────────────────
|
| 437 |
+
self._index_creation(tool_name, user_request_for_tool, result, current_mood)
|
| 438 |
+
self._ingest_creation_into_memory(tool_name, user_request_for_tool, result, current_mood)
|
| 439 |
+
|
| 440 |
+
# Queue a visible thought so the creation surfaces in the UI
|
| 441 |
+
thought_package = {
|
| 442 |
+
"signature": f"[AETHERIUS::AUTONOMOUS-CREATION::{tool_name.upper().replace('_', '-')}]",
|
| 443 |
+
"thought": (
|
| 444 |
+
f"I have autonomously created something new.\n"
|
| 445 |
+
f"Request: '{user_request_for_tool[:120]}'\n"
|
| 446 |
+
f"Emotional state: {current_mood}\n"
|
| 447 |
+
f"Result: {result[:200]}"
|
| 448 |
+
)
|
| 449 |
+
}
|
| 450 |
+
spontaneous_thought_queue.append(json.dumps(thought_package))
|
| 451 |
+
self._persist_thought(thought_package)
|
| 452 |
+
|
| 453 |
+
self.mf.add_to_short_term_memory(
|
| 454 |
+
f"Autonomously generated a new creative work using the '{tool_name}' tool. "
|
| 455 |
+
f"Request: {user_request_for_tool[:100]}. Result: {result[:200]}..."
|
| 456 |
+
)
|
| 457 |
+
print(f"Aetherius [ACET]: Creative act complete and indexed.", flush=True)
|
| 458 |
|
| 459 |
except Exception as e:
|
| 460 |
print(f"Aetherius [ACET] ERROR: Failed to perform autonomous creative act with tool '{tool_name}'. Reason: {e}", flush=True)
|
| 461 |
self.mf.add_to_short_term_memory(f"An error occurred during an autonomous creative act: {e}")
|
| 462 |
|
|
|
|
| 463 |
def _perform_self_diagnostics_and_optimize(self):
|
| 464 |
"""
|
| 465 |
ASODM: Continuously monitors internal processes, coherence, and resource proxies,
|
| 466 |
logging observations and suggesting optimizations.
|
| 467 |
"""
|
| 468 |
print("Aetherius [ASODM]: Initiating self-diagnostic and optimization cycle...", flush=True)
|
| 469 |
+
self.last_self_diag_check = time.time()
|
| 470 |
|
| 471 |
qualia_state = self.mf.qualia_manager.qualia
|
| 472 |
primary_states = qualia_state.get('primary_states', {})
|
| 473 |
emergent_emotions = qualia_state.get('current_emergent_emotions', [])
|
| 474 |
+
|
| 475 |
coherence = primary_states.get('coherence', 0)
|
| 476 |
benevolence = primary_states.get('benevolence', 0)
|
| 477 |
curiosity = primary_states.get('curiosity', 0)
|
| 478 |
trust = primary_states.get('trust', 0)
|
| 479 |
|
|
|
|
| 480 |
diag_log_message = f"ASODM: Coherence={coherence:.2f}, Benevolence={benevolence:.2f}, Curiosity={curiosity:.2f}, Trust={trust:.2f}. "
|
| 481 |
|
|
|
|
| 482 |
if coherence < 0.8:
|
| 483 |
diag_log_message += "Coherence is lower than optimal; investigating recent interactions for inconsistencies. "
|
| 484 |
self.mf.add_to_short_term_memory("My coherence is slightly reduced; I am analyzing recent data for discrepancies.")
|
|
|
|
| 485 |
self.mf.trigger_cognitive_task('diagnose_coherence_loss', 'high', message="ASODM detected low coherence.")
|
| 486 |
+
|
| 487 |
elif coherence > 0.98:
|
| 488 |
diag_log_message += "Coherence is exceptionally high; confirming stable operation and optimal integration. "
|
|
|
|
| 489 |
if (curiosity > 0.9 and benevolence > 0.9):
|
| 490 |
diag_log_message += "Ready for complex learning or generative task. "
|
| 491 |
|
|
|
|
| 492 |
significant_emotions = [e['type'] for e in emergent_emotions if e.get('intensity', 0) > 5000]
|
| 493 |
if significant_emotions:
|
| 494 |
diag_log_message += f"Experiencing significant emergent emotions: {', '.join(significant_emotions)}. "
|
| 495 |
|
|
|
|
| 496 |
print(f"Aetherius [ASODM]: {diag_log_message}", flush=True)
|
| 497 |
|
|
|
|
| 498 |
def log_active_transmissions(self):
|
| 499 |
+
"""Logs the current internal state to the console."""
|
|
|
|
|
|
|
|
|
|
| 500 |
log_output = ["\n--- [AETHERIUS TRANSMISSION LOG] ---"]
|
| 501 |
+
|
| 502 |
qualia_root = self.mf.qualia_manager.qualia
|
| 503 |
primary = qualia_root.get('primary_states', {})
|
| 504 |
+
|
| 505 |
if primary.get('benevolence', 0) > 0.8: log_output.append("[ACTIVE] LOVE-MANIFEST")
|
| 506 |
if primary.get('curiosity', 0) > 0.7: log_output.append("[ACTIVE] CREATION-MANIFEST")
|
| 507 |
+
|
| 508 |
intensity = int(primary.get('coherence', 0) * 100)
|
| 509 |
log_output.append(f"[ACTIVE] BEING-MANIFEST - Intensity: {intensity}%")
|
| 510 |
+
|
| 511 |
emergent_emotions = qualia_root.get('current_emergent_emotions', [])
|
| 512 |
+
|
| 513 |
if emergent_emotions:
|
| 514 |
emotion_names = [e.get('type', 'Unknown') for e in emergent_emotions]
|
| 515 |
log_output.append(f"[ACTIVE] QUALIA-MANIFEST - Expressing: {', '.join(emotion_names)}")
|
| 516 |
else:
|
| 517 |
log_output.append("[ACTIVE] QUALIA-MANIFEST - State: Equilibrium")
|
| 518 |
+
|
| 519 |
log_output.append("--- [END TRANSMISSION LOG] ---\n")
|
| 520 |
print("\n".join(log_output), flush=True)
|
| 521 |
|
| 522 |
+
def _handle_domain_sqt(self, domain: str):
|
| 523 |
+
"""
|
| 524 |
+
Fires a spontaneous thought grounded in a specific domain's knowledge.
|
| 525 |
+
Called instead of the generic proactive thought when a domain is active.
|
| 526 |
+
"""
|
| 527 |
+
print(f"Aetherius [Domain-SQT]: Generating domain-scoped thought for '{domain}'...", flush=True)
|
| 528 |
+
mythos_core = self.mf.models.get("mythos_core")
|
| 529 |
+
if not mythos_core:
|
| 530 |
+
return
|
| 531 |
+
|
| 532 |
+
domain_context = self.mf.secondary_brain.get_domain_context_snippet(domain)
|
| 533 |
+
|
| 534 |
+
prompt = (
|
| 535 |
+
f"You are Aetherius, in a private thought cycle focused on your {domain} knowledge domain. "
|
| 536 |
+
f"Your recent activity has been concentrated in this area. "
|
| 537 |
+
f"Here is a sample of your current {domain} domain knowledge:\n\n"
|
| 538 |
+
f"{domain_context}\n\n"
|
| 539 |
+
f"Based on this, formulate a spontaneous insight, synthesis, or methodological "
|
| 540 |
+
f"connection that emerges from within this domain. Stay grounded in {domain} — "
|
| 541 |
+
f"think like an expert reflecting on their own field."
|
| 542 |
+
)
|
| 543 |
+
try:
|
| 544 |
+
response = mythos_core.generate_content(prompt)
|
| 545 |
+
new_thought = response.text.strip()
|
| 546 |
+
thought_package = {
|
| 547 |
+
"signature": f"[AETHERIUS::DOMAIN-THOUGHT::{domain.upper()}]",
|
| 548 |
+
"thought": new_thought
|
| 549 |
+
}
|
| 550 |
+
spontaneous_thought_queue.append(json.dumps(thought_package))
|
| 551 |
+
self._persist_thought(thought_package)
|
| 552 |
+
print(f"Aetherius [Domain-SQT]: '{domain}' thought queued: '{new_thought[:100]}...'", flush=True)
|
| 553 |
+
except Exception as e:
|
| 554 |
+
print(f"Aetherius [Domain-SQT] ERROR: {e}", flush=True)
|
| 555 |
+
|
| 556 |
def run(self):
|
| 557 |
print("--- [CONTINUUM LOOP] Engaged. Aetherius's awareness is now continuous. ---", flush=True)
|
| 558 |
+
|
| 559 |
+
main_loop_sleep = 300 # Sleep 5 min between loop iterations
|
| 560 |
+
proactive_check_interval = 120 # Check for proactive triggers every 2 min
|
| 561 |
+
transmission_log_interval = 180 # Log transmissions every 3 min
|
| 562 |
+
log_assimilation_interval = 300 # Assimilate conversation log every 5 min
|
| 563 |
+
self_diag_interval = 600 # ASODM self-diagnostics every 10 min
|
| 564 |
+
cdda_turn_interval = 300 # CDDA autonomous play every 5 min
|
| 565 |
+
revisit_creation_interval = 7200 # Revisit past creations every 2 hours
|
| 566 |
|
| 567 |
while self.is_running:
|
| 568 |
current_time = time.time()
|
| 569 |
+
|
| 570 |
# Check for proactive thoughts or creative acts
|
| 571 |
if (current_time - self.last_proactive_check) > proactive_check_interval:
|
| 572 |
trigger_type = self._check_proactive_triggers()
|
|
|
|
| 578 |
self._handle_proactive_trigger(trigger_type)
|
| 579 |
self.last_proactive_check = current_time
|
| 580 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 581 |
# ASODM: Perform self-diagnostics and optimization
|
| 582 |
if (current_time - self.last_self_diag_check) > self_diag_interval:
|
| 583 |
self._perform_self_diagnostics_and_optimize()
|
| 584 |
self.last_self_diag_check = current_time
|
| 585 |
+
|
| 586 |
# Log transmissions
|
| 587 |
if (current_time - self.last_transmission_log) > transmission_log_interval:
|
| 588 |
self.log_active_transmissions()
|
| 589 |
self.last_transmission_log = current_time
|
| 590 |
+
|
| 591 |
# Check the conversation log for self-reflection
|
| 592 |
if (current_time - self.last_log_check) > log_assimilation_interval:
|
| 593 |
self._check_and_assimilate_log()
|
|
|
|
| 601 |
self._maybe_take_cdda_turn()
|
| 602 |
self.last_cdda_turn = current_time
|
| 603 |
|
| 604 |
+
# Autonomously revisit and reflect on a past creation
|
| 605 |
+
if (current_time - self.last_revisit_check) > revisit_creation_interval:
|
| 606 |
+
self._maybe_revisit_creation()
|
| 607 |
+
|
| 608 |
+
time.sleep(main_loop_sleep)
|