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/CHANGELOG.md +12 -1
- package/package.json +2 -1
- package/skills/pi-browser-harness/SKILL.md +17 -1
- package/src/cdp/daemon-transport.ts +277 -0
- package/src/client.ts +16 -2
- package/src/daemon/bridge.ts +411 -0
- package/src/daemon/index.ts +114 -0
- package/src/daemon/protocol.ts +162 -0
- package/src/daemon/server.ts +245 -0
- package/src/daemon/spawn.ts +85 -0
- package/src/domains/navigate.ts +17 -3
- package/src/domains/setup.ts +41 -0
- package/src/index.ts +46 -25
- package/src/registry.ts +3 -0
- package/src/setup.ts +45 -39
- package/src/util/tool.ts +19 -0
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(
|