@heyhuynhgiabuu/pi-oauth-antigravity 0.1.9 → 0.2.0

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,55 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.2.0] - 2026-11-15
11
+
12
+ ### Added
13
+
14
+ - **Gemini 4 Carbon** (`gemini-4-carbon-{low,medium,high}`, launched 2026-11-10) and
15
+ **Gemini 4 Hydrogen** (`gemini-4-hydrogen-{low,medium,high,xhigh}`, launched 2026-11-12 —
16
+ the backend's first `-xhigh` effort tier). Carbon/Hydrogen wire ids follow the family
17
+ pattern and are UNVERIFIED against a live listing; rejected requests fall back through
18
+ the Gemini 4 family (Hydrogen → Carbon → Argon → 3.8 Flash), with an xHigh tier
19
+ downgrade at each family boundary since only Hydrogen advertises `-xhigh`.
20
+ - Fresh `x-cloudaicompanion-trace-id` / `X-Aicode-Request-Id` headers on every request.
21
+ - **403 `TOS_VIOLATION` is recognized and surfaces account-risk advice** instead of the
22
+ generic "try another model, re-login" line. Google is actively enforcing third-party
23
+ OAuth use (the appeal copy names "third party software"); the reason lives in
24
+ `error.details`, which the old message path dropped, so a flagged account now gets told
25
+ that retries and re-login will not clear it and that further use risks suspension.
26
+ - **Server `Retry-After` is honored on transient 429s** (seconds or HTTP-date form,
27
+ capped at 60s). A longer `Retry-After` is a cooldown that cannot clear inside the
28
+ retry loop (CPA issue #6646), so no attempts are burned on it and the backend's own
29
+ reset note is surfaced. Without the header the 2s/4s backoff is unchanged.
30
+ - Claude Opus 5.5 / Sonnet 5.5 are documented as officially served (2026-11 models doc,
31
+ live discovery since 2026-10-03); the listed output/context figures remain same-family
32
+ estimates until Google publishes 5.5-specific numbers.
33
+
34
+ ### Added
35
+
36
+ - **Gemini 4 Carbon** (`gemini-4-carbon-{low,medium,high}`, launched 2026-11-10) and
37
+ **Gemini 4 Hydrogen** (`gemini-4-hydrogen-{low,medium,high,xhigh}`, launched 2026-11-12 —
38
+ the backend's first `-xhigh` effort tier). Carbon/Hydrogen wire ids follow the family
39
+ pattern and are UNVERIFIED against a live listing; rejected requests fall back through
40
+ the Gemini 4 family (Hydrogen → Carbon → Argon → 3.8 Flash), with an xHigh tier
41
+ downgrade at each family boundary since only Hydrogen advertises `-xhigh`.
42
+ - Fresh `x-cloudaicompanion-trace-id` / `X-Aicode-Request-Id` headers on every request.
43
+
44
+ ### Changed
45
+
46
+ - **`claude-opus-4-6-thinking`, `claude-sonnet-4-6` and `gpt-oss-120b-medium` leave the
47
+ selectable catalog** — Google removes them on 2026-11-18. Pinned overrides to their wire
48
+ ids still resolve (routing + output-token entries retained), and the retirement-notice
49
+ detector now covers their plain-text notices instead of rendering them as assistant text;
50
+ the surfaced error names retirement generically and points at `/antigravity.models`.
51
+ - **Request identity tracks the shipping client** (`antigravity/hub/2.32.1`, was 2.23.0).
52
+ A stale identity silently receives a REDUCED model catalog from discovery, without an
53
+ error (codex2api e3d59f9; oh-my-pi pinned 2.32.1 on 2026-11-14 for the same reason).
54
+ - Gemini 4 Argon is no longer provisional: launched 2026-10-13, wire ids verified against
55
+ live `fetchAvailableModels` (opencodex 2026-10-14, codex2api 2026-10-16). Catalog table
56
+ and README reflect the 2026-11 models doc; README carries a ToS-risk warning for
57
+ third-party OAuth use.
58
+
10
59
  ## [0.1.9] - 2026-10-26
11
60
 
12
61
  ### Added
package/README.md CHANGED
@@ -23,25 +23,48 @@ Google Antigravity OAuth provider extension for [Pi](https://pi.dev). Connects P
23
23
 
24
24
  | Public Model ID | Backend Wire ID | Max Output | Context Window |
25
25
  | :--- | :--- | :--- | :--- |
26
- | `antigravity/gemini-4-argon` | `gemini-4-argon-{low,medium,high}`† | 65,536† | 1,048,576† |
26
+ | `antigravity/gemini-4-hydrogen` | `gemini-4-hydrogen-{low,medium,high,xhigh}`† | 65,536† | 1,048,576† |
27
+ | `antigravity/gemini-4-carbon` | `gemini-4-carbon-{low,medium,high}`† | 65,536† | 1,048,576† |
28
+ | `antigravity/gemini-4-argon` | `gemini-4-argon-{low,medium,high}` | 65,536† | 1,048,576† |
27
29
  | `antigravity/gemini-3.8-flash` | `gemini-3.8-flash-{low,medium,high}` | 65,536 | 1,048,576 |
28
30
  | `antigravity/gemini-3.7-flash` | `gemini-3.7-flash-{low,medium,high}` | 65,536 | 1,048,576 |
29
31
  | `antigravity/gemini-3.7-flash-thinking` | `gemini-3.7-flash-thinking` | 65,536 | 1,048,576 |
30
32
  | `antigravity/gemini-3.6-flash` | `gemini-3.6-flash-{low,medium,high}` | 65,536 | 1,048,576 |
31
33
  | `antigravity/gemini-3.1-pro` | `gemini-3.1-pro` | 65,536 | 1,048,576 |
32
- | `antigravity/claude-opus-4-6` | `claude-opus-4-6` | 64,000 | 200,000 |
33
34
  | `antigravity/claude-opus-5-5-low` | `claude-opus-5-5-low` | 64,000* | 250,000* |
34
35
  | `antigravity/claude-opus-5-5-medium` | `claude-opus-5-5-medium` | 64,000* | 250,000* |
35
36
  | `antigravity/claude-opus-5-5-high` | `claude-opus-5-5-high` | 64,000* | 250,000* |
36
- | `antigravity/claude-sonnet-4-6` | `claude-sonnet-4-6` | 64,000 | 200,000 |
37
37
  | `antigravity/claude-sonnet-5-5-low` | `claude-sonnet-5-5-low` | 64,000* | 200,000* |
38
38
  | `antigravity/claude-sonnet-5-5-medium` | `claude-sonnet-5-5-medium` | 64,000* | 200,000* |
39
39
  | `antigravity/claude-sonnet-5-5-high` | `claude-sonnet-5-5-high` | 64,000* | 200,000* |
40
- | `antigravity/gpt-oss-120b` | `gpt-oss-120b` | 8,192 | 131,072 |
41
40
 
42
- † Inferred from runtime ids referenced by Antigravity IDE 2.23.0, not yet confirmed against a live model listing; limits and pricing are provisional, and requests fall back to Gemini 3.8 Flash if the backend rejects the model.
41
+ Hydrogen (2026-11-12) is the first model with an `-xhigh` effort tier; Carbon (2026-11-10)
42
+ and Argon (2026-10-13) top out at High. Argon/Carbon/Hydrogen are entitlement-gated
43
+ (Ultra / Enterprise / paid Pro); a rejected request falls back through the Gemini 4
44
+ family to Gemini 3.8 Flash.
43
45
 
44
- \* Provisional same-family estimates only; Claude 5.5 backend output/context limits have not been verified.
46
+ `claude-opus-4-6-thinking`, `claude-sonnet-4-6` and `gpt-oss-120b-medium` were removed by
47
+ Google on **2026-11-18** and are no longer selectable; pinned overrides to their wire ids
48
+ still resolve until the backend drops them, and their retirement notices are detected and
49
+ surfaced as errors instead of assistant text.
50
+
51
+ ### Third-party OAuth is a ToS risk
52
+
53
+ Google's enforcement against third-party Antigravity OAuth clients is active: appeal forms
54
+ name "using third party software to access Antigravity", and 403 `PERMISSION_DENIED /
55
+ TOS_VIOLATION` reports against third-party clients exist (oh-my-pi paused its provider on
56
+ 2026-11-14 for this reason). Using this extension may put your Google account at risk —
57
+ prefer the official Antigravity IDE/CLI when possible, and don't say you weren't warned.
58
+
59
+ † Gemini 4 family: Argon wire ids verified against live discovery (2026-10-14); Carbon/Hydrogen wire ids follow the family pattern but are UNVERIFIED against a live listing. Limits and pricing are same-family estimates; a rejected request falls back to the previous Gemini 4 model, then Gemini 3.8 Flash.
60
+
61
+ \* Claude Opus 5.5 / Sonnet 5.5 are officially served (2026-11 models doc, live discovery
62
+ since 2026-10-03); the listed output/context figures stay same-family estimates until
63
+ Google publishes 5.5-specific numbers.
64
+
65
+ The request identity tracks the shipping client (`antigravity/hub/2.32.1`) and every call
66
+ sends fresh `x-cloudaicompanion-trace-id` / `X-Aicode-Request-Id` headers — a stale client
67
+ identity silently receives a REDUCED model catalog from discovery, without an error.
45
68
 
46
69
  ## Installation
47
70
 
@@ -1,4 +1,4 @@
1
- import { createHash } from "node:crypto";
1
+ import { createHash, randomUUID } from "node:crypto";
2
2
  import { Platform } from "../types/enums.js";
3
3
  import { getCurrentAvailableModels, getCurrentEndpoint, getCurrentMatchedModelDebug, setLastAvailableModels, setLastEndpoint, setLastError, setLastMatchedModelDebug, setLastStatus, } from "../diagnostics/diagnostics.js";
4
4
  import { assertSafeApiBaseUrl, safeError } from "../utils/security.js";
@@ -45,8 +45,11 @@ export function endpointCandidates(preferredEndpoint) {
45
45
  }
46
46
  return ENDPOINT_FALLBACKS;
47
47
  }
48
- // Cloud Code rejects newer models (e.g. Gemini 4 Argon) for clients below 2.23.0.
49
- const DEFAULT_ANTIGRAVITY_VERSION = "2.23.0";
48
+ // Cloud Code rejects newer models (e.g. Gemini 4 Argon) for clients below 2.23.0, and a
49
+ // stale identity silently gets a REDUCED catalog from discovery (no error): control-plane
50
+ // requests sent as antigravity/1.11.3 returned fewer models (codex2api e3d59f9). Track the
51
+ // shipping client — oh-my-pi pinned 2.32.1 on 2026-11-14 for the same reason.
52
+ const DEFAULT_ANTIGRAVITY_VERSION = "2.32.1";
50
53
  const DEFAULT_ANTIGRAVITY_CL = "963137146";
51
54
  function defaultUserAgent() {
52
55
  const version = antigravityEnv("HUB_VERSION") || DEFAULT_ANTIGRAVITY_VERSION;
@@ -67,6 +70,10 @@ export function antigravityHeaders(token) {
67
70
  Accept: "text/event-stream",
68
71
  "User-Agent": antigravityEnv("USER_AGENT") || defaultUserAgent(),
69
72
  "X-Goog-Api-Client": "google-cloud-sdk vscode_cloudshelleditor/0.1",
73
+ // Per-request trace/request ids match the shipping client (oh-my-pi #19279,
74
+ // 2026-11-14): requests without them were served the reduced catalog.
75
+ "x-cloudaicompanion-trace-id": randomUUID(),
76
+ "X-Aicode-Request-Id": randomUUID(),
70
77
  "Client-Metadata": JSON.stringify({
71
78
  ideType: "ANTIGRAVITY",
72
79
  platform,
@@ -5,27 +5,30 @@ export declare const PROVIDER_NAME = "Antigravity";
5
5
  /**
6
6
  * Public selectable model IDs → backend request model IDs by thinking effort.
7
7
  *
8
- * Catalog mirrors `agy models` (Antigravity CLI), which currently advertises:
9
- * - Gemini 4 Argon (Low / Medium / High) — provisional, see below
8
+ * Catalog mirrors `agy models` (Antigravity CLI) and the 2026-11 models doc, which advertises:
9
+ * - Gemini 4 Argon (Low / Medium / High) — CONFIRMED: launched 2026-10-13; wire IDs
10
+ * `gemini-4-argon-{low,medium,high}` verified against live `fetchAvailableModels`
11
+ * (opencodex 2026-10-14, codex2api 2026-10-16). Entitlement-gated (Ultra / Enterprise /
12
+ * paid Pro); requests fall back to Gemini 3.8 Flash when the backend rejects it.
13
+ * - Gemini 4 Carbon (Low / Medium / High) — launched 2026-11-10 (changelog v2.31.0);
14
+ * CCA wire IDs follow the family pattern but are UNVERIFIED against a live listing,
15
+ * so requests fall back through Argon to Gemini 3.8 Flash when rejected.
16
+ * - Gemini 4 Hydrogen (Low / Medium / High / xHigh) — launched 2026-11-12; the four
17
+ * SKUs incl. the new `-xhigh` tier were observed in live discovery (oh-my-pi 7c74c203,
18
+ * opencodex #8644 2026-11-13). Falls back through Carbon → Argon → 3.8 Flash.
10
19
  * - Gemini 3.8 Flash (Low / Medium / High)
11
- * - Gemini 3.7 Flash (Low / Medium / High)
12
- * - Gemini 3.6 Flash (Low / Medium / High)
20
+ * - Gemini 3.7 Flash (Low / Medium / High) — still served, single `gemini-3.7-flash-tiered`
21
+ * wire id on newer discovery payloads; Enterprise-only per the 2026-11 models doc.
22
+ * - Gemini 3.6 Flash (Low / Medium / High) — Enterprise-only; effectively absent from CCA
23
+ * for non-Enterprise accounts since 3.7 shipped, but kept selectable for entitled ones.
13
24
  * - Gemini 3.1 Pro (Low / High)
14
- * - Claude Sonnet 4.6 (Thinking)
15
- * - Claude Opus 4.6 (Thinking)
16
25
  * - Claude Opus 5.5 (Low / Medium / High)
17
26
  * - Claude Sonnet 5.5 (Low / Medium / High)
18
- * - GPT-OSS 120B (Medium)
19
27
  *
20
- * Gemini 4 Argon is inferred from runtime ids referenced by Antigravity IDE 2.23.0
21
- * (`gemini-4-argon-{low,medium,high}`); it is not yet confirmed against a live
22
- * `fetchAvailableModels` or `agy models` listing, so its limits and pricing are
23
- * provisional and requests fall back to Gemini 3.8 Flash when the backend rejects it.
24
- *
25
- * Gemini 3.5 Flash is intentionally omitted from the selectable catalog; the
26
- * stream handler recognizes the reported retirement notice for old model IDs.
27
- * Pi exposes the remaining models as public IDs and surfaces the exact thinking
28
- * levels advertised by the backend for each model.
28
+ * Removed 2026-11-18 per Google's models doc: `claude-opus-4-6-thinking`,
29
+ * `claude-sonnet-4-6`, `gpt-oss-120b-medium`. They are no longer selectable; the stream
30
+ * handler still recognizes their retirement notices, and pinned runtime overrides to the
31
+ * old wire IDs keep working until the backend drops them.
29
32
  */
30
33
  export declare const ANTIGRAVITY_ROUTING: Record<string, AntigravityRouting>;
31
34
  /**
@@ -4,29 +4,54 @@ export const PROVIDER_NAME = "Antigravity";
4
4
  /**
5
5
  * Public selectable model IDs → backend request model IDs by thinking effort.
6
6
  *
7
- * Catalog mirrors `agy models` (Antigravity CLI), which currently advertises:
8
- * - Gemini 4 Argon (Low / Medium / High) — provisional, see below
7
+ * Catalog mirrors `agy models` (Antigravity CLI) and the 2026-11 models doc, which advertises:
8
+ * - Gemini 4 Argon (Low / Medium / High) — CONFIRMED: launched 2026-10-13; wire IDs
9
+ * `gemini-4-argon-{low,medium,high}` verified against live `fetchAvailableModels`
10
+ * (opencodex 2026-10-14, codex2api 2026-10-16). Entitlement-gated (Ultra / Enterprise /
11
+ * paid Pro); requests fall back to Gemini 3.8 Flash when the backend rejects it.
12
+ * - Gemini 4 Carbon (Low / Medium / High) — launched 2026-11-10 (changelog v2.31.0);
13
+ * CCA wire IDs follow the family pattern but are UNVERIFIED against a live listing,
14
+ * so requests fall back through Argon to Gemini 3.8 Flash when rejected.
15
+ * - Gemini 4 Hydrogen (Low / Medium / High / xHigh) — launched 2026-11-12; the four
16
+ * SKUs incl. the new `-xhigh` tier were observed in live discovery (oh-my-pi 7c74c203,
17
+ * opencodex #8644 2026-11-13). Falls back through Carbon → Argon → 3.8 Flash.
9
18
  * - Gemini 3.8 Flash (Low / Medium / High)
10
- * - Gemini 3.7 Flash (Low / Medium / High)
11
- * - Gemini 3.6 Flash (Low / Medium / High)
19
+ * - Gemini 3.7 Flash (Low / Medium / High) — still served, single `gemini-3.7-flash-tiered`
20
+ * wire id on newer discovery payloads; Enterprise-only per the 2026-11 models doc.
21
+ * - Gemini 3.6 Flash (Low / Medium / High) — Enterprise-only; effectively absent from CCA
22
+ * for non-Enterprise accounts since 3.7 shipped, but kept selectable for entitled ones.
12
23
  * - Gemini 3.1 Pro (Low / High)
13
- * - Claude Sonnet 4.6 (Thinking)
14
- * - Claude Opus 4.6 (Thinking)
15
24
  * - Claude Opus 5.5 (Low / Medium / High)
16
25
  * - Claude Sonnet 5.5 (Low / Medium / High)
17
- * - GPT-OSS 120B (Medium)
18
26
  *
19
- * Gemini 4 Argon is inferred from runtime ids referenced by Antigravity IDE 2.23.0
20
- * (`gemini-4-argon-{low,medium,high}`); it is not yet confirmed against a live
21
- * `fetchAvailableModels` or `agy models` listing, so its limits and pricing are
22
- * provisional and requests fall back to Gemini 3.8 Flash when the backend rejects it.
23
- *
24
- * Gemini 3.5 Flash is intentionally omitted from the selectable catalog; the
25
- * stream handler recognizes the reported retirement notice for old model IDs.
26
- * Pi exposes the remaining models as public IDs and surfaces the exact thinking
27
- * levels advertised by the backend for each model.
27
+ * Removed 2026-11-18 per Google's models doc: `claude-opus-4-6-thinking`,
28
+ * `claude-sonnet-4-6`, `gpt-oss-120b-medium`. They are no longer selectable; the stream
29
+ * handler still recognizes their retirement notices, and pinned runtime overrides to the
30
+ * old wire IDs keep working until the backend drops them.
28
31
  */
29
32
  export const ANTIGRAVITY_ROUTING = {
33
+ "gemini-4-hydrogen": {
34
+ off: "gemini-4-hydrogen-low",
35
+ routing: {
36
+ minimal: "gemini-4-hydrogen-low",
37
+ low: "gemini-4-hydrogen-low",
38
+ medium: "gemini-4-hydrogen-medium",
39
+ high: "gemini-4-hydrogen-high",
40
+ xhigh: "gemini-4-hydrogen-xhigh",
41
+ },
42
+ defaultRequestId: "gemini-4-hydrogen-low",
43
+ },
44
+ "gemini-4-carbon": {
45
+ off: "gemini-4-carbon-low",
46
+ routing: {
47
+ minimal: "gemini-4-carbon-low",
48
+ low: "gemini-4-carbon-low",
49
+ medium: "gemini-4-carbon-medium",
50
+ high: "gemini-4-carbon-high",
51
+ xhigh: "gemini-4-carbon-high",
52
+ },
53
+ defaultRequestId: "gemini-4-carbon-low",
54
+ },
30
55
  "gemini-4-argon": {
31
56
  off: "gemini-4-argon-low",
32
57
  routing: {
@@ -130,6 +155,8 @@ export const ANTIGRAVITY_ROUTING = {
130
155
  },
131
156
  defaultRequestId: "gemini-3.6-flash-low",
132
157
  },
158
+ // Removed-from-catalog IDs keep their routing so a pinned frontend override still
159
+ // resolves to the right wire id until the backend drops the model (2026-11-18).
133
160
  "gpt-oss-120b": {
134
161
  off: "gpt-oss-120b-medium",
135
162
  routing: {
@@ -146,6 +173,16 @@ export const ANTIGRAVITY_ROUTING = {
146
173
  * Requesting more than these limits returns a 400 Bad Request from the API.
147
174
  */
148
175
  export const RUNTIME_MAX_OUTPUT_TOKENS = {
176
+ // Gemini 4 family: 3.8-tier value as provisional estimate; no verified 4-family limit.
177
+ "gemini-4-carbon": 65536,
178
+ "gemini-4-carbon-low": 65536,
179
+ "gemini-4-carbon-medium": 65536,
180
+ "gemini-4-carbon-high": 65536,
181
+ "gemini-4-hydrogen": 65536,
182
+ "gemini-4-hydrogen-low": 65536,
183
+ "gemini-4-hydrogen-medium": 65536,
184
+ "gemini-4-hydrogen-high": 65536,
185
+ "gemini-4-hydrogen-xhigh": 65536,
149
186
  // Provisional: family fallback, not a verified Gemini 4 limit.
150
187
  "gemini-4-argon": 65536,
151
188
  "gemini-4-argon-low": 65536,
@@ -200,7 +237,6 @@ const geminiFlashCost = { input: 0.1, output: 0.4, cacheRead: 0.025, cacheWrite:
200
237
  const geminiProCost = { input: 1.25, output: 5.0, cacheRead: 0.3125, cacheWrite: 1.25 };
201
238
  const claudeSonnetCost = { input: 3.0, output: 15.0, cacheRead: 0.3, cacheWrite: 3.75 };
202
239
  const claudeOpusCost = { input: 15.0, output: 75.0, cacheRead: 1.5, cacheWrite: 18.75 };
203
- const gptOssCost = { input: 0.6, output: 2.4, cacheRead: 0.15, cacheWrite: 0.6 };
204
240
  // A null entry is intentionally hidden by Pi. Do not collapse levels that happen to
205
241
  // route to the same runtime ID: the UI must reflect the levels the backend advertises.
206
242
  const thinkingLevelMaps = {
@@ -213,6 +249,15 @@ const thinkingLevelMaps = {
213
249
  xhigh: null,
214
250
  max: null,
215
251
  },
252
+ lowMediumHighXhigh: {
253
+ off: null,
254
+ minimal: null,
255
+ low: "low",
256
+ medium: "medium",
257
+ high: "high",
258
+ xhigh: "xhigh",
259
+ max: null,
260
+ },
216
261
  lowHigh: {
217
262
  off: null,
218
263
  minimal: null,
@@ -256,8 +301,10 @@ const claude55ThinkingLevelMaps = {
256
301
  high: thinkingLevelMaps.thinking,
257
302
  };
258
303
  /**
259
- * Use existing same-family values as provisional estimates only; 5.5-specific
260
- * cost, context-window, and output-token metadata has not been verified.
304
+ * Claude Opus 5.5 and Sonnet 5.5 are officially served by Antigravity (confirmed in the
305
+ * 2026-11 models doc and observed in live discovery since 2026-10-03). The per-tier cost,
306
+ * context window, and output caps below remain same-family estimates — Google does not
307
+ * publish 5.5-specific numbers — but the models themselves are first-class.
261
308
  */
262
309
  function claude55Models(family) {
263
310
  const familyName = family === "opus" ? "Opus" : "Sonnet";
@@ -280,7 +327,8 @@ function claude55Models(family) {
280
327
  /** Selectable provider models; effort variants share public IDs where routing supports them. */
281
328
  export const ANTIGRAVITY_MODELS = [
282
329
  {
283
- // Provisional: cost (Pro-tier estimate), context window, and max output are unverified.
330
+ // Wire IDs verified against live discovery (2026-10-14); cost/context are
331
+ // Pro-tier estimates and the output cap is the 3.8-tier value.
284
332
  id: "gemini-4-argon",
285
333
  name: "Gemini 4 Argon (Antigravity)",
286
334
  reasoning: true,
@@ -290,6 +338,30 @@ export const ANTIGRAVITY_MODELS = [
290
338
  contextWindow: 1048576,
291
339
  maxTokens: 65536,
292
340
  },
341
+ {
342
+ // Launched 2026-11-10. Carbon-specific cost/context/output are unverified;
343
+ // values reuse the Gemini 4 family estimates.
344
+ id: "gemini-4-carbon",
345
+ name: "Gemini 4 Carbon (Antigravity)",
346
+ reasoning: true,
347
+ thinkingLevelMap: thinkingLevelMaps.lowMediumHigh,
348
+ input: ["text", "image"],
349
+ cost: geminiProCost,
350
+ contextWindow: 1048576,
351
+ maxTokens: 65536,
352
+ },
353
+ {
354
+ // Launched 2026-11-12 with the backend's first -xhigh tier. Hydrogen-specific
355
+ // cost/context/output are unverified; values reuse the Gemini 4 family estimates.
356
+ id: "gemini-4-hydrogen",
357
+ name: "Gemini 4 Hydrogen (Antigravity)",
358
+ reasoning: true,
359
+ thinkingLevelMap: thinkingLevelMaps.lowMediumHighXhigh,
360
+ input: ["text", "image"],
361
+ cost: geminiProCost,
362
+ contextWindow: 1048576,
363
+ maxTokens: 65536,
364
+ },
293
365
  {
294
366
  id: "gemini-3.8-flash",
295
367
  name: "Gemini 3.8 Flash (Antigravity)",
@@ -320,28 +392,8 @@ export const ANTIGRAVITY_MODELS = [
320
392
  contextWindow: 1048576,
321
393
  maxTokens: 65536,
322
394
  },
323
- {
324
- id: "claude-opus-4-6",
325
- name: "Claude Opus 4.6 (Antigravity)",
326
- reasoning: true,
327
- thinkingLevelMap: thinkingLevelMaps.thinking,
328
- input: ["text", "image"],
329
- cost: claudeOpusCost,
330
- contextWindow: 250000,
331
- maxTokens: 64000,
332
- },
333
395
  ...claude55Models("opus"),
334
396
  ...claude55Models("sonnet"),
335
- {
336
- id: "claude-sonnet-4-6",
337
- name: "Claude Sonnet 4.6 (Antigravity)",
338
- reasoning: true,
339
- thinkingLevelMap: thinkingLevelMaps.thinking,
340
- input: ["text", "image"],
341
- cost: claudeSonnetCost,
342
- contextWindow: 200000,
343
- maxTokens: 64000,
344
- },
345
397
  {
346
398
  id: "gemini-3.1-pro",
347
399
  name: "Gemini 3.1 Pro (Antigravity)",
@@ -352,16 +404,6 @@ export const ANTIGRAVITY_MODELS = [
352
404
  contextWindow: 1048576,
353
405
  maxTokens: 65535,
354
406
  },
355
- {
356
- id: "gpt-oss-120b",
357
- name: "GPT-OSS 120B (Antigravity)",
358
- reasoning: true,
359
- thinkingLevelMap: thinkingLevelMaps.medium,
360
- input: ["text"],
361
- cost: gptOssCost,
362
- contextWindow: 131072,
363
- maxTokens: 32768,
364
- },
365
407
  ];
366
408
  /** Resolve public model id + thinking effort to Antigravity runtime model id. */
367
409
  export function getAntigravityRequestModelId(modelId, effort) {
@@ -393,6 +435,22 @@ export function getAntigravityRequestModelId(modelId, effort) {
393
435
  * provide a fallback runtime model ID (e.g. Gemini 3.6 Flash) to maintain availability.
394
436
  */
395
437
  export function getFallbackRuntimeModel(runtimeModel, effort) {
438
+ // Only Hydrogen advertises an -xhigh wire id; Carbon and Argon top out at -high,
439
+ // so a Hydrogen xHigh fallback must downgrade the tier when it crosses families.
440
+ const carbonTarget = runtimeModel.startsWith("gemini-4-hydrogen-")
441
+ ? runtimeModel.replace("gemini-4-hydrogen-", "gemini-4-carbon-").replace(/-xhigh$/, "-high")
442
+ : undefined;
443
+ if (runtimeModel === "gemini-4-hydrogen") {
444
+ return "gemini-4-carbon-low";
445
+ }
446
+ if (carbonTarget)
447
+ return carbonTarget;
448
+ if (runtimeModel === "gemini-4-carbon") {
449
+ return "gemini-4-argon-low";
450
+ }
451
+ if (runtimeModel.startsWith("gemini-4-carbon-")) {
452
+ return runtimeModel.replace("gemini-4-carbon-", "gemini-4-argon-").replace(/-xhigh$/, "-high");
453
+ }
396
454
  if (runtimeModel === "gemini-4-argon") {
397
455
  return "gemini-3.8-flash-low";
398
456
  }
@@ -5,6 +5,13 @@ import { type AntigravitySessionState } from "../utils/util.js";
5
5
  export { ANTIGRAVITY_API };
6
6
  /** Plan quota is deterministic; everything else on a 429 is a transient throttle. */
7
7
  export declare function isPlanQuotaError(status: number | undefined, text: string): boolean;
8
+ /**
9
+ * Transient 429s may carry a server-provided Retry-After (seconds or HTTP-date, CPA
10
+ * issue #6646). Trust it over the local backoff when it is short enough to be worth a
11
+ * retry; a longer value is a cooldown that will not clear inside this loop.
12
+ */
13
+ export declare const THROTTLE_RETRY_AFTER_CAP_SECONDS = 60;
14
+ export declare function parseRetryAfterSeconds(raw: string | null | undefined): number | undefined;
8
15
  /** Exported for unit tests. */
9
16
  export declare function convertMessages(model: Model<Api>, context: TranscriptContext, runtimeModel: string): GeminiContent[];
10
17
  /**
@@ -49,6 +49,28 @@ function sleep(ms, signal) {
49
49
  export function isPlanQuotaError(status, text) {
50
50
  return status === 429 && /Individual quota reached/i.test(text);
51
51
  }
52
+ /**
53
+ * Transient 429s may carry a server-provided Retry-After (seconds or HTTP-date, CPA
54
+ * issue #6646). Trust it over the local backoff when it is short enough to be worth a
55
+ * retry; a longer value is a cooldown that will not clear inside this loop.
56
+ */
57
+ export const THROTTLE_RETRY_AFTER_CAP_SECONDS = 60;
58
+ export function parseRetryAfterSeconds(raw) {
59
+ if (!raw)
60
+ return undefined;
61
+ const trimmed = raw.trim();
62
+ if (!trimmed)
63
+ return undefined;
64
+ if (/^\d+$/.test(trimmed)) {
65
+ const seconds = Number(trimmed);
66
+ return Number.isFinite(seconds) && seconds >= 0 ? seconds : undefined;
67
+ }
68
+ const date = Date.parse(trimmed);
69
+ if (Number.isNaN(date))
70
+ return undefined;
71
+ const seconds = Math.round((date - Date.now()) / 1000);
72
+ return seconds >= 0 ? seconds : 0;
73
+ }
52
74
  /**
53
75
  * pi chooses auto-retry by matching the error text (`isRetryableAssistantError`) and
54
76
  * checks account-limit phrases like "quota exceeded" BEFORE retryable ones. Google's
@@ -495,16 +517,30 @@ export function mapStopReason(reason) {
495
517
  return StopReason.Length;
496
518
  return reason ? StopReason.Error : StopReason.Stop;
497
519
  }
498
- const RETIRED_GEMINI_35_NOTICE_PREFIX = "gemini 3.5 flash is no longer available. please switch to";
499
- function isRetiredGemini35Runtime(runtimeModel) {
500
- return /^(?:gemini-3\.5-flash(?:-|$)|gemini-3-flash-agent$)/i.test(runtimeModel);
520
+ /**
521
+ * Backends answer retired models with a plain text notice instead of an error. The 3.5
522
+ * wording is the observed template; the 2026-11-18 removals (Claude 4.6, Sonnet 4.6,
523
+ * GPT-OSS 120B) are expected to reuse it. Match on the model name prefix, not the full
524
+ * sentence, so wording drift on the suffix stays harmless.
525
+ */
526
+ const RETIRED_NOTICE_PREFIXES = [
527
+ "gemini 3.5 flash is no longer available. please switch to",
528
+ "claude-opus-4-6 is no longer available",
529
+ "claude-sonnet-4-6 is no longer available",
530
+ "gpt-oss-120b is no longer available",
531
+ ];
532
+ const RETIRED_RUNTIME_PATTERN = /^(?:gemini-3\.5-flash(?:-|$)|gemini-3-flash-agent$|claude-opus-4-6|claude-sonnet-4-6|gpt-oss-120b)/i;
533
+ function isRetiredRuntime(runtimeModel) {
534
+ return RETIRED_RUNTIME_PATTERN.test(runtimeModel);
501
535
  }
502
536
  function retiredNoticePrefixState(text) {
503
537
  const normalized = text.trimStart().replace(/\s+/g, " ").toLowerCase();
504
- if (normalized.startsWith(RETIRED_GEMINI_35_NOTICE_PREFIX))
505
- return "match";
506
- if (RETIRED_GEMINI_35_NOTICE_PREFIX.startsWith(normalized))
507
- return "possible";
538
+ for (const prefix of RETIRED_NOTICE_PREFIXES) {
539
+ if (normalized.startsWith(prefix))
540
+ return "match";
541
+ if (prefix.startsWith(normalized) && normalized.length > 0)
542
+ return "possible";
543
+ }
508
544
  return "no-match";
509
545
  }
510
546
  /**
@@ -600,6 +636,16 @@ export function friendlyAntigravityError(status, text) {
600
636
  if (/verify your account|VALIDATION_REQUIRED/i.test(msg)) {
601
637
  return formatAccountValidation({ message: msg });
602
638
  }
639
+ // Google is actively enforcing third-party OAuth use (403 PERMISSION_DENIED,
640
+ // reason TOS_VIOLATION; the appeal copy names "third party software"). The reason
641
+ // lives in error.details, which jsonOrTextError drops — match the raw body. Retries,
642
+ // re-login and model switches do not clear it, and the account itself is at risk.
643
+ if (/TOS_VIOLATION|third[- ]party (software|tools|services|clients?)/i.test(text)) {
644
+ return ("Antigravity flagged this account for third-party access (TOS_VIOLATION). " +
645
+ "Retries and re-login will not clear it; further use may get the account suspended. " +
646
+ "Next: stop using third-party clients on this account and appeal through Google support. " +
647
+ `Backend said: ${msg}`);
648
+ }
603
649
  if (/permission|forbidden|access/i.test(msg)) {
604
650
  return "Antigravity access was denied for this account or project. Next: try another model, re-login, or use an account with access.";
605
651
  }
@@ -816,8 +862,8 @@ export async function streamResponse(response, stream, output, model, sessionSta
816
862
  // The response is being discarded; cancellation is best-effort.
817
863
  }
818
864
  reader.releaseLock();
819
- throw new Error("Antigravity reports that Gemini 3.5 Flash is no longer available. " +
820
- "Next: switch to gemini-3.8-flash, gemini-3.7-flash, or another catalog model.");
865
+ throw new Error("Antigravity reports that this model has been retired and is no longer available. " +
866
+ "Next: switch to a current catalog model (see /antigravity.models).");
821
867
  }
822
868
  if (noticeState !== "possible")
823
869
  flushPendingRetiredNoticeParts();
@@ -981,8 +1027,18 @@ export function streamAntigravity(model, context, options) {
981
1027
  break;
982
1028
  // Every other 429 is a transient throttle. Back off on the same endpoint
983
1029
  // instead of hopping regions, which multiplies load on a throttled account.
984
- if (response.status === 429 && throttleAttempt < THROTTLE_MAX_RETRIES) {
985
- await sleep(throttleBaseDelayMs() * 2 ** throttleAttempt, opts.signal);
1030
+ // Honor a server Retry-After when it is short; a longer one is a cooldown
1031
+ // that will not clear inside this loop, so burn no attempts on it.
1032
+ const retryAfterSeconds = parseRetryAfterSeconds(response.headers.get("retry-after"));
1033
+ const retryable = response.status === 429 &&
1034
+ throttleAttempt < THROTTLE_MAX_RETRIES &&
1035
+ (retryAfterSeconds === undefined ||
1036
+ retryAfterSeconds <= THROTTLE_RETRY_AFTER_CAP_SECONDS);
1037
+ if (retryable) {
1038
+ const delayMs = retryAfterSeconds !== undefined
1039
+ ? retryAfterSeconds * 1000
1040
+ : throttleBaseDelayMs() * 2 ** throttleAttempt;
1041
+ await sleep(delayMs, opts.signal);
986
1042
  throttleAttempt += 1;
987
1043
  continue;
988
1044
  }
@@ -1057,7 +1113,7 @@ export function streamAntigravity(model, context, options) {
1057
1113
  cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
1058
1114
  };
1059
1115
  output.stopReason = "stop";
1060
- received = await streamResponse(response, stream, output, model, sessionState, isRetiredGemini35Runtime(runtimeModel));
1116
+ received = await streamResponse(response, stream, output, model, sessionState, isRetiredRuntime(runtimeModel));
1061
1117
  if (received)
1062
1118
  break;
1063
1119
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyhuynhgiabuu/pi-oauth-antigravity",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
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",
@@ -59,8 +59,8 @@
59
59
  "undici": "^8.10.0"
60
60
  },
61
61
  "devDependencies": {
62
- "@earendil-works/pi-ai": "1.3.0",
63
- "@earendil-works/pi-coding-agent": "1.3.0",
62
+ "@earendil-works/pi-ai": "1.2.0",
63
+ "@earendil-works/pi-coding-agent": "1.2.0",
64
64
  "@types/node": "^22.20.1",
65
65
  "pi-usage-core": "^0.1.0",
66
66
  "tsx": "^4.20.6",