Ports the ncp PATH work from upstream. Registering ncp as a shell-profile function failed three ways on Windows: the default Restricted execution policy blocks the profile itself, profiles don't exist outside PowerShell (cmd, Win+R, Task Scheduler), and the self-elevating installer writes the admin's profile. Windows now ships management/ncp.cmd and the installer appends management\ to the Machine PATH via [Environment]::SetEnvironmentVariable -- never setx, which truncates PATH at 1024 chars. A .cmd is exempt from the execution policy. Linux symlinks /usr/local/bin/ncp -> management/nexus-cli.sh, falling back to the old .bashrc function when sudo is unavailable. Also renames requirements-wsl.txt to requirements-windows.txt and purges stale WSL references, including vite.config.js's dev-server comment and controlpanel.py's "Check WSLg." error string. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
69 lines
3.1 KiB
PowerShell
69 lines
3.1 KiB
PowerShell
# NexusOS launcher for Windows (native, no Vite).
|
|
#
|
|
# Single-process app: the backend on :8000 serves the built web UI itself, so
|
|
# this starts only the memory service + backend, then opens the UI as an Edge
|
|
# app window. The AI (Ollama) does NOT auto-start - turn it on from the UI's
|
|
# Start AI button. Closing the app window stops the services.
|
|
#
|
|
# Right-click -> Run with PowerShell (or: powershell -File launch_nexus.ps1)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$Root = $PSScriptRoot
|
|
$Py = Join-Path $Root "Promethean\Scripts\python.exe"
|
|
if (-not (Test-Path $Py)) { $Py = "python" } # fall back to PATH
|
|
|
|
$Runtime = Join-Path $Root "runtime"
|
|
$Logs = Join-Path $Runtime "logs"
|
|
New-Item -ItemType Directory -Force -Path $Runtime, $Logs | Out-Null
|
|
|
|
function Start-Svc($log, $argList) {
|
|
return Start-Process -FilePath $Py -ArgumentList $argList `
|
|
-WorkingDirectory $Root -WindowStyle Hidden -PassThru `
|
|
-RedirectStandardOutput $log -RedirectStandardError "$log.err"
|
|
}
|
|
|
|
Write-Host "Starting NexusOS..." -ForegroundColor Cyan
|
|
# Only start a service if its port is free. If it's already listening (a prior
|
|
# launch, or started by hand) reuse it instead of spawning a duplicate that
|
|
# fails to bind and stalls the readiness wait below.
|
|
$memory = $null
|
|
if (-not (Get-NetTCPConnection -LocalPort 8001 -State Listen -ErrorAction SilentlyContinue)) {
|
|
$memory = Start-Svc (Join-Path $Runtime "memory.log") @("-m","uvicorn","synapse.memory.service:app","--host","127.0.0.1","--port","8001")
|
|
}
|
|
$backend = $null
|
|
if (-not (Get-NetTCPConnection -LocalPort 8000 -State Listen -ErrorAction SilentlyContinue)) {
|
|
$backend = Start-Svc (Join-Path $Runtime "backend.log") @("-m","uvicorn","synapse.main:sio_app","--host","127.0.0.1","--port","8000")
|
|
}
|
|
|
|
# Wait for the backend to answer on :8000.
|
|
$ok = $false
|
|
foreach ($i in 1..30) {
|
|
try {
|
|
Invoke-WebRequest -UseBasicParsing -Uri "http://localhost:8000/status" -TimeoutSec 2 | Out-Null
|
|
$ok = $true; break
|
|
} catch { Start-Sleep -Seconds 1 }
|
|
}
|
|
if (-not $ok) {
|
|
Write-Host "Backend did not come up - check runtime\backend.log" -ForegroundColor Red
|
|
}
|
|
|
|
# Open the UI in a native window (pywebview / WebView2) - no browser, no Edge
|
|
# profile cold-start. bin\nexus_window.py blocks until the window is closed and
|
|
# falls back to the default browser if WebView2 is unavailable.
|
|
$app = Start-Process -FilePath $Py -ArgumentList @((Join-Path $Root "bin\nexus_window.py")) `
|
|
-WorkingDirectory $Root -PassThru
|
|
|
|
Write-Host "NexusOS is running at http://localhost:8000 (AI is off - start it in the UI)" -ForegroundColor Green
|
|
# Block until the app window (or a service we started) exits, so this process
|
|
# stays alive to hold and later stop the services. No blind Read-Host: the
|
|
# shortcut runs hidden, where a prompt no one can answer would hang forever.
|
|
if ($app) { $app.WaitForExit() }
|
|
elseif ($backend) { $backend.WaitForExit() }
|
|
elseif ($memory) { $memory.WaitForExit() }
|
|
|
|
# Shut the services down.
|
|
Write-Host "Stopping NexusOS..." -ForegroundColor Cyan
|
|
foreach ($p in @($backend, $memory)) {
|
|
if ($p -and -not $p.HasExited) { Stop-Process -Id $p.Id -Force -ErrorAction SilentlyContinue }
|
|
}
|