omp-antigravity-acp-provider 0.1.44 → 0.2.2

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 (63) hide show
  1. package/AGENT_INSTALL.md +1 -1
  2. package/README.md +87 -20
  3. package/THIRD_PARTY_NOTICES.md +12 -1
  4. package/extension/acp-errors.ts +37 -10
  5. package/extension/adapter-config.ts +123 -6
  6. package/extension/assets/src/acp/supervisor.mjs +4 -1
  7. package/extension/auth-sync.ts +245 -55
  8. package/extension/catalog-store.ts +52 -26
  9. package/extension/commands.ts +54 -156
  10. package/extension/index.ts +459 -98
  11. package/extension/model-catalog.ts +37 -3
  12. package/extension/omp-session-lifecycle.ts +13 -2
  13. package/extension/omp-session-source.ts +16 -5
  14. package/extension/runtime/acp/antigravity.ts +185 -0
  15. package/extension/runtime/acp/bounded-stream.ts +171 -0
  16. package/extension/runtime/acp/connection.ts +507 -0
  17. package/extension/runtime/acp/credential-storage.ts +113 -0
  18. package/extension/runtime/acp/errors.ts +54 -0
  19. package/extension/runtime/acp/events.ts +66 -0
  20. package/extension/runtime/acp/headless-oauth.ts +209 -0
  21. package/extension/runtime/acp/prompt-watchdog.ts +80 -0
  22. package/extension/runtime/acp/proxy.ts +54 -0
  23. package/extension/runtime/acp/runtime-manifest.ts +185 -0
  24. package/extension/runtime/acp/session-state.ts +76 -0
  25. package/extension/runtime/asset.ts +24 -0
  26. package/extension/runtime/binding.ts +145 -0
  27. package/extension/runtime/config.ts +119 -0
  28. package/extension/runtime/constants.ts +18 -0
  29. package/extension/runtime/history-seed.ts +227 -0
  30. package/extension/runtime/image-history.ts +233 -0
  31. package/extension/runtime/index.ts +23 -0
  32. package/extension/runtime/launch.ts +545 -0
  33. package/extension/runtime/managed.ts +872 -0
  34. package/extension/runtime/models.ts +192 -0
  35. package/extension/runtime/process.ts +281 -0
  36. package/extension/{context-transfer.ts → runtime/prompt.ts} +183 -70
  37. package/extension/runtime/provider.ts +149 -0
  38. package/extension/runtime/routing.ts +47 -0
  39. package/extension/runtime/runtime-manifest.json +205 -0
  40. package/extension/runtime/runtime.ts +2204 -0
  41. package/extension/runtime/status.ts +87 -0
  42. package/extension/runtime/stream/json.ts +17 -0
  43. package/extension/runtime/stream/pi-events.ts +142 -0
  44. package/extension/runtime/stream/usage.ts +37 -0
  45. package/extension/runtime/supervisor.mjs +113 -0
  46. package/extension/{tool-args.ts → runtime/tools/args.ts} +1 -1
  47. package/extension/runtime/tools/bridge.ts +331 -0
  48. package/extension/{tool-relay.ts → runtime/tools/relay.ts} +8 -3
  49. package/extension/runtime/tools/schema.ts +256 -0
  50. package/extension/runtime.mjs +2793 -1239
  51. package/extension/secret-service.ts +85 -0
  52. package/extension/session-cleanup.ts +49 -2
  53. package/extension/session-store.ts +1 -1
  54. package/extension/tier-connection.ts +248 -56
  55. package/extension/tool-order.ts +4 -2
  56. package/extension/tool-routing.ts +112 -30
  57. package/extension/usage-accounting.ts +6 -2
  58. package/extension/usage-db.ts +95 -22
  59. package/extension/usage.ts +1 -1
  60. package/package.json +10 -6
  61. package/extension/acp-runtime-source.ts +0 -310
  62. package/extension/history-fingerprint.ts +0 -80
  63. 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,11 +5,13 @@
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)**.
12
12
 
