pi-agent-browser-native 0.2.0 → 0.2.2

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,25 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.2.2 - 2026-04-12
4
+
5
+ ### Fixed
6
+ - plain-text inspection commands like `agent_browser --help` and `--version` now stay stateless: they no longer claim the implicit managed session or leave behind ambiguous `parseError` details on success
7
+ - extension-managed session ownership is now reconstructed from persisted tool details on resume/reload while still preserving cwd-hash isolation across same-named checkouts and worktrees
8
+ - echoed tool updates/details now redact sensitive invocation values and structured secret-bearing fields instead of replaying headers, proxy credentials, cookies, or auth-bearing URL params back into `pi`
9
+ - the subprocess wrapper no longer forwards ambient parent-shell `AGENT_BROWSER_*` state into child runs, reducing surprising hidden configuration leaks from the caller environment
10
+ - browser-specific system-prompt injection is now minimal and only added for clearly browser-oriented turns, while the full playbook stays in tool metadata where it belongs
11
+ - published docs and changelog notes now match the current result/details contract, resume behavior, prompt behavior, and release workflow
12
+
13
+ ## 0.2.1 - 2026-04-12
14
+
15
+ ### Fixed
16
+ - the GitHub source trial docs now use `pi --no-extensions -e https://github.com/fitchmultz/pi-agent-browser-native` so published-package users do not hit duplicate `agent_browser` registration conflicts during source-path testing
17
+ - successful unnamed `sessionMode: "fresh"` launches now rotate the extension-managed session to the new browser, and later default `sessionMode: "auto"` calls keep following that fresh session instead of silently snapping back to the older one
18
+ - mixed-success `batch` failures now preserve per-step rendering, include the first failing step in the visible output and structured details, and still mark the overall tool call as an error so agents can recover from partial progress
19
+ - implicit `piab-*` session names now include a stable cwd hash in addition to the `pi` session id so same-named checkouts and worktrees no longer collide onto the same browser session
20
+ - value-taking flags like `--session`, `--profile`, `--session-name`, and `--cdp` now fail locally with direct validation errors when the value is missing or replaced by another flag, instead of producing confusing downstream JSON parse failures
21
+ - the bash guard now catches wrapped `agent-browser` invocations such as `env agent-browser ...`, `npx --yes agent-browser ...`, `pnpm dlx agent-browser ...`, `yarn dlx agent-browser ...`, `bunx agent-browser ...`, and absolute-path execution, reducing accidental bypasses of the native-tool path
22
+
3
23
  ## 0.2.0 - 2026-04-12
4
24
 
5
25
  ### Changed
@@ -8,7 +28,7 @@
8
28
  - plain-text inspection commands like `agent_browser --help` and `--version` are now always allowed, removing the old prompt-dependent inspection gate and making the inspection contract local and predictable
9
29
  - navigation actions like `click`, `dblclick`, `back`, `forward`, and `reload` now include lightweight post-action title/url summaries when the wrapper can address the active session, reducing guess-and-check follow-up snapshots
10
30
  - compact snapshot rendering is leaner by default: fewer additional sections, fewer refs, smaller role summaries, and the raw spill path now stays in `details.fullOutputPath` instead of dominating the visible snapshot body
11
- - README and injected tool guidance now include a compact agent quick start with the core call shapes for `open` + `snapshot`, `click` + re-snapshot, `batch`, `eval --stdin`, and fresh profiled launches
31
+ - README and tool prompt guidance now include a compact agent quick start with the core call shapes for `open` + `snapshot`, `click` + re-snapshot, `batch`, `eval --stdin`, and fresh profiled launches, while turn-level system-prompt injection stays minimal
12
32
 
13
33
  ### Migration notes
14
34
  - replace any use of `useActiveSession` with `sessionMode`
@@ -19,7 +39,7 @@
19
39
  ### Changed
20
40
  - hardened the implicit browser-session lifecycle so failed first launches no longer mark the convenience session active, startup-scoped flags behave correctly across launches and closes, and the highest-risk entrypoint paths now have direct automated and isolated-`pi` coverage
