aboutsummaryrefslogtreecommitdiff
path: root/src/setup.ts
diff options
context:
space:
mode:
authorAman Kumar <145339995+amankumarsingh77@users.noreply.github.com>2026-07-12 22:03:43 +0530
committerGitHub <noreply@github.com>2026-07-12 22:03:43 +0530
commitcf92c10eda651cdad882aa050439c80d2f40b4b1 (patch)
tree789e211f90c8548bac7b149ddfecc4312a6ba037 /src/setup.ts
parentf6bab02b6b93c3804ec83b853e333fba417a0988 (diff)
fix: make browser daemon setup work on Windows (#7) (#12)
The Unix socket daemon introduced in v0.6.0 made several POSIX-only assumptions that break setup on Windows: - protocol.ts hardcoded a Unix socket path (/tmp/pi-browser-daemon.sock). Node IPC on Windows requires a named pipe (\\.\pipe\<name>); a /tmp path is not a valid net listen/connect target there. - spawn.ts spawned the bare tsx binary / `npx` and probed the non-Windows .bin/tsx shim. On Windows npm binaries are .cmd shims that must run via a shell, and spawning them directly fails with EINVAL / ENOENT. - isDaemonRunning() pre-checked the socket with fs.access(), which always fails for a named pipe and would report a live daemon as dead. - stale-socket unlink() would throw on a named pipe path. Changes: - DAEMON_SOCKET_PATH is now platform-aware: named pipe on win32, Unix socket elsewhere. - spawnDaemon() resolves tsx.cmd / npx.cmd on Windows, runs via shell with per-token quoting (paths with spaces) and windowsVerbatimArguments. - isDaemonRunning() skips the fs.access pre-check on Windows and probes the pipe directly. - stale-socket cleanup is a no-op on Windows (named pipes self-clean). - setup.ts daemon-failure message uses the actual DAEMON_SOCKET_PATH. Closes #7
Diffstat (limited to 'src/setup.ts')
-rw-r--r--src/setup.ts3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/setup.ts b/src/setup.ts
index 561a343..1ff7c36 100644
--- a/src/setup.ts
+++ b/src/setup.ts
@@ -8,6 +8,7 @@ import type { ExtensionAPI } from "@mariozechner/pi-coding-agent";
import { execSync } from "node:child_process";
import type { BrowserClient } from "./client";
import { ensureDaemon } from "./daemon/spawn";
+import { DAEMON_SOCKET_PATH } from "./daemon/protocol";
// ── Public: register the /browser-setup slash command ──────────────────────
@@ -41,7 +42,7 @@ export async function performSetup(client: BrowserClient): Promise<SetupResult>
// Step 2: Start the browser daemon (spawns if not running, silently reuses if alive)
const daemonReady = await ensureDaemon();
if (!daemonReady) {
- return { success: false, error: "Could not start the browser daemon. Check /tmp/pi-browser-daemon.sock." };
+ return { success: false, error: `Could not start the browser daemon. Check ${DAEMON_SOCKET_PATH}.` };
}
// Step 3: Connect to Chrome DevTools