13
+ Current version: `0.2.2`.
14
+
13
15
  **An OMP-focused derivative fork of [zacbemis/pi-antigravity-acp-provider](https://github.com/zacbemis/pi-antigravity-acp-provider).** Original project by [zacbemis](https://github.com/zacbemis) and contributors, licensed under MIT.
14
16
 
15
17
  This is an independent adaptation, **NOT** an official Google or OMP integration. It uses ACP over stdio. The local HTTP MCP bridge carries tool calls; it is not a model API reverse proxy.
@@ -18,18 +20,39 @@ This is an independent adaptation, **NOT** an official Google or OMP integration
18
20
 
19
21
  - All server-advertised models, including Claude, GPT-OSS and future IDs when the ACP endpoint advertises them.
20
22
  - 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.
23
+ - 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
24
  - OMP tools through an authenticated loopback MCP bridge.
23
25
  - Optional `disabled` native-tool mode for strict OMP-only sessions.
24
- - Lazy ACP startup and warm session reuse.
26
+ - Standby ACP initialization coordinated with discovery, plus warm session reuse and guarded oldest-image history continuity.
25
27
  - `/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.
28
+ - 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
29
  - 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
30
  - 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
31
  - 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
32
  - 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
33
  - 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
34
  - 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.
35
+ - 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.
36
+
37
+ ## Supported platforms
38
+
39
+ 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.
40
+
41
+ | Platform | Configuration | Validation |
42
+ | --- | --- | --- |
43
+ | 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. |
44
+ | 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. |
45
+ | 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. |
46
+
47
+ ### Credentials and keyrings
48
+
49
+ 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.
50
+
51
+ - **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.
52
+ - **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.
53
+ - **Windows.** There is no keyring integration. The token file and `GEMINI_API_KEY` are supported credential sources.
54
+
55
+ 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
56
 
34
57
  ## Install: for human
35
58
 
@@ -39,7 +62,7 @@ Follow these steps in order. The whole flow takes a few minutes, plus Google's s
39
62
 
40
63
  - OMP is installed and `omp --version` works.
41
64
  - 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.
65
+ - A supported platform: macOS, Linux or Windows. [Supported platforms](#supported-platforms) lists what each one accepts and what has been validated.
43
66
  - 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
67
 
45
68
  ### 2. Install exactly one adapter
@@ -57,6 +80,8 @@ Or install the published npm package directly:
57
80
  omp plugin install npm:omp-antigravity-acp-provider
58
81
  ```
59
82
 
83
+ To pin this version, use `omp plugin install npm:omp-antigravity-acp-provider@0.2.2`.
84
+
60
85
  Do not install both. Remove or disable any older Antigravity ACP adapter first.
61
86
 
62
87
  ### 3. Restart OMP
@@ -65,7 +90,7 @@ The provider registers at startup. Restart every running OMP process so they agr
65
90
 
66
91
  ### 4. Sign in
67
92
 
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.
93
+ 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
94
 
70
95
  ### 5. Load models and pick one
71
96
 
@@ -84,6 +109,14 @@ Run `/login`, choose **Google Antigravity (ACP)**, and complete Google's consent
84
109
 
85
110
  This shows the runtime, native-tool mode and usage state. Send a short prompt to confirm inference.
86
111
 
112
+ ### Upgrade or remove
113
+
114
+ ```sh
115
+ omp plugin upgrade omp-antigravity-acp-provider
116
+ ```
117
+
118
+ 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.
119
+
87
120
  ### Troubleshooting
88
121
 
89
122
  | Symptom | Check |
@@ -106,6 +139,7 @@ Google ships the same ACP server through two channels. The adapter chooses one a
106
139
 
107
140
  - **`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
141
  - **Managed runtime.** The registry-signed release in `~/.local/opt/agy-acp/`. It is the fallback when the CLI is missing or unusable.
142
+ The bundled signed manifest may select 1.3.0 until Google's newer release is approved. System-append routing and `native-tools disabled` require 1.4.1 or newer.
109
143
 
110
144
  Selection order:
111
145
 
@@ -117,13 +151,21 @@ Selection order:
117
151
 
118
152
  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
153
 
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.
154
+ 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.
155
+
156
+ ### Standby warmup
157
+
158
+ 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.
159
+
160
+ 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.
161
+
162
+ 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
163
 
122
164
  Create or edit `~/.omp/agent/antigravity-acp-provider/config.json`:
123
165
 
124
166
  ```json
125
167
  {
126
- "permissions": "yolo",
168
+ "permissions": "follow",
127
169
  "runtimeSource": "auto",
128
170
  "nativeTools": "prefer",
129
171
  "debugToolUpdates": false,
@@ -132,7 +174,7 @@ Create or edit `~/.omp/agent/antigravity-acp-provider/config.json`:
132
174
  }
133
175
  ```
134
176
 
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`.
177
+ `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: "prefer"`, `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
178
 
137
179
  - `auto` uses the CLI first and falls back to the managed runtime. If no usable CLI exists, it downloads the managed runtime.
138
180
  - `cli` requires a usable `agy` CLI. If the CLI is missing or unusable, the first ACP use fails and nothing is downloaded.
@@ -144,7 +186,7 @@ Session storage follows the server's own `--app_data_dir`. The generated wrapper
144
186
 
145
187
  The active channel and its versions are recorded in `~/.omp/agent/antigravity-acp-provider/acp-runtime-source.json` whenever the CLI is chosen.
146
188
 
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.
189
+ 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
190
 
149
191
  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
192
 
@@ -156,6 +198,20 @@ The estimate is a heuristic, not a server measurement. To use managed ACP when e
156
198
 
157
199
  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
200
 
201
+ ### Supplemental per-turn usage
202
+
203
+ 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.
204
+
205
+ 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.
206
+
207
+ 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.
208
+
209
+ ### History continuity and seed safety
210
+
211
+ 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.
212
+
213
+ 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.
214
+
159
215
  ## Commands
160
216
 
161
217
  Use the `/antigravity-acp ` prefix once, followed by a row below. For example, `status` means `/antigravity-acp status`.
@@ -168,21 +224,19 @@ Use the `/antigravity-acp ` prefix once, followed by a row below. For example, `
168
224
  | `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
225
  | `login` | Start a fresh Google authorization. |
170
226
  | `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
227
  | `refresh` | Discover and cache advertised models, then list the refreshed IDs. |
173
228
  | `usage` | Show configured → effective supplemental-query mode (`OMP_ACP_USAGE=off` forces `off`) and only populated per-connection context, compaction and accounting details. |
174
229
  | `usage auto` | Query supplemental usage after each reply. Context occupancy updates remain enabled. |
175
230
  | `usage off` | Skip supplemental queries without disabling context occupancy updates. |
176
231
 
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.
232
+ 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
233
 
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.
234
+ 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
235
 
181
236
  ### Advanced maintenance
182
237
 
183
238
  | Subcommand and options | Purpose |
184
239
  | --- | --- |
185
- | `tools` | Inspect offered/available OMP tools, every omission reason and live MCP capability checks. |
186
240
  | `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
241
  | `context set default KEY NUMBER` | Change a shared numeric context setting. |
188
242
  | `context set MODEL KEY NUMBER` | Change one model override. Reselect the model or restart OMP to refresh its displayed limits. |
@@ -193,13 +247,10 @@ OMP's built-in `omp usage`, interactive `/usage`, and the statusline `usage` seg
193
247
  | `cleanup timeout [DAYS]` | Apply timeout collection, optionally with a custom idle retention in days. |
194
248
  | `cleanup balanced [DAYS]` | Apply timeout and soft-budget cleanup with recovery protection, optionally with custom idle days. |
195
249
  | `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
250
  | `native-tools prefer` | Let OMP tools shadow matching ACP-native tools. |
201
251
  | `native-tools disabled` | Disable ACP-native built-ins for strict OMP-tool sessions while retaining MCP configuration; connections are recreated on the next request. |
202
252
  | `permissions default` | Confirm edits and commands. |
253
+ | `permissions follow` | Follow OMP's `tools.approvalMode`; this is the default. |
203
254
  | `permissions auto-edit` | Auto-accept edits. |
204
255
  | `permissions yolo` | Auto-accept everything; changing modes recreates runtimes to avoid reusing an unsafe process. |
205
256
 
@@ -231,7 +282,8 @@ A `refusal` stop reason is reported as an explicit provider refusal. An empty `e
231
282
  ## Limitations vs direct OAuth
232
283
 
233
284
  - 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.
285
+ - 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).
286
+ - 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
287
  - Only models advertised by the ACP server are available.
236
288
  - Only thinking levels confirmed by the ACP server are selectable.
237
289
  - No arbitrary generation controls: temperature, top_p, seed, stop sequences, tool_choice, response format, or output-token limit.
@@ -243,6 +295,21 @@ A `refusal` stop reason is reported as an explicit provider refusal. An empty `e
243
295
 
244
296
  Detailed behavior, advanced settings and limitations: [docs/](docs/) and [CHANGELOG.md](CHANGELOG.md).
245
297
 
298
+ ## Release tooling
299
+
300
+ 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.
301
+
302
+ The `Release` workflow runs only for pushed `v*` tags. It reruns the offline 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.
303
+
304
+ ## Contributors
305
+
306
+ 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.
307
+ 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).
308
+
309
+ 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.
310
+
311
+ 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.
312
+
246
313
  ## License
