From ce1240fa9b3b74983cc22171469c24d0708b10ea Mon Sep 17 00:00:00 2001 From: amankumarsingh77 Date: Tue, 28 Jul 2026 19:46:57 +0530 Subject: fix(tool): stop the socket gate rejecting every tool call on Windows The tool gate ran access() on DAEMON_SOCKET_PATH, which on Windows is the named pipe \\.\pipe\pi-browser-daemon. Named pipes are not filesystem entries, so access() always fails there and every browser_* call returned "Browser harness not initialized" no matter how healthy the daemon was. spawn.ts already skipped the identical check for this reason; that knowledge is now one shared daemonSocketMayExist() used by both call sites, with platform and path as parameters so the branch is testable off-platform. Report: docs/superpowers/reports/2026-07-26-bug-audit.md#f1 Co-Authored-By: Claude Opus 5 (1M context) --- src/util/tool.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'src/util') diff --git a/src/util/tool.ts b/src/util/tool.ts index e4bb5ba..76087bc 100644 --- a/src/util/tool.ts +++ b/src/util/tool.ts @@ -8,8 +8,7 @@ import type { ToolRenderResultOptions, } from "@mariozechner/pi-coding-agent"; import type { Component } from "@mariozechner/pi-tui"; -import { access } from "node:fs/promises"; -import { DAEMON_SOCKET_PATH } from "../daemon/protocol"; +import { daemonSocketMayExist } from "../daemon/spawn"; import type { BrowserClient } from "../client"; import type { Result } from "./result"; @@ -141,9 +140,7 @@ export const registerBrowserTool = ( // Check daemon socket exists before attempting browser control. // If missing, the user hasn't run /browser-setup yet. Return a clear // error so the agent knows to direct the user to initialize. - try { - await access(DAEMON_SOCKET_PATH); - } catch { + if (!(await daemonSocketMayExist())) { return toToolResult( { success: false, -- cgit v1.2.3