From 09213e1a1d91d0ed58386151b4f4a8a78937307a Mon Sep 17 00:00:00 2001 From: Xavier Date: Thu, 29 Oct 2026 22:51:14 -0300 Subject: [PATCH 1/4] fix(agent-device): find an npm-installed agent-device on Windows `findAgentDevice` split PATH on `:`, wanted an execute bit and took the command's real path as a symlink into the package. On Windows PATH is `;`-separated with `C:` drives, Node reports every file as 0o666, and npm installs a `.cmd` shim beside `node_modules/agent-device` rather than a symlink, so a worker there always reported "agent-device not found: \"agent-device\" is not on PATH". On Windows the lookup now splits on `;`, treats any file as runnable, and takes `/agent-device.cmd` to mean the package beside it, using that package's own `bin` file as the real path (`node --version` runs it; the package root is above it). A configured path may use `\`. PATH is read case-insensitively, since Windows names it `Path` and a copy of `process.env` loses its case-insensitive lookup. Co-Authored-By: Claude Opus 5.5 --- .../host/agent-device-supervisor.ts | 4 +- src/agent-device/host/install.test.ts | 93 +++++++++++++++++++ src/agent-device/host/install.ts | 69 ++++++++++++-- 3 files changed, 155 insertions(+), 11 deletions(-) create mode 100644 src/agent-device/host/install.test.ts diff --git a/src/agent-device/host/agent-device-supervisor.ts b/src/agent-device/host/agent-device-supervisor.ts index b3ae1cabf..60c074f46 100644 --- a/src/agent-device/host/agent-device-supervisor.ts +++ b/src/agent-device/host/agent-device-supervisor.ts @@ -24,7 +24,7 @@ import { NO_ANDROID_DEVICE_SERIAL, } from "../shared/daemon-environment.js"; import type { AgentDeviceHealthProbe } from "./health.js"; -import { findAgentDevice } from "./install.js"; +import { findAgentDevice, pathVariableOf } from "./install.js"; export type AgentDevicePlatform = "ios" | "android"; @@ -325,7 +325,7 @@ export class AgentDeviceSupervisor { const install = await findAgentDevice( o.filesystem, o.config.command, - o.baseEnvironment["PATH"], + pathVariableOf(o.baseEnvironment), ); if (!install.ok) { this.#fail(install.reason, install.message); diff --git a/src/agent-device/host/install.test.ts b/src/agent-device/host/install.test.ts new file mode 100644 index 000000000..7b7d320d9 --- /dev/null +++ b/src/agent-device/host/install.test.ts @@ -0,0 +1,93 @@ +import { describe, expect, it } from "vitest"; + +import { MemoryFilesystem } from "../../ports/index.js"; +import { findAgentDevice, pathVariableOf } from "./install.js"; + +const npm = "/Users/me/AppData/Roaming/npm"; +const packageRoot = `${npm}/node_modules/agent-device`; + +/** why: npm on Windows lays out a global install as a `.cmd` shim beside `node_modules`, every file 0o666. */ +async function windowsNpmInstall( + options: { readonly bin?: unknown; readonly shim?: boolean } = {}, +): Promise { + const filesystem = new MemoryFilesystem(); + await filesystem.mkdirp(`${packageRoot}/bin`); + await filesystem.mkdirp(`${packageRoot}/dist/src/internal`); + if (options.shim !== false) + await filesystem.writeFileAtomic(`${npm}/agent-device.cmd`, "@node ..."); + await filesystem.writeFileAtomic( + `${packageRoot}/package.json`, + JSON.stringify({ + bin: options.bin ?? { "agent-device": "bin/agent-device.mjs" }, + name: "agent-device", + }), + ); + await filesystem.writeFileAtomic(`${packageRoot}/bin/agent-device.mjs`, "#!/usr/bin/env node\n"); + await filesystem.writeFileAtomic(`${packageRoot}/dist/src/internal/daemon.js`, ""); + for (const path of [`${npm}/agent-device.cmd`, `${packageRoot}/bin/agent-device.mjs`]) { + if (await filesystem.exists(path)) filesystem.defineAttributes(path, { mode: 0o666 }); + } + return filesystem; +} + +// why: pure lookup rules, per platform, with many cases the supervisor's own tests reach only one at a time. +describe("findAgentDevice", () => { + it.each([ + ["an object", { "agent-device": "bin/agent-device.mjs" }], + ["a string", "./bin/agent-device.mjs"], + ])( + "finds an npm .cmd shim on a Windows PATH and stands in its package's bin, named as %s", + async (_form, bin) => { + const filesystem = await windowsNpmInstall({ bin }); + + await expect( + findAgentDevice(filesystem, "agent-device", `/Windows/System32;${npm};/other`, "win32"), + ).resolves.toEqual({ + entry: `${packageRoot}/dist/src/internal/daemon.js`, + ok: true, + realPath: `${packageRoot}/bin/agent-device.mjs`, + }); + }, + ); + + it("does not take a package with no .cmd shim beside it as the command on Windows", async () => { + const filesystem = await windowsNpmInstall({ shim: false }); + + await expect(findAgentDevice(filesystem, "agent-device", npm, "win32")).resolves.toMatchObject({ + ok: false, + reason: "not-found", + }); + }); + + it("accepts a configured path to the bin file on Windows, where no file has an execute bit", async () => { + const filesystem = await windowsNpmInstall(); + const bin = `${packageRoot}/bin/agent-device.mjs`; + + await expect(findAgentDevice(filesystem, bin, undefined, "win32")).resolves.toMatchObject({ + ok: true, + realPath: bin, + }); + await expect(findAgentDevice(filesystem, bin, undefined, "linux")).resolves.toMatchObject({ + ok: false, + reason: "not-found", + }); + }); + + it("still splits PATH on ':' and ignores .cmd shims off Windows", async () => { + const filesystem = await windowsNpmInstall(); + + await expect( + findAgentDevice(filesystem, "agent-device", `/usr/bin:${npm}`, "linux"), + ).resolves.toMatchObject({ ok: false, reason: "not-found" }); + }); +}); + +describe("pathVariableOf", () => { + it.each([ + ["PATH", { PATH: "/usr/bin" }, "/usr/bin"], + ["Windows' Path", { Path: "C:\\npm;C:\\bin" }, "C:\\npm;C:\\bin"], + ["none", { HOME: "/home/me" }, undefined], + ])("reads %s", (_name, environment, expected) => { + expect(pathVariableOf(environment)).toBe(expected); + }); +}); diff --git a/src/agent-device/host/install.ts b/src/agent-device/host/install.ts index f6f9af629..1810e9b18 100644 --- a/src/agent-device/host/install.ts +++ b/src/agent-device/host/install.ts @@ -10,41 +10,92 @@ export type AgentDeviceInstall = readonly message: string; }; -async function isExecutableFile(filesystem: Filesystem, path: string): Promise { +// why: Windows has no execute bit; Node reports every file there as 0o666, so any file counts. +async function isExecutableFile( + filesystem: Filesystem, + path: string, + windows: boolean, +): Promise { try { const details = await filesystem.stat(path); - return details.kind === "file" && ((details.mode ?? 0) & 0o111) !== 0; + return details.kind === "file" && (windows || ((details.mode ?? 0) & 0o111) !== 0); } catch { return false; } } +/** + * why: npm on Windows installs a `.cmd` shim, not a symlink, with the package beside it + * in `node_modules/`. `node` cannot run the shim, and its real path is itself, so the + * package's own `bin` file stands in for it: `--version` runs it, and the package root is above it. + */ +async function npmShimTarget( + filesystem: Filesystem, + directory: string, + command: string, +): Promise { + if (!(await isExecutableFile(filesystem, `${directory}/${command}.cmd`, true))) return undefined; + const packageRoot = `${directory}/node_modules/${command}`; + try { + const { bin } = JSON.parse(await filesystem.readFile(`${packageRoot}/package.json`)) as { + bin?: unknown; + }; + const relative = + typeof bin === "string" ? bin : (bin as Record | undefined)?.[command]; + if (typeof relative !== "string") return undefined; + const target = `${packageRoot}/${relative.replace(/^\.\//, "")}`; + return (await isExecutableFile(filesystem, target, true)) ? target : undefined; + } catch { + return undefined; + } +} + +function isPath(command: string, windows: boolean): boolean { + return command.includes("/") || (windows && command.includes("\\")); +} + async function locate( filesystem: Filesystem, command: string, pathVariable: string | undefined, + platform: NodeJS.Platform, ): Promise { - if (command.includes("/")) { - return (await isExecutableFile(filesystem, command)) ? command : undefined; + const windows = platform === "win32"; + if (isPath(command, windows)) { + return (await isExecutableFile(filesystem, command, windows)) ? command : undefined; } - for (const directory of (pathVariable ?? "").split(":")) { + // why: Windows separates PATH entries with `;`, and its drive letters hold a `:`. + for (const directory of (pathVariable ?? "").split(windows ? ";" : ":")) { if (directory === "") continue; - const candidate = `${directory}/${command}`; - if (await isExecutableFile(filesystem, candidate)) return candidate; + const candidate = windows + ? await npmShimTarget(filesystem, directory, command) + : (await isExecutableFile(filesystem, `${directory}/${command}`, false)) + ? `${directory}/${command}` + : undefined; + if (candidate !== undefined) return candidate; } return undefined; } +/** why: on Windows the variable is `Path`, and a copy of `process.env` loses its case-insensitive lookup. */ +export function pathVariableOf(environment: NodeJS.ProcessEnv): string | undefined { + return ( + environment["PATH"] ?? + Object.entries(environment).find(([key]) => key.toUpperCase() === "PATH")?.[1] + ); +} + export async function findAgentDevice( filesystem: Filesystem, command: string, pathVariable: string | undefined, + platform: NodeJS.Platform = process.platform, ): Promise { - const found = await locate(filesystem, command, pathVariable); + const found = await locate(filesystem, command, pathVariable, platform); const notFound = { ok: false, reason: "not-found", - message: command.includes("/") + message: isPath(command, platform === "win32") ? `agent-device not found: ${command} is not an executable file` : `agent-device not found: "${command}" is not on PATH`, } as const; From d4a3f49104e6e609ac472b48d7e9ed3667219614 Mon Sep 17 00:00:00 2001 From: Szymon Chmal Date: Fri, 30 Oct 2026 12:52:26 +0100 Subject: [PATCH 2/4] test(agent-device): assert the ':' PATH split and the Windows backslash path (#1068) --- src/agent-device/host/install.test.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/agent-device/host/install.test.ts b/src/agent-device/host/install.test.ts index 7b7d320d9..ff08e6ad3 100644 --- a/src/agent-device/host/install.test.ts +++ b/src/agent-device/host/install.test.ts @@ -75,10 +75,28 @@ describe("findAgentDevice", () => { it("still splits PATH on ':' and ignores .cmd shims off Windows", async () => { const filesystem = await windowsNpmInstall(); + await filesystem.mkdirp("/opt/bin"); + await filesystem.writeFileAtomic("/opt/bin/agent-device", "#!/bin/sh\n"); + filesystem.defineAttributes("/opt/bin/agent-device", { mode: 0o755 }); await expect( findAgentDevice(filesystem, "agent-device", `/usr/bin:${npm}`, "linux"), ).resolves.toMatchObject({ ok: false, reason: "not-found" }); + await expect( + findAgentDevice(filesystem, "agent-device", "/usr/bin:/opt/bin", "linux"), + ).resolves.toMatchObject({ ok: false, reason: "not-agent-device" }); + }); + + it("takes a command with a backslash as a path on Windows only", async () => { + const filesystem = new MemoryFilesystem(); + const command = "C:\\Users\\me\\agent-device.mjs"; + + await expect(findAgentDevice(filesystem, command, undefined, "win32")).resolves.toMatchObject({ + message: `agent-device not found: ${command} is not an executable file`, + }); + await expect(findAgentDevice(filesystem, command, undefined, "linux")).resolves.toMatchObject({ + message: `agent-device not found: "${command}" is not on PATH`, + }); }); }); From 6e80fa8cf3270ed5a933145603205d6240fab090 Mon Sep 17 00:00:00 2001 From: Xavier Date: Fri, 30 Oct 2026 09:41:45 -0300 Subject: [PATCH 3/4] fix(agent-device): resolve every form of an npm .cmd shim on Windows Three npm layouts were reported as not-found or not-agent-device: - a local install, whose shim sits in node_modules/.bin with the package beside .bin rather than under it; - a configured command name that already ends in .cmd, which was looked up as agent-device.cmd.cmd; - a configured path to the shim itself, which was taken as the program rather than resolved to the package's bin. `locate` is split into small helpers, which also brings it back under Fallow's complexity limit. Addresses CodeRabbit review on #1055. Co-Authored-By: Claude Opus 5.5 --- src/agent-device/host/install.test.ts | 71 ++++++++++++++++++++++++++- src/agent-device/host/install.ts | 63 ++++++++++++++++++------ 2 files changed, 118 insertions(+), 16 deletions(-) diff --git a/src/agent-device/host/install.test.ts b/src/agent-device/host/install.test.ts index ff08e6ad3..a8e26ef60 100644 --- a/src/agent-device/host/install.test.ts +++ b/src/agent-device/host/install.test.ts @@ -1,6 +1,10 @@ +import { mkdir, mkdtemp, rm, writeFile } from "node:fs/promises"; +import { tmpdir } from "node:os"; +import { join } from "node:path"; + import { describe, expect, it } from "vitest"; -import { MemoryFilesystem } from "../../ports/index.js"; +import { MemoryFilesystem, NodeFilesystem } from "../../ports/index.js"; import { findAgentDevice, pathVariableOf } from "./install.js"; const npm = "/Users/me/AppData/Roaming/npm"; @@ -50,6 +54,42 @@ describe("findAgentDevice", () => { }, ); + it("finds a local install's shim in node_modules/.bin, its package beside .bin", async () => { + const project = "/work/app/node_modules"; + const filesystem = new MemoryFilesystem(); + await filesystem.mkdirp(`${project}/.bin`); + await filesystem.mkdirp(`${project}/agent-device/bin`); + await filesystem.mkdirp(`${project}/agent-device/dist/src`); + await filesystem.writeFileAtomic(`${project}/.bin/agent-device.cmd`, "@node ..."); + await filesystem.writeFileAtomic( + `${project}/agent-device/package.json`, + JSON.stringify({ bin: { "agent-device": "bin/agent-device.mjs" }, name: "agent-device" }), + ); + await filesystem.writeFileAtomic(`${project}/agent-device/bin/agent-device.mjs`, ""); + await filesystem.writeFileAtomic(`${project}/agent-device/dist/src/daemon.js`, ""); + + await expect( + findAgentDevice(filesystem, "agent-device", `/Windows;${project}/.bin/`, "win32"), + ).resolves.toEqual({ + entry: `${project}/agent-device/dist/src/daemon.js`, + ok: true, + realPath: `${project}/agent-device/bin/agent-device.mjs`, + }); + }); + + it.each([ + ["a command name ending in .cmd, looked up on PATH", "agent-device.CMD", npm], + ["a configured path to the shim", `${npm}/agent-device.cmd`, undefined], + ])("stands in the package's bin for %s on Windows", async (_case, command, pathVariable) => { + const filesystem = await windowsNpmInstall(); + + await expect(findAgentDevice(filesystem, command, pathVariable, "win32")).resolves.toEqual({ + entry: `${packageRoot}/dist/src/internal/daemon.js`, + ok: true, + realPath: `${packageRoot}/bin/agent-device.mjs`, + }); + }); + it("does not take a package with no .cmd shim beside it as the command on Windows", async () => { const filesystem = await windowsNpmInstall({ shim: false }); @@ -100,6 +140,35 @@ describe("findAgentDevice", () => { }); }); +describe.runIf(process.platform === "win32")("findAgentDevice on Windows", () => { + it("finds a local install from a PATH entry that is a project's node_modules .bin, written with backslashes", async () => { + const directory = await mkdtemp(join(tmpdir(), "simlock agent-device ")); + const modules = join(directory, "node_modules"); + const packageRoot = join(modules, "agent-device"); + try { + await mkdir(join(modules, ".bin"), { recursive: true }); + await mkdir(join(packageRoot, "bin"), { recursive: true }); + await mkdir(join(packageRoot, "dist", "src"), { recursive: true }); + await writeFile(join(modules, ".bin", "agent-device.cmd"), "@node ..."); + await writeFile( + join(packageRoot, "package.json"), + JSON.stringify({ bin: { "agent-device": "bin/agent-device.mjs" }, name: "agent-device" }), + ); + await writeFile(join(packageRoot, "bin", "agent-device.mjs"), ""); + await writeFile(join(packageRoot, "dist", "src", "daemon.js"), ""); + + await expect( + findAgentDevice(new NodeFilesystem(), "agent-device", join(modules, ".bin"), "win32"), + ).resolves.toMatchObject({ + ok: true, + realPath: join(packageRoot, "bin", "agent-device.mjs"), + }); + } finally { + await rm(directory, { force: true, recursive: true }); + } + }); +}); + describe("pathVariableOf", () => { it.each([ ["PATH", { PATH: "/usr/bin" }, "/usr/bin"], diff --git a/src/agent-device/host/install.ts b/src/agent-device/host/install.ts index 1810e9b18..f736c4305 100644 --- a/src/agent-device/host/install.ts +++ b/src/agent-device/host/install.ts @@ -1,4 +1,4 @@ -import { dirname } from "node:path"; +import { dirname, win32 } from "node:path"; import { type Filesystem } from "../../ports/index.js"; @@ -24,24 +24,42 @@ async function isExecutableFile( } } +const SHIM_SUFFIX = /\.cmd$/i; + /** - * why: npm on Windows installs a `.cmd` shim, not a symlink, with the package beside it - * in `node_modules/`. `node` cannot run the shim, and its real path is itself, so the - * package's own `bin` file stands in for it: `--version` runs it, and the package root is above it. + * why: npm on Windows installs a `.cmd` shim, not a symlink. `node` cannot run the shim, + * and its real path is itself, so the package's own `bin` file stands in for it: `--version` runs + * it, and the package root is above it. A configured name or path may already end in `.cmd`. */ async function npmShimTarget( filesystem: Filesystem, directory: string, command: string, ): Promise { - if (!(await isExecutableFile(filesystem, `${directory}/${command}.cmd`, true))) return undefined; - const packageRoot = `${directory}/node_modules/${command}`; + const name = command.replace(SHIM_SUFFIX, ""); + const shimDirectory = directory.replace(/[\\/]+$/, ""); + if (!(await isExecutableFile(filesystem, `${shimDirectory}/${name}.cmd`, true))) return undefined; + return packageBin(filesystem, packageRootBeside(shimDirectory, name), name); +} + +// why: a global install puts its shims beside `node_modules`; a local one puts them in `node_modules/.bin`, beside the package. +function packageRootBeside(shimDirectory: string, name: string): string { + return /(^|[\\/])node_modules[\\/]\.bin$/i.test(shimDirectory) + ? `${win32.dirname(shimDirectory)}/${name}` + : `${shimDirectory}/node_modules/${name}`; +} + +async function packageBin( + filesystem: Filesystem, + packageRoot: string, + name: string, +): Promise { try { const { bin } = JSON.parse(await filesystem.readFile(`${packageRoot}/package.json`)) as { bin?: unknown; }; const relative = - typeof bin === "string" ? bin : (bin as Record | undefined)?.[command]; + typeof bin === "string" ? bin : (bin as Record | undefined)?.[name]; if (typeof relative !== "string") return undefined; const target = `${packageRoot}/${relative.replace(/^\.\//, "")}`; return (await isExecutableFile(filesystem, target, true)) ? target : undefined; @@ -54,6 +72,26 @@ function isPath(command: string, windows: boolean): boolean { return command.includes("/") || (windows && command.includes("\\")); } +async function locatePath( + filesystem: Filesystem, + command: string, + windows: boolean, +): Promise { + if (windows && SHIM_SUFFIX.test(command)) { + return npmShimTarget(filesystem, win32.dirname(command), win32.basename(command)); + } + return (await isExecutableFile(filesystem, command, windows)) ? command : undefined; +} + +async function executableIn( + filesystem: Filesystem, + directory: string, + command: string, +): Promise { + const candidate = `${directory}/${command}`; + return (await isExecutableFile(filesystem, candidate, false)) ? candidate : undefined; +} + async function locate( filesystem: Filesystem, command: string, @@ -61,17 +99,12 @@ async function locate( platform: NodeJS.Platform, ): Promise { const windows = platform === "win32"; - if (isPath(command, windows)) { - return (await isExecutableFile(filesystem, command, windows)) ? command : undefined; - } + if (isPath(command, windows)) return locatePath(filesystem, command, windows); + const lookIn = windows ? npmShimTarget : executableIn; // why: Windows separates PATH entries with `;`, and its drive letters hold a `:`. for (const directory of (pathVariable ?? "").split(windows ? ";" : ":")) { if (directory === "") continue; - const candidate = windows - ? await npmShimTarget(filesystem, directory, command) - : (await isExecutableFile(filesystem, `${directory}/${command}`, false)) - ? `${directory}/${command}` - : undefined; + const candidate = await lookIn(filesystem, directory, command); if (candidate !== undefined) return candidate; } return undefined; From 2596c35601c4226512b49bc28cfda911ccf6c7de Mon Sep 17 00:00:00 2001 From: Xavier Date: Fri, 30 Oct 2026 09:58:05 -0300 Subject: [PATCH 4/4] fix(agent-device): the supervisor is given the host platform `findAgentDevice` read `process.platform` when no platform was passed, and the supervisor passed none, so on a Windows host the supervisor's tests (POSIX PATH and modes) took the Windows lookup and failed. The platform is now injected like `nodePath` and `nodeVersion`: a `hostPlatform` on `WorkerContext`, set from `process.platform` in the daemon's composition root, passed through the supervisor; the default is gone. Test harnesses fix it to "linux". Also corrects the install comment: a read-only file reports 0o444. Addresses blind review R1 (and claims note R2) on #1055. Co-Authored-By: Claude Opus 5.5 --- src/agent-device/host/agent-device-supervisor.test.ts | 1 + src/agent-device/host/agent-device-supervisor.ts | 2 ++ src/agent-device/host/install.ts | 4 ++-- src/agent-device/host/upstream.test.ts | 1 + src/agent-device/worker.ts | 1 + src/daemon/main.ts | 1 + src/modules/testing.ts | 1 + src/modules/types.ts | 1 + 8 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/agent-device/host/agent-device-supervisor.test.ts b/src/agent-device/host/agent-device-supervisor.test.ts index c0adc83b5..9def2d269 100644 --- a/src/agent-device/host/agent-device-supervisor.test.ts +++ b/src/agent-device/host/agent-device-supervisor.test.ts @@ -187,6 +187,7 @@ async function arrange(options: Options = {}) { filesystem, healthProbe: health, home: simlockHome, + hostPlatform: "linux", ...supervisorRole(options), leaseMaxTtlMs: options.leaseMaxTtlMs ?? 4 * 60 * 60_000, logger, diff --git a/src/agent-device/host/agent-device-supervisor.ts b/src/agent-device/host/agent-device-supervisor.ts index 60c074f46..d00479e3c 100644 --- a/src/agent-device/host/agent-device-supervisor.ts +++ b/src/agent-device/host/agent-device-supervisor.ts @@ -90,6 +90,7 @@ export interface AgentDeviceSupervisorOptions { readonly filesystem: Filesystem; readonly healthProbe: AgentDeviceHealthProbe; readonly home: string; + readonly hostPlatform: NodeJS.Platform; readonly ios?: AgentDeviceIosSigning; readonly leaseMaxTtlMs: number; readonly logger: Logger; @@ -326,6 +327,7 @@ export class AgentDeviceSupervisor { o.filesystem, o.config.command, pathVariableOf(o.baseEnvironment), + o.hostPlatform, ); if (!install.ok) { this.#fail(install.reason, install.message); diff --git a/src/agent-device/host/install.ts b/src/agent-device/host/install.ts index f736c4305..c83be94ad 100644 --- a/src/agent-device/host/install.ts +++ b/src/agent-device/host/install.ts @@ -10,7 +10,7 @@ export type AgentDeviceInstall = readonly message: string; }; -// why: Windows has no execute bit; Node reports every file there as 0o666, so any file counts. +// why: Windows has no execute bit; Node reports a file there as 0o666 (0o444 when read-only), so any file counts. async function isExecutableFile( filesystem: Filesystem, path: string, @@ -122,7 +122,7 @@ export async function findAgentDevice( filesystem: Filesystem, command: string, pathVariable: string | undefined, - platform: NodeJS.Platform = process.platform, + platform: NodeJS.Platform, ): Promise { const found = await locate(filesystem, command, pathVariable, platform); const notFound = { diff --git a/src/agent-device/host/upstream.test.ts b/src/agent-device/host/upstream.test.ts index f52d9b200..b70961a78 100644 --- a/src/agent-device/host/upstream.test.ts +++ b/src/agent-device/host/upstream.test.ts @@ -73,6 +73,7 @@ async function arrange(version: string) { filesystem, healthProbe: health, home, + hostPlatform: "linux", leaseMaxTtlMs, logger: new JsonLinesLogger({ clock, level: "debug", sink: new MemoryLogSink() }), nodePath, diff --git a/src/agent-device/worker.ts b/src/agent-device/worker.ts index d01b26adf..9a951be7f 100644 --- a/src/agent-device/worker.ts +++ b/src/agent-device/worker.ts @@ -127,6 +127,7 @@ export function createWorkerWith( logger: ctx.logger, nodePath: ctx.nodePath, nodeVersion: ctx.nodeVersion, + hostPlatform: ctx.hostPlatform, platforms: ctx.platforms, processRunner: ctx.processRunner, processSupervisor: ctx.processSupervisor, diff --git a/src/daemon/main.ts b/src/daemon/main.ts index 72cd7a5c6..a6fe2f5a1 100644 --- a/src/daemon/main.ts +++ b/src/daemon/main.ts @@ -509,6 +509,7 @@ async function composeDaemon( leaseEnvironment, nodePath: process.execPath, nodeVersion: process.versions.node, + hostPlatform: process.platform, platforms: drivers.map((driver) => driver.platform), processRunner, processSupervisor, diff --git a/src/modules/testing.ts b/src/modules/testing.ts index e1e85cb39..17766ced7 100644 --- a/src/modules/testing.ts +++ b/src/modules/testing.ts @@ -186,6 +186,7 @@ export async function fakeWorkerContext(name: string, config: C): Promise { readonly environment: NodeJS.ProcessEnv; readonly nodePath: string; readonly nodeVersion: string; + readonly hostPlatform: NodeJS.Platform; readonly platforms: readonly Platform[]; readonly leaseEnvironment: Readonly>; readonly registry: ModuleRegistryView;