# Shadow-Gate Windows Client Installer # Downloads and installs the AI client to %LOCALAPPDATA%\ai-client $ErrorActionPreference = "Stop" # Script parameters - can be overridden before running if (-not $Server) { $Server = "" } if (-not $Token) { $Token = "" } function Get-DefaultServer { if ($env:SHADOWGATE_SERVER) { return $env:SHADOWGATE_SERVER } # Will be set by the caller when downloaded from server return "https://projectveil.co" } $server = if ($Server) { $Server } else { Get-DefaultServer } $root = Join-Path $env:LOCALAPPDATA "ai-client" $sandbox = Join-Path $env:USERPROFILE "ai_sandbox" Write-Host "Shadow-Gate Windows Client Installer" -ForegroundColor Cyan Write-Host "======================================" -ForegroundColor Cyan Write-Host "" Write-Host "Server: $server" -ForegroundColor Yellow Write-Host "Install directory: $root" -ForegroundColor Yellow Write-Host "" # Check Python $pythonInstalled = $false try { $pythonVersion = python --version 2>&1 if ($pythonVersion -match "Python 3\.") { Write-Host "[OK] Python found: $pythonVersion" -ForegroundColor Green $pythonInstalled = $true } } catch { Write-Host "[WARNING] Python 3 not found" -ForegroundColor Yellow } if (-not $pythonInstalled) { Write-Host "[ERROR] Python 3.8+ required. Install from: https://www.python.org/downloads/" -ForegroundColor Red Write-Host " Make sure to check 'Add Python to PATH' during installation" -ForegroundColor Yellow exit 1 } # Create directories Write-Host "" Write-Host "Creating directories..." -ForegroundColor Cyan New-Item -Force -ItemType Directory -Path $root | Out-Null New-Item -Force -ItemType Directory -Path (Join-Path $root "data") | Out-Null New-Item -Force -ItemType Directory -Path (Join-Path $root "logs") | Out-Null New-Item -Force -ItemType Directory -Path (Join-Path $root "shared") | Out-Null New-Item -Force -ItemType Directory -Path $sandbox | Out-Null # Install Python dependencies Write-Host "Installing Python dependencies..." -ForegroundColor Cyan python -m pip install --quiet --upgrade pip python -m pip install --quiet websockets pynacl # Download client files Write-Host "Downloading client files..." -ForegroundColor Cyan $clientFile = Join-Path $root "ai_client.py" $executorsFile = Join-Path $root "executors.py" $configFile = Join-Path $root "client.config.json" # Download ai_client.py try { $clientUrl = "$server/download/ai_client.py" Write-Host " - Downloading ai_client.py..." -ForegroundColor Gray Invoke-WebRequest -UseBasicParsing -Uri $clientUrl -OutFile $clientFile Write-Host " [OK] ai_client.py" -ForegroundColor Green } catch { Write-Host " [ERROR] Failed to download ai_client.py: $_" -ForegroundColor Red Write-Host " You may need to manually copy the client files." -ForegroundColor Yellow } # Download executors.py try { $executorsUrl = "$server/download/executors.py" Write-Host " - Downloading executors.py..." -ForegroundColor Gray Invoke-WebRequest -UseBasicParsing -Uri $executorsUrl -OutFile $executorsFile Write-Host " [OK] executors.py" -ForegroundColor Green } catch { Write-Host " [ERROR] Failed to download executors.py: $_" -ForegroundColor Red Write-Host " You may need to manually copy the executors file." -ForegroundColor Yellow } # Create config $cfg = @{ server = $server device_name = $env:COMPUTERNAME token = $Token log_path = (Join-Path $root "logs" "client.log") sandbox_path = $sandbox } $cfg | ConvertTo-Json -Depth 4 | Set-Content -Encoding UTF8 $configFile Write-Host "" Write-Host "======================================" -ForegroundColor Green Write-Host "Installation complete!" -ForegroundColor Green Write-Host "======================================" -ForegroundColor Green Write-Host "" Write-Host "Installation directory: $root" -ForegroundColor Cyan Write-Host "Sandbox directory: $sandbox" -ForegroundColor Cyan Write-Host "" if ($Token) { Write-Host "Pairing with token..." -ForegroundColor Yellow Push-Location $root python ai_client.py pair --token $Token --server $server Pop-Location Write-Host "" Write-Host "To run the client:" -ForegroundColor Cyan Write-Host " cd `"$root`"" -ForegroundColor White Write-Host " python ai_client.py run" -ForegroundColor White } else { Write-Host "Next steps:" -ForegroundColor Yellow Write-Host "1. Get a pairing token from the Shadow-Gate dashboard" -ForegroundColor White Write-Host "2. Run pairing:" -ForegroundColor White Write-Host " cd `"$root`"" -ForegroundColor White Write-Host " python ai_client.py pair --token YOUR_TOKEN --server $server" -ForegroundColor White Write-Host "3. Start the client:" -ForegroundColor White Write-Host " python ai_client.py run" -ForegroundColor White } Write-Host ""