@estebanforge/pi-antigravity-bridge 1.10.3 → 1.10.5
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/CHANGELOG.md +12 -0
- package/README.md +1 -1
- package/extensions/index.ts +1 -1
- package/package.json +2 -2
- package/src/acp/driver.ts +71 -6
- package/src/acp/events.ts +9 -0
- package/src/config.ts +1 -1
- package/src/models.ts +4 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,18 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [1.10.5] - 2026-11-13
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- **The AskAntigravity default model is now `gemini-4-hydrogen` (was `flash`).** The default resolves as a catalog tiered base: the tier suffix comes from `AGY_DEFAULT_THINKING` or the call's thinking param (`gemini-4-hydrogen-medium` at the default medium), so the default no longer tracks the newest Flash generation. To make that resolution possible the shared resolver (`@estebanforge/pi-ask-shared`, also consumed by pi-ask-antigravity) now resolves a single-base catalog tiered slug BEFORE the bare-"gemini" Flash fallthrough — before, any unrecognized `gemini-<line>` base silently resolved as Flash; version pins across mixed bases (`gemini-3.6`) keep the Flash family semantics. Sequencing: publish shared first, then bump this package's shared floor to the version carrying that change and run npm install, then publish this package (a floor must point at a version npm has). The offline fallback catalog lists `gemini-4-hydrogen` first so the default stays resolvable when `agy models` fails, and the `/agy model` picker offers the exact slug alongside the aliases.
|
|
10
|
+
|
|
11
|
+
## [1.10.4] - 2026-11-10
|
|
12
|
+
|
|
13
|
+
### Fixed
|
|
14
|
+
|
|
15
|
+
- **ACP turns no longer report a multiplied context length that fired compaction at a fraction of the real occupancy.** agy's PromptResponse.usage sums input + cacheRead + output over EVERY inference of the prompt (billing totals), and pi reads `Usage.totalTokens` as the live context length, so each tool round-trip re-counted the whole cached prefix: an 18-step turn gauged 107% of the window at ~7% real, and pi's auto-compaction destroyed the session history for no reason (issue #12). The driver keeps the billing fields but replaces the total with the occupancy-shaped value pi expects: the observed `usage_update` occupancy when the server sends it (absent on native agy 1.5.4, probe-calibrated 2026-11-10), otherwise the derived Σinput + Σoutput + ceil(ΣcacheRead / (toolBatches + 1)) where toolBatches counts tool_call batches (a batch opens on the first tool_call after model output and closes on the next output frame, so parallel calls and out-of-order completions cannot inflate the divisor) - exact at one inference (the raw aggregate), and every miscount residual shrinks the divisor, which over-reads, the safe direction; calibrated within +11%..+57% of the real occupancy on live probe turns where the raw aggregate ran +99% (the reported 18-step sessions gauged 107-135% and would land in the low teens). `scripts/probe-acp-usage.mjs` recalibrates the formula against live frames.
|
|
16
|
+
|
|
5
17
|
## [1.10.3] - 2026-11-10
|
|
6
18
|
|
|
7
19
|
### Added
|
package/README.md
CHANGED
|
@@ -184,7 +184,7 @@ For isolation when running any agent that executes commands without a confirmati
|
|
|
184
184
|
| `AGY_READONLY` | `1`/`true`/`on` (or any set value except `0`/`false`/`off`/empty) turns every provider turn and the `AskAntigravity` tool into a visible refusal (fail-closed: the CLI has no review-only enforcement on any path, [#1181](https://github.com/google-antigravity/antigravity-cli/issues/1181)). Wins over the config file. |
|
|
185
185
|
| `AGY_SKIP_PERMISSIONS` | `1`/`true` (default) to pass `--dangerously-skip-permissions` so commands don't hang on an unanswerable prompt in `-p` mode. `0`/`false` to prompt (hangs any `run_command` non-interactively). Wins over the config file. |
|
|
186
186
|
| `AGY_USAGE_ESTIMATE` | Fallback ACP token display when the server omits usage: `estimate` (default; live client-side per-delta estimates), `direct`, `off`. Exact server usage always wins. Wins over the config file. |
|
|
187
|
-
| `AGY_DEFAULT_MODEL` | Default model
|
|
187
|
+
| `AGY_DEFAULT_MODEL` | Default model for the `AskAntigravity` tool: `flash`/`pro`/`gemini`, or an exact id such as `gemini-4-hydrogen`. Default `gemini-4-hydrogen`; the tier suffix rides `AGY_DEFAULT_THINKING`. Wins over the config file. |
|
|
188
188
|
| `AGY_DEFAULT_THINKING` | Default thinking tier for the `AskAntigravity` tool: `low`/`medium`/`high`. Anything else falls back to `medium`. Wins over the config file. |
|
|
189
189
|
| `AGY_DEBUG` | `1`/`true`/`on` writes the full trail to the daily log (driver lifecycle, raw bridge traffic). Default off: **only `error` records land on disk** - routine disk writes are zero for regular users, and warnings surface as UI toasts instead. |
|
|
190
190
|
| `AGY_APPROVALS` | Approval gate mode: `auto` (default; gate on only when a pi permission extension is detected), `shadow` (force the shadow-tool gate on), `dedicated`, `off`. Unknown values fall back to `auto`, so a typo can never force the gate on. Wins over `config.approvals.gateMode`. |
|
package/extensions/index.ts
CHANGED
|
@@ -1738,7 +1738,7 @@ async function openAgyPicker(ui: ExtensionUIContext, ctx: AgyCommandCtx): Promis
|
|
|
1738
1738
|
description:
|
|
1739
1739
|
"AskAntigravity one-shot delegation tool: model used when its caller omits the model param. Callers may override per call; this is only the fallback. flash/pro/gemini, or an exact id. Does not affect the provider model you pick in /model.",
|
|
1740
1740
|
currentValue: config.defaultModel,
|
|
1741
|
-
values: ["flash", "pro", "gemini"],
|
|
1741
|
+
values: ["flash", "pro", "gemini", "gemini-4-hydrogen"],
|
|
1742
1742
|
},
|
|
1743
1743
|
{
|
|
1744
1744
|
id: "thinking",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@estebanforge/pi-antigravity-bridge",
|
|
3
|
-
"version": "1.10.
|
|
3
|
+
"version": "1.10.5",
|
|
4
4
|
"description": "Gemini provider for Pi on the Antigravity ACP server (official Google ACP) or the stream-json agy CLI. Use antigravity/* models in Pi. Full /model picker support. Models runs Pi's tools. ToS safe to use.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"pi-package",
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@estebanforge/pi-ask-shared": "^0.1.
|
|
57
|
+
"@estebanforge/pi-ask-shared": "^0.1.6",
|
|
58
58
|
"@estebanforge/pi-tui-dialogs": "^0.1.3",
|
|
59
59
|
"@modelcontextprotocol/sdk": "^1.31.0"
|
|
60
60
|
}
|
package/src/acp/driver.ts
CHANGED
|
@@ -83,6 +83,20 @@ interface ActiveTurn {
|
|
|
83
83
|
thoughtDeltas: number;
|
|
84
84
|
/** Estimated once, not re-tokenized for every streaming delta. */
|
|
85
85
|
estimatedInputTokens: number;
|
|
86
|
+
/** Native tool_call batches seen this turn: parallel calls in one
|
|
87
|
+
* inference collapse to one batch. A batch opens on the first tool_call
|
|
88
|
+
* after model output (text/thought) and stays open until the next output
|
|
89
|
+
* frame, so interleaved completions cannot split it. Proxies how many
|
|
90
|
+
* times the model inferred; feeds the PromptResponse.usage context
|
|
91
|
+
* correction (issue #12). */
|
|
92
|
+
toolBatches: number;
|
|
93
|
+
/** True between the first tool_call of an inference and the next model
|
|
94
|
+
* output frame. tool-only inferences keep it open and merge into the
|
|
95
|
+
* previous batch: the divisor shrinks, the total over-reads (safe). */
|
|
96
|
+
toolBatchOpen: boolean;
|
|
97
|
+
/** Last usage_update occupancy this turn. Authoritative over every
|
|
98
|
+
* derived total; native agy 1.5.4 never sends it (probe 2026-11-10). */
|
|
99
|
+
contextUsed: number | undefined;
|
|
86
100
|
sawResult: boolean;
|
|
87
101
|
/** True once the prompt RPC was issued. Abort before this point has
|
|
88
102
|
* nothing to cancel: probing would risk a success-as-noop answer from a
|
|
@@ -341,15 +355,20 @@ export class AcpDriver implements TurnDriver {
|
|
|
341
355
|
const result = await conn.prompt(turn.sessionId, request.prompt, request.images, request.contextBlock);
|
|
342
356
|
if (turn.closed) return;
|
|
343
357
|
turn.sawResult = true;
|
|
344
|
-
//
|
|
345
|
-
//
|
|
346
|
-
|
|
358
|
+
// Exact PromptResponse.usage supersedes every partial estimate, but
|
|
359
|
+
// its total is a billing sum over all inferences, not context (see
|
|
360
|
+
// #derivedContextTokens): correct it before it reaches pi's gauge.
|
|
361
|
+
let settleUsage: AgyUsage | undefined;
|
|
362
|
+
if (result.usage) {
|
|
363
|
+
settleUsage = this.#contextCorrectedUsage(turn, result.usage);
|
|
364
|
+
this.#emit(turn, { type: "usage", usage: settleUsage });
|
|
365
|
+
}
|
|
347
366
|
const mapped = mapStopReason(result.stopReason);
|
|
348
367
|
this.#settle(turn, {
|
|
349
368
|
conversationId: turn.sessionId,
|
|
350
369
|
status: mapped.status,
|
|
351
370
|
response: turn.response.text,
|
|
352
|
-
usage:
|
|
371
|
+
usage: settleUsage,
|
|
353
372
|
error: mapped.error,
|
|
354
373
|
finished: true,
|
|
355
374
|
aborted: mapped.aborted,
|
|
@@ -404,6 +423,7 @@ export class AcpDriver implements TurnDriver {
|
|
|
404
423
|
if (emit) {
|
|
405
424
|
turn.textDeltas += 1;
|
|
406
425
|
turn.textTokens += estimateTokens(emit);
|
|
426
|
+
turn.toolBatchOpen = false;
|
|
407
427
|
this.#emitLiveEstimate(turn);
|
|
408
428
|
this.#emit(turn, { type: "text", delta: emit });
|
|
409
429
|
}
|
|
@@ -413,11 +433,29 @@ export class AcpDriver implements TurnDriver {
|
|
|
413
433
|
if (!mapped.delta) return;
|
|
414
434
|
turn.thoughtDeltas += 1;
|
|
415
435
|
turn.thoughtTokens += estimateTokens(mapped.delta);
|
|
436
|
+
turn.toolBatchOpen = false;
|
|
416
437
|
this.#emitLiveEstimate(turn);
|
|
417
438
|
this.#emit(turn, { type: "thought", delta: mapped.delta });
|
|
418
439
|
return;
|
|
419
440
|
}
|
|
441
|
+
case "usage": {
|
|
442
|
+
// Occupancy frames are real server data, not the Gate B synthetic:
|
|
443
|
+
// surface them live so pi's gauge tracks the turn (toPiUsage only
|
|
444
|
+
// overwrites the fields the activity carries).
|
|
445
|
+
turn.contextUsed = mapped.used;
|
|
446
|
+
this.#emit(turn, { type: "usage", usage: { total_tokens: mapped.used } });
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
420
449
|
case "tool_start": {
|
|
450
|
+
// One inference can issue several calls in parallel (and complete
|
|
451
|
+
// them out of order); the divisor must count inference batches, not
|
|
452
|
+
// frames. A batch opens on the first tool_call after model output
|
|
453
|
+
// and only model output closes it, so interleaved completions and
|
|
454
|
+
// duplicate tool_call frames never split or re-open one.
|
|
455
|
+
if (!turn.toolBatchOpen) {
|
|
456
|
+
turn.toolBatches += 1;
|
|
457
|
+
turn.toolBatchOpen = true;
|
|
458
|
+
}
|
|
421
459
|
const entry = { name: mapped.name, args: mapped.args, diff: mapped.diff, mcpServer: mapped.mcpServer };
|
|
422
460
|
turn.toolCalls.set(mapped.toolCallId, entry);
|
|
423
461
|
this.#emit(turn, { type: "tool_start", name: mapped.name, args: mapped.args, mcpServer: mapped.mcpServer, toolCallId: mapped.toolCallId });
|
|
@@ -607,8 +645,11 @@ export class AcpDriver implements TurnDriver {
|
|
|
607
645
|
textDeltas: 0,
|
|
608
646
|
thoughtDeltas: 0,
|
|
609
647
|
estimatedInputTokens: estimateTokens(request.contextBlock?.text ? `${request.prompt}\n${request.contextBlock.text}` : request.prompt),
|
|
648
|
+
toolBatches: 0,
|
|
649
|
+
toolBatchOpen: false,
|
|
650
|
+
contextUsed: undefined,
|
|
610
651
|
sawResult: false,
|
|
611
|
-
|
|
652
|
+
promptStarted: false,
|
|
612
653
|
aborted: false,
|
|
613
654
|
abortedBy: null,
|
|
614
655
|
parks: 0,
|
|
@@ -779,7 +820,7 @@ export class AcpDriver implements TurnDriver {
|
|
|
779
820
|
// the connection outlives turns and no exact data ever replaces them
|
|
780
821
|
// on servers without PromptResponse.usage.
|
|
781
822
|
if (this.#conn?.exactUsageSeen) return undefined;
|
|
782
|
-
|
|
823
|
+
const usage = synthesizeUsage({
|
|
783
824
|
mode,
|
|
784
825
|
prompt: turn.request.prompt,
|
|
785
826
|
contextText: turn.request.contextBlock?.text,
|
|
@@ -789,6 +830,30 @@ export class AcpDriver implements TurnDriver {
|
|
|
789
830
|
textDeltas: turn.textDeltas,
|
|
790
831
|
thoughtDeltas: turn.thoughtDeltas,
|
|
791
832
|
});
|
|
833
|
+
// Observed occupancy outranks the synthetic gauge guess; the estimate's
|
|
834
|
+
// in/out still feed the status line on servers without PromptResponse.usage.
|
|
835
|
+
if (usage && turn.contextUsed !== undefined) return { ...usage, total_tokens: turn.contextUsed };
|
|
836
|
+
return usage;
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
/** Keep PromptResponse.usage billing fields, replace only the context
|
|
840
|
+
* total. Occupancy frames win; otherwise derive (issue #12, derivation
|
|
841
|
+
* in AGENTS.md). */
|
|
842
|
+
#contextCorrectedUsage(turn: ActiveTurn, usage: AgyUsage): AgyUsage {
|
|
843
|
+
return { ...usage, total_tokens: turn.contextUsed ?? this.#derivedContextTokens(turn, usage) };
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
/** PromptResponse.usage sums input+cacheRead+output over EVERY inference
|
|
847
|
+
* of the prompt, but pi reads Usage.totalTokens as the live context
|
|
848
|
+
* length. Each inference's cacheRead is at least the warm prefix C0, so
|
|
849
|
+
* the batch average lower-bounds C0 and added content reaches the total
|
|
850
|
+
* through the Σinput term; exact at one batch (the raw aggregate). Full
|
|
851
|
+
* derivation in AGENTS.md. */
|
|
852
|
+
#derivedContextTokens(turn: ActiveTurn, usage: AgyUsage): number {
|
|
853
|
+
const input = usage.input_tokens ?? 0;
|
|
854
|
+
const output = usage.output_tokens ?? 0;
|
|
855
|
+
const cacheRead = usage.cache_read_tokens ?? 0;
|
|
856
|
+
return input + output + Math.ceil(cacheRead / (turn.toolBatches + 1));
|
|
792
857
|
}
|
|
793
858
|
|
|
794
859
|
#log(msg: string, data?: unknown): void {
|
package/src/acp/events.ts
CHANGED
|
@@ -34,6 +34,7 @@ export interface AcpEditDiff {
|
|
|
34
34
|
export type MappedUpdate =
|
|
35
35
|
| { kind: "text"; delta: string }
|
|
36
36
|
| { kind: "thought"; delta: string }
|
|
37
|
+
| { kind: "usage"; used: number }
|
|
37
38
|
| { kind: "tool_start"; toolCallId: string; name: string; args: Record<string, unknown>; diff?: AcpEditDiff; mcpServer?: string }
|
|
38
39
|
| { kind: "tool_done"; toolCallId: string; output?: string; diff?: AcpEditDiff; mcpServer?: string }
|
|
39
40
|
| { kind: "tool_error"; toolCallId: string; message: string; mcpServer?: string }
|
|
@@ -52,6 +53,14 @@ export function mapUpdate(update: unknown): MappedUpdate {
|
|
|
52
53
|
return { kind: "thought", delta: chunkText(u.content) };
|
|
53
54
|
case "user_message_chunk":
|
|
54
55
|
return { kind: "replay_user" };
|
|
56
|
+
case "usage_update": {
|
|
57
|
+
// Context-window occupancy after one inference. Absent on native agy
|
|
58
|
+
// 1.5.4 (probe 2026-11-10); other ACP runtimes send it per inference.
|
|
59
|
+
const used = u.used;
|
|
60
|
+
return typeof used === "number" && Number.isSafeInteger(used) && used > 0
|
|
61
|
+
? { kind: "usage", used }
|
|
62
|
+
: null;
|
|
63
|
+
}
|
|
55
64
|
case "tool_call": {
|
|
56
65
|
const id = stringField(u.toolCallId);
|
|
57
66
|
if (!id) return null;
|
package/src/config.ts
CHANGED
package/src/models.ts
CHANGED
|
@@ -395,6 +395,10 @@ export function toPiModel(entry: AgyModelEntry, input: Array<"text" | "image"> =
|
|
|
395
395
|
* can still select a model and get a clear runtime error instead of an empty
|
|
396
396
|
* list. Update these when agy ships new Gemini versions. */
|
|
397
397
|
export const FALLBACK_MODELS: AgyModelEntry[] = [
|
|
398
|
+
// First entry = offline picker default; keep it aligned with the configured
|
|
399
|
+
// AskAntigravity default (config.ts) so the default stays resolvable when
|
|
400
|
+
// `agy models` fails.
|
|
401
|
+
{ full: "gemini-4-hydrogen", id: "gemini-4-hydrogen", efforts: ["low", "medium", "high"] },
|
|
398
402
|
{ full: "gemini-3.8-flash", id: "gemini-3-8-flash", efforts: ["low", "medium", "high"] },
|
|
399
403
|
{ full: "gemini-3.1-pro", id: "gemini-3-1-pro", efforts: ["low", "high"] },
|
|
400
404
|
{ full: "claude-sonnet-5-5", id: "claude-sonnet-5-5", efforts: ["low", "medium", "high"] },
|