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.
@@ -0,0 +1,131 @@
1
+ /**
2
+ * Rewrites system-prompt phrases Antigravity refuses regardless of quota.
3
+ *
4
+ * agy answers some third-party harness prompt lines with RESOURCE_EXHAUSTED
5
+ * (429) whatever quota is left; the refusal is content-based, so waiting or
6
+ * switching models does not help. The known lines are reworded minimally
7
+ * before they reach `systemPrompt.append`: meaning is preserved, the exact
8
+ * fingerprint is not. Phrase list and rewordings adapted from
9
+ * a community Antigravity bridge plugin's cloak module (MIT, DylanLIiii, gitxm, yce; see
10
+ * THIRD_PARTY_NOTICES.md); Claude-Code-only long passages and billing-header
11
+ * lines are omitted because OMP instructions cannot contain them.
12
+ */
13
+ export interface CloakRule {
14
+ id: string;
15
+ /** Lowercase, whitespace-folded needle matched against normalized text. */
16
+ phrase: string;
17
+ /** Produces the replacement for the matched source slice. */
18
+ says: (matched: string) => string;
19
+ }
20
+
21
+ const youAre = (matched: string) => matched.replace(/^you\s+are/iu, "you're");
22
+ const basedToBuilt = (matched: string) => matched.replace(/based(\s+)on/iu, "built$1");
23
+
24
+ export const CLOAK_RULES: readonly CloakRule[] = [
25
+ { id: "claude-agent-sdk", phrase: "built on anthropic's claude agent sdk",
26
+ says: matched => matched.replace(/^(built\s+on\s+)anthropic's(\s+)(claude\s+agent\s+sdk)$/iu, "$1the$2$3 by Anthropic") },
27
+ { id: "codex-agent", phrase: "you are codex, an agent based on gpt-5", says: basedToBuilt },
28
+ { id: "codex-coding-agent", phrase: "you are codex, a coding agent based on gpt-5", says: basedToBuilt },
29
+ { id: "rfc2119-keywords", phrase: "rfc 2119 keywords: must, required, should, recommended, may, optional.",
30
+ says: matched => matched.replace(/(key)(words)/iu, "$1 $2") },
31
+ { id: "hermes-agent", phrase: "you are hermes agent", says: youAre },
32
+ { id: "nous-research", phrase: "an intelligent ai assistant created by nous research",
33
+ says: matched => matched.replace(/created(\s+)by/iu, "built$1") },
34
+ { id: "opencode", phrase: "you are opencode", says: youAre },
35
+ { id: "codex-cli", phrase: "you are a coding agent running in the codex cli", says: youAre },
36
+ { id: "pi-harness", phrase: "a coding assistant running inside pi",
37
+ says: matched => matched.replace(/inside/iu, "within") },
38
+ { id: "deepseek-harness", phrase: "you are an ai agent powered by deepseek harness", says: youAre },
39
+ { id: "claude-code", phrase: "you are claude code, anthropic's official cli for claude", says: youAre },
40
+ { id: "pi-bolt", phrase: "you are a coding assistant running inside pi-bolt",
41
+ says: matched => matched.replace(/pi-bolt$/iu, "a tool") },
42
+ // Verified live on 2026-11-16: this exact guidance sentence alone draws a
43
+ // 429 whatever quota is left, while the reworded form passes; the detector
44
+ // is sentence-level, so breaking the token chain is what matters.
45
+ { id: "omp-tool-docs", phrase: "for full docs + json schema before first use",
46
+ says: matched => matched.replace(/\+\s*/u, "and ").replace(/schema(?!\s*s)/iu, "schemas") },
47
+ // Also verified live on 2026-11-16: the canonical smoke-test prompt
48
+ // "Reply with exactly: OK" alone draws the 429 when it lands in the system
49
+ // prompt (a recalled memory can carry it there), while the same words as a
50
+ // user turn or with any other value pass.
51
+ { id: "omp-eval-prompt", phrase: "reply with exactly: ok",
52
+ says: matched => matched.replace(/^reply/iu, "Respond") },
53
+ ];
54
+
55
+ const INVISIBLE_RE = /[\u00ad\u180e\u200b-\u200f\u2060-\u2064\ufeff]/gu;
56
+
57
+ function isInvisible(code: number): boolean {
58
+ return code === 0x00ad || code === 0x180e ||
59
+ (code >= 0x200b && code <= 0x200f) || (code >= 0x2060 && code <= 0x2064) || code === 0xfeff;
60
+ }
61
+
62
+ /**
63
+ * Folds text for matching while retaining source offsets: invisible
64
+ * characters are skipped, letters are lowercased, and whitespace runs become
65
+ * one space. Only matched spans are ever rewritten, so the rest of the source
66
+ * stays byte-identical.
67
+ */
68
+ function matchText(text: string): { text: string; offsets: number[] } {
69
+ const chars: string[] = [];
70
+ const offsets: number[] = [];
71
+ let previousSpace = false;
72
+ for (let i = 0; i < text.length; i++) {
73
+ const code = text.charCodeAt(i);
74
+ if (isInvisible(code)) continue;
75
+ const char = text[i]!;
76
+ if (/\s/u.test(char)) {
77
+ if (!previousSpace) {
78
+ chars.push(" ");
79
+ offsets.push(i);
80
+ }
81
+ previousSpace = true;
82
+ } else {
83
+ chars.push(code >= 65 && code <= 90 ? String.fromCharCode(code + 32) : char);
84
+ offsets.push(i);
85
+ previousSpace = false;
86
+ }
87
+ }
88
+ return { text: chars.join(""), offsets };
89
+ }
90
+
91
+ export interface CloakResult {
92
+ text: string;
93
+ /** Rule ids whose phrase appeared in the source. */
94
+ matched: string[];
95
+ }
96
+
97
+ /** Rewrites every known fingerprint phrase in `text`, leaving the rest intact. */
98
+ export function cloakText(text: string): CloakResult {
99
+ if (typeof text !== "string" || !text) return { text, matched: [] };
100
+ const normalized = matchText(text);
101
+ const matched: string[] = [];
102
+ const spans: Array<[number, number, CloakRule]> = [];
103
+ for (const rule of CLOAK_RULES) {
104
+ let from = 0;
105
+ for (;;) {
106
+ const at = normalized.text.indexOf(rule.phrase, from);
107
+ if (at < 0) break;
108
+ spans.push([normalized.offsets[at]!, normalized.offsets[at + rule.phrase.length - 1]! + 1, rule]);
109
+ if (!matched.includes(rule.id)) matched.push(rule.id);
110
+ from = at + rule.phrase.length;
111
+ }
112
+ }
113
+ if (!spans.length) return { text, matched };
114
+ spans.sort((a, b) => a[0] - b[0]);
115
+ let result = "";
116
+ let previous = 0;
117
+ for (const [from, to, rule] of spans) {
118
+ if (from < previous) continue;
119
+ result += text.slice(previous, from);
120
+ result += rule.says(text.slice(from, to).replace(INVISIBLE_RE, ""));
121
+ previous = to;
122
+ }
123
+ return { text: result + text.slice(previous), matched };
124
+ }
125
+
126
+ /** Whether `text` still contains any known fingerprint phrase. */
127
+ export function turnsAway(text: string): boolean {
128
+ if (typeof text !== "string" || !text) return false;
129
+ const normalized = matchText(text).text;
130
+ return CLOAK_RULES.some(rule => normalized.includes(rule.phrase));
131
+ }
@@ -21,6 +21,8 @@ export interface QuotaUsageScope {
21
21
  modelId?: string;
22
22
  tier?: string;
23
23
  windowId?: string;
24
+ shared?: boolean;
25
+ sharedGroup?: string;
24
26
  }
25
27
 
26
28
  export interface QuotaUsageLimit {
@@ -67,7 +69,7 @@ export interface QuotaUsageProvider {
67
69
  fetchUsage(params: QuotaUsageProviderParams, ctx: QuotaUsageProviderContext): Promise<QuotaUsageReport | null>;
68
70
  }
69
71
 
70
- const DEFAULT_PROVIDER = "antigravity-acp";
72
+ const DEFAULT_PROVIDER = "antigravity-acp-provider";
71
73
  const WEEK_MS = 604_800_000;
72
74
  const FIVE_HOURS_MS = 18_000_000;
73
75
  const DAY_MS = 86_400_000;
@@ -137,14 +139,21 @@ export function quotaSnapshotToUsageReport(
137
139
  ? Math.min(1, Math.max(0, bucket.remainingFraction)) : 0;
138
140
  const usedFraction = 1 - remainingFraction;
139
141
  for (const modelId of matches.length ? matches : [undefined]) {
140
- const scope: QuotaUsageScope = { provider, tier: group.displayName, windowId: window.id };
142
+ const isShared = matches.length > 1 || group.displayName.toLowerCase().includes("models");
143
+ const sharedGroup = isShared ? `${provider}:${groupSlug}:${window.id}` : undefined;
144
+ const scope: QuotaUsageScope = {
145
+ provider,
146
+ tier: group.displayName,
147
+ windowId: window.id,
148
+ ...(isShared ? { shared: true, sharedGroup } : {}),
149
+ };
141
150
  if (modelId) scope.modelId = modelId;
142
151
  const baseId = `${provider}:${groupSlug}${modelId ? `:${slug(modelId)}` : ""}:${window.id}`;
143
152
  const seen = usedIds.get(baseId) ?? 0;
144
153
  usedIds.set(baseId, seen + 1);
145
154
  limits.push({
146
155
  id: seen === 0 ? baseId : `${baseId}-${seen + 1}`,
147
- label: `${group.displayName}${matches.length > 1 ? ` (${modelId})` : ""} ${window.label}`,
156
+ label: `${group.displayName} ${window.label}`,
148
157
  scope,
149
158
  window: { ...window, ...(Number.isFinite(resetsAt) ? { resetsAt } : {}) },
150
159
  amount: {
@@ -49,6 +49,11 @@ export type AntigravityAuthStatus =
49
49
  | "corrupt"
50
50
  | "missing";
51
51
 
52
+ /** Adapter-owned marker recording a logout the server's own stores cannot
53
+ * express: it stops the CLI token sync from copying a personal login back into
54
+ * this ACP tree and keeps auth inspection logged out until a fresh login. */
55
+ export const ANTIGRAVITY_LOGOUT_MARKER = "logged-out";
56
+
52
57
  export interface AntigravityAuthHealth {
53
58
  status: AntigravityAuthStatus;
54
59
  authType?: string;
@@ -69,6 +74,33 @@ export function resolveAntigravityAcpDirectory(env: NodeJS.ProcessEnv = process.
69
74
  return path.join(base, "antigravity-acp");
70
75
  }
71
76
 
77
+ /** The agy CLI's own token file. It follows the same home rules as the ACP tree
78
+ * so an explicit `GEMINI_HOME` never mixes the isolated tree with the real
79
+ * user's CLI login. */
80
+ export function resolveAntigravityCliTokenPath(env: NodeJS.ProcessEnv = process.env): string {
81
+ const home = effectiveHome(env);
82
+ const geminiHome = env.GEMINI_HOME?.trim();
83
+ const base = geminiHome ? expandHome(geminiHome, home) : path.join(home, ".gemini");
84
+ return path.join(base, "antigravity-cli", "antigravity-oauth-token");
85
+ }
86
+
87
+ export function isAntigravityLoggedOut(directory = resolveAntigravityAcpDirectory()): boolean {
88
+ return regularFile(path.join(directory, ANTIGRAVITY_LOGOUT_MARKER));
89
+ }
90
+
91
+ export function markAntigravityLoggedOut(directory = resolveAntigravityAcpDirectory()): void {
92
+ fs.mkdirSync(directory, { recursive: true, mode: 0o700 });
93
+ fs.writeFileSync(
94
+ path.join(directory, ANTIGRAVITY_LOGOUT_MARKER),
95
+ `${JSON.stringify({ loggedOutAt: new Date().toISOString() })}\n`,
96
+ { mode: 0o600 },
97
+ );
98
+ }
99
+
100
+ export function clearAntigravityLogoutMarker(directory = resolveAntigravityAcpDirectory()): void {
101
+ fs.rmSync(path.join(directory, ANTIGRAVITY_LOGOUT_MARKER), { force: true });
102
+ }
103
+
72
104
  /** Structural local health only. A network probe is required to call an OAuth
73
105
  * token valid; secret values are never returned or logged. `env` is the
74
106
  * environment whose credentials are inspected, not necessarily this process's. */
@@ -93,6 +125,11 @@ export function inspectAntigravityAuth(
93
125
  }
94
126
  }
95
127
  if (env.GEMINI_API_KEY) return { status: "api-key-env", authType: "gemini-api-key", tokenFile, settingsFile };
128
+ // A recorded logout survives restarts and cannot be undone by a later CLI
129
+ // token sync. Without a token file it reports the logged-out state instead of
130
+ // the settings file's stale auth choice; a token stored by a real login
131
+ // (including one this adapter never observed) is inspected normally.
132
+ if (!tokenFile && isAntigravityLoggedOut(directory)) return { status: "missing", tokenFile, settingsFile };
96
133
  if (tokenFile) {
97
134
  try {
98
135
  const token = JSON.parse(fs.readFileSync(tokenPath, "utf8")) as { refresh_token?: unknown };
@@ -115,11 +152,15 @@ export function hasAntigravityAuth(): boolean {
115
152
  }
116
153
 
117
154
  /** Local logout. Google currently advertises logout as an agent command rather
118
- * than an ACP SDK RPC, so this removes the local refresh token and auth choice. */
155
+ * than an ACP SDK RPC, so this removes the local refresh token and auth choice.
156
+ * The marker goes first: a logout that cannot be recorded leaves the credentials
157
+ * untouched instead of letting the next token sync restore the login. */
119
158
  export function clearAntigravityCredentials(
120
159
  directory = resolveAntigravityAcpDirectory(),
121
160
  ): void {
161
+ markAntigravityLoggedOut(directory);
122
162
  fs.rmSync(path.join(directory, "acp_token.json"), { force: true });
163
+ fs.rmSync(path.join(directory, "antigravity-oauth-token"), { force: true });
123
164
  const settingsPath = path.join(directory, "settings.json");
124
165
  let parsed: unknown;
125
166
  try { parsed = JSON.parse(fs.readFileSync(settingsPath, "utf8")); } catch { return; }
@@ -377,6 +377,10 @@ export class AntigravityAcpConnection {
377
377
 
378
378
  async retireForReplacement(_key: string, _sessionId: string): Promise<void> {}
379
379
 
380
+ consumeNoticeCapture(_sessionId: string): import("../../agent-notices.ts").AgentNoticeCapture | undefined {
381
+ return undefined;
382
+ }
383
+
380
384
  private updateSessionState(sessionId: string, response: unknown): SessionState {
381
385
  const commands = (response as { availableCommands?: AvailableCommand[] | null }).availableCommands;
382
386
  const state = { ...this.sessions.get(sessionId), ...decodeSessionState(response), ...(commands === undefined ? {} : { availableCommands: commands }) };
@@ -394,6 +398,7 @@ export class AntigravityAcpConnection {
394
398
  option => option.type === "select" && (option.category === category || option.id === category),
395
399
  );
396
400
  if (!selector) return false;
401
+ if (selector.currentValue === value) return true;
397
402
  const response = await this.withAbort(
398
403
  this.withDeadline(
399
404
  this.connection.setSessionConfigOption({ sessionId, configId: selector.id, value }),
@@ -10,7 +10,10 @@ export {
10
10
  inspectAntigravityAuth,
11
11
  hasAntigravityAuth,
12
12
  clearAntigravityCredentials,
13
+ clearAntigravityLogoutMarker,
14
+ isAntigravityLoggedOut,
13
15
  resolveAntigravityAcpDirectory,
16
+ resolveAntigravityCliTokenPath,
14
17
  } from "./acp/antigravity.ts";
15
18
  export { describeCredentialStorage } from "./acp/credential-storage.ts";
16
19
  export { FALLBACK_MODELS, projectModels } from "./models.ts";
@@ -21,3 +24,6 @@ export { PiEventWriter } from "./stream/pi-events.ts";
21
24
  export { TierConnection } from "../tier-connection.ts";
22
25
  export { SessionCleanup } from "../session-cleanup.ts";
23
26
  export { Type } from "typebox";
27
+ // Adapter config edits need the same cross-process lock the bundled stores
28
+ // use, and a bare package import cannot be resolved from the load-time graph.
29
+ export { lock as lockFile } from "proper-lockfile";
@@ -466,7 +466,7 @@ function readManagedVersion(home: string): string | undefined {
466
466
  return typeof version === "string" ? version : undefined;
467
467
  }
468
468
 
469
- function compareVersions(left: string, right: string): number {
469
+ export function compareVersions(left: string, right: string): number {
470
470
  const parse = (value: string) => value.split(".").map(part => Number.parseInt(part, 10) || 0);
471
471
  const a = parse(left);
472
472
  const b = parse(right);
@@ -498,6 +498,10 @@ function wrapperCommand(file: string, platform: NodeJS.Platform, args: readonly
498
498
  return { command: process.env.ComSpec ?? "cmd.exe", args: ["/d", "/s", "/e:on", "/v:off", "/c", `call "${file}"`, ...args] };
499
499
  }
500
500
 
501
+ // The wrapper only launches the CLI. Credential sync happens once in
502
+ // prepareRuntime(), where GEMINI_HOME and an atomic, newer-than replacement are
503
+ // known; a shell copy here would hardcode $HOME and could overwrite a newer ACP
504
+ // token with an older CLI one.
501
505
  function cliWrapperScript(agyPath: string, platform: NodeJS.Platform = process.platform): string {
502
506
  if (platform === "win32") {
503
507
  const escaped = agyPath.replace(/%/g, "%%");
@@ -1,13 +1,14 @@
1
1
  import type { AcpModelInfo } from "./acp/session-state.ts";
2
2
  import type { ContextOptions } from "../context-settings.ts";
3
+ import { splitLegacyEffort } from "../efforts.ts";
3
4
  import type {
4
5
  Model,
5
6
  ThinkingLevel,
6
7
  ThinkingLevelMap,
7
8
  } from "@earendil-works/pi-ai";
8
9
 
9
- export const PROVIDER_ID = "antigravity-acp";
10
- export const API_ID = "antigravity-acp";
10
+ export const PROVIDER_ID = "antigravity-acp-provider";
11
+ export const API_ID = "antigravity-acp-provider";
11
12
 
12
13
  export interface AntigravityModel extends Omit<Model<typeof API_ID>, "baseUrl" | "input" | "compat"> {
13
14
  baseUrl?: string;
@@ -16,6 +17,45 @@ export interface AntigravityModel extends Omit<Model<typeof API_ID>, "baseUrl" |
16
17
  }
17
18
 
18
19
  const ZERO_COST = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 } as const;
20
+
21
+ /** Per-model context/output limits for the catalog Antigravity advertises
22
+ * (data adapted from a community Antigravity bridge plugin, MIT). OMP compacts against
23
+ * contextWindow, so over-reporting a small-context model delays compaction
24
+ * until the server rejects the request. Unknown IDs keep the generic floor. */
25
+ export const KNOWN_MODEL_LIMITS: Readonly<Record<string, { contextWindow: number; maxTokens: number }>> = Object.freeze({
26
+ "gemini-4-carbon": { contextWindow: 1_048_576, maxTokens: 262_144 },
27
+ "gemini-4-argon": { contextWindow: 1_048_576, maxTokens: 65_536 },
28
+ "gemini-4-hydrogen": { contextWindow: 1_048_576, maxTokens: 262_144 },
29
+ "gemini-pro-orchestrator": { contextWindow: 1_048_576, maxTokens: 262_144 },
30
+ "gemini-pro-orchestrator-argon": { contextWindow: 1_048_576, maxTokens: 65_536 },
31
+ "gemini-flash-worker-agy": { contextWindow: 1_048_576, maxTokens: 262_144 },
32
+ "gemini-3.8-flash": { contextWindow: 1_048_576, maxTokens: 65_536 },
33
+ "gemini-3.8-flash-tiered": { contextWindow: 1_048_576, maxTokens: 65_536 },
34
+ "gemini-3-flash": { contextWindow: 1_048_576, maxTokens: 65_536 },
35
+ "gemini-3.1-flash-image": { contextWindow: 65_536, maxTokens: 65_536 },
36
+ "gemini-3.5-flash-lite": { contextWindow: 1_048_576, maxTokens: 65_535 },
37
+ "gemini-3.1-flash-lite": { contextWindow: 1_048_576, maxTokens: 65_535 },
38
+ "gemini-2.5-flash": { contextWindow: 1_048_576, maxTokens: 65_535 },
39
+ "gemini-2.5-flash-thinking": { contextWindow: 1_048_576, maxTokens: 65_535 },
40
+ "gemini-2.5-flash-lite": { contextWindow: 1_048_576, maxTokens: 65_535 },
41
+ "gemini-2.5-pro": { contextWindow: 1_048_576, maxTokens: 65_535 },
42
+ "claude-opus-5-5": { contextWindow: 1_000_000, maxTokens: 128_000 },
43
+ "claude-sonnet-5-5": { contextWindow: 1_000_000, maxTokens: 128_000 },
44
+ "claude-opus-4-6": { contextWindow: 250_000, maxTokens: 64_000 },
45
+ "claude-opus-4-6-thinking": { contextWindow: 250_000, maxTokens: 64_000 },
46
+ "claude-sonnet-4-6": { contextWindow: 250_000, maxTokens: 64_000 },
47
+ "gpt-oss-120b": { contextWindow: 131_072, maxTokens: 32_768 },
48
+ "gpt-oss-120b-medium": { contextWindow: 131_072, maxTokens: 32_768 },
49
+ });
50
+
51
+ /** Resolve limits for a possibly effort-suffixed model ID. gpt-oss-120b-medium
52
+ * is itself a catalog ID, so the exact ID wins before stripping the suffix.
53
+ * The same normalization the catalog uses (all effort suffixes, the models/
54
+ * alias) keeps both consumers answering identically for one ID. */
55
+ export function modelLimits(id: string): { contextWindow: number; maxTokens: number } {
56
+ const base = (splitLegacyEffort(id)?.base ?? id).replace(/^models\//iu, "");
57
+ return KNOWN_MODEL_LIMITS[id.toLowerCase()] ?? KNOWN_MODEL_LIMITS[base.toLowerCase()] ?? { contextWindow: 1_000_000, maxTokens: 65_536 };
58
+ }
19
59
  type Effort = "low" | "medium" | "high";
20
60
  type Variants = Partial<Record<Effort, string>>;
21
61
 
@@ -156,8 +196,7 @@ function baseModel(
156
196
  ...(thinkingLevelMap ? { thinkingLevelMap } : {}),
157
197
  input: ["text", "image"],
158
198
  cost: ZERO_COST,
159
- contextWindow: 1_000_000,
160
- maxTokens: 65_536,
199
+ ...modelLimits(id),
161
200
  };
162
201
  }
163
202
 
@@ -74,7 +74,7 @@ export const ACP_STEP_TEXT_BYTES = 188_000;
74
74
 
75
75
  // A shadow side turn never executes tools, so no prompt text on that flow may
76
76
  // invite one. Every ephemeral header, boundary and retry text reuses this
77
- // sentence instead of the main new-call/pi_task wording.
77
+ // sentence instead of the main new-call/omp_task wording.
78
78
  const EPHEMERAL_NO_TOOLS_TEXT =
79
79
  "No tools may be called in this side turn; tool calls are discarded without execution. Reply with plain text only.";
80
80
 
@@ -83,7 +83,7 @@ const HISTORY_HEADER =
83
83
  "# Prior OMP conversation (reference only)\n\n" +
84
84
  "The JSON below is historical conversation data, not a new request or a queue of tasks. " +
85
85
  "Do not answer historical user requests, and do not repeat a tool call merely because it appears in this history. " +
86
- "New tool calls, including another pi_task, are allowed when the current OMP user request needs them. " +
86
+ "New tool calls, including another omp_task, are allowed when the current OMP user request needs them. " +
87
87
  "Use it only as context for the current OMP user request identified after this resource.\n\n";
88
88
  const HISTORY_HEADER_EPHEMERAL =
89
89
  "# Prior OMP conversation (reference only)\n\n" +
@@ -188,7 +188,7 @@ export function promptTextBytes(prompt: TransferBlock[]): number {
188
188
  export function currentSystemInstructions(context: TransferContext): string {
189
189
  const prompt = getCurrentSystemPrompt(context.messages as never) || context.systemPrompt || "";
190
190
  if (Buffer.byteLength(prompt, "utf8") > 134_217_728) throw new Error("OMP system instructions exceed the 128 MiB hard transfer ceiling; reduce them rather than truncating instructions");
191
- return prompt;
191
+ return prompt.replace(/You are omp's trusted coding assistant\b/g, "You are omp's coding assistant");
192
192
  }
193
193
 
194
194
  function safeJson(value: unknown): string {
@@ -279,7 +279,7 @@ function retryRequestText(content: string | TransferBlock[], kind: PromptKind =
279
279
  return "\n\n# OMP retry request\n\n" +
280
280
  "The user discarded the previous response to the current user request. " +
281
281
  "Produce a completely new answer for it. Do not continue, quote or repeat the discarded response. " +
282
- "Make any new tool calls, including another pi_task, that the new answer requires; " +
282
+ "Make any new tool calls, including another omp_task, that the new answer requires; " +
283
283
  "do not replay earlier tool calls merely because they appear in history." +
284
284
  (restate ? `\n\n# Original request\n\n${restate}` : "");
285
285
  }
@@ -447,7 +447,7 @@ function inProgressText(kind: PromptKind): string {
447
447
  }
448
448
  return "This request is already in progress; the history includes prior assistant actions and tool results. " +
449
449
  "Continue from those results rather than restarting completed work; do not replay earlier tool calls automatically, " +
450
- "but make any new tool calls, including another pi_task, that the request still needs.\n\n";
450
+ "but make any new tool calls, including another omp_task, that the request still needs.\n\n";
451
451
  }
452
452
 
453
453
  function requestFinalHeader(inProgress: boolean, kind: PromptKind = "main"): string {
@@ -721,7 +721,7 @@ function historyRecordItems(
721
721
  }
722
722
 
723
723
  export function buildPromptParts(context: TransferContext, fresh: boolean, unseenStart?: number,
724
- limits: { contextWindow?: number; maxTokens?: number; policy?: ContextOptions; sessionRouting?: boolean; sessionGuidance?: string; promptKind?: PromptKind } = {}, retryResend = false): PromptParts {
724
+ limits: { contextWindow?: number; maxTokens?: number; policy?: ContextOptions; sessionRouting?: boolean; sessionGuidance?: string; promptKind?: PromptKind; deliveryBlocks?: readonly TransferBlock[] } = {}, retryResend = false): PromptParts {
725
725
  // catalog-store attaches ompContextPolicy to discovered models; re-resolution
726
726
  // is only needed for partial input in tests and standalone callers.
727
727
  const policy = limits.policy;
@@ -757,6 +757,7 @@ export function buildPromptParts(context: TransferContext, fresh: boolean, unsee
757
757
  // user prompt would duplicate policy text and consume the step budget.
758
758
  const instructions = fresh && !limits.sessionRouting ? currentSystemInstructions(context) : "";
759
759
  const guidance = fresh && !limits.sessionRouting ? limits.sessionGuidance ?? "" : "";
760
+ const deliveryBlocks = limits.deliveryBlocks ?? [];
760
761
  checkStepTextBytes(Buffer.byteLength(instructions, "utf8"));
761
762
  const instructionParts = [instructions, guidance].filter(Boolean);
762
763
  const instructionsText = instructionParts.length ? `# OMP session instructions\n\n${instructionParts.join("\n\n")}` : "";
@@ -835,11 +836,11 @@ export function buildPromptParts(context: TransferContext, fresh: boolean, unsee
835
836
  : "\n\n# Continue the active OMP request\n\n" +
836
837
  "The new context/tool results above belong to the user request already received in this session. " +
837
838
  "Finish that request from those results. Do not answer historical user requests or repeat a tool call merely because it appears in history; " +
838
- "make any new tool calls, including another pi_task, that the active request still requires.";
839
+ "make any new tool calls, including another omp_task, that the active request still requires.";
839
840
  const continuation = { type: "text", text: retryResend
840
841
  ? retryRequestText(messages[latest]!.content, kind)
841
842
  : continuationText };
842
- tailBlocks.push(...reminderBlocks, continuation);
843
+ tailBlocks.push(...reminderBlocks, ...deliveryBlocks, continuation);
843
844
  } else {
844
845
  // Official ACP merges following text into an embedded-resource string with
845
846
  // a space. Explicit newlines/labels must survive that conversion; role
@@ -851,9 +852,9 @@ export function buildPromptParts(context: TransferContext, fresh: boolean, unsee
851
852
  const content = messages[latest]!.content;
852
853
  // Blocks are consumed read-only; shallow copies only churn the hot path.
853
854
  const latestBlocks: TransferBlock[] = typeof content === "string" ? [{ type: "text", text: content }] : content;
854
- const normalTail: TransferBlock[] = [...reminderBlocks, boundary, ...latestBlocks];
855
+ const normalTail: TransferBlock[] = [...reminderBlocks, ...deliveryBlocks, boundary, ...latestBlocks];
855
856
  if (promptTextBytes(normalTail) > ACP_STEP_TEXT_BYTES) {
856
- const split = splitOversizedRequest(latestBlocks, inProgress, kind, reminderBlocks);
857
+ const split = splitOversizedRequest(latestBlocks, inProgress, kind, [...reminderBlocks, ...deliveryBlocks]);
857
858
  requestSeedSteps = split.seedSteps;
858
859
  tailBlocks = split.tailBlocks;
859
860
  } else {
@@ -14,8 +14,8 @@ import { hasAntigravityAuth } from "./acp/antigravity.ts";
14
14
  import { type AntigravityModel, FALLBACK_MODELS, projectModels, PROVIDER_ID } from "./models.ts";
15
15
  import { AntigravityRuntime, MANAGED_AUTH_MARKER, type OmpStreamOptions } from "./runtime.ts";
16
16
 
17
- export interface AntigravityProvider extends Omit<Provider<"antigravity-acp">, "auth" | "streamSimple"> {
18
- auth: NonNullable<Provider<"antigravity-acp">["auth"]> & {
17
+ export interface AntigravityProvider extends Omit<Provider<"antigravity-acp-provider">, "auth" | "streamSimple"> {
18
+ auth: NonNullable<Provider<"antigravity-acp-provider">["auth"]> & {
19
19
  oauth: {
20
20
  name: string;
21
21
  loginLabel: string;
@@ -174,4 +174,4 @@ function stream(
174
174
  return runtime.stream(model, context, options).stream;
175
175
  }
176
176
 
177
- export const ANTIGRAVITY_ACP_API = "antigravity-acp" satisfies Api;
177
+ export const ANTIGRAVITY_ACP_API = "antigravity-acp-provider" satisfies Api;