@howaboua/pi-browser 0.0.14 → 0.0.16

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # @howaboua/pi-browser
2
2
 
3
+ ## 0.0.16
4
+
5
+ - Shortened browser timeout and tab-creation errors. They say what may have happened and what to check before retrying.
6
+
7
+ ## 0.0.15
8
+
9
+ - Browser settings clarify which listed host runs locally and where to set the Node.js executable for SSH hosts.
10
+ - Browser always uses compact tool help, including in standalone installs.
11
+
3
12
  ## 0.0.14
4
13
 
5
14
  - Updates use Pi's native changelog notices and `collapseChangelog` instead of custom suppression.
package/README.md CHANGED
@@ -10,7 +10,7 @@ The extension is the TypeScript counterpart of Pi Codex's browser custom tool. I
10
10
  pi install npm:@howaboua/pi-browser
11
11
  ```
12
12
 
13
- Requires Pi 1.0.0 or newer, Node.js 22.19 or newer, and a Chrome-family browser with remote debugging enabled at `chrome://inspect/#remote-debugging`.
13
+ Requires the latest Pi release, Node.js 22.19 or newer, and a Chrome-family browser with remote debugging enabled at `chrome://inspect/#remote-debugging`.
14
14
 
15
15
  Pi Codex 3.0.52 or newer is optional. Without it, Browser remains a normal top-level Pi tool. Do not load Pi Codex's example `browser.toml` custom tool alongside this extension.
16
16
 
