omp-antigravity-acp-provider 0.1.9 → 0.1.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,7 @@ The repository keeps the OMP adapter sources separately and installs upstream ve
19
19
 
20
20
  ## Status
21
21
 
22
- Version 0.1.9 supports all models advertised by the official ACP server. Tested with macOS, OMP 18.12.3, upstream provider 0.1.15 and official ACP runtime 1.4.1. Other platforms and OMP versions are not yet verified.
22
+ Version 0.1.11 supports all models advertised by the official ACP server. Tested with macOS, OMP 18.12.3, upstream provider 0.1.15 and official ACP runtime 1.4.1. Other platforms and OMP versions are not yet verified.
23
23
 
24
24
  Google's consumer-plan policies can restrict third-party agent access even through the official CLI or ACP executable. An official transport does not establish permission to use a subscription in OMP. Check the current [Antigravity FAQ](https://www.antigravity.google/docs/faq/) and [terms](https://antigravity.google/terms) for your account.
25
25
 
@@ -33,7 +33,7 @@ Google's consumer-plan policies can restrict third-party agent access even throu
33
33
  - Duplicate gray ACP tool-status lines are hidden by default, with an optional debug display switch. OMP tool calls/results and actual thought summaries remain visible.
34
34
  - Lazy ACP startup; model selection and cached listing do not launch the server.
35
35
  - Runtimes scoped to OMP sessions, including recovery after a planning session is disposed.
36
- - OAuth credentials owned by Antigravity; OMP stores only a non-secret marker.
36
+ - OMP `/login` support plus `/antigravity-acp login`, `logout` and `account` commands; OMP's `/logout` automatically finishes the Antigravity-side logout, including the macOS keychain entry the Antigravity server owns.
37
37
  - API-equivalent cost estimates, not subscription billing or quota measurements.
38
38
 
39
39
  ## Install from the OMP marketplace
@@ -56,7 +56,7 @@ Or, inside OMP:
56
56
 
57
57
  Select **omp-antigravity-acp-provider** in the browser, install it, and restart OMP to load the provider.
58
58
 
59
- OMP's marketplace installer currently copies Git content without installing npm dependencies. This marketplace therefore ships a small source launcher that retrieves the exact published **0.1.9** prebuilt npm adapter and production dependencies on first load. It disables npm install scripts, skips Pi CLI peer installation, and performs no local compilation. Node.js 22.19+ and npm must be on PATH. First preparation needs internet access and roughly **150 MiB** of disk space; later loads reuse the installed cache without npm network access.
59
+ OMP's marketplace installer currently copies Git content without installing npm dependencies. This marketplace therefore ships a small source launcher that retrieves the exact published **0.1.11** prebuilt npm adapter and production dependencies on first load. It disables npm install scripts, skips Pi CLI peer installation, and performs no local compilation. Node.js 22.19+ and npm must be on PATH. First preparation needs internet access and roughly **150 MiB** of disk space; later loads reuse the installed cache without npm network access.
60
60
 
61
61
  The launcher stores its versioned dependencies in `.runtime/` inside the installed marketplace plugin's cache directory. Uninstalling the marketplace plugin removes that cache when it is no longer referenced by another scope. Google credentials and the separately downloaded official ACP runtime are unaffected.
62
62
 
@@ -80,7 +80,7 @@ omp plugin install npm:omp-antigravity-acp-provider
80
80
  To pin a specific release:
81
81
 
82
82
  ```sh
83
- omp plugin install npm:omp-antigravity-acp-provider@0.1.9
83
+ omp plugin install npm:omp-antigravity-acp-provider@0.1.11
84
84
  ```
85
85
 
86
86
  Restart OMP after installation. The npm package includes the built adapter; users do not need esbuild or a manual build step. Disable any older ACP adapter for the same provider before loading this package.
@@ -137,6 +137,8 @@ This repository does not change an existing OMP installation or overwrite its se
137
137
  3. Run `/antigravity-acp refresh` to discover the models actually advertised for the account.
