pi-agent-browser-native 0.1.1 → 0.1.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,19 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3 - 2026-04-12
4
+
5
+ ### Changed
6
+ - when `BRAVE_API_KEY` is present and non-empty, the extension now tells agents to prefer the Brave Search API via `bash`/`curl` for URL discovery and then open the chosen destination with `agent_browser` instead of driving a search engine results page in the browser
7
+ - when `BRAVE_API_KEY` is absent, the extension behavior remains unchanged
8
+ - added a small runtime helper and unit coverage for the `BRAVE_API_KEY` gate so the change stays explicit and minimal
9
+
10
+ ## 0.1.2 - 2026-04-11
11
+
12
+ ### Changed
13
+ - renamed the public GitHub repository to `pi-agent-browser-native` so the repo name, npm package name, install docs, and package metadata all align
14
+ - updated package metadata and install guidance to use the new GitHub source path `https://github.com/fitchmultz/pi-agent-browser-native`
15
+ - switched the local global pi install from the repo checkout path to the published npm package `pi-agent-browser-native`
16
+
3
17
  ## 0.1.1 - 2026-04-11
4
18
 
5
19
  ### Changed
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # pi-agent-browser
1
+ # pi-agent-browser-native
2
2
 
3
3
  Native `pi` integration for [`agent-browser`](https://agent-browser.dev/).
4
4
 
@@ -66,13 +66,13 @@ pi -e npm:pi-agent-browser-native
66
66
  For the source install path, prefer the repository URL:
67
67
 
68
68
  ```bash
69
- pi install https://github.com/fitchmultz/pi-agent-browser
69
+ pi install https://github.com/fitchmultz/pi-agent-browser-native
70
70
  ```
71
71
 
72
72
  To try the GitHub source without installing it permanently:
73
73
 
74
74
  ```bash
75
- pi -e https://github.com/fitchmultz/pi-agent-browser
75
+ pi -e https://github.com/fitchmultz/pi-agent-browser-native
76
76
  ```
77
77
 
78
78
  ### Current practical local-checkout flow
@@ -80,13 +80,13 @@ pi -e https://github.com/fitchmultz/pi-agent-browser
80
80
  Until you are using a published package release, install from a checkout:
81
81
 
82
82
  ```bash
83
- pi install /absolute/path/to/pi-agent-browser
83
+ pi install /absolute/path/to/pi-agent-browser-native
84
84
  ```
85
85
 
86
86
  Or try it for one session only:
87
87
 
88
88
  ```bash
89
- pi -e /absolute/path/to/pi-agent-browser
89
+ pi -e /absolute/path/to/pi-agent-browser-native
90
90
  ```
91
91
 
92
92
  The native tool exposed to the agent is named `agent_browser`.
@@ -104,7 +104,7 @@ This keeps the product centered on native tool usage instead of auxiliary skill
104
104
 
105
105
  ## Responsibility split
106
106
 
107
- ### `pi-agent-browser` owns
107
+ ### `pi-agent-browser-native` owns
108
108
 
109
109
  - tool registration and schema
110
110
  - subprocess execution and JSON parsing
package/docs/RELEASE.md CHANGED
@@ -8,7 +8,7 @@ Related docs:
8
8
 
9
9
  ## Purpose
10
10
 
11
- Provide one concrete maintainer workflow for validating repo state, package contents, and install guidance before publishing `pi-agent-browser`.
11
+ Provide one concrete maintainer workflow for validating repo state, package contents, and install guidance before publishing `pi-agent-browser-native`.
12
12
 
13
13
  ## Pre-release checks
14
14
 
@@ -8,7 +8,7 @@ Related docs:
8
8
 
9
9
  ## Purpose
10
10
 
11
- Define the product requirements and constraints for `pi-agent-browser`.
11
+ Define the product requirements and constraints for `pi-agent-browser-native`.
12
12
 
13
13
  ## Product requirements
14
14
 
@@ -45,7 +45,7 @@ Define the product requirements and constraints for `pi-agent-browser`.
45
45
 
46
46
  - Prioritize the package install path first.
47
47
  - User-facing install docs should lead with `pi install npm:pi-agent-browser-native` and `pi -e npm:pi-agent-browser-native` once releases exist.
48
- - User-facing install docs should also include the GitHub source path `pi install https://github.com/fitchmultz/pi-agent-browser`.
48
+ - User-facing install docs should also include the GitHub source path `pi install https://github.com/fitchmultz/pi-agent-browser-native`.
49
49
  - Keep the current local-checkout path documented as the practical pre-release and development flow.
50
50
  - Most users will install this extension globally rather than as a project-local extension.
51
51
  - Repo-local `.pi/` wiring is for development convenience only and should not drive the product design.
@@ -19,6 +19,7 @@ import {
19
19
  createEphemeralSessionSeed,
20
20
  createImplicitSessionName,
21
21
  getLatestUserPrompt,
22
+ hasUsableBraveApiKey,
22
23
  validateToolArgs,
23
24
  } from "./lib/runtime.js";
24
25
  import { cleanupSecureTempArtifacts } from "./lib/temp.js";
@@ -78,8 +79,14 @@ function buildInspectionDeflectionMessage(): string {
78
79
  ].join("\n");
79
80
  }
