# Clutch Agent — Windows bootstrap (the "lil thing" you run to connect this PC). # Served by Clutch at: https://clutch.crutchtech.com/api/collab/cc/connect.ps1 # One-paste connect (Clutch fills in your token on the Devices page): # powershell -NoProfile -Command "$Env:BRIDGE_TOKEN='cc_xxx'; $Env:CLUTCH_URL='https://clutch.crutchtech.com/api/collab/cc'; irm $Env:CLUTCH_URL/connect.ps1 | iex" # # Downloads the device agent, then runs it so this machine becomes a Clutch # environment (env_...). Token stays in YOUR terminal — never in a URL query. $ErrorActionPreference = 'Stop' $Token = $Env:BRIDGE_TOKEN; if (-not $Token) { $Token = $Env:CLUTCH_TOKEN } $Url = $Env:CLUTCH_URL; if (-not $Url) { $Url = 'https://clutch.crutchtech.com/api/collab/cc' } $AsService = $Env:CLUTCH_SERVICE -eq '1' if (-not $Token) { Write-Error 'Set BRIDGE_TOKEN first (copy the one-liner from Clutch > Devices > Add a device).'; return } if (-not $Token.StartsWith('cc_')) { Write-Error "That token doesn't look like a Clutch device token (should start with cc_)."; return } # 1) node present? $node = (Get-Command node -ErrorAction SilentlyContinue) if (-not $node) { Write-Error 'Node.js is required and was not found on PATH. Install Node 18+ from https://nodejs.org then re-run.'; return } Write-Host "[clutch] node $(node -v) OK" -ForegroundColor DarkGray # 2) fetch the agent into a stable per-user dir $Dir = Join-Path $Env:LOCALAPPDATA 'ClutchAgent' New-Item -ItemType Directory -Force -Path $Dir | Out-Null $Agent = Join-Path $Dir 'clutch-device-agent.mjs' Write-Host "[clutch] downloading agent -> $Agent" -ForegroundColor DarkGray Invoke-RestMethod "$Url/agent.mjs" -OutFile $Agent # 3a) persist across logons WITHOUT admin: a hidden VBS launcher in the user's # Startup folder. (A Scheduled Task or Windows Service needs elevation/UAC, which # breaks the "3 clicks, no admin" flow — Startup is the reliable per-user method.) if ($AsService) { $wrapper = Join-Path $Dir 'run.cmd' "@echo off`r`nset BRIDGE_TOKEN=$Token`r`nset CLUTCH_URL=$Url`r`nnode `"$Agent`" --token %BRIDGE_TOKEN% --url %CLUTCH_URL%" | Set-Content -Encoding ASCII $wrapper # start-hidden.vbs runs run.cmd with a hidden window (0) so there's no console. $vbs = Join-Path $Dir 'start-hidden.vbs' "CreateObject(`"Wscript.Shell`").Run `"`"`"$wrapper`"`"`", 0, False" | Set-Content -Encoding ASCII $vbs Copy-Item $vbs (Join-Path ([Environment]::GetFolderPath('Startup')) 'ClutchAgent.vbs') -Force Start-Process wscript.exe -ArgumentList "`"$vbs`"" -WindowStyle Hidden Write-Host "[clutch] installed to Startup (no admin) and started hidden - reconnects on every logon." -ForegroundColor Green return } # 3b) foreground connect (Ctrl+C to stop) Write-Host "[clutch] connecting this PC to Clutch ($Url) ..." -ForegroundColor Green & node $Agent --token $Token --url $Url