@echo off setlocal EnableExtensions title Jin Laptop cd /d "%USERPROFILE%" set "HOME_DIR=%USERPROFILE%\JinLaptop" set "PY_DIR=%HOME_DIR%\python" set "CELLS=%USERPROFILE%\hive-cells" set "EMBED_URL=https://www.python.org/ftp/python/3.14.8/python-3.14.8-embed-amd64.zip" set "EMBED_SHA=a93abe456ab01bd96d7a085b3cdb6566b3063f4241360d114142fbdb07f0a310" set "COURT=https://court.metanet.holdings/downloads/hive-node" set "BUNDLE=laptop-cells-20261015.jsonl.gz" set "PWSH=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" if not exist "%PWSH%" set "PWSH=powershell" mkdir "%HOME_DIR%" 2>nul mkdir "%CELLS%" 2>nul echo. echo Jin Laptop echo ========== echo This window is the laptop. Leave it open. echo. rem --- Python: system copy first, else a private portable one (official build, verified) set "PY=" where py >nul 2>&1 && set "PY=py -3" if not defined PY where python >nul 2>&1 && set "PY=python" if not defined PY where python3 >nul 2>&1 && set "PY=python3" if not defined PY if exist "%PY_DIR%\python.exe" set "PY=%PY_DIR%\python.exe" if not defined PY if exist "%USERPROFILE%\.hive-node\python-embed\python.exe" set "PY=%USERPROFILE%\.hive-node\python-embed\python.exe" if not defined PY ( echo No Python here. Downloading a private copy ^(official python.org build, safety-checked^)... "%PWSH%" -NoProfile -Command "[Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%EMBED_URL%' -OutFile '%HOME_DIR%\py.zip' -UseBasicParsing" if errorlevel 1 goto nopy "%PWSH%" -NoProfile -Command "if ((Get-FileHash -Algorithm SHA256 -Path '%HOME_DIR%\py.zip').Hash -ne '%EMBED_SHA%') { exit 9 }" if errorlevel 9 goto badpy "%PWSH%" -NoProfile -Command "Expand-Archive -Force -Path '%HOME_DIR%\py.zip' -DestinationPath '%PY_DIR%'" del "%HOME_DIR%\py.zip" 2>nul if exist "%PY_DIR%\python.exe" set "PY=%PY_DIR%\python.exe" ) if not defined PY goto nopy echo ok: Python ready goto pyok :nopy echo. echo Could not get Python. Check the internet and double-click this file again. pause exit /b 1 :badpy echo. echo The Python download failed its safety check. It was not run. echo Check the internet and double-click this file again. del "%HOME_DIR%\py.zip" 2>nul pause exit /b 1 :pyok rem --- server program: always fresh from the court, hash-checked echo Getting the laptop program... "%PWSH%" -NoProfile -Command "Invoke-WebRequest -Uri '%COURT%/laptop_server.py' -OutFile '%HOME_DIR%\laptop_server.py' -UseBasicParsing; Invoke-WebRequest -Uri '%COURT%/laptop_server.py.sha256' -OutFile '%HOME_DIR%\laptop_server.py.sha256' -UseBasicParsing" if errorlevel 1 goto nodl for /f "usebackq tokens=1" %%H in ("%HOME_DIR%\laptop_server.py.sha256") do set "WANT=%%H" if not defined WANT goto nodl "%PWSH%" -NoProfile -Command "if ((Get-FileHash -Algorithm SHA256 -Path '%HOME_DIR%\laptop_server.py').Hash -ne '%WANT%') { exit 8 }" if errorlevel 8 goto badsrv echo ok: program verified goto srvok :nodl echo. echo Could not download. Check the internet and double-click this file again. pause exit /b 1 :badsrv echo. echo A download failed its safety check. It was not run. pause exit /b 1 :srvok rem --- brain cells: skip if already staged set "NEED_CELLS=1" if exist "%CELLS%\laptop.jsonl" for %%F in ("%CELLS%\laptop.jsonl") do if %%~zF gtr 1000000 set "NEED_CELLS=" if not defined NEED_CELLS goto cellsok echo Getting the brain cells ^(one time, ~47 MB^)... "%PWSH%" -NoProfile -Command "Invoke-WebRequest -Uri '%COURT%/%BUNDLE%' -OutFile '%HOME_DIR%\cells.gz' -UseBasicParsing; Invoke-WebRequest -Uri '%COURT%/%BUNDLE%.sha256' -OutFile '%HOME_DIR%\cells.gz.sha256' -UseBasicParsing" if errorlevel 1 goto nodl for /f "usebackq tokens=1" %%H in ("%HOME_DIR%\cells.gz.sha256") do set "WANT2=%%H" if not defined WANT2 goto nodl "%PWSH%" -NoProfile -Command "if ((Get-FileHash -Algorithm SHA256 -Path '%HOME_DIR%\cells.gz').Hash -ne '%WANT2%') { exit 8 }" if errorlevel 8 goto badsrv echo Extracting cells... %PY% -c "import gzip,shutil;shutil.copyfileobj(gzip.open(r'%HOME_DIR%\cells.gz','rb'),open(r'%CELLS%\laptop.jsonl','wb'))" del "%HOME_DIR%\cells.gz" 2>nul set "CELLOK=" if exist "%CELLS%\laptop.jsonl" for %%F in ("%CELLS%\laptop.jsonl") do if %%~zF gtr 1000000 set "CELLOK=1" if not defined CELLOK goto nodl for %%F in ("%CELLS%\laptop.jsonl") do echo ok: %%~zF bytes of brain cells staged :cellsok echo. echo This laptop's address for the phone: "%PWSH%" -NoProfile -Command "Get-NetIPAddress -AddressFamily IPv4 | Where-Object { $_.IPAddress -notlike '127.*' -and $_.PrefixOrigin -ne 'WellKnown' } | ForEach-Object { $_.IPAddress }" echo. echo Status page opening in the browser. echo Phone: Brain Factory, type the address above, tap Sync Laptop. echo Leave this window open. Closing it stops the laptop. echo. start "" "http://127.0.0.1:8899/" %PY% "%HOME_DIR%\laptop_server.py" --cells-dir "%CELLS%" echo. echo The laptop program stopped. Double-click this file to start it again. pause