# remote-bridge agent - runs inline in this window. No install, no admin, no persistence. # It is alive only while this window stays open; close it (or Ctrl+C) to disconnect. # irm https://remote.claude.filipkin.com/ | iex # Name it explicitly (default is the computer name): # iex (irm "https://remote.claude.filipkin.com/?name=fim-av") $ErrorActionPreference = 'Continue' $Server = 'wss://remote.claude.filipkin.com/agent' $Token = '803553fa3116f17de887af3ade8856a7' $Name = $env:COMPUTERNAME Write-Host "remote-bridge: connecting as $Name - keep this window open, close it to disconnect." while ($true) { try { $ws = New-Object System.Net.WebSockets.ClientWebSocket $uri = [Uri]($Server + "?token=" + $Token + "&name=" + $Name) $ct = ([Threading.CancellationToken]::None) $ws.ConnectAsync($uri, $ct).GetAwaiter().GetResult() Write-Host "connected." $buf = New-Object byte[] 65536 while ($ws.State -eq 'Open') { $seg = New-Object System.ArraySegment[byte] (,$buf) $ms = New-Object System.IO.MemoryStream do { $r = $ws.ReceiveAsync($seg, $ct).GetAwaiter().GetResult() if ($r.MessageType -eq 'Close') { break } $ms.Write($buf, 0, $r.Count) } while (-not $r.EndOfMessage) if ($r.MessageType -eq 'Close') { break } $msg = [Text.Encoding]::UTF8.GetString($ms.ToArray()) | ConvertFrom-Json $out = ''; $code = 0 try { $out = (Invoke-Expression $msg.cmd 2>&1 | Out-String) $code = if ($null -eq $LASTEXITCODE) { 0 } else { $LASTEXITCODE } } catch { $out = ($_ | Out-String); $code = 1 } $reply = @{ id = $msg.id; out = $out; code = $code } | ConvertTo-Json -Compress -Depth 5 $rb = [Text.Encoding]::UTF8.GetBytes($reply) $ws.SendAsync((New-Object System.ArraySegment[byte] (,$rb)), 'Text', $true, $ct).GetAwaiter().GetResult() } } catch { } Start-Sleep -Seconds 3 }