@timmyjl12/pi-agy-bridge 0.1.2 → 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/ARCHITECTURE.md CHANGED
@@ -63,7 +63,7 @@ Invalidation comes from three places: pi-context's rewrite registry (`Symbol.for
63
63
 
64
64
  ## Process model
65
65
 
66
- One shared `agy acp` per pi process, started on first real use, serving every caller (main session, subagents, side calls). Start is single-flight. A turn that went silent or hit pi's `timeoutMs` and then ignores `session/cancel` for the grace period gets its process killed (our PID only, identity-checked); an aborted or tool-call turn that ignores the cancel only has its session discarded. Other turns on a killed process fail with `agy exited with status N`, which fallback chains treat as transient. An unconditional synchronous kill runs on pi's `exit` event. quit/reload dispose the process; new/resume/fork only invalidate that session.
66
+ One shared `agy acp` per extension runtime, started on first real use, serving every caller (main session, subagents, side calls). Start is single-flight. A turn that went silent or hit pi's `timeoutMs` and then ignores `session/cancel` for the grace period gets its process killed (our PID only, identity-checked); an aborted or tool-call turn that ignores the cancel only has its session discarded. Other turns on a killed process fail with `agy exited with status N`, which fallback chains treat as transient. An unconditional synchronous kill runs on pi's `exit` event. Every `session_shutdown` (`quit`, `reload`, `new`, `resume` or `fork`) recycles the outgoing runtime: stop the process, forget sessions/discovery, detach global hooks and flush writes without permanently latching the pool. A background caller on the outgoing model runtime can therefore retry through a fresh process, which the normal idle reaper stops later. Explicit `AgyRuntime.dispose()` remains terminal for real cleanup and replaced pools.
67
67
 
68
68
  ## Isolation and the native-tool fence
69
69
 