21
41
  - added explicit temp-root ownership markers, aggregate spill-file disk budgeting, inline image size limits, and graceful fallback behavior when large snapshot or stdout artifacts exceed temp budgets
22
- - consolidated the shared browser operating playbook across the injected system prompt and tool prompt guidance while adding direct extension-hook coverage for prompt injection, bash blocking, and session resets
42
+ - consolidated the shared browser operating playbook into the tool prompt guidance while keeping turn-level system-prompt injection minimal, and added direct extension-hook coverage for prompt injection, bash blocking, and session resets
23
43
  - split the old result-rendering god module into focused envelope, presentation, shared, and snapshot modules, and made snapshot compaction fall back to a resilient outline mode when upstream raw snapshot formatting is unfamiliar
24
44
  - refactored the release-package verification script into smaller testable helpers, preserved the retired autoload-shim guard, and aligned the tarball gate with the split result-rendering module layout
25
45
 
package/README.md CHANGED
@@ -69,12 +69,14 @@ For the source install path, prefer the repository URL:
69
69
  pi install https://github.com/fitchmultz/pi-agent-browser-native
70
70
  ```
71
71
 
72
- To try the GitHub source without installing it permanently:
72
+ To try the GitHub source without installing it permanently, isolate that temporary source extension from your normal installed package set:
73
73
 
74
74
  ```bash
75
- pi -e https://github.com/fitchmultz/pi-agent-browser-native
75
+ pi --no-extensions -e https://github.com/fitchmultz/pi-agent-browser-native
76
76
  ```
77
77
 
78
+ This avoids duplicate `agent_browser` registrations when you already have `pi-agent-browser-native` installed globally.
79
+
78
80
  ### Current practical local-checkout flow
79
81
 
80
82
  Until you are using a published package release, prefer an explicit checkout-only run instead of installing the checkout into your normal `pi` package set:
@@ -89,8 +91,8 @@ The native tool exposed to the agent is named `agent_browser`.
89
91
 
90
92
  The primary session control parameter is `sessionMode`:
91
93
 
92
- - `"auto"` (default) reuses the implicit `pi`-scoped session when possible
93
- - `"fresh"` skips that implicit session so startup-scoped flags like `--profile`, `--session-name`, and `--cdp` can launch a fresh upstream session
94
+ - `"auto"` (default) reuses the extension-managed `pi`-scoped session when possible
95
+ - `"fresh"` switches that managed session to a fresh upstream launch so startup-scoped flags like `--profile`, `--session-name`, and `--cdp` apply and later auto calls follow the new browser
94
96
 
95
97
  ## Agent quick start
96
98
 
@@ -99,8 +101,8 @@ The primary session control parameter is `sessionMode`:
99
101
  - `args` — exact CLI args after `agent-browser`
100
102
  - `stdin` — raw stdin only for `batch` and `eval --stdin`
101
103
  - `sessionMode`
102
- - `"auto"` — default, reuse the implicit `pi`-scoped session
103
- - `"fresh"` — skip the implicit session for a new profile/debug launch
104
+ - `"auto"` — default, reuse the extension-managed `pi`-scoped session
105
+ - `"fresh"` — switch that managed session to a new profile/debug launch
104
106
 
105
107
  ### Common call shapes
106
108
 
@@ -136,7 +138,9 @@ Start a fresh profiled launch after you already used the implicit session:
136
138
  { "args": ["--profile", "Default", "open", "https://example.com/account"], "sessionMode": "fresh" }
137
139
  ```
138
140
 
139
- Name a new upstream session explicitly when you want to keep reusing it:
141
+ After a successful unnamed fresh launch, later `sessionMode: "auto"` calls follow that new browser automatically.
142
+
143
+ Name a new upstream session explicitly when you want to keep reusing it yourself:
140
144
 
