The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
fix(grid): install and run grid on Windows (#1904)
lingrd9c4962af05a0
diff --git a/cli/src/gridCommand.spec.ts b/cli/src/gridCommand.spec.tsindex 0ff80381f..26006803b 100644--- a/cli/src/gridCommand.spec.ts+++ b/cli/src/gridCommand.spec.ts@@ -142,6 +142,7 @@ function envFor(root: string, backendUrl?: string, extra: NodeJS.ProcessEnv = {}return {...inherited,HOME: root,+ USERPROFILE: root, // Windows' HOME: the resolver's last stop is `%USERPROFILE%\.local\bin`HARNESS_AUTH_DIR: join(root, 'auth'),ADAPTER_DATA_DIR: join(root, 'data'),ADAPTER_CLI_DIR: join(root, 'cli'),diff --git a/cli/src/lib/gridBinary.ts b/cli/src/lib/gridBinary.tsindex 575ebcb2b..46807488d 100644--- a/cli/src/lib/gridBinary.ts+++ b/cli/src/lib/gridBinary.ts@@ -63,22 +63,44 @@ export function managedGridPath(): string | null {* directory holds. The managed runtime outranks it: once the pin is published the installer's* copy is only ever a fallback for a machine the pin could not reach.*/-export function gridBinaryPath(processEnv: NodeJS.ProcessEnv = process.env): string {+export function gridBinaryPath(processEnv: NodeJS.ProcessEnv = process.env, platform: NodeJS.Platform = process.platform): string {const override = processEnv.HARNESS_GRID_BIN?.trim()if (override) return overrideconst managed = managedGridPath()if (managed) return managedif (binaryOnPath(GRID_BINARY, processEnv)) return GRID_BINARY- // Keyed on the environment's HOME rather than `os.homedir()`, so a caller that hands in an+ // Keyed on the environment's home rather than `os.homedir()`, so a caller that hands in an// environment (the tests, a deliberately bare one) gets exactly what that environment can see.- const home = processEnv.HOME?.trim()+ // Windows has no HOME, and grid's installer there (`install.ps1`) writes `grid.exe` — or, where Smart+ // App Control blocked that, `grid.cmd` — into `%USERPROFILE%\.local\bin`.+ const windows = platform === 'win32'+ const home = (windows ? processEnv.USERPROFILE : processEnv.HOME)?.trim()if (home) {- const installed = join(home, '.local', 'bin', GRID_BINARY)- try { accessSync(installed, constants.X_OK); return installed } catch { /* not there either */ }+ for (const name of windows ? ['grid.exe', 'grid.cmd'] : [GRID_BINARY]) {+ const installed = join(home, '.local', 'bin', name)+ try { accessSync(installed, constants.X_OK); return installed } catch { /* not there either */ }+ }}return GRID_BINARY}+/**+ * What to spawn to run [binary] with [args]. Almost always the binary itself. The exception is the+ * `grid.cmd` that grid's Windows installer writes where Smart App Control blocked its unsigned+ * `grid.exe`: Node cannot spawn a `.cmd` without a shell, and a shell would have to re-quote every+ * argument, so the installer's own line — `"<install>\Scripts\python.exe" -m cli %*` — is read and that+ * signed python is run directly. A `.cmd` that is not that shape is returned as it is, and fails as it did.+ */+export function gridCommand(binary: string, args: readonly string[], platform: NodeJS.Platform = process.platform): { file: string; args: string[] } {+ if (platform === 'win32' && /\.(?:cmd|bat)$/i.test(binary)) {+ try {+ const python = /"([^"]+\.exe)" -m cli %\*/.exec(readFileSync(binary, 'utf8'))?.[1]+ if (python) return { file: python, args: ['-m', 'cli', ...args] }+ } catch { /* unreadable: spawn reports it */ }+ }+ return { file: binary, args: [...args] }+}+/** Is there a `grid` to run at all? Asked by reading rather than by spawning, so a missing binary is* a sentence rather than a spawn error every caller has to recognise — and so a present-but-not-* executable one (EACCES, never ENOENT) is caught too. */diff --git a/cli/src/lib/gridExec.spec.ts b/cli/src/lib/gridExec.spec.tsindex 1a21af2bf..f00837c0c 100644--- a/cli/src/lib/gridExec.spec.ts+++ b/cli/src/lib/gridExec.spec.ts@@ -13,7 +13,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'let root = ''let runtimeDir = ''-const saved = { PATH: process.env.PATH, HOME: process.env.HOME, HARNESS_GRID_BIN: process.env.HARNESS_GRID_BIN, ADAPTER_RUNTIME_DIR: process.env.ADAPTER_RUNTIME_DIR }+const saved = { PATH: process.env.PATH, HOME: process.env.HOME, USERPROFILE: process.env.USERPROFILE, HARNESS_GRID_BIN: process.env.HARNESS_GRID_BIN, ADAPTER_RUNTIME_DIR: process.env.ADAPTER_RUNTIME_DIR }/** `gridExec.ts` reads `env.ADAPTER_RUNTIME_DIR` at import time, so the module is loaded fresh per case. */async function load() {@@ -37,9 +37,10 @@ beforeEach(() => {mkdirSync(runtimeDir)mkdirSync(join(root, 'empty-bin'))process.env.PATH = join(root, 'empty-bin')- // The resolver's last fallback is `$HOME/.local/bin/grid` (grid's own installer's path), so a- // developer machine that has one must not leak into "nothing to run".+ // The resolver's last fallback is `$HOME/.local/bin/grid` (grid's own installer's path; on Windows+ // `%USERPROFILE%\.local\bin`), so a developer machine that has one must not leak into "nothing to run".process.env.HOME = root+ process.env.USERPROFILE = rootdelete process.env.HARNESS_GRID_BIN})@@ -146,3 +147,72 @@ describe('gridExec', () => {expect(result.message).toContain('grid')})})++/**+ * grid on Windows. Its installer (`install.ps1`) puts `grid.exe` in `%USERPROFILE%\.local\bin`, a+ * folder a daemon started by a launcher may not have on PATH — and Windows has no HOME. Where Smart App+ * Control blocks the unsigned `grid.exe` it writes `grid.cmd` instead, which runs the install's signed+ * `python.exe -m cli`; Node cannot spawn a `.cmd` without a shell, so the python behind it is run directly.+ */+describe('grid on Windows', () => {+ const PYTHON = 'C:\\Users\\me\\AppData\\Roaming\\uv\\tools\\grid\\Scripts\\python.exe'+ const CMD = [+ '@ECHO off',+ 'SETLOCAL',+ `endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "${PYTHON}" -m cli %*`,+ '',+ ].join('\r\n')++ function installed(...names: string[]): string {+ const bin = join(root, '.local', 'bin')+ mkdirSync(bin, { recursive: true })+ for (const name of names) writeFileSync(join(bin, name), name.endsWith('.cmd') ? CMD : 'MZ', { mode: 0o755 })+ return bin+ }++ it("finds grid.exe in USERPROFILE\\.local\\bin when PATH does not have it, with no HOME at all", async () => {+ const bin = installed('grid.exe')+ const { gridBinaryPath } = await load()++ expect(gridBinaryPath({ USERPROFILE: root }, 'win32')).toBe(join(bin, 'grid.exe'))+ })++ it('takes grid.exe over grid.cmd, and grid.cmd when it is all there is', async () => {+ const bin = installed('grid.cmd')+ const { gridBinaryPath } = await load()+ expect(gridBinaryPath({ USERPROFILE: root }, 'win32')).toBe(join(bin, 'grid.cmd'))++ installed('grid.exe')+ expect(gridBinaryPath({ USERPROFILE: root }, 'win32')).toBe(join(bin, 'grid.exe'))+ })++ it("runs the python behind grid.cmd directly, with the arguments after `-m cli`", async () => {+ const bin = installed('grid.cmd')+ const { gridCommand } = await load()++ expect(gridCommand(join(bin, 'grid.cmd'), ['--remote', 'ls', '--json'], 'win32')).toEqual({+ file: PYTHON,+ args: ['-m', 'cli', '--remote', 'ls', '--json'],+ })+ })++ it('leaves everything else as it is: an .exe, a .cmd it cannot read, and any other OS', async () => {+ const bin = installed('grid.exe', 'grid.cmd')+ const { gridCommand } = await load()++ expect(gridCommand(join(bin, 'grid.exe'), ['ls'], 'win32')).toEqual({ file: join(bin, 'grid.exe'), args: ['ls'] })+ expect(gridCommand(join(bin, 'gone.cmd'), ['ls'], 'win32')).toEqual({ file: join(bin, 'gone.cmd'), args: ['ls'] })+ writeFileSync(join(bin, 'odd.cmd'), '@ECHO off\r\necho hi\r\n')+ expect(gridCommand(join(bin, 'odd.cmd'), ['ls'], 'win32')).toEqual({ file: join(bin, 'odd.cmd'), args: ['ls'] })+ expect(gridCommand(join(bin, 'grid.cmd'), ['ls'], 'linux')).toEqual({ file: join(bin, 'grid.cmd'), args: ['ls'] })+ })++ it('keeps the POSIX lookup under HOME unchanged', async () => {+ const bin = join(root, '.local', 'bin')+ mkdirSync(bin, { recursive: true })+ writeFileSync(join(bin, 'grid'), '#!/bin/sh\n', { mode: 0o755 })+ const { gridBinaryPath } = await load()++ expect(gridBinaryPath({ HOME: root }, 'linux')).toBe(join(bin, 'grid'))+ })+})diff --git a/cli/src/lib/gridExec.ts b/cli/src/lib/gridExec.tsindex 96f9bee6a..a4150995b 100644--- a/cli/src/lib/gridExec.ts+++ b/cli/src/lib/gridExec.ts@@ -21,11 +21,11 @@*/import { spawn } from 'node:child_process'import { binaryOnPath } from './binaryOnPath.js'-import { GRID_NO_UPDATE_CHECK_VAR, gridBinaryPath, gridChildEnv } from './gridBinary.js'+import { GRID_NO_UPDATE_CHECK_VAR, gridBinaryPath, gridChildEnv, gridCommand } from './gridBinary.js'// Which `grid` to run is gridBinary.ts's, which the core keeps for its launches; said again here for// every grid call that imports it from this module.-export { GRID_BINARY, GRID_NO_UPDATE_CHECK_VAR, gridAvailable, gridBinaryPath, gridChildEnv, gridCliPresence, managedGridPath, type GridCliPresence } from './gridBinary.js'+export { GRID_BINARY, GRID_NO_UPDATE_CHECK_VAR, gridAvailable, gridBinaryPath, gridChildEnv, gridCliPresence, gridCommand, managedGridPath, type GridCliPresence } from './gridBinary.js'/*** The oldest `grid` this daemon can drive.@@ -100,7 +100,8 @@ export async function gridExec(args: readonly string[], opts: GridExecOptions =return { code: 'GRID_CLI_MISSING', exitCode: 1, stdout: '', stderr: '', message: MISSING_MESSAGE }}return await new Promise<GridResult>((resolve) => {- const child = spawn(binary, [...args], { stdio: ['pipe', 'pipe', 'pipe'], env: gridChildEnv(processEnv) })+ const command = gridCommand(binary, args)+ const child = spawn(command.file, command.args, { stdio: ['pipe', 'pipe', 'pipe'], env: gridChildEnv(processEnv) })let stdout = ''let stderr = ''let settled = falsediff --git a/cli/src/lib/gridFleetRpc.ts b/cli/src/lib/gridFleetRpc.tsindex 230351acb..4d3a12bc3 100644--- a/cli/src/lib/gridFleetRpc.ts+++ b/cli/src/lib/gridFleetRpc.ts@@ -1,6 +1,6 @@/** Grid's complete argv API, carried over the existing paired-machine connection. No shell. */import { spawn } from 'node:child_process'-import { gridBinaryPath, gridChildEnv } from './gridExec.js'+import { gridBinaryPath, gridChildEnv, gridCommand } from './gridExec.js'import { GRID_FLEET_MAX_TIMEOUT_MS } from './gridFleetProtocol.js'// The handshake's own module, which the socket answers it from (gridFleetProtocol.ts).@@ -61,7 +61,8 @@ export class GridFleetRpc {const output = { stdout: new GridOutputCapture(), stderr: new GridOutputCapture() }let stopped: string | null = null, done = falselet timeout: ReturnType<typeof setTimeout>, kill: ReturnType<typeof setTimeout> | undefined- const child = spawn(gridBinaryPath(this.processEnv), request.args, {+ const command = gridCommand(gridBinaryPath(this.processEnv), request.args)+ const child = spawn(command.file, command.args, {env: { ...gridChildEnv(this.processEnv), ...(request.thinking === undefined ? {} : {LLAMA_ARG_CHAT_TEMPLATE_KWARGS: JSON.stringify({ enable_thinking: request.thinking }),}) }, stdio: ['ignore', 'pipe', 'pipe'],diff --git a/cli/src/lib/gridHandoff.spec.ts b/cli/src/lib/gridHandoff.spec.tsindex f610db1ba..9c812e228 100644--- a/cli/src/lib/gridHandoff.spec.ts+++ b/cli/src/lib/gridHandoff.spec.ts@@ -15,7 +15,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'let root = ''let runtimeDir = ''-const saved = { PATH: process.env.PATH, HOME: process.env.HOME, HARNESS_GRID_BIN: process.env.HARNESS_GRID_BIN, ADAPTER_RUNTIME_DIR: process.env.ADAPTER_RUNTIME_DIR }+const saved = { PATH: process.env.PATH, HOME: process.env.HOME, USERPROFILE: process.env.USERPROFILE, HARNESS_GRID_BIN: process.env.HARNESS_GRID_BIN, ADAPTER_RUNTIME_DIR: process.env.ADAPTER_RUNTIME_DIR }/** `gridExec.ts` reads `env.ADAPTER_RUNTIME_DIR` at import time, so the module is loaded fresh per case. */async function load() {@@ -54,8 +54,9 @@ beforeEach(() => {mkdirSync(join(root, 'empty-bin'))process.env.PATH = join(root, 'empty-bin')// The resolver's last fallback is `$HOME/.local/bin/grid` (grid's own installer's path), so a- // developer machine that has one must not leak into "nothing to run".+ // developer machine that has one must not leak into "nothing to run" (`USERPROFILE` is Windows' HOME).process.env.HOME = root+ process.env.USERPROFILE = rootdelete process.env.HARNESS_GRID_BIN})diff --git a/cli/src/lib/gridHandoff.ts b/cli/src/lib/gridHandoff.tsindex acde17483..0f16c8225 100644--- a/cli/src/lib/gridHandoff.ts+++ b/cli/src/lib/gridHandoff.ts@@ -24,7 +24,7 @@import { spawn } from 'node:child_process'import { binaryOnPath } from './binaryOnPath.js'import { gridEnvelopes } from './gridEnvelope.js'-import { gridBinaryPath, gridChildEnv } from './gridExec.js'+import { gridBinaryPath, gridChildEnv, gridCommand } from './gridExec.js'/** The flag on `grid login` that means "read the token off stdin" (autonomous-grid's `cli/parser.py`).* WHICH `grid` is not decided here: `gridBinaryPath()` (lib/gridExec.ts) answers that for every grid@@ -131,7 +131,8 @@ export async function handOffToGrid(const timeoutMs = opts.timeoutMs ?? HANDOFF_TIMEOUT_MSconst args = ['login', GRID_HANDOFF_FLAG, ...(opts.json ? ['--json'] : [])]return await new Promise<GridHandoffResult>((resolve) => {- const child = spawn(binary, args, {+ const command = gridCommand(binary, args)+ const child = spawn(command.file, command.args, {stdio: ['pipe', opts.json ? 'pipe' : 'inherit', opts.json ? 'pipe' : 'inherit'],// The human path inherits stderr, which is a terminal — exactly where grid would offer// `grid update` for a binary the harness pins. See GRID_NO_UPDATE_CHECK_VAR in gridExec.ts.diff --git a/cli/src/lib/gridInstall.spec.ts b/cli/src/lib/gridInstall.spec.tsindex ed596b501..a2af41922 100644--- a/cli/src/lib/gridInstall.spec.ts+++ b/cli/src/lib/gridInstall.spec.ts@@ -1,5 +1,5 @@import { describe, expect, it, vi } from 'vitest'-import { ensureGridInstalled, GRID_INSTALL_URL, type GridInstallDeps } from './gridInstall.js'+import { ensureGridInstalled, GRID_INSTALL_PS1_URL, GRID_INSTALL_URL, installerCommand, type GridInstallDeps } from './gridInstall.js'function deps(overrides: Partial<GridInstallDeps> = {}): GridInstallDeps & { runs: string[] } {const runs: string[] = []@@ -8,6 +8,8 @@ function deps(overrides: Partial<GridInstallDeps> = {}): GridInstallDeps & { runavailable: () => false,curlOnPath: () => true,enabled: true,+ // The curl-and-bash path, whatever machine runs the test; the Windows tests say 'win32'.+ platform: 'linux',run: async (script) => { runs.push(script); return { exitCode: 0, output: '✓ grid installed' } },...overrides,}@@ -68,4 +70,31 @@ describe('ensureGridInstalled', () => {expect(b.status).toBe('installed')expect(run).toHaveBeenCalledTimes(1)})++ it("on Windows runs grid's PowerShell installer, and does not need curl", async () => {+ let installed = false+ const runs: string[] = []+ const d = deps({+ platform: 'win32',+ curlOnPath: () => false,+ available: () => installed,+ run: async (script) => { runs.push(script); installed = true; return { exitCode: 0, output: 'ok' } },+ })+ expect((await ensureGridInstalled(d)).status).toBe('installed')+ expect(runs).toEqual([`irm ${GRID_INSTALL_PS1_URL} | iex`])+ })+})++describe('installerCommand', () => {+ it('runs the installer script with bash off Windows', () => {+ expect(installerCommand('darwin', 'S')).toEqual({ file: 'bash', args: ['-c', 'S'] })+ expect(installerCommand('linux', 'S')).toEqual({ file: 'bash', args: ['-c', 'S'] })+ })++ it("runs it with Windows PowerShell by absolute path on Windows — a bare name is searched in the current folder", () => {+ expect(installerCommand('win32', 'S', { SystemRoot: 'C:\\Windows' })).toEqual({+ file: 'C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe',+ args: ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', 'S'],+ })+ })})diff --git a/cli/src/lib/gridInstall.ts b/cli/src/lib/gridInstall.tsindex 07c0a6e25..82968c37a 100644--- a/cli/src/lib/gridInstall.ts+++ b/cli/src/lib/gridInstall.ts@@ -21,13 +21,34 @@*/import { spawn } from 'node:child_process'import { homedir } from 'node:os'-import { join } from 'node:path'+import { delimiter, join, win32 } from 'node:path'import { env } from '../config/env.js'import { binaryOnPath } from './binaryOnPath.js'import { gridAvailable } from './gridExec.js'export const GRID_INSTALL_URL = 'https://grid.autonomous.ai/install.sh'+/** The Windows installer. Served from GitHub, not grid.autonomous.ai: that host serves install.sh only. */+export const GRID_INSTALL_PS1_URL = 'https://raw.githubusercontent.com/autonomous-ai/autonomous-grid/main/install.ps1'++/**+ * The program that runs the installer script. Windows has no bash; its installer is PowerShell, which+ * has `irm` built in (so no `curl` either). Windows PowerShell 5.1 ships with every supported Windows,+ * and is named by absolute path: `CreateProcess` searches the current folder first for a bare name.+ */+export function installerCommand(+ platform: NodeJS.Platform,+ script: string,+ environment: NodeJS.ProcessEnv = process.env,+): { file: string; args: string[] } {+ if (platform !== 'win32') return { file: 'bash', args: ['-c', script] }+ const root = environment.SystemRoot || 'C:\\Windows'+ return {+ file: win32.join(root, 'System32', 'WindowsPowerShell', 'v1.0', 'powershell.exe'),+ args: ['-NoProfile', '-NonInteractive', '-ExecutionPolicy', 'Bypass', '-Command', script],+ }+}+/** Where grid's installer puts the binary on both platforms — the reason `gridBinaryPath` falls* back to this directory when `~/.local/bin` is not on the daemon's PATH. */export const GRID_INSTALL_DIR = join(homedir(), '.local', 'bin')@@ -60,6 +81,8 @@ export interface GridInstallDeps {/** Run the installer; resolves with its exit code and bounded output. Injected for the tests. */run: (script: string, timeoutMs: number) => Promise<{ exitCode: number; output: string }>enabled: boolean+ /** Defaults to this machine's. Injected so the Windows branch is tested on any OS. */+ platform?: NodeJS.Platform}function capped(sofar: string, chunk: Buffer): string {@@ -70,9 +93,10 @@ function capped(sofar: string, chunk: Buffer): string {* `uv` it may have just installed is found by the same run. */export function runInstaller(script: string, timeoutMs: number): Promise<{ exitCode: number; output: string }> {return new Promise((resolve) => {- const child = spawn('bash', ['-c', script], {+ const { file, args } = installerCommand(process.platform, script)+ const child = spawn(file, args, {stdio: ['ignore', 'pipe', 'pipe'],- env: { ...process.env, PATH: `${GRID_INSTALL_DIR}:${process.env.PATH ?? ''}` },+ env: { ...process.env, PATH: `${GRID_INSTALL_DIR}${delimiter}${process.env.PATH ?? ''}` },})let output = ''let settled = false@@ -110,13 +134,15 @@ let inFlight: Promise<GridInstallResult> | null = nullexport function ensureGridInstalled(deps: GridInstallDeps = defaultGridInstallDeps): Promise<GridInstallResult> {if (deps.available()) return Promise.resolve({ status: 'present', message: '`grid` is installed' })if (!deps.enabled) return Promise.resolve({ status: 'skipped', message: 'grid install is switched off (DISABLE_GRID_INSTALL)' })- if (!deps.curlOnPath()) {+ const windows = (deps.platform ?? process.platform) === 'win32'+ if (!windows && !deps.curlOnPath()) {return Promise.resolve({ status: 'skipped', message: 'no `grid` on this machine and no `curl` to fetch its installer with — install it from ' + GRID_INSTALL_URL })}if (inFlight) return inFlightinFlight = (async (): Promise<GridInstallResult> => {try {- const { exitCode, output } = await deps.run(`curl -fsSL ${GRID_INSTALL_URL} | bash`, INSTALL_TIMEOUT_MS)+ const script = windows ? `irm ${GRID_INSTALL_PS1_URL} | iex` : `curl -fsSL ${GRID_INSTALL_URL} | bash`+ const { exitCode, output } = await deps.run(script, INSTALL_TIMEOUT_MS)const tail = output.trim().split('\n').slice(-3).join(' · ').replace(/\[[0-9;]*m/g, '')if (exitCode !== 0) {return { status: 'failed', message: `grid installer exited ${exitCode}${tail ? ` · ${tail}` : ''}` }diff --git a/cli/src/lib/gridLogout.spec.ts b/cli/src/lib/gridLogout.spec.tsindex 809a32a51..4416df9b2 100644--- a/cli/src/lib/gridLogout.spec.ts+++ b/cli/src/lib/gridLogout.spec.ts@@ -11,7 +11,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'let root = ''let runtimeDir = ''-const saved = { PATH: process.env.PATH, HOME: process.env.HOME, HARNESS_GRID_BIN: process.env.HARNESS_GRID_BIN, ADAPTER_RUNTIME_DIR: process.env.ADAPTER_RUNTIME_DIR }+const saved = { PATH: process.env.PATH, HOME: process.env.HOME, USERPROFILE: process.env.USERPROFILE, HARNESS_GRID_BIN: process.env.HARNESS_GRID_BIN, ADAPTER_RUNTIME_DIR: process.env.ADAPTER_RUNTIME_DIR }async function load() {vi.resetModules()@@ -45,8 +45,9 @@ beforeEach(() => {process.env.PATH = join(root, 'empty-bin')// The resolver's last resort is `$HOME/.local/bin/grid` (gridExec.ts) — on a developer's machine// that is a REAL grid, and the "no child" case below ran its real `grid logout` before HOME was- // pointed here. Every case now sees a home with nothing under it.+ // pointed here. Every case now sees a home with nothing under it (`USERPROFILE` is Windows' HOME).process.env.HOME = root+ process.env.USERPROFILE = rootdelete process.env.HARNESS_GRID_BIN})diff --git a/cli/src/lib/gridLogout.ts b/cli/src/lib/gridLogout.tsindex 6f32842be..f06c10f33 100644--- a/cli/src/lib/gridLogout.ts+++ b/cli/src/lib/gridLogout.ts@@ -17,7 +17,7 @@*/import { spawn } from 'node:child_process'import { binaryOnPath } from './binaryOnPath.js'-import { GRID_BINARY, gridBinaryPath, gridChildEnv } from './gridExec.js'+import { GRID_BINARY, gridBinaryPath, gridChildEnv, gridCommand } from './gridExec.js'/** The verb, on the same binary the hand-off spawns. Deliberately NOT a cross-repo pin: rename it in* autonomous-grid and argparse refuses it loudly, in the child's own words, on the child's own@@ -59,7 +59,8 @@ export async function passThroughToGridLogout(args: string[]): Promise<GridLogou// this a passthrough rather than a re-narration of one.// Inherited stderr is a terminal, where grid would offer `grid update` for a binary the harness// pins — off, as for every child of this daemon (GRID_NO_UPDATE_CHECK_VAR in gridExec.ts).- const child = spawn(binary, [GRID_LOGOUT_VERB, ...args], { stdio: 'inherit', env: gridChildEnv() })+ const command = gridCommand(binary, [GRID_LOGOUT_VERB, ...args])+ const child = spawn(command.file, command.args, { stdio: 'inherit', env: gridChildEnv() })let settled = falseconst settle = (outcome: GridLogoutOutcome): void => { if (!settled) { settled = true; resolve(outcome) } }