138
138
  4. Select a model with `/model` and use OMP's thinking control to select a supported effort.
139
139
 
140
+ `/antigravity-acp login` runs the same Google authorization through a command dialog without touching OMP's stored account record; use it to re-authenticate or switch the Antigravity-side Google account. `/antigravity-acp account` shows the current authentication state on both sides.
141
+
140
142
  First use or login may download the official runtime. The observed macOS runtime occupies about **383 MiB**; size varies by platform/version. It lives outside this repository under `~/.local/opt/agy-acp/`. Do not remove it while ACP processes are running.
141
143
 
142
144
  If OMP's `enabledModels` whitelist is configured, add `antigravity-acp/*` alongside your existing entries in `~/.omp/agent/config.yml` to allow newly discovered models. Use individual `antigravity-acp/<server-model-id>` entries instead if you prefer a restricted list. The adapter does not rewrite that whitelist or any model-role preset.
@@ -147,6 +149,9 @@ After upgrading from an older adapter, run `/antigravity-acp refresh` once to re
147
149
 
148
150
  | Command | Purpose |
149
151
  | --- | --- |
152
+ | `/antigravity-acp account` | Authentication state on both the OMP and Antigravity sides |
153
+ | `/antigravity-acp login` | Run the Antigravity Google authorization in a command dialog |
154
+ | `/antigravity-acp logout` | Clear Antigravity credentials, saved ACP sessions and OMP's marker record |
150
155
  | `/antigravity-acp status` | Runtime, confirmed thinking and usage information |
151
156
  | `/antigravity-acp usage` | Current ACP context occupancy, accounting source and cache-data availability |
152
157
  | `/antigravity-acp usage auto` | Enable supplemental usage queries |
@@ -170,6 +175,10 @@ After upgrading from an older adapter, run `/antigravity-acp refresh` once to re
170
175
 
171
176
  The initial permission mode follows upstream configuration, whose default is `yolo`. Native Antigravity tools have separate execution permissions from OMP tools.
172
177
 
178
+ ### Sign out
179
+
180
+ OMP's oauth contract has no provider-side logout hook, so `/logout` by itself only removes OMP's stored non-secret marker record. This adapter watches the credential store and finishes the Antigravity-side logout automatically: after `/logout` removes the marker, it closes this process's ACP runtimes, clears saved ACP session mappings, deletes the local token file and the settings auth choice, and removes the matching macOS keychain entry, then confirms with a notification. The cleanup waits for in-flight Antigravity requests to finish, a re-login before it runs cancels it, and automatic credential soft-disables (for example an expired refresh grant) never trigger it. Set `OMP_ACP_FOLLOW_LOGOUT=0` before starting OMP to keep OMP's `/logout` marker-only. `/antigravity-acp logout` performs the same complete logout in one command without waiting for OMP; it refuses to run while Antigravity requests are active. If its OMP-marker removal is unavailable through the host API, the command says so and OMP's `/logout` finishes that part.
181
+
173
182
  The debug switch controls gray `[Antigravity tool: …]` and `[Antigravity tool update: …]` lines. It defaults to off and applies immediately to this process's active ACP connections. Normal OMP tool displays/results, real thought chunks and plan messages are preserved. The option is saved as `debugToolUpdates` in `omp-tools.json` alongside `nativeTools`; toggling either option preserves the other. Existing policy files without the debug field default to off. Other OMP processes need a restart to read a setting changed elsewhere. `OMP_ACP_TRACE=1` is a separate, opt-in terminal diagnostic setting.
174
183
 
175
184
  ## OMP tool routing and native-tool mode
