pi-browser-harness 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/util/tool.ts CHANGED
@@ -9,6 +9,8 @@ import type {
9
9
  ToolRenderResultOptions,
10
10
  } from "@mariozechner/pi-coding-agent";
11
11
  import type { Component } from "@mariozechner/pi-tui";
12
+ import { access } from "node:fs/promises";
13
+ import { DAEMON_SOCKET_PATH } from "../daemon/protocol";
12
14
  import type { BrowserClient } from "../client";
13
15
  import type { Result } from "./result";
14
16
 
@@ -142,6 +144,23 @@ export const registerBrowserTool = (
142
144
  : {}),
143
145
  async execute(_toolCallId, args, signal, onUpdate, extensionCtx) {
144
146
  if (def.ensureAlive !== false) {
147
+ // Check daemon socket exists before attempting browser control.
148
+ // If missing, the user hasn't run /browser-setup yet. Return a clear
149
+ // error so the agent knows to direct the user to initialize.
150
+ try {
151
+ await access(DAEMON_SOCKET_PATH);
152
+ } catch {
153
+ return toToolResult(
154
+ {
155
+ success: false,
156
+ error: {
157
+ kind: "not_connected",
158
+ message: "Browser harness not initialized. Run /browser-setup first",
159
+ },
160
+ },
161
+ def.name,
162
+ );
163
+ }
145
164
  const alive = await client.ensureAlive();
146
165
  if (!alive.success) {
147
166
  return toToolResult(