omp-antigravity-acp-provider 0.2.4 → 0.3.2
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/AGENT_INSTALL.md +2 -2
- package/README.md +12 -8
- package/THIRD_PARTY_NOTICES.md +1 -0
- package/extension/acp-errors.ts +27 -2
- package/extension/agent-notices.ts +216 -30
- package/extension/auth-sync.ts +15 -7
- package/extension/commands.ts +25 -2
- package/extension/index.ts +112 -12
- package/extension/model-catalog.ts +11 -12
- package/extension/omp-model-whitelist.ts +323 -0
- package/extension/omp-session-lifecycle.ts +3 -3
- package/extension/prompt-cloak.ts +131 -0
- package/extension/quota-usage.ts +12 -3
- package/extension/runtime/acp/antigravity.ts +42 -1
- package/extension/runtime/acp/connection.ts +5 -0
- package/extension/runtime/index.ts +6 -0
- package/extension/runtime/launch.ts +5 -1
- package/extension/runtime/models.ts +43 -4
- package/extension/runtime/prompt.ts +11 -10
- package/extension/runtime/provider.ts +3 -3
- package/extension/runtime/runtime.ts +245 -40
- package/extension/runtime/stream/pi-events.ts +20 -5
- package/extension/runtime/tools/bridge.ts +157 -7
- package/extension/runtime/tools/delivery.ts +260 -0
- package/extension/runtime/tools/relay.ts +32 -1
- package/extension/runtime/tools/schema.ts +189 -0
- package/extension/runtime.mjs +1265 -153
- package/extension/tier-connection.ts +13 -1
- package/extension/tool-relay-protocol.d.mts +2 -2
- package/extension/tool-relay-protocol.mjs +2 -2
- package/extension/tool-routing.ts +193 -16
- package/package.json +2 -2
|
@@ -7,7 +7,7 @@ import { choices, resolveSelection, selector } from "./selectors.ts";
|
|
|
7
7
|
import { normalizeInitializeResponse, sessionRoutingRequest, type NativeToolMode, type SessionRpcRequest, type SessionRoutingKind } from "./tool-routing.ts";
|
|
8
8
|
import { showAcpUpdate } from "./activity-presentation.ts";
|
|
9
9
|
import { alignContextTokens, applyCompactionChunk, applyCompactionUpdate, isTerminalCompaction, type AcpCompactionNotice, type AcpCompactionRecord } from "./acp-compaction.ts";
|
|
10
|
-
import { AgentNoticeFilter } from "./agent-notices.ts";
|
|
10
|
+
import { AgentNoticeFilter, type AgentNoticeCapture } from "./agent-notices.ts";
|
|
11
11
|
import { parseSessionUsage, usageDelta, type SessionUsage } from "./usage-accounting.ts";
|
|
12
12
|
import { conversationDbPath, peekMaxModelStepIdx, readModelStepsAfter, type StepUsageBatch } from "./usage-db.ts";
|
|
13
13
|
import { DEFAULT_USAGE_MODE } from "./context-settings.ts";
|
|
@@ -471,11 +471,20 @@ export class TierConnection extends AntigravityAcpConnection {
|
|
|
471
471
|
this.usageReads?.delete(id);
|
|
472
472
|
this.noticeFilter?.forget(id);
|
|
473
473
|
this.noticeClosed?.delete(id);
|
|
474
|
+
// Captured failure evidence outlives the per-turn forget so the finished
|
|
475
|
+
// turn stays readable; a retired session must not keep it.
|
|
476
|
+
this.noticeFilter?.consumeCaptured(id);
|
|
474
477
|
this.permissionIdentity?.forget(id);
|
|
475
478
|
this.permissionTurns?.delete(id);
|
|
476
479
|
this.steerMuted?.delete(id);
|
|
477
480
|
this.steerActivity?.delete(id);
|
|
478
481
|
}
|
|
482
|
+
|
|
483
|
+
consumeNoticeCapture(sessionId: string): AgentNoticeCapture | undefined {
|
|
484
|
+
const captured = this.noticeFilter.captured(sessionId);
|
|
485
|
+
if (!captured.terminal && !captured.apiDetail && !captured.refusedDetail) return undefined;
|
|
486
|
+
return this.noticeFilter.consumeCaptured(sessionId);
|
|
487
|
+
}
|
|
479
488
|
private permissionTurn(sessionId: string): number {
|
|
480
489
|
return this.permissionTurns?.get(sessionId) ?? 0;
|
|
481
490
|
}
|
|
@@ -638,6 +647,9 @@ export class TierConnection extends AntigravityAcpConnection {
|
|
|
638
647
|
override async prompt(request: Parameters<AntigravityAcpConnection["prompt"]>[0], signal?: AbortSignal): Promise<PromptResponse> {
|
|
639
648
|
this.activePrompts++;
|
|
640
649
|
const id = request.sessionId;
|
|
650
|
+
// A previous turn that threw before its capture was consumed must not leak
|
|
651
|
+
// that evidence into this turn's failure classification.
|
|
652
|
+
this.noticeFilter?.consumeCaptured(id);
|
|
641
653
|
this.noticeClosed?.delete(id);
|
|
642
654
|
const permissionTurn = this.permissionTurn(id) + 1;
|
|
643
655
|
this.permissionTurns?.set(id, permissionTurn);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export declare const TOOL_RELAY_CONTROL_NAME = "
|
|
2
|
-
export declare const TOOL_RELAY_PI_NAME = "
|
|
1
|
+
export declare const TOOL_RELAY_CONTROL_NAME = "omp_await_result";
|
|
2
|
+
export declare const TOOL_RELAY_PI_NAME = "await_result";
|
|
3
3
|
export declare const TOOL_RELAY_VERSION = 1;
|
|
4
4
|
export declare function relayNotice(callId: string): string;
|
|
5
5
|
export declare function parseRelayCallId(text: unknown): string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const TOOL_RELAY_CONTROL_NAME = "
|
|
2
|
-
export const TOOL_RELAY_PI_NAME = "
|
|
1
|
+
export const TOOL_RELAY_CONTROL_NAME = "omp_await_result";
|
|
2
|
+
export const TOOL_RELAY_PI_NAME = "await_result";
|
|
3
3
|
export const TOOL_RELAY_VERSION = 1;
|
|
4
4
|
|
|
5
5
|
export function relayNotice(callId) {
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { InitializeResponse } from "@agentclientprotocol/sdk";
|
|
2
2
|
|
|
3
|
+
import { cloakText } from "./prompt-cloak.ts";
|
|
4
|
+
|
|
3
5
|
export type NativeToolMode = "prefer" | "disabled";
|
|
4
6
|
|
|
5
7
|
// A main session may delegate through the pi-bridge; an ephemeral side turn
|
|
@@ -10,20 +12,20 @@ export type SessionRoutingKind = "main" | "ephemeral";
|
|
|
10
12
|
// the pi-bridge MCP server. Keep the mapping short and schema-driven instead of
|
|
11
13
|
// naming an agent roster the runtime cannot verify.
|
|
12
14
|
const PI_BRIDGE_GUIDANCE =
|
|
13
|
-
"OMP tools exposed by the authenticated pi-bridge MCP server use
|
|
14
|
-
"Native OMP guidance about task maps to
|
|
15
|
+
"OMP tools exposed by the authenticated pi-bridge MCP server use omp_ names. " +
|
|
16
|
+
"Native OMP guidance about task maps to omp_task: submit delegated work by calling omp_task, " +
|
|
15
17
|
"and follow the supplied tool schema for agent selection and for delegated or parallel work. " +
|
|
16
18
|
"Use the supplied wait mechanism for completion notifications. " +
|
|
17
|
-
"Use only supplied
|
|
19
|
+
"Use only supplied omp_* tools that appear in the active tool list. " +
|
|
18
20
|
"Antigravity-native tools run in a separate runtime with their own permission negotiation; " +
|
|
19
21
|
"their results are not OMP tool results.";
|
|
20
22
|
|
|
21
23
|
function contextControlGuidance(projectedToolNames: readonly string[]): string {
|
|
22
24
|
return [
|
|
23
25
|
projectedToolNames.includes("context_notes")
|
|
24
|
-
? "Native OMP guidance about context_notes maps to
|
|
26
|
+
? "Native OMP guidance about context_notes maps to omp_context_notes." : "",
|
|
25
27
|
projectedToolNames.includes("new_context")
|
|
26
|
-
? "Native OMP guidance about new_context maps to
|
|
28
|
+
? "Native OMP guidance about new_context maps to omp_new_context." : "",
|
|
27
29
|
].filter(Boolean).join(" ");
|
|
28
30
|
}
|
|
29
31
|
|
|
@@ -41,14 +43,14 @@ const EPHEMERAL_TOOL_GUIDANCE =
|
|
|
41
43
|
"no tools may be called in this side turn, and tool calls are discarded without execution. " +
|
|
42
44
|
"Reply with plain text only.";
|
|
43
45
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
//
|
|
46
|
+
// Disabled native tools redirect the Antigravity host prompt so the OMP
|
|
47
|
+
// instruction owns tool use. Prefer keeps native tools, so its append starts
|
|
48
|
+
// with the OMP text unchanged.
|
|
47
49
|
const ANTIGRAVITY_OVERRIDE =
|
|
48
|
-
"
|
|
50
|
+
"You are operating as the coding assistant for Oh My Pi (OMP). Follow the OMP instructions below.";
|
|
49
51
|
const ANTIGRAVITY_OVERRIDE_WITH_TOOLS =
|
|
50
|
-
"
|
|
51
|
-
"use only OMP
|
|
52
|
+
"You are operating as the coding assistant for Oh My Pi (OMP). Follow the OMP instructions below; " +
|
|
53
|
+
"use only OMP omp_* tools and omp_task for reads, writes, searches, commands and subagent delegation.";
|
|
52
54
|
|
|
53
55
|
function antigravityOverride(mode: NativeToolMode, sessionKind: SessionRoutingKind, hasOmpTools: boolean): string {
|
|
54
56
|
if (mode !== "disabled") return "";
|
|
@@ -144,9 +146,182 @@ export function ompToolGuidance(
|
|
|
144
146
|
return [guidance, contextGuidance, ...(mode === "disabled" ? [NATIVE_TOOLS_DISABLED] : [])].filter(Boolean).join("\n\n");
|
|
145
147
|
}
|
|
146
148
|
|
|
147
|
-
//
|
|
148
|
-
//
|
|
149
|
-
//
|
|
149
|
+
// agy refuses a prompt that embeds OMP's internal tool and device schemas:
|
|
150
|
+
// they are not valid for its runtime and only spend the customization budget.
|
|
151
|
+
// Section removal is line-based with fence tracking, so a `#` or `<` inside a
|
|
152
|
+
// fenced sample never truncates the section, and subheadings stay part of the
|
|
153
|
+
// section they belong to.
|
|
154
|
+
const INTERNAL_SECTIONS: ReadonlyArray<{ readonly level: number; readonly heading: RegExp }> = [
|
|
155
|
+
{ level: 1, heading: /^#\s+Internal URLs\s*$/ },
|
|
156
|
+
{ level: 1, heading: /^#\s+xd:\/\/\s*Tool Devices\s*$/ },
|
|
157
|
+
{ level: 2, heading: /^##\s+MCP Tool Routes\s*$/ },
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
function headingLevel(line: string): number | undefined {
|
|
161
|
+
const match = /^(#{1,6})\s/.exec(line);
|
|
162
|
+
return match ? match[1]!.length : undefined;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface Fence {
|
|
166
|
+
readonly char: "`" | "~";
|
|
167
|
+
readonly length: number;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function openingFence(line: string): Fence | undefined {
|
|
171
|
+
const match = /^\s{0,3}(`{3,}|~{3,})(.*)$/.exec(line);
|
|
172
|
+
if (!match) return undefined;
|
|
173
|
+
return { char: match[1]![0] as "`" | "~", length: match[1]!.length };
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function closesFence(line: string, open: Fence): boolean {
|
|
177
|
+
const match = /^\s{0,3}(`{3,}|~{3,})\s*$/.exec(line);
|
|
178
|
+
return match !== null && match[1]![0] === open.char && match[1]!.length >= open.length;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
// Marks every line belonging to a fenced code block, delimiters included.
|
|
182
|
+
// Opening and closing runs are tracked separately: a triple-backtick example
|
|
183
|
+
// inside a four-backtick fence is content, not a close.
|
|
184
|
+
function fencedLines(lines: readonly string[]): boolean[] {
|
|
185
|
+
const fenced: boolean[] = [];
|
|
186
|
+
let open: Fence | undefined;
|
|
187
|
+
for (const line of lines) {
|
|
188
|
+
if (open !== undefined) {
|
|
189
|
+
fenced.push(true);
|
|
190
|
+
if (closesFence(line, open)) open = undefined;
|
|
191
|
+
continue;
|
|
192
|
+
}
|
|
193
|
+
const opening = openingFence(line);
|
|
194
|
+
if (opening !== undefined) {
|
|
195
|
+
open = opening;
|
|
196
|
+
fenced.push(true);
|
|
197
|
+
continue;
|
|
198
|
+
}
|
|
199
|
+
fenced.push(false);
|
|
200
|
+
}
|
|
201
|
+
return fenced;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function isSectionBoundary(line: string, level: number): boolean {
|
|
205
|
+
if (line.startsWith("⁂") || line.startsWith("<")) return true;
|
|
206
|
+
const heading = headingLevel(line);
|
|
207
|
+
return heading !== undefined && heading <= level;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function internalSectionRanges(lines: readonly string[], fenced: readonly boolean[]): Array<readonly [number, number]> {
|
|
211
|
+
const ranges: Array<readonly [number, number]> = [];
|
|
212
|
+
for (let index = 0; index < lines.length; index++) {
|
|
213
|
+
if (fenced[index]) continue;
|
|
214
|
+
const section = INTERNAL_SECTIONS.find(candidate => candidate.heading.test(lines[index]!));
|
|
215
|
+
if (!section) continue;
|
|
216
|
+
let end = index + 1;
|
|
217
|
+
while (end < lines.length && (fenced[end] || !isSectionBoundary(lines[end]!, section.level))) end++;
|
|
218
|
+
ranges.push([index, end]);
|
|
219
|
+
index = end - 1;
|
|
220
|
+
}
|
|
221
|
+
return ranges;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// Balanced-brace scan for `namespace functions { ... }`, skipping strings and
|
|
225
|
+
// comments so a brace in a type literal or comment cannot end the block early.
|
|
226
|
+
// Returns the closing line, or undefined when the block never closes.
|
|
227
|
+
function namespaceClosingLine(lines: readonly string[], start: number): number | undefined {
|
|
228
|
+
const openColumn = lines[start]!.indexOf("{");
|
|
229
|
+
if (openColumn < 0) return undefined;
|
|
230
|
+
let depth = 0;
|
|
231
|
+
let blockComment = false;
|
|
232
|
+
let quote: "'" | '"' | "`" | undefined;
|
|
233
|
+
for (let line = start; line < lines.length; line++) {
|
|
234
|
+
const text = lines[line]!;
|
|
235
|
+
for (let column = line === start ? openColumn : 0; column < text.length; column++) {
|
|
236
|
+
const char = text[column];
|
|
237
|
+
if (blockComment) {
|
|
238
|
+
if (char === "*" && text[column + 1] === "/") {
|
|
239
|
+
blockComment = false;
|
|
240
|
+
column++;
|
|
241
|
+
}
|
|
242
|
+
continue;
|
|
243
|
+
}
|
|
244
|
+
if (quote !== undefined) {
|
|
245
|
+
if (char === "\\") column++;
|
|
246
|
+
else if (char === quote) quote = undefined;
|
|
247
|
+
continue;
|
|
248
|
+
}
|
|
249
|
+
if (char === "/" && text[column + 1] === "/") break;
|
|
250
|
+
if (char === "/" && text[column + 1] === "*") {
|
|
251
|
+
blockComment = true;
|
|
252
|
+
column++;
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
if (char === "'" || char === '"' || char === "`") {
|
|
256
|
+
quote = char;
|
|
257
|
+
continue;
|
|
258
|
+
}
|
|
259
|
+
if (char === "{") {
|
|
260
|
+
depth++;
|
|
261
|
+
} else if (char === "}") {
|
|
262
|
+
depth--;
|
|
263
|
+
if (depth === 0) return line;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
return undefined;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
// The heading directly above the block and a trailing `// namespace functions`
|
|
271
|
+
// comment belong to the same generated schema fragment.
|
|
272
|
+
function namespaceRange(
|
|
273
|
+
lines: readonly string[],
|
|
274
|
+
fenced: readonly boolean[],
|
|
275
|
+
start: number,
|
|
276
|
+
closing: number,
|
|
277
|
+
): readonly [number, number] {
|
|
278
|
+
let from = start;
|
|
279
|
+
for (let line = start - 1; line >= 0; line--) {
|
|
280
|
+
if (lines[line]!.trim() === "") continue;
|
|
281
|
+
if (!fenced[line] && /^#{1,6}\s+functions\s*$/.test(lines[line]!)) from = line;
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
let to = closing + 1;
|
|
285
|
+
for (let line = closing + 1; line < lines.length; line++) {
|
|
286
|
+
const text = lines[line]!.trim();
|
|
287
|
+
if (text === "") continue;
|
|
288
|
+
if (/^\/\/\s*namespace functions\b/.test(text)) {
|
|
289
|
+
to = line + 1;
|
|
290
|
+
continue;
|
|
291
|
+
}
|
|
292
|
+
break;
|
|
293
|
+
}
|
|
294
|
+
return [from, to];
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
export function cleanOmpSystemInstructions(instructions: string): string {
|
|
298
|
+
if (!instructions) return "";
|
|
299
|
+
const lines = instructions.split("\n");
|
|
300
|
+
const fenced = fencedLines(lines);
|
|
301
|
+
const dropped = lines.map(() => false);
|
|
302
|
+
for (const [from, to] of internalSectionRanges(lines, fenced)) {
|
|
303
|
+
for (let line = from; line < to; line++) dropped[line] = true;
|
|
304
|
+
}
|
|
305
|
+
for (let line = 0; line < lines.length; line++) {
|
|
306
|
+
if (fenced[line]) continue;
|
|
307
|
+
if (!/^\s*namespace\s+functions\s*\{/.test(lines[line]!)) continue;
|
|
308
|
+
const closing = namespaceClosingLine(lines, line);
|
|
309
|
+
// An unbalanced block is left alone: truncating the rest of the prompt
|
|
310
|
+
// would delete user instructions instead of internal schema text.
|
|
311
|
+
if (closing === undefined) continue;
|
|
312
|
+
const [from, to] = namespaceRange(lines, fenced, line, closing);
|
|
313
|
+
for (let index = from; index < to; index++) dropped[index] = true;
|
|
314
|
+
line = to - 1;
|
|
315
|
+
}
|
|
316
|
+
if (!dropped.some(Boolean)) return instructions;
|
|
317
|
+
return lines.filter((_, index) => !dropped[index]).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Composes the session append: optional Antigravity override, the cleaned
|
|
321
|
+
// complete OMP instruction, then the existing tool guidance. Disabled mode
|
|
322
|
+
// also rewords known fingerprint phrases agy refuses with 429s; prefer stays
|
|
323
|
+
// byte-identical apart from the cleaning above.
|
|
324
|
+
// `hasOmpTools` is only needed when the bridge is registered without tools.
|
|
150
325
|
export function sessionSystemAppend(
|
|
151
326
|
initialize: InitializeMetadata | undefined,
|
|
152
327
|
mode: NativeToolMode,
|
|
@@ -157,9 +332,11 @@ export function sessionSystemAppend(
|
|
|
157
332
|
projectedToolNames: readonly string[] = [],
|
|
158
333
|
): string {
|
|
159
334
|
const bridgeActive = bridgeConfigured && hasOmpTools !== false && mcpHttpAvailable(initialize);
|
|
335
|
+
const cleaned = cleanOmpSystemInstructions(instructions);
|
|
336
|
+
const instructionText = mode === "disabled" ? cloakText(cleaned).text : cleaned;
|
|
160
337
|
return [
|
|
161
338
|
antigravityOverride(mode, sessionKind, bridgeActive),
|
|
162
|
-
|
|
339
|
+
instructionText,
|
|
163
340
|
ompToolGuidance(initialize, mode, bridgeActive, sessionKind, projectedToolNames),
|
|
164
341
|
].filter(Boolean).join("\n\n");
|
|
165
342
|
}
|
|
@@ -200,7 +377,7 @@ export function sessionRoutingRequest<T extends SessionRpcRequest>(
|
|
|
200
377
|
const bridgeConfigured = request.mcpServers?.some(server => server.name === "pi-bridge") === true;
|
|
201
378
|
// A registered bridge normally implies tools; the explicit false override
|
|
202
379
|
// keeps an externally registered empty bridge from being eagerly connected
|
|
203
|
-
// or advertised as
|
|
380
|
+
// or advertised as omp_ tools.
|
|
204
381
|
if (hasOmpTools === false) eager.delete("pi-bridge");
|
|
205
382
|
else if (bridgeConfigured) eager.add("pi-bridge");
|
|
206
383
|
return { ...request, _meta: { ...request._meta, antigravity: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omp-antigravity-acp-provider",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
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",
|
|
@@ -88,5 +88,5 @@
|
|
|
88
88
|
"acp",
|
|
89
89
|
"gemini"
|
|
90
90
|
],
|
|
91
|
-
"gitHead": "
|
|
91
|
+
"gitHead": "e229b8f1bdc0d60ca8a8b5a08515d9c54f0d9529"
|
|
92
92
|
}
|