pi-agent-browser-native 0.2.16 → 0.2.17

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
@@ -2,6 +2,15 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.17 - 2026-05-03
6
+
7
+ ### Fixed
8
+ - close the active extension-managed `piab-*` browser session when the originating `pi` process quits, while preserving managed browser continuity across `/reload` and resumable session transitions
9
+ - added lifecycle regression coverage for quit-time managed-session cleanup and reload-time preservation
10
+
11
+ ### Changed
12
+ - clarified that the managed-session idle timeout is now an abnormal-exit backstop, not the primary cleanup path for normal `pi` exits
13
+
5
14
  ## 0.2.16 - 2026-05-02
6
15
 
7
16
  ### Fixed
package/README.md CHANGED
@@ -263,7 +263,7 @@ These calls return plain text and stay stateless: the extension does not inject
263
263
  Current cautions:
264
264
  - passing `--profile` is an explicit upstream choice; this extension does not add its own profile-cloning or isolation layer
265
265
  - launch-scoped flags like `--profile`, `--session-name`, `--cdp`, `--state`, and `--auto-connect` 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
266
- - 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` and metadata-only `details.artifactManifest` survive reload/resume without unbounded growth, and still clean up process-private temp spill artifacts on shutdown
266
+ - implicit `piab-*` sessions are extension-managed convenience sessions; they stay alive across `/reload` and resumable session transitions so later default calls can keep following the active managed browser on `/reload` or `/resume`, close when the originating `pi` process quits, rely on the configured idle timeout only as an abnormal-exit backstop, store persisted-session large snapshot spill files under a private session-scoped artifact directory with a bounded per-session budget so `details.fullOutputPath` and metadata-only `details.artifactManifest` survive reload/resume without unbounded growth, and still clean up process-private temp spill artifacts on shutdown
267
267
  - `sessionMode: "fresh"` without an explicit `--session` rotates that extension-managed session to the new browser so later auto calls keep using it
268
268
  - 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
269
269
  - for direct headless local Chrome launches to `chat.com`, `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`
@@ -87,8 +87,9 @@ V1 ownership rule:
87
87
  - extension-managed sessions should be reusable during an active `pi` session and across `/reload` / `/resume`, while still being cleaned up predictably
88
88
 
89
89
  Practical policy:
90
- - preserve the current extension-managed session across normal `pi` shutdown/reload so persisted sessions can keep following the live browser after `/reload` or `/resume`
91
- - set an idle timeout on extension-managed sessions so abandoned daemons self-clean after inactivity
90
+ - preserve the current extension-managed session across `/reload` and resumable session transitions so persisted sessions can keep following the live browser after `/reload` or `/resume`
91
+ - close the active extension-managed session when the originating `pi` process quits, while leaving explicit caller-provided sessions alone
92
+ - set an idle timeout on extension-managed sessions as a backstop for abnormal exits or cleanup failures
92
93
  - 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
93
94
  - reconstruct the current extension-managed session from persisted tool details on resume/reload so later default calls keep following the active managed browser
94
95
  - if an unnamed fresh launch replaces an active extension-managed session, best-effort close the old managed session after the switch succeeds
@@ -213,8 +213,9 @@ If `agent-browser` is not on `PATH`, fail with a message that:
213
213
  - derive the base implicit session name from the official `pi` session id plus a cwd hash so same-named checkouts do not collide
214
214
  - respect explicit upstream `--session` with minimal interference
215
215
  - treat the extension-managed session as convenience state owned by the wrapper
216
- - preserve the current extension-managed session across normal `pi` shutdown/reload so persisted sessions can keep following the live browser on `/reload` or `/resume`
217
- - set an idle timeout on extension-managed sessions so abandoned daemons eventually self-clean
216
+ - preserve the current extension-managed session across `/reload` and resumable session transitions so persisted sessions can keep following the live browser on `/reload` or `/resume`
217
+ - close the active extension-managed session when the originating `pi` process quits, while leaving explicit caller-provided sessions alone
218
+ - set an idle timeout on extension-managed sessions as a backstop for abnormal exits or cleanup failures
218
219
  - 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
219
220
  - reconstruct the current extension-managed session and latest `artifactManifest` from persisted tool details on resume/reload so later default calls keep following the active managed browser and can continue reporting artifact retention state
220
221
  - when an unnamed `sessionMode: "fresh"` launch succeeds, make it the new extension-managed session so later default calls keep using it
@@ -1385,7 +1385,17 @@ export default function agentBrowserExtension(pi: ExtensionAPI) {
1385
1385
  artifactManifest = restoreArtifactManifestFromBranch(ctx.sessionManager.getBranch());
1386
1386
  });
1387
1387
 
1388
- pi.on("session_shutdown", async () => {
1388
+ pi.on("session_shutdown", async (event) => {
1389
+ if (event?.reason === "quit") {
1390
+ await managedSessionExecutionQueue.run(async () => {
1391
+ if (!managedSessionActive) return;
1392
+ await closeManagedSession({
1393
+ cwd: managedSessionCwd,
1394
+ sessionName: managedSessionName,
1395
+ timeoutMs: implicitSessionCloseTimeoutMs,
1396
+ });
1397
+ });
1398
+ }
1389
1399
  managedSessionActive = false;
1390
1400
  sessionTabTargets = new Map<string, OrderedSessionTabTarget>();
1391
1401
  sessionTabTargetUpdateOrder = 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-agent-browser-native",
3
- "version": "0.2.16",
3
+ "version": "0.2.17",
4
4
  "description": "pi extension that exposes agent-browser as a native tool for browser automation",
5
5
  "type": "module",
6
6
  "author": "Mitch Fultz (https://github.com/fitchmultz)",