@@ -306,6 +315,8 @@ See the [0.1.8 context/compaction and usage benchmark](docs/context-compaction-0
306
315
 
307
316
  `npm run test:usage` uses Bun and mocked protocol responses to verify restored-session baselines, counter resets, query failures and advertised-command gating without starting ACP. `bun scripts/verify-continuity-live.ts --live` is a separate Flash-only probe of long history, synthetic tools, usage accounting and idle process reclamation/restoration; it consumes quota. Its one-second idle setting is isolated to the test process and is not the production default.
308
317
 
318
+ `npm run test:auth` uses Bun with an isolated `GEMINI_HOME`, a stubbed keychain and a stubbed OAuth flow to verify the account view, login dialog mapping, logout cleanup, the active-request guard and the credential-store watch behind OMP-logout following (removal, automatic-disable suppression, re-login cancellation, opt-out and busy deferral) without starting ACP. Real Google login and logout change account state, so they are not part of any automated test.
319
+
309
320
  `npm run test:packed` additionally requires OMP on PATH. It installs the exact npm tarball into a temporary consumer directory with development dependencies omitted and install scripts disabled, checks runtime assets, and loads its model catalog with ACP execution disabled. It downloads production dependencies and removes the temporary installation afterward.
310
321
 
311
322
  `npm run test:marketplace` exercises catalog discovery, installation, automatic provider loading, offline cache reuse and uninstallation in a temporary named OMP profile. It downloads the published adapter and cleans the entire test profile afterward. Add `-- --remote` after publishing catalog changes to test the GitHub source instead of the local working tree. No model inference is performed.
@@ -16,14 +16,62 @@ import { Type, createAntigravityProvider, AntigravityRuntime, PERMISSION_TOOL_NA
16
16
 
17
17
  const MARKER = "pi-antigravity-acp:managed-by-antigravity";
18
18
 
19
+ // macOS keychain operations behind one mutable object so offline command
20
+ // tests can substitute them without touching the user's real keychain.
21
+ export const keychain = {
22
+ // Check existence only. Never retrieve credentials from the keychain.
23
+ present(): boolean | undefined {
24
+ if (process.platform !== "darwin") return undefined;
25
+ try {
26
+ execFileSync("/usr/bin/security", ["find-generic-password", "-s", "gemini", "-a", "antigravity-acp"], { stdio: "ignore", timeout: 3000 });
27
+ return true;
28
+ } catch { return false; }
29
+ },
30
+ // Local logout for macOS keychain storage. The Antigravity server owns this
31
+ // item; removing it is required for a complete logout when no token file exists.
32
+ remove(): boolean | undefined {
33
+ if (process.platform !== "darwin") return undefined;
34
+ try {
35
+ execFileSync("/usr/bin/security", ["delete-generic-password", "-s", "gemini", "-a", "antigravity-acp"], { stdio: "ignore", timeout: 3000 });
36
+ return true;
37
+ } catch { return false; }
38
+ },
39
+ };
40
+
41
+ // Timing knobs for following OMP-side logouts; mutable so offline tests can
42
+ // run the delayed detection without real waits.
43
+ export const logoutFollow = { delayMs: 500, retryMs: 15_000 };
44
+
19
45
  function authReady() {
20
- if (hasAntigravityAuth()) return true;
21
- if (process.platform !== "darwin") return false;
46
+ return hasAntigravityAuth() || keychain.present() === true;
47
+ }
48
+
49
+ // OMP stores only the non-secret marker credential. Read it defensively:
50
+ // the model registry surface is host version dependent and absent in tests.
51
+ function ompCredentialSummary(ctx: any) {
52
+ try {
53
+ const stored = ctx?.modelRegistry?.authStorage?.credentials?.getOAuth?.("antigravity-acp");
54
+ if (!stored) return { present: false };
55
+ return {
56
+ present: true,
57
+ record: stored.refresh === MARKER ? "managed marker (non-secret)" : "oauth",
58
+ authorizedAt: typeof stored.authorizedAt === "number" ? new Date(stored.authorizedAt).toISOString() : undefined,
59
+ };
60
+ } catch (error: any) {
61
+ return { present: undefined, error: error instanceof Error ? error.message : String(error) };
62
+ }
63
+ }
64
+
65
+ // Removes OMP's stored marker record so one command completes the logout.
66
+ async function removeOmpCredentialRecord(ctx: any): Promise<"removed" | "absent" | "unavailable"> {
22
67
  try {
23
- // Check existence only. Never retrieve credentials from the keychain.
24
- execFileSync("/usr/bin/security", ["find-generic-password", "-s", "gemini", "-a", "antigravity-acp"], { stdio: "ignore", timeout: 3000 });
25
- return true;
26
- } catch { return false; }
68
+ const credentials = ctx?.modelRegistry?.authStorage?.credentials;
69
+ if (!credentials?.remove || !credentials.getOAuth) return "unavailable";
70
+ if (!credentials.getOAuth("antigravity-acp")) return "absent";
71
+ await credentials.remove("antigravity-acp");
72
+ try { await ctx.modelRegistry.refreshProvider?.("antigravity-acp", "online"); } catch { /* advisory only */ }
73
+ return "removed";
74
+ } catch { return "unavailable"; }
27
75
  }
28
76
 
29
77
  export default async function (pi: any) {
@@ -77,6 +125,80 @@ export async function registerOmpAdapter(pi: any, stateDir: string) {
77
125
  await runtimes.closeAll();
78
126
  }
79
127
  });
