@heyhuynhgiabuu/pi-oauth-antigravity 0.3.1 → 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/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.2] - 2026-11-19
11
+
12
+ ### Added
13
+
14
+ - **`promptCache` declared for all Gemini models (`short: 300`).** Pi's cache warming
15
+ (default `cacheWarming: "idle"`) only re-sends prompts for models that declare a cache
16
+ lifetime, so the conversation cache now gets refreshed while the session is idle (up to
17
+ 30 minutes) instead of expiring during subagent detours and returning as a full-cache
18
+ miss. Lifetime measured live: a cache hit was observed after a multi-minute subagent
19
+ detour, matching the Google implicit-caching norm (~5 minutes, refreshed on hit).
20
+ Warm refreshes count toward the session's daily request quota; Pi only warms when it
21
+ estimates ≥ $0.05 in avoided miss cost.
22
+
23
+ ### Fixed
24
+
25
+ - **Agent-name scrub no longer flattens whitespace or mangles relative paths.** The
26
+ previous scrub collapsed runs of spaces globally (flattening markdown indentation in
27
+ AGENTS.md context and tool descriptions on every request, match or not) and deleted the
28
+ harness name inside `pi/agent` relative paths. The scrub now consumes only the spaces
29
+ adjacent to a match, spares `pi/…` path forms, and leaves all other whitespace and
30
+ indentation verbatim.
31
+ - **Scrub punctuation collapse is scoped to the deleted name.** The space-before-
32
+ punctuation tidy pass ran globally and rewrote ` :` / ` ?` / ` .` sequences in system
33
+ text and tool descriptions that never contained the harness name (reviewer Major
34
+ finding). The collapse now happens only inside a match: punctuation directly after the
35
+ deleted span attaches to the previous word, a match at line start keeps the line
36
+ indentation, and text without the harness name is byte-identical (pinned by negative
37
+ tests: `x ? y : z`, JSON samples).
38
+
10
39
  ## [0.3.1] - 2026-11-19
11
40
 
12
41
  ### Fixed
@@ -56,7 +85,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
56
85
  Previously, after the in-place retries ran out, the throttled runtime model (for example
57
86
  `gemini-4-hydrogen-medium`, "Resource has been exhausted") ended the request even though a
58
87
  fallback model (`gemini-4-carbon-medium`) was lined up. Plan quota ("Individual quota
59
- reached") still fails fast.
88
+ reached") still fails fast. Worst case when every candidate is throttled is bounded but
89
+ slow: each candidate runs its own in-place retries before the next one is tried.
60
90
  - **Retry hints are also read from the 429 body, and exhausted-plan reasons fail fast**
61
91
  (mirrors CLIProxyAPI's 429 handling, issue #7565). The wait now comes from the
62
92
  `Retry-After` header, the body's `RetryInfo.retryDelay`, `ErrorInfo
@@ -42,7 +42,6 @@ export declare const ANTIGRAVITY_ROUTING: Record<string, AntigravityRouting>;
42
42
  */
43
43
  export declare const RUNTIME_MAX_OUTPUT_TOKENS: Record<string, number>;
44
44
  export declare function getMaxOutputTokens(modelId: string, runtimeModel?: string): number;
45
- /** Selectable provider models; effort variants share public IDs where routing supports them. */
46
45
  export declare const ANTIGRAVITY_MODELS: ProviderModelConfig[];
47
46
  /** Resolve public model id + thinking effort to Antigravity runtime model id. */
48
47
  export declare function getAntigravityRequestModelId(modelId: string, effort: string | undefined): string;
@@ -350,6 +350,13 @@ function claude55Models(family) {
350
350
  });
351
351
  }
352
352
  /** Selectable provider models; effort variants share public IDs where routing supports them. */
