omp-antigravity-acp-provider 0.1.33 → 0.1.35
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 +4 -0
- package/extension/auth-sync.ts +17 -9
- package/extension/catalog-store.ts +11 -3
- package/extension/commands.ts +20 -14
- package/extension/context-settings.ts +1 -0
- package/extension/context-transfer.ts +10 -3
- package/extension/index.ts +4 -3
- package/extension/runtime.mjs +28 -17
- package/extension/tier-connection.ts +3 -1
- package/extension/tool-routing.ts +3 -10
- package/extension/transcript-routing.ts +1 -0
- package/extension/turn-cancellation.ts +11 -1
- package/extension/usage-accounting.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -109,10 +109,14 @@ The installation runbook is in [AGENT_INSTALL.md](AGENT_INSTALL.md). Hand that f
|
|
|
109
109
|
| `/antigravity-acp debug on\|off` | ACP tool-status lines |
|
|
110
110
|
| `/antigravity-acp permissions default\|auto-edit\|yolo` | Permission mode |
|
|
111
111
|
|
|
112
|
+
Supplemental `/usage` queries are off by default. Context occupancy still comes from ACP `usage_update`. Run `/antigravity-acp usage auto` to opt into the extra query.
|
|
113
|
+
|
|
112
114
|
## Steering and queued messages
|
|
113
115
|
|
|
114
116
|
By default a new user message waits for the active ACP turn to finish (`OMP_ACP_STEER_MODE=queue`) and then continues on the warm session, avoiding a full replay and OMP auto-compaction. Set `OMP_ACP_STEER_MODE=steer` to restore immediate interruption. At tool/permission boundaries the adapter falls back to steer and waits for the ACP terminal response; `OMP_ACP_STEER_GRACE_MS` (default 60000) and `OMP_ACP_STEER_GRACE_MAX_MS` (default 300000) bound that wait.
|
|
115
117
|
|
|
118
|
+
ACP runtimes stay warm for 15 minutes by default. Set `OMP_ACP_IDLE_TIMEOUT_MS=0` to keep them until OMP exits, or lower the value to reclaim memory sooner.
|
|
119
|
+
|
|
116
120
|
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
121
|
|
|
118
122
|
## Limitations vs direct OAuth
|
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
|
@@ -2,7 +2,7 @@ import { describeCredentialStorage, inspectAntigravityAuth, savePermissionMode }
|
|
|
2
2
|
import { antigravityAccountEmail, authReady, formatLogoutSummary, keychain, ompCredentialSummary, type OmpAuthCoordinator, type OmpCommandContext } from "./auth-sync.ts";
|
|
3
3
|
import { parseNativeToolMode, type NativeToolMode } from "./tool-routing.ts";
|
|
4
4
|
import { saveToolPolicy, type ToolPolicy } from "./tool-policy.ts";
|
|
5
|
-
import { updateContextSettings, resolveContextOptions, saveContextSettings, type ContextSettings } from "./context-settings.ts";
|
|
5
|
+
import { DEFAULT_USAGE_MODE, updateContextSettings, resolveContextOptions, saveContextSettings, type ContextSettings } from "./context-settings.ts";
|
|
6
6
|
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";
|
|
@@ -254,8 +254,8 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
254
254
|
if (command === "usage") {
|
|
255
255
|
const currentSettings = deps.getContextSettings();
|
|
256
256
|
ctx.ui.notify(JSON.stringify({
|
|
257
|
-
configured: currentSettings.defaults.usageMode ??
|
|
258
|
-
effective: process.env.OMP_ACP_USAGE === "off" ? "off" : currentSettings.defaults.usageMode ??
|
|
257
|
+
configured: currentSettings.defaults.usageMode ?? DEFAULT_USAGE_MODE,
|
|
258
|
+
effective: process.env.OMP_ACP_USAGE === "off" ? "off" : currentSettings.defaults.usageMode ?? DEFAULT_USAGE_MODE,
|
|
259
259
|
connections: [...deps.connections].map(connection => ({
|
|
260
260
|
context: [...connection.contextUsage].map(([sessionId, usage]) => ({
|
|
261
261
|
sessionId,
|
|
@@ -297,17 +297,23 @@ export function createAntigravityCommandHandler(deps: CommandControllerDeps) {
|
|
|
297
297
|
|
|
298
298
|
// Only the tools inspection and the status display below need a live
|
|
299
299
|
// runtime; every earlier command runs without one.
|
|
300
|
-
const
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
+
}
|
|
309
312
|
|
|
310
|
-
|
|
311
|
-
|
|
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
|
+
}
|
|
312
318
|
};
|
|
313
319
|
}
|
|
@@ -12,6 +12,7 @@ export interface ContextSettings {
|
|
|
12
12
|
defaults: ContextOptions & { usageMode?: "auto" | "off" };
|
|
13
13
|
models: Record<string, ContextOptions>;
|
|
14
14
|
}
|
|
15
|
+
export const DEFAULT_USAGE_MODE: "auto" | "off" = "off";
|
|
15
16
|
const ranges: Record<keyof ContextOptions, [number, number]> = {
|
|
16
17
|
contextWindow: [4096, 16_777_216], maxTokens: [1, 1_048_576], inputTokenBudget: [1, 16_777_216],
|
|
17
18
|
reserveTokens: [0, 1_048_576], maxTransferBytes: [65_536, 134_217_728], maxImageBytes: [0, 100_663_296],
|
|
@@ -148,7 +148,6 @@ export function stableSystemContent(text: string): string {
|
|
|
148
148
|
.replace(DATE_CWD_REMINDER, "")
|
|
149
149
|
.replace(SYSTEM_REMINDER_TAG, (match, body: string) => isVolatileReminder(body) ? "" : match)
|
|
150
150
|
.replace(OMP_TOOL_NAMES_LINE, "")
|
|
151
|
-
.replace(TOOL_ROUTING.trim(), "")
|
|
152
151
|
.replace(/\n{3,}/g, "\n\n")
|
|
153
152
|
.trim();
|
|
154
153
|
}
|
|
@@ -542,9 +541,17 @@ export function buildPromptParts(context: TransferContext, fresh: boolean, unsee
|
|
|
542
541
|
if (promptTextBytes(prompt) > ACP_STEP_TEXT_BYTES) {
|
|
543
542
|
const seedTail: TransferBlock[] = [{ type: "text", text: SEED_ACK_TEXT }];
|
|
544
543
|
let pendingInstructions = instructionsBlock;
|
|
544
|
+
let finalInstructions: TransferBlock | undefined;
|
|
545
|
+
if (pendingInstructions && promptTextBytes(assembleStep(pendingInstructions, [], seedTail)) > ACP_STEP_TEXT_BYTES) {
|
|
546
|
+
// Instructions that cannot fit beside a seed acknowledgement stay in
|
|
547
|
+
// the final prompt; history seed steps can still be sent without them.
|
|
548
|
+
finalInstructions = pendingInstructions;
|
|
549
|
+
pendingInstructions = undefined;
|
|
550
|
+
}
|
|
545
551
|
let cursor = 0;
|
|
546
552
|
while (cursor < recordItems.length || pendingInstructions) {
|
|
547
|
-
const
|
|
553
|
+
const remainingInstructions = finalInstructions ?? pendingInstructions;
|
|
554
|
+
const remaining = assembleStep(remainingInstructions, recordItems.slice(cursor), tailBlocks);
|
|
548
555
|
if (promptTextBytes(remaining) <= ACP_STEP_TEXT_BYTES) break;
|
|
549
556
|
const chunkItems: RecordItem[] = [];
|
|
550
557
|
const chunkInst = pendingInstructions;
|
|
@@ -565,7 +572,7 @@ export function buildPromptParts(context: TransferContext, fresh: boolean, unsee
|
|
|
565
572
|
historySeedSteps.push(seedStep);
|
|
566
573
|
pendingInstructions = undefined;
|
|
567
574
|
}
|
|
568
|
-
prompt = assembleStep(pendingInstructions, recordItems.slice(cursor), tailBlocks);
|
|
575
|
+
prompt = assembleStep(finalInstructions ?? pendingInstructions, recordItems.slice(cursor), tailBlocks);
|
|
569
576
|
checkStepTextBytes(promptTextBytes(prompt));
|
|
570
577
|
}
|
|
571
578
|
const seedSteps = historySeedSteps.length || requestSeedSteps.length
|
package/extension/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import { Diagnostics, instrumentRuntime } from "./diagnostics.ts";
|
|
|
10
10
|
import { stableTools } from "./tool-order.ts";
|
|
11
11
|
import { toolDeclarations, normalizeOmpSystemDeltas, type OmpToolDeclaration } from "./omp-context.ts";
|
|
12
12
|
import { OmpSessionLifecycle, type OmpProviderSessionState } from "./omp-session-lifecycle.ts";
|
|
13
|
-
import { loadContextSettings } from "./context-settings.ts";
|
|
13
|
+
import { DEFAULT_USAGE_MODE, loadContextSettings } from "./context-settings.ts";
|
|
14
14
|
import { selectRuntimeModel, type PublicCatalogModel } from "./model-catalog.ts";
|
|
15
15
|
import { TOOL_ROUTING } from "./tool-routing.ts";
|
|
16
16
|
import { TranscriptRouting } from "./transcript-routing.ts";
|
|
@@ -111,7 +111,7 @@ export async function registerOmpAdapter(pi: OmpHostApi, stateDir: string,
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
const connections = new Set<TierConnection>();
|
|
114
|
-
const idleTimeoutMs = Number(process.env.OMP_ACP_IDLE_TIMEOUT_MS ??
|
|
114
|
+
const idleTimeoutMs = Number(process.env.OMP_ACP_IDLE_TIMEOUT_MS ?? 900_000);
|
|
115
115
|
if (!Number.isSafeInteger(idleTimeoutMs) || idleTimeoutMs < 0 || idleTimeoutMs > 2_147_483_647 || (idleTimeoutMs > 0 && idleTimeoutMs < 1000)) {
|
|
116
116
|
throw new Error("OMP_ACP_IDLE_TIMEOUT_MS must be 0 (disabled) or an integer between 1000 and 2147483647");
|
|
117
117
|
}
|
|
@@ -138,7 +138,7 @@ export async function registerOmpAdapter(pi: OmpHostApi, stateDir: string,
|
|
|
138
138
|
...options,
|
|
139
139
|
ompNativeTools: toolPolicy.nativeTools,
|
|
140
140
|
ompDebugToolUpdates: toolPolicy.debugToolUpdates,
|
|
141
|
-
ompUsageMode: contextSettings.defaults.usageMode ??
|
|
141
|
+
ompUsageMode: contextSettings.defaults.usageMode ?? DEFAULT_USAGE_MODE,
|
|
142
142
|
ompCleanup: cleanup,
|
|
143
143
|
ompDiagnostics: diagnostics,
|
|
144
144
|
});
|
|
@@ -252,6 +252,7 @@ export async function registerOmpAdapter(pi: OmpHostApi, stateDir: string,
|
|
|
252
252
|
prepareRuntime,
|
|
253
253
|
() => [...(FALLBACK_MODELS as PublicCatalogModel[])],
|
|
254
254
|
requireAcpAuth,
|
|
255
|
+
createConnection,
|
|
255
256
|
);
|
|
256
257
|
let initialModels = catalogStore.loadInitialOrCached(contextSettings);
|
|
257
258
|
|
package/extension/runtime.mjs
CHANGED
|
@@ -19338,9 +19338,10 @@ async function drainCancelledTurn(binding, abort, signal, timeoutMs = 1500, timi
|
|
|
19338
19338
|
if (!completion || signal?.aborted) return false;
|
|
19339
19339
|
const deadline = Promise.withResolvers();
|
|
19340
19340
|
const cancelled = () => deadline.resolve(false);
|
|
19341
|
-
let timer
|
|
19341
|
+
let timer;
|
|
19342
19342
|
let giveup;
|
|
19343
19343
|
let finished = false;
|
|
19344
|
+
let cancelSettled = false;
|
|
19344
19345
|
signal?.addEventListener("abort", cancelled, { once: true });
|
|
19345
19346
|
const extendForNaturalCompletion = () => {
|
|
19346
19347
|
if (finished || giveup) return;
|
|
@@ -19348,14 +19349,20 @@ async function drainCancelledTurn(binding, abort, signal, timeoutMs = 1500, timi
|
|
|
19348
19349
|
clearTimeout(timer);
|
|
19349
19350
|
giveup = armSteerGiveup(binding.connection, binding.session.sessionId, timings, cancelled);
|
|
19350
19351
|
};
|
|
19352
|
+
timer = setTimeout(() => {
|
|
19353
|
+
if (!cancelSettled && timings.idleMs > 0) extendForNaturalCompletion();
|
|
19354
|
+
else cancelled();
|
|
19355
|
+
}, timeoutMs);
|
|
19351
19356
|
try {
|
|
19352
19357
|
abort();
|
|
19353
19358
|
void (async () => {
|
|
19354
19359
|
try {
|
|
19355
19360
|
await binding.connection.cancel(binding.session.sessionId);
|
|
19361
|
+
cancelSettled = true;
|
|
19356
19362
|
if (timings.idleMs > 0) extendForNaturalCompletion();
|
|
19357
19363
|
else deadline.resolve(false);
|
|
19358
19364
|
} catch (error62) {
|
|
19365
|
+
cancelSettled = true;
|
|
19359
19366
|
if (timings.idleMs > 0 && isCancelUnsupported(error62)) extendForNaturalCompletion();
|
|
19360
19367
|
else deadline.resolve(false);
|
|
19361
19368
|
}
|
|
@@ -19461,17 +19468,9 @@ function createStructuredFingerprintMemo() {
|
|
|
19461
19468
|
}
|
|
19462
19469
|
|
|
19463
19470
|
// extension/tool-routing.ts
|
|
19464
|
-
var TOOL_ROUTING =
|
|
19465
|
-
OMP tool routing:
|
|
19466
|
-
The supplied OMP tools are exposed by the authenticated pi-bridge MCP server with pi_ prefixes. When eagerly registered, call these tools directly using their advertised names.
|
|
19467
|
-
For workspace reads, searches, edits, command execution, and other user tasks, choose an appropriate supplied pi_ MCP tool before considering an Antigravity-native tool. Their results return through the OMP tool loop.
|
|
19468
|
-
You may use Antigravity's normal MCP discovery mechanism to inspect the pi-bridge tool manifests if required. Do not search unrelated directories or configuration files to locate MCP tools.
|
|
19469
|
-
If an OMP tool fails, inspect the error and correct its arguments when appropriate. Do not switch to a native tool merely because the OMP call failed.
|
|
19470
|
-
If no suitable OMP tool is available, explain the missing capability. Before substituting an Antigravity-native tool for a user task, state the proposed tool and reason and obtain the user's explicit approval. Without approval, stop that operation and report the limitation.
|
|
19471
|
-
This exception does not require approval for normal pi-bridge MCP manifest discovery; it applies to performing the user's task with native tools.
|
|
19472
|
-
`;
|
|
19471
|
+
var TOOL_ROUTING = "Supplied OMP tools are exposed by the authenticated pi-bridge MCP server with pi_ prefixes. Call them directly for user tasks. If no OMP tool fits, report the missing capability and obtain explicit approval before using an Antigravity-native tool.";
|
|
19473
19472
|
function systemRouting(mode) {
|
|
19474
|
-
return TOOL_ROUTING + (mode === "disabled" ? "\
|
|
19473
|
+
return TOOL_ROUTING + (mode === "disabled" ? "\nAntigravity-native tools are disabled for this session. Report a missing capability instead of substituting one." : "");
|
|
19475
19474
|
}
|
|
19476
19475
|
function supportsSessionRouting(initialize) {
|
|
19477
19476
|
const version2 = initialize?.agentInfo?.version?.match(/^(\d+)\.(\d+)\.(\d+)$/);
|
|
@@ -59530,6 +59529,7 @@ function writeJsonAtomic(file2, value, pretty = true) {
|
|
|
59530
59529
|
}
|
|
59531
59530
|
|
|
59532
59531
|
// extension/context-settings.ts
|
|
59532
|
+
var DEFAULT_USAGE_MODE = "off";
|
|
59533
59533
|
function resolveContextOptions(model, settings2) {
|
|
59534
59534
|
const options = { ...settings2.defaults, ...settings2.models[model.id] };
|
|
59535
59535
|
const contextWindow = options.contextWindow ?? model.contextWindow;
|
|
@@ -59613,7 +59613,7 @@ function isVolatileReminder(body) {
|
|
|
59613
59613
|
return lines.length > 0 && lines.every((line) => /^Today: .*$/u.test(line) || /^OMP tool names: .*$/u.test(line));
|
|
59614
59614
|
}
|
|
59615
59615
|
function stableSystemContent(text) {
|
|
59616
|
-
return text.replace(DATE_CWD_REMINDER, "").replace(SYSTEM_REMINDER_TAG, (match, body) => isVolatileReminder(body) ? "" : match).replace(OMP_TOOL_NAMES_LINE, "").replace(
|
|
59616
|
+
return text.replace(DATE_CWD_REMINDER, "").replace(SYSTEM_REMINDER_TAG, (match, body) => isVolatileReminder(body) ? "" : match).replace(OMP_TOOL_NAMES_LINE, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
59617
59617
|
}
|
|
59618
59618
|
function stableSystemInstructions(context) {
|
|
59619
59619
|
return stableSystemContent(currentSystemInstructions(context));
|
|
@@ -59937,9 +59937,15 @@ ${instructions}` : "";
|
|
|
59937
59937
|
if (promptTextBytes(prompt) > ACP_STEP_TEXT_BYTES) {
|
|
59938
59938
|
const seedTail = [{ type: "text", text: SEED_ACK_TEXT }];
|
|
59939
59939
|
let pendingInstructions = instructionsBlock;
|
|
59940
|
+
let finalInstructions;
|
|
59941
|
+
if (pendingInstructions && promptTextBytes(assembleStep(pendingInstructions, [], seedTail)) > ACP_STEP_TEXT_BYTES) {
|
|
59942
|
+
finalInstructions = pendingInstructions;
|
|
59943
|
+
pendingInstructions = void 0;
|
|
59944
|
+
}
|
|
59940
59945
|
let cursor = 0;
|
|
59941
59946
|
while (cursor < recordItems.length || pendingInstructions) {
|
|
59942
|
-
const
|
|
59947
|
+
const remainingInstructions = finalInstructions ?? pendingInstructions;
|
|
59948
|
+
const remaining = assembleStep(remainingInstructions, recordItems.slice(cursor), tailBlocks);
|
|
59943
59949
|
if (promptTextBytes(remaining) <= ACP_STEP_TEXT_BYTES) break;
|
|
59944
59950
|
const chunkItems = [];
|
|
59945
59951
|
const chunkInst = pendingInstructions;
|
|
@@ -59960,7 +59966,7 @@ ${instructions}` : "";
|
|
|
59960
59966
|
historySeedSteps.push(seedStep);
|
|
59961
59967
|
pendingInstructions = void 0;
|
|
59962
59968
|
}
|
|
59963
|
-
prompt = assembleStep(pendingInstructions, recordItems.slice(cursor), tailBlocks);
|
|
59969
|
+
prompt = assembleStep(finalInstructions ?? pendingInstructions, recordItems.slice(cursor), tailBlocks);
|
|
59964
59970
|
checkStepTextBytes(promptTextBytes(prompt));
|
|
59965
59971
|
}
|
|
59966
59972
|
const seedSteps = historySeedSteps.length || requestSeedSteps.length ? [...historySeedSteps, ...requestSeedSteps] : void 0;
|
|
@@ -61162,7 +61168,6 @@ var AntigravityRuntime = class {
|
|
|
61162
61168
|
for (const activity of mapSessionUpdate(notification)) {
|
|
61163
61169
|
if (activity.type === "text") binding.writer.text(activity.delta);
|
|
61164
61170
|
else if (activity.type === "thought") binding.writer.thinking(activity.delta);
|
|
61165
|
-
else if (activity.type === "tool" || activity.type === "plan") binding.writer.thinking(activity.text);
|
|
61166
61171
|
}
|
|
61167
61172
|
}
|
|
61168
61173
|
async ompRemoveSaved(piSessionId, acpSessionId) {
|
|
@@ -61552,6 +61557,12 @@ function resolveSelection(state, requested) {
|
|
|
61552
61557
|
return { modelId: requested };
|
|
61553
61558
|
}
|
|
61554
61559
|
|
|
61560
|
+
// extension/activity-presentation.ts
|
|
61561
|
+
function showAcpUpdate(notification, debugToolUpdates) {
|
|
61562
|
+
const kind = notification.update?.sessionUpdate;
|
|
61563
|
+
return debugToolUpdates || kind !== "tool_call" && kind !== "tool_call_update";
|
|
61564
|
+
}
|
|
61565
|
+
|
|
61555
61566
|
// extension/acp-compaction.ts
|
|
61556
61567
|
function isTerminalCompaction(status) {
|
|
61557
61568
|
return status === "completed" || status === "failed" || status === "cancelled";
|
|
@@ -61620,7 +61631,7 @@ function parseSessionUsage(text) {
|
|
|
61620
61631
|
if (!Object.keys(counts).length && total > 0) return;
|
|
61621
61632
|
const usage = { input: counts.prompt ?? 0, completion: counts.completion ?? 0, thinking: counts.thinking ?? 0, cached: counts.cached, total };
|
|
61622
61633
|
if (usage.cached !== void 0 && usage.cached > usage.input) return;
|
|
61623
|
-
if (usage.input + usage.completion + usage.thinking
|
|
61634
|
+
if (usage.input + usage.completion + usage.thinking > usage.total) return;
|
|
61624
61635
|
return usage;
|
|
61625
61636
|
}
|
|
61626
61637
|
function usageDelta(before, after) {
|
|
@@ -61676,7 +61687,7 @@ var TierConnection = class extends AntigravityAcpConnection {
|
|
|
61676
61687
|
void this.process.exited.then(() => this.releaseCleanupLeases()).catch(() => {
|
|
61677
61688
|
});
|
|
61678
61689
|
this.debugToolUpdates = options.ompDebugToolUpdates ?? false;
|
|
61679
|
-
this.usageMode = options.ompUsageMode ??
|
|
61690
|
+
this.usageMode = options.ompUsageMode ?? DEFAULT_USAGE_MODE;
|
|
61680
61691
|
this.steerMode = options.ompSteerMode ?? steerMode();
|
|
61681
61692
|
this.steerTimings = options.ompSteerTimings ?? steerTimings();
|
|
61682
61693
|
this.setHandlers({ ...options.handlers, onUpdate: async (notification) => {
|
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
import { AntigravityAcpConnection } from "./vendor/pi-antigravity-acp-provider/src/acp/connection.ts";
|
|
4
4
|
import { choices, resolveSelection, selector } from "./selectors.ts";
|
|
5
5
|
import { installSessionRouting, type NativeToolMode } from "./tool-routing.ts";
|
|
6
|
+
import { showAcpUpdate } from "./activity-presentation.ts";
|
|
6
7
|
import { alignContextTokens, applyCompactionChunk, applyCompactionUpdate, isTerminalCompaction, type AcpCompactionNotice, type AcpCompactionRecord } from "./acp-compaction.ts";
|
|
7
8
|
import { parseSessionUsage, usageDelta, type SessionUsage } from "./usage-accounting.ts";
|
|
9
|
+
import { DEFAULT_USAGE_MODE } from "./context-settings.ts";
|
|
8
10
|
import type { SessionCleanup } from "./session-cleanup.ts";
|
|
9
11
|
import type { Diagnostics } from "./diagnostics.ts";
|
|
10
12
|
import { deferredAbortSignal, isSteerAbort, steerMode as resolveSteerMode, steerTimings as resolveSteerTimings, type SteerMode, type SteerTimings } from "./turn-cancellation.ts";
|
|
@@ -45,7 +47,7 @@ export class TierConnection extends AntigravityAcpConnection {
|
|
|
45
47
|
this.cleanup?.start();
|
|
46
48
|
void this.process.exited.then(() => this.releaseCleanupLeases()).catch(() => {});
|
|
47
49
|
this.debugToolUpdates = options.ompDebugToolUpdates ?? false;
|
|
48
|
-
this.usageMode = options.ompUsageMode ??
|
|
50
|
+
this.usageMode = options.ompUsageMode ?? DEFAULT_USAGE_MODE;
|
|
49
51
|
this.steerMode = options.ompSteerMode ?? resolveSteerMode();
|
|
50
52
|
this.steerTimings = options.ompSteerTimings ?? resolveSteerTimings();
|
|
51
53
|
this.setHandlers({ ...options.handlers, onUpdate: async notification => {
|
|
@@ -1,18 +1,11 @@
|
|
|
1
1
|
export type NativeToolMode = "prefer" | "disabled";
|
|
2
2
|
|
|
3
|
-
export const TOOL_ROUTING =
|
|
4
|
-
OMP tool
|
|
5
|
-
The supplied OMP tools are exposed by the authenticated pi-bridge MCP server with pi_ prefixes. When eagerly registered, call these tools directly using their advertised names.
|
|
6
|
-
For workspace reads, searches, edits, command execution, and other user tasks, choose an appropriate supplied pi_ MCP tool before considering an Antigravity-native tool. Their results return through the OMP tool loop.
|
|
7
|
-
You may use Antigravity's normal MCP discovery mechanism to inspect the pi-bridge tool manifests if required. Do not search unrelated directories or configuration files to locate MCP tools.
|
|
8
|
-
If an OMP tool fails, inspect the error and correct its arguments when appropriate. Do not switch to a native tool merely because the OMP call failed.
|
|
9
|
-
If no suitable OMP tool is available, explain the missing capability. Before substituting an Antigravity-native tool for a user task, state the proposed tool and reason and obtain the user's explicit approval. Without approval, stop that operation and report the limitation.
|
|
10
|
-
This exception does not require approval for normal pi-bridge MCP manifest discovery; it applies to performing the user's task with native tools.
|
|
11
|
-
`;
|
|
3
|
+
export const TOOL_ROUTING =
|
|
4
|
+
"Supplied OMP tools are exposed by the authenticated pi-bridge MCP server with pi_ prefixes. Call them directly for user tasks. If no OMP tool fits, report the missing capability and obtain explicit approval before using an Antigravity-native tool.";
|
|
12
5
|
|
|
13
6
|
export function systemRouting(mode: NativeToolMode): string {
|
|
14
7
|
return TOOL_ROUTING + (mode === "disabled"
|
|
15
|
-
? "\
|
|
8
|
+
? "\nAntigravity-native tools are disabled for this session. Report a missing capability instead of substituting one."
|
|
16
9
|
: "");
|
|
17
10
|
}
|
|
18
11
|
|
|
@@ -23,6 +23,7 @@ export class TranscriptRouting {
|
|
|
23
23
|
if (transcriptId.includes(":side:")) return transcriptId;
|
|
24
24
|
if (this.pending.delete(transcriptId)) {
|
|
25
25
|
this.byTranscript.set(transcriptId, transcriptId);
|
|
26
|
+
if (!this.pending.size) this.ambiguous = false;
|
|
26
27
|
return transcriptId;
|
|
27
28
|
}
|
|
28
29
|
if (!this.ambiguous && this.pending.size === 1) {
|
|
@@ -143,9 +143,10 @@ export async function drainCancelledTurn(
|
|
|
143
143
|
if (!completion || signal?.aborted) return false;
|
|
144
144
|
const deadline = Promise.withResolvers<boolean>();
|
|
145
145
|
const cancelled = () => deadline.resolve(false);
|
|
146
|
-
let timer
|
|
146
|
+
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
147
147
|
let giveup: { dispose: () => void } | undefined;
|
|
148
148
|
let finished = false;
|
|
149
|
+
let cancelSettled = false;
|
|
149
150
|
signal?.addEventListener("abort", cancelled, { once: true });
|
|
150
151
|
// session/cancel is an ACP notification: a successful send only means the
|
|
151
152
|
// server received it, not that the prompt already stopped. Freeze retained
|
|
@@ -157,15 +158,24 @@ export async function drainCancelledTurn(
|
|
|
157
158
|
clearTimeout(timer);
|
|
158
159
|
giveup = armSteerGiveup(binding.connection, binding.session.sessionId, timings, cancelled);
|
|
159
160
|
};
|
|
161
|
+
timer = setTimeout(() => {
|
|
162
|
+
// A slow cancel RPC is not the same as a transport that never sent the
|
|
163
|
+
// notification. Give an unacknowledged-but-pending cancel the same grace
|
|
164
|
+
// as an acknowledged one before deciding to rebuild.
|
|
165
|
+
if (!cancelSettled && timings.idleMs > 0) extendForNaturalCompletion();
|
|
166
|
+
else cancelled();
|
|
167
|
+
}, timeoutMs);
|
|
160
168
|
try {
|
|
161
169
|
abort();
|
|
162
170
|
// A blocked cancel transport must not block the fallback deadline.
|
|
163
171
|
void (async () => {
|
|
164
172
|
try {
|
|
165
173
|
await binding.connection.cancel(binding.session.sessionId);
|
|
174
|
+
cancelSettled = true;
|
|
166
175
|
if (timings.idleMs > 0) extendForNaturalCompletion();
|
|
167
176
|
else deadline.resolve(false);
|
|
168
177
|
} catch (error) {
|
|
178
|
+
cancelSettled = true;
|
|
169
179
|
if (timings.idleMs > 0 && isCancelUnsupported(error)) extendForNaturalCompletion();
|
|
170
180
|
else deadline.resolve(false);
|
|
171
181
|
}
|
|
@@ -12,7 +12,7 @@ export function parseSessionUsage(text: string): SessionUsage | undefined {
|
|
|
12
12
|
if (!Object.keys(counts).length && total > 0) return;
|
|
13
13
|
const usage = { input: counts.prompt ?? 0, completion: counts.completion ?? 0, thinking: counts.thinking ?? 0, cached: counts.cached, total };
|
|
14
14
|
if (usage.cached !== undefined && usage.cached > usage.input) return;
|
|
15
|
-
if (usage.input + usage.completion + usage.thinking
|
|
15
|
+
if (usage.input + usage.completion + usage.thinking > usage.total) return;
|
|
16
16
|
return usage;
|
|
17
17
|
}
|
|
18
18
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omp-antigravity-acp-provider",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.35",
|
|
4
4
|
"ompAcpBundle": 1,
|
|
5
5
|
"description": "Google Antigravity ACP provider for Oh My Pi (OMP), with tool bridging and per-model thinking; derived from zacbemis/pi-antigravity-acp-provider",
|
|
6
6
|
"type": "module",
|