247
314
 
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.
315
+ 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.
@@ -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
 
@@ -102,22 +102,49 @@ function isAntigravityAcpError(error: unknown): error is AntigravityAcpErrorLike
102
102
  && typeof (error as { code?: unknown }).code === "string";
103
103
  }
104
104
 
105
+ function sanitizedCause(error: unknown): Error {
106
+ const message = error instanceof Error ? error.message : String(error);
107
+ const sanitized = new Error(redactSensitiveText(message));
108
+ if (error instanceof Error) {
109
+ sanitized.name = error.name;
110
+ if (error.stack) sanitized.stack = redactSensitiveText(error.stack);
111
+ const code = (error as { code?: unknown }).code;
112
+ if (typeof code === "string") Object.assign(sanitized, { code });
113
+ }
114
+ return sanitized;
115
+ }
116
+
117
+ function needsSanitization(error: unknown): boolean {
118
+ return error instanceof Error
119
+ && (error.cause !== undefined || Boolean(error.stack && redactSensitiveText(error.stack) !== error.stack));
120
+ }
121
+
122
+ function sanitizedError(error: unknown): Error {
123
+ const sanitized = sanitizedCause(error);
124
+ if (error instanceof Error && error.cause !== undefined) sanitized.cause = sanitizedCause(error.cause);
125
+ return sanitized;
126
+ }
127
+
105
128
  export function classifyAcpFailure(error: unknown): Error {
106
129
  if (isAntigravityAcpError(error)) {
107
130
  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 });
