@echo off
setlocal EnableExtensions EnableDelayedExpansion

echo ================================
echo MindExec Local Bridge
echo ================================
echo.

cd /d "%~dp0"

if "%WORKSPACE_PATH%"=="" (
    for %%I in ("%~dp0..") do set "WORKSPACE_PATH=%%~fI"
)

if "%BRIDGE_PORT%"=="" (
    set "BRIDGE_PORT=5167"
)

if not exist "node_modules" (
    echo Installing dependencies...
    npm install
    echo.
)

echo Starting bridge server...
echo Workspace: %WORKSPACE_PATH%
echo Port: %BRIDGE_PORT%
echo.
node launch-bridge.cjs

pause
goto :eof