128
+ // OMP's oauth contract has no logout hook: /logout only removes the stored
129
+ // marker credential. Watching the credential store's generation counter lets
130
+ // this adapter finish the Antigravity-side logout when OMP reports removal.
131
+ let watchingCredentials = false;
132
+ let markerPresent: boolean | undefined;
133
+ let suppressFollow = false;
134
+ let selfLogout = false;
135
+ let followTimer: ReturnType<typeof setTimeout> | undefined;
136
+ let followRetry: ReturnType<typeof setTimeout> | undefined;
137
+ function ompMarkerStored(ctx: any): boolean | undefined {
138
+ try {
139
+ return Boolean(ctx?.modelRegistry?.authStorage?.credentials?.getOAuth?.("antigravity-acp"));
140
+ } catch { return undefined; }
141
+ }
142
+ async function finishFollowedLogout(ctx: any) {
143
+ if (runtimes.values().some(bundle => bundle.isBusy())) {
144
+ // Never interrupt an in-flight Antigravity request; retry once idle.
145
+ clearTimeout(followRetry);
146
+ followRetry = setTimeout(() => {
147
+ followRetry = undefined;
148
+ if (ompMarkerStored(ctx) === false) void finishFollowedLogout(ctx);
149
+ }, logoutFollow.retryMs);
150
+ followRetry.unref?.();
151
+ return;
152
+ }
153
+ runtimes.get();
154
+ await Promise.all(runtimes.values().map(bundle => bundle.runtime.logout()));
155
+ await runtimes.closeAll();
156
+ const keychainRemoved = keychain.remove();
157
+ const after = inspectAntigravityAuth();
158
+ try {
159
+ ctx?.ui?.notify?.([
160
+ "Antigravity ACP: finished the logout OMP started.",
161
+ `ACP auth after logout: ${after.status}${after.authType ? ` (${after.authType})` : ""}`,
162
+ `macOS keychain entry: ${keychainRemoved === undefined ? "not applicable (non-macOS)" : keychainRemoved ? "removed" : "not present or not removable"}`,
163
+ "Saved ACP sessions: cleared",
164
+ "Run /antigravity-acp login or OMP /login to sign in again.",
165
+ ].join("\n"), "info");
166
+ } catch { /* the host UI may already be gone */ }
167
+ }
168
+ function watchOmpCredentials(ctx: any) {
169
+ if (watchingCredentials) return;
170
+ const credentials = ctx?.modelRegistry?.authStorage?.credentials;
171
+ if (!credentials?.getOAuth || !credentials.onGeneration) return;
172
+ const initial = ompMarkerStored(ctx);
173
+ if (initial === undefined) return;
174
+ watchingCredentials = true;
175
+ markerPresent = initial;
176
+ // Automatic soft-disables (for example an invalid_grant refresh) must not
177
+ // destroy the Antigravity-side login. OMP emits credential_disabled for
178
+ // those, but not for user-initiated removals such as /logout.
179
+ pi.on("credential_disabled", (event: any) => {
180
+ if (event?.provider === "antigravity-acp") suppressFollow = true;
181
+ });
182
+ credentials.onGeneration(() => {
183
+ const current = ompMarkerStored(ctx);
184
+ if (current === undefined) return;
185
+ const wasPresent = markerPresent === true;
186
+ markerPresent = current;
187
+ if (current) suppressFollow = false;
188
+ if (!wasPresent || current || selfLogout) return;
189
+ clearTimeout(followTimer);
190
+ followTimer = setTimeout(() => {
191
+ followTimer = undefined;
192
+ if (process.env.OMP_ACP_FOLLOW_LOGOUT === "0") return;
193
+ if (suppressFollow) { suppressFollow = false; return; }
194
+ // A quick re-login after the removal cancels the cleanup.
195
+ if (ompMarkerStored(ctx) !== false) return;
196
+ void finishFollowedLogout(ctx);
197
+ }, logoutFollow.delayMs);
198
+ followTimer.unref?.();
199
+ });
200
+ }
201
+ pi.on("session_start", async (_event: any, ctx: any) => { watchOmpCredentials(ctx); });
80
202
  pi.registerTool({
81
203
  name: PERMISSION_TOOL_NAME,
82
204
  label: "Antigravity ACP Permission",
@@ -95,8 +217,9 @@ export async function registerOmpAdapter(pi: any, stateDir: string) {
95
217
  },
96
218
  });