@@ -841,10 +841,10 @@ function cdpTimeoutAttempts(method) {
841
841
  function timeoutError(method, attempts) {
842
842
  const seconds = CDP_TIMEOUT_MS / 1000;
843
843
  if (attempts > 1) {
844
- return new Error(`Chrome did not answer ${method} after two ${seconds}s attempts. The tab may be unresponsive or suspended.`);
844
+ return new Error(`${method} timed out twice (${seconds}s each). Tab may be unresponsive or suspended.`);
845
845
  }
846
846
  if (method === "Runtime.evaluate") {
847
- return new Error(`Chrome did not answer Runtime.evaluate within ${seconds}s. The expression or awaited promise may still be running; check its effect before retrying.`);
847
+ return new Error(`Runtime.evaluate timed out (${seconds}s). Expression or awaited promise may still be running. Check effects before retrying.`);
848
848
  }
849
849
  return new Error(`Chrome did not answer ${method} within ${seconds}s.`);
850
850
  }
@@ -1342,7 +1342,7 @@ class BrowserTabs {
1342
1342
  try {
1343
1343
  response = asRecord(await this.cdp.send("Target.createTarget", { url, background: true }), "Target.createTarget response");
1344
1344
  } catch (error) {
1345
- throw new Error(`Chrome did not confirm tab creation; a shared tab may exist. Run tabs before retrying: ${errorMessage(error)}`);
1345
+ throw new Error(`Tab may have opened as shared. Run tabs before retrying: ${errorMessage(error)}`);
1346
1346
  }
1347
1347
  if (typeof response["targetId"] !== "string")
1348
1348
  throw new Error("Chrome did not return a new tab target; run tabs before retrying");
@@ -1350,7 +1350,7 @@ class BrowserTabs {
1350
1350
  try {
1351
1351
  await this.remember(created);
1352
1352
  } catch (error) {
1353
- throw new Error(`Opened tab ${created} but could not save ownership; it remains shared: ${errorMessage(error)}`);
1353
+ throw new Error(`Opened tab ${created}. Ownership save failed. Tab remains shared: ${errorMessage(error)}`);
1354
1354
  }
1355
1355
  return created;
1356
1356
  }, signal);
@@ -1800,16 +1800,16 @@ async function discardCachedResult(handle) {
1800
1800
  }
1801
1801
 
1802
1802
  // src/browser/help.ts
1803
- function browserHelp(hosts = [], gpt = false) {
1803
+ function browserHelp(hosts = []) {
1804
1804
  const routed = hosts.length > 0;
1805
1805
  return {
1806
1806
  input: "{action,...fields}",
1807
1807
  ...routed ? {
1808
- host: `${hosts.join("|")}${gpt ? " optional; user-named host→all calls; refs/handles stay with host" : " optional; keep the user-named host on every call and reuse refs or handles only on their host"}`
1808
+ host: `${hosts.join("|")} optional; user-named host→all calls; refs/handles stay with host`
1809
1809
  } : {},
1810
- refs: gpt ? "tabs→open; ref_id/id/cursors stay with result" : "tabs -> open; keep ref_id/id/cursors with their result",
1811
- safety: gpt ? "MUST ask before unfamiliar low-trust navigation or consequential action unless authorised. MUST NOT close shared browser" : "Unless authorised, MUST ask before unfamiliar low-trust navigation or consequential action. MUST NOT close a shared browser",
1812
- batch: gpt ? "Independent only: {action_name:[{...fields}],...}; nonempty arrays; root host/response_length; omit item action" : "Batch independent actions only: {action_name:[{...fields}],...}. Nonempty arrays; host and response_length at root; omit item action",
1810
+ refs: "tabs→open; ref_id/id/cursors stay with result",
1811
+ safety: "MUST ask before unfamiliar low-trust navigation or consequential action unless authorised. MUST NOT close shared browser",
1812
+ batch: "Independent only: {action_name:[{...fields}],...}; nonempty arrays; root host/response_length; omit item action",
1813
1813
  actions: {
1814
1814
  help: "",
1815
1815
  tabs: "query? offset? owned_only? -> ref_id title url owned",
@@ -1821,7 +1821,7 @@ function browserHelp(hosts = [], gpt = false) {
1821
1821
  type: "ref_id text id?; id focuses",
1822
1822
  fill: "ref_id id|selector value; replace/clear text, select option value/label, boolean checks/unchecks",
1823
1823
  press: "ref_id key; focused element, e.g. Enter or Control+a",
1824
- wait: "ref_id selector|text|url_includes timeout_ms?; DOM presence or substring, default 10000ms",
1824
+ wait: "ref_id selector|text|url_includes timeout_ms?; DOM presence or substring",
1825
1825
  screenshot: "ref_id id?|selector?; brings tab to foreground -> file",
1826
1826
  navigate: "ref_id url",
1827
1827
  html: "ref_id id?|selector?",
@@ -1 +1 @@
1
- export declare function browserHelp(hosts?: readonly string[], gpt?: boolean): Record<string, unknown>;
1
+ export declare function browserHelp(hosts?: readonly string[]): Record<string, unknown>;
@@ -1,21 +1,15 @@
1
- export function browserHelp(hosts = [], gpt = false) {
1
+ export function browserHelp(hosts = []) {
2
2
  const routed = hosts.length > 0;
3
3
  return {
4
4
  input: "{action,...fields}",
5
5
  ...(routed
6
6
  ? {
7
- host: `${hosts.join("|")}${gpt ? " optional; user-named host→all calls; refs/handles stay with host" : " optional; keep the user-named host on every call and reuse refs or handles only on their host"}`,
7
+ host: `${hosts.join("|")} optional; user-named host→all calls; refs/handles stay with host`,
8
8
  }
9
9
  : {}),
10
- refs: gpt
11
- ? "tabs→open; ref_id/id/cursors stay with result"
12
- : "tabs -> open; keep ref_id/id/cursors with their result",
13
- safety: gpt
14
- ? "MUST ask before unfamiliar low-trust navigation or consequential action unless authorised. MUST NOT close shared browser"
15
- : "Unless authorised, MUST ask before unfamiliar low-trust navigation or consequential action. MUST NOT close a shared browser",
16
- batch: gpt
17
- ? "Independent only: {action_name:[{...fields}],...}; nonempty arrays; root host/response_length; omit item action"
18
- : "Batch independent actions only: {action_name:[{...fields}],...}. Nonempty arrays; host and response_length at root; omit item action",
10
+ refs: "tabs→open; ref_id/id/cursors stay with result",
11
+ safety: "MUST ask before unfamiliar low-trust navigation or consequential action unless authorised. MUST NOT close shared browser",
12
+ batch: "Independent only: {action_name:[{...fields}],...}; nonempty arrays; root host/response_length; omit item action",
19
13
  actions: {
20
14
  help: "",
21
15
  tabs: "query? offset? owned_only? -> ref_id title url owned",
@@ -27,7 +21,7 @@ export function browserHelp(hosts = [], gpt = false) {
27
21
  type: "ref_id text id?; id focuses",
28
22
  fill: "ref_id id|selector value; replace/clear text, select option value/label, boolean checks/unchecks",
29
23
  press: "ref_id key; focused element, e.g. Enter or Control+a",
30
- wait: "ref_id selector|text|url_includes timeout_ms?; DOM presence or substring, default 10000ms",
24
+ wait: "ref_id selector|text|url_includes timeout_ms?; DOM presence or substring",
31
25
  screenshot: "ref_id id?|selector?; brings tab to foreground -> file",
32
26
  navigate: "ref_id url",
33
27
  html: "ref_id id?|selector?",
@@ -75,7 +75,7 @@ async function manageAdvanced(ctx, initial) {
75
75
  ]);
76
76
  if (!selected || selected === BACK)
77
77
  return config;
78
- const value = (await ctx.ui.input("Remote Node path", config.remoteNodePath))?.trim();
78
+ const value = (await ctx.ui.input("Node.js executable on SSH hosts", config.remoteNodePath))?.trim();
79
79
  if (!value)
80
80
  continue;
81
81
  try {
@@ -105,7 +105,7 @@ async function openBrowserSettings(ctx) {
105
105
  return;
106
106
  while (true) {
107
107
  const hosts = `Hosts · ${config.hosts.length ? config.hosts.join(", ") : "local only"}`;
108
- const machine = `This machine · ${currentMachineRoute(config) ?? "unnamed local"}`;
108
+ const machine = `Local host name for routing · ${currentMachineRoute(config) ?? "unnamed local"}`;
109
109
  const selected = await ctx.ui.select("Browser settings", [
110
110
  hosts,
111
111
  machine,
@@ -120,10 +120,7 @@ async function openBrowserSettings(ctx) {
120
120
  continue;
121
121
  }
122
122
  if (selected === machine) {
123
- const route = await ctx.ui.select("This machine", [
124
- "Unnamed local browser",
125
- ...config.hosts,
126
- ]);
123
+ const route = await ctx.ui.select("Which listed host should open locally instead of over SSH?", ["Unnamed local browser", ...config.hosts]);
127
124
  if (route) {
128
125
  config = setCurrentMachineRoute(config, route === "Unnamed local browser" ? undefined : route);
129
126
  }
@@ -15,28 +15,9 @@ export default async function browserExtension(pi, sdk) {
15
15
  configError = error instanceof Error ? error.message : String(error);
16
16
  }
17
17
  const runtime = new BrowserRuntime(routes);
18
- let gpt = false;
19
- const tool = createBrowserTool(sdk, runtime, () => gpt);
18
+ const tool = createBrowserTool(sdk, runtime);
20
19
  registerBrowserCommand(pi);
21
20
  pi.registerTool(tool);
22
- try {
23
- const { registerGptPromptMode } = await import("@howaboua/pi-codex-conversion/prompt-mode");
24
- registerGptPromptMode(pi, (active) => {
25
- gpt = active;
26
- return [tool];
27
- });
28
- }
29
- catch (error) {
30
- if (!(error instanceof Error) ||
31
- !("code" in error) ||
32
- ![
33
- "ERR_MODULE_NOT_FOUND",
34
- "MODULE_NOT_FOUND",
35
- "ERR_PACKAGE_PATH_NOT_EXPORTED",
36
- ].includes(String(error.code)) ||
37
- !error.message.includes(CODE_MODE_PACKAGE))
38
- throw error;
39
- }
40
21
  const registration = await registerBrowserInCodeMode(pi, tool, sdk);
41
22
  pi.on("session_shutdown", async () => {
42
23
  registration?.unregister();
@@ -9,6 +9,6 @@ export declare function createBrowserTool({ defineTool, obj, opt, str, }: {
9
9
  obj: typeof schemaObj;
10
10
  opt: typeof schemaOpt;
11
11
  str: typeof schemaStr;
12
- }, runtime: BrowserRuntime, isGpt?: () => boolean): import("@earendil-works/pi-coding-agent").ToolDefinition<import("@earendil-works/pi-schema").Schema<{
12
+ }, runtime: BrowserRuntime): import("@earendil-works/pi-coding-agent").ToolDefinition<import("@earendil-works/pi-schema").Schema<{
13
13
  command?: string;
14
14
  }>, unknown, any> & import("@earendil-works/pi-coding-agent").ToolDefinition<any, any, any>;
@@ -1,4 +1,3 @@
1
- import { browserHelp } from "./browser/help.js";
2
1
  import { isRecordValue } from "./browser/parse-operation.js";
3
2
  import { parseBrowserRequest } from "./browser/request.js";
4
3
  export function prepareBrowserInput(input) {
@@ -19,7 +18,7 @@ export function prepareBrowserInput(input) {
19
18
  parseBrowserRequest(input);
20
19
  return { command: JSON.stringify(input) };
21
20
  }
22
- export function createBrowserTool({ defineTool, obj, opt, str, }, runtime, isGpt = () => false) {
21
+ export function createBrowserTool({ defineTool, obj, opt, str, }, runtime) {
23
22
  const parameters = obj({
24
23
  command: opt(str({ description: "help or JSON request" })),
25
24
  }, { open: false });
@@ -31,7 +30,7 @@ export function createBrowserTool({ defineTool, obj, opt, str, }, runtime, isGpt
31
30
  prepareArguments: prepareBrowserInput,
32
31
  async execute(_toolCallId, input, signal, onUpdate, ctx) {
33
32
  const request = parseBrowserRequest(input.command);
34
- let result = await runtime.execute(request, {
33
+ const result = await runtime.execute(request, {
35
34
  ownerId: ctx.sessionManager.getSessionId(),
36
35
  signal: signal ?? new AbortController().signal,
37
36
  onOperation(operation, index, total) {
@@ -53,8 +52,6 @@ export function createBrowserTool({ defineTool, obj, opt, str, }, runtime, isGpt
53
52
  });
54
53
  },
55
54
  });
56
- if (isGpt() && "help" in request)
57
- result = browserHelp(runtime.hosts, true);
58
55
  return {
59
56
  content: [{ type: "text", text: JSON.stringify(result) }],
60
57
  details: result,
@@ -1,4 +1,4 @@
1
1
  import type { BrowserRuntime } from "./browser/runtime.js";
2
- export declare function createBrowserTool(runtime: BrowserRuntime, isGpt?: () => boolean): import("@earendil-works/pi-coding-agent").ToolDefinition<import("@earendil-works/pi-schema").Schema<{
2
+ export declare function createBrowserTool(runtime: BrowserRuntime): import("@earendil-works/pi-coding-agent").ToolDefinition<import("@earendil-works/pi-schema").Schema<{
3
3
  command?: string;
4
4
  }>, unknown, any> & import("@earendil-works/pi-coding-agent").ToolDefinition<any, any, any>;
@@ -1,6 +1,6 @@
1
1
  import { defineTool } from "@earendil-works/pi-coding-agent";
2
2
  import { obj, opt, str } from "@earendil-works/pi-schema";
3
3
  import { createBrowserTool as createTool } from "./browser-tool-definition.js";
4
- export function createBrowserTool(runtime, isGpt = () => false) {
5
- return createTool({ defineTool, obj, opt, str }, runtime, isGpt);
4
+ export function createBrowserTool(runtime) {
5
+ return createTool({ defineTool, obj, opt, str }, runtime);
6
6
  }
@@ -13,10 +13,10 @@ function cdpTimeoutAttempts(method) {
13
13
  function timeoutError(method, attempts) {
14
14
  const seconds = CDP_TIMEOUT_MS / 1_000;
15
15
  if (attempts > 1) {
16
- return new Error(`Chrome did not answer ${method} after two ${seconds}s attempts. The tab may be unresponsive or suspended.`);
16
+ return new Error(`${method} timed out twice (${seconds}s each). Tab may be unresponsive or suspended.`);
17
17
  }
18
18
  if (method === "Runtime.evaluate") {
19
- return new Error(`Chrome did not answer Runtime.evaluate within ${seconds}s. The expression or awaited promise may still be running; check its effect before retrying.`);
19
+ return new Error(`Runtime.evaluate timed out (${seconds}s). Expression or awaited promise may still be running. Check effects before retrying.`);
20
20
  }
21
21
  return new Error(`Chrome did not answer ${method} within ${seconds}s.`);
22
22
  }
@@ -134,7 +134,7 @@ export class BrowserTabs {
134
134
  response = asRecord(await this.cdp.send("Target.createTarget", { url, background: true }), "Target.createTarget response");
135
135
  }
136
136
  catch (error) {
137
- throw new Error(`Chrome did not confirm tab creation; a shared tab may exist. Run tabs before retrying: ${errorMessage(error)}`);
137
+ throw new Error(`Tab may have opened as shared. Run tabs before retrying: ${errorMessage(error)}`);
138
138
  }
139
139
  if (typeof response["targetId"] !== "string")
140
140
  throw new Error("Chrome did not return a new tab target; run tabs before retrying");
@@ -143,7 +143,7 @@ export class BrowserTabs {
143
143
  await this.remember(created);
144
144
  }
145
145
  catch (error) {
146
- throw new Error(`Opened tab ${created} but could not save ownership; it remains shared: ${errorMessage(error)}`);
146
+ throw new Error(`Opened tab ${created}. Ownership save failed. Tab remains shared: ${errorMessage(error)}`);
147
147
  }
148
148
  return created;
149
149
  }, signal);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-browser",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Logged-in browser inspection and control for Pi, Code Mode and Notebook Mode.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,10 +45,10 @@
45
45
  "format:check": "oxfmt --check '**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,json,jsonc,json5,css}'"
46
46
  },
47
47
  "peerDependencies": {
48
- "@howaboua/pi-codex-conversion": ">=5.0.2",
49
- "@earendil-works/pi-ai": ">=1.0.0",
50
- "@earendil-works/pi-coding-agent": ">=1.5.0",
51
- "@earendil-works/pi-tui": ">=1.0.0"
48
+ "@howaboua/pi-codex-conversion": ">=5.1.1",
49
+ "@earendil-works/pi-ai": ">=1.6.1",
50
+ "@earendil-works/pi-coding-agent": ">=1.6.1",
51
+ "@earendil-works/pi-tui": ">=1.6.1"
52
52
  },
53
53
  "peerDependenciesMeta": {
54
54
  "@howaboua/pi-codex-conversion": {
@@ -56,12 +56,12 @@
56
56
  }
57
57
  },
58
58
  "devDependencies": {
59
- "@howaboua/pi-codex-conversion": "5.0.2",
60
- "@earendil-works/pi-ai": "1.6.0",
61
- "@earendil-works/pi-coding-agent": "1.6.0",
62
- "@types/node": "^26.6.6",
63
- "typescript": "^7.0.2",
64
- "oxfmt": "^0.78.0"
59
+ "@howaboua/pi-codex-conversion": "5.1.1",
60
+ "@earendil-works/pi-ai": "1.6.1",
61
+ "@earendil-works/pi-coding-agent": "1.6.1",
62
+ "@types/node": "26.6.6",
63
+ "typescript": "7.0.2",
64
+ "oxfmt": "0.79.0"
65
65
  },
66
66
  "pi": {
67
67
  "extensions": [
@@ -90,6 +90,6 @@
90
90
  "access": "public"
91
91
  },
92
92
  "dependencies": {
93
- "@earendil-works/pi-schema": "1.6.0"
93
+ "@earendil-works/pi-schema": "1.6.1"
94
94
  }
95
95
  }
@@ -1,24 +1,19 @@
1
1
  export function browserHelp(
2
2
  hosts: readonly string[] = [],
3
- gpt = false,
4
3
  ): Record<string, unknown> {
5
4
  const routed = hosts.length > 0;
6
5
  return {
7
6
  input: "{action,...fields}",
8
7
  ...(routed
9
8
  ? {
10
- host: `${hosts.join("|")}${gpt ? " optional; user-named host→all calls; refs/handles stay with host" : " optional; keep the user-named host on every call and reuse refs or handles only on their host"}`,
9
+ host: `${hosts.join("|")} optional; user-named host→all calls; refs/handles stay with host`,
11
10
  }
12
11
  : {}),
13
- refs: gpt
14
- ? "tabs→open; ref_id/id/cursors stay with result"
15
- : "tabs -> open; keep ref_id/id/cursors with their result",
16
- safety: gpt
17
- ? "MUST ask before unfamiliar low-trust navigation or consequential action unless authorised. MUST NOT close shared browser"
18
- : "Unless authorised, MUST ask before unfamiliar low-trust navigation or consequential action. MUST NOT close a shared browser",
19
- batch: gpt
20
- ? "Independent only: {action_name:[{...fields}],...}; nonempty arrays; root host/response_length; omit item action"
21
- : "Batch independent actions only: {action_name:[{...fields}],...}. Nonempty arrays; host and response_length at root; omit item action",
12
+ refs: "tabs→open; ref_id/id/cursors stay with result",
13
+ safety:
14
+ "MUST ask before unfamiliar low-trust navigation or consequential action unless authorised. MUST NOT close shared browser",
15
+ batch:
16
+ "Independent only: {action_name:[{...fields}],...}; nonempty arrays; root host/response_length; omit item action",
22
17
  actions: {
23
18
  help: "",
24
19
  tabs: "query? offset? owned_only? -> ref_id title url owned",
@@ -30,7 +25,7 @@ export function browserHelp(
30
25
  type: "ref_id text id?; id focuses",
31
26
  fill: "ref_id id|selector value; replace/clear text, select option value/label, boolean checks/unchecks",
32
27
  press: "ref_id key; focused element, e.g. Enter or Control+a",
33
- wait: "ref_id selector|text|url_includes timeout_ms?; DOM presence or substring, default 10000ms",
28
+ wait: "ref_id selector|text|url_includes timeout_ms?; DOM presence or substring",
34
29
  screenshot: "ref_id id?|selector?; brings tab to foreground -> file",
35
30
  navigate: "ref_id url",
36
31
  html: "ref_id id?|selector?",
@@ -111,7 +111,10 @@ async function manageAdvanced(
111
111
  ]);
112
112
  if (!selected || selected === BACK) return config;
113
113
  const value = (
114
- await ctx.ui.input("Remote Node path", config.remoteNodePath)
114
+ await ctx.ui.input(
115
+ "Node.js executable on SSH hosts",
116
+ config.remoteNodePath,
117
+ )
115
118
  )?.trim();
116
119
  if (!value) continue;
117
120
  try {
@@ -150,7 +153,7 @@ async function openBrowserSettings(
150
153
  if (!config) return;
151
154
  while (true) {
152
155
  const hosts = `Hosts · ${config.hosts.length ? config.hosts.join(", ") : "local only"}`;
153
- const machine = `This machine · ${currentMachineRoute(config) ?? "unnamed local"}`;
156
+ const machine = `Local host name for routing · ${currentMachineRoute(config) ?? "unnamed local"}`;
154
157
  const selected = await ctx.ui.select("Browser settings", [
155
158
  hosts,
156
159
  machine,
@@ -164,10 +167,10 @@ async function openBrowserSettings(
164
167
  continue;
165
168
  }
166
169
  if (selected === machine) {
167
- const route = await ctx.ui.select("This machine", [
168
- "Unnamed local browser",
169
- ...config.hosts,
170
- ]);
170
+ const route = await ctx.ui.select(
171
+ "Which listed host should open locally instead of over SSH?",
172
+ ["Unnamed local browser", ...config.hosts],
173
+ );
171
174
  if (route) {
172
175
  config = setCurrentMachineRoute(
173
176
  config,
@@ -29,30 +29,9 @@ export default async function browserExtension(
29
29
  configError = error instanceof Error ? error.message : String(error);
30
30
  }
31
31
  const runtime = new BrowserRuntime(routes);
32
- let gpt = false;
33
- const tool = createBrowserTool(sdk, runtime, () => gpt);
32
+ const tool = createBrowserTool(sdk, runtime);
34
33
  registerBrowserCommand(pi);
35
34
  pi.registerTool(tool);
36
- try {
37
- const { registerGptPromptMode } =
38
- await import("@howaboua/pi-codex-conversion/prompt-mode");
39
- registerGptPromptMode(pi, (active) => {
40
- gpt = active;
41
- return [tool];
42
- });
43
- } catch (error) {
44
- if (
45
- !(error instanceof Error) ||
46
- !("code" in error) ||
47
- ![
48
- "ERR_MODULE_NOT_FOUND",
49
- "MODULE_NOT_FOUND",
50
- "ERR_PACKAGE_PATH_NOT_EXPORTED",
51
- ].includes(String(error.code)) ||
52
- !error.message.includes(CODE_MODE_PACKAGE)
53
- )
54
- throw error;
55
- }
56
35
 
57
36
  const registration = await registerBrowserInCodeMode(pi, tool, sdk);
58
37
  pi.on("session_shutdown", async () => {
@@ -5,7 +5,6 @@ import type {
5
5
  opt as schemaOpt,
6
6
  str as schemaStr,
7
7
  } from "@earendil-works/pi-schema";
8
- import { browserHelp } from "./browser/help.js";
9
8
  import { isRecordValue } from "./browser/parse-operation.js";
10
9
  import { parseBrowserRequest } from "./browser/request.js";
11
10
  import type { BrowserRuntime } from "./browser/runtime.js";
@@ -42,7 +41,6 @@ export function createBrowserTool(
42
41
  str: typeof schemaStr;
43
42
  },
44
43
  runtime: BrowserRuntime,
45
- isGpt = () => false,
46
44
  ) {
47
45
  const parameters = obj(
48
46
  {
@@ -64,7 +62,7 @@ export function createBrowserTool(
64
62
  ctx,
65
63
  ) {
66
64
  const request = parseBrowserRequest(input.command);
67
- let result = await runtime.execute(request, {
65
+ const result = await runtime.execute(request, {
68
66
  ownerId: ctx.sessionManager.getSessionId(),
69
67
  signal: signal ?? new AbortController().signal,
70
68
  onOperation(operation, index, total) {
@@ -87,8 +85,6 @@ export function createBrowserTool(
87
85
  });
88
86
  },
89
87
  });
90
- if (isGpt() && "help" in request)
91
- result = browserHelp(runtime.hosts, true);
92
88
  return {
93
89
  content: [{ type: "text", text: JSON.stringify(result) }],
94
90
  details: result,
@@ -3,9 +3,6 @@ import { obj, opt, str } from "@earendil-works/pi-schema";
3
3
  import type { BrowserRuntime } from "./browser/runtime.js";
4
4
  import { createBrowserTool as createTool } from "./browser-tool-definition.js";
5
5
 
6
- export function createBrowserTool(
7
- runtime: BrowserRuntime,
8
- isGpt = () => false,
9
- ) {
10
- return createTool({ defineTool, obj, opt, str }, runtime, isGpt);
6
+ export function createBrowserTool(runtime: BrowserRuntime) {
7
+ return createTool({ defineTool, obj, opt, str }, runtime);
11
8
  }
package/src/cdp/client.ts CHANGED
@@ -28,12 +28,12 @@ function timeoutError(method: string, attempts: number): Error {
28
28
  const seconds = CDP_TIMEOUT_MS / 1_000;
29
29
  if (attempts > 1) {
30
30
  return new Error(
31
- `Chrome did not answer ${method} after two ${seconds}s attempts. The tab may be unresponsive or suspended.`,
31
+ `${method} timed out twice (${seconds}s each). Tab may be unresponsive or suspended.`,
32
32
  );
33
33
  }
34
34
  if (method === "Runtime.evaluate") {
35
35
  return new Error(
36
- `Chrome did not answer Runtime.evaluate within ${seconds}s. The expression or awaited promise may still be running; check its effect before retrying.`,
36
+ `Runtime.evaluate timed out (${seconds}s). Expression or awaited promise may still be running. Check effects before retrying.`,
37
37
  );
38
38
  }
39
39
  return new Error(`Chrome did not answer ${method} within ${seconds}s.`);
package/src/cdp/tabs.ts CHANGED
@@ -175,7 +175,7 @@ export class BrowserTabs {
175
175
  );
176
176
  } catch (error) {
177
177
  throw new Error(
178
- `Chrome did not confirm tab creation; a shared tab may exist. Run tabs before retrying: ${errorMessage(error)}`,
178
+ `Tab may have opened as shared. Run tabs before retrying: ${errorMessage(error)}`,
179
179
  );
180
180
  }
181
181
  if (typeof response["targetId"] !== "string")
@@ -187,7 +187,7 @@ export class BrowserTabs {
187
187
  await this.remember(created);
188
188
  } catch (error) {
189
189
  throw new Error(
190
- `Opened tab ${created} but could not save ownership; it remains shared: ${errorMessage(error)}`,
190
+ `Opened tab ${created}. Ownership save failed. Tab remains shared: ${errorMessage(error)}`,
191
191
  );
192
192
  }
193
193
  return created;