File size: 4,838 Bytes
dff1e71
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/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()