Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Windows: start every server and electron console child hidden
skygunner0163e1782e99
diff --git a/electron/android-device.mjs b/electron/android-device.mjsindex 75fb8a5af8..d32c744815 100644--- a/electron/android-device.mjs+++ b/electron/android-device.mjs@@ -119,6 +119,7 @@ export function createAndroidDeviceController(options = {}) {maxBuffer: extra.maxBuffer ?? 32 * 1024 * 1024,encoding: extra.encoding ?? "utf8",env: { ...process.env, ADB_TRACE: "" },+ windowsHide: true,});return result;};diff --git a/electron/android-device.test.mjs b/electron/android-device.test.mjsindex bbd094afef..8d0fe8ae85 100644--- a/electron/android-device.test.mjs+++ b/electron/android-device.test.mjs@@ -85,4 +85,16 @@ describe("Android USB device bridge", () => {}),).rejects.toThrow("basic punctuation");});++ it("runs adb hidden so Windows does not give it a visible console", async () => {+ const optionsSeen = [];+ const run = async (_binary, args, options) => {+ optionsSeen.push(options);+ return { stdout: devicesOutput, stderr: "" };+ };+ const controller = createAndroidDeviceController({ run, resolveBinary: () => "/trusted/adb" });++ await controller.status();+ expect(optionsSeen.at(-1)?.windowsHide).toBe(true);+ });});diff --git a/electron/cua.mjs b/electron/cua.mjsindex fcf7635a0d..01e390108b 100644--- a/electron/cua.mjs+++ b/electron/cua.mjs@@ -431,6 +431,7 @@ export async function cuaPermissionsStatus() {killSignal: "SIGKILL",maxBuffer: 65_536,env: { ...process.env, ...CUA_ENV },+ windowsHide: true,}).catch((error) => ({ stdout: error.stdout }));try {return { available: true, ...JSON.parse(out.stdout) };diff --git a/server/cli-setup.ts b/server/cli-setup.tsindex 27684f8d7b..497847a0c8 100644--- a/server/cli-setup.ts+++ b/server/cli-setup.ts@@ -47,7 +47,7 @@ export async function runSetupCli(cli: string, args: string[], environment: Recodelete env.CLAUDE_CODE_ENTRYPOINT;const command = resolveCli(cli, args);await new Promise<void>((done, reject) => {- const child = spawn(command.command, command.args, { env, stdio: "inherit" });+ const child = spawn(command.command, command.args, { env, stdio: "inherit", windowsHide: true });child.once("error", () => reject(new Error(`Could not start ${cli}. Check that it is installed and on PATH.`)));child.once("exit", (code, signal) => {if (code === 0) done();diff --git a/server/cli.ts b/server/cli.tsindex 6b04ca3d16..0849b958bb 100644--- a/server/cli.ts+++ b/server/cli.ts@@ -753,7 +753,7 @@ export async function runServe(options: CliOptions, log: (line: string) => void}if (startupCancelled) throw new SetupCancelled();if (publicUrl) env.OMB_PUBLIC_URL = publicUrl;- child = spawn(entry.command, entry.args, { env, stdio: [ownerToken ? "pipe" : "ignore", logFd ?? "inherit", logFd ?? "inherit"] });+ child = spawn(entry.command, entry.args, { env, stdio: [ownerToken ? "pipe" : "ignore", logFd ?? "inherit", logFd ?? "inherit"], windowsHide: true });if (ownerToken) {child.stdin?.on("error", () => {});child.stdin?.end(`${ownerToken}\n`);diff --git a/server/drivers/pi-mcp-extension.ts b/server/drivers/pi-mcp-extension.tsindex 9afb2a0019..abe69dbcb2 100644--- a/server/drivers/pi-mcp-extension.ts+++ b/server/drivers/pi-mcp-extension.ts@@ -104,6 +104,7 @@ export class StdioMcp {this.child = spawn(def.command, def.args ?? [], {stdio: ["pipe", "pipe", "pipe"],env: { ...process.env, ...def.env },+ windowsHide: true,});this.child.stderr.on("data", () => {/* best-effort drain so a chatty server never blocks */diff --git a/server/headless/host-doctor.ts b/server/headless/host-doctor.tsindex 82e1cec496..f0213a2531 100644--- a/server/headless/host-doctor.ts+++ b/server/headless/host-doctor.ts@@ -266,7 +266,7 @@ export function hostReport(checks: readonly HostCheck[]): { result: Record<strinfunction run(command: string, args: string[]): Promise<CommandResult> {return new Promise((done) => {- execFile(command, args, { timeout: 10_000, env: { ...process.env, LC_ALL: "C" } }, (error, stdout, stderr) => {+ execFile(command, args, { timeout: 10_000, env: { ...process.env, LC_ALL: "C" }, windowsHide: true }, (error, stdout, stderr) => {done({ ok: !error, stdout: String(stdout), stderr: String(stderr), missing: (error as NodeJS.ErrnoException | null)?.code === "ENOENT" });});});diff --git a/server/local-vm-profiles.ts b/server/local-vm-profiles.tsindex 0b488be39a..af95fe5ace 100644--- a/server/local-vm-profiles.ts+++ b/server/local-vm-profiles.ts@@ -97,7 +97,7 @@ export async function rescueFirefoxProfile(runtime: string, target: LocalVmTargetry {const { command, args } = resolveCliSpawn(runtime, ["cp", `${target.containerName}:${PROFILE_IN_CONTAINER}`, staging]);try {- await run(command, args, { timeout: 5 * 60_000, maxBuffer: 1024 * 1024, env: { ...process.env, PATH: augmentedPath() } });+ await run(command, args, { timeout: 5 * 60_000, maxBuffer: 1024 * 1024, env: { ...process.env, PATH: augmentedPath() }, windowsHide: true });} catch (error) {const failure = error as { stderr?: string; message?: string };if (NOT_IN_CONTAINER.test(`${failure.stderr ?? ""} ${failure.message ?? ""}`)) return "none";@@ -137,7 +137,7 @@ export async function rescueInstalledApps(runtime: string, target: LocalVmTargettry {const { command, args } = resolveCliSpawn(runtime, ["cp", `${target.containerName}:${APPS_IN_CONTAINER}`, staging]);try {- await run(command, args, { timeout: 5 * 60_000, maxBuffer: 1024 * 1024, env: { ...process.env, PATH: augmentedPath() } });+ await run(command, args, { timeout: 5 * 60_000, maxBuffer: 1024 * 1024, env: { ...process.env, PATH: augmentedPath() }, windowsHide: true });} catch (error) {const failure = error as { stderr?: string; message?: string };if (NOT_IN_CONTAINER.test(`${failure.stderr ?? ""} ${failure.message ?? ""}`)) return "none";diff --git a/server/service-cli.ts b/server/service-cli.tsindex de90cc7c03..d2f8e8201e 100644--- a/server/service-cli.ts+++ b/server/service-cli.ts@@ -122,7 +122,7 @@ function pinnedCopy(input: ServiceInstallInput, io: ServiceIo): string | null {function installWithNpm(prefix: string, version: string): boolean {mkdirSync(prefix, { recursive: true, mode: 0o700 });const npm = process.platform === "win32" ? "npm.cmd" : "npm";- return spawnSync(npm, ["install", "--prefix", prefix, `openmausbot@${version}`, "--no-audit", "--no-fund"], { stdio: "inherit" }).status === 0;+ return spawnSync(npm, ["install", "--prefix", prefix, `openmausbot@${version}`, "--no-audit", "--no-fund"], { stdio: "inherit", windowsHide: true }).status === 0;}function bundleHasSentinel(script: string): boolean {diff --git a/server/tailscale.test.ts b/server/tailscale.test.tsindex 49acaf8fbf..955c53c6b8 100644--- a/server/tailscale.test.ts+++ b/server/tailscale.test.ts@@ -57,9 +57,11 @@ describe("serve --tailscale", () => {const status: TailscaleStatus = { cli: "/usr/bin/tailscale", dnsName: "mini.tail1234.ts.net", addresses: [], backendState: "Running", httpsEnabled: true };const fakeServe = (exitCode: number | null, stderr = "") => {const calls: string[][] = [];+ const options: Array<Record<string, unknown>> = [];const children: Array<EventEmitter & { kill(signal: string): void; killed: string[] }> = [];- const spawnImpl = ((_cli: string, args: string[]) => {+ const spawnImpl = ((_cli: string, args: string[], spawnOptions: Record<string, unknown>) => {calls.push(args);+ options.push(spawnOptions);const child: EventEmitter & { stderr: EventEmitter; killed: string[]; kill(signal: string): void } = Object.assign(new EventEmitter(), {stderr: new EventEmitter(), killed: [] as string[], kill(signal: string) { child.killed.push(signal); setImmediate(() => child.emit("exit", null)); },});@@ -67,7 +69,7 @@ describe("serve --tailscale", () => {if (exitCode !== null) setImmediate(() => { child.stderr.emit("data", Buffer.from(stderr)); child.emit("exit", exitCode); });return child;}) as never;- return { calls, children, spawnImpl };+ return { calls, options, children, spawnImpl };};it("serves in the foreground, notes it, and turns it off when serve stops", async () => {@@ -79,6 +81,8 @@ describe("serve --tailscale", () => {expect(served.origin).toBe("https://mini.tail1234.ts.net");expect(fake.calls).toEqual([["serve", "--https=443", "http://127.0.0.1:8799"]]);expect(fake.calls[0]).not.toContain("--bg");+ // a console child spawned from the desktop shell flashes a visible terminal window on Windows otherwise+ expect(fake.options[0]?.windowsHide).toBe(true);expect(existsSync(tailscaleMarker(dir))).toBe(true);await served.stop();expect(fake.children[0]!.killed).toEqual(["SIGTERM"]);diff --git a/server/tailscale.ts b/server/tailscale.tsindex 4283ed1c5e..fa9817721d 100644--- a/server/tailscale.ts+++ b/server/tailscale.ts@@ -62,7 +62,7 @@ function run(cli: string, args: string[], timeoutMs: number): Promise<{ ok: boolexecFile(cli,args,- { timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 16 * 1024 * 1024, env: tailscaleEnvironment() },+ { timeout: timeoutMs, killSignal: "SIGKILL", maxBuffer: 16 * 1024 * 1024, windowsHide: true, env: tailscaleEnvironment() },(error, stdout, stderr) => {const code = error && "code" in error && typeof error.code === "number" ? error.code : error ? null : 0;resolve({ ok: !error, stdout: String(stdout ?? ""), stderr: String(stderr ?? ""), code });@@ -152,7 +152,7 @@ export async function tailscaleServe(if (!status.httpsEnabled) return { failure: "https-not-enabled" };const origin = httpsPort === 443 ? `https://${status.dnsName}` : `https://${status.dnsName}:${httpsPort}`;if (await (options.otherServer ?? (() => Promise.resolve(false)))(origin)) return { failure: "other-server" };- const child = (options.spawnImpl ?? spawn)(status.cli, ["serve", `--https=${httpsPort}`, `http://127.0.0.1:${localPort}`], { stdio: ["ignore", "ignore", "pipe"], env: tailscaleEnvironment() });+ const child = (options.spawnImpl ?? spawn)(status.cli, ["serve", `--https=${httpsPort}`, `http://127.0.0.1:${localPort}`], { stdio: ["ignore", "ignore", "pipe"], env: tailscaleEnvironment(), windowsHide: true });let stderr = "";child.stderr?.on("data", (chunk: Buffer) => { stderr = (stderr + chunk.toString()).slice(-4096); });const exited = new Promise<number | null>((done) => { child.once("exit", (code) => done(code)); child.once("error", () => done(-1)); });diff --git a/server/tunnel.ts b/server/tunnel.tsindex f6cb2b5540..67f7083c0d 100644--- a/server/tunnel.ts+++ b/server/tunnel.ts@@ -236,6 +236,7 @@ export async function ensureCloudflared(options: {const child = spawn(process.execPath, [prepareEntry(options.here), "--current", "--root", options.dataDir], {env,stdio: ["ignore", "inherit", "inherit"],+ windowsHide: true,});child.on("error", (error) => fail(new Error(`could not prepare cloudflared: ${error.message}`)));child.on("exit", (code) => (code === 0 ? done() : fail(new Error(`the cloudflared ${refreshStaged ? "refresh" : "download"} failed (exit ${code ?? "signal"})`))));diff --git a/server/vps-ssh-windows-hide.test.ts b/server/vps-ssh-windows-hide.test.tsnew file mode 100644index 0000000000..b75b1fc78c--- /dev/null+++ b/server/vps-ssh-windows-hide.test.ts@@ -0,0 +1,65 @@+// The wake script is a console child: without windowsHide Windows gives it a visible console window. These tests+// stub the platform because the POSIX wake fixtures cannot run on the Windows CI shards that exercise this path.+import { EventEmitter } from "node:events";+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";+import { tmpdir } from "node:os";+import { join } from "node:path";+import { afterEach, describe, expect, it, vi } from "vitest";++import { ensureVpsSshMaster, prepareVpsSsh, VPS_SSH_DIR, VPS_WAKE_SCRIPT } from "./vps-ssh.ts";++const spawns = vi.hoisted(() => [] as Array<{ file: string; args: string[]; options: Record<string, unknown> }>);++vi.mock("node:child_process", async (importOriginal) => {+ const actual = await importOriginal<typeof import("node:child_process")>();+ return {+ ...actual,+ spawn(file: string, args: string[], options: Record<string, unknown>) {+ spawns.push({ file, args, options });+ const child = Object.assign(new EventEmitter(), { pid: 60_000, stderr: new EventEmitter() });+ setImmediate(() => child.emit("close", 0, null));+ return child;+ },+ };+});++const roots: string[] = [];+afterEach(() => {+ vi.unstubAllGlobals();+ for (const root of roots.splice(0)) rmSync(root, { recursive: true, force: true });+});++/** A host that refuses SSH, with an executable wake script, so ensureVpsSshMaster runs the script as a child. */+function refusingHost() {+ const root = mkdtempSync(join(tmpdir(), "omb-vps-hide-"));+ roots.push(root);+ const bin = join(root, "bin");+ const data = join(root, "data");+ mkdirSync(bin);+ mkdirSync(data);+ writeFileSync(join(bin, "ssh"), [+ "#!/bin/sh",+ `echo 'ssh: connect to host refused.example port 22: Connection refused' >&2`,+ "exit 255",+ "",+ ].join("\n"), { mode: 0o700 });+ const ssh = prepareVpsSsh(data, bin, "linux");+ writeFileSync(join(data, VPS_SSH_DIR, VPS_WAKE_SCRIPT), "#!/bin/sh\nexit 0\n", { mode: 0o700 });+ return ssh;+}++describe("VPS wake script spawn options", () => {+ it("hides the wake script's console on Windows, without a process group there", async () => {+ vi.stubGlobal("process", { ...process, platform: "win32" });+ const ssh = refusingHost();+ await expect(ensureVpsSshMaster(ssh, "hidden-vps")).rejects.toThrow("Connection refused");+ expect(spawns.at(-1)?.options).toMatchObject({ windowsHide: true, detached: false });+ });++ it("keeps the POSIX process group while hiding the console", async () => {+ vi.stubGlobal("process", { ...process, platform: "linux" });+ const ssh = refusingHost();+ await expect(ensureVpsSshMaster(ssh, "grouped-vps")).rejects.toThrow("Connection refused");+ expect(spawns.at(-1)?.options).toMatchObject({ windowsHide: true, detached: true });+ });+});diff --git a/server/vps-ssh.ts b/server/vps-ssh.tsindex 38b845da35..49027739f4 100644--- a/server/vps-ssh.ts+++ b/server/vps-ssh.ts@@ -121,7 +121,7 @@ function runWakeScript(file: string, alias: string, pathValue: string, timeoutMsreturn new Promise((resolve, reject) => {if (timeoutMs <= 0) { reject(new Error("VPS SSH initialization timed out")); return; }const group = process.platform !== "win32";- const child = spawn(file, [alias], { env: { ...process.env, PATH: pathValue }, stdio: ["ignore", "ignore", "pipe"], detached: group });+ const child = spawn(file, [alias], { env: { ...process.env, PATH: pathValue }, stdio: ["ignore", "ignore", "pipe"], detached: group, windowsHide: true });let stderr = "";let timedOut = false;child.stderr?.on("data", (chunk: Buffer) => { stderr = (stderr + chunk.toString()).slice(-1000); });diff --git a/server/windows-hide.test.ts b/server/windows-hide.test.tsnew file mode 100644index 0000000000..a8bc9bcb42--- /dev/null+++ b/server/windows-hide.test.ts@@ -0,0 +1,170 @@+// Guard for issue #4660: a console-subsystem child spawned without windowsHide opens a visible console window on+// Windows. Every spawn/exec site in server/ and electron/ must set windowsHide (a no-op elsewhere), spread+// OWN_GROUP, or be allowlisted here with the reason it may stay as it is.+import { readFileSync, readdirSync, statSync } from "node:fs";+import { join } from "node:path";+import { fileURLToPath } from "node:url";+import { describe, expect, it } from "vitest";++const ROOT = fileURLToPath(new URL("..", import.meta.url)).replace(/\/+$/, "");+const APIS = ["spawn", "spawnSync", "execFile", "execFileSync", "exec", "execSync"];++const isTestFile = (name: string): boolean =>+ /\.(test|node-test|e2e|integration|spec)\.[cm]?[jt]sx?$/.test(name) || name.endsWith(".d.ts");++function childProcessFiles(): string[] {+ const found: string[] = [];+ const visit = (dir: string): void => {+ for (const entry of readdirSync(dir).sort()) {+ const path = join(dir, entry);+ if (statSync(path).isDirectory()) visit(path);+ else if (!isTestFile(entry) && /\.(ts|mts|mjs)$/.test(entry) && readFileSync(path, "utf8").includes("node:child_process")) found.push(path);+ }+ };+ for (const dir of ["server", "electron"]) visit(join(ROOT, dir));+ return found;+}++/** Blank whole comment lines (keeping offsets) so prose like "spawn (oom-score.ts)" is not read as a call. */+const withoutCommentLines = (src: string): string =>+ src.split("\n").map((line) => {+ const trimmed = line.trimStart();+ return trimmed.startsWith("//") || trimmed.startsWith("*") || trimmed.startsWith("/*") ? " ".repeat(line.length) : line;+ }).join("\n");++/** child_process entry points plus the local names bound to them (`promisify(execFile)`, `run = options.run ?? execFileAsync`, `run = execFile`). */+function trackedNames(src: string): Set<string> {+ const names = new Set(APIS);+ for (let round = 0; round < 3; round++) {+ const bare = (identifier: string | undefined): boolean =>+ identifier !== undefined && new RegExp(`^(${[...names].join("|")})$`).test(identifier);+ const aliased = (name: string | undefined, rhs: string | undefined): void => {+ if (name && !names.has(name) && bare(rhs)) names.add(name);+ };+ for (const m of src.matchAll(/(?:const|let)\s+(\w+)(?:\s*:[^=]+)?\s*=\s*promisify\((\w+)\)/g)) aliased(m[1], m[2]);+ for (const m of src.matchAll(/(?:const|let)\s+(\w+)(?:\s*:[^=]+)?\s*=\s*(?:[\w$.]+\s*\?\?\s*)?(\w+)\s*(?![\w(=])/g)) aliased(m[1], m[2]);+ for (const m of src.matchAll(/(?<![\w.=])(\w+)\s*=\s*(?!=)(\w+)\s*(?![\w(=])/g)) aliased(m[1], m[2]);+ }+ return names;+}++/** One entry per allowed unhidden site: `file` is repo-relative (a trailing `/` allows the whole directory), `match` picks the call when the file has several. */+const ALLOWED: Array<{ file: string; match?: string; why: string }> = [+ // Test rigs: spawn fixture servers under vitest on CI runners, never in the shipped desktop app.+ { file: "server/testing/", why: "test rig, runs under vitest only" },++ // Linux-only features and probes.+ { file: "server/bot-box/box-bridge.ts", match: "spawn(command[0]!", why: "runs inside the Linux bot box" },+ { file: "server/bot-box/box-probe.ts", match: "spawnSync(spec.engine.name", why: "runs inside the Linux bot box" },+ { file: "server/bot-box/box-probe.ts", match: 'spawnSync("python3"', why: "runs inside the Linux bot box" },+ { file: "server/bot-box/detect.ts", match: "spawnSync(bwrap", why: "bubblewrap probe; box detection reports not-linux off Linux" },+ { file: "server/bot-box/self-check.ts", match: 'spawn("sleep"', why: "Linux box self-check" },+ { file: "server/bot-box/self-check.ts", match: "spawn(wrapped.command", why: "Linux box self-check" },+ { file: "server/browser/desktop/policy.ts", match: "execFileSync(candidate", why: "bwrap sandbox policy probe, Linux" },+ { file: "server/browser/desktop/displays.ts", match: "spawn(xvnc", why: "Xvnc per-display server, Linux desktops only" },+ { file: "server/caddy.ts", match: 'spawnSync("tar"', why: "ensureCaddy refuses win32 before any download; the tar extraction is POSIX-only" },+ { file: "server/caddy.ts", match: "spawn(options.binary", why: "startCaddy is reachable only through ensureCaddy, so never on Windows" },+ { file: "server/cloud-clock-keeper.ts", match: "spawnSync(DATE", why: "/bin/date clock step, Linux cloud home" },+ { file: "server/cloud-home-start.ts", match: 'spawnSync("/usr/bin/flock"', why: "Linux cloud home" },+ { file: "server/cloud-home-start.ts", match: "spawnSync(command, args", why: "Linux cloud home" },+ { file: "server/cloud-home-start.ts", match: "spawn(command, args, { env: clockPipe", why: "Linux cloud home" },+ { file: "server/cloud-home-start.ts", match: "spawn(edgeBin", why: "Linux cloud home" },+ { file: "server/cloud-home-start.ts", match: "spawn(tunnel.command", why: "Linux cloud home" },+ { file: "server/fleet-cli.ts", match: 'execFileSync("/usr/bin/getent"', why: "Linux root fleet agent (getuid/getent)" },+ { file: "server/fleet-cli.ts", match: "execFileSync(process.execPath", why: "Linux root fleet agent (getuid/getent)" },+ { file: "server/fleet-cli.ts", match: "spawn(command!", why: "Linux root fleet agent (getuid/getent)" },+ { file: "server/host/conversation-folder-cleanup.ts", match: 'execFile("rm"', why: "GNU rm probe, Linux-gated" },+ { file: "server/host/conversation-folder-cleanup.ts", match: 'execFile("nice"', why: "GNU coreutils, Linux" },+ { file: "server/host/conversation-folder-cleanup.ts", match: 'execFile("chmod"', why: "GNU coreutils, Linux" },+ { file: "server/meetings/meetbot.ts", match: 'execFileSync("pactl"', why: "PulseAudio null sink, Linux meeting bot" },+ { file: "server/meetings/meetbot.ts", match: 'execFileSync("ffmpeg"', why: "Linux meeting bot" },+ { file: "server/meetings/meetbot.ts", match: "spawn(config.chrome", why: "/usr/bin/google-chrome, Linux meeting bot" },+ { file: "server/meetings/meetbot.ts", match: 'spawn("bash"', why: "whisper venv install, Linux" },+ { file: "server/meetings/meetbot.ts", match: "spawn(python", why: "whisper worker, Linux" },+ { file: "server/meetings/meetbot.ts", match: 'spawn("ffmpeg"', why: "Linux meeting bot" },+ { file: "server/server-launcher.ts", match: "spawn(process.execPath, server.args", why: "Linux container image entry" },+ { file: "server/engine-records.ts", match: "execFile(PS, args", why: "ps(1) process records, POSIX" },+ { file: "server/engine-records.ts", match: "execFileSync(PS", why: "ps(1) process records, POSIX" },+ { file: "server/proc-descendants.ts", match: "execFileSync(process.platform", why: "ps(1), POSIX" },++ // macOS-only.+ { file: "server/browser/chrome/resolve.ts", match: 'spawnSync("osascript"', why: "macOS AppleScript probe" },+ { file: "server/engine-standalone.ts", match: 'execFile("/usr/bin/codesign"', why: "macOS code signing" },+ { file: "server/headless/saved-servers.ts", match: 'spawnSync("/usr/bin/security"', why: "macOS keychain" },+ { file: "server/tts/system-voices.ts", match: "execFileAsync(file, args, { timeout", why: "macOS `say` voices; systemVoicesAvailable gates darwin" },+ { file: "electron/build-speech-helper.mjs", match: '"swiftc"', why: "macOS build tool, not shipped runtime" },+ { file: "electron/build-speech-helper.mjs", match: '"lipo"', why: "macOS build tool, not shipped runtime" },+ { file: "electron/build-speech-helper.mjs", match: '"codesign"', why: "macOS build tool, not shipped runtime" },+ { file: "electron/cloud-sync-mark.mjs", match: "/usr/bin/xattr", why: "macOS quarantine mark; the win32 branch writes Zone.Identifier without a child" },+ { file: "electron/cua.mjs", match: 'execFileAsync("/usr/bin/open"', why: "darwin-gated standalone driver attach (returns null off darwin)" },+ { file: "electron/shell-path.mjs", match: 'execFile(shell, ["-l", "-i", "-c"', why: "POSIX login-shell PATH probe; commandPath returns env.PATH on win32" },+ { file: "electron/speech.mjs", match: "/usr/bin/mkfifo", why: "macOS speech lifeline fifo" },+ { file: "electron/speech.mjs", match: "/usr/bin/open", why: "macOS helper launch; the Windows path sets windowsHide" },+ { file: "electron/system-name.mjs", match: "/usr/bin/id", why: "goes through run(), which sets windowsHide" },+ { file: "electron/system-name.mjs", match: 'exec("getent"', why: "goes through run(), which sets windowsHide" },+ { file: "electron/system-proxy.mjs", match: 'execFile("/usr/sbin/scutil"', why: "macOS proxy settings" },++ // Options come prebuilt, deliberately detached, or through an approved hiding helper.+ { file: "server/drivers/antigravity-runtime.ts", match: 'execFile(executablePath, ["--version"], options', why: "options are built just above with windowsHide" },+ { file: "server/drivers/codex-process.ts", match: "spawn()", why: "spawnHoldingSlot's callback parameter; callers spawn through spawnCli/execFileInGroup, which hide" },+ { file: "server/drivers/device-auth.ts", match: "private exec(args", why: "method declaration; its body spawns via procs.ts spawnCli, which hides on Windows" },+ { file: "server/github/gh-cli.ts", match: "spawn(file: string", why: "interface declaration, not a call" },+ { file: "server/github/gh-cli.ts", match: "spawn(file, args, env) {", why: "adapter method definition; its body sets windowsHide" },+ { file: "server/headless/prompt.ts", match: 'spawn(command, args, { stdio: "ignore", detached: true }', why: "deliberately detached + unref'd browser opener; Windows' opener rundll32 is GUI-subsystem" },+ { file: "server/env-path.ts", match: 'spawn(shell, ["-l", "-i", "-c"', why: "POSIX login-shell PATH probe ($SHELL), deliberately detached: an interactive shell takes the terminal's foreground" },+ { file: "server/vps-ssh.ts", match: 'execFile("ssh"', why: "needs a ControlMaster config, and prepareVpsSsh returns configPath null on win32, so ensureVpsSshMaster returns before this" },+ { file: "electron/elevated-install.mjs", match: "pkexec", why: "Linux package install (pkexec + .deb)" },+ { file: "electron/terminal-launch.mjs", match: "run(executable, args, options", why: "options come from the callers; the win32 caller passes windowsHide: true" },++ // Scanner artifacts.+ { file: "electron/launch-probes.mjs", match: "STARTERS", why: "instrumentation: matches a child_process name regex, not a spawn call" },+];++interface Site { line: number; api: string; text: string }++function callSites(src: string, names: Set<string>): Site[] {+ const sites: Site[] = [];+ const alt = [...names].sort((a, b) => b.length - a.length).join("|");+ const collect = (re: RegExp): void => {+ let m: RegExpExecArray | null;+ while ((m = re.exec(src))) {+ const open = m.index + m[0].length - 1;+ let depth = 0;+ let text = src.slice(open + 1, open + 400);+ for (let i = open; i < src.length && i - open < 8_000; i++) {+ if (src[i] === "(") depth++;+ else if (src[i] === ")") { depth--; if (depth === 0) { text = src.slice(open + 1, i); break; } }+ }+ sites.push({ line: src.slice(0, m.index).split("\n").length, api: m[1]!, text });+ }+ };+ collect(new RegExp(`(?<![\\w.])(${alt})\\s*\\(`, "g"));+ // `(options.spawnImpl ?? spawn)(...)`: the callee is a parenthesized expression naming a tracked entry point.+ collect(new RegExp(`\\([^()]*?(?<![\\w.])(${alt})\\b[^()]*?\\)\\s*\\(`, "g"));+ return sites;+}++describe("windows console hiding", () => {+ it("every child_process spawn in server/ and electron/ hides its console on Windows or is allowlisted", () => {+ const unhidden: string[] = [];+ for (const file of childProcessFiles()) {+ const rel = file.slice(ROOT.length + 1);+ const src = withoutCommentLines(readFileSync(file, "utf8"));+ const lines = src.split("\n");+ for (const site of callSites(src, trackedNames(src))) {+ if (/windowsHide|OWN_GROUP/.test(site.text)) continue;+ const line = (lines[site.line - 1] ?? "").trim();+ const why = ALLOWED.find((entry) =>+ (entry.file.endsWith("/") ? rel.startsWith(entry.file) : rel === entry.file)+ && (!entry.match || `${site.text}\n${line}`.includes(entry.match)),+ )?.why;+ if (!why) unhidden.push(`${rel}:${site.line} [${site.api}] ${line.replace(/\s+/g, " ").slice(0, 130)}`);+ }+ }+ expect(unhidden, [+ "child_process sites that hide no console on Windows (add windowsHide: true, or an allowlist entry with the",+ "reason it stays unhidden: POSIX-only, deliberately detached, or an approved helper):",+ ...unhidden,+ ].join("\n")).toEqual([]);+ });+});