omp-antigravity-acp-provider 0.1.44 → 0.2.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.
Files changed (78) hide show
  1. package/AGENT_INSTALL.md +1 -1
  2. package/README.md +90 -25
  3. package/THIRD_PARTY_LICENSES.txt +70 -39
  4. package/THIRD_PARTY_NOTICES.md +12 -1
  5. package/extension/acp-compaction.ts +14 -2
  6. package/extension/acp-errors.ts +48 -13
  7. package/extension/adapter-config.ts +124 -7
  8. package/extension/ambient.d.ts +23 -0
  9. package/extension/assets/src/acp/supervisor.mjs +4 -1
  10. package/extension/assets/zip-archive.mjs +10839 -0
  11. package/extension/auth-sync.ts +333 -62
  12. package/extension/catalog-store.ts +52 -26
  13. package/extension/commands.ts +66 -171
  14. package/extension/context-settings.ts +2 -2
  15. package/extension/index.ts +520 -123
  16. package/extension/model-catalog.ts +38 -4
  17. package/extension/omp-context.ts +14 -3
  18. package/extension/omp-session-lifecycle.ts +13 -2
  19. package/extension/omp-session-source.ts +16 -5
  20. package/extension/quota-usage.ts +2 -1
  21. package/extension/runtime/acp/antigravity.ts +185 -0
  22. package/extension/runtime/acp/bounded-stream.ts +225 -0
  23. package/extension/runtime/acp/connection.ts +519 -0
  24. package/extension/runtime/acp/credential-storage.ts +113 -0
  25. package/extension/runtime/acp/errors.ts +54 -0
  26. package/extension/runtime/acp/events.ts +66 -0
  27. package/extension/runtime/acp/headless-oauth.ts +209 -0
  28. package/extension/runtime/acp/prompt-watchdog.ts +80 -0
  29. package/extension/runtime/acp/proxy.ts +54 -0
  30. package/extension/runtime/acp/runtime-manifest.ts +185 -0
  31. package/extension/runtime/acp/session-state.ts +76 -0
  32. package/extension/runtime/asset.ts +24 -0
  33. package/extension/runtime/binding.ts +145 -0
  34. package/extension/runtime/config.ts +119 -0
  35. package/extension/runtime/constants.ts +18 -0
  36. package/extension/runtime/history-seed.ts +227 -0
  37. package/extension/runtime/image-history.ts +233 -0
  38. package/extension/runtime/index.ts +23 -0
  39. package/extension/runtime/launch.ts +545 -0
  40. package/extension/runtime/managed.ts +873 -0
  41. package/extension/runtime/models.ts +199 -0
  42. package/extension/runtime/process.ts +281 -0
  43. package/extension/{context-transfer.ts → runtime/prompt.ts} +272 -119
  44. package/extension/runtime/provider.ts +177 -0
  45. package/extension/runtime/routing.ts +47 -0
  46. package/extension/runtime/runtime-manifest.json +205 -0
  47. package/extension/runtime/runtime.ts +2234 -0
  48. package/extension/runtime/status.ts +87 -0
  49. package/extension/runtime/stream/json.ts +17 -0
  50. package/extension/runtime/stream/pi-events.ts +142 -0
  51. package/extension/runtime/stream/usage.ts +37 -0
  52. package/extension/runtime/supervisor.mjs +113 -0
  53. package/extension/{tool-args.ts → runtime/tools/args.ts} +1 -1
  54. package/extension/runtime/tools/bridge.ts +343 -0
  55. package/extension/{tool-relay.ts → runtime/tools/relay.ts} +10 -5
  56. package/extension/runtime/tools/schema.ts +256 -0
  57. package/extension/runtime/zip-archive.ts +1 -0
  58. package/extension/runtime.d.mts +1 -0
  59. package/extension/runtime.mjs +20242 -35753
  60. package/extension/secret-service.ts +113 -0
  61. package/extension/selectors.ts +8 -7
  62. package/extension/session-cleanup.ts +49 -2
  63. package/extension/session-store.ts +8 -8
  64. package/extension/tier-connection.ts +283 -60
  65. package/extension/tool-order.ts +4 -2
  66. package/extension/tool-policy.ts +2 -2
  67. package/extension/tool-relay-protocol.d.mts +5 -0
  68. package/extension/tool-routing.ts +141 -42
  69. package/extension/transcript-routing.ts +16 -3
  70. package/extension/turn-cancellation.ts +1 -1
  71. package/extension/usage-accounting.ts +6 -2
  72. package/extension/usage-db.ts +135 -42
  73. package/extension/usage.ts +2 -2
  74. package/licenses/{pi-ai-1.3.0.txt → pi-mit.txt} +1 -2
  75. package/package.json +16 -10
  76. package/extension/acp-runtime-source.ts +0 -310
  77. package/extension/history-fingerprint.ts +0 -80
  78. package/extension/structured-fingerprint.ts +0 -63
package/AGENT_INSTALL.md CHANGED
@@ -15,7 +15,7 @@ Steps:
15
15
  2. Run `omp plugin list --json` and search `npm[].name` and `marketplace[].id` for `antigravity-acp-provider`. If one exists, stop and report it instead of installing a second copy.
16
16
  3. Install with `omp plugin install npm:omp-antigravity-acp-provider`. For the marketplace variant, run `omp plugin marketplace add SenCha930511/omp-antigravity-acp-provider` first, then `omp plugin install omp-antigravity-acp-provider@sencha-plugins`.
17
17
  4. Run `omp plugin list --json` again and confirm exactly one adapter is present. Record its version.
18
- 5. Run `omp models antigravity-acp --json`. Cached listing must not start the ACP server. An empty catalog before sign-in is acceptable; report it instead of retrying in a loop.
18
+ 5. Run `omp models antigravity-acp --json`. Offline/cached listing must not start the ACP server. Before discovery, the built-in Gemini, Hydrogen and known partner-model fallback entries may be listed; neither those entries nor an empty catalog proves a live login. Report any failure instead of retrying in a loop.
19
19
  6. Tell the user to restart OMP, then run `/login` → "Google Antigravity (ACP)" and `/antigravity-acp refresh` inside OMP. Do not perform these steps yourself.
20
20
 
21
21
  Notes:
