pi-agent-browser-native 0.2.16 → 0.2.18

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,26 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 0.2.18 - 2026-05-03
6
+
7
+ ### Fixed
8
+ - persist oversized parse-failure spill files when Pi provides a session directory without a session file
9
+ - isolate the opt-in real-upstream download contract test from the user's global Downloads folder and avoid killing unrelated `agent-browser` processes
10
+
11
+ ### Changed
12
+ - clarified the README and repo guidance for the current published package state
13
+ - marked the completed implementation plan as superseded so current design guidance stays canonical
14
+ - tightened the implicit-session idle-timeout helper to return milliseconds as a number and convert to an environment string only at the process boundary
15
+
16
+ ## 0.2.17 - 2026-05-03
17
+
18
+ ### Fixed
19
+ - 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
20
+ - added lifecycle regression coverage for quit-time managed-session cleanup and reload-time preservation
21
+
22
+ ### Changed
23
+ - clarified that the managed-session idle timeout is now an abnormal-exit backstop, not the primary cleanup path for normal `pi` exits
24
+
5
25
  ## 0.2.16 - 2026-05-02
6
26
 
7
27
  ### Fixed
package/README.md CHANGED
@@ -4,9 +4,9 @@ Native `pi` integration for [`agent-browser`](https://agent-browser.dev/).
4
4
 
5
5
  ## Status
6
6
 
7
- Early working scaffold.
7
+ Published pre-1.0 package.
8
8
 
9
- The package scaffold, native `agent_browser` tool, local typecheck/test setup, and release/package verification workflow are in place.
9
+ The native `agent_browser` tool, local verification workflow, package-content checks, and release checks are in place. Package install is the default path; checkout loading is for development and validation.
10
10
 
11
11
  ## Goal
12
12
 
@@ -45,7 +45,7 @@ A native `pi` integration can improve on the current skill by adding:
45
45
 
46
46
  ## Install and try
47
47
 
48
- The product direction is package-first. Prefer the package source once a release exists, while keeping the local-checkout flow for current development and pre-release validation.
48
+ The product direction is package-first. Prefer the package source for normal use; keep the local-checkout flow for development and pre-release validation.
49
49
 
50
50
  ### Preferred package install
51
51
 
@@ -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
@@ -1216,17 +1216,12 @@ function buildSessionDetailFields(sessionName: string | undefined, usedImplicitS
1216
1216
  function getPersistentSessionArtifactStore(ctx: {
1217
1217
  sessionManager: {
1218
1218
  getSessionDir?: () => string;
1219
- getSessionFile?: () => string | undefined;
1220
1219
  getSessionId: () => string | undefined;
1221
1220
  };
1222
1221
  }): PersistentSessionArtifactStore | undefined {
1223
- const sessionFile = typeof ctx.sessionManager.getSessionFile === "function" ? ctx.sessionManager.getSessionFile() : undefined;
1224
1222
  const sessionDir = typeof ctx.sessionManager.getSessionDir === "function" ? ctx.sessionManager.getSessionDir() : undefined;
1225
1223
  const sessionId = ctx.sessionManager.getSessionId();
1226
- if (!sessionFile || !sessionDir || !sessionId) {
1227
- return undefined;
1228
- }
1229
- return { sessionDir, sessionId };
1224
+ return sessionDir && sessionId ? { sessionDir, sessionId } : undefined;
1230
1225
  }
1231
1226
 
1232
1227
  async function preserveParseFailureOutput(options: {
@@ -1360,7 +1355,7 @@ export default function agentBrowserExtension(pi: ExtensionAPI) {
1360
1355
  const ephemeralSessionSeed = createEphemeralSessionSeed();
1361
1356
  const hasBraveApiKey = hasUsableBraveApiKey();
1362
1357
  const toolPromptGuidelines = buildToolPromptGuidelines({ includeBraveSearch: hasBraveApiKey });
1363
- const implicitSessionIdleTimeoutMs = getImplicitSessionIdleTimeoutMs();
1358
+ const implicitSessionIdleTimeoutMs = String(getImplicitSessionIdleTimeoutMs());
1364
1359
  const implicitSessionCloseTimeoutMs = getImplicitSessionCloseTimeoutMs();
1365
1360
  let managedSessionActive = false;
1366
1361
  let managedSessionBaseName = createImplicitSessionName(undefined, process.cwd(), ephemeralSessionSeed);
@@ -1385,7 +1380,17 @@ export default function agentBrowserExtension(pi: ExtensionAPI) {
1385
1380
  artifactManifest = restoreArtifactManifestFromBranch(ctx.sessionManager.getBranch());
1386
1381
  });
1387
1382
 
1388
- pi.on("session_shutdown", async () => {
1383
+ pi.on("session_shutdown", async (event) => {
1384
+ if (event?.reason === "quit") {
1385
+ await managedSessionExecutionQueue.run(async () => {
1386
+ if (!managedSessionActive) return;
1387
+ await closeManagedSession({
1388
+ cwd: managedSessionCwd,
1389
+ sessionName: managedSessionName,
1390
+ timeoutMs: implicitSessionCloseTimeoutMs,
1391
+ });
1392
+ });
1393
+ }
1389
1394
  managedSessionActive = false;
1390
1395
  sessionTabTargets = new Map<string, OrderedSessionTabTarget>();
1391
1396
  sessionTabTargetUpdateOrder = 0;
@@ -421,12 +421,10 @@ function parseTimeoutMs(rawValue: string | undefined, minimumValue: number): num
421
421
  return parsedValue;
422
422
  }
423
423
 
424
- export function getImplicitSessionIdleTimeoutMs(env: NodeJS.ProcessEnv = process.env): string {
425
- return String(
426
- parseTimeoutMs(env[IMPLICIT_SESSION_IDLE_TIMEOUT_ENV], 0) ??
427
- parseTimeoutMs(env[AGENT_BROWSER_IDLE_TIMEOUT_ENV], 0) ??
428
- DEFAULT_IMPLICIT_SESSION_IDLE_TIMEOUT_MS,
429
- );
424
+ export function getImplicitSessionIdleTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {
425
+ return parseTimeoutMs(env[IMPLICIT_SESSION_IDLE_TIMEOUT_ENV], 0) ??
426
+ parseTimeoutMs(env[AGENT_BROWSER_IDLE_TIMEOUT_ENV], 0) ??
427
+ DEFAULT_IMPLICIT_SESSION_IDLE_TIMEOUT_MS;
430
428
  }
431
429
 
432
430
  export function getImplicitSessionCloseTimeoutMs(env: NodeJS.ProcessEnv = process.env): number {
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.18",
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)",