Router that virtually distributes inference across connected devices in the home.
Go
@REM SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
@REM SPDX-License-Identifier: Apache-2.0
@echo off
setlocal
set ROOT=%~dp0
set BIN_OUT=%ROOT%build\bin
set VERSIONS_FILE=%ROOT%versions.json
REM jq is required to parse versions.json. PowerShell startup added ~3s of
REM dead time per build; jq is ~200x faster. Fail fast with a useful hint.
where jq >nul 2>&1
if errorlevel 1 (
echo ERROR: jq not found in PATH.
echo Install it with one of:
echo winget install jqlang.jq
echo choco install jq
echo scoop install jq
echo or grab a binary from https://jqlang.org/download/
endlocal
exit /b 1
)
echo ========================================
echo Reading versions from %VERSIONS_FILE%
echo ========================================
echo.
if not exist "%VERSIONS_FILE%" (
echo ERROR: versions.json not found at %VERSIONS_FILE%
endlocal
exit /b 1
)
REM Parse versions.json with jq. We use --arg to pass each component key as
REM a string variable, which sidesteps cmd's hostility toward embedded
REM double quotes inside the jq filter (component keys contain hyphens, so
REM bare .components.nvpair-ui-broker would parse as subtraction).
for /f "delims=" %%V in ('jq -r ".services" "%VERSIONS_FILE%"') do set "V_SERVICES=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-proxy" ".components[$k]" "%VERSIONS_FILE%"') do set "V_PROXY=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-node-info" ".components[$k]" "%VERSIONS_FILE%"') do set "V_NINFO=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-node-scanner" ".components[$k]" "%VERSIONS_FILE%"') do set "V_NSCAN=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-manual-nodes" ".components[$k]" "%VERSIONS_FILE%"') do set "V_MNODES=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-workload-manager" ".components[$k]" "%VERSIONS_FILE%"') do set "V_WLMGR=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-errors" ".components[$k]" "%VERSIONS_FILE%"') do set "V_ERRORS=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-node-settings" ".components[$k]" "%VERSIONS_FILE%"') do set "V_NSETTINGS=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-ui-broker" ".components[$k]" "%VERSIONS_FILE%"') do set "V_BROKER=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-engine-manager" ".components[$k]" "%VERSIONS_FILE%"') do set "V_ENGMGR=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-cluster-manager" ".components[$k]" "%VERSIONS_FILE%"') do set "V_CLUMGR=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-job-scheduler" ".components[$k]" "%VERSIONS_FILE%"') do set "V_SCHED=%%V"
for /f "delims=" %%V in ('jq -r --arg k "nvpair-tui" ".components[$k]" "%VERSIONS_FILE%"') do set "V_TUI=%%V"
REM The release version, which lives in desktop/package.json rather than here.
REM nvpair-tui's update notice compares this against the published release tag,
REM so it is the only one of PAIR's three numbers that can answer "is there a
REM newer PAIR than mine". The services suite version is currently the larger
REM number, so stamping that instead would be silently wrong: every check would
REM conclude this build is ahead of the feed and say nothing.
set "PACKAGE_JSON=%ROOT%..\desktop\package.json"
for /f "delims=" %%V in ('jq -r ".version" "%PACKAGE_JSON%"') do set "V_RELEASE=%%V"
if "%V_SERVICES%"=="" (
echo ERROR: failed to parse versions.json
endlocal
exit /b 1
)
if "%V_RELEASE%"=="" (
echo ERROR: failed to read .version from %PACKAGE_JSON%
echo nvpair-tui's update notice is stamped from the release version.
endlocal
exit /b 1
)
echo release = %V_RELEASE%
echo services = %V_SERVICES%
echo nvpair-proxy = %V_PROXY%
echo nvpair-node-info = %V_NINFO%
echo nvpair-node-scanner = %V_NSCAN%
echo nvpair-manual-nodes = %V_MNODES%
echo nvpair-workload-mgr = %V_WLMGR%
echo nvpair-errors = %V_ERRORS%
echo nvpair-node-settings = %V_NSETTINGS%
echo nvpair-ui-broker = %V_BROKER%
echo nvpair-engine-manager= %V_ENGMGR%
echo nvpair-cluster-mgr = %V_CLUMGR%
echo nvpair-job-scheduler = %V_SCHED%
echo nvpair-tui = %V_TUI%
echo.
echo ========================================
echo Building all components
echo ========================================
echo.
echo [1/13] Building nvpair-proxy (v%V_PROXY%)...
cd /d "%ROOT%nvpair-proxy"
go build -ldflags "-X main.Version=%V_PROXY%" -o nvpair-proxy.exe . || goto :fail
echo OK
echo [2/13] Building nvpair-node-info (v%V_NINFO%)...
cd /d "%ROOT%nvpair-node-info"
go build -ldflags "-X main.Version=%V_NINFO%" -o nvpair-node-info.exe . || goto :fail
echo OK
echo [3/13] Building nvpair-node-scanner (v%V_NSCAN%)...
cd /d "%ROOT%nvpair-node-scanner"
go build -ldflags "-X main.Version=%V_NSCAN%" -o nvpair-node-scanner.exe . || goto :fail
echo OK
echo [4/13] Building nvpair-manual-nodes (v%V_MNODES%)...
cd /d "%ROOT%nvpair-manual-nodes"
go build -ldflags "-X main.Version=%V_MNODES%" -o nvpair-manual-nodes.exe . || goto :fail
echo OK
echo [5/13] Building nvpair-workload-manager (v%V_WLMGR%)...
cd /d "%ROOT%nvpair-workload-manager"
go build -ldflags "-X main.Version=%V_WLMGR%" -o nvpair-workload-manager.exe . || goto :fail
echo OK
echo [6/13] Building nvpair-errors (v%V_ERRORS%)...
cd /d "%ROOT%nvpair-errors"
go build -ldflags "-X main.Version=%V_ERRORS%" -o nvpair-errors.exe . || goto :fail
echo OK
echo [7/13] Building nvpair-engine-manager (v%V_ENGMGR%)...
cd /d "%ROOT%nvpair-engine-manager"
go build -ldflags "-X main.Version=%V_ENGMGR%" -o nvpair-engine-manager.exe . || goto :fail
echo OK
echo [8/13] Building nvpair-node-settings (v%V_NSETTINGS%)...
cd /d "%ROOT%nvpair-node-settings"
go build -ldflags "-X main.Version=%V_NSETTINGS%" -o nvpair-node-settings.exe . || goto :fail
echo OK
echo [9/13] Building nvpair-ui-broker (v%V_BROKER%)...
cd /d "%ROOT%nvpair-ui-broker"
go build -ldflags "-X main.Version=%V_BROKER%" -o nvpair-ui-broker.exe . || goto :fail
echo OK
echo [10/13] Building nvpair-cluster-manager (v%V_CLUMGR%)...
cd /d "%ROOT%nvpair-cluster-manager"
go build -ldflags "-X main.Version=%V_CLUMGR%" -o nvpair-cluster-manager.exe . || goto :fail
echo OK
echo [11/13] Building nvpair-job-scheduler (v%V_SCHED%)...
cd /d "%ROOT%nvpair-job-scheduler"
go build -ldflags "-X main.Version=%V_SCHED%" -o nvpair-job-scheduler.exe . || goto :fail
echo OK
REM nvpair-tui also carries the release version: that is what the update notice
REM compares against the published tag, and its own component version means
REM nothing to that comparison. A -X on a symbol path that does not exist fails
REM silently, so verify the stamp rather than assuming it.
echo [12/13] Building nvpair-tui (v%V_TUI%)...
cd /d "%ROOT%nvpair-tui"
go build -ldflags "-X main.Version=%V_TUI% -X nvpair-tui/ui.ReleaseVersion=%V_RELEASE%" -o nvpair-tui.exe . || goto :fail
echo OK
REM inference-dispatcher is built here but is not a worker: it speaks no
REM JSON-RPC, nothing supervises it, and it is deliberately absent from
REM versions.json. It is an ordinary HTTP client the Inference Demo spawns once
REM per request, built here because the terminal interface runs the same demo
REM and ships from this bundle. Its module lives outside this tree, at the
REM monorepo root, for the same reason: it is not a service.
echo [13/13] Building inference-dispatcher (v%V_SERVICES%)...
if not exist "%ROOT%..\scripts\inference-dispatcher" (
echo ERROR: %ROOT%..\scripts\inference-dispatcher not found. 1>&2
echo The Inference Demo client lives at scripts\inference-dispatcher 1>&2
echo in the monorepo root; this bundle cannot be built without it. 1>&2
goto :fail
)
cd /d "%ROOT%..\scripts\inference-dispatcher"
go build -ldflags "-X main.Version=%V_SERVICES%" -o inference-dispatcher.exe . || goto :fail
echo OK
echo.
echo ========================================
echo Copying binaries to %BIN_OUT%
echo ========================================
echo.
REM Start from an empty bin dir so a binary from an earlier build (a component
REM that doesn't exist at this commit) can't linger and ride into the installer
REM as a stale stray.
if exist "%BIN_OUT%" rmdir /s /q "%BIN_OUT%"
mkdir "%BIN_OUT%"
copy /y "%ROOT%nvpair-proxy\nvpair-proxy.exe" "%BIN_OUT%\nvpair-proxy.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-node-info\nvpair-node-info.exe" "%BIN_OUT%\nvpair-node-info.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-node-scanner\nvpair-node-scanner.exe" "%BIN_OUT%\nvpair-node-scanner.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-manual-nodes\nvpair-manual-nodes.exe" "%BIN_OUT%\nvpair-manual-nodes.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-workload-manager\nvpair-workload-manager.exe" "%BIN_OUT%\nvpair-workload-manager.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-errors\nvpair-errors.exe" "%BIN_OUT%\nvpair-errors.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-engine-manager\nvpair-engine-manager.exe" "%BIN_OUT%\nvpair-engine-manager.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-node-settings\nvpair-node-settings.exe" "%BIN_OUT%\nvpair-node-settings.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-ui-broker\nvpair-ui-broker.exe" "%BIN_OUT%\nvpair-ui-broker.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-cluster-manager\nvpair-cluster-manager.exe" "%BIN_OUT%\nvpair-cluster-manager.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-job-scheduler\nvpair-job-scheduler.exe" "%BIN_OUT%\nvpair-job-scheduler.exe" >nul || goto :fail
copy /y "%ROOT%nvpair-tui\nvpair-tui.exe" "%BIN_OUT%\nvpair-tui.exe" >nul || goto :fail
REM Beside the binaries it is not one of: nvpair-tui resolves the broker next to
REM its own executable, and the demo finds this the same way.
copy /y "%ROOT%..\scripts\inference-dispatcher\inference-dispatcher.exe" "%BIN_OUT%\inference-dispatcher.exe" >nul || goto :fail
echo.
echo ========================================
echo Build complete (services v%V_SERVICES%)
echo ========================================
echo.
echo Proxy: %BIN_OUT%\nvpair-proxy.exe
echo Node Info: %BIN_OUT%\nvpair-node-info.exe
echo Node Scanner: %BIN_OUT%\nvpair-node-scanner.exe
echo Manual Nodes: %BIN_OUT%\nvpair-manual-nodes.exe
echo Workload Mgr: %BIN_OUT%\nvpair-workload-manager.exe
echo Errors: %BIN_OUT%\nvpair-errors.exe
echo Engine Mgr: %BIN_OUT%\nvpair-engine-manager.exe
echo Node Settings: %BIN_OUT%\nvpair-node-settings.exe
echo UI Broker: %BIN_OUT%\nvpair-ui-broker.exe
echo Cluster Mgr: %BIN_OUT%\nvpair-cluster-manager.exe
echo Job Scheduler: %BIN_OUT%\nvpair-job-scheduler.exe
echo TUI: %BIN_OUT%\nvpair-tui.exe
echo.
REM Surface the services version to any caller (e.g. installer_build.bat) so
REM they don't have to re-parse versions.json.
endlocal & set "NVPAIR_SERVICES_VERSION=%V_SERVICES%"
exit /b 0
:fail
echo.
echo BUILD FAILED
echo.
endlocal
exit /b 1