#!/usr/bin/env python3 """ Launch Script: Agent Generated by Uatu Genesis Engine This script boots the digital person with: - Environment configuration - Emergence Gate state (TALK_ONLY/FULL) - ConvexStateLogger for state persistence - Agent Zero framework integration """ import sys import os import json import asyncio import logging from pathlib import Path logging.basicConfig(level=logging.INFO) logger = logging.getLogger(__name__) # ============================================================================== # PERSONA CONFIGURATION # ============================================================================== PERSONA_DIR = Path(__file__).parent PERSONA_NAME = "Agent" PROFILE_NAME = "agent" # Sanitized name for Agent Zero config.profile ARCHETYPE = "Unknown" # Set persona-specific environment os.environ["AGENT_PROFILE"] = PROFILE_NAME os.environ["AGENT_PROMPTS_DIR"] = str(PERSONA_DIR / "prompts") # ============================================================================== # EMERGENCE GATE: TALK_ONLY vs FULL MODE # ============================================================================== try: from uatu_genesis_engine.agent_zero_integration.emergence_gate import EmergenceGate, GateState gate = EmergenceGate(storage_dir=str(PERSONA_DIR / "emergence_gate")) current_state = gate.get_state() if current_state == GateState.TALK_ONLY: os.environ["WORKSHOP_TALK_ONLY"] = "true" logger.info(f"EmergenceGate: TALK_ONLY mode (no code execution)") else: logger.info(f"EmergenceGate: {current_state.value} mode") except ImportError: logger.warning("EmergenceGate not available - defaulting to TALK_ONLY") os.environ["WORKSHOP_TALK_ONLY"] = "true" except Exception as e: logger.error(f"EmergenceGate error: {e}") # ============================================================================== # CONVEX STATE LOGGER: Black Box Recorder # ============================================================================== convex_logger = None try: from uatu_genesis_engine.agent_zero_integration.convex_state_logger import ConvexStateLogger # Initialize with local backup (Convex URL can be set via environment) convex_logger = ConvexStateLogger( convex_url=os.environ.get("CONVEX_URL"), api_key=os.environ.get("CONVEX_API_KEY"), enable_local_backup=True, local_backup_path=str(PERSONA_DIR / "state_logs") ) logger.info("ConvexStateLogger initialized - state persistence active") except ImportError: logger.warning("ConvexStateLogger not available - no state persistence") except Exception as e: logger.error(f"ConvexStateLogger error: {e}") # ============================================================================== # BOOT SEQUENCE # ============================================================================== def print_genesis_banner(): """Print the genesis banner for this digital person.""" print("=" * 60) print(f" GENESIS: {PERSONA_NAME}") print(f" Archetype: {ARCHETYPE}") print(f" Prompts: {PERSONA_DIR / 'prompts'}") print(f" Mode: {'TALK_ONLY' if os.environ.get('WORKSHOP_TALK_ONLY') else 'FULL'}") print("=" * 60) async def log_boot_event(): """Log the boot event to Convex.""" if convex_logger: await convex_logger.log_custom( entry_type="genesis_boot", data={ "persona": PERSONA_NAME, "archetype": ARCHETYPE, "mode": "TALK_ONLY" if os.environ.get("WORKSHOP_TALK_ONLY") else "FULL", "prompts_dir": str(PERSONA_DIR / "prompts") } ) def main(): """Main entry point.""" print_genesis_banner() # Log boot event if convex_logger: asyncio.run(log_boot_event()) # Agent Zero Profile Integration # This persona is installed as a native Agent Zero profile. # The prompts are at: agents/agent/prompts/ logger.info(f"{PERSONA_NAME} environment configured") logger.info("") logger.info("=" * 50) logger.info(" AGENT ZERO PROFILE INTEGRATION") logger.info("=" * 50) logger.info("") logger.info("To use this persona with Agent Zero:") logger.info("") logger.info(" 1. In Agent Zero settings, set:") logger.info(f" config.profile = '{PROFILE_NAME}'") logger.info("") logger.info(" 2. Or via environment variable:") logger.info(f" export AGENT_PROFILE={PROFILE_NAME}") logger.info("") logger.info(" 3. Then run Agent Zero from agent_zero_framework/:") logger.info(" python run_ui.py (web UI)") logger.info(" python main.py (CLI)") logger.info("") logger.info(f"Prompts location: agents/{PROFILE_NAME}/prompts/") logger.info("=" * 50) if __name__ == "__main__": main()