pi-agent-browser-native 0.2.2 → 0.2.4
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 +16 -0
- package/README.md +8 -1
- package/docs/ARCHITECTURE.md +10 -5
- package/docs/RELEASE.md +11 -2
- package/docs/REQUIREMENTS.md +7 -1
- package/docs/TOOL_CONTRACT.md +9 -4
- package/extensions/agent-browser/index.ts +596 -61
- package/extensions/agent-browser/lib/process.ts +30 -2
- package/extensions/agent-browser/lib/results/presentation.ts +92 -6
- package/extensions/agent-browser/lib/results/snapshot.ts +15 -6
- package/extensions/agent-browser/lib/runtime.ts +171 -7
- package/extensions/agent-browser/lib/temp.ts +94 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,21 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.4 - 2026-04-13
|
|
4
|
+
|
|
5
|
+
### Fixed
|
|
6
|
+
- wrapper-spawned local Unix `agent-browser` runs now use a short private socket directory under `/tmp`, so extension-generated session names no longer fail the upstream Unix socket-path length limit in longer cwd/session-name combinations
|
|
7
|
+
- once the wrapper knows which tab a session should stay on, later active-tab commands like `click` and `snapshot -i` now best-effort pin that same tab inside the same upstream invocation instead of letting reconnect drift send the action to a restored/background tab
|
|
8
|
+
- persisted `sessionTabTarget` state now survives `/reload` / `/resume` for both managed and explicit sessions, so the reconnect-time tab pinning behavior can continue after restart/resume flows
|
|
9
|
+
- README, requirements, architecture notes, and tool-contract docs now describe the socket-path mitigation and the follow-up-command tab-pinning behavior
|
|
10
|
+
|
|
11
|
+
## 0.2.3 - 2026-04-13
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
- direct headless local Chrome launches to `chatgpt.com` and `chat.openai.com` now inject a normal Chrome user agent when the caller did not explicitly choose one, keeping authenticated ChatGPT/OpenAI browsing working without forcing `--headed` or `--auto-connect`
|
|
15
|
+
- profiled `open` / `goto` / `navigate` calls now best-effort switch back to the page that was just opened when restored profile tabs steal focus during launch, reducing confusing cross-tab drift in profile-backed sessions
|
|
16
|
+
- command parsing now treats additional value-taking global flags like `--user-agent`, `--args`, `--allowed-domains`, `--action-policy`, and related launch options as launch metadata instead of accidentally parsing their values as subcommands
|
|
17
|
+
- README, requirements, architecture notes, and tool-contract docs now describe the new headless ChatGPT/OpenAI compatibility behavior and the profiled-tab focus recovery path
|
|
18
|
+
|
|
3
19
|
## 0.2.2 - 2026-04-12
|
|
4
20
|
|
|
5
21
|
### Fixed
|
package/README.md
CHANGED
|
@@ -178,6 +178,8 @@ Validated workflow examples:
|
|
|
178
178
|
- click a link and confirm the destination title
|
|
179
179
|
- use an explicit `--session` across multiple tool calls
|
|
180
180
|
- use an explicit `--profile` and verify persisted browser storage across restarts
|
|
181
|
+
- open `chatgpt.com` headlessly with `--profile Default` without forcing `--headed` or `--auto-connect`
|
|
182
|
+
- verify `/reload` and full restart + `/resume` keep following the same implicit managed browser session
|
|
181
183
|
- run `batch` with JSON via `stdin`
|
|
182
184
|
- run `eval --stdin`
|
|
183
185
|
- take a screenshot with inline attachment support
|
|
@@ -188,9 +190,14 @@ Inspection commands like `agent_browser --help` and `--version` are always suppo
|
|
|
188
190
|
Current cautions:
|
|
189
191
|
- passing `--profile` is an explicit upstream choice; this extension does not add its own profile-cloning or isolation layer
|
|
190
192
|
- 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
|
|
191
|
-
- implicit `piab-*` sessions are extension-managed convenience sessions; they
|
|
193
|
+
- implicit `piab-*` sessions are extension-managed convenience sessions; they stay alive across `pi` shutdown/reload so later default calls can keep following the active managed browser on `/reload` or `/resume`, rely on the configured idle timeout to reduce stale background daemons, store persisted-session large snapshot spill files under a private session-scoped artifact directory with a bounded per-session budget so `details.fullOutputPath` survives reload/resume without unbounded growth, and still clean up process-private temp spill artifacts on shutdown
|
|
192
194
|
- `sessionMode: "fresh"` without an explicit `--session` rotates that extension-managed session to the new browser so later auto calls keep using it
|
|
195
|
+
- for local Unix launches, the wrapper uses a short private socket directory under `/tmp` so extension-generated session names do not trip upstream Unix socket-path limits in longer cwd/session-name combinations
|
|
196
|
+
- for direct headless local Chrome launches to `chatgpt.com` and `chat.openai.com`, the extension injects a normal Chrome user agent when the caller did not explicitly provide `--user-agent`; this keeps the default headless workflow usable without forcing `--headed` or `--auto-connect`
|
|
197
|
+
- after profiled `open` calls, the extension best-effort re-selects the tab that matches the returned page URL when restored profile tabs steal focus during launch
|
|
198
|
+
- after a target tab is known, later active-tab commands like `click` and `snapshot -i` best-effort pin that same tab inside the same upstream invocation when a reconnect would otherwise drift to a restored tab
|
|
193
199
|
- explicit caller-provided `--session` values are treated as user-managed and are not auto-closed by the extension
|
|
200
|
+
- explicit caller-provided `--user-agent` values win over the ChatGPT/OpenAI compatibility workaround
|
|
194
201
|
- tool progress/details redact sensitive invocation values such as `--headers`, proxy credentials, and auth-bearing URL parameters before echoing them back into Pi
|
|
195
202
|
|
|
196
203
|
### Switching from public browsing to a fresh profile/debug launch
|
package/docs/ARCHITECTURE.md
CHANGED
|
@@ -78,17 +78,20 @@ V1 ownership rule:
|
|
|
78
78
|
- implicit auto-generated sessions are extension-managed convenience sessions
|
|
79
79
|
- unnamed `sessionMode: "fresh"` launches rotate that extension-managed session to a new upstream browser
|
|
80
80
|
- explicit/user-managed sessions are not auto-managed by default
|
|
81
|
-
- extension-managed sessions should be reusable during an active `pi` session
|
|
81
|
+
- extension-managed sessions should be reusable during an active `pi` session and across `/reload` / `/resume`, while still being cleaned up predictably
|
|
82
82
|
|
|
83
83
|
Practical policy:
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
- clean up private temp spill artifacts
|
|
84
|
+
- preserve the current extension-managed session across normal `pi` shutdown/reload so persisted sessions can keep following the live browser after `/reload` or `/resume`
|
|
85
|
+
- set an idle timeout on extension-managed sessions so abandoned daemons self-clean after inactivity
|
|
86
|
+
- clean up process-private temp spill artifacts on shutdown, but keep persisted-session snapshot spill files in a private session-scoped artifact directory with a bounded per-session budget so `details.fullOutputPath` stays usable after reload/resume without unbounded growth
|
|
87
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
88
|
- if an unnamed fresh launch replaces an active extension-managed session, best-effort close the old managed session after the switch succeeds
|
|
89
89
|
- leave explicit caller-provided `--session` choices alone unless the caller closes them explicitly
|
|
90
|
+
- after profiled `open` / `goto` / `navigate` calls, verify the active tab still matches the returned page URL and best-effort switch back when restored profile tabs steal focus
|
|
91
|
+
- once the wrapper knows which tab the agent is operating on, later active-tab commands may synthesize a tiny upstream `batch` that re-selects that tab and then runs the requested command in the same upstream invocation; this stays thin while avoiding reconnect-time drift on profile-restored sessions
|
|
92
|
+
- for local Unix launches, set a short private socket directory so extension-generated session names do not fail on the upstream Unix socket-path length limit
|
|
90
93
|
|
|
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
|
|
94
|
+
This is primarily about ownership clarity and avoiding surprise, not adding a heavy safety wrapper. If the extension invented the session, the extension should own its lifecycle without breaking reload/resume semantics. If the caller explicitly chose the upstream session model, the extension should stay out of the way.
|
|
92
95
|
|
|
93
96
|
### Launch flags
|
|
94
97
|
|
|
@@ -97,6 +100,8 @@ The extension should surface that clearly and avoid hidden restart behavior in v
|
|
|
97
100
|
|
|
98
101
|
That means explicit startup-scoping flags like `--profile`, `--session-name`, and `--cdp` should remain explicit upstream choices instead of being wrapped in extra hidden restart or cloning logic.
|
|
99
102
|
|
|
103
|
+
The wrapper may still apply narrow compatibility normalizations when observed behavior justifies them and the result remains thin, local, and opt-out. For example, if a specific site starts rejecting the default local headless Chrome user agent while the same flow works with a normal Chrome UA, the extension may inject a domain-specific fallback UA only when the caller did not already choose `--user-agent`, `--headed`, `--cdp`, `--auto-connect`, or a provider-backed launch.
|
|
104
|
+
|
|
100
105
|
If the implicit session is already active and one of those startup-scoped flags appears again while `sessionMode` is still `"auto"`, the extension should fail clearly instead of silently sending a command shape that upstream would ignore.
|
|
101
106
|
|
|
102
107
|
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.
|
package/docs/RELEASE.md
CHANGED
|
@@ -57,13 +57,21 @@ Before publishing, also validate the explicit local-checkout path:
|
|
|
57
57
|
2. Launch `pi --no-extensions -e .` from this repository root.
|
|
58
58
|
3. Confirm the checkout extension loads from `extensions/agent-browser/index.ts`.
|
|
59
59
|
4. Run a smoke prompt that exercises `agent_browser`.
|
|
60
|
+
5. Validate managed-session continuity with both `/reload` and a full restart + `/resume`.
|
|
60
61
|
|
|
61
|
-
Example prompt:
|
|
62
|
+
Example smoke prompt:
|
|
62
63
|
|
|
63
64
|
```text
|
|
64
65
|
Use the agent_browser tool to open https://react.dev and then take an interactive snapshot.
|
|
65
66
|
```
|
|
66
67
|
|
|
68
|
+
Recommended lifecycle follow-up:
|
|
69
|
+
|
|
70
|
+
1. Open a page with the implicit managed session and confirm the title.
|
|
71
|
+
2. Run `/reload`, then ask for `snapshot -i` and confirm the same page is still active.
|
|
72
|
+
3. Exit `pi`, relaunch it against the same session file or use `/resume`, then ask for `snapshot -i` again and confirm the same page is still active.
|
|
73
|
+
4. Open a large page that compacts its snapshot output and confirm `details.fullOutputPath` still exists after the restart/resume flow.
|
|
74
|
+
|
|
67
75
|
## Post-publish install validation
|
|
68
76
|
|
|
69
77
|
After publishing a release, validate the package-first install path explicitly:
|
|
@@ -73,7 +81,7 @@ pi install npm:pi-agent-browser-native@<version>
|
|
|
73
81
|
pi -e npm:pi-agent-browser-native@<version>
|
|
74
82
|
```
|
|
75
83
|
|
|
76
|
-
Then confirm `pi` exposes the native `agent_browser` tool
|
|
84
|
+
Then confirm `pi` exposes the native `agent_browser` tool, that a basic `open` + `snapshot -i` flow works, and that `/reload` plus restart/`/resume` keep following the same implicit managed browser session.
|
|
77
85
|
|
|
78
86
|
## Release notes checklist
|
|
79
87
|
|
|
@@ -83,4 +91,5 @@ Before publishing:
|
|
|
83
91
|
- confirm README install guidance still leads with the package-first flow
|
|
84
92
|
- confirm the explicit local-checkout instructions still work for pre-release validation
|
|
85
93
|
- rerun `npm run verify:release`
|
|
94
|
+
- manually exercise `/reload` and full restart + `/resume` continuity in local checkout validation
|
|
86
95
|
- publish only after the tarball contents match expectations
|
package/docs/REQUIREMENTS.md
CHANGED
|
@@ -71,7 +71,8 @@ Define the product requirements and constraints for `pi-agent-browser-native`.
|
|
|
71
71
|
|
|
72
72
|
- The primary confidence path is a real `pi` session driven in `tmux`.
|
|
73
73
|
- For local checkout validation, launch `pi --no-extensions -e .` from the repository root so only the checkout copy loads.
|
|
74
|
-
-
|
|
74
|
+
- Validate both `/reload` and a full `pi` restart with `/resume` when changes touch managed-session continuity, reload behavior, or persisted artifact paths.
|
|
75
|
+
- Prefer full `pi` restart over `/reload` when validating extension changes beyond a quick reload smoke check.
|
|
75
76
|
- Use `/resume` when needed after restart.
|
|
76
77
|
- Keep testing broader than a single smoke site like `example.com`.
|
|
77
78
|
- Maintain a concrete release/package verification workflow in `docs/RELEASE.md` and matching repository scripts.
|
|
@@ -84,6 +85,7 @@ The design should comfortably support workflows such as:
|
|
|
84
85
|
- web research
|
|
85
86
|
- using browser UIs for other LLMs such as ChatGPT, Grok, Gemini, and Claude
|
|
86
87
|
- isolated authenticated browser sessions
|
|
88
|
+
- headless authenticated ChatGPT/OpenAI browsing without forcing `--headed` or `--auto-connect`
|
|
87
89
|
- upstream profile/debug workflows without adding a local profile-cloning layer in this package
|
|
88
90
|
|
|
89
91
|
## Implications for the implementation
|
|
@@ -94,6 +96,10 @@ The design should comfortably support workflows such as:
|
|
|
94
96
|
- User-facing docs belong in `README.md` and the canonical published files under `docs/`.
|
|
95
97
|
- Agent workflow and deeper testing procedures can stay in `AGENTS.md`, but published docs must not depend on that file being present.
|
|
96
98
|
- Keep mitigations for legacy-skill coexistence simple; do not add extra moving parts unless observed behavior justifies them.
|
|
99
|
+
- Prefer narrow, evidence-backed compatibility mitigations over broad stealth layers when a specific upstream site starts rejecting the default headless launch fingerprint.
|
|
100
|
+
- Preserve the page that a profiled `open` just navigated to; if restored profile tabs steal focus during launch, the wrapper should best-effort switch back to the returned page URL before handing control back to the agent.
|
|
101
|
+
- Once a tab target is known for a session, later active-tab commands should best-effort pin that same tab inside the same upstream invocation when reconnect drift would otherwise land on a restored/background tab.
|
|
102
|
+
- On local Unix launches, extension-generated session names should not fail just because the upstream default socket path is too long; the wrapper should choose a shorter socket directory when needed.
|
|
97
103
|
|
|
98
104
|
## Open design questions
|
|
99
105
|
|
package/docs/TOOL_CONTRACT.md
CHANGED
|
@@ -141,13 +141,13 @@ Additional structured fields can appear when relevant:
|
|
|
141
141
|
- `batchFailure` and `batchSteps` for `batch` rendering, including mixed-success runs
|
|
142
142
|
- `navigationSummary` for navigation-style commands like `click`, `back`, `forward`, and `reload`
|
|
143
143
|
- `imagePath` / `imagePaths` for screenshots and batched image outputs
|
|
144
|
-
- `fullOutputPath` / `fullOutputPaths` when large snapshot output is compacted and spilled to a private
|
|
144
|
+
- `fullOutputPath` / `fullOutputPaths` when large snapshot output is compacted and spilled to a private file; persisted sessions keep that path under a private session-scoped artifact directory with a bounded per-session budget so it survives reload/resume without unbounded growth
|
|
145
145
|
- `sessionRecoveryHint` when startup-scoped flags need `sessionMode: "fresh"`
|
|
146
146
|
- `inspection: true` plus `stdout` for successful plain-text inspection commands like `--help` and `--version`
|
|
147
147
|
|
|
148
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
149
|
|
|
150
|
-
For oversized snapshots, details should switch to a compact metadata object and include `fullOutputPath` pointing at a private
|
|
150
|
+
For oversized snapshots, details should switch to a compact metadata object and include `fullOutputPath` pointing at a private JSON spill file with the full upstream snapshot payload. Persisted sessions should keep that spill file under a private session-scoped artifact directory so the path remains usable after reload/restart, with the oldest persisted spill files evicted as needed to stay within the per-session budget.
|
|
151
151
|
|
|
152
152
|
## High-value result rendering
|
|
153
153
|
|
|
@@ -156,6 +156,7 @@ For oversized snapshots, details should switch to a compact metadata object and
|
|
|
156
156
|
Worth doing in v1:
|
|
157
157
|
- screenshots → inline image attachment
|
|
158
158
|
- snapshots → origin + ref count + main-content-first compact preview, with the raw snapshot spill path kept in `details.fullOutputPath` when the inline result would otherwise be too large
|
|
159
|
+
- extraction-style commands like `eval --stdin` and `get title` → scalar-first text with lightweight origin context when available
|
|
159
160
|
- navigation actions like `click`, `back`, `forward`, and `reload` → lightweight post-action title/url summary when available
|
|
160
161
|
- tab lists → compact summary/table
|
|
161
162
|
- stream status → enabled/connected/port summary
|
|
@@ -173,16 +174,20 @@ If `agent-browser` is not on `PATH`, fail with a message that:
|
|
|
173
174
|
- derive the base implicit session name from the official `pi` session id plus a cwd hash so same-named checkouts do not collide
|
|
174
175
|
- respect explicit upstream `--session` with minimal interference
|
|
175
176
|
- treat the extension-managed session as convenience state owned by the wrapper
|
|
176
|
-
-
|
|
177
|
+
- preserve the current extension-managed session across normal `pi` shutdown/reload so persisted sessions can keep following the live browser on `/reload` or `/resume`
|
|
177
178
|
- set an idle timeout on extension-managed sessions so abandoned daemons eventually self-clean
|
|
178
|
-
- clean up private temp spill artifacts
|
|
179
|
+
- clean up process-private temp spill artifacts on shutdown, while keeping persisted-session snapshot spill files in a private session-scoped artifact directory so `details.fullOutputPath` survives reload/restart and the oldest spill files are evicted if the per-session artifact budget is exceeded
|
|
179
180
|
- reconstruct the current extension-managed session from persisted tool details on resume/reload so later default calls keep following the active managed browser
|
|
180
181
|
- when an unnamed `sessionMode: "fresh"` launch succeeds, make it the new extension-managed session so later default calls keep using it
|
|
181
182
|
- if that unnamed fresh launch replaced an already-active managed session, best-effort close the old managed session after the switch succeeds
|
|
182
183
|
- treat explicit caller-provided `--session` choices as user-managed
|
|
183
184
|
- pass explicit `--profile` straight through to upstream `agent-browser`; no profile-cloning or isolation layer is added in v1
|
|
185
|
+
- after profiled `open` / `goto` / `navigate`, if upstream leaves a restored profile tab active instead of the page that was just opened, best-effort switch back to the tab whose URL matches the returned open result before returning control to the agent
|
|
186
|
+
- once the wrapper has a known tab target for a session, later active-tab commands may best-effort pin that tab inside the same upstream invocation so reconnect drift does not send a `click`, `snapshot`, or similar action to a restored/background tab instead
|
|
187
|
+
- on local Unix launches, set a short private socket directory for wrapper-spawned `agent-browser` processes so extension-generated session names do not fail the upstream Unix socket-path length limit in longer cwd/session-name combinations
|
|
184
188
|
- 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
|
|
185
189
|
- 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"`
|
|
190
|
+
- for direct headless local Chrome launches to `chatgpt.com` / `chat.openai.com`, allow a narrow compatibility fallback that injects a normal Chrome `--user-agent` only when the caller did not explicitly provide one and did not choose `--headed`, `--cdp`, `--auto-connect`, or a provider-backed launch
|
|
186
191
|
|
|
187
192
|
## Non-goals
|
|
188
193
|
|