# AppShip Studio agent — install (or update) and start, for Windows. No admin rights needed. # irm https://bestaso.app/agent/install.ps1 | iex # Everything goes to %USERPROFILE%\.appship-studio-agent: a private Node.js if yours is missing or older than 22, # and the agent. It connects Studio on the web (https://bestaso.app/app/) to the projects and keys on this computer and # listens on 127.0.0.1 only. Remove it any time by deleting that folder. $ErrorActionPreference = 'Stop' $ProgressPreference = 'SilentlyContinue' $Site = 'https://bestaso.app' $Dir = Join-Path $env:USERPROFILE '.appship-studio-agent' New-Item -ItemType Directory -Force -Path (Join-Path $Dir 'bin') | Out-Null # 1. Node.js 22+: yours, or the official build downloaded once (checked against nodejs.org's checksums). $Node = $null $sys = Get-Command node -ErrorAction SilentlyContinue if ($sys -and [int](& $sys.Source -p "process.versions.node.split('.')[0]") -ge 22) { $Node = $sys.Source } elseif (Test-Path (Join-Path $Dir 'node\node.exe')) { $Node = Join-Path $Dir 'node\node.exe' } else { $arch = if ($env:PROCESSOR_ARCHITECTURE -eq 'ARM64') { 'arm64' } else { 'x64' } Write-Host 'Downloading Node.js 22 (one time, about 30 MB)...' $base = 'https://nodejs.org/dist/latest-v22.x' $sums = (Invoke-WebRequest "$base/SHASUMS256.txt" -UseBasicParsing).Content -split "\r?\n" $line = $sums | Where-Object { $_ -match "-win-$arch\.zip$" } | Select-Object -First 1 if (-not $line) { throw "No Node.js build for win-$arch." } $want, $file = ($line -split '\s+') $zip = Join-Path $env:TEMP $file Invoke-WebRequest "$base/$file" -OutFile $zip -UseBasicParsing if ((Get-FileHash $zip -Algorithm SHA256).Hash.ToLower() -ne $want) { throw 'Node.js download did not match its checksum.' } $tmp = Join-Path $env:TEMP 'appship-node' Remove-Item -Recurse -Force $tmp -ErrorAction SilentlyContinue Expand-Archive $zip -DestinationPath $tmp Remove-Item -Recurse -Force (Join-Path $Dir 'node') -ErrorAction SilentlyContinue Move-Item (Get-ChildItem $tmp | Select-Object -First 1).FullName (Join-Path $Dir 'node') Remove-Item $zip $Node = Join-Path $Dir 'node\node.exe' } $NodeDir = Split-Path $Node $Npm = Join-Path $NodeDir 'npm.cmd' # 2. The agent package, from https://bestaso.app (only when a newer one is published). $latest = (Invoke-WebRequest "$Site/agent/version.txt" -UseBasicParsing).Content.Trim() $verFile = Join-Path $Dir 'version.txt' $current = if (Test-Path $verFile) { (Get-Content $verFile).Trim() } else { 'none' } if ($latest -ne $current) { Write-Host "Installing AppShip Studio agent $latest..." $tgz = Join-Path $Dir 'agent.tgz' Invoke-WebRequest "$Site/agent/appship-studio-agent-$latest.tgz" -OutFile $tgz -UseBasicParsing $env:Path = "$NodeDir;$env:Path" & $Npm install --prefix (Join-Path $Dir 'app') --omit=dev --no-audit --no-fund --no-update-notifier --loglevel=error $tgz | Out-Null Remove-Item $tgz Set-Content $verFile $latest } # 3. A launcher, so next time it is just: %USERPROFILE%\.appship-studio-agent\bin\appship-studio-agent.cmd $entry = Join-Path $Dir 'app\node_modules\appship-studio-agent\agent\index.js' Set-Content (Join-Path $Dir 'bin\appship-studio-agent.cmd') "@echo off`r`n`"$Node`" `"$entry`" %*" Write-Host 'Starting the agent. Your browser opens Studio, paired with this computer. Keep this window open.' & $Node $entry