131
+ const cause = { cause: sanitizedCause(error) };
132
+ if (error.code === "auth") return new AcpFailure("auth", redactSensitiveText(appendHint(error.message, AUTH_RULE)), cause);
133
+ if (error.code === "quota") return new AcpFailure("quota", redactSensitiveText(appendHint(error.message, QUOTA_RULE)), cause);
134
+ if (error.code === "timeout") return new AcpFailure("timeout", redactSensitiveText(appendHint(error.message, TIMEOUT_RULE)), cause);
135
+ if (error.code === "spawn" || error.code === "process_exit") return new AcpFailure("transport", redactSensitiveText(appendHint(error.message, TRANSPORT_RULE)), cause);
136
+ if (error.code === "protocol" || error.code === "invalid_input") return new AcpFailure("protocol", redactSensitiveText(appendHint(error.message, PROTOCOL_RULE)), cause);
137
+ if (error.code === "model") return new AcpFailure("model", redactSensitiveText(error.message), cause);
114
138
  }
115
139
  const message = error instanceof Error ? error.message : String(error);
116
- if (!message.trim()) return error instanceof Error ? error : new Error(message);
140
+ if (!message.trim()) return needsSanitization(error) ? sanitizedError(error) : error instanceof Error ? error : new Error(message);
117
141
  for (const rule of RULES) {
118
- if (rule.match.test(message)) return new AcpFailure(rule.code, redactSensitiveText(appendHint(message, rule)), { cause: error });
142
+ if (rule.match.test(message)) {
143
+ return new AcpFailure(rule.code, redactSensitiveText(appendHint(message, rule)), { cause: sanitizedCause(error) });
144
+ }
119
145
  }
120
146
  const redacted = redactSensitiveText(message);
121
- if (redacted === message) return error instanceof Error ? error : new Error(message);
122
- return new Error(redacted);
147
+ const needs = needsSanitization(error);
148
+ if (redacted === message && !needs) return error instanceof Error ? error : new Error(message);
149
+ return redacted === message ? sanitizedError(error) : new Error(redacted);
123
150
  }
@@ -2,7 +2,9 @@ import fs from "node:fs";
2
2
  import path from "node:path";
3
3
  import { writeJsonAtomic } from "./fs-atomic.ts";
4
4
 
5
- export type AdapterPermissionMode = "default" | "auto_edit" | "yolo";
5
+ export type AdapterPermissionMode = "default" | "auto_edit" | "yolo" | "follow";
6
+ export type EffectivePermissionMode = Exclude<AdapterPermissionMode, "follow">;
7
+ export type OmpApprovalMode = "always-ask" | "always-ask-cached" | "write" | "yolo";
6
8
  export type AdapterRuntimeUpdateMode = "automatic" | "notify" | "manual";
7
9
  export type RuntimeSourcePreference = "auto" | "cli" | "managed";
8
10
  export type AdapterUsageMode = "auto" | "off";