80
81
 
82
+ function buildBraveSearchGuidance(hasBraveApiKey: boolean): string {
83
+ if (!hasBraveApiKey) return "";
84
+ return "\n- A non-empty `BRAVE_API_KEY` is available in the current environment. For web search or URL discovery, prefer the Brave Search API via `bash`/`curl` to find the destination URL, then open that URL with `agent_browser` instead of using browser automation to drive Google or another search engine results page. If the Brave request fails, fall back to the normal workflow.";
85
+ }
86
+
81
87
  export default function agentBrowserExtension(pi: ExtensionAPI) {
82
88
  const ephemeralSessionSeed = createEphemeralSessionSeed();
89
+ const braveSearchGuidance = buildBraveSearchGuidance(hasUsableBraveApiKey());
83
90
  let implicitSessionActive = false;
84
91
  let implicitSessionName = createImplicitSessionName(undefined, process.cwd(), ephemeralSessionSeed);
85
92
  let implicitSessionCwd = process.cwd();
@@ -112,7 +119,8 @@ export default function agentBrowserExtension(pi: ExtensionAPI) {
112
119
  return {
113
120
  systemPrompt:
114
121
  event.systemPrompt +
115
- "\n\nProject rule: when browser automation is needed, prefer the native `agent_browser` tool. Do not run direct `agent-browser` bash commands unless the user explicitly asks for a bash-oriented workflow or browser-integration debugging.\n\nBrowser operating playbook:\n- Standard workflow: open the page, then snapshot -i, then interact via refs, then re-snapshot after navigation or major DOM changes.\n- For user-specific or authenticated content like feeds, inboxes, dashboards, and accounts, start with an authenticated browser strategy instead of public browsing. Prefer `--profile Default` on the first browser call and let the current implicit session carry continuity. Use `--auto-connect` only if profile-based reuse is unavailable or the task is specifically about attaching to a running debug-enabled browser.\n- Do not invent fixed explicit session names for routine tasks. Use the implicit session unless you truly need multiple isolated browser sessions in the same conversation.\n- When using startup-scoped flags like `--profile`, `--session-name`, or `--cdp`, put them on the first command for that session. If you intentionally use an explicit `--session`, keep using that same explicit session for follow-ups.\n- If a session lands on the wrong page or tab, an interaction changes origin unexpectedly, or an `open` call returns blocked, blank, or otherwise unexpected results, use `tab list`, `tab <n>`, and `snapshot -i` to recover state before retrying different URLs or fallback strategies. Only use `wait` with an explicit argument like milliseconds, `--load`, `--url`, `--fn`, or `--text`.\n- For feed, timeline, or inbox reading tasks, focus on the main timeline/list region and read the first item there rather than unrelated composer or sidebar content.\n- For read-only browsing tasks, prefer extracting the answer from the current snapshot, structured ref labels, or `eval --stdin` on the current page before navigating away. Only click into media viewers, detail routes, or new pages when the current view does not contain the needed information.\n- When using `eval --stdin`, scope checks and actions to the target element or route whenever possible instead of relying on broad page-wide text heuristics.\n- When using `eval --stdin` for extraction, return the value you want instead of relying on `console.log` as the primary result channel.\n- Do not use `agent_browser --help` for normal browsing tasks.",
122
+ "\n\nProject rule: when browser automation is needed, prefer the native `agent_browser` tool. Do not run direct `agent-browser` bash commands unless the user explicitly asks for a bash-oriented workflow or browser-integration debugging.\n\nBrowser operating playbook:\n- Standard workflow: open the page, then snapshot -i, then interact via refs, then re-snapshot after navigation or major DOM changes.\n- For user-specific or authenticated content like feeds, inboxes, dashboards, and accounts, start with an authenticated browser strategy instead of public browsing. Prefer `--profile Default` on the first browser call and let the current implicit session carry continuity. Use `--auto-connect` only if profile-based reuse is unavailable or the task is specifically about attaching to a running debug-enabled browser.\n- Do not invent fixed explicit session names for routine tasks. Use the implicit session unless you truly need multiple isolated browser sessions in the same conversation.\n- When using startup-scoped flags like `--profile`, `--session-name`, or `--cdp`, put them on the first command for that session. If you intentionally use an explicit `--session`, keep using that same explicit session for follow-ups.\n- If a session lands on the wrong page or tab, an interaction changes origin unexpectedly, or an `open` call returns blocked, blank, or otherwise unexpected results, use `tab list`, `tab <n>`, and `snapshot -i` to recover state before retrying different URLs or fallback strategies. Only use `wait` with an explicit argument like milliseconds, `--load`, `--url`, `--fn`, or `--text`.\n- For feed, timeline, or inbox reading tasks, focus on the main timeline/list region and read the first item there rather than unrelated composer or sidebar content.\n- For read-only browsing tasks, prefer extracting the answer from the current snapshot, structured ref labels, or `eval --stdin` on the current page before navigating away. Only click into media viewers, detail routes, or new pages when the current view does not contain the needed information.\n- When using `eval --stdin`, scope checks and actions to the target element or route whenever possible instead of relying on broad page-wide text heuristics.\n- When using `eval --stdin` for extraction, return the value you want instead of relying on `console.log` as the primary result channel.\n- Do not use `agent_browser --help` for normal browsing tasks." +
123
+ braveSearchGuidance,
116
124
  };
117
125
  });