141
145
  ```json
142
146
  { "args": ["--session", "auth-flow", "open", "https://example.com"] }
@@ -177,15 +181,17 @@ Validated workflow examples:
177
181
  - run `batch` with JSON via `stdin`
178
182
  - run `eval --stdin`
179
183
  - take a screenshot with inline attachment support
180
- - inspect `agent_browser --help` and `--version` via the tool's plain-text inspection fallback
184
+ - inspect `agent_browser --help` and `--version` via the tool's stateless plain-text inspection fallback
181
185
 
182
- Inspection commands like `agent_browser --help` and `--version` are always supported. They return plain text and are useful for debugging or capability checks, but they are not required for normal browsing workflows.
186
+ Inspection commands like `agent_browser --help` and `--version` are always supported. They return plain text, are useful for debugging or capability checks, and stay stateless: the extension does not inject its implicit session for them and they do not consume the managed-session slot needed for a later `--profile`, `--session-name`, or `--cdp` launch.
183
187
 
184
188
  Current cautions:
185
189
  - passing `--profile` is an explicit upstream choice; this extension does not add its own profile-cloning or isolation layer
186
190
  - startup-scoped flags like `--profile`, `--session-name`, and `--cdp` are for the first command that launches a session; if the implicit session is already active, retry that call with `sessionMode: "fresh"` or provide an explicit `--session ...` for the new launch
187
- - implicit `piab-*` sessions are extension-managed convenience sessions; they are best-effort closed on `pi` shutdown, get an idle timeout to reduce stale background daemons, and clean up private temp spill artifacts on shutdown
188
- - explicit upstream sessions like `--session`, `--profile`, `--session-name`, and `--cdp` are treated as user-managed and are not auto-closed by the extension
191
+ - implicit `piab-*` sessions are extension-managed convenience sessions; they are best-effort closed on `pi` shutdown, get an idle timeout to reduce stale background daemons, clean up private temp spill artifacts on shutdown, and are reconstructed from persisted tool details on resume/reload so later default calls keep following the active managed browser
192
+ - `sessionMode: "fresh"` without an explicit `--session` rotates that extension-managed session to the new browser so later auto calls keep using it
193
+ - explicit caller-provided `--session` values are treated as user-managed and are not auto-closed by the extension
194
+ - tool progress/details redact sensitive invocation values such as `--headers`, proxy credentials, and auth-bearing URL parameters before echoing them back into Pi
189
195
 
190
196
  ### Switching from public browsing to a fresh profile/debug launch
191
197
 
@@ -203,6 +209,8 @@ Use `sessionMode: "fresh"` for that transition instead of relying on the implici
203
209
  }
204
210
  ```
205
211
 
212
+ After that call succeeds, later default `sessionMode: "auto"` calls continue in the new fresh browser.
213
+
206
214
  If you want to name the new upstream session yourself, pass an explicit session instead:
207
215
 
