omp-antigravity-acp-provider 0.1.32 → 0.1.34
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 +13 -0
- package/extension/acp-compaction.ts +122 -0
- package/extension/auth-sync.ts +17 -9
- package/extension/catalog-store.ts +11 -3
- package/extension/commands.ts +24 -12
- package/extension/context-settings.ts +1 -1
- package/extension/context-transfer.ts +465 -71
- package/extension/index.ts +38 -6
- package/extension/model-catalog.ts +5 -1
- package/extension/runtime.mjs +808 -147
- package/extension/session-cleanup.ts +91 -9
- package/extension/session-store.ts +52 -2
- package/extension/tier-connection.ts +75 -1
- package/extension/transcript-routing.ts +50 -0
- package/extension/turn-cancellation.ts +11 -1
- package/extension/usage-accounting.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,6 +115,19 @@ By default a new user message waits for the active ACP turn to finish (`OMP_ACP_
|
|
|
115
115
|
|
|
116
116
|
Inference and `/antigravity-acp refresh` refuse to start ACP when no local Google login is available; run `/login` (or `/antigravity-acp login`) first instead of waiting for an interactive consent flow inside `session/new`.
|
|
117
117
|
|
|
118
|
+
## Limitations vs direct OAuth
|
|
119
|
+
|
|
120
|
+
- No direct model API endpoint or reverse-proxy mode.
|
|
121
|
+
- No API-key, service-account, or raw OAuth-token authentication; Google browser consent is required.
|
|
122
|
+
- Only models advertised by the ACP server are available.
|
|
123
|
+
- Only thinking levels confirmed by the ACP server are selectable.
|
|
124
|
+
- No arbitrary generation controls: temperature, top_p, seed, stop sequences, tool_choice, response format, or output-token limit.
|
|
125
|
+
- No exact API billing or complete subagent usage; cost and quota figures are estimates.
|
|
126
|
+
- No guaranteed prompt-cache hits, cache discounts, or identical tokenization.
|
|
127
|
+
- No full native history or hidden reasoning across a cold rebuild; server-side compaction is outside adapter control.
|
|
128
|
+
- No per-tool native allowlist; `native-tools` supports only `prefer` and `disabled`, and global MCP servers remain.
|
|
129
|
+
- No standalone client; the official ACP runtime is required.
|
|
130
|
+
|
|
118
131
|
Detailed behavior, advanced settings and limitations: [docs/](docs/) and [CHANGELOG.md](CHANGELOG.md).
|
|
119
132
|
|
|
120
133
|
## License
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// ACP compaction is server-owned context maintenance. Keep its display state
|
|
2
|
+
// separate from OMP's transcript so a server summary never becomes fake
|
|
3
|
+
// assistant text or a second OMP compaction.
|
|
4
|
+
export type AcpCompactionStatus = string;
|
|
5
|
+
|
|
6
|
+
export interface AcpCompactionRecord {
|
|
7
|
+
sessionId: string;
|
|
8
|
+
compactionId: string;
|
|
9
|
+
status: AcpCompactionStatus;
|
|
10
|
+
summary: string;
|
|
11
|
+
error?: string;
|
|
12
|
+
updatedAt: number;
|
|
13
|
+
notified: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export interface AcpCompactionNotice {
|
|
17
|
+
sessionId: string;
|
|
18
|
+
compactionId: string;
|
|
19
|
+
status: AcpCompactionStatus;
|
|
20
|
+
summary: string;
|
|
21
|
+
error?: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface CompactionUpdateLike {
|
|
25
|
+
compactionId?: unknown;
|
|
26
|
+
status?: unknown;
|
|
27
|
+
summary?: unknown;
|
|
28
|
+
error?: unknown;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface CompactionChunkLike {
|
|
32
|
+
compactionId?: unknown;
|
|
33
|
+
content?: unknown;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function isTerminalCompaction(status: string): boolean {
|
|
37
|
+
return status === "completed" || status === "failed" || status === "cancelled";
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function contentText(content: unknown): string {
|
|
41
|
+
if (!Array.isArray(content)) return "";
|
|
42
|
+
const parts: string[] = [];
|
|
43
|
+
for (const block of content) {
|
|
44
|
+
if (!block || typeof block !== "object") continue;
|
|
45
|
+
const record = block as { type?: unknown; text?: unknown };
|
|
46
|
+
if (record.type === "text" && typeof record.text === "string") parts.push(record.text);
|
|
47
|
+
}
|
|
48
|
+
return parts.join("\n");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function compactionSummary(value: unknown): string | undefined {
|
|
52
|
+
if (value === undefined) return undefined;
|
|
53
|
+
if (value === null) return "";
|
|
54
|
+
return contentText(value);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export function applyCompactionUpdate(
|
|
58
|
+
previous: AcpCompactionRecord | undefined,
|
|
59
|
+
sessionId: string,
|
|
60
|
+
update: CompactionUpdateLike,
|
|
61
|
+
now = Date.now(),
|
|
62
|
+
): AcpCompactionRecord | undefined {
|
|
63
|
+
if (typeof update.compactionId !== "string" || !update.compactionId) return previous;
|
|
64
|
+
if (typeof update.status !== "string" || !update.status) return previous;
|
|
65
|
+
const summary = compactionSummary(update.summary);
|
|
66
|
+
const errorProvided = update.error === null || typeof update.error === "string";
|
|
67
|
+
const error = typeof update.error === "string" ? update.error : undefined;
|
|
68
|
+
return {
|
|
69
|
+
sessionId,
|
|
70
|
+
compactionId: update.compactionId,
|
|
71
|
+
status: update.status,
|
|
72
|
+
summary: summary === undefined ? previous?.summary ?? "" : summary,
|
|
73
|
+
...(errorProvided ? (error !== undefined ? { error } : {}) : previous?.error !== undefined ? { error: previous.error } : {}),
|
|
74
|
+
updatedAt: now,
|
|
75
|
+
notified: previous?.notified ?? false,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function applyCompactionChunk(
|
|
80
|
+
previous: AcpCompactionRecord | undefined,
|
|
81
|
+
sessionId: string,
|
|
82
|
+
chunk: CompactionChunkLike,
|
|
83
|
+
now = Date.now(),
|
|
84
|
+
): AcpCompactionRecord | undefined {
|
|
85
|
+
if (typeof chunk.compactionId !== "string" || !chunk.compactionId) return previous;
|
|
86
|
+
const text = contentText([chunk.content]);
|
|
87
|
+
if (!text) return previous;
|
|
88
|
+
return {
|
|
89
|
+
sessionId,
|
|
90
|
+
compactionId: chunk.compactionId,
|
|
91
|
+
status: previous?.status ?? "in_progress",
|
|
92
|
+
summary: (previous?.summary ?? "") + text,
|
|
93
|
+
...(previous?.error !== undefined ? { error: previous.error } : {}),
|
|
94
|
+
updatedAt: now,
|
|
95
|
+
notified: previous?.notified ?? false,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export function formatCompactionNotice(notice: AcpCompactionNotice): string {
|
|
100
|
+
const prefix = "Antigravity ACP";
|
|
101
|
+
if (notice.status === "completed") {
|
|
102
|
+
const summary = notice.summary.trim();
|
|
103
|
+
const preview = summary.length > 320 ? `${summary.slice(0, 317)}...` : summary;
|
|
104
|
+
return `${prefix} compacted its context${preview ? `: ${preview}` : "."} OMP history was retained.`;
|
|
105
|
+
}
|
|
106
|
+
if (notice.status === "failed") {
|
|
107
|
+
return `${prefix} compaction failed${notice.error ? `: ${notice.error}` : "."} OMP history was retained.`;
|
|
108
|
+
}
|
|
109
|
+
if (notice.status === "cancelled") return `${prefix} compaction was cancelled. OMP history was retained.`;
|
|
110
|
+
return `${prefix} compaction status: ${notice.status}.`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// OMP compacts against its own model.contextWindow. ACP reports the server's
|
|
114
|
+
// actual window in usage_update.size, so normalize the occupancy before OMP's
|
|
115
|
+
// 85% decision. Without both values, preserve the raw server count.
|
|
116
|
+
export function alignContextTokens(used: number, size: number, ompContextWindow?: number): number {
|
|
117
|
+
if (!Number.isSafeInteger(used) || used < 0) return used;
|
|
118
|
+
if (!Number.isSafeInteger(size) || size <= 0) return used;
|
|
119
|
+
if (!Number.isSafeInteger(ompContextWindow) || ompContextWindow === undefined || ompContextWindow <= 0) return used;
|
|
120
|
+
const scaled = Math.round((used / size) * ompContextWindow);
|
|
121
|
+
return Number.isSafeInteger(scaled) && scaled >= 0 ? scaled : used;
|
|
122
|
+
}
|
package/extension/auth-sync.ts
CHANGED
|
@@ -167,6 +167,7 @@ export interface AuthCoordinatorDeps {
|
|
|
167
167
|
// this adapter finish the Antigravity-side logout when OMP reports removal.
|
|
168
168
|
export class OmpAuthCoordinator {
|
|
169
169
|
private watchingCredentials = false;
|
|
170
|
+
private activeContext: OmpCommandContext | undefined;
|
|
170
171
|
private markerPresent: boolean | undefined;
|
|
171
172
|
private suppressFollow = false;
|
|
172
173
|
private selfLogout = false;
|
|
@@ -268,12 +269,14 @@ export class OmpAuthCoordinator {
|
|
|
268
269
|
}
|
|
269
270
|
|
|
270
271
|
private async finishFollowedLogout(ctx: OmpCommandContext): Promise<void> {
|
|
272
|
+
const activeCtx = this.activeContext ?? ctx;
|
|
271
273
|
if (this.deps.isPoolBusy()) {
|
|
272
274
|
// Never interrupt an in-flight Antigravity request; retry once idle.
|
|
273
275
|
clearTimeout(this.followRetry);
|
|
274
276
|
this.followRetry = setTimeout(() => {
|
|
275
277
|
this.followRetry = undefined;
|
|
276
|
-
|
|
278
|
+
const currentCtx = this.activeContext ?? activeCtx;
|
|
279
|
+
if (this.ompMarkerStored(currentCtx) === false) this.runFollowedLogout(currentCtx);
|
|
277
280
|
}, logoutFollow.retryMs);
|
|
278
281
|
this.followRetry.unref?.();
|
|
279
282
|
return;
|
|
@@ -282,27 +285,30 @@ export class OmpAuthCoordinator {
|
|
|
282
285
|
await this.deps.closeAllRuntimes();
|
|
283
286
|
// A quick re-login can restore the marker while the steps above await;
|
|
284
287
|
// a restored or unknown marker keeps the new keychain entry untouched.
|
|
285
|
-
if (this.ompMarkerStored(
|
|
288
|
+
if (this.ompMarkerStored(this.activeContext ?? activeCtx) !== false) return;
|
|
286
289
|
const keychainRemoved = await this.removeKeychainCredentialDurably();
|
|
287
290
|
// Keep the confirmation terse; /antigravity-acp account shows the details.
|
|
288
291
|
try {
|
|
289
|
-
|
|
292
|
+
(this.activeContext ?? activeCtx)?.ui?.notify?.(formatLogoutSummary({ keychainRemoved, followed: true }), "info");
|
|
290
293
|
} catch { /* the host UI may already be gone */ }
|
|
291
294
|
}
|
|
292
295
|
|
|
293
296
|
// The follow-up runs detached from timer callbacks; a failure must not
|
|
294
297
|
// become an unhandled rejection, and the notice stays credential-free.
|
|
295
298
|
private runFollowedLogout(ctx: OmpCommandContext): void {
|
|
296
|
-
|
|
299
|
+
const activeCtx = this.activeContext ?? ctx;
|
|
300
|
+
void this.finishFollowedLogout(activeCtx).catch(() => {
|
|
297
301
|
try {
|
|
298
|
-
|
|
302
|
+
(this.activeContext ?? activeCtx)?.ui?.notify?.("Antigravity ACP: the logout OMP started could not be finished. Run /antigravity-acp logout to retry.", "error");
|
|
299
303
|
} catch { /* the host UI may already be gone */ }
|
|
300
304
|
});
|
|
301
305
|
}
|
|
302
306
|
|
|
303
307
|
watchOmpCredentials(ctx: OmpCommandContext | undefined): void {
|
|
304
|
-
if (
|
|
308
|
+
if (!ctx) return;
|
|
305
309
|
const credentials = ctx.modelRegistry?.authStorage?.credentials;
|
|
310
|
+
if (credentials?.getOAuth && credentials.onGeneration) this.activeContext = ctx;
|
|
311
|
+
if (this.watchingCredentials) return;
|
|
306
312
|
if (!credentials?.getOAuth || !credentials.onGeneration) return;
|
|
307
313
|
const initial = this.ompMarkerStored(ctx);
|
|
308
314
|
if (initial === undefined) return;
|
|
@@ -317,7 +323,8 @@ export class OmpAuthCoordinator {
|
|
|
317
323
|
}
|
|
318
324
|
});
|
|
319
325
|
credentials.onGeneration(() => {
|
|
320
|
-
const
|
|
326
|
+
const activeCtx = this.activeContext ?? ctx;
|
|
327
|
+
const current = this.ompMarkerStored(activeCtx);
|
|
321
328
|
if (current === undefined) return;
|
|
322
329
|
const wasPresent = this.markerPresent === true;
|
|
323
330
|
this.markerPresent = current;
|
|
@@ -342,12 +349,13 @@ export class OmpAuthCoordinator {
|
|
|
342
349
|
return;
|
|
343
350
|
}
|
|
344
351
|
// A quick re-login after the removal cancels the cleanup.
|
|
345
|
-
|
|
352
|
+
const currentCtx = this.activeContext ?? activeCtx;
|
|
353
|
+
if (this.ompMarkerStored(currentCtx) !== false) {
|
|
346
354
|
this.apiKeyFallback = true;
|
|
347
355
|
this.deps.onSyncProvider();
|
|
348
356
|
return;
|
|
349
357
|
}
|
|
350
|
-
this.runFollowedLogout(
|
|
358
|
+
this.runFollowedLogout(currentCtx);
|
|
351
359
|
}, logoutFollow.delayMs);
|
|
352
360
|
this.followTimer.unref?.();
|
|
353
361
|
});
|
|
@@ -26,6 +26,8 @@ export class CatalogStore {
|
|
|
26
26
|
private readonly prepareRuntime: () => Promise<void>,
|
|
27
27
|
private readonly fallbackModels: () => PublicCatalogModel[],
|
|
28
28
|
private readonly requireAuth: () => Promise<void> = async () => {},
|
|
29
|
+
private readonly createConnection: (options: ConstructorParameters<typeof TierConnection>[0]) => TierConnection =
|
|
30
|
+
options => new TierConnection(options),
|
|
29
31
|
) {}
|
|
30
32
|
|
|
31
33
|
projectWithSettings(models: PublicCatalogModel[], settings: ContextSettings): ConfiguredCatalogModel[] {
|
|
@@ -111,7 +113,7 @@ export class CatalogStore {
|
|
|
111
113
|
private async discoverOnce(): Promise<AdvertisedModel[]> {
|
|
112
114
|
await this.requireAuth();
|
|
113
115
|
await this.prepareRuntime();
|
|
114
|
-
const connection =
|
|
116
|
+
const connection = this.createConnection({ cwd: process.cwd(), ompCleanup: this.cleanup });
|
|
115
117
|
let discoveredSession: string | undefined;
|
|
116
118
|
try {
|
|
117
119
|
await connection.initialize();
|
|
@@ -123,9 +125,15 @@ export class CatalogStore {
|
|
|
123
125
|
for (const option of modern) {
|
|
124
126
|
// Model changes can alter reasoning choices; inspect each model's
|
|
125
127
|
// confirmed configuration rather than sharing one global tier list.
|
|
126
|
-
|
|
127
|
-
|
|
128
|
+
try {
|
|
129
|
+
await connection.setModel(session.sessionId, option.value);
|
|
130
|
+
models.push(advertisedRecord(connection.getSessionState(session.sessionId), option.value, option.name));
|
|
131
|
+
} catch {
|
|
132
|
+
// An advertised preview/retired model can reject selection without
|
|
133
|
+
// making the remaining models unusable.
|
|
134
|
+
}
|
|
128
135
|
}
|
|
136
|
+
if (!models.length) throw new Error("Antigravity advertised models but none could be selected");
|
|
129
137
|
return models;
|
|
130
138
|
}
|
|
131
139
|
const models = readModels(session.models?.availableModels);
|
package/extension/commands.ts
CHANGED
|
@@ -257,7 +257,13 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
257
257
|
configured: currentSettings.defaults.usageMode ?? "auto",
|
|
258
258
|
effective: process.env.OMP_ACP_USAGE === "off" ? "off" : currentSettings.defaults.usageMode ?? "auto",
|
|
259
259
|
connections: [...deps.connections].map(connection => ({
|
|
260
|
-
context: [...connection.contextUsage.
|
|
260
|
+
context: [...connection.contextUsage].map(([sessionId, usage]) => ({
|
|
261
|
+
sessionId,
|
|
262
|
+
...usage,
|
|
263
|
+
ompContextWindow: connection.getOmpContextWindow?.(sessionId),
|
|
264
|
+
})),
|
|
265
|
+
compactions: [...connection.compactions].flatMap(([sessionId, records]) =>
|
|
266
|
+
[...records.values()].map(record => ({ sessionId, ...record }))),
|
|
261
267
|
accounting: [...connection.usageStatus.values()],
|
|
262
268
|
activePrompts: connection.activePrompts,
|
|
263
269
|
})),
|
|
@@ -291,17 +297,23 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
291
297
|
|
|
292
298
|
// Only the tools inspection and the status display below need a live
|
|
293
299
|
// runtime; every earlier command runs without one.
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
const lease = deps.acquireRuntimeForSession
|
|
301
|
+
? deps.acquireRuntimeForSession(sessionIdOf(ctx))
|
|
302
|
+
: { value: deps.getRuntimeForSession(sessionIdOf(ctx)), release: () => {} };
|
|
303
|
+
try {
|
|
304
|
+
const snapshot = await lease.value.runtime.snapshot();
|
|
305
|
+
if (command === "tools") {
|
|
306
|
+
const lastToolAudit = deps.getLastToolAudit();
|
|
307
|
+
ctx.ui.notify(lastToolAudit
|
|
308
|
+
? `OMP ACP tool bridge\nAvailable: ${lastToolAudit.available.join(", ")}\nOmitted: ${JSON.stringify(lastToolAudit.omitted)}\nLive ACP checks: ${JSON.stringify(snapshot.processes.map(item => ({ mcpHttp: item.mcpHttp, omittedTools: item.omittedTools })))}`
|
|
309
|
+
: "No model request yet. Send a message with this ACP model to inspect its offered OMP tools.", "info");
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
303
312
|
|
|
304
|
-
|
|
305
|
-
|
|
313
|
+
const policy = deps.getToolPolicy();
|
|
314
|
+
ctx.ui.notify(`Antigravity ACP (OMP adapter)\nAuth storage: ${(await authReady()) ? "configured (ACP-owned token file or macOS keychain)" : inspectAntigravityAuth().status}\nPermissions: ${snapshot.permissionMode}\nNative tools: ${policy.nativeTools}\nDebug tool updates: ${policy.debugToolUpdates ? "on" : "off"}\nTool routing: ${JSON.stringify([...deps.connections].map(connection => connection.toolRouting).filter(Boolean))}\nActive sessions: ${snapshot.bindings}\nConfirmed thinking: ${JSON.stringify([...deps.connections].map(connection => connection.confirmedThinking).filter(Boolean))}\nUsage: ${JSON.stringify(snapshot.metrics)}\n${JSON.stringify(snapshot.processes)}`, "info");
|
|
315
|
+
} finally {
|
|
316
|
+
lease.release();
|
|
317
|
+
}
|
|
306
318
|
};
|
|
307
319
|
}
|
|
@@ -87,5 +87,5 @@ export function resolveContextOptions(model: { id: string; contextWindow: number
|
|
|
87
87
|
// confuse payload bytes with tokens. Non-ASCII receives a larger allowance.
|
|
88
88
|
export function estimateTransferTokens(text: string, images = 0, utf8Bytes = Buffer.byteLength(text, "utf8")) {
|
|
89
89
|
const nonAscii = Math.min(text.length, Math.ceil((utf8Bytes - text.length) / 2));
|
|
90
|
-
return Math.ceil((text.length - nonAscii) / 3 + nonAscii * 1.
|
|
90
|
+
return Math.ceil((text.length - nonAscii) / 3.6 + nonAscii * 1.1) + images * 1024;
|
|
91
91
|
}
|