@echo off
setlocal
title Make Agent - Local StockX Setup

set "SETUP_FILE=%TEMP%\make-agent-stockx-setup.ps1"
echo Downloading the Make Agent local setup from your server...
powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -Command "$ProgressPreference='SilentlyContinue'; Invoke-WebRequest -UseBasicParsing -Uri 'https://make-agent.ltz88.cn/ui/install-local-stockx-runner.ps1' -OutFile '%SETUP_FILE%'"
if errorlevel 1 goto :failed

powershell.exe -NoLogo -NoProfile -ExecutionPolicy Bypass -File "%SETUP_FILE%"
if errorlevel 1 goto :failed

echo.
echo Setup complete. Return to Make Agent and click Connect this computer.
echo If the browser asks for local network access, choose Allow.
pause
exit /b 0

:failed
echo.
echo Setup did not complete. Keep this window open and share the error shown above.
pause
exit /b 1