package/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  [![license](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
6
6
  [![node](https://img.shields.io/badge/node-%E2%89%A522.19-339933?logo=node.js&logoColor=white)](package.json)
7
7
  [![OMP marketplace](https://img.shields.io/badge/OMP-marketplace-7c3aed)](https://github.com/SenCha930511/omp-antigravity-acp-provider)
8
- [![ACP runtime](https://img.shields.io/badge/ACP%20runtime-%E2%89%A51.4.1-4285F4)](https://github.com/SenCha930511/omp-antigravity-acp-provider)
8
+ [![ACP runtime](https://img.shields.io/badge/ACP%20runtime-%E2%89%A51.3.0-4285F4)](https://github.com/SenCha930511/omp-antigravity-acp-provider)
9
9
  [![GitHub stars](https://img.shields.io/github/stars/SenCha930511/omp-antigravity-acp-provider)](https://github.com/SenCha930511/omp-antigravity-acp-provider/stargazers)
10
10
 
11
11
  Google Antigravity's official ACP server, adapted for **Oh My Pi (OMP)**.
@@ -18,18 +18,39 @@ This is an independent adaptation, **NOT** an official Google or OMP integration
18
18
 
19
19
  - All server-advertised models, including Claude, GPT-OSS and future IDs when the ACP endpoint advertises them.
20
20
  - CLI-first selection. When a usable `agy` CLI is on `PATH`, the adapter launches it through a generated `AGY_ACP_BIN` wrapper. The managed runtime is the fallback. An explicit `AGY_ACP_BIN` always wins.
21
- - Per-model thinking levels, exposed only when the server confirms them.
21
+ - Per-model thinking levels, exposed only when the server confirms them. The offline catalog includes Gemini 4 Hydrogen through `xhigh` and known partner models; the first inference after an empty cache attempts real server discovery.
22
22
  - OMP tools through an authenticated loopback MCP bridge.
23
- - Optional `disabled` native-tool mode for strict OMP-only sessions.
24
- - Lazy ACP startup and warm session reuse.
23
+ - ACP-native tools are disabled by default for strict OMP-only sessions; `/antigravity-acp native-tools prefer` restores them.
24
+ - Standby ACP initialization coordinated with discovery, plus warm session reuse and guarded oldest-image history continuity.
25
25
  - `/login` plus `/antigravity-acp` account, usage and cleanup commands.
26
- - API-equivalent cost estimates from a model-ID rate table, not subscription billing. ACP model records do not include price fields.
26
+ - API-equivalent cost estimates from a model-ID rate table, not subscription billing. Native response usage takes precedence, with a read-only SQLite fallback for completed model steps when no supplemental usage query runs.
27
27
  - Long-running OMP tools survive the MCP request window through a relay. The model resumes the same result with `pi_omp_await_result`; the control tool is a separate MCP server and never appears in OMP's tool list.
28
28
  - Permission requests are tied to the originating session, turn and tool call. Forged, conflicting or previous-turn identities fail closed, while normal requests still use OMP's human review.
29
29
  - The MCP `tools/list` reflects the current OMP tool set. The offline wire test covers add, remove and restore on one warm ACP session.
30
30
  - Tool-argument hardening on the MCP bridge. Habitual alias mistakes such as `path` for `file_path` are corrected only when the tool schema makes the mapping unambiguous, and rejected calls return the missing required keys plus the tool's expected signature instead of a bare schema failure.
31
31
  - Loopback traffic always bypasses proxied environments. When `HTTP(S)_PROXY` or `ALL_PROXY` is set for the ACP child process, the adapter appends `localhost`, `127.0.0.1` and `::1` to `NO_PROXY`/`no_proxy` so the loopback MCP bridge is never routed through an external proxy.
32
32
  - OAuth material is redacted from failure text. Authorization URLs, sensitive query values, `Bearer` tokens and OAuth pairs such as `code_challenge` or `access_token` are masked before messages reach OMP, while ordinary diagnostics like `exit code=1` stay intact.
33
+ - Fresh-login and logout synchronization bounds credential-disable suppression and clears only the current login attempt's state, so a failed or cancelled login cannot suppress a later real logout.
34
+
35
+ ## Supported platforms
36
+
37
+ The adapter is a Node.js OMP plugin. The table lists the configuration each platform accepts and the validation actually performed, not a promise that every path has been run on every system.
38
+
39
+ | Platform | Configuration | Validation |
40
+ | --- | --- | --- |
41
+ | macOS on arm64 | `agy` on `PATH`, an explicit `AGY_ACP_BIN`, or the managed runtime in `~/.local/opt/agy-acp/`. Keychain lookups use `/usr/bin/security`. | Live: Gemini inference, MCP tools, steering, cancellation and continuation, local plugin linking. |
42
+ | Linux | `agy` on `PATH`, an explicit `AGY_ACP_BIN`, or the managed runtime. Secret Service items are inspected and removed with `secret-tool` from libsecret. | Offline tests with synthetic fixtures. No live Linux run in this environment. |
43
+ | Windows | `agy.exe` on `PATH`, an explicit `AGY_ACP_BIN` pointing at your ACP command, or the generated `.cmd` wrapper. | Configuration only. The supervisor wrapper and the full managed-runtime download have not been run on Windows. |
44
+
45
+ ### Credentials and keyrings
46
+
47
+ Google browser consent works on every platform. The ACP server stores the result in its own credential store, and the adapter checks the same store for login readiness and logout.
48
+
49
+ - **macOS.** The adapter checks the login keychain item `gemini` / `antigravity-acp` with `/usr/bin/security`. The attribute-only lookup does not prompt for the keychain password. Logout removes that item. Keychain-stored tokens expose no account email, so `account` shows the address only when a token file exists.
50
+ - **Linux.** Secret Service holds the same item as `service=gemini`, `username=antigravity`. The adapter needs `secret-tool` from libsecret to detect or delete it; install it from your distribution's libsecret package. A confirmed missing item is distinct from an unavailable or locked backend. Without `secret-tool`, the backend's state cannot be confirmed. Login readiness falls back to the token file under `~/.gemini/antigravity-acp/` and to `GEMINI_API_KEY`. A login that exists only in Secret Service is not detected in that state, while token-file and API-key inference still work.
51
+ - **Windows.** There is no keyring integration. The token file and `GEMINI_API_KEY` are supported credential sources.
52
+
53
+ On Windows, CLI discovery searches for `agy` and `agy.exe`. Set `AGY_ACP_BIN` explicitly for an npm-generated `.cmd` shim. The `.cmd` supervisor wrapper has not been exercised on Windows.
33
54
 
34
55
  ## Install: for human
35
56
 
@@ -39,7 +60,7 @@ Follow these steps in order. The whole flow takes a few minutes, plus Google's s
39
60
 
40
61
  - OMP is installed and `omp --version` works.
41
62
  - Node.js 22.19 or newer (`node --version`) and npm are on `PATH`; the marketplace launcher uses them on first load.
42
- - A supported platform: macOS, Linux or Windows. Live testing has been on macOS.
63
+ - A supported platform: macOS, Linux or Windows. [Supported platforms](#supported-platforms) lists what each one accepts and what has been validated.
43
64
  - Internet access when no usable `agy` CLI is installed. The managed fallback downloads separately (about 383 MiB on macOS) into `~/.local/opt/agy-acp/`.
44
65
 
45
66
  ### 2. Install exactly one adapter
@@ -57,6 +78,8 @@ Or install the published npm package directly:
57
78
  omp plugin install npm:omp-antigravity-acp-provider
58
79
  ```
59
80
 
81
+ To pin this version, use `omp plugin install npm:omp-antigravity-acp-provider@0.2.4`.
82
+
60
83
  Do not install both. Remove or disable any older Antigravity ACP adapter first.
61
84
 
62
85
  ### 3. Restart OMP
@@ -65,7 +88,7 @@ The provider registers at startup. Restart every running OMP process so they agr
65
88
 
66
89
  ### 4. Sign in
67
90
 
68
- Run `/login`, choose **Google Antigravity (ACP)**, and complete Google's consent in the browser. On a headless machine the provider relays the callback URL.
91
+ Run `/login`, choose **Google Antigravity (ACP)**, and complete Google's consent in the browser. On a headless machine the provider relays the callback URL. Alternatively, add the **Antigravity Gemini API key** method in `/login` and paste a Gemini API key, or export `GEMINI_API_KEY` before starting OMP. On Linux, keyring requirements are covered under [Supported platforms](#supported-platforms).
69
92
 
70
93
  ### 5. Load models and pick one
71
94
 
@@ -84,6 +107,14 @@ Run `/login`, choose **Google Antigravity (ACP)**, and complete Google's consent
84
107
 
85
108
  This shows the runtime, native-tool mode and usage state. Send a short prompt to confirm inference.
86
109
 
110
+ ### Upgrade or remove
111
+
112
+ ```sh
113
+ omp plugin upgrade omp-antigravity-acp-provider
114
+ ```
115
+
116
+ To remove the installed plugin, use `omp plugin uninstall omp-antigravity-acp-provider`. Removing a plugin does not sign out Google or delete its ACP history. Handle logout and session cleanup separately before removal when that is desired; do not install both the npm and marketplace variants.
117
+
87
118
  ### Troubleshooting
88
119
 
89
120
  | Symptom | Check |
@@ -92,7 +123,7 @@ This shows the runtime, native-tool mode and usage state. Send a short prompt to
92
123
  | No models after `/antigravity-acp refresh` | Run `/antigravity-acp account` to confirm both sides are signed in, then retry with internet access. ACP can advertise fewer models than the Antigravity app. |
93
124
  | Two Antigravity providers appear | Remove the older adapter (`antigravity-acp-omp`, the upstream Pi extension, or a duplicate npm install), then restart OMP. |
94
125
  | Login opens the wrong Google account | Both login paths always start a fresh sign-in. Choose the intended account (or "Use another account") on Google's consent screen. |
95
- | `disabled` native-tool mode rejects the session | The official runtime must advertise system-append support (1.4.1+). Upgrade the runtime or run `/antigravity-acp native-tools prefer`. |
126
+ | Default `disabled` native-tool mode rejects the session | The official runtime must advertise system-append support (1.4.1+). Upgrade the runtime or run `/antigravity-acp native-tools prefer`. |
96
127
  | The first request is slow | Runtime download and cold ACP start happen once; later turns reuse the warm session. |
97
128
  | A tool call returns a relay notice | The model should call `pi_omp_await_result` with the notice's `call_id`. Lower `OMP_ACP_TOOL_RELAY_MS` or set it to `0` to disable relay. |
98
129
 
@@ -106,6 +137,7 @@ Google ships the same ACP server through two channels. The adapter chooses one a
106
137
 
107
138
  - **`agy` CLI.** Preferred whenever `agy` or `agy.exe` is on `PATH` and `agy acp --version` returns a semantic version. The adapter writes `agy-acp-cli.sh` or `agy-acp-cli.cmd` and points `AGY_ACP_BIN` at that wrapper.
108
139
  - **Managed runtime.** The registry-signed release in `~/.local/opt/agy-acp/`. It is the fallback when the CLI is missing or unusable.
140
+ The bundled signed manifest may select 1.3.0 until Google's newer release is approved. System-append routing and the default `native-tools disabled` require 1.4.1 or newer; on 1.3.0, upgrade or run `/antigravity-acp native-tools prefer`.
109
141
 
110
142
  Selection order:
111
143
 
@@ -117,22 +149,30 @@ Selection order:
117
149
 
118
150
  The adapter never installs the `agy` CLI. It downloads the managed runtime only in `auto` when no usable CLI is selected. Inference and quota use the same selection.
119
151
 
120
- On the first session start after OMP launches, the adapter attempts one background model refresh. A successful refresh re-registers the provider so newly advertised models and their API-equivalent rates become available. If login or ACP startup fails, the cached catalog remains usable and `/antigravity-acp refresh` still forces a refresh.
152
+ On the first session start after OMP launches, the adapter attempts one background model refresh. A successful refresh re-registers the provider so newly advertised models and their API-equivalent rates become available. If login or ACP startup fails, the cached catalog remains usable and `/antigravity-acp refresh` still forces a refresh. Before a cache exists, the offline catalog advertises Hydrogen (`low`, `medium`, `high`, `xhigh`), Argon and known partner models rather than treating those unverified entries as a completed server discovery. The first real inference then attempts discovery and updates the registered catalog.
153
+
154
+ ### Standby warmup
155
+
156
+ Warmup is enabled by default. Set `OMP_ACP_WARMUP=off` to keep every request on the cold path. With authentication and a usable runtime target, it creates one initialized, **session-less** standby after startup discovery closes, then lets the first matching inference rebind its handlers on that transport. It never creates a throwaway inference session.
157
+
158
+ Runtime target, cwd, permission auto-approval, native-tool policy and usage mode must match before reuse. Policy changes, failed initialization, invalidation and shutdown close the standby; initialization or authentication failure is silent and leaves the normal inference path available. Synthetic tests cover invalidation and handler rebinding; [Supported platforms](#supported-platforms) distinguishes those from live platform validation.
159
+
160
+ The CLI selection record caches binary stat metadata to avoid repeatedly querying an unchanged binary's version. This is a local cache optimization, not a claim that every CLI runtime is equally fast on every platform.
121
161
 
122
162
  Create or edit `~/.omp/agent/antigravity-acp-provider/config.json`:
123
163
 
124
164
  ```json
125
165
  {
126
- "permissions": "yolo",
166
+ "permissions": "follow",
127
167
  "runtimeSource": "auto",
128
- "nativeTools": "prefer",
168
+ "nativeTools": "disabled",
129
169
  "debugToolUpdates": false,
130
170
  "usageMode": "off",
131
171
  "diagnostics": false
132
172
  }
133
173
  ```
134
174
 
135
- `permissions` accepts `default`, `auto_edit`, or `yolo`. `runtimeSource` accepts `auto`, `cli`, or `managed`. `nativeTools` accepts `prefer` or `disabled`. `usageMode` accepts `auto` or `off`. `debugToolUpdates` and `diagnostics` are booleans. Missing fields use these defaults: `permissions: "yolo"`, `runtimeSource: "auto"`, `nativeTools: "prefer"`, `debugToolUpdates: false`, `usageMode: "off"`, and `diagnostics: false`. Slash commands write the command-backed fields and keep the legacy setting files in sync. Context budgets remain in `context.json`; cleanup policy remains in `cleanup.json`.
175
+ `permissions` accepts `default`, `auto_edit`, `yolo`, or `follow`. `runtimeSource` accepts `auto`, `cli`, or `managed`. `nativeTools` accepts `prefer` or `disabled`. `usageMode` accepts `auto` or `off`. `debugToolUpdates` and `diagnostics` are config-only booleans. Missing fields use these defaults: `permissions: "follow"`, `runtimeSource: "auto"`, `nativeTools: "disabled"`, `debugToolUpdates: false`, `usageMode: "off"`, and `diagnostics: false`. `follow` reads OMP's effective approval mode at plugin startup: OMP CLI `--approval-mode` and `--auto-approve` take precedence, then the project `.omp` override, then the active agent config. It maps `yolo` to `yolo`, `write` to `auto_edit`, and both ask modes to `default`. Restart OMP after changing OMP's approval mode so the ACP process is recreated with the matching auto-approval policy. Slash commands write the command-backed fields and keep the legacy setting files in sync. Context budgets remain in `context.json`; cleanup policy remains in `cleanup.json`.
136
176
 
137
177
  - `auto` uses the CLI first and falls back to the managed runtime. If no usable CLI exists, it downloads the managed runtime.
138
178
  - `cli` requires a usable `agy` CLI. If the CLI is missing or unusable, the first ACP use fails and nothing is downloaded.
@@ -144,7 +184,7 @@ Session storage follows the server's own `--app_data_dir`. The generated wrapper
144
184
 
145
185
  The active channel and its versions are recorded in `~/.omp/agent/antigravity-acp-provider/acp-runtime-source.json` whenever the CLI is chosen.
146
186
 
147
- Permission IDs differ between the channels. Managed ACP 1.4.5 supports `default`, `auto_edit`, and `yolo` directly. CLI ACP 1.5.3 advertises `default`, `accept-edits`, and `plan` instead. The adapter maps `auto-edit` to `accept-edits`. For `yolo`, it selects wire mode `default` and passes the CLI's official `--dangerously-skip-permissions` flag. This preserves auto-approval instead of substituting `accept-edits`. Changing permission modes recreates the ACP runtime so a process with auto-approval cannot serve a later `default` or `auto-edit` request. An explicit `AGY_ACP_BIN` is left unchanged.
187
+ Permission IDs differ between the channels. Managed ACP 1.4.5 supports `default`, `auto_edit`, and `yolo` directly. CLI ACP 1.5.3 advertises `default`, `accept-edits`, and `plan` instead. The adapter maps `auto-edit` to `accept-edits`. For `yolo`, it selects wire mode `default` and passes the CLI's official `--dangerously-skip-permissions` flag. This preserves auto-approval instead of substituting `accept-edits`. `follow` resolves OMP's effective approval mode first, with CLI `--approval-mode` and `--auto-approve` overrides taking precedence over project and agent config: `yolo` to `yolo`, `write` to `auto_edit`, and `always-ask` or `always-ask-cached` to `default`. Changing permission modes recreates the ACP runtime so a process with auto-approval cannot serve a later `default` or `auto-edit` request. An explicit `AGY_ACP_BIN` is left unchanged.
148
188
 
149
189
  CLI ACP 1.5.3 omits `mcpCapabilities` from its initialization response, but it still discovers HTTP MCP servers and calls `tools/list`. The adapter normalizes this capability for that server identity so OMP tools remain available. CLI 1.5.3 reports no audio input, while the adapter's model catalog already limits input to text and images.
150
190
 
@@ -156,6 +196,20 @@ The estimate is a heuristic, not a server measurement. To use managed ACP when e
156
196
 
157
197
  Keep `compaction.autoContinue` enabled for normal long-running work. The false context rollover was fixed at the occupancy signal, not by disabling automatic continuation.
158
198
 
199
+ ### Supplemental per-turn usage
200
+
201
+ Native usage on the model response takes precedence. When there is none and no supplemental `/usage` query is running, the adapter may read the ACP server's own per-session SQLite store. It prefers `bun:sqlite` under OMP's Bun host and falls back to `node:sqlite`; both open the existing database read-only. Only completed model steps after a per-session cursor are counted, with two short WAL-consistency retries if the newest step has not committed yet.
202
+
203
+ This fallback never creates a missing database and accepts only a UUID-shaped ACP session ID. It can enrich usage and estimated cost, but is not authoritative server billing. It does not replace `usage_update` context occupancy. `OMP_ACP_USAGE=off` disables both the supplemental `/usage` query and local-store accounting; the command setting `usage off` disables only the supplemental query. No extra model request is sent to collect local-store usage.
204
+
205
+ Managed quota discovery waits up to 20 seconds for the official `/usage` advertisement. A brief 1.5-second grace before closing a successful or timed-out probe gives the server's background token refresh room to settle; cancellation still follows the bounded abort-safe process cleanup. This is cleanup protection, not a guarantee that a quota value or OAuth refresh will be available.
206
+
207
+ ### History continuity and seed safety
208
+
209
+ When OMP removes the **oldest** image blocks to meet its image budget, the adapter recognizes the proven one-way eviction and can retain the warm ACP session. Checkpoints retain bounded positions and digests, not image bytes. Text edits, image substitutions, changed tool identities and unsupported message shapes force a clean rebuild instead of preserving a mismatched history.
210
+
211
+ Large history transfers can use hidden seed steps. Each requires the exact response `OK` and has a 60-second deadline. Adapter-mediated tool and permission requests fail the step without dispatching bridged work; an unsafe partial ACP session is retired before retry. An already-executed native operation cannot be undone merely by rejecting its later notification, so this guard is not a rollback mechanism. Compact history before retrying after these explicit failures.
212
+
159
213
  ## Commands
160
214
 
161
215
  Use the `/antigravity-acp ` prefix once, followed by a row below. For example, `status` means `/antigravity-acp status`.
@@ -168,21 +222,19 @@ Use the `/antigravity-acp ` prefix once, followed by a row below. For example, `
168
222
  | `account` | Show the signed-in account, ACP authentication and non-secret OMP marker. Token ownership, logout behavior and account/store inconsistencies are not hidden. |
169
223
  | `login` | Start a fresh Google authorization. |
170
224
  | `logout` | Clear Antigravity credentials, saved sessions and the OMP marker. |
171
- | `quota` | Query live quota and print one model heading with one remaining/reset row per quota window. Query failures are reported explicitly. |
172
225
  | `refresh` | Discover and cache advertised models, then list the refreshed IDs. |
173
226
  | `usage` | Show configured → effective supplemental-query mode (`OMP_ACP_USAGE=off` forces `off`) and only populated per-connection context, compaction and accounting details. |
174
227
  | `usage auto` | Query supplemental usage after each reply. Context occupancy updates remain enabled. |
175
228
  | `usage off` | Skip supplemental queries without disabling context occupancy updates. |
176
229
 
177
- Quota results use a 60-second cache. When the adapter selects the CLI, the quota command runs the CLI's print-mode `/usage` command with the same `--app_data_dir` as the CLI ACP wrapper. When it selects managed ACP, the quota command uses a short-lived ACP session. An explicit `AGY_ACP_BIN` remains authoritative. If an ACP runtime does not advertise `usage`, the adapter reports the limitation without sending a model prompt. The quota display excludes usage counters for temporary ACP sessions.
230
+ Quota results use a 60-second cache. When the adapter selects the CLI, the automatic quota query runs the CLI's print-mode `/usage` command with the same `--app_data_dir` as the CLI ACP wrapper. When it selects managed ACP, the query uses a short-lived ACP session. An explicit `AGY_ACP_BIN` remains authoritative. If an ACP runtime does not advertise `usage`, the adapter reports the limitation without sending a model prompt. Usage counters from temporary ACP sessions are excluded.
178
231
 
179
- OMP's built-in `omp usage`, interactive `/usage`, and the statusline `usage` segment read the same quota through the provider's registered usage source. The adapter uses the CLI `/usage` command first and queries an installed managed runtime only when the user is signed in. A usage probe never downloads a runtime. Statusline selects the active model's limit group when that group maps to one model. Multi-model groups remain visible in `/usage`. The custom `/antigravity-acp quota` command remains the detailed text view.
232
+ OMP's built-in `omp usage`, interactive `/usage`, and the statusline `usage` segment read the same quota through the provider's registered usage source. The adapter uses the CLI `/usage` command first and queries an installed managed runtime only when the user is signed in. A usage probe never downloads a runtime. Statusline selects the active model's limit group when that group maps to one model. Multi-model groups remain visible in `/usage`.
180
233
 
181
234
  ### Advanced maintenance
182
235
 
183
236
  | Subcommand and options | Purpose |
184
237
  | --- | --- |
185
- | `tools` | Inspect offered/available OMP tools, every omission reason and live MCP capability checks. |
186
238
  | `context` | Show saved shared defaults separately from each cached model's effective limits and model-only overrides. Effective values include the input, output, reserve, transfer and image budgets used by runtime compatibility checks. |
187
239
  | `context set default KEY NUMBER` | Change a shared numeric context setting. |
188
240
  | `context set MODEL KEY NUMBER` | Change one model override. Reselect the model or restart OMP to refresh its displayed limits. |
@@ -193,13 +245,10 @@ OMP's built-in `omp usage`, interactive `/usage`, and the statusline `usage` seg
193
245
  | `cleanup timeout [DAYS]` | Apply timeout collection, optionally with a custom idle retention in days. |
194
246
  | `cleanup balanced [DAYS]` | Apply timeout and soft-budget cleanup with recovery protection, optionally with custom idle days. |
195
247
  | `cleanup budget MAX_SESSIONS MAX_MIB` | Set soft session/byte limits; `0` disables either limit. Active and recently used sessions can remain above a soft budget. Timeout deletion loses ACP-only state but retains OMP history. |
196
- | `diagnostics` | Show collection state and non-empty samples as count/median/max per stage. |
197
- | `diagnostics on\|off` | Enable or disable bounded local timing collection. |
198
- | `diagnostics reset` | Clear collected samples without changing the enabled state. |
199
- | `debug on\|off` | Toggle raw ACP tool-status lines; normal tool results and thought summaries are preserved. |
200
- | `native-tools prefer` | Let OMP tools shadow matching ACP-native tools. |
201
- | `native-tools disabled` | Disable ACP-native built-ins for strict OMP-tool sessions while retaining MCP configuration; connections are recreated on the next request. |
248
+ | `native-tools disabled` | Disable ACP-native built-ins for strict OMP-tool sessions while retaining MCP configuration; this is the default and requires ACP 1.4.1+. Connections are recreated on the next request. |
249
+ | `native-tools prefer` | Retain ACP-native built-ins and let OMP tools shadow matching native tools. |
202
250
  | `permissions default` | Confirm edits and commands. |
251
+ | `permissions follow` | Follow OMP's `tools.approvalMode`; this is the default. |
203
252
  | `permissions auto-edit` | Auto-accept edits. |
204
253
  | `permissions yolo` | Auto-accept everything; changing modes recreates runtimes to avoid reusing an unsafe process. |
205
254
 
@@ -231,7 +280,8 @@ A `refusal` stop reason is reported as an explicit provider refusal. An empty `e
231
280
  ## Limitations vs direct OAuth
232
281
 
233
282
  - No direct model API endpoint or reverse-proxy mode.
234
- - No API-key, service-account, or raw OAuth-token authentication; Google browser consent is required.
283
+ - Credentials come from the ACP server's own stores: Google browser consent, `GEMINI_API_KEY`, or a Gemini API key saved in OMP's auth store. Raw OAuth tokens supplied by hand and service accounts are not accepted. Keyring access is limited to what the adapter can inspect; see [Supported platforms](#supported-platforms).
284
+ - Usage and quota through a key saved in OMP's auth store can be incomplete, because the host usage provider is not passed that credential.
235
285
  - Only models advertised by the ACP server are available.
236
286
  - Only thinking levels confirmed by the ACP server are selectable.
237
287
  - No arbitrary generation controls: temperature, top_p, seed, stop sequences, tool_choice, response format, or output-token limit.
@@ -243,6 +293,21 @@ A `refusal` stop reason is reported as an explicit provider refusal. An empty `e
243
293
 
244
294
  Detailed behavior, advanced settings and limitations: [docs/](docs/) and [CHANGELOG.md](CHANGELOG.md).
245
295
 
296
+ ## Release tooling
297
+
298
+ For a prepared release, first update `CHANGELOG.md`, then run `npm run release:bump -- X.Y.Z`. The helper updates all six supported version declarations and runs the version consistency checker; it does not commit, tag, push or publish. `npm run check:versions` verifies the current metadata, and `node scripts/check-release-versions.mjs --release --tag vX.Y.Z` additionally checks the tag and changelog heading.
299
+
300
+ The `Release` workflow runs only for pushed `v*` tags. It reruns the offline check and marketplace check, validates the packed tarball against the tag and commit, then uses npm trusted publishing with provenance before creating or reusing the GitHub release. The tag run is the only publishing path; do not publish from a local checkout. A separate `Release dry run` workflow can verify an existing tag without publishing.
301
+
302
+ ## Contributors
303
+
304
+ The Linux Secret Service credential handling and model metadata/fallback adaptations come from [Maddock (@notmaddock)](https://github.com/notmaddock)'s work, including [PR #2](https://github.com/SenCha930511/omp-antigravity-acp-provider/pull/2). Image-eviction continuity and hidden-seed guards are adapted from `ldfhhc/omp-antigravity-acp-provider`. Auth/discovery, Bun SQLite usage, CLI stat caching, quota timing, warmup and release-helper adaptations use work from `00lllooolll00/omp-antigravity-acp-provider`, with additional integration and lifecycle fixes in this repository.
305
+ The standard Google OAuth endpoint and AccountChooser handling in headless login is adapted from [Dwi Fitriyanto (@masred)](https://github.com/masred)'s [PR #14](https://github.com/SenCha930511/omp-antigravity-acp-provider/pull/14).
306
+
307
+ See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for links to all four fork projects and the separation between their adaptations and the upstream project attribution.
308
+
309
+ GitHub counts a contributor when a commit that credits them, as author or through a `Co-authored-by:` trailer, reaches the default branch ([contributor list](https://docs.github.com/en/repositories/viewing-activity-and-data-for-your-repository/viewing-a-projects-contributors), [co-authored commits](https://docs.github.com/en/pull-requests/how-tos/commit-changes/creating-a-commit-with-multiple-authors)). Until commits carrying that credit are on the default branch of the public repository, its contributors page will not list the addition.
310
+
246
311
  ## License
247
312
 
248
- MIT. See [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). Upstream source is vendored under `extension/vendor/pi-antigravity-acp-provider` (MIT) and kept with attribution. Official Google executables and their licenses are separate.
313
+ MIT. See [LICENSE](LICENSE) and [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md). Upstream 0.1.15 code is incorporated into the owned runtime sources under `extension/runtime/` (MIT) and kept with attribution. Official Google executables and their licenses are separate.
@@ -197,12 +197,11 @@ LICENSE
197
197
 
198
198
  ============================================================
199
199
 
200
- @earendil-works/pi-ai@1.3.0
200
+ @earendil-works/pi-ai@1.5.2
201
201
  License: MIT
202
202
 
203
203
  Source: https://github.com/earendil-works/pi/blob/main/LICENSE
204
- Package: @earendil-works/pi-ai@1.3.0 (declares MIT; npm archive omits LICENSE)
205
- Retrieved: 2026-10-19
204
+ Retrieved: 2026-11-14
206
205
 
207
206
  MIT License
208
207
 
@@ -229,7 +228,69 @@ SOFTWARE.
229
228
 
230
229
  ============================================================
231
230
 
232
- @hono/node-server@2.1.5
231
+ @earendil-works/pi-schema@1.5.2
232
+ License: MIT
233
+
234
+ Source: https://github.com/earendil-works/pi/blob/main/LICENSE
235
+ Retrieved: 2026-11-14
236
+
237
+ MIT License
238
+
239
+ Copyright (c) 2025 Mario Zechner
240
+
241
+ Permission is hereby granted, free of charge, to any person obtaining a copy
242
+ of this software and associated documentation files (the "Software"), to deal
243
+ in the Software without restriction, including without limitation the rights
244
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
245
+ copies of the Software, and to permit persons to whom the Software is
246
+ furnished to do so, subject to the following conditions:
247
+
248
+ The above copyright notice and this permission notice shall be included in all
249
+ copies or substantial portions of the Software.
250
+
251
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
252
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
253
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
254
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
255
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
256
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
257
+ SOFTWARE.
258
+
259
+
260
+ ============================================================
261
+
262
+ @earendil-works/pi-telemetry@1.5.2
263
+ License: MIT
264
+
265
+ Source: https://github.com/earendil-works/pi/blob/main/LICENSE
266
+ Retrieved: 2026-11-14
267
+
268
+ MIT License
269
+
270
+ Copyright (c) 2025 Mario Zechner
271
+
272
+ Permission is hereby granted, free of charge, to any person obtaining a copy
273
+ of this software and associated documentation files (the "Software"), to deal
274
+ in the Software without restriction, including without limitation the rights
275
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
276
+ copies of the Software, and to permit persons to whom the Software is
277
+ furnished to do so, subject to the following conditions:
278
+
279
+ The above copyright notice and this permission notice shall be included in all
280
+ copies or substantial portions of the Software.
281
+
282
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
283
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
284
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
285
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
286
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
287
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
288
+ SOFTWARE.
289
+
290
+
291
+ ============================================================
292
+
293
+ @hono/node-server@2.1.8
233
294
  License: MIT
234
295
 
235
296
  LICENSE
@@ -258,7 +319,7 @@ SOFTWARE.
258
319
 
259
320
  ============================================================
260
321
 
261
- @modelcontextprotocol/sdk@1.32.1
322
+ @modelcontextprotocol/sdk@1.32.2
262
323
  License: MIT
263
324
 
264
325
  LICENSE
@@ -495,7 +556,7 @@ SOFTWARE.
495
556
 
496
557
  ============================================================
497
558
 
498
- fast-uri@3.1.8
559
+ fast-uri@3.1.9
499
560
  License: BSD-3-Clause
500
561
 
501
562
  LICENSE
@@ -578,7 +639,7 @@ IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
578
639
 
579
640
  ============================================================
580
641
 
581
- hono@4.13.13
642
+ hono@4.13.18
582
643
  License: MIT
583
644
 
584
645
  LICENSE
@@ -1046,37 +1107,7 @@ IN THE SOFTWARE.
1046
1107
 
1047
1108
  ============================================================
1048
1109
 
1049
- typebox@1.3.36
1050
- License: MIT
1051
-
1052
- license
1053
- TypeBox
1054
-
1055
- The MIT License (MIT)
1056
-
1057
- Copyright (c) 2017-2026 Haydn Paterson
1058
-
1059
- Permission is hereby granted, free of charge, to any person obtaining a copy
1060
- of this software and associated documentation files (the "Software"), to deal
1061
- in the Software without restriction, including without limitation the rights
1062
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1063
- copies of the Software, and to permit persons to whom the Software is
1064
- furnished to do so, subject to the following conditions:
1065
-
1066
- The above copyright notice and this permission notice shall be included in
1067
- all copies or substantial portions of the Software.
1068
-
1069
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1070
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1071
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1072
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1073
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1074
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1075
- THE SOFTWARE.
1076
-
1077
- ============================================================
1078
-
1079
- typebox@1.3.27
1110
+ typebox@1.4.6
1080
1111
  License: MIT
1081
1112
 
1082
1113
  license
@@ -1198,7 +1229,7 @@ OTHER DEALINGS IN THE SOFTWARE.
1198
1229
 
1199
1230
  ============================================================
1200
1231
 
1201
- zod@4.6.5
1232
+ zod@4.6.7
1202
1233
  License: MIT
1203
1234
 
1204
1235
  LICENSE
@@ -1,11 +1,22 @@
1
1
  # Third-party notices
2
2
 
3
- omp-antigravity-acp-provider is an OMP-focused derivative fork/adaptation of [pi-antigravity-acp-provider](https://github.com/zacbemis/pi-antigravity-acp-provider), originally created by [zacbemis](https://github.com/zacbemis) and contributors and distributed under MIT. It vendors upstream version 0.1.15 source under `extension/vendor/pi-antigravity-acp-provider` (see `extension/vendor/pi-antigravity-acp-provider/LICENSE`) and keeps attribution.
3
+ omp-antigravity-acp-provider is an OMP-focused derivative fork/adaptation of [pi-antigravity-acp-provider](https://github.com/zacbemis/pi-antigravity-acp-provider), originally created by [zacbemis](https://github.com/zacbemis) and contributors and distributed under MIT. Upstream 0.1.15 code is incorporated directly into the owned runtime sources under `extension/runtime/` and is kept with attribution; there is no separate vendored copy or upstream package dependency.
4
4
 
5
5
  The upstream authors retain credit for the original ACP transport, authentication, runtime installation, session restoration and MCP bridge implementation.
6
6
 
7
7
  Its original license notice follows. The adapter adds OMP-specific registration, model selectors, lifecycle handling, tool-routing instructions and cost estimation. Published npm packages include the generated `THIRD_PARTY_LICENSES.txt` with license notices for bundled dependencies. Google runtime executables are not included.
8
8
 
9
+ ## Community fork adaptations
10
+
11
+ The following community work was adapted into the owned adapter architecture rather than merging the pre-refactor source trees. These notices cover adaptation, not endorsement by the contributors or by Google.
12
+
13
+ - [notmaddock/omp-antigravity-acp-provider](https://github.com/notmaddock/omp-antigravity-acp-provider) (`@notmaddock`): Linux Secret Service authentication and known Claude/GPT-OSS metadata plus offline partner-model fallback.
14
+ - [ldfhhc/omp-antigravity-acp-provider](https://github.com/ldfhhc/omp-antigravity-acp-provider) (`@ldfhhc`): oldest-image history continuity and hidden history/request seed guards. The independently guarded implementation lives in `extension/runtime/image-history.ts` and `extension/runtime/history-seed.ts`.
15
+ - [00lllooolll00/omp-antigravity-acp-provider](https://github.com/00lllooolll00/omp-antigravity-acp-provider) (`@00lllooolll00`): fresh-login watcher protection, Hydrogen/offline catalog discovery, Bun SQLite usage, CLI stat caching, quota refresh grace, standby warmup and release helper ideas, adapted and additionally hardened in this repository.
16
+ - [masred/omp-antigravity-acp-provider](https://github.com/masred/omp-antigravity-acp-provider) (`@masred`): standard Google OAuth endpoints and AccountChooser handling for headless login, adapted into `extension/runtime/acp/headless-oauth.ts`.
17
+
18
+ Each contribution remains distinguishable in the owned source and its feature commit where applicable. The adapter does not copy fork-specific package names, publishing identities or personal skill files.
19
+
9
20
  ```
10
21
  MIT License
11
22
 
@@ -53,6 +53,18 @@ export function compactionSummary(value: unknown): string | undefined {
53
53
  if (value === null) return "";
54
54
  return contentText(value);
55
55
  }
56
+ const MAX_COMPACTION_SUMMARY_CHARS = 4096;
57
+
58
+ function boundedCompactionSummary(value: string): string {
59
+ return value.length > MAX_COMPACTION_SUMMARY_CHARS ? value.slice(0, MAX_COMPACTION_SUMMARY_CHARS) : value;
60
+ }
61
+
62
+ function appendCompactionSummary(previous: string, text: string): string {
63
+ const remaining = MAX_COMPACTION_SUMMARY_CHARS - previous.length;
64
+ if (remaining <= 0) return previous;
65
+ return previous + (text.length > remaining ? text.slice(0, remaining) : text);
66
+ }
67
+
56
68
 
57
69
  export function applyCompactionUpdate(
58
70
  previous: AcpCompactionRecord | undefined,
@@ -69,7 +81,7 @@ export function applyCompactionUpdate(
69
81
  sessionId,
70
82
  compactionId: update.compactionId,
71
83
  status: update.status,
72
- summary: summary === undefined ? previous?.summary ?? "" : summary,
84
+ summary: summary === undefined ? previous?.summary ?? "" : boundedCompactionSummary(summary),
73
85
  ...(errorProvided ? (error !== undefined ? { error } : {}) : previous?.error !== undefined ? { error: previous.error } : {}),
74
86
  updatedAt: now,
75
87
  notified: previous?.notified ?? false,
@@ -89,7 +101,7 @@ export function applyCompactionChunk(
89
101
  sessionId,
90
102
  compactionId: chunk.compactionId,
91
103
  status: previous?.status ?? "in_progress",
92
- summary: (previous?.summary ?? "") + text,
104
+ summary: appendCompactionSummary(previous?.summary ?? "", text),
93
105
  ...(previous?.error !== undefined ? { error: previous.error } : {}),
94
106
  updatedAt: now,
95
107
  notified: previous?.notified ?? false,
@@ -34,7 +34,7 @@ const AUTH_RULE: FailureRule = {
34
34
  code: "auth",
35
35
  match: /authentication required|not logged in|not signed in|unauthenticated|sign in|invalid_grant|401 unauthorized/i,
36
36
  ensure: /run `agy`|terminal/i,
37
- append: "run `agy` once in a terminal to sign in",
37
+ append: "run `agy` once in a terminal to sign in, or verify HTTP_PROXY/HTTPS_PROXY if token refresh timed out",
38
38
  };
39
39
  const QUOTA_RULE: FailureRule = {
40
40
  code: "quota",
@@ -75,9 +75,10 @@ const SERVER_RULE: FailureRule = {
75
75
  const TRANSPORT_RULE: FailureRule = {
76
76
  code: "transport",
77
77
  match: /network|connection|fetch failed|socket|stream ended|closed|ENOTFOUND|EAI_AGAIN|broken pipe|EPIPE|failed to bind|process exited/i,
78
- ensure: /connection|network|socket|stream|bind|process/i,
79
- append: "connection error",
78
+ ensure: /connection|network|socket|stream|bind|process|proxy/i,
79
+ append: "connection/network error — check network or HTTP_PROXY/HTTPS_PROXY",
80
80
  };
81
+ const OAUTH_NETWORK_REFRESH = /(?:token refresh failed due to network|oauth2\.googleapis\.com\/token[^:]*:\s*(?:EOF|unexpected EOF|context deadline exceeded|timeout|ENOTFOUND|EAI_AGAIN|connection|network))/i;
81
82
  const RULES: FailureRule[] = [
82
83
  AUTH_RULE,
83
84
  QUOTA_RULE,
@@ -102,22 +103,56 @@ function isAntigravityAcpError(error: unknown): error is AntigravityAcpErrorLike
102
103
  && typeof (error as { code?: unknown }).code === "string";
103
104
  }
104
105
 
106
+ function sanitizedCause(error: unknown): Error {
107
+ const message = error instanceof Error ? error.message : String(error);
108
+ const sanitized = new Error(redactSensitiveText(message));
109
+ if (error instanceof Error) {
110
+ sanitized.name = error.name;
111
+ if (error.stack) sanitized.stack = redactSensitiveText(error.stack);
112
+ const code = (error as { code?: unknown }).code;
113
+ if (typeof code === "string") Object.assign(sanitized, { code });
114
+ }
115
+ return sanitized;
116
+ }
117
+
118
+ function needsSanitization(error: unknown): boolean {
119
+ return error instanceof Error
120
+ && (error.cause !== undefined || Boolean(error.stack && redactSensitiveText(error.stack) !== error.stack));
121
+ }
122
+
123
+ function sanitizedError(error: unknown): Error {
124
+ const sanitized = sanitizedCause(error);
125
+ if (error instanceof Error && error.cause !== undefined) sanitized.cause = sanitizedCause(error.cause);
126
+ return sanitized;
127
+ }
128
+
105
129
  export function classifyAcpFailure(error: unknown): Error {
106
130
  if (isAntigravityAcpError(error)) {
107
131
  if (error.code === "aborted") return error;
108
- if (error.code === "auth") return new AcpFailure("auth", redactSensitiveText(appendHint(error.message, AUTH_RULE)), { cause: error });
109
- if (error.code === "quota") return new AcpFailure("quota", redactSensitiveText(appendHint(error.message, QUOTA_RULE)), { cause: error });
110
- if (error.code === "timeout") return new AcpFailure("timeout", redactSensitiveText(appendHint(error.message, TIMEOUT_RULE)), { cause: error });
111
- if (error.code === "spawn" || error.code === "process_exit") return new AcpFailure("transport", redactSensitiveText(appendHint(error.message, TRANSPORT_RULE)), { cause: error });
112
- if (error.code === "invalid_input") return new AcpFailure("protocol", redactSensitiveText(appendHint(error.message, PROTOCOL_RULE)), { cause: error });
113
- if (error.code === "model") return new AcpFailure("model", redactSensitiveText(error.message), { cause: error });
132
+ const cause = { cause: sanitizedCause(error) };
133
+ if (error.code === "auth") return new AcpFailure("auth", redactSensitiveText(appendHint(error.message, AUTH_RULE)), cause);
134
+ if (error.code === "quota") return new AcpFailure("quota", redactSensitiveText(appendHint(error.message, QUOTA_RULE)), cause);
135
+ if (error.code === "timeout") return new AcpFailure("timeout", redactSensitiveText(appendHint(error.message, TIMEOUT_RULE)), cause);
136
+ if (error.code === "spawn" || error.code === "process_exit") return new AcpFailure("transport", redactSensitiveText(appendHint(error.message, TRANSPORT_RULE)), cause);
137
+ if ((error.code === "protocol" || error.code === "invalid_input")
138
+ && OAUTH_NETWORK_REFRESH.test(error.message) && !/invalid_grant/i.test(error.message)) {
139
+ return new AcpFailure("transport", redactSensitiveText(appendHint(error.message, TRANSPORT_RULE)), cause);
140
+ }
141
+ if (error.code === "protocol" || error.code === "invalid_input") return new AcpFailure("protocol", redactSensitiveText(appendHint(error.message, PROTOCOL_RULE)), cause);
142
+ if (error.code === "model") return new AcpFailure("model", redactSensitiveText(error.message), cause);
114
143
  }
115
144
  const message = error instanceof Error ? error.message : String(error);
116
- if (!message.trim()) return error instanceof Error ? error : new Error(message);
145
+ if (!message.trim()) return needsSanitization(error) ? sanitizedError(error) : error instanceof Error ? error : new Error(message);
146
+ if (OAUTH_NETWORK_REFRESH.test(message) && !/invalid_grant/i.test(message)) {
147
+ return new AcpFailure("transport", redactSensitiveText(appendHint(message, TRANSPORT_RULE)), { cause: sanitizedCause(error) });
148
+ }
117
149
  for (const rule of RULES) {
118
- if (rule.match.test(message)) return new AcpFailure(rule.code, redactSensitiveText(appendHint(message, rule)), { cause: error });
150
+ if (rule.match.test(message)) {
151
+ return new AcpFailure(rule.code, redactSensitiveText(appendHint(message, rule)), { cause: sanitizedCause(error) });
152
+ }
119
153
  }
120
154
  const redacted = redactSensitiveText(message);
121
- if (redacted === message) return error instanceof Error ? error : new Error(message);
122
- return new Error(redacted);
155
+ const needs = needsSanitization(error);
156
+ if (redacted === message && !needs) return error instanceof Error ? error : new Error(message);
157
+ return redacted === message ? sanitizedError(error) : new Error(redacted);
123
158
  }