#!/bin/bash # Launch Complete The-Tired-AGI System # Gossip Service + Frontend + Chat Interface set -e SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" AGI_HOME="$(dirname "$SCRIPT_DIR")" FRONTEND_DIR="$AGI_HOME/frontend" GOSSIP_DIR="$AGI_HOME/gossip" CORE_DIR="$AGI_HOME/core" echo "╔════════════════════════════════════════════════════════╗" echo "║ 🧠 The-Tired-AGI Complete System Launcher ║" echo "╚════════════════════════════════════════════════════════╝" echo "" # Create logs directory mkdir -p "$AGI_HOME/logs" # Step 1: Build/check gossip service echo "📦 Step 1: Gossip Service" if [ ! -f "$GOSSIP_DIR/gossipd" ]; then echo " Building gossip service..." cd "$GOSSIP_DIR" go build -o gossipd main.go echo " ✅ Built" else echo " ✅ Already built" fi # Step 2: Build/check frontend server echo "📦 Step 2: Frontend Server" if [ ! -f "$FRONTEND_DIR/frontend_server" ]; then echo " Building frontend server..." cd "$FRONTEND_DIR" go build -o frontend_server server.go echo " ✅ Built" else echo " ✅ Already built" fi # Step 3: Build/check agi_chat echo "📦 Step 3: Conversational Interface" if [ ! -f "$CORE_DIR/build/bin/agi_chat" ]; then echo " Building agi_chat..." cd "$CORE_DIR" mkdir -p build cd build cmake .. -DCMAKE_BUILD_TYPE=Release make -j$(nproc) agi_chat echo " ✅ Built" else echo " ✅ Already built" fi echo "" echo "╔════════════════════════════════════════════════════════╗" echo "║ 🚀 Starting Services ║" echo "╚════════════════════════════════════════════════════════╝" echo "" # Start gossip service if ! curl -s -m 2 http://localhost:8008/stats > /dev/null 2>&1; then echo "🌐 Starting Gossip Service (port 8008)..." cd "$GOSSIP_DIR" nohup ./gossipd > "$AGI_HOME/logs/gossip.log" 2>&1 & GOSSIP_PID=$! echo " PID: $GOSSIP_PID" echo " Log: $AGI_HOME/logs/gossip.log" sleep 2 # Verify it started if curl -s -m 2 http://localhost:8008/stats > /dev/null 2>&1; then echo " ✅ Running" else echo " ❌ Failed to start" exit 1 fi else echo "🌐 Gossip Service already running" fi # Start frontend server if ! curl -s -m 2 http://localhost:3000 > /dev/null 2>&1; then echo "🎨 Starting Frontend Server (port 3000)..." cd "$FRONTEND_DIR" nohup ./frontend_server > "$AGI_HOME/logs/frontend.log" 2>&1 & FRONTEND_PID=$! echo " PID: $FRONTEND_PID" echo " Log: $AGI_HOME/logs/frontend.log" sleep 1 echo " ✅ Running" else echo "🎨 Frontend Server already running" fi echo "" echo "╔════════════════════════════════════════════════════════╗" echo "║ ✅ System Ready ║" echo "╚════════════════════════════════════════════════════════╝" echo "" echo " 🌐 Frontend Dashboard: http://localhost:3000" echo " 📡 Gossip API: http://localhost:8008/stats" echo " 💬 Chat Interface: $CORE_DIR/build/bin/agi_chat" echo "" echo "Commands:" echo " → Open dashboard: xdg-open http://localhost:3000" echo " → Chat with AGI: $CORE_DIR/build/bin/agi_chat" echo " → View logs: tail -f $AGI_HOME/logs/*.log" echo " → Stop services: pkill -f gossipd && pkill -f frontend_server" echo "" # Get current swarm status echo "Current Swarm Status:" curl -s http://localhost:8008/stats | sed 's/^/ /' echo "" echo "Press Enter to open dashboard in browser, or Ctrl+C to exit" read -r # Try to open browser if command -v xdg-open > /dev/null; then xdg-open http://localhost:3000 elif command -v open > /dev/null; then open http://localhost:3000 else echo "Please open http://localhost:3000 in your browser" fi