@timmyjl12/pi-agy-bridge 0.1.2 → 0.1.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/ARCHITECTURE.md +1 -1
- package/README.md +2 -1
- package/compat/probe.ts +1 -1
- package/package.json +1 -1
- package/src/acp/connection.ts +1 -1
- package/src/config.ts +6 -2
- package/src/index.ts +5 -8
- package/src/runtime.ts +13 -1
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
|
|
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.
|
|
7
|
+
> Status: 0.1.4. The default bridge home now honors Pi's configured agent directory (`PI_CODING_AGENT_DIR`). 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.
|
|
43
|
+
version: "0.1.4",
|
|
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.
|
|
3
|
+
"version": "0.1.4",
|
|
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",
|
package/src/acp/connection.ts
CHANGED
|
@@ -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.
|
|
197
|
+
clientInfo: { name: "pi-agy-bridge", title: "pi-agy-bridge", version: "0.1.4" },
|
|
198
198
|
});
|
|
199
199
|
return (result ?? {}) as AcpInitializeResult;
|
|
200
200
|
}
|
package/src/config.ts
CHANGED
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
import os from "node:os";
|
|
5
5
|
import path from "node:path";
|
|
6
6
|
|
|
7
|
+
function agentDir(env: Record<string, string | undefined>): string {
|
|
8
|
+
return env.PI_CODING_AGENT_DIR?.trim() || path.join(os.homedir(), ".pi", "agent");
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
/** How pi's system prompt reaches agy. `append`: `_meta.antigravity.systemPrompt.append` on `session/new`. `inline`: at
|
|
8
12
|
* the top of the first prompt (the conversation resource). `auto`: append, but when the backend answers a fresh appended
|
|
9
13
|
* session with RESOURCE_EXHAUSTED before any output, retry that turn once inline and keep using inline if it worked. */
|
|
@@ -36,7 +40,7 @@ export interface AgyConfig {
|
|
|
36
40
|
|
|
37
41
|
export const DEFAULT_CONFIG: Readonly<AgyConfig> = Object.freeze({
|
|
38
42
|
command: "agy",
|
|
39
|
-
home: path.join(
|
|
43
|
+
home: path.join(agentDir(process.env), "pi-agy-bridge"),
|
|
40
44
|
idleExitMs: 10 * 60_000,
|
|
41
45
|
sessionTtlMs: 5 * 60_000,
|
|
42
46
|
toolTtlMs: 30 * 60_000,
|
|
@@ -80,7 +84,7 @@ function positiveInt(value: string | undefined, fallback: number, scale = 1): nu
|
|
|
80
84
|
/** Resolve configuration from an environment. Pure: pass `process.env` or a test double. */
|
|
81
85
|
export function loadConfig(env: Record<string, string | undefined> = process.env): AgyConfig {
|
|
82
86
|
const command = env.PI_AGY_COMMAND?.trim() || env.AGY_BIN?.trim() || DEFAULT_CONFIG.command;
|
|
83
|
-
const home = env.PI_AGY_HOME?.trim() ||
|
|
87
|
+
const home = env.PI_AGY_HOME?.trim() || path.join(agentDir(env), "pi-agy-bridge");
|
|
84
88
|
return {
|
|
85
89
|
command,
|
|
86
90
|
home,
|
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
|
-
//
|
|
40
|
-
//
|
|
41
|
-
|
|
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
|
-
|
|
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([
|
|
285
|
+
await Promise.allSettled([stopPool(), this.settleRetired()]);
|
|
274
286
|
await this.flushWrites();
|
|
275
287
|
}
|
|
276
288
|
}
|