package/README.md CHANGED
@@ -4,7 +4,7 @@ Use Google Antigravity models (Gemini, Claude, GPT-OSS) in [pi](https://github.c
4
4
 
5
5
  It follows the design of `pi-claude-code`: **pi keeps the conversation, the approvals and the tool execution; agy is only the model.** Every pi request becomes one ACP prompt turn. When the model wants a pi tool it writes a small tool-call block, pi runs the tool, and the next request carries the result. Nothing is parked between requests, so a slow tool (a long `pytest` run, a user dialog) can take as long as it needs and there is no turn time limit.
6
6
 
7
- > Status: 0.1.2. The compatibility probe passed on `agy 1.5.8` and `1.5.9` (identical surface). On 2026-11-14 (agy 1.5.9) the Antigravity backend began refusing pi's default system prompt sent through the append hook with `RESOURCE_EXHAUSTED`; live `gemini-4-hydrogen` turns and pi-subagents runs succeed through the `auto` inline fallback (see `PI_AGY_SYSTEM_PROMPT`). Earlier live bridge checks passed on `agy 1.5.8`. Live turns succeeded on `gemini-3.8-flash`, `gemini-4-hydrogen` (including `xhigh`), and `gemini-pro-orchestrator-g1-pro`. A real pi surface check with the configured extensions also passed. Claude and GPT-OSS have not been exercised in a live model turn.
7
+ > Status: 0.1.3. Every Pi session shutdown now recycles the outgoing runtime instead of permanently latching it shut, so a late pi-advisor retry can start a fresh ACP process; explicit terminal disposal remains terminal. The compatibility probe passed on `agy 1.5.8` and `1.5.9` (identical surface). On 2026-11-14 (agy 1.5.9) the Antigravity backend began refusing pi's default system prompt sent through the append hook with `RESOURCE_EXHAUSTED`; live `gemini-4-hydrogen` turns and pi-subagents runs succeed through the `auto` inline fallback (see `PI_AGY_SYSTEM_PROMPT`). Earlier live bridge checks passed on `agy 1.5.8`. Live turns succeeded on `gemini-3.8-flash`, `gemini-4-hydrogen` (including `xhigh`), and `gemini-pro-orchestrator-g1-pro`. A real pi surface check with the configured extensions also passed. Claude and GPT-OSS have not been exercised in a live model turn.
8
8
 
9
9
  ## Requirements
10
10
 
@@ -97,6 +97,7 @@ Example chain, mirrored from an `antigravity/*` chain:
97
97
  | `agy quota exceeded: Antigravity answered RESOURCE_EXHAUSTED ...` | the backend refused the request (429). agy would retry five times (~75 s); the bridge stops at the first notice. Since 2026-11-14 the backend refuses pi's default system prompt when it comes through the append hook (all models), while the same text inline is served; `auto` handles this | nothing in `auto` mode; otherwise use another model. The message says whether the prompt was appended or inline |
98
98
  | `agy stalled for 120s with no output` | the model produced nothing for the silence limit | retry; raise `PI_AGY_SILENCE_SEC` for very long silent thinking |
99
99
  | `agy exited with status N` | the agy process died | retry (a new process starts); `/agy-bridge doctor` shows agy's last stderr |
100
+ | `agy is unavailable: pi-agy-bridge is shut down` during or just after reload/session replacement | 0.1.2 or older permanently latched the outgoing pool while a background caller (often pi-advisor) was retrying | upgrade to 0.1.3 or newer. An old advisor error can remain visible until a later review succeeds; that sticky status is normal |
100
101
  | `pi-agy-bridge is unavailable: agy ... below the minimum` | agy too old | `agy update` |
101
102
  | a notice that agy is `newer-untested` | agy is newer than the tested matrix | it keeps working; see `UPGRADING.md` |
102
103
 
package/compat/probe.ts CHANGED
@@ -40,7 +40,7 @@ export const PROBE_PROTOCOL_VERSION = 1;
40
40
  export const PROBE_CLIENT_INFO = {
41
41
  name: "pi-agy-bridge-compat-probe",
42
42
  title: "pi-agy-bridge zero-cost compat probe",
43
- version: "0.1.2",
43
+ version: "0.1.3",
44
44
  } as const;
45
45
 
46
46
  /** One failed probe step. `step` names the command or exchange. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@timmyjl12/pi-agy-bridge",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "pi provider for Google Antigravity (agy) models over the official ACP server, modelled on pi-claude-code: pi keeps the loop, history and tool execution",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -194,7 +194,7 @@ export class AcpProcess {
194
194
  const result = await this.#rpc.request("initialize", {
195
195
  protocolVersion: 1,
196
196
  clientCapabilities: { fs: { readTextFile: false, writeTextFile: false }, terminal: false },
197
- clientInfo: { name: "pi-agy-bridge", title: "pi-agy-bridge", version: "0.1.2" },
197
+ clientInfo: { name: "pi-agy-bridge", title: "pi-agy-bridge", version: "0.1.3" },
198
198
  });
199
199
  return (result ?? {}) as AcpInitializeResult;
200
200
  }
package/src/index.ts CHANGED
@@ -36,15 +36,12 @@ export default function agyBridgeExtension(pi: ExtensionAPI): void {
36
36
  runtime.onNotice = (message, level) => ctx.ui.notify(message, level);
37
37
  });
38
38
 
39
- // quit/reload discard this extension instance, so stop the process. new/resume/fork only replace the pi
40
- // session: drop that session's pooled agy session and keep the process warm for the next one.
41
- pi.on("session_shutdown", async (event, ctx) => {
39
+ // Every shutdown reason replaces this extension runtime. Recycle rather than permanently disposing the pool:
40
+ // a background caller (for example pi-advisor's retry) can finish against the outgoing ModelRuntime and must
41
+ // not hit a terminal shutdown latch. Hooks stay detached; a late process is bounded by the normal idle reaper.
42
+ pi.on("session_shutdown", async () => {
42
43
  runtime.onNotice = undefined;
43
- if (event.reason === "quit" || event.reason === "reload") {
44
- await runtime.dispose();
45
- return;
46
- }
47
- runtime.pool.invalidate(ctx.sessionManager.getSessionId());
44
+ await runtime.recycle();
48
45
  });
49
46
  }
50
47
 
package/src/runtime.ts CHANGED
@@ -266,11 +266,23 @@ export class AgyRuntime {
266
266
  await Promise.allSettled([...this.#writes]);
267
267
  }
268
268
 
269
+ /** Retire this extension instance without latching its pool shut. Pi replaces the extension runtime on every
270
+ * session_shutdown, but a background caller on the outgoing ModelRuntime can still finish or retry after the
271
+ * event. Stop the current process and detach global hooks; such a late caller gets a fresh process, bounded by
272
+ * the normal idle reaper. Use dispose() for terminal cleanup. */
273
+ async recycle(): Promise<void> {
274
+ await this.#retire(() => this.#pool.reset());
275
+ }
276
+
269
277
  async dispose(): Promise<void> {
278
+ await this.#retire(() => this.#pool.dispose());
279
+ }
280
+
281
+ async #retire(stopPool: () => Promise<void>): Promise<void> {
270
282
  this.#disposed = true;
271
283
  this.#detach?.();
272
284
  this.#detach = undefined;
273
- await Promise.allSettled([this.#pool.dispose(), this.settleRetired()]);
285
+ await Promise.allSettled([stopPool(), this.settleRetired()]);
274
286
  await this.flushWrites();
275
287
  }
276
288
  }