208
216
  ```json
@@ -59,7 +59,7 @@ The published package should exclude agent-only and superseded repo materials su
59
59
 
60
60
  ### Default
61
61
 
62
- If the caller does not provide `--session`, the extension should default to `sessionMode: "auto"` and use an implicit session name derived from the current `pi` session id.
62
+ If the caller does not provide `--session`, the extension should default to `sessionMode: "auto"` and use an implicit session name derived from the current `pi` session id plus a hash of the absolute cwd.
63
63
 
64
64
  Why:
65
65
  - works out of the box
@@ -70,20 +70,23 @@ Why:
70
70
 
71
71
  If the caller provides `--session`, `--profile`, `--cdp`, or similar upstream flags, the extension should respect them with minimal interference.
72
72
 
73
- The tool should also expose a first-class `sessionMode: "fresh"` escape hatch so agents can intentionally skip the implicit session and launch a fresh upstream session without inventing a fixed explicit session name.
73
+ The tool should also expose a first-class `sessionMode: "fresh"` escape hatch so agents can intentionally rotate the extension-managed session to a fresh upstream launch without inventing a fixed explicit session name.
74
74
 
75
75
  ### Ownership
76
76
 
77
77
  V1 ownership rule:
78
78
  - implicit auto-generated sessions are extension-managed convenience sessions
79
+ - unnamed `sessionMode: "fresh"` launches rotate that extension-managed session to a new upstream browser
79
80
  - explicit/user-managed sessions are not auto-managed by default
80
- - implicit sessions should be reusable during an active `pi` session, but should still be cleaned up predictably
81
+ - extension-managed sessions should be reusable during an active `pi` session, but should still be cleaned up predictably
81
82
 
82
83
  Practical policy:
83
- - on normal `pi` shutdown, best-effort close the implicit session
84
- - also set an idle timeout on implicit sessions so abandoned daemons self-clean after inactivity
85
- - clean up private temp spill artifacts owned by the implicit session on shutdown
86
- - leave explicit upstream sessions like `--session`, `--profile`, `--session-name`, and `--cdp` alone unless the caller closes them explicitly
84
+ - on normal `pi` shutdown, best-effort close the current extension-managed session
85
+ - also set an idle timeout on extension-managed sessions so abandoned daemons self-clean after inactivity
86
+ - clean up private temp spill artifacts owned by the extension-managed session on shutdown
87
+ - reconstruct the current extension-managed session from persisted tool details on resume/reload so later default calls keep following the active managed browser
88
+ - if an unnamed fresh launch replaces an active extension-managed session, best-effort close the old managed session after the switch succeeds
89
+ - leave explicit caller-provided `--session` choices alone unless the caller closes them explicitly
87
90
 
88
91
  This is primarily about ownership clarity and avoiding surprise, not adding a heavy safety wrapper. If the extension invented the session, the extension should clean it up. If the caller explicitly chose the upstream session model, the extension should stay out of the way.
89
92
 
@@ -98,6 +101,8 @@ If the implicit session is already active and one of those startup-scoped flags
98
101
 
99
102
  That failure should include a structured recovery hint pointing to `sessionMode: "fresh"` as the first-line fix, while still allowing an explicit `--session` when the caller wants to name the new upstream session.
100
103
 
104
+ A successful unnamed `sessionMode: "fresh"` launch should become the new extension-managed session so later default calls follow that browser instead of silently snapping back to the older managed session.
105
+
101
106
  ## Preferring the native tool
102
107
 
103
108
  Keep the handling simple:
@@ -84,7 +84,7 @@ The design should comfortably support workflows such as:
84
84
  - web research
85
85
  - using browser UIs for other LLMs such as ChatGPT, Grok, Gemini, and Claude
86
86
  - isolated authenticated browser sessions
87
- - cloned-profile workflows similar to the patterns used in `pi-oracle`
87
+ - upstream profile/debug workflows without adding a local profile-cloning layer in this package
88
88
 
89
89
  ## Implications for the implementation
90
90
 
@@ -77,8 +77,8 @@ Examples:
77
77
 
78
78
  Behavior:
79
79
  - if `args` already include `--session`, upstream session choice wins
80
- - `"auto"` prepends the implicit active session when appropriate
81
- - `"fresh"` skips the implicit session so startup-scoped flags like `--profile`, `--session-name`, or `--cdp` can launch a fresh upstream session
80
+ - `"auto"` prepends the current extension-managed active session when appropriate
81
+ - `"fresh"` rotates that managed session to a fresh upstream launch so startup-scoped flags like `--profile`, `--session-name`, or `--cdp` apply and later default calls follow the new browser
82
82
 
83
83
  Recommended use:
84
84
  - use `"auto"` for the common browse/snapshot/click flow inside one `pi` session
@@ -121,7 +121,8 @@ Recommended details:
121
121
  ```json
