omp-antigravity-acp-provider 0.1.41 → 0.1.43
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 +51 -14
- package/extension/acp-errors.ts +1 -0
- package/extension/acp-runtime-source.ts +63 -3
- package/extension/commands.ts +276 -54
- package/extension/context-transfer.ts +79 -15
- package/extension/diagnostics.ts +11 -2
- package/extension/index.ts +66 -21
- package/extension/omp-context.ts +3 -0
- package/extension/omp-session-lifecycle.ts +13 -4
- package/extension/runtime.mjs +400 -65
- package/extension/session-store.ts +12 -4
- package/extension/tier-connection.ts +65 -7
- package/extension/tool-relay.ts +5 -1
- package/extension/transcript-routing.ts +303 -29
- package/extension/usage-accounting.ts +100 -0
- package/extension/usage.ts +15 -2
- package/package.json +9 -6
package/README.md
CHANGED
|
@@ -118,23 +118,60 @@ Permission IDs differ between the channels. Managed ACP 1.4.5 supports `default`
|
|
|
118
118
|
|
|
119
119
|
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.
|
|
120
120
|
|
|
121
|
+
### Context occupancy and compaction
|
|
122
|
+
|
|
123
|
+
ACP may report live occupancy with `usage_update`. When it does, the adapter forwards that server value. When a runtime (for example CLI ACP 1.5.4) reports only cumulative billable usage, the adapter estimates the full OMP context from the system prompt, retained messages and tool schemas with `estimateTransferTokens`, then sets `usage.contextTokens` and marks `contextTokensSource: "estimate"`. The billable `input`, `cacheRead` and `output` counters are left untouched.
|
|
124
|
+
|
|
125
|
+
The estimate is a heuristic, not a server measurement. Managed ACP remains preferable when exact occupancy matters. In this source checkout, `scripts/with-managed-context.sh` starts OMP with the installed managed binary while preserving an explicit `AGY_ACP_BIN`. Run `/antigravity-acp refresh` afterward to inspect the models that runtime actually advertises.
|
|
126
|
+
|
|
127
|
+
Keep `compaction.autoContinue` enabled for normal long-running work. The false context rollover was fixed at the occupancy signal, not by disabling automatic continuation.
|
|
128
|
+
|
|
121
129
|
## Commands
|
|
122
130
|
|
|
123
|
-
|
|
131
|
+
Use the `/antigravity-acp ` prefix once, followed by a row below. For example, `status` means `/antigravity-acp status`.
|
|
132
|
+
|
|
133
|
+
### Common operations
|
|
134
|
+
|
|
135
|
+
| Subcommand | Purpose |
|
|
136
|
+
| --- | --- |
|
|
137
|
+
| *(none)* or `status` | Show login readiness, negotiated runtime/native channel when available, permission policy, native tools, non-empty usage records and active sessions. Requested and wire permissions share one row when they differ. Empty process details are omitted; runtime/API warnings remain visible. |
|
|
138
|
+
| `account` | Show the signed-in account, ACP authentication and non-secret OMP marker. Token ownership, logout behavior and account/store inconsistencies are not hidden. |
|
|
139
|
+
| `login` | Start a fresh Google authorization. |
|
|
140
|
+
| `logout` | Clear Antigravity credentials, saved sessions and the OMP marker. |
|
|
141
|
+
| `quota` | Query live quota and print one model heading with one remaining/reset row per quota window. Query failures are reported explicitly. |
|
|
142
|
+
| `refresh` | Discover and cache advertised models, then list the refreshed IDs. |
|
|
143
|
+
| `usage` | Show configured → effective supplemental-query mode (`OMP_ACP_USAGE=off` forces `off`) and only populated per-connection context, compaction and accounting details. |
|
|
144
|
+
| `usage auto` | Query supplemental usage after each reply. Context occupancy updates remain enabled. |
|
|
145
|
+
| `usage off` | Skip supplemental queries without disabling context occupancy updates. |
|
|
146
|
+
|
|
147
|
+
Quota results use a separate short-lived ACP session and a 60-second cache. When the adapter selects a CLI automatically, this read-only query uses managed ACP instead, which supports the quota command. An explicit `AGY_ACP_BIN` remains authoritative. If that runtime does not advertise `usage`, the adapter reports the limitation without sending a model prompt. The quota display excludes usage counters for that temporary session.
|
|
148
|
+
|
|
149
|
+
### Advanced maintenance
|
|
150
|
+
|
|
151
|
+
| Subcommand and options | Purpose |
|
|
124
152
|
| --- | --- |
|
|
125
|
-
|
|
|
126
|
-
|
|
|
127
|
-
|
|
|
128
|
-
|
|
|
129
|
-
|
|
|
130
|
-
|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
133
|
-
|
|
|
134
|
-
|
|
|
135
|
-
|
|
|
136
|
-
|
|
|
137
|
-
|
|
|
153
|
+
| `tools` | Inspect offered/available OMP tools, every omission reason and live MCP capability checks. |
|
|
154
|
+
| `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. |
|
|
155
|
+
| `context set default KEY NUMBER` | Change a shared numeric context setting. |
|
|
156
|
+
| `context set MODEL KEY NUMBER` | Change one model override. Reselect the model or restart OMP to refresh its displayed limits. |
|
|
157
|
+
| `context set default usageMode auto\|off` | Equivalent to `usage auto\|off`. |
|
|
158
|
+
| `cleanup` | Collect using the saved policy and show its mode, retention, non-empty session counts, actual removals, warnings and state-loss risk. |
|
|
159
|
+
| `cleanup off` | Keep every saved session. |
|
|
160
|
+
| `cleanup conservative` | Remove only eligible idle, unmapped sessions while preserving mapped history and live leases. |
|
|
161
|
+
| `cleanup timeout [DAYS]` | Apply timeout collection, optionally with a custom idle retention in days. |
|
|
162
|
+
| `cleanup balanced [DAYS]` | Apply timeout and soft-budget cleanup with recovery protection, optionally with custom idle days. |
|
|
163
|
+
| `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. |
|
|
164
|
+
| `diagnostics` | Show collection state and non-empty samples as count/median/max per stage. |
|
|
165
|
+
| `diagnostics on\|off` | Enable or disable bounded local timing collection. |
|
|
166
|
+
| `diagnostics reset` | Clear collected samples without changing the enabled state. |
|
|
167
|
+
| `debug on\|off` | Toggle raw ACP tool-status lines; normal tool results and thought summaries are preserved. |
|
|
168
|
+
| `native-tools prefer` | Let OMP tools shadow matching ACP-native tools. |
|
|
169
|
+
| `native-tools disabled` | Disable ACP-native built-ins for strict OMP-tool sessions while retaining MCP configuration; connections are recreated on the next request. |
|
|
170
|
+
| `permissions default` | Confirm edits and commands. |
|
|
171
|
+
| `permissions auto-edit` | Auto-accept edits. |
|
|
172
|
+
| `permissions yolo` | Auto-accept everything; changing modes recreates runtimes to avoid reusing an unsafe process. |
|
|
173
|
+
|
|
174
|
+
Context `KEY` is one of `contextWindow`, `maxTokens`, `inputTokenBudget`, `reserveTokens`, `maxTransferBytes` or `maxImageBytes`.
|
|
138
175
|
|
|
139
176
|
The OMP input autocompletes this command. Type `/antigravity-acp ` to list the subcommands, and keep typing to filter them. Fixed values such as `permissions` modes and `context set` targets (default plus the cached model IDs) complete the same way.
|
|
140
177
|
|
package/extension/acp-errors.ts
CHANGED
|
@@ -104,6 +104,7 @@ export function classifyAcpFailure(error: unknown): Error {
|
|
|
104
104
|
if (isAntigravityAcpError(error)) {
|
|
105
105
|
if (error.code === "aborted") return error;
|
|
106
106
|
if (error.code === "auth") return new AcpFailure("auth", appendHint(error.message, AUTH_RULE), { cause: error });
|
|
107
|
+
if (error.code === "quota") return new AcpFailure("quota", appendHint(error.message, QUOTA_RULE), { cause: error });
|
|
107
108
|
if (error.code === "timeout") return new AcpFailure("timeout", appendHint(error.message, TIMEOUT_RULE), { cause: error });
|
|
108
109
|
if (error.code === "spawn" || error.code === "process_exit") return new AcpFailure("transport", appendHint(error.message, TRANSPORT_RULE), { cause: error });
|
|
109
110
|
if (error.code === "invalid_input") return new AcpFailure("protocol", appendHint(error.message, PROTOCOL_RULE), { cause: error });
|
|
@@ -48,11 +48,33 @@ export function resolveAcpPermissionProfile(
|
|
|
48
48
|
};
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
export function resolveManagedAcpCommand(
|
|
52
|
+
home = os.homedir(), platform: NodeJS.Platform = process.platform,
|
|
53
|
+
): { command: string; args: string[] } | undefined {
|
|
54
|
+
const root = path.join(home, ".local", "opt", "agy-acp", "current");
|
|
55
|
+
for (const name of ["agy_acp_server.par", "agy_acp_server.exe"]) {
|
|
56
|
+
const command = path.join(root, name);
|
|
57
|
+
if (isExecutableFile(command)) return { command, args: platform === "linux" ? ["--uid="] : [] };
|
|
58
|
+
}
|
|
59
|
+
return undefined;
|
|
60
|
+
}
|
|
61
|
+
|
|
51
62
|
export function assertSelectedAcpCliLaunch(
|
|
52
63
|
stateDir: string,
|
|
53
64
|
preference: AcpRuntimePreference | undefined,
|
|
54
65
|
env: NodeJS.ProcessEnv = process.env,
|
|
55
|
-
|
|
66
|
+
purpose: "inference" | "quota" = "inference",
|
|
67
|
+
home = os.homedir(),
|
|
68
|
+
): { command: string; args: string[] } | undefined {
|
|
69
|
+
const automaticWrapper = path.join(stateDir, "agy-acp-cli.sh");
|
|
70
|
+
const configured = env.AGY_ACP_BIN?.trim();
|
|
71
|
+
if (purpose === "quota" && configured && path.resolve(configured) !== path.resolve(automaticWrapper)) return undefined;
|
|
72
|
+
if (purpose === "quota") {
|
|
73
|
+
const managed = resolveManagedAcpCommand(home);
|
|
74
|
+
if (!managed) throw new Error("Managed ACP binary is missing or not executable for quota");
|
|
75
|
+
env.AGY_ACP_BIN = managed.command;
|
|
76
|
+
return managed;
|
|
77
|
+
}
|
|
56
78
|
if (preference?.source !== "cli") return;
|
|
57
79
|
const wrapper = path.join(stateDir, "agy-acp-cli.sh");
|
|
58
80
|
let intact = false;
|
|
@@ -71,16 +93,34 @@ export async function preferNewestAcpRuntime(
|
|
|
71
93
|
env: NodeJS.ProcessEnv = process.env,
|
|
72
94
|
home = os.homedir(),
|
|
73
95
|
): Promise<AcpRuntimePreference> {
|
|
74
|
-
|
|
96
|
+
const wrapper = path.join(stateDir, "agy-acp-cli.sh");
|
|
97
|
+
const configured = env.AGY_ACP_BIN?.trim();
|
|
98
|
+
// A wrapper written by this adapter is not a user override. A second
|
|
99
|
+
// extension instance can see the first instance's AGY_ACP_BIN and must
|
|
100
|
+
// recover the CLI profile instead of treating it as an explicit env runtime.
|
|
101
|
+
if (configured && path.resolve(configured) === path.resolve(wrapper)) {
|
|
102
|
+
const cli = await findAgyCli(env);
|
|
103
|
+
if (cli) {
|
|
104
|
+
const preference = { source: "cli", cliPath: cli.path, cliVersion: cli.version, managedVersion: readManagedVersion(home) } as const;
|
|
105
|
+
writeCliWrapper(wrapper, cli.path);
|
|
106
|
+
writeRuntimeSourceRecord(stateDir, preference);
|
|
107
|
+
env.AGY_ACP_BIN = wrapper;
|
|
108
|
+
return preference;
|
|
109
|
+
}
|
|
110
|
+
const recorded = readRuntimeSourceRecord(stateDir);
|
|
111
|
+
if (recorded) return recorded;
|
|
112
|
+
} else if (configured) {
|
|
113
|
+
return { source: "env" };
|
|
114
|
+
}
|
|
75
115
|
// The generated wrapper is a POSIX shell script that upstream launches
|
|
76
116
|
// directly; Windows cannot execute it, so it stays managed-only there.
|
|
77
117
|
if (process.platform === "win32") return { source: "managed" };
|
|
78
118
|
const cli = await findAgyCli(env);
|
|
79
119
|
const managedVersion = readManagedVersion(home);
|
|
80
120
|
if (!cli || (managedVersion && compareVersions(cli.version, managedVersion) <= 0)) {
|
|
121
|
+
if (configured) delete env.AGY_ACP_BIN;
|
|
81
122
|
return { source: "managed", cliPath: cli?.path, cliVersion: cli?.version, managedVersion };
|
|
82
123
|
}
|
|
83
|
-
const wrapper = path.join(stateDir, "agy-acp-cli.sh");
|
|
84
124
|
const preference = { source: "cli", cliPath: cli.path, cliVersion: cli.version, managedVersion } as const;
|
|
85
125
|
writeCliWrapper(wrapper, cli.path);
|
|
86
126
|
writeRuntimeSourceRecord(stateDir, preference);
|
|
@@ -88,6 +128,26 @@ export async function preferNewestAcpRuntime(
|
|
|
88
128
|
return preference;
|
|
89
129
|
}
|
|
90
130
|
|
|
131
|
+
function readRuntimeSourceRecord(stateDir: string): AcpRuntimePreference | undefined {
|
|
132
|
+
try {
|
|
133
|
+
const value = JSON.parse(fs.readFileSync(path.join(stateDir, "acp-runtime-source.json"), "utf8")) as {
|
|
134
|
+
source?: unknown;
|
|
135
|
+
cliPath?: unknown;
|
|
136
|
+
cliVersion?: unknown;
|
|
137
|
+
managedVersion?: unknown;
|
|
138
|
+
};
|
|
139
|
+
if (value.source !== "cli" || typeof value.cliPath !== "string" || typeof value.cliVersion !== "string") return undefined;
|
|
140
|
+
return {
|
|
141
|
+
source: "cli",
|
|
142
|
+
cliPath: value.cliPath,
|
|
143
|
+
cliVersion: value.cliVersion,
|
|
144
|
+
...(typeof value.managedVersion === "string" ? { managedVersion: value.managedVersion } : {}),
|
|
145
|
+
};
|
|
146
|
+
} catch {
|
|
147
|
+
return undefined;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
|
|
91
151
|
async function findAgyCli(env: NodeJS.ProcessEnv): Promise<{ path: string; version: string } | undefined> {
|
|
92
152
|
const agy = findExecutableOnPath("agy", env) ?? findExecutableOnPath("agy.exe", env);
|
|
93
153
|
if (!agy) return undefined;
|
package/extension/commands.ts
CHANGED
|
@@ -7,17 +7,26 @@ import type { CatalogStore, ConfiguredCatalogModel } from "./catalog-store.ts";
|
|
|
7
7
|
import type { SessionCleanup, CleanupMode } from "./session-cleanup.ts";
|
|
8
8
|
import type { Diagnostics } from "./diagnostics.ts";
|
|
9
9
|
import type { TierConnection } from "./tier-connection.ts";
|
|
10
|
+
import type { AntigravityQuotaSnapshot } from "./usage-accounting.ts";
|
|
10
11
|
|
|
11
12
|
export interface RuntimeSnapshotProcess {
|
|
12
13
|
mcpHttp: boolean;
|
|
13
|
-
omittedTools:
|
|
14
|
+
omittedTools: ToolAuditSummary["omitted"];
|
|
15
|
+
key?: string;
|
|
16
|
+
modelId?: string;
|
|
17
|
+
agentVersion?: string;
|
|
18
|
+
alive?: boolean;
|
|
19
|
+
ignoredStdoutNoiseLines?: number;
|
|
14
20
|
[key: string]: unknown;
|
|
15
21
|
}
|
|
16
22
|
|
|
17
23
|
export interface RuntimeSnapshotView {
|
|
18
24
|
bindings: number;
|
|
19
25
|
permissionMode: string;
|
|
20
|
-
metrics:
|
|
26
|
+
metrics: {
|
|
27
|
+
totals?: Partial<Record<"turns" | "input" | "output" | "reasoning" | "cacheRead" | "cacheWrite", number>>;
|
|
28
|
+
latestQuota?: { remaining?: number; limit?: number; resetAt?: string; tier?: string; model?: string };
|
|
29
|
+
};
|
|
21
30
|
processes: RuntimeSnapshotProcess[];
|
|
22
31
|
}
|
|
23
32
|
|
|
@@ -30,6 +39,7 @@ export interface StreamEventLike {
|
|
|
30
39
|
export interface RuntimeBundleView {
|
|
31
40
|
runtime: {
|
|
32
41
|
snapshot: () => Promise<RuntimeSnapshotView>;
|
|
42
|
+
quota: (apiKey: string | undefined, signal?: AbortSignal) => Promise<AntigravityQuotaSnapshot>;
|
|
33
43
|
setPermissionMode: (mode: string) => Promise<void>;
|
|
34
44
|
logout: () => Promise<void>;
|
|
35
45
|
close: () => Promise<void>;
|
|
@@ -127,6 +137,7 @@ const SUBCOMMANDS: SubcommandSpec[] = [
|
|
|
127
137
|
usage: "[auto|off]",
|
|
128
138
|
values: [["auto", "Query usage after each reply"], ["off", "Skip supplemental usage queries"]],
|
|
129
139
|
},
|
|
140
|
+
{ name: "quota", description: "Live model quota groups and reset times" },
|
|
130
141
|
{
|
|
131
142
|
name: "context",
|
|
132
143
|
description: "Context window and transfer settings",
|
|
@@ -165,7 +176,7 @@ const SUBCOMMANDS: SubcommandSpec[] = [
|
|
|
165
176
|
name: "native-tools",
|
|
166
177
|
description: "Native ACP tool exposure",
|
|
167
178
|
usage: "prefer|disabled",
|
|
168
|
-
values: [["prefer", "Let OMP tools shadow ACP natives (default)"], ["disabled", "
|
|
179
|
+
values: [["prefer", "Let OMP tools shadow ACP natives (default)"], ["disabled", "Disable ACP-native tools for strict OMP-tool sessions"]],
|
|
169
180
|
},
|
|
170
181
|
{
|
|
171
182
|
name: "permissions",
|
|
@@ -228,6 +239,133 @@ export function createAntigravityArgumentCompletions(deps: AntigravityCompletion
|
|
|
228
239
|
};
|
|
229
240
|
}
|
|
230
241
|
|
|
242
|
+
type DisplayField = readonly [label: string, value: string | number | undefined];
|
|
243
|
+
|
|
244
|
+
function section(title: string, fields: DisplayField[]): string {
|
|
245
|
+
const visible = fields.filter((field): field is readonly [string, string | number] => field[1] !== undefined);
|
|
246
|
+
const width = Math.max(0, ...visible.map(([label]) => label.length));
|
|
247
|
+
return [title, ...visible.map(([label, value]) =>
|
|
248
|
+
` ${`${label}:`.padEnd(width + 1)} ${typeof value === "number" ? formatNumber(value) : value}`)].join("\n");
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function formatNumber(value: number): string {
|
|
252
|
+
return value.toLocaleString("en-US", { maximumFractionDigits: 3 });
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function formatBytes(value: number): string {
|
|
256
|
+
if (value === 0) return "0 B";
|
|
257
|
+
const units = ["B", "KiB", "MiB", "GiB"];
|
|
258
|
+
const exponent = Math.min(Math.floor(Math.log(value) / Math.log(1024)), units.length - 1);
|
|
259
|
+
return `${formatNumber(value / 1024 ** exponent)} ${units[exponent]}`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function formatDays(value: number): string {
|
|
263
|
+
return `${formatNumber(value)} ${value === 1 ? "day" : "days"}`;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
function formatContextValue(key: string, value: number | string | undefined): string | undefined {
|
|
267
|
+
if (value === undefined) return undefined;
|
|
268
|
+
if (typeof value === "string") return value;
|
|
269
|
+
return key.endsWith("Bytes") ? formatBytes(value) : `${formatNumber(value)} tokens`;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
function formatUsageRecord(metrics: RuntimeSnapshotView["metrics"]): string | undefined {
|
|
273
|
+
const totals = metrics.totals;
|
|
274
|
+
if (!totals) return undefined;
|
|
275
|
+
const parts = (["turns", "input", "output", "reasoning", "cacheRead", "cacheWrite"] as const)
|
|
276
|
+
.filter(key => (totals[key] ?? 0) > 0)
|
|
277
|
+
.map(key => `${formatNumber(totals[key]!)} ${key === "cacheRead" ? "cache read" : key === "cacheWrite" ? "cache write" : key}`);
|
|
278
|
+
return parts.length ? parts.join(" · ") : "no completed turns";
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function formatLatestQuota(quota: NonNullable<RuntimeSnapshotView["metrics"]["latestQuota"]>): string | undefined {
|
|
282
|
+
const parts = [
|
|
283
|
+
quota.tier,
|
|
284
|
+
quota.model,
|
|
285
|
+
quota.remaining !== undefined || quota.limit !== undefined
|
|
286
|
+
? `${quota.remaining === undefined ? "unknown" : formatNumber(quota.remaining)}${quota.limit === undefined ? "" : ` / ${formatNumber(quota.limit)}`} remaining`
|
|
287
|
+
: undefined,
|
|
288
|
+
quota.resetAt ? `reset ${quota.resetAt}` : undefined,
|
|
289
|
+
].filter((part): part is string => Boolean(part));
|
|
290
|
+
return parts.length ? parts.join(" · ") : undefined;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
interface DiagnosticsStatusView {
|
|
294
|
+
enabled: boolean;
|
|
295
|
+
samples: number;
|
|
296
|
+
capacity: number;
|
|
297
|
+
stages: Record<string, { count: number; medianMs: number; maxMs: number }>;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function formatDiagnostics(status: DiagnosticsStatusView | undefined): string {
|
|
301
|
+
const fields: DisplayField[] = [["Collection", status?.enabled ? "on" : "off"]];
|
|
302
|
+
if (status?.samples) fields.push(["Samples", `${formatNumber(status.samples)} / ${formatNumber(status.capacity)}`]);
|
|
303
|
+
for (const [stage, sample] of Object.entries(status?.stages ?? {})) {
|
|
304
|
+
fields.push([stage, `count ${formatNumber(sample.count)} · median ${formatNumber(sample.medianMs)} ms · max ${formatNumber(sample.maxMs)} ms`]);
|
|
305
|
+
}
|
|
306
|
+
return section("ACP diagnostics", fields);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
interface CleanupStatusView {
|
|
310
|
+
mode: CleanupMode;
|
|
311
|
+
idleDays: number;
|
|
312
|
+
maxSessions?: number;
|
|
313
|
+
maxBytes?: number;
|
|
314
|
+
orphanGraceDays?: number;
|
|
315
|
+
recoveryDays?: number;
|
|
316
|
+
owned: number;
|
|
317
|
+
active: number;
|
|
318
|
+
mapped: number;
|
|
319
|
+
unmapped: number;
|
|
320
|
+
ownedBytes: number;
|
|
321
|
+
reclaimedBytes: number;
|
|
322
|
+
retainedForRecovery: number;
|
|
323
|
+
deferred: number;
|
|
324
|
+
pendingLifecycleUpdates: number;
|
|
325
|
+
failures: number;
|
|
326
|
+
warning?: string;
|
|
327
|
+
scope: string;
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
function formatCleanup(status: CleanupStatusView, removed: number): string {
|
|
331
|
+
const fields: DisplayField[] = [
|
|
332
|
+
["Mode", status.mode],
|
|
333
|
+
["Idle retention", status.idleDays === undefined ? undefined : formatDays(status.idleDays)],
|
|
334
|
+
["Orphan retention", status.orphanGraceDays === undefined ? undefined : formatDays(status.orphanGraceDays)],
|
|
335
|
+
["Recovery", status.recoveryDays === undefined ? undefined : formatDays(status.recoveryDays)],
|
|
336
|
+
["Session budget", status.maxSessions === undefined ? undefined : status.maxSessions === 0 ? "disabled" : status.maxSessions],
|
|
337
|
+
["Byte budget", status.maxBytes === undefined ? undefined : status.maxBytes === 0 ? "disabled" : formatBytes(status.maxBytes)],
|
|
338
|
+
["Owned sessions", status.owned || undefined],
|
|
339
|
+
["Active sessions", status.active || undefined],
|
|
340
|
+
["Mapped sessions", status.mapped || undefined],
|
|
341
|
+
["Unmapped sessions", status.unmapped || undefined],
|
|
342
|
+
["Stored data", status.ownedBytes ? formatBytes(status.ownedBytes) : undefined],
|
|
343
|
+
["Removed this run", removed],
|
|
344
|
+
["Reclaimed", status.reclaimedBytes ? formatBytes(status.reclaimedBytes) : undefined],
|
|
345
|
+
["Retained for recovery", status.retainedForRecovery || undefined],
|
|
346
|
+
["Deferred", status.deferred || undefined],
|
|
347
|
+
["Pending updates", status.pendingLifecycleUpdates || undefined],
|
|
348
|
+
["Failures", status.failures || undefined],
|
|
349
|
+
["Warning", status.warning],
|
|
350
|
+
["Scope", status.scope],
|
|
351
|
+
["Risk", "Active sessions are protected. Timeout cleanup loses ACP-only state; OMP history is retained."],
|
|
352
|
+
];
|
|
353
|
+
return section("ACP session cleanup", fields);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function formatQuota(snapshot: AntigravityQuotaSnapshot): string {
|
|
357
|
+
const groups = snapshot.groups.map(group => {
|
|
358
|
+
const width = Math.max(0, ...group.buckets.map(bucket => bucket.window.length));
|
|
359
|
+
return [
|
|
360
|
+
` ${group.displayName}`,
|
|
361
|
+
...(group.buckets.length ? group.buckets.map(bucket =>
|
|
362
|
+
` ${bucket.window.padEnd(width)} ${Math.round(bucket.remainingFraction * 100)}% remaining${bucket.resetTime ? ` · reset ${bucket.resetTime}` : ""}`)
|
|
363
|
+
: [" no percentage limits reported"]),
|
|
364
|
+
].join("\n");
|
|
365
|
+
});
|
|
366
|
+
return ["Antigravity quota", ...groups].join("\n");
|
|
367
|
+
}
|
|
368
|
+
|
|
231
369
|
export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
232
370
|
const sessionIdOf = (ctx: OmpCommandContext | undefined): string | undefined => ctx?.sessionManager?.getSessionId?.();
|
|
233
371
|
|
|
@@ -239,7 +377,7 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
239
377
|
if (parts.length > 2 || (value !== undefined && !["on", "off", "reset"].includes(value))) throw new Error("Usage: /antigravity-acp diagnostics [on|off|reset]");
|
|
240
378
|
if (value === "reset") deps.diagnostics?.reset();
|
|
241
379
|
else if (value) deps.diagnostics?.configure(value === "on");
|
|
242
|
-
ctx.ui.notify(
|
|
380
|
+
ctx.ui.notify(formatDiagnostics(deps.diagnostics?.status()), "info");
|
|
243
381
|
return;
|
|
244
382
|
}
|
|
245
383
|
|
|
@@ -253,15 +391,10 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
253
391
|
throw new Error("Usage: /antigravity-acp cleanup [off|conservative|timeout|balanced [DAYS]]");
|
|
254
392
|
}
|
|
255
393
|
deps.cleanup.configure(value as CleanupMode, parts[2] === undefined ? undefined : Number(parts[2]));
|
|
256
|
-
deps.cleanup.start();
|
|
257
394
|
}
|
|
258
395
|
deps.cleanup.start();
|
|
259
396
|
const removed = await deps.cleanup.collect();
|
|
260
|
-
ctx.ui.notify(
|
|
261
|
-
...deps.cleanup.status(),
|
|
262
|
-
removed,
|
|
263
|
-
note: "Active sessions are protected. Timeout cleanup loses ACP-only state; OMP history is retained.",
|
|
264
|
-
}, null, 2), "info");
|
|
397
|
+
ctx.ui.notify(formatCleanup(deps.cleanup.status(), removed), "info");
|
|
265
398
|
return;
|
|
266
399
|
}
|
|
267
400
|
|
|
@@ -284,11 +417,27 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
284
417
|
} else if (value) {
|
|
285
418
|
throw new Error("Usage: /antigravity-acp context [set default|MODEL KEY NUMBER]");
|
|
286
419
|
} else {
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
420
|
+
const sections: string[] = [];
|
|
421
|
+
const shared = Object.entries(currentSettings.defaults).map(([key, value]) =>
|
|
422
|
+
[key, formatContextValue(key, value)] as DisplayField).filter(field => field[1] !== undefined);
|
|
423
|
+
sections.push(shared.length ? section("Shared defaults", shared)
|
|
424
|
+
: "Shared defaults\n Catalog values; no saved overrides.");
|
|
425
|
+
for (const model of deps.catalog.currentModels) {
|
|
426
|
+
const effective = resolveContextOptions(model, currentSettings);
|
|
427
|
+
const overrides = Object.entries(currentSettings.models[model.id] ?? {}).map(([key, value]) =>
|
|
428
|
+
`${key}=${formatContextValue(key, value)}`).join(", ");
|
|
429
|
+
sections.push(section(model.id, [
|
|
430
|
+
["Context window", formatContextValue("contextWindow", effective.contextWindow)],
|
|
431
|
+
["Output limit", formatContextValue("maxTokens", effective.maxTokens)],
|
|
432
|
+
["Reply reserve", formatContextValue("reserveTokens", effective.reserveTokens)],
|
|
433
|
+
["Input budget", formatContextValue("inputTokenBudget", effective.inputTokenBudget)],
|
|
434
|
+
["Transfer limit", formatContextValue("maxTransferBytes", effective.maxTransferBytes)],
|
|
435
|
+
["Image limit", formatContextValue("maxImageBytes", effective.maxImageBytes)],
|
|
436
|
+
["Overrides", overrides || undefined],
|
|
437
|
+
]));
|
|
438
|
+
}
|
|
439
|
+
if (!deps.catalog.currentModels.length) sections.push("Models\n None cached; run /antigravity-acp refresh.");
|
|
440
|
+
ctx.ui.notify(["ACP context settings", ...sections].join("\n\n"), "info");
|
|
292
441
|
}
|
|
293
442
|
return;
|
|
294
443
|
}
|
|
@@ -375,43 +524,78 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
375
524
|
const snapshot = await bundle?.runtime.snapshot();
|
|
376
525
|
const permissionMode = deps.getPermissionMode();
|
|
377
526
|
const omp = ompCredentialSummary(ctx);
|
|
378
|
-
const
|
|
379
|
-
|
|
527
|
+
const accountEmail = antigravityAccountEmail();
|
|
528
|
+
const marker = omp.present === undefined ? "unknown; host did not expose the credential store"
|
|
529
|
+
: omp.present ? `present · ${omp.record} · authorized ${omp.authorizedAt ?? "unknown time"}${omp.email && omp.email !== accountEmail ? ` · account ${omp.email}` : ""}`
|
|
380
530
|
: "not stored; run /login or /antigravity-acp login";
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
"
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
531
|
+
const fields: DisplayField[] = [
|
|
532
|
+
["Google account", accountEmail ?? ((await keychain.present()) === true ? "signed in · keychain token; email unavailable" : "not signed in")],
|
|
533
|
+
["ACP authentication", `${auth.status}${auth.authType ? ` · ${auth.authType}` : ""}`],
|
|
534
|
+
["Credential storage", describeCredentialStorage()],
|
|
535
|
+
["OMP login marker", marker],
|
|
536
|
+
["OMP auth source", ompSource],
|
|
537
|
+
["Saved ACP sessions", deps.getSavedSessionCount()],
|
|
538
|
+
["Permission", permissionMode === "auto_edit" ? "auto-edit" : permissionMode],
|
|
539
|
+
["Active sessions", snapshot?.bindings ?? 0],
|
|
540
|
+
["Token ownership", "Google OAuth tokens stay in Antigravity-owned storage; OMP stores only a non-secret marker."],
|
|
541
|
+
["Logout", "/antigravity-acp logout clears both sides; OMP /logout also finishes Antigravity-side cleanup."],
|
|
542
|
+
];
|
|
543
|
+
const ompEmail = "email" in omp ? omp.email : undefined;
|
|
544
|
+
const ompError = "error" in omp ? omp.error : undefined;
|
|
545
|
+
if (ompError) fields.push(["OMP warning", ompError]);
|
|
546
|
+
if (accountEmail && ompEmail && ompEmail !== accountEmail) {
|
|
547
|
+
fields.push(["Account warning", "The OMP marker and Antigravity token identify different accounts."]);
|
|
548
|
+
}
|
|
549
|
+
ctx.ui.notify(section("Antigravity ACP account", fields), "info");
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
if (command === "quota") {
|
|
554
|
+
if (value !== undefined) throw new Error("Usage: /antigravity-acp quota");
|
|
555
|
+
await deps.prepareRuntime();
|
|
556
|
+
const lease = deps.acquireRuntimeForSession
|
|
557
|
+
? deps.acquireRuntimeForSession(sessionIdOf(ctx))
|
|
558
|
+
: { value: deps.getRuntimeForSession(sessionIdOf(ctx)), release: () => {} };
|
|
559
|
+
try {
|
|
560
|
+
const quota = await lease.value.runtime.quota(undefined).then(formatQuota,
|
|
561
|
+
(error: unknown) => section("Antigravity quota", [
|
|
562
|
+
["Status", "unavailable"],
|
|
563
|
+
["Reason", error instanceof Error ? error.message : String(error)],
|
|
564
|
+
]));
|
|
565
|
+
ctx.ui.notify(quota, "info");
|
|
566
|
+
} finally {
|
|
567
|
+
lease.release();
|
|
568
|
+
}
|
|
395
569
|
return;
|
|
396
570
|
}
|
|
397
571
|
|
|
398
572
|
if (command === "usage") {
|
|
399
573
|
const currentSettings = deps.getContextSettings();
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
574
|
+
const configured = currentSettings.defaults.usageMode ?? DEFAULT_USAGE_MODE;
|
|
575
|
+
const overridden = process.env.OMP_ACP_USAGE === "off";
|
|
576
|
+
const effective = overridden ? "off" : configured;
|
|
577
|
+
const sections = [section("ACP usage", [["Queries", `${configured} → ${effective}${overridden ? " · OMP_ACP_USAGE=off override" : ""}`]])];
|
|
578
|
+
let visibleConnections = 0;
|
|
579
|
+
for (const connection of deps.connections) {
|
|
580
|
+
const fields: DisplayField[] = [];
|
|
581
|
+
for (const [sessionId, usage] of connection.contextUsage) {
|
|
582
|
+
const ompWindow = connection.getOmpContextWindow?.(sessionId);
|
|
583
|
+
fields.push([`Context ${sessionId}`, `${formatNumber(usage.used)} / ${formatNumber(usage.size)} ACP tokens${ompWindow === undefined ? "" : ` · OMP window ${formatNumber(ompWindow)}`}`]);
|
|
584
|
+
}
|
|
585
|
+
for (const records of connection.compactions.values()) {
|
|
586
|
+
for (const record of records.values()) {
|
|
587
|
+
fields.push([`Compaction ${record.sessionId}/${record.compactionId}`, record.status]);
|
|
588
|
+
if (record.error) fields.push([`Compaction error ${record.compactionId}`, record.error]);
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
for (const [sessionId, accounting] of connection.usageStatus) {
|
|
592
|
+
fields.push([`Accounting ${sessionId}`, `${accounting.source} · cache ${accounting.cache}`]);
|
|
593
|
+
if (accounting.error) fields.push([`Accounting error ${sessionId}`, accounting.error]);
|
|
594
|
+
}
|
|
595
|
+
if (connection.activePrompts) fields.push(["Active prompts", connection.activePrompts]);
|
|
596
|
+
if (fields.length) sections.push(section(`Connection ${++visibleConnections}`, fields));
|
|
597
|
+
}
|
|
598
|
+
ctx.ui.notify(sections.join("\n\n"), "info");
|
|
415
599
|
return;
|
|
416
600
|
}
|
|
417
601
|
|
|
@@ -419,7 +603,7 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
419
603
|
if (value !== undefined) throw new Error("Usage: /antigravity-acp refresh");
|
|
420
604
|
const refreshed = await deps.catalog.refresh(deps.getContextSettings());
|
|
421
605
|
deps.onModelsUpdated(refreshed);
|
|
422
|
-
ctx.ui.notify(
|
|
606
|
+
ctx.ui.notify(section("ACP model cache refreshed", [["Models", refreshed.length ? refreshed.map(model => model.id).join(", ") : "none advertised"]]), "info");
|
|
423
607
|
return;
|
|
424
608
|
}
|
|
425
609
|
|
|
@@ -434,15 +618,15 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
434
618
|
await deps.closeAllRuntimes();
|
|
435
619
|
}
|
|
436
620
|
}
|
|
437
|
-
const usageError = "Usage: /antigravity-acp [status|account|login|logout|tools|usage|context|cleanup|diagnostics|debug|native-tools|permissions|refresh]";
|
|
621
|
+
const usageError = "Usage: /antigravity-acp [status|account|login|logout|tools|usage|quota|context|cleanup|diagnostics|debug|native-tools|permissions|refresh]";
|
|
438
622
|
if (command && command !== "status" && command !== "tools" && command !== "permissions") {
|
|
439
623
|
throw new Error(usageError);
|
|
440
624
|
}
|
|
441
625
|
if (command === "status" && value !== undefined) throw new Error(usageError);
|
|
442
626
|
if (command === "tools" && value !== undefined) throw new Error("Usage: /antigravity-acp tools");
|
|
443
627
|
|
|
444
|
-
//
|
|
445
|
-
//
|
|
628
|
+
// Tools and status inspect a runtime snapshot. Quota owns a separate
|
|
629
|
+
// query lifecycle above; the other earlier commands stay offline.
|
|
446
630
|
const lease = deps.acquireRuntimeForSession
|
|
447
631
|
? deps.acquireRuntimeForSession(sessionIdOf(ctx))
|
|
448
632
|
: { value: deps.getRuntimeForSession(sessionIdOf(ctx)), release: () => {} };
|
|
@@ -450,14 +634,52 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
450
634
|
const snapshot = await lease.value.runtime.snapshot();
|
|
451
635
|
if (command === "tools") {
|
|
452
636
|
const lastToolAudit = deps.getLastToolAudit();
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
637
|
+
if (!lastToolAudit) {
|
|
638
|
+
ctx.ui.notify("No model request yet. Send a message with this ACP model to inspect its offered OMP tools.", "info");
|
|
639
|
+
return;
|
|
640
|
+
}
|
|
641
|
+
const sections = [section("OMP ACP tool bridge", [
|
|
642
|
+
["Offered", lastToolAudit.offered.length],
|
|
643
|
+
["Available", lastToolAudit.available.join(", ") || "none"],
|
|
644
|
+
["Omitted", lastToolAudit.omitted.length || undefined],
|
|
645
|
+
])];
|
|
646
|
+
if (lastToolAudit.omitted.length) {
|
|
647
|
+
sections.push(section("Omitted OMP tools", lastToolAudit.omitted.map((tool): DisplayField => [tool.name, tool.reason])));
|
|
648
|
+
}
|
|
649
|
+
snapshot.processes.forEach((process, index) => {
|
|
650
|
+
const name = process.modelId ?? process.key ?? `Runtime ${index + 1}`;
|
|
651
|
+
sections.push(section(name, [
|
|
652
|
+
["MCP over HTTP", process.mcpHttp ? "yes" : "no"],
|
|
653
|
+
...process.omittedTools.map(tool => [`Omitted ${tool.name}`, tool.reason] as DisplayField),
|
|
654
|
+
]));
|
|
655
|
+
});
|
|
656
|
+
ctx.ui.notify(sections.join("\n\n"), "info");
|
|
456
657
|
return;
|
|
457
658
|
}
|
|
458
659
|
|
|
459
660
|
const policy = deps.getToolPolicy();
|
|
460
|
-
|
|
661
|
+
const requestedPermission = deps.getPermissionMode();
|
|
662
|
+
const requestedLabel = requestedPermission === "auto_edit" ? "auto-edit" : requestedPermission;
|
|
663
|
+
const wireLabel = snapshot.permissionMode === "auto_edit" ? "auto-edit" : snapshot.permissionMode;
|
|
664
|
+
const versions = [...new Set(snapshot.processes.map(process => process.agentVersion).filter((version): version is string => Boolean(version)))];
|
|
665
|
+
const channels = [...new Set([...deps.connections].map(connection => connection.toolRouting?.channel).filter((channel): channel is "pending" | "system-append" | "legacy-prompt" => Boolean(channel)))];
|
|
666
|
+
const thinking = [...deps.connections].map(connection => connection.confirmedThinking).filter((value): value is { model: string; effort: string } => Boolean(value));
|
|
667
|
+
const stopped = snapshot.processes.filter(process => process.alive === false).length;
|
|
668
|
+
const ignoredNoise = snapshot.processes.reduce((total, process) => total + (process.ignoredStdoutNoiseLines ?? 0), 0);
|
|
669
|
+
ctx.ui.notify(section("Antigravity ACP (OMP adapter)", [
|
|
670
|
+
["Login", (await authReady()) ? "ready" : `not ready · ${inspectAntigravityAuth().status}`],
|
|
671
|
+
["Runtime", versions.join(", ") || undefined],
|
|
672
|
+
["Native channel", channels.join(", ") || undefined],
|
|
673
|
+
["Permission", requestedLabel === wireLabel ? requestedLabel : `requested ${requestedLabel} → wire ${wireLabel}`],
|
|
674
|
+
["Native tools", policy.nativeTools],
|
|
675
|
+
["Tool debug", policy.debugToolUpdates ? "on" : undefined],
|
|
676
|
+
["Thinking", thinking.map(value => `${value.model}=${value.effort}`).join(", ") || undefined],
|
|
677
|
+
["Usage record", formatUsageRecord(snapshot.metrics)],
|
|
678
|
+
["Latest quota", snapshot.metrics.latestQuota ? formatLatestQuota(snapshot.metrics.latestQuota) : undefined],
|
|
679
|
+
["Active sessions", snapshot.bindings],
|
|
680
|
+
["Runtime warning", stopped ? `${stopped} stopped process${stopped === 1 ? "" : "es"}` : undefined],
|
|
681
|
+
["API warning", ignoredNoise ? `${formatNumber(ignoredNoise)} ignored stdout noise line${ignoredNoise === 1 ? "" : "s"}` : undefined],
|
|
682
|
+
]), "info");
|
|
461
683
|
} finally {
|
|
462
684
|
lease.release();
|
|
463
685
|
}
|