@@ -26,7 +28,7 @@ export interface AdapterConfigSeed {
26
28
  }
27
29
 
28
30
  const DEFAULTS: AdapterConfig = {
29
- permissions: "yolo",
31
+ permissions: "follow",
30
32
  runtimeUpdates: "automatic",
31
33
  runtimeSource: "auto",
32
34
  nativeTools: "prefer",
@@ -52,7 +54,11 @@ export function loadAdapterConfig(file: string, seed: AdapterConfigSeed = {}): A
52
54
  } catch {
53
55
  return seeded(seed);
54
56
  }
55
- if (!parsed || typeof parsed !== "object") return seeded(seed);
57
+ return parseAdapterConfig(parsed, seed);
58
+ }
59
+
60
+ function parseAdapterConfig(parsed: unknown, seed: AdapterConfigSeed): AdapterConfig {
61
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return seeded(seed);
56
62
  const record = parsed as Record<string, unknown>;
57
63
  const runtimeSource = record.runtimeSource;
58
64
  if (runtimeSource !== undefined && runtimeSource !== "auto" && runtimeSource !== "cli" && runtimeSource !== "managed") {
@@ -71,7 +77,8 @@ export function loadAdapterConfig(file: string, seed: AdapterConfigSeed = {}): A
71
77
  throw new Error("diagnostics must be boolean");
72
78
  }
73
79
  return {
74
- permissions: record.permissions === "default" || record.permissions === "auto_edit" || record.permissions === "yolo"
80
+ permissions: record.permissions === "default" || record.permissions === "auto_edit"
81
+ || record.permissions === "yolo" || record.permissions === "follow"
75
82
  ? record.permissions : DEFAULTS.permissions,
76
83
  runtimeUpdates: record.runtimeUpdates === "automatic" || record.runtimeUpdates === "notify" || record.runtimeUpdates === "manual"
77
84
  ? record.runtimeUpdates : DEFAULTS.runtimeUpdates,
@@ -91,8 +98,19 @@ export function updateAdapterConfig(file: string, patch: Partial<AdapterConfig>)
91
98
  } catch {
92
99
  // A missing or malformed file starts from an empty object.
93
100
  }
94
- writeJsonAtomic(file, { ...raw, ...patch });
95
- return loadAdapterConfig(file);
101
+ const merged = { ...raw, ...patch };
102
+ const config = parseAdapterConfig(merged, {});
103
+ writeJsonAtomic(file, {
104
+ ...merged,
105
+ permissions: config.permissions,
106
+ runtimeUpdates: config.runtimeUpdates,
107
+ runtimeSource: config.runtimeSource,
108
+ nativeTools: config.nativeTools,
109
+ debugToolUpdates: config.debugToolUpdates,
110
+ usageMode: config.usageMode,
111
+ diagnostics: config.diagnostics,
112
+ });
113
+ return config;
96
114
  }
97
115
 