122
122
  {
123
123
  "args": ["snapshot", "-i"],
124
- "effectiveArgs": ["--session", "pi-abc123", "--json", "snapshot", "-i"],
124
+ "effectiveArgs": ["--json", "--session", "pi-abc123", "snapshot", "-i"],
125
+ "command": "snapshot",
125
126
  "sessionMode": "auto",
126
127
  "sessionName": "pi-abc123",
127
128
  "usedImplicitSession": true,
@@ -131,10 +132,21 @@ Recommended details:
131
132
  "e1": { "name": "Example Domain", "role": "heading" }
132
133
  },
133
134
  "snapshot": "- heading \"Example Domain\" [level=1, ref=e1]"
134
- }
135
+ },
136
+ "summary": "Snapshot: 1 refs on https://example.com/"
135
137
  }
136
138
  ```
137
139
 
140
+ Additional structured fields can appear when relevant:
141
+ - `batchFailure` and `batchSteps` for `batch` rendering, including mixed-success runs
142
+ - `navigationSummary` for navigation-style commands like `click`, `back`, `forward`, and `reload`
143
+ - `imagePath` / `imagePaths` for screenshots and batched image outputs
144
+ - `fullOutputPath` / `fullOutputPaths` when large snapshot output is compacted and spilled to a private temp file
145
+ - `sessionRecoveryHint` when startup-scoped flags need `sessionMode: "fresh"`
146
+ - `inspection: true` plus `stdout` for successful plain-text inspection commands like `--help` and `--version`
147
+
148
+ When the tool echoes `args` or `effectiveArgs` back into Pi, sensitive values such as `--headers`, proxy credentials, and auth-bearing URL parameters should be redacted first.
149
+
138
150
  For oversized snapshots, details should switch to a compact metadata object and include `fullOutputPath` pointing at a private temp JSON spill file with the full upstream snapshot payload.
139
151
 
140
152
  ## High-value result rendering
@@ -157,15 +169,19 @@ If `agent-browser` is not on `PATH`, fail with a message that:
157
169
 
158
170
  ## Session behavior
159
171
 
160
- - maintain one implicit active session per `pi` session for the common path
161
- - derive that implicit session from the official `pi` session id
172
+ - maintain one extension-managed active session per `pi` session for the common path
173
+ - derive the base implicit session name from the official `pi` session id plus a cwd hash so same-named checkouts do not collide
162
174
  - respect explicit upstream `--session` with minimal interference
163
- - treat the implicit session as extension-managed convenience state
164
- - on normal `pi` shutdown, best-effort close the implicit session
165
- - set an idle timeout on implicit sessions so abandoned daemons eventually self-clean
166
- - clean up private temp spill artifacts owned by the implicit session on shutdown
167
- - treat explicit upstream session choices like `--session`, `--profile`, `--session-name`, and `--cdp` as user-managed
175
+ - treat the extension-managed session as convenience state owned by the wrapper
176
+ - on normal `pi` shutdown, best-effort close the current extension-managed session
177
+ - set an idle timeout on extension-managed sessions so abandoned daemons eventually self-clean
178
+ - clean up private temp spill artifacts owned by the extension-managed session on shutdown
179
+ - reconstruct the current extension-managed session from persisted tool details on resume/reload so later default calls keep following the active managed browser
180
+ - when an unnamed `sessionMode: "fresh"` launch succeeds, make it the new extension-managed session so later default calls keep using it
181
+ - if that unnamed fresh launch replaced an already-active managed session, best-effort close the old managed session after the switch succeeds
182
+ - treat explicit caller-provided `--session` choices as user-managed
168
183
  - pass explicit `--profile` straight through to upstream `agent-browser`; no profile-cloning or isolation layer is added in v1
184
+ - treat successful plain-text inspection commands like `--help` and `--version` as stateless: do not inject the implicit managed session and do not let those calls claim the managed-session slot
169
185
  - if startup-scoped flags like `--profile`, `--session-name`, or `--cdp` are supplied after the implicit session is already active while `sessionMode` is `"auto"`, return a validation error with a structured recovery hint that recommends `sessionMode: "fresh"`
170
186
 
171
187
  ## Non-goals