omp-antigravity-acp-provider 0.1.32 → 0.1.33

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
@@ -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
+ }
@@ -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.values()],
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
  })),
@@ -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.5) + images * 4096;
90
+ return Math.ceil((text.length - nonAscii) / 3.6 + nonAscii * 1.1) + images * 1024;
91
91
  }