# Yah Mesh desktop — one-command install for Windows, served by the relay: # # irm https://relay.yahai.app/desktop.ps1 | iex # # Installs the Yah Code SERVICE (Bun) and registers it to start at logon. # The native Windows window (WinUI) is still in the works — until it lands, # the service is the working core: your phone pairs to it, starts coding # runs on this machine, and sees every session. Nothing here is silent. $ErrorActionPreference = 'Stop' $Relay = 'https://relay.yahai.app' $AppDir = Join-Path $env:USERPROFILE '.yahcode\app' function Say($m) { Write-Host ("-> " + $m) } # -- bun ------------------------------------------------------------------ $bun = Get-Command bun -ErrorAction SilentlyContinue if ($bun) { Say ("bun " + (& bun --version) + " already installed") } else { Say "installing bun (the service's runtime)..." irm https://bun.sh/install.ps1 | iex $env:Path = "$env:USERPROFILE\.bun\bin;$env:Path" $bun = Get-Command bun -ErrorAction Stop } $BunExe = $bun.Source # -- payload -------------------------------------------------------------- Say "fetching the desktop payload from $Relay..." New-Item -ItemType Directory -Force -Path $AppDir | Out-Null $zip = Join-Path $env:TEMP 'yahmesh-desktop.zip' Invoke-WebRequest -UseBasicParsing -Uri ($Relay + '/desktop.zip') -OutFile $zip # Expand-Archive is PowerShell's own — no reliance on tar or the session # PATH, which the bun installer rewrites mid-script. (The first field test # died exactly there: tar.exe exists on every Win10+, but PATH no longer # said so by the time this line ran.) Expand-Archive -LiteralPath $zip -DestinationPath $AppDir -Force Say "payload extracted to $AppDir" Say "installing service dependencies (compiles llama.cpp once - minutes, not seconds)..." Push-Location (Join-Path $AppDir 'yahcode') & $BunExe install if ($LASTEXITCODE -ne 0) { Pop-Location; throw "bun install failed - see output above" } Pop-Location # -- the service: a logon task, visible in Task Scheduler ----------------- # Launched through a .vbs under wscript //B, the same idiom the mesh connector # uses on Windows: a bare `bun run` as a scheduled task leaves a console # window on the desktop at every logon — which the first field install did. # WScript.Shell's Run with windowStyle 0 and bWaitOnReturn false starts the # service with no window and does not linger. $main = Join-Path $AppDir 'yahcode\src\main.ts' $vbs = Join-Path $AppDir 'yahcode-launch.vbs' @" Set sh = CreateObject("WScript.Shell") sh.CurrentDirectory = "$(Join-Path $AppDir 'yahcode')" sh.Run """$BunExe"" run ""$main""", 0, False "@ | Set-Content -Path $vbs -Encoding ASCII $action = New-ScheduledTaskAction -Execute 'wscript.exe' -Argument ('//B "' + $vbs + '"') -WorkingDirectory (Join-Path $AppDir 'yahcode') $trigger = New-ScheduledTaskTrigger -AtLogOn -User $env:USERNAME $settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -ExecutionTimeLimit ([TimeSpan]::Zero) Register-ScheduledTask -TaskName 'YahCode' -Action $action -Trigger $trigger -Settings $settings -Force | Out-Null Start-ScheduledTask -TaskName 'YahCode' Say "service registered as scheduled task 'YahCode' and started" # -- the mesh machinery, in the same install ------------------------------ # Same reasoning as the sh installer: the app's Agents tab drives these # helpers, and they used to require a separate connector install first. $MeshDir = Join-Path $env:USERPROFILE '.agentmesh' New-Item -ItemType Directory -Force -Path $MeshDir | Out-Null foreach ($helper in @('install-service.mjs','pair.mjs','doctor.mjs','update.mjs','mesh-mcp.mjs')) { $dest = Join-Path $MeshDir $helper if (-not (Test-Path $dest)) { Invoke-WebRequest -UseBasicParsing -Uri ($Relay + '/' + $helper) -OutFile $dest Say ("mesh helper installed: " + $helper) } } Say "done. Next: open Yah AI on your phone -> Settings -> Yah Code -> pair this machine." Say "Mint the code with: irm http://127.0.0.1:8765/api/pair -Method POST -Body '{}' -ContentType application/json"