| 19 | // Per-OS guest specifics: working dir, binary name, and the shell idioms for |
| 20 | // prep/cleanup — Unix `sh` on tart (macOS/Linux), PowerShell on EC2 Windows. |
| 21 | const guestPlan = (os: VmOs) => { |
| 22 | if (os === "windows") { |
| 23 | const dir = "C:/ed"; |
| 24 | const exe = `${dir}/executor.exe`; |
| 25 | return { |
| 26 | dir, |
| 27 | prep: `Remove-Item -Recurse -Force '${dir}' -ErrorAction SilentlyContinue; New-Item -ItemType Directory -Force -Path '${dir}' | Out-Null`, |
| 28 | postPush: "Write-Output ok", // no chmod/quarantine on Windows |
| 29 | install: `& '${exe}' service install --port ${PORT}`, |
| 30 | readToken: 'Get-Content "$env:USERPROFILE\\.executor\\server-control\\auth.json" -Raw', |
| 31 | uninstall: `& '${exe}' service uninstall`, |
| 32 | }; |
| 33 | } |
| 34 | const dir = "~/ed"; |
| 35 | const exe = `${dir}/executor`; |
| 36 | return { |
| 37 | dir, |
| 38 | prep: `rm -rf ${dir} && mkdir -p ${dir}`, |
| 39 | // macOS quarantines scp'd executables; clear it so the binary can run. |
| 40 | postPush: |
| 41 | os === "macos" |
| 42 | ? `chmod +x ${exe}; xattr -dr com.apple.quarantine ${dir} 2>/dev/null || true` |
| 43 | : `chmod +x ${exe}`, |
| 44 | install: `${exe} service install --port ${PORT}`, |
| 45 | readToken: "cat ~/.executor/server-control/auth.json", |
| 46 | uninstall: `${exe} service uninstall`, |
| 47 | }; |
| 48 | }; |
| 49 | |
| 50 | export async function setupCliTarget(os: VmOs): Promise<(() => Promise<void>) | void> { |
| 51 | process.env.E2E_VM_OS = os; // so the worker-side target resolves the same OS |