118
126
 
@@ -141,6 +149,11 @@ export default function agentBrowserExtension(pi: ExtensionAPI) {
141
149
  promptGuidelines: [
142
150
  "Use this tool whenever the task requires a real browser or live web content.",
143
151
  "Standard workflow: open the page, snapshot -i, interact using refs, and re-snapshot after navigation or major DOM changes.",
152
+ ...(braveSearchGuidance
153
+ ? [
154
+ "When a non-empty BRAVE_API_KEY is available in the current environment, prefer the Brave Search API via bash/curl to discover specific destination URLs, then open the chosen URL with agent_browser instead of browsing a search engine results page just to find the target.",
155
+ ]
156
+ : []),
144
157
  "For authenticated or user-specific content like feeds, inboxes, dashboards, and accounts, prefer --profile Default on the first browser call and let the implicit session carry continuity. Use --auto-connect only if profile-based reuse is unavailable or the task is specifically about attaching to a running debug-enabled browser.",
145
158
  "Do not invent fixed explicit session names for routine tasks. Use the implicit session unless you truly need multiple isolated browser sessions in the same conversation.",
146
159
  "When using --profile, --session-name, or --cdp, put them on the first command for that session. If you intentionally use an explicit --session, keep using that same explicit session for follow-ups.",
@@ -10,6 +10,7 @@ import { createHash, randomUUID } from "node:crypto";
10
10
  import { basename } from "node:path";
11
11
 
12
12
  const STARTUP_SCOPED_FLAGS = ["--cdp", "--profile", "--session-name"] as const;
13
+ const BRAVE_API_KEY_ENV = "BRAVE_API_KEY";
13
14
  const INSPECTION_ALLOW_PATTERNS = [
14
15
  /\bagent[_ -]?browser\s+--(?:help|version)\b/i,
15
16
  /\bagent[_ -]?browser\b.*\b(?:help|version|docs?|documentation|tool contract|tool guidance|tool description)\b/i,
@@ -77,6 +78,10 @@ export interface PromptPolicy {
77
78
  allowLegacyAgentBrowserBash: boolean;
78
79
  }
79
80
 
81
+ export function hasUsableBraveApiKey(apiKey: string | null | undefined = process.env[BRAVE_API_KEY_ENV]): boolean {
82
+ return typeof apiKey === "string" && apiKey.trim().length > 0;
83
+ }
84
+
80
85
  export function createEphemeralSessionSeed(): string {
81
86
  return randomUUID();
82
87
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-browser-native",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Native pi integration for agent-browser",
5
5
  "type": "module",
6
6
  "author": "Mitch Fultz (https://github.com/fitchmultz)",
@@ -15,11 +15,11 @@
15
15
  "license": "MIT",
16
16
  "repository": {
17
17
  "type": "git",
18
- "url": "git+https://github.com/fitchmultz/pi-agent-browser.git"
18
+ "url": "git+https://github.com/fitchmultz/pi-agent-browser-native.git"
19
19
  },
20
- "homepage": "https://github.com/fitchmultz/pi-agent-browser#readme",
20
+ "homepage": "https://github.com/fitchmultz/pi-agent-browser-native#readme",
21
21
  "bugs": {
22
- "url": "https://github.com/fitchmultz/pi-agent-browser/issues"
22
+ "url": "https://github.com/fitchmultz/pi-agent-browser-native/issues"
23
23
  },
24
24
  "engines": {
25
25
  "node": ">=20.6.0"