@howaboua/pi-browser 0.0.2 → 0.0.3

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,9 @@
1
1
  # @howaboua/pi-browser
2
2
 
3
+ ## 0.0.3
4
+
5
+ - Removed redundant tool guidance from Ask, Shepherdr, Skills and Browser. Code and Notebook Mode now show one callable contract per tool, with detailed Browser and agent rules in help.
6
+
3
7
  ## 0.0.2
4
8
 
5
9
  - Keep tool results actionable.
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ export default async function browserExtension(pi) {
19
19
  const tool = createBrowserTool(runtime);
20
20
  registerBrowserCommand(pi);
21
21
  pi.registerTool(tool);
22
- const registration = await registerBrowserInCodeMode(pi, tool, runtime.hosts.length > 0);
22
+ const registration = await registerBrowserInCodeMode(pi, tool);
23
23
  pi.on("session_shutdown", () => {
24
24
  registration?.unregister();
25
25
  runtime.close();
@@ -30,14 +30,14 @@ export default async function browserExtension(pi) {
30
30
  });
31
31
  }
32
32
  }
33
- async function registerBrowserInCodeMode(pi, tool, routed) {
33
+ async function registerBrowserInCodeMode(pi, tool) {
34
34
  try {
35
35
  const { adaptToolForCodeMode, registerCodeModeExtensionTools } = await import("@howaboua/pi-codex-conversion/code-mode");
36
36
  return registerCodeModeExtensionTools(pi, () => [
37
37
  adaptToolForCodeMode(tool, {
38
38
  kind: "freeform",
39
39
  prepareInput: prepareBrowserCodeModeInput,
40
- usage: `await tools.browser("help"); await tools.browser(JSON.stringify({ action: "tabs" })) // Logged-in ${routed ? "routed " : "local "}browser with web__run refs; ask before consequential external actions`,
40
+ usage: 'await tools.browser("help") // Logged-in browser; help before other actions',
41
41
  }),
42
42
  ]);
43
43
  }
@@ -1255,7 +1255,11 @@ function browserHelp(hosts = []) {
1255
1255
  const routed = hosts.length > 0;
1256
1256
  return {
1257
1257
  input: "Code=JSON.stringify(request); normal=request",
1258
- ...routed ? { host: `${hosts.join("|")} optional` } : {},
1258
+ ...routed ? {
1259
+ host: `${hosts.join("|")} optional; keep a user-named host on every call and its refs/handles`
1260
+ } : {},
1261
+ refs: "tabs -> open; keep ref_id/id/cursors with their result",
1262
+ safety: "Ask before unfamiliar low-trust navigation or consequential action unless authorized; never close shared browser",
1259
1263
  batch: "top-level nonempty action arrays; items omit action/host/response_length; independent only",
1260
1264
  actions: {
1261
1265
  tabs: "query? offset? -> ref_id title url",
@@ -1272,8 +1276,8 @@ function browserHelp(hosts = []) {
1272
1276
  raw: "ref_id method params?",
1273
1277
  start: "",
1274
1278
  stop: "ref_id?",
1275
- read_result: `handle offset${routed ? "; same host" : ""}`,
1276
- discard_result: `handle${routed ? "; same host" : ""}`
1279
+ read_result: "handle offset",
1280
+ discard_result: "handle"
1277
1281
  },
1278
1282
  continue: "next_lineno/next_offset; response_length=short|medium|long"
1279
1283
  };
@@ -2,7 +2,13 @@ export function browserHelp(hosts = []) {
2
2
  const routed = hosts.length > 0;
3
3
  return {
4
4
  input: "Code=JSON.stringify(request); normal=request",
5
- ...(routed ? { host: `${hosts.join("|")} optional` } : {}),
5
+ ...(routed
6
+ ? {
7
+ host: `${hosts.join("|")} optional; keep a user-named host on every call and its refs/handles`,
8
+ }
9
+ : {}),
10
+ refs: "tabs -> open; keep ref_id/id/cursors with their result",
11
+ safety: "Ask before unfamiliar low-trust navigation or consequential action unless authorized; never close shared browser",
6
12
  batch: "top-level nonempty action arrays; items omit action/host/response_length; independent only",
7
13
  actions: {
8
14
  tabs: "query? offset? -> ref_id title url",
@@ -19,8 +25,8 @@ export function browserHelp(hosts = []) {
19
25
  raw: "ref_id method params?",
20
26
  start: "",
21
27
  stop: "ref_id?",
22
- read_result: `handle offset${routed ? "; same host" : ""}`,
23
- discard_result: `handle${routed ? "; same host" : ""}`,
28
+ read_result: "handle offset",
29
+ discard_result: "handle",
24
30
  },
25
31
  continue: "next_lineno/next_offset; response_length=short|medium|long",
26
32
  };
@@ -28,18 +28,8 @@ export function createBrowserTool(runtime) {
28
28
  return defineTool({
29
29
  name: "browser",
30
30
  label: "Browser",
31
- description: "Inspect and control logged-in browser tabs with bounded accessibility content, interactive references, continuations and expert CDP actions.",
31
+ description: "Control logged-in browser; call help before other actions",
32
32
  parameters,
33
- promptSnippet: "Help first.",
34
- promptGuidelines: [
35
- "browser: tabs -> open; keep ref_id/id/cursors with their result.",
36
- ...(runtime.hosts.length > 0
37
- ? [
38
- "browser: Keep a user-named host on every call and its refs/handles.",
39
- ]
40
- : []),
41
- "browser: Ask before unfamiliar low-trust navigation or consequential action unless authorized; never close shared browser.",
42
- ],
43
33
  async execute(_toolCallId, input, signal, onUpdate) {
44
34
  const result = await runtime.execute(browserRequest(input), {
45
35
  signal: signal ?? new AbortController().signal,
package/index.ts CHANGED
@@ -27,11 +27,7 @@ export default async function browserExtension(
27
27
  const tool = createBrowserTool(runtime);
28
28
  registerBrowserCommand(pi);
29
29
  pi.registerTool(tool);
30
- const registration = await registerBrowserInCodeMode(
31
- pi,
32
- tool,
33
- runtime.hosts.length > 0,
34
- );
30
+ const registration = await registerBrowserInCodeMode(pi, tool);
35
31
  pi.on("session_shutdown", () => {
36
32
  registration?.unregister();
37
33
  runtime.close();
@@ -46,7 +42,6 @@ export default async function browserExtension(
46
42
  async function registerBrowserInCodeMode(
47
43
  pi: ExtensionAPI,
48
44
  tool: ReturnType<typeof createBrowserTool>,
49
- routed: boolean,
50
45
  ) {
51
46
  try {
52
47
  const { adaptToolForCodeMode, registerCodeModeExtensionTools } =
@@ -55,9 +50,8 @@ async function registerBrowserInCodeMode(
55
50
  adaptToolForCodeMode(tool, {
56
51
  kind: "freeform",
57
52
  prepareInput: prepareBrowserCodeModeInput,
58
- usage: `await tools.browser("help"); await tools.browser(JSON.stringify({ action: "tabs" })) // Logged-in ${
59
- routed ? "routed " : "local "
60
- }browser with web__run refs; ask before consequential external actions`,
53
+ usage:
54
+ 'await tools.browser("help") // Logged-in browser; help before other actions',
61
55
  }),
62
56
  ]);
63
57
  } catch (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@howaboua/pi-browser",
3
- "version": "0.0.2",
3
+ "version": "0.0.3",
4
4
  "description": "Logged-in browser inspection and control for Pi, Code Mode and Notebook Mode.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -46,7 +46,7 @@
46
46
  "pack:dry": "npm pack --dry-run"
47
47
  },
48
48
  "peerDependencies": {
49
- "@howaboua/pi-codex-conversion": ">=3.0.26",
49
+ "@howaboua/pi-codex-conversion": ">=3.0.33",
50
50
  "@earendil-works/pi-ai": ">=0.84.3",
51
51
  "@earendil-works/pi-coding-agent": ">=0.84.3",
52
52
  "typebox": "*",
@@ -58,10 +58,10 @@
58
58
  }
59
59
  },
60
60
  "devDependencies": {
61
- "@howaboua/pi-codex-conversion": "3.0.26",
61
+ "@howaboua/pi-codex-conversion": "3.0.33",
62
62
  "@biomejs/biome": "^2.5.10",
63
- "@earendil-works/pi-ai": "0.85.0",
64
- "@earendil-works/pi-coding-agent": "0.85.0",
63
+ "@earendil-works/pi-ai": "0.85.1",
64
+ "@earendil-works/pi-coding-agent": "0.85.1",
65
65
  "@types/node": "^26.2.0",
66
66
  "tsx": "^4.23.12",
67
67
  "typebox": "1.3.18",
@@ -4,7 +4,14 @@ export function browserHelp(
4
4
  const routed = hosts.length > 0;
5
5
  return {
6
6
  input: "Code=JSON.stringify(request); normal=request",
7
- ...(routed ? { host: `${hosts.join("|")} optional` } : {}),
7
+ ...(routed
8
+ ? {
9
+ host: `${hosts.join("|")} optional; keep a user-named host on every call and its refs/handles`,
10
+ }
11
+ : {}),
12
+ refs: "tabs -> open; keep ref_id/id/cursors with their result",
13
+ safety:
14
+ "Ask before unfamiliar low-trust navigation or consequential action unless authorized; never close shared browser",
8
15
  batch:
9
16
  "top-level nonempty action arrays; items omit action/host/response_length; independent only",
10
17
  actions: {
@@ -22,8 +29,8 @@ export function browserHelp(
22
29
  raw: "ref_id method params?",
23
30
  start: "",
24
31
  stop: "ref_id?",
25
- read_result: `handle offset${routed ? "; same host" : ""}`,
26
- discard_result: `handle${routed ? "; same host" : ""}`,
32
+ read_result: "handle offset",
33
+ discard_result: "handle",
27
34
  },
28
35
  continue: "next_lineno/next_offset; response_length=short|medium|long",
29
36
  };
@@ -43,19 +43,8 @@ export function createBrowserTool(runtime: BrowserRuntime) {
43
43
  return defineTool({
44
44
  name: "browser",
45
45
  label: "Browser",
46
- description:
47
- "Inspect and control logged-in browser tabs with bounded accessibility content, interactive references, continuations and expert CDP actions.",
46
+ description: "Control logged-in browser; call help before other actions",
48
47
  parameters,
49
- promptSnippet: "Help first.",
50
- promptGuidelines: [
51
- "browser: tabs -> open; keep ref_id/id/cursors with their result.",
52
- ...(runtime.hosts.length > 0
53
- ? [
54
- "browser: Keep a user-named host on every call and its refs/handles.",
55
- ]
56
- : []),
57
- "browser: Ask before unfamiliar low-trust navigation or consequential action unless authorized; never close shared browser.",
58
- ],
59
48
  async execute(_toolCallId, input, signal, onUpdate) {
60
49
  const result = await runtime.execute(browserRequest(input), {
61
50
  signal: signal ?? new AbortController().signal,