97
219
  pi.registerCommand("antigravity-acp", {
98
- description: "Inspect ACP status/tools/usage/context/cleanup, configure budgets, toggle debug, refresh models or set tool policies",
220
+ description: "Inspect ACP status/account/tools/usage/context/cleanup, manage Antigravity login/logout, configure budgets, toggle debug, refresh models or set tool policies",
99
221
  async handler(args: string, ctx: any) {
222
+ watchOmpCredentials(ctx);
100
223
  const parts = args.trim().split(/\s+/);
101
224
  const [command, value] = parts;
102
225
  if (command === "cleanup") {
@@ -152,6 +275,73 @@ export async function registerOmpAdapter(pi: any, stateDir: string) {
152
275
  ctx.ui.notify(`Native tools: ${mode}. ACP connections will be recreated on the next request with the new policy.`, "info");
153
276
  return;
154
277
  }
278
+ if (command === "login") {
279
+ if (value) throw new Error("Usage: /antigravity-acp login");
280
+ await prepareRuntime();
281
+ // Direct Antigravity Google login through the command UI. OMP's /login
282
+ // runs the same flow and additionally stores the provider marker.
283
+ await runtimes.get().provider.auth.oauth.login({
284
+ signal: undefined,
285
+ notify(event: any) {
286
+ const link = event.links?.[0];
287
+ if (link) ctx.ui.notify(`${event.message ?? "Open this URL to authorize:"}\n${link.url}`, "info");
288
+ else if (event.message) ctx.ui.notify(event.message, "info");
289
+ },
290
+ prompt: async (request: any) => {
291
+ const answer = await ctx.ui.input(request.message, request.placeholder);
292
+ if (!answer?.trim()) throw new Error("Antigravity OAuth login cancelled");
293
+ return answer;
294
+ },
295
+ });
296
+ const auth = inspectAntigravityAuth();
297
+ ctx.ui.notify(`Antigravity Google login finished. ACP auth: ${auth.status}${auth.authType ? ` (${auth.authType})` : ""}.\nRun /antigravity-acp account to inspect the stored state, or OMP /login to also record the provider marker in OMP's account list.`, "info");
298
+ return;
299
+ }
300
+ if (command === "logout") {
301
+ if (value) throw new Error("Usage: /antigravity-acp logout");
302
+ if (runtimes.values().some(bundle => bundle.isBusy())) {
303
+ throw new Error("Wait for active Antigravity requests to finish before logging out.");
304
+ }
305
+ // Ensure a runtime (and its ACP session store) exists even before any request.
306
+ runtimes.get();
307
+ // runtime.logout() closes ACP connections, clears saved sessions and
308
+ // removes the local token file plus the settings auth choice.
309
+ await Promise.all(runtimes.values().map(bundle => bundle.runtime.logout()));
310
+ await runtimes.closeAll();
311
+ const keychainRemoved = keychain.remove();
312
+ // Removing the marker ourselves must not trigger the follow-up logout.
313
+ selfLogout = true;
314
+ let ompMarker: "removed" | "absent" | "unavailable";
315
+ try { ompMarker = await removeOmpCredentialRecord(ctx); } finally { selfLogout = false; }
316
+ const after = inspectAntigravityAuth();
317
+ ctx.ui.notify([
318
+ "Antigravity ACP logout",
319
+ `ACP auth after logout: ${after.status}${after.authType ? ` (${after.authType})` : ""}`,
320
+ `macOS keychain entry: ${keychainRemoved === undefined ? "not applicable (non-macOS)" : keychainRemoved ? "removed" : "not present or not removable"}`,
321
+ "Saved ACP sessions: cleared",
322
+ `OMP marker record: ${ompMarker === "removed" ? "removed" : ompMarker === "absent" ? "was not stored" : "could not be removed; run /logout to drop it"}`,
323
+ "Run /antigravity-acp login or OMP /login to sign in again.",
324
+ ].join("\n"), "info");
325
+ return;
326
+ }
327
+ if (command === "account") {
328
+ if (value) throw new Error("Usage: /antigravity-acp account");
329
+ const auth = inspectAntigravityAuth();
330
+ let ompSource: string | undefined;
331
+ try { ompSource = ctx?.modelRegistry?.authStorage?.keys?.describe?.("antigravity-acp", sessionIdOf(ctx)); } catch { /* host version dependent */ }
332
+ const snapshot = await runtimes.get(sessionIdOf(ctx)).runtime.snapshot();
333
+ ctx.ui.notify(JSON.stringify({
334
+ provider: "antigravity-acp",
335
+ ompCredential: ompCredentialSummary(ctx),
336
+ ompAuthSource: ompSource,
337
+ acpAuth: { status: auth.status, authType: auth.authType, tokenFile: auth.tokenFile, settingsFile: auth.settingsFile, usable: authReady() },
338
+ macOSKeychainEntry: keychain.present(),
339
+ savedAcpSessions: runtimes.get(sessionIdOf(ctx)).runtime.sessionStore?.read().length ?? 0,
340
+ runtime: { permissionMode: snapshot.permissionMode, activeSessions: snapshot.bindings },
341
+ note: "Google OAuth tokens stay in Antigravity-owned storage (~/.gemini/antigravity-acp or the macOS keychain). OMP stores only a non-secret marker. /antigravity-acp logout clears both sides in one command; OMP /logout also triggers the Antigravity-side cleanup automatically (set OMP_ACP_FOLLOW_LOGOUT=0 to disable).",
342
+ }, null, 2), "info");
343
+ return;
344
+ }
155
345
  const { runtime } = runtimes.get(sessionIdOf(ctx));
156
346
  if (command === "usage") {
157
347
  ctx.ui.notify(JSON.stringify({ configured: contextSettings.defaults.usageMode ?? "auto",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-antigravity-acp-provider",
3
- "version": "0.1.9",
3
+ "version": "0.1.11",
4
4
  "description": "Google Antigravity ACP provider for Oh My Pi (OMP), with tool bridging and per-model thinking; derived from zacbemis/pi-antigravity-acp-provider",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -39,7 +39,7 @@
39
39
  "test:packed": "node scripts/test-packed.mjs",
40
40
  "test:marketplace": "node scripts/test-marketplace.mjs",
41
41
  "test:commands": "bun scripts/test-tool-command.ts",
42
- "test:usage": "bun scripts/test-usage-command.ts",
42
+ "test:auth": "bun scripts/test-auth-command.ts",
43
43
  "test:cleanup": "node scripts/test-cleanup-runtime.ts",
44
44
  "check": "npm run build && npm test && npm run test:cleanup",
45
45
  "prepack": "npm run build",