@timmyjl12/pi-agy-bridge 0.0.0-stage → 0.1.1
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 +108 -0
- package/LICENSE +21 -0
- package/NOTICE.md +8 -0
- package/README.md +124 -2
- package/UPGRADING.md +111 -0
- package/compat/baselines/agy-1.5.3.json +202 -0
- package/compat/baselines/agy-1.5.8.json +231 -0
- package/compat/baselines/sdk-0.1.23.json +4317 -0
- package/compat/matrix.json +15 -0
- package/compat/probe-cli.ts +203 -0
- package/compat/probe.ts +825 -0
- package/compat/sdk-canary/canary.py +266 -0
- package/compat/sdk-canary/diff_fingerprint.py +88 -0
- package/compat/sdk-canary/fingerprint_proto.py +97 -0
- package/compat/sdk-canary/pyproject.toml +12 -0
- package/compat/sdk-canary/uv.lock +1761 -0
- package/package.json +59 -4
- package/src/acp/command.ts +57 -0
- package/src/acp/connection.ts +251 -0
- package/src/acp/frame-guard.ts +38 -0
- package/src/acp/jsonrpc.ts +227 -0
- package/src/acp/process-tree.ts +176 -0
- package/src/acp/staging.ts +99 -0
- package/src/acp/types.ts +75 -0
- package/src/atomic-write.ts +42 -0
- package/src/compat/features.ts +367 -0
- package/src/compat/matrix.ts +189 -0
- package/src/config.ts +83 -0
- package/src/doctor.ts +55 -0
- package/src/errors.ts +96 -0
- package/src/index.ts +53 -0
- package/src/model-catalog.ts +158 -0
- package/src/pi-context-hook.ts +32 -0
- package/src/provider.ts +94 -0
- package/src/runtime.ts +221 -0
- package/src/session-pool.ts +538 -0
- package/src/state.ts +40 -0
- package/src/stream.ts +476 -0
- package/src/tool-protocol.ts +381 -0
- package/src/trace.ts +29 -0
- package/src/transcript.ts +291 -0
package/ARCHITECTURE.md
ADDED
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
pi-agy-bridge is a pi provider (`createProvider` from pi-ai 1.5) whose models are served by `agy acp`, the Agent Client Protocol server of the Antigravity CLI. It is modelled on `pi-claude-code`: the loop, history, approvals and tool execution stay in pi.
|
|
4
|
+
|
|
5
|
+
## One request, end to end
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
pi -> streamAgy(model, context, options)
|
|
9
|
+
1 splitContext system prompt + current tools | history (up to the last assistant message) | latest input
|
|
10
|
+
2 hashChain sha256 chain over [system, tools, model, thought] then each message
|
|
11
|
+
3 pool.acquire reuse a pooled agy session only if it already holds exactly this prefix
|
|
12
|
+
otherwise session/new (+ system prompt and tool protocol as _meta append) and set model / thought_level
|
|
13
|
+
4 buildPrompt [resource pi://conversation.md (history, only for a fresh session)] + text(latest input) + images
|
|
14
|
+
5 session/prompt agy streams agent_thought_chunk / agent_message_chunk
|
|
15
|
+
6 Translator thought -> thinking block; message -> ToolCallStreamParser -> text blocks | toolCall
|
|
16
|
+
7 first complete <pi_tool_call> block -> toolCall block, session/cancel, stopReason toolUse
|
|
17
|
+
8 end_turn stopReason stop; usage mapped
|
|
18
|
+
9 pool.finish the session is kept after a clean answer AND after our own cancel at a tool call
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
pi then executes the tool and calls again with the result; the request that carries it continues the same agy session and sends only the tool result. Because the agy turn is cancelled at the tool call, nothing waits on pi: there is no parked turn, no deadline to extend and no limit on how long a tool may run.
|
|
22
|
+
|
|
23
|
+
## Modules
|
|
24
|
+
|
|
25
|
+
| Module | Role |
|
|
26
|
+
| --- | --- |
|
|
27
|
+
| `index.ts` | extension entry: provider, `/agy-bridge`, shutdown handling, one-time notices |
|
|
28
|
+
| `provider.ts` | `createProvider`: cheap `check`, `resolve`, `fetchModels`, `filterModels`, stream functions |
|
|
29
|
+
| `runtime.ts` | config, shared pool, compatibility report, availability hint, observed context windows |
|
|
30
|
+
| `stream.ts` | `streamAgy`: events, silence/total timeouts, cancel, usage, error mapping |
|
|
31
|
+
| `session-pool.ts` | the shared `agy acp` process and pooled sessions; reuse rule; TTL, LRU, idle exit; invalidation |
|
|
32
|
+
| `transcript.ts` | context split, history/latest serialisation, canonical messages, hash chain |
|
|
33
|
+
| `tool-protocol.ts` | protocol prompt + tool catalogue, streaming parser for `<pi_tool_call>` blocks |
|
|
34
|
+
| `acp/connection.ts` | one `agy acp` child: JSON-RPC, update routing, deny-all permissions, exit handling, exit safety net |
|
|
35
|
+
| `acp/jsonrpc.ts`, `process-tree.ts`, `frame-guard.ts` | NDJSON JSON-RPC session, identity-checked tree kill, frame limits (from pi-antigravity-bridge) |
|
|
36
|
+
| `acp/staging.ts` | carrier agent and private config root, content-addressed, atomic writes |
|
|
37
|
+
| `acp/command.ts` | find the agy executable with file-system lookups only |
|
|
38
|
+
| `model-catalog.ts` | models from agy's `model` / `thought_level` options, fallback list, limits, thinking map |
|
|
39
|
+
| `errors.ts` | error kinds and message phrasing the fallback classifiers understand |
|
|
40
|
+
| `state.ts` | `state.json`: the small health hint behind the cheap availability check |
|
|
41
|
+
| `atomic-write.ts` | temp-file + rename that retries the transient Windows errors and tolerates concurrent writers (staging, state hint) |
|
|
42
|
+
| `pi-context-hook.ts` | registration in pi-context's history-rewrite registry |
|
|
43
|
+
| `doctor.ts`, `trace.ts` | diagnostics |
|
|
44
|
+
| `compat/*`, `../compat/*` | feature negotiation, version matrix, free drift probe, SDK canary |
|
|
45
|
+
|
|
46
|
+
## Why a text tool protocol
|
|
47
|
+
|
|
48
|
+
ACP offers no way to hand a client-defined tool to the agent as a typed function. agy's own tools are removed (see below), and the model is told, in the system prompt, to end a reply with one `<pi_tool_call name="...">{json}</pi_tool_call>` block. The parser is chunk-invariant (tested against every split position and random chunkings), honours the closing tag only outside JSON strings, and turns invalid JSON into a recoverable `argumentsError` that includes what the model wrote. If a stray quote hides the closing tag, the first closing tag still decides at the end of the reply. A named self-closing tag is a complete call with no arguments; an unquoted name is accepted only when it looks like a tool name (a JSON-escaped example of the tag inside a reply stays text). A block inside a Markdown code fence is still a call: a text protocol cannot tell an example from a request, and pi's approval gates are the backstop. The parser buffers an unterminated block without a size cap (agy bounds the reply).
|
|
49
|
+
|
|
50
|
+
Tool output is untrusted data. It is rendered inside a code fence longer than any run of backticks it contains, with sanitised `name`/`id` attributes, so it cannot forge a result terminator, a `[user]` header or a second result, and it reaches the model byte for byte; the protocol also tells the model to treat it as data, not instructions. Tool schemas and arguments are serialised with a cycle- and BigInt-safe writer (a shared sub-object is kept, a true cycle becomes `"[Circular]"`).
|
|
51
|
+
|
|
52
|
+
## Session reuse, and when it is not safe
|
|
53
|
+
|
|
54
|
+
A pooled session is reused only when all of these hold:
|
|
55
|
+
|
|
56
|
+
1. the previous turn ended with plain text (`end_turn`) or at our own cancel of a tool call (measured: the session continues correctly and ~90% of the prompt is then served from agy's cache); not after an abort, stall, timeout, error, `length` or a cancel that agy ignored
|
|
57
|
+
2. the new context extends exactly what that session saw (prefix of the hash chain; the seed covers system prompt, tools, model and thought level, so a changed tool set or prompt replays)
|
|
58
|
+
3. the number of new messages equals the new input (`latestCount`)
|
|
59
|
+
4. the pi session id matches and nobody invalidated it
|
|
60
|
+
|
|
61
|
+
Invalidation comes from three places: pi-context's rewrite registry (`Symbol.for("claude-bridge:markRebuildHooks")`), pi-ai `cleanupSessionResources` (`/fresh`, session end), and the prefix check itself as the backstop. Replaying is always correct; reuse saves a `session/new` (about a second), the resent history and, above roughly 16k prompt tokens, most of the prompt cost: agy's cache works only inside a continuing session (three fresh sessions with an identical 22.9k prefix cached nothing). A session that ended at a tool call is kept for `PI_AGY_TOOL_TTL_MIN` (30 min) because pi may run a long tool; any retained session also keeps the process alive.
|
|
62
|
+
|
|
63
|
+
## Process model
|
|
64
|
+
|
|
65
|
+
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
|
+
|
|
67
|
+
## Isolation and the native-tool fence
|
|
68
|
+
|
|
69
|
+
- agy runs with `--gemini-dir <home>/gemini`: its conversations, logs and caches never touch `~/.gemini`, and your global MCP servers and settings are not loaded.
|
|
70
|
+
- A staged carrier agent (`--add-dir <home>/stage --agent pi-agy-fence-<hash>`) sets `tools: []`, `commandExecutionPolicy: off`, `inheritCustomizations: false` and `excludeDefaultComponents: true`. This removes agy's native tools and its built-in prompt scaffolding. Measured: the base prompt shrinks from 2431 to 716 tokens and the model no longer hears that its workspace is our private stage folder, to write artifacts to a brain directory or to build `file://` links, all of which conflict with pi owning the files. pi-antigravity-bridge cannot do this because its tool route is MCP, whose catalogue lives in those components. MCP built-ins are never listed under `tools:` (agy rejects them at start-up). Evidence: `evidence/cache-and-usage-semantics.md`.
|
|
71
|
+
- The ACP client capabilities declare no file or terminal access, and every `session/request_permission` is answered with a reject option.
|
|
72
|
+
- Sessions use an empty working directory so no project rules leak into agy's prompt (pi already sends its own).
|
|
73
|
+
|
|
74
|
+
## Start-up cost (measured)
|
|
75
|
+
|
|
76
|
+
pi waits for the provider's availability `check` while it starts. The first design ran the full handshake there and cost +282 ms on the full package set (+740 ms alone). `check` now only looks for the executable and reads `state.json`; the handshake happens on first use and records the outcome. Measured afterwards: +10 ms on the full set, ~+45 ms alone (module load). Evidence: `.plan/pi-agy-bridge/evidence/integration/`.
|
|
77
|
+
|
|
78
|
+
## Optional agy features degrade explicitly
|
|
79
|
+
|
|
80
|
+
`deriveFeatures` reads what agy advertises and each gap has a real fallback, not just a warning: no system-prompt hook means pi's prompt and the tool protocol are inlined at the top of the first prompt of each fresh session (inside the conversation resource when embedded context is available); no embedded context means history is inlined into the text block; no image support means attachments are skipped; no `session/close` means the pool never sends it and leaves sessions to process exit. Each is covered by a test against a fake agy lacking that feature.
|
|
81
|
+
|
|
82
|
+
## Usage accounting
|
|
83
|
+
|
|
84
|
+
Measured on agy 1.5.3 (`evidence/cache-and-usage-semantics.md`, pinned by `tests/usage.test.ts`): `inputTokens` is the uncached input, `cachedReadTokens` is separate, `outputTokens` already contains `thoughtTokens`, and `totalTokens == input + output + cachedRead`. pi's `Usage` has the same shape, so the mapping is a copy; the prompt size pi-context sees is `input + cacheRead + cacheWrite`.
|
|
85
|
+
|
|
86
|
+
## Errors
|
|
87
|
+
|
|
88
|
+
| Situation | Message starts with | Class (fallback-chains) |
|
|
89
|
+
| --- | --- | --- |
|
|
90
|
+
| cannot start agy | `agy spawn failed:` | retryable |
|
|
91
|
+
| agy died mid-turn | `agy exited with status N` | retryable |
|
|
92
|
+
| no output for the silence limit | `agy stalled for Ns with no output` | retryable |
|
|
93
|
+
| pi `timeoutMs` reached | `agy request timed out after Ns` | retryable |
|
|
94
|
+
| empty answer | `agy returned success but produced no model output:` | retryable |
|
|
95
|
+
| quota (agy sends it as a normal `end_turn` reply with no usage; detected and failed) | `agy quota exhausted:` + agy's text (keeps `Resets in ...`) | retryable, provider cap |
|
|
96
|
+
| not logged in | `agy authentication required (not logged in)` | non-retryable |
|
|
97
|
+
| context too large | `context_length_exceeded:` | non-retryable |
|
|
98
|
+
| agy too old / wrong protocol | `pi-agy-bridge is unavailable:` | retryable |
|
|
99
|
+
|
|
100
|
+
Own messages avoid bare three-digit numbers because the classifier reads them as HTTP statuses.
|
|
101
|
+
|
|
102
|
+
## Upgrade path
|
|
103
|
+
|
|
104
|
+
`compat/matrix.json` lists the tested agy versions, the minimum, known-bad versions and the ACP protocol. At handshake `deriveFeatures` negotiates optional features with fallbacks (system prompt inside the conversation resource, history inlined as text, no images). A protocol or minimum-version mismatch stops the provider with an actionable message; a newer untested version only warns once. `UPGRADING.md` is the runbook; the probe and the SDK canary cost no quota.
|
|
105
|
+
|
|
106
|
+
## Tests
|
|
107
|
+
|
|
108
|
+
`npm test` is hermetic: a fake `agy acp` (`tests/fixtures/fake-acp-server.mjs`, built on the recorded 1.5.3 handshake) drives the real connection, pool and stream code. `tests/ecosystem.test.ts` imports the real classifier of pi-fallback-chains and the real rewrite notifier of pi-context. `tests/live.test.ts` (opt-in) and `scripts/pi-rpc-check.mjs` exercise the real agy and a real pi.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 timmyjl12
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE.md
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Notice
|
|
2
|
+
|
|
3
|
+
pi-agy-bridge is an independent package. It reuses ideas and small, marked pieces of two MIT-licensed projects:
|
|
4
|
+
|
|
5
|
+
- **pi-claude-code** (Copyright (c) 2026 Armin Ronacher, MIT) — the architecture this package ports: pi keeps the conversation, approvals and tool execution; the vendor CLI is used only as the model; the pi-ai `createProvider` integration, event-stream mapping and warm-session reuse rules follow its design. Source: https://github.com/earendil-works/pi-claude-code
|
|
6
|
+
- **pi-antigravity-bridge** (Copyright (c) 2026 EstebanForge, MIT) — `src/acp/jsonrpc.ts`, `src/acp/process-tree.ts` and `src/acp/frame-guard.ts` are copied from that project (with the async/resource hardening made in the timmyjl12 fork at commit 8425baf). Source: https://github.com/EstebanForge/pi-extensions
|
|
7
|
+
|
|
8
|
+
This package talks to Google's official `agy acp` server. It does not read, store or forward Antigravity credentials and does not redirect agy's upstream endpoint.
|
package/README.md
CHANGED
|
@@ -1,3 +1,125 @@
|
|
|
1
|
-
#
|
|
1
|
+
# pi-agy-bridge
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use Google Antigravity models (Gemini, Claude, GPT-OSS) in [pi](https://github.com/earendil-works/pi) through the **official `agy acp` server**.
|
|
4
|
+
|
|
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
|
+
|
|
7
|
+
> Status: 0.1.1. The compatibility probe and 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
|
+
|
|
9
|
+
## Requirements
|
|
10
|
+
|
|
11
|
+
- pi 1.5 or newer, Node 22.19 or newer
|
|
12
|
+
- the Antigravity CLI `agy` 1.5.1 or newer, installed and logged in (run `agy` once and sign in)
|
|
13
|
+
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
```sh
|
|
17
|
+
pi install npm:@timmyjl12/pi-agy-bridge
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
or try it for one run: `pi -e npm:@timmyjl12/pi-agy-bridge`. To develop on it, install a local checkout instead
|
|
21
|
+
(`pi install /path/to/pi-agy-bridge`); keep only one of the two, or the provider registers twice.
|
|
22
|
+
|
|
23
|
+
Loading the extension starts nothing: no process, no network. The first request starts one shared `agy acp` process.
|
|
24
|
+
|
|
25
|
+
## Use
|
|
26
|
+
|
|
27
|
+
Models appear as `agy/<id>` in `/model`:
|
|
28
|
+
|
|
29
|
+
| Model | Thinking levels |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `agy/gemini-4-argon`, `agy/gemini-3.8-flash`, `agy/claude-opus-5-5`, `agy/claude-sonnet-5-5` | low, medium, high |
|
|
32
|
+
| `agy/gemini-4-hydrogen` | low, medium, high, xhigh (reported by agy 1.5.8) |
|
|
33
|
+
| `agy/gemini-pro-orchestrator-g1-pro` | no selectable reasoning level |
|
|
34
|
+
| `agy/gpt-oss-120b-medium` | fixed (medium) |
|
|
35
|
+
|
|
36
|
+
The list is what your agy reports, so new models appear without an update. pi's "off" thinking level is not offered because agy cannot switch thinking off.
|
|
37
|
+
|
|
38
|
+
| Command | What it does |
|
|
39
|
+
| --- | --- |
|
|
40
|
+
| `/agy-bridge status` | one line: agy version, process, pooled sessions |
|
|
41
|
+
| `/agy-bridge doctor` | handshake, compatibility with this package, features, models, process, hooks (no model call, no quota) |
|
|
42
|
+
| `/agy-bridge reset` | stop the agy process and forget pooled sessions |
|
|
43
|
+
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
Environment variables (all optional). Invalid values fall back to the default.
|
|
47
|
+
|
|
48
|
+
| Variable | Default | Meaning |
|
|
49
|
+
| --- | --- | --- |
|
|
50
|
+
| `PI_AGY_COMMAND` / `AGY_BIN` | `agy` | the executable; a bare name is searched on `PATH`, then in the installer's default folder |
|
|
51
|
+
| `PI_AGY_HOME` | `~/.pi/agent/pi-agy-bridge` | everything this package writes (see below) |
|
|
52
|
+
| `PI_AGY_SILENCE_SEC` | `120` | cancel a turn when agy sends nothing for this long (`0` disables) |
|
|
53
|
+
| `PI_AGY_SESSION_TTL_MIN` | `5` | close an unused pooled session after this long |
|
|
54
|
+
| `PI_AGY_TOOL_TTL_MIN` | `30` | same, for a session whose turn ended at a tool call (pi is running the tool) |
|
|
55
|
+
| `PI_AGY_MAX_SESSIONS` | `2` | reusable sessions kept between turns |
|
|
56
|
+
| `PI_AGY_IDLE_MIN` | `10` | stop the agy process after this long without activity and with no pooled session |
|
|
57
|
+
| `PI_AGY_CANCEL_GRACE_MS` | `3000` | wait this long for a cancel before giving up on a turn |
|
|
58
|
+
| `PI_AGY_MAX_REPLAY_KB` | `8192` | refuse to replay a conversation larger than this |
|
|
59
|
+
| `PI_AGY_CONTROL_TIMEOUT_SEC` | `60` | timeout for handshake and session calls |
|
|
60
|
+
| `PI_AGY_TRACE` | off | `1` appends diagnostics to `<home>/trace.log` |
|
|
61
|
+
|
|
62
|
+
pi's own request `timeoutMs`, when set, is honoured as a total deadline for the turn.
|
|
63
|
+
|
|
64
|
+
### What is written to disk
|
|
65
|
+
|
|
66
|
+
Only under `PI_AGY_HOME`: the staged carrier agent (`stage/`), agy's private config root (`gemini/`), an empty working directory (`work/`), a small health hint (`state.json`) and the optional trace. Nothing is written to your project, to `~/.gemini` or to any global agy setting, and your agy login is only *used*, never read or copied.
|
|
67
|
+
|
|
68
|
+
## Working with your other extensions
|
|
69
|
+
|
|
70
|
+
| Extension | Interaction |
|
|
71
|
+
| --- | --- |
|
|
72
|
+
| **pi-context** | Shake, boundary compaction and rollover rewrite history without `session_compact`. This package registers in pi-context's rewrite registry and drops the affected pooled session, so the next turn replays the rewritten history. `/fresh` (pi-ai `cleanupSessionResources`) does the same. Usage follows agy's measured semantics: `input` is uncached input, cache reads are separate, reasoning is part of output; zero cache reads are reported as zero. |
|
|
73
|
+
| **pi-fallback-chains** | Errors use phrases its classifier already knows (`agy stalled for 120s with no output`, `agy spawn failed:`, `agy exited with status N`, `quota` with agy's reset hint, `not logged in`, `context_length_exceeded`). Chains are keyed by model, so mirror your existing `antigravity/*` chains for `agy/*` when you switch (example below). |
|
|
74
|
+
| **pi-subagents, pi-advisor, pi-fusion, pi-btw** | All share one agy process; each pi session has its own agy session, so concurrent callers never see each other's text. A cancelled or crashed turn does not affect the others. |
|
|
75
|
+
| **pi-model-picker, pi-statusline** | Models carry names, context windows, a thinking map and zero list price. `check` answers from the file system and a small hint, so it never delays pi's start-up. |
|
|
76
|
+
| **pi-todo, pi-ask-user and other tool extensions** | Their tools are listed to the model in the tool protocol and run by pi like any other tool. |
|
|
77
|
+
| **pi-antigravity-bridge, pi-claude-code** | Independent: different provider id (`agy`), no shared state, private agy config root. Both can be loaded together. |
|
|
78
|
+
|
|
79
|
+
Example chain, mirrored from an `antigravity/*` chain:
|
|
80
|
+
|
|
81
|
+
```json
|
|
82
|
+
"agy/claude-opus-5-5": [
|
|
83
|
+
{ "model": "neuralwatt/kimi-k3-flex", "thinking_level": "max" },
|
|
84
|
+
{ "model": "agy/gemini-4-argon", "thinking_level": "high" },
|
|
85
|
+
{ "model": "agy/gemini-3.8-flash", "thinking_level": "high" }
|
|
86
|
+
]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Troubleshooting
|
|
90
|
+
|
|
91
|
+
| Symptom | Likely cause | Fix |
|
|
92
|
+
| --- | --- | --- |
|
|
93
|
+
| no `agy/*` models in `/model` | agy not found, or the last use found it logged out or too old (hidden for 5 minutes) | `agy` once to sign in, then `/agy-bridge doctor` (a successful run clears the hint) |
|
|
94
|
+
| `agy authentication required (not logged in)` | login expired | run `agy` and sign in |
|
|
95
|
+
| `agy quota exhausted: ... Resets in ...` | the plan's quota for that model is used up (agy delivers this as a normal reply with no tokens; the bridge turns it into an error so fallback chains rotate) | use another model; the reset time is in the message |
|
|
96
|
+
| `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 |
|
|
97
|
+
| `agy exited with status N` | the agy process died | retry (a new process starts); `/agy-bridge doctor` shows agy's last stderr |
|
|
98
|
+
| `pi-agy-bridge is unavailable: agy ... below the minimum` | agy too old | `agy update` |
|
|
99
|
+
| a notice that agy is `newer-untested` | agy is newer than the tested matrix | it keeps working; see `UPGRADING.md` |
|
|
100
|
+
|
|
101
|
+
## Known limits
|
|
102
|
+
|
|
103
|
+
- agy's own tools (shell, file editing) are disabled on purpose: pi runs all tools. The model is told about pi's tools through a text protocol, so tool calls are as reliable as the model's JSON.
|
|
104
|
+
- `temperature`, `maxTokens` and other sampling options cannot be sent through ACP and are ignored.
|
|
105
|
+
- A tool-call block the model writes inside a Markdown code fence is still treated as a call (a text protocol cannot tell an example from a request); your approval settings in pi remain the safeguard. Tool output is shown to the model inside a code fence it cannot close and marked as data, not instructions.
|
|
106
|
+
- agy does not report context windows, so every model defaults to 1M tokens (set deliberately; a window agy reports through `usage_update.size` replaces it). If a model's real limit is lower, agy answers `context_length_exceeded`, pi compacts and retries, and that one request is the cost.
|
|
107
|
+
- A session is kept across tool calls: after pi runs a tool, the next request continues the same agy session and sends only the tool result (a session waiting for a tool is kept for `PI_AGY_TOOL_TTL_MIN`, default 30 minutes). If the session was dropped meanwhile (TTL, `/fresh`, a pi-context rewrite, a changed system prompt or tool set), history is replayed into a new session (about one extra second).
|
|
108
|
+
- agy's prompt cache applies only to a continuing session and only above roughly 16k prompt tokens, so short conversations show no cache reads; real coding sessions cross that quickly.
|
|
109
|
+
- The first request of a pi session starts the agy process (about one second). A running `agy acp` uses roughly 170 MB (measured idle on Windows, plus a `conhost` child) and stops after `PI_AGY_IDLE_MIN` minutes without activity.
|
|
110
|
+
|
|
111
|
+
## Upgrading agy or the SDK
|
|
112
|
+
|
|
113
|
+
`UPGRADING.md` is the runbook: a free drift probe (`npm run compat:probe`), an SDK canary (`npm run compat:sdk`), and a compatibility matrix in `compat/matrix.json`.
|
|
114
|
+
|
|
115
|
+
## Development
|
|
116
|
+
|
|
117
|
+
```powershell
|
|
118
|
+
npm install
|
|
119
|
+
npm run check # tsc --noEmit
|
|
120
|
+
npm test # hermetic: fake agy, real sibling classifiers, no quota
|
|
121
|
+
$env:PI_AGY_LIVE = "1"; node --test tests/live.test.ts # real agy, a few short Flash turns
|
|
122
|
+
node scripts/pi-rpc-check.mjs --surface # real pi + your packages (machine-specific paths)
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
See `ARCHITECTURE.md` for the design and `NOTICE.md` for credits (pi-claude-code and pi-antigravity-bridge, both MIT).
|
package/UPGRADING.md
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
# Upgrading pi-agy-bridge (agy / SDK drift runbook)
|
|
2
|
+
|
|
3
|
+
`agy` ships often (three patch releases in one week of November 2026) and the
|
|
4
|
+
`google-antigravity` SDK ships about once a week. None of this needs a model
|
|
5
|
+
call or quota: the probes are free.
|
|
6
|
+
|
|
7
|
+
## Triggers
|
|
8
|
+
|
|
9
|
+
| Signal | What it means | Go to |
|
|
10
|
+
| --- | --- | --- |
|
|
11
|
+
| `/agy-bridge doctor`, or the one-time notice shown at the first request, says `untested` / `newer-untested` | a newer agy is installed than the matrix tested | §1, then §3 |
|
|
12
|
+
| doctor says `below-minimum`, `known-bad`, `protocol` or `not-agy` | the provider refused to start (it names the fix) | §1 → §4 |
|
|
13
|
+
| `npm run compat:probe` exits 1 or 2 | agy's flags/capabilities/models moved | §3 |
|
|
14
|
+
| `uv run --project compat/sdk-canary python compat/sdk-canary/canary.py --latest` exits 1 or 2 | the SDK harness contract moved | §5 |
|
|
15
|
+
| a contract test or replay fixture fails after an agy update | an ACP exchange changed shape | §4 |
|
|
16
|
+
| Windows/uv problems, missing `agy` | environment, not drift | §6 |
|
|
17
|
+
|
|
18
|
+
`npm run compat:probe` exit codes: `0` identical, `1` additive only (or no
|
|
19
|
+
baseline recorded yet), `2` breaking, `3` the probe could not run. The SDK
|
|
20
|
+
canary uses the same codes.
|
|
21
|
+
|
|
22
|
+
## 1. Free drift probe (no prompt, no quota)
|
|
23
|
+
|
|
24
|
+
```powershell
|
|
25
|
+
npm run compat:probe # compare installed agy with compat/baselines/agy-<version>.json
|
|
26
|
+
npm run compat:probe -- --json # machine-readable (status, breaking[], additive[])
|
|
27
|
+
npm run compat:probe -- --record # write compat/baselines/agy-<version>.json
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
> **PowerShell:** it consumes the first `--`, so `npm run compat:probe -- --record` silently runs a plain check (and `-- --help` goes to npm). Quote the separator, `npm run compat:probe "--" --record`, or call the script directly: `node compat/probe-cli.ts --record`. The same applies to every `npm run compat:... -- <flag>` in this file; for the SDK canary use `uv run --project compat/sdk-canary python compat/sdk-canary/canary.py --record`.
|
|
31
|
+
|
|
32
|
+
The probe uses a temp cwd and `agy acp --gemini-dir <temp>`, so `~/.gemini` is
|
|
33
|
+
never written and your login is only used, not copied. It kills only the process
|
|
34
|
+
it spawned.
|
|
35
|
+
|
|
36
|
+
## 2. Decide what the drift is
|
|
37
|
+
|
|
38
|
+
| Probe result | Meaning | Action |
|
|
39
|
+
| --- | --- | --- |
|
|
40
|
+
| `identical` | nothing changed | done |
|
|
41
|
+
| `additive` | new flags / capabilities / models / config values | review the list (for new models, also check what a real session accepts, see `tests/model-catalog.test.ts`), `-- --record`, add the version to `compat/matrix.json` (§4), commit both |
|
|
42
|
+
| `breaking` (removed flag, capability, config option or value, model id, auth method; changed protocolVersion or agent name) | the adapter may now be wrong | **stop**. Read `agy changelog`, adjust the adapter, add/re-record the replay fixture, run `node --test tests/features.test.ts tests/probe.test.ts`, and only then re-record baselines |
|
|
43
|
+
| `no baseline` | first run on a new major/minor | `-- --record` after reviewing the printed summary |
|
|
44
|
+
|
|
45
|
+
Never re-record a baseline to make a red probe green: it is the reviewed
|
|
46
|
+
"known good", not a snapshot of whatever happens to be installed.
|
|
47
|
+
|
|
48
|
+
## 3. Tests after an agy change
|
|
49
|
+
|
|
50
|
+
```powershell
|
|
51
|
+
node --test tests/features.test.ts tests/probe.test.ts
|
|
52
|
+
npm test # whole package (needs the other suites to exist)
|
|
53
|
+
npm run check # tsc --noEmit
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
`features.test.ts` pins feature negotiation against the recorded 1.5.3
|
|
57
|
+
`initialize` result and its mutations. `model-catalog.test.ts` covers the
|
|
58
|
+
`session/new` catalog captured from agy 1.5.8, including per-model `xhigh` and
|
|
59
|
+
models with no selectable reasoning level. `probe.test.ts` pins parsers, diff
|
|
60
|
+
classification, baseline selection and CLI exit codes through injected
|
|
61
|
+
fixtures; these tests never spawn agy.
|
|
62
|
+
|
|
63
|
+
## 4. Add a version to the matrix
|
|
64
|
+
|
|
65
|
+
Edit `compat/matrix.json` (JSON, no rebuild needed):
|
|
66
|
+
|
|
67
|
+
- `agy.tested`: add the version once its probe diff is reviewed (keep the list
|
|
68
|
+
short — the last two or three releases).
|
|
69
|
+
- `agy.minimum`: raise only when a lower version provably can no longer work
|
|
70
|
+
(record why in the commit message; the refusal message is user-facing).
|
|
71
|
+
- `agy.knownBad`: `"1.5.2"` or `{ "version": "1.5.2", "reason": "ACP shutdown hang" }`.
|
|
72
|
+
- `acp.protocolVersion`: bump together with the adapter that speaks it.
|
|
73
|
+
- `sdk.tested`: the SDK releases whose fingerprint is committed.
|
|
74
|
+
|
|
75
|
+
## 5. SDK contract canary
|
|
76
|
+
|
|
77
|
+
```powershell
|
|
78
|
+
uv run --project compat/sdk-canary python compat/sdk-canary/canary.py
|
|
79
|
+
uv run --project compat/sdk-canary python compat/sdk-canary/canary.py --record
|
|
80
|
+
uv run --project compat/sdk-canary python compat/sdk-canary/canary.py --latest
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
First run creates `compat/sdk-canary/.venv` (the pinned `google-antigravity`
|
|
84
|
+
version is in `pyproject.toml`; `uv.lock` is committed and `.venv` is gitignored).
|
|
85
|
+
As of 2026-11-13, PyPI latest and the recorded SDK baseline are both `0.1.23`, so
|
|
86
|
+
there is no newer SDK to adopt. `--latest` needs network (PyPI + uv);
|
|
87
|
+
`--record` is deterministic. Additive: re-record, add to `sdk.tested`. Breaking
|
|
88
|
+
(removed/renumbered messages, fields or enums): the harness family behind `agy`
|
|
89
|
+
changed — check the affected call in the adapter, then re-record after review.
|
|
90
|
+
|
|
91
|
+
## 6. Rollback
|
|
92
|
+
|
|
93
|
+
- **agy**: reinstall the previous release and pin it (keep the old version in
|
|
94
|
+
`agy.tested`); the provider refuses only below `agy.minimum` or on a protocol
|
|
95
|
+
mismatch, so a tested older release keeps working.
|
|
96
|
+
- **package**: `npm i -g @timmyjl12/pi-agy-bridge@<previous>` (or `pi` extension
|
|
97
|
+
pin) and restore the previous `compat/baselines/*.json` and
|
|
98
|
+
`compat/matrix.json` from git — never edit them in place to dodge a failure.
|
|
99
|
+
- **fixtures**: replay fixtures are recorded artifacts; revert them with the code
|
|
100
|
+
that expects them.
|
|
101
|
+
|
|
102
|
+
## 7. Ground rules (non-negotiable)
|
|
103
|
+
|
|
104
|
+
- Never read, store, forward or replace Antigravity credentials, and never
|
|
105
|
+
override agy's endpoint or user agent. The bridge is a client, not a proxy.
|
|
106
|
+
- Never change the user's `~/.gemini` (`settings.json`, `mcp_config.json`,
|
|
107
|
+
agents, login). Per-session state travels in ACP parameters and a private
|
|
108
|
+
staged directory.
|
|
109
|
+
- Kill only processes the bridge spawned (exact PID, tree kill); never by name.
|
|
110
|
+
- Re-recording is one documented command whose diff is reviewed before the
|
|
111
|
+
baseline is committed.
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
{
|
|
2
|
+
"schema": 1,
|
|
3
|
+
"agyVersion": "1.5.3",
|
|
4
|
+
"collectedAt": "2026-11-07T17:14:23.550Z",
|
|
5
|
+
"helpFlags": [
|
|
6
|
+
"--add-dir",
|
|
7
|
+
"--agent",
|
|
8
|
+
"--continue",
|
|
9
|
+
"--conversation",
|
|
10
|
+
"--dangerously-skip-permissions",
|
|
11
|
+
"--disable-slash-commands",
|
|
12
|
+
"--effort",
|
|
13
|
+
"--input-format",
|
|
14
|
+
"--json-schema",
|
|
15
|
+
"--log-file",
|
|
16
|
+
"--mode",
|
|
17
|
+
"--model",
|
|
18
|
+
"--new-project",
|
|
19
|
+
"--output-format",
|
|
20
|
+
"--print",
|
|
21
|
+
"--print-timeout",
|
|
22
|
+
"--project",
|
|
23
|
+
"--prompt",
|
|
24
|
+
"--prompt-interactive",
|
|
25
|
+
"--remote-agent",
|
|
26
|
+
"--remote-control",
|
|
27
|
+
"--sandbox",
|
|
28
|
+
"--settings",
|
|
29
|
+
"-c",
|
|
30
|
+
"-i",
|
|
31
|
+
"-p"
|
|
32
|
+
],
|
|
33
|
+
"acpHelpFlags": [
|
|
34
|
+
"--add-dir",
|
|
35
|
+
"--agent",
|
|
36
|
+
"--app-data-dir",
|
|
37
|
+
"--app_data_dir",
|
|
38
|
+
"--cli_dir_name",
|
|
39
|
+
"--cli_log_file",
|
|
40
|
+
"--cloud_code_endpoint",
|
|
41
|
+
"--dangerously-skip-permissions",
|
|
42
|
+
"--disable-telemetry",
|
|
43
|
+
"--disable_telemetry",
|
|
44
|
+
"--gemini-dir",
|
|
45
|
+
"--gemini_dir",
|
|
46
|
+
"--help",
|
|
47
|
+
"--ide-mcp-port",
|
|
48
|
+
"--ide_mcp_port",
|
|
49
|
+
"--include-default-customizations",
|
|
50
|
+
"--is_google3_workspace",
|
|
51
|
+
"--is_google_internal",
|
|
52
|
+
"--log-file",
|
|
53
|
+
"--login",
|
|
54
|
+
"--override_user_agent_name",
|
|
55
|
+
"--process-per-session",
|
|
56
|
+
"--sandbox",
|
|
57
|
+
"--stdio",
|
|
58
|
+
"--use_stubby_auth",
|
|
59
|
+
"--worker",
|
|
60
|
+
"-h"
|
|
61
|
+
],
|
|
62
|
+
"models": [
|
|
63
|
+
{
|
|
64
|
+
"id": "claude-opus-5-5-high",
|
|
65
|
+
"label": "Claude Opus 5.5 (High)"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "claude-opus-5-5-low",
|
|
69
|
+
"label": "Claude Opus 5.5 (Low)"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"id": "claude-opus-5-5-medium",
|
|
73
|
+
"label": "Claude Opus 5.5 (Medium)"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"id": "claude-sonnet-5-5-high",
|
|
77
|
+
"label": "Claude Sonnet 5.5 (High)"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"id": "claude-sonnet-5-5-low",
|
|
81
|
+
"label": "Claude Sonnet 5.5 (Low)"
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
"id": "claude-sonnet-5-5-medium",
|
|
85
|
+
"label": "Claude Sonnet 5.5 (Medium)"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "gemini-3.8-flash-high",
|
|
89
|
+
"label": "Gemini 3.8 Flash (High)"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "gemini-3.8-flash-low",
|
|
93
|
+
"label": "Gemini 3.8 Flash (Low)"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
"id": "gemini-3.8-flash-medium",
|
|
97
|
+
"label": "Gemini 3.8 Flash (Medium)"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"id": "gemini-4-argon-high",
|
|
101
|
+
"label": "Gemini 4 Argon (High)"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"id": "gemini-4-argon-low",
|
|
105
|
+
"label": "Gemini 4 Argon (Low)"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "gemini-4-argon-medium",
|
|
109
|
+
"label": "Gemini 4 Argon (Medium)"
|
|
110
|
+
},
|
|
111
|
+
{
|
|
112
|
+
"id": "gpt-oss-120b-medium",
|
|
113
|
+
"label": "GPT-OSS 120B (Medium)"
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"initialize": {
|
|
117
|
+
"protocolVersion": 1,
|
|
118
|
+
"agentName": "Antigravity ACP Server",
|
|
119
|
+
"agentVersion": "1.5.3",
|
|
120
|
+
"capabilities": {
|
|
121
|
+
"_meta.antigravity.systemPrompt.append": true,
|
|
122
|
+
"auth.logout": true,
|
|
123
|
+
"loadSession": true,
|
|
124
|
+
"load_session": true,
|
|
125
|
+
"promptCapabilities.audio": false,
|
|
126
|
+
"promptCapabilities.embeddedContext": true,
|
|
127
|
+
"promptCapabilities.image": true,
|
|
128
|
+
"sessionCapabilities.additionalDirectories": true,
|
|
129
|
+
"sessionCapabilities.close": true,
|
|
130
|
+
"sessionCapabilities.list": true,
|
|
131
|
+
"sessionCapabilities.load": true,
|
|
132
|
+
"sessionCapabilities.resume": true,
|
|
133
|
+
"session_capabilities.additionalDirectories": true,
|
|
134
|
+
"session_capabilities.close": true,
|
|
135
|
+
"session_capabilities.list": true,
|
|
136
|
+
"session_capabilities.load": true,
|
|
137
|
+
"session_capabilities.resume": true
|
|
138
|
+
},
|
|
139
|
+
"authMethodIds": [
|
|
140
|
+
"agent-platform",
|
|
141
|
+
"gemini-api-key",
|
|
142
|
+
"oauth-business",
|
|
143
|
+
"oauth-personal"
|
|
144
|
+
]
|
|
145
|
+
},
|
|
146
|
+
"session": {
|
|
147
|
+
"configOptions": [
|
|
148
|
+
{
|
|
149
|
+
"id": "mode",
|
|
150
|
+
"type": "select",
|
|
151
|
+
"values": [
|
|
152
|
+
"accept-edits",
|
|
153
|
+
"default",
|
|
154
|
+
"plan"
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"id": "model",
|
|
159
|
+
"type": "select",
|
|
160
|
+
"values": [
|
|
161
|
+
"claude-opus-5-5",
|
|
162
|
+
"claude-sonnet-5-5",
|
|
163
|
+
"gemini-3.8-flash",
|
|
164
|
+
"gemini-4-argon",
|
|
165
|
+
"gpt-oss-120b-medium"
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
"id": "thought_level",
|
|
170
|
+
"type": "select",
|
|
171
|
+
"values": [
|
|
172
|
+
"high",
|
|
173
|
+
"low",
|
|
174
|
+
"medium"
|
|
175
|
+
]
|
|
176
|
+
}
|
|
177
|
+
],
|
|
178
|
+
"modeIds": [
|
|
179
|
+
"accept-edits",
|
|
180
|
+
"default",
|
|
181
|
+
"plan"
|
|
182
|
+
],
|
|
183
|
+
"modelIds": [
|
|
184
|
+
"claude-opus-5-5-high",
|
|
185
|
+
"claude-opus-5-5-low",
|
|
186
|
+
"claude-opus-5-5-medium",
|
|
187
|
+
"claude-sonnet-5-5-high",
|
|
188
|
+
"claude-sonnet-5-5-low",
|
|
189
|
+
"claude-sonnet-5-5-medium",
|
|
190
|
+
"gemini-3.8-flash-high",
|
|
191
|
+
"gemini-3.8-flash-low",
|
|
192
|
+
"gemini-3.8-flash-medium",
|
|
193
|
+
"gemini-4-argon-high",
|
|
194
|
+
"gemini-4-argon-low",
|
|
195
|
+
"gemini-4-argon-medium",
|
|
196
|
+
"gpt-oss-120b-medium"
|
|
197
|
+
],
|
|
198
|
+
"metaKeys": [
|
|
199
|
+
"antigravity"
|
|
200
|
+
]
|
|
201
|
+
}
|
|
202
|
+
}
|