@howaboua/pi-browser 0.0.14 → 0.0.15

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,10 @@
1
1
  # @howaboua/pi-browser
2
2
 
3
+ ## 0.0.15
4
+
5
+ - Browser settings clarify which listed host runs locally and where to set the Node.js executable for SSH hosts.
6
+ - Browser always uses compact tool help, including in standalone installs.
7
+
3
8
  ## 0.0.14
4
9
 
5
10
  - Updates use Pi's native changelog notices and `collapseChangelog` instead of custom suppression.
@@ -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",
@@ -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",
@@ -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
  }
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.15",
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,7 +45,7 @@
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",
48
+ "@howaboua/pi-codex-conversion": ">=5.1.0",
49
49
  "@earendil-works/pi-ai": ">=1.0.0",
50
50
  "@earendil-works/pi-coding-agent": ">=1.5.0",
51
51
  "@earendil-works/pi-tui": ">=1.0.0"
@@ -56,12 +56,12 @@
56
56
  }
57
57
  },
58
58
  "devDependencies": {
59
- "@howaboua/pi-codex-conversion": "5.0.2",
59
+ "@howaboua/pi-codex-conversion": "5.1.0",
60
60
  "@earendil-works/pi-ai": "1.6.0",
61
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"
62
+ "@types/node": "26.6.6",
63
+ "typescript": "7.0.2",
64
+ "oxfmt": "0.79.0"
65
65
  },
66
66
  "pi": {
67
67
  "extensions": [
@@ -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",
@@ -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
  }