353
+ /**
354
+ * Implicit-cache lifetime measured on the backend (hit observed after a multi-minute
355
+ * subagent detour; Google implicit caching norm is ~5 minutes, refreshed on hit).
356
+ * Declaring it lets Pi's cacheWarming (default "idle") keep the conversation cache warm
357
+ * while the user is away — the missing piece that made post-subagent turns miss.
358
+ */
359
+ const geminiPromptCache = { short: 300 };
353
360
  export const ANTIGRAVITY_MODELS = [
354
361
  {
355
362
  // Wire IDs verified against live discovery (2026-10-14); cost/context are
@@ -358,6 +365,7 @@ export const ANTIGRAVITY_MODELS = [
358
365
  name: "Gemini 4 Argon (Antigravity)",
359
366
  reasoning: true,
360
367
  thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
368
+ promptCache: geminiPromptCache,
361
369
  input: ["text", "image"],
362
370
  cost: geminiProCost,
363
371
  contextWindow: 1048576,
@@ -370,6 +378,7 @@ export const ANTIGRAVITY_MODELS = [
370
378
  name: "Gemini 4 Carbon (Antigravity)",
371
379
  reasoning: true,
372
380
  thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
381
+ promptCache: geminiPromptCache,
373
382
  input: ["text", "image"],
374
383
  cost: geminiProCost,
375
384
  contextWindow: 1048576,
@@ -383,6 +392,7 @@ export const ANTIGRAVITY_MODELS = [
383
392
  name: "Gemini 4 Neon (Antigravity)",
384
393
  reasoning: true,
385
394
  thinkingLevelMap: thinkingLevelMaps.lowMediumHighXhigh,
395
+ promptCache: geminiPromptCache,
386
396
  input: ["text", "image"],
387
397
  cost: geminiNeonCost,
388
398
  contextWindow: 1048576,
@@ -395,6 +405,7 @@ export const ANTIGRAVITY_MODELS = [
395
405
  name: "Gemini 4 Hydrogen (Antigravity)",
396
406
  reasoning: true,
397
407
  thinkingLevelMap: thinkingLevelMaps.lowMediumHighXhigh,
408
+ promptCache: geminiPromptCache,
398
409
  input: ["text", "image"],
399
410
  cost: geminiProCost,
400
411
  contextWindow: 1048576,
@@ -405,6 +416,7 @@ export const ANTIGRAVITY_MODELS = [
405
416
  name: "Gemini 3.8 Flash (Antigravity)",
406
417
  reasoning: true,
407
418
  thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
419
+ promptCache: geminiPromptCache,
408
420
  input: ["text", "image"],
409
421
  cost: geminiFlashCost,
410
422
  contextWindow: 1048576,
@@ -415,6 +427,7 @@ export const ANTIGRAVITY_MODELS = [
415
427
  name: "Gemini 3.7 Flash (Antigravity)",
416
428
  reasoning: true,
417
429
  thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
430
+ promptCache: geminiPromptCache,
418
431
  input: ["text", "image"],
419
432
  cost: geminiFlashCost,
420
433
  contextWindow: 1048576,
@@ -425,6 +438,7 @@ export const ANTIGRAVITY_MODELS = [
425
438
  name: "Gemini 3.6 Flash (Antigravity)",
426
439
  reasoning: true,
427
440
  thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
441
+ promptCache: geminiPromptCache,
428
442
  input: ["text", "image"],
429
443
  cost: geminiFlashCost,
430
444
  contextWindow: 1048576,
@@ -437,6 +451,7 @@ export const ANTIGRAVITY_MODELS = [
437
451
  name: "Gemini 3.1 Pro (Antigravity)",
438
452
  reasoning: true,
439
453
  thinkingLevelMap: thinkingLevelMaps.lowHigh,
454
+ promptCache: geminiPromptCache,
440
455
  input: ["text", "image"],
441
456
  cost: geminiProCost,
442
457
  contextWindow: 1048576,
@@ -576,13 +576,21 @@ export function buildRequest(model, context, projectId, options, runtimeModel, s
576
576
  * instructions and tool descriptions — while message text is left untouched so file
577
577
  * paths and identifiers in the conversation survive.
578
578
  */
579
- const AGENT_NAME_PATTERN = /(?<![\w.-])pi(?![\w-])/gi;
579
+ const AGENT_NAME_PATTERN = /[ \t]*(?<![\w./-])pi(?![\w/-])[ \t]*/gi;
580
580
  /** Exported for unit tests. */
581
581
  export function scrubAgentName(text) {
582
- return text
583
- .replace(AGENT_NAME_PATTERN, "")
584
- .replace(/\s+,/g, ",")
585
- .replace(/ {2,}/g, " ");
582
+ // The replacement is scoped to the match: punctuation directly after the deleted
583
+ // name attaches to the previous word, everything else becomes a single space. A
584
+ // match at line start keeps the line's indentation. No global whitespace pass —
585
+ // "x ? y : z" and indented markdown survive byte-for-byte when no name is present.
586
+ return text.replace(AGENT_NAME_PATTERN, (match, offset, full) => {
587
+ if (offset === 0 || full[offset - 1] === "\n") {
588
+ // Match at line start: the consumed leading run was this line's indentation.
589
+ return match.match(/^[ \t]+/)?.[0] ?? "";
590
+ }
591
+ const after = full.slice(offset + match.length, offset + match.length + 1);
592
+ return /[,.;:!?]/.test(after) ? "" : " ";
593
+ });
586
594
  }
587
595
  function scrubRequestAgentName(request) {
588
596
  for (const part of request.systemInstruction?.parts ?? []) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyhuynhgiabuu/pi-oauth-antigravity",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Google Antigravity OAuth provider extension for Pi with Gemini 3.8, prompt cache session affinity, and trajectory chaining.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",