98
116
  export function saveAdapterPermissionMode(mode: AdapterPermissionMode, file: string): void {
@@ -102,3 +120,102 @@ export function saveAdapterPermissionMode(mode: AdapterPermissionMode, file: str
102
120
  export function loadRuntimeSourcePreference(stateDir: string): RuntimeSourcePreference {
103
121
  return loadAdapterConfig(path.join(stateDir, "config.json")).runtimeSource;
104
122
  }
123
+
124
+ const OMP_APPROVAL_MODES = new Set<OmpApprovalMode>(["always-ask", "always-ask-cached", "write", "yolo"]);
125
+
126
+ function yamlScalar(value: string): string {
127
+ const trimmed = value.trim();
128
+ if (trimmed.startsWith('"') || trimmed.startsWith("'")) {
129
+ const quote = trimmed[0]!;
130
+ const end = trimmed.lastIndexOf(quote);
131
+ if (end > 0) return trimmed.slice(1, end);
132
+ }
133
+ return trimmed.replace(/\s+#.*$/u, "").trim();
134
+ }
135
+
136
+ function approvalModeValue(value: string): OmpApprovalMode | undefined {
137
+ const parsed = yamlScalar(value);
138
+ return OMP_APPROVAL_MODES.has(parsed as OmpApprovalMode) ? parsed as OmpApprovalMode : undefined;
139
+ }
140
+
141
+ // OMP settings are YAML. Only `tools.approvalMode` is needed here, so a full
142
+ // YAML parser would add weight for one scalar. Nested keys at a deeper indent
143
+ // are ignored, and an unreadable or unknown value falls back to default.
144
+ function readApprovalMode(file: string): OmpApprovalMode | undefined {
145
+ let text: string;
146
+ try { text = fs.readFileSync(file, "utf8"); } catch { return undefined; }
147
+ let inTools = false;
148
+ let childIndent: number | undefined;
149
+ for (const raw of text.split(/\r?\n/u)) {
150
+ const line = raw.trimEnd();
151
+ if (!line.trim() || line.trimStart().startsWith("#")) continue;
152
+ const indent = line.length - line.trimStart().length;
153
+ const body = line.trim();
154
+ if (indent === 0) {
155
+ inTools = /^tools\s*:\s*(?:#.*)?$/u.test(body);
156
+ childIndent = undefined;
157
+ const inline = /^tools\s*:\s*\{(.*)\}\s*$/u.exec(body);
158
+ if (inline) {
159
+ for (const part of inline[1]!.split(",")) {
160
+ const match = /^\s*approvalMode\s*:\s*(.+?)\s*$/u.exec(part);
161
+ if (match) return approvalModeValue(match[1]!);
162
+ }
163
+ }
164
+ const dotted = /^tools\.approvalMode\s*:\s*(.+)$/u.exec(body);
165
+ if (dotted) return approvalModeValue(dotted[1]!);
166
+ continue;
167
+ }
168
+ if (!inTools) continue;
169
+ if (childIndent === undefined) childIndent = indent;
170
+ if (indent < childIndent) { inTools = false; continue; }
171
+ if (indent !== childIndent) continue;
172
+ const match = /^approvalMode\s*:\s*(.+)$/u.exec(body);
173
+ if (match) return approvalModeValue(match[1]!);
174
+ }
175
+ return undefined;
176
+ }
177
+
178
+ function approvalModeArg(argv: readonly string[]): OmpApprovalMode | undefined {
179
+ if (argv.includes("--auto-approve")) return "yolo";
180
+ for (let index = 0; index < argv.length; index++) {
181
+ const arg = argv[index]!;
182
+ const value = arg === "--approval-mode" ? argv[index + 1]
183
+ : arg.startsWith("--approval-mode=") ? arg.slice("--approval-mode=".length) : undefined;
184
+ if (value !== undefined) return OMP_APPROVAL_MODES.has(value as OmpApprovalMode) ? value as OmpApprovalMode : undefined;
185
+ }
186
+ return undefined;
187
+ }
188
+
189
+ /** Project-local OMP settings override the global agent config. */
190
+ export function readOmpApprovalMode(
191
+ agentDir: string,
192
+ cwd = process.cwd(),
193
+ argv: readonly string[] = process.argv,
194
+ ): OmpApprovalMode | undefined {
195
+ const override = approvalModeArg(argv);
196
+ if (override) return override;
197
+ let mode: OmpApprovalMode | undefined;
198
+ for (const file of [
199
+ path.join(agentDir, "config.yml"),
200
+ path.join(agentDir, "config.yaml"),
201
+ path.join(cwd, ".omp", "config.yml"),
202
+ path.join(cwd, ".omp", "config.yaml"),
203
+ ]) {
204
+ const next = readApprovalMode(file);
205
+ if (next) mode = next;
206
+ }
207
+ return mode;
208
+ }
209
+
210
+ export function resolveAdapterPermissionMode(
211
+ preference: AdapterPermissionMode,
212
+ agentDir: string,
213
+ cwd = process.cwd(),
214
+ ): EffectivePermissionMode {
215
+ if (preference !== "follow") return preference;
216
+ switch (readOmpApprovalMode(agentDir, cwd)) {
217
+ case "yolo": return "yolo";
218
+ case "write": return "auto_edit";
219
+ default: return "default";
220
+ }
221
+ }
@@ -99,7 +99,10 @@ function signalAgent(signal) {
99
99
  if (process.platform === "win32" && agent.pid) {
100
100
  const args = ["/PID", String(agent.pid), "/T"];
101
101
  if (signal === "SIGKILL") args.push("/F");
102
- spawn("taskkill", args, { stdio: "ignore", windowsHide: true });
102
+ const killer = spawn("taskkill", args, { stdio: "ignore", windowsHide: true });
103
+ killer.on("error", () => {
104
+ try { agent.kill(signal); } catch { /* The tree is already gone. */ }
105
+ });
103
106
  return;
104
107
  }
105
108
  if (agent.pid) process.kill(-agent.pid, signal);