@echo off
echo 🚀 Starting Cortex Agent Node...

if exist agent-node.exe (
    echo [*] Binary executable detected. Launching...
    agent-node.exe
    exit /b %errorlevel%
)

if exist src\agent_node (
    echo [*] Source code detected. Checking environment...
    python --version >nul 2>&1
    if %errorlevel% neq 0 (
        echo ❌ Error: python not found. Please install Python 3.10+.
        pause
        exit /b 1
    )
    if not exist .venv (
        echo [*] Creating virtual environment...
        python -m venv .venv
    )
    call .venv\Scripts\activate
    if exist requirements.txt (
        echo [*] Syncing dependencies...
        pip install --upgrade pip --quiet
        pip install -r requirements.txt --quiet
    )
    echo ✅ Environment ready. Booting node...
    python src\agent_node\main.py
) else (
    echo ❌ Error: No executable ('agent-node.exe') or source code ('src\agent_node\') found.
    pause
    exit /b 1
)
