File size: 5,021 Bytes
17afe48
 
 
15fec87
17afe48
 
 
 
15fec87
 
 
 
17afe48
 
 
 
 
 
 
 
 
 
 
 
 
 
15fec87
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17afe48
 
 
15fec87
17afe48
 
 
 
 
15fec87
 
 
17afe48
 
 
 
 
15fec87
 
 
 
 
 
 
 
 
 
17afe48
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/bin/bash

echo "πŸ”„ FastAPI Django Main Live - Post Start Setup..."
echo "🧠 AI GUI System - PostStart Initialization"

# Ensure Rust is in PATH
export PATH="$HOME/.cargo/bin:$PATH"

# Set environment variables for GUI
export DISPLAY=:1
export XVFB_RES=1920x1080x24

# Check if all dependencies are installed
echo "πŸ” Checking dependencies..."
python3 -c "
try:
    import gradio
    import fastapi
    import open_interpreter
    import sqlite3
    print('βœ… All core dependencies available')
except ImportError as e:
    print(f'❌ Missing dependency: {e}')
    print('Run: pip install -r requirements.txt')
"

# Start GUI services - Using Persistent Docker Desktop
echo "πŸ–₯️ Initializing AI Persistent GUI Desktop..."

# Check if docker is available
if command -v docker &> /dev/null; then
    echo "🐳 Docker is available - Starting persistent GUI environment..."
    
    # Start the persistent GUI environment
    if [ -f "ai_persistent_gui_manager.py" ]; then
        echo "πŸš€ Starting AI Persistent GUI Manager..."
        python3 ai_persistent_gui_manager.py &
        sleep 5
    else
        echo "⚠️ AI Persistent GUI Manager not found, using fallback method..."
        
        # Fallback: Direct docker-compose
        if [ -f "docker-compose-persistent-gui.yml" ]; then
            echo "🐳 Starting GUI with docker-compose..."
            docker-compose -f docker-compose-persistent-gui.yml up -d
            sleep 5
        fi
    fi
else
    echo "⚠️ Docker not available, using local GUI services..."
    
    # Fallback to local GUI services
    # Check if X server is running
    if ! pgrep -x "Xvfb" > /dev/null; then
        echo "πŸ–₯️ Starting Xvfb..."
        Xvfb :1 -screen 0 1920x1080x24 &
        sleep 2
    fi

    # Check if desktop environment is running
    if ! pgrep -x "fluxbox" > /dev/null; then
        echo "πŸ–₯️ Starting Fluxbox desktop..."
        DISPLAY=:1 fluxbox &
        sleep 2
    fi

    # Try to start VNC and noVNC
    if ! pgrep -x "x11vnc" > /dev/null; then
        echo "πŸ“Ί Starting VNC server..."
        DISPLAY=:1 x11vnc -display :1 -forever -passwd copilot -rfbport 5901 -shared -bg
        sleep 2
    fi
    
    # Try websockify for noVNC
    if ! pgrep -f "websockify" > /dev/null && command -v websockify &> /dev/null; then
        echo "🌐 Starting noVNC with websockify..."
        websockify --web=/usr/share/novnc/ 6080 localhost:5901 &
        sleep 2
    fi
fi

# Restore AI memory
echo "🧠 Restoring AI Memory..."

# Check if AI memory restoration script exists
if [ -f "ai_memory_restoration.py" ]; then
    echo "🧠 Running AI memory restoration..."
    python3 ai_memory_restoration.py
else
    echo "⚠️ AI memory restoration script not found"
fi

# Initialize AI memory system
echo "🧠 Initializing AI Memory System..."
python3 -c "
from ai_memory_system import ai_memory
print('🧠 AI Memory System Status:')
print(ai_memory.generate_memory_summary())
" 2>/dev/null || echo "⚠️ AI Memory System not yet available"

# Create directories for AI operations
echo "πŸ“ Setting up AI directories..."
mkdir -p /ai-memory/screenshots
mkdir -p /ai-memory/downloads
mkdir -p /ai-memory/temp
mkdir -p /gui-data/profiles
mkdir -p /browser-data/downloads

# Set permissions
chmod -R 755 /ai-memory 2>/dev/null || true
chmod -R 755 /gui-data 2>/dev/null || true
chmod -R 755 /browser-data 2>/dev/null || true

# Start browser environment
echo "🌐 Checking browser environment..."
if [ ! -f "/browser-data/.browser-initialized" ]; then
    echo "🌐 Initializing browser environment..."
    mkdir -p /browser-data/firefox-profile
    touch /browser-data/.browser-initialized
fi

# Display helpful information
echo ""
echo "πŸš€ FastAPI Django Main Live is ready!"
echo "βœ… AI GUI System startup complete!"
echo ""
echo "πŸ“± Available services:"
echo "  β€’ Main App: http://localhost:7860"
echo "  β€’ Test Manager: http://localhost:7861" 
echo "  β€’ Debug Port: 5678"
echo "  β€’ AI GUI Desktop (Persistent): http://localhost:6081"
echo "  β€’ AI GUI Desktop (Fallback): http://localhost:6080"
echo "  β€’ VNC Direct Access: localhost:5902 (Persistent) / localhost:5901 (Fallback)"
echo ""
echo "πŸ› οΈ Quick commands:"
echo "  β€’ Start main app: python3 app.py"
echo "  β€’ Start debug mode: python3 app_debug_server.py"
echo "  β€’ Test prompt manager: python3 test_prompt_manager.py"
echo "  β€’ Test AI GUI system: python3 ai_gui_system.py"
echo ""
echo "πŸ“Š System Status:"
echo "   - X Server: $(pgrep -x Xvfb > /dev/null && echo 'βœ… Running' || echo '❌ Not running')"
echo "   - Desktop: $(pgrep -x fluxbox > /dev/null && echo 'βœ… Running' || echo '❌ Not running')"
echo "   - noVNC: $(pgrep -f novnc > /dev/null && echo 'βœ… Running' || echo '❌ Not running')"
echo "   - AI Memory: $([ -d '/ai-memory' ] && echo 'βœ… Available' || echo '❌ Not available')"
echo ""
echo "πŸ” VNC Password: copilot"
echo "🎯 30-Year Dream Status: SYSTEM READY FOR AI GUI AUTOMATION!"
echo ""