@heyhuynhgiabuu/pi-oauth-antigravity 0.1.3 → 0.1.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 CHANGED
@@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.1.5] - 2026-09-26
9
+
10
+ ### Fixed
11
+ - **`403 VALIDATION_REQUIRED` now reports the account verification Google actually requires.** When an account is blocked pending identity/phone verification, the error details carry a `validation_url` that the provider previously discarded, so users were told to "re-login or try another model" — neither of which can clear an account-level block. The message now links Google's verification flow, states that re-login and model switching will not help, and points at `/login antigravity` with another personal Google account as the alternative. Supplied links are rendered only when they are `https` URLs on Google-owned hosts, so a compromised or proxied response body cannot turn the error into a phishing link.
12
+
13
+ ## [0.1.4] - 2026-09-20
14
+
15
+ ### Fixed
16
+ - Kept Antigravity tool declarations on the plain JSON-schema compatibility path while retaining `VALIDATED` tool calling, so optional arguments are not rewritten as required by Pi's strict-prefer schema helper.
17
+
8
18
  ## [0.1.3] - 2026-09-20
9
19
 
10
20
  ### Fixed
@@ -19,6 +19,18 @@ export declare function convertTools(tools: Tool[] | undefined, useLegacyParamet
19
19
  export declare function buildRequest(model: Model<Api>, context: TranscriptContext, projectId: string, options: AntigravityStreamOptions, runtimeModel: string, sessionState?: AntigravitySessionState): AntigravityGenerateRequest;
20
20
  /** Exported for unit tests. */
21
21
  export declare function mapStopReason(reason: string | undefined): StopReason;
22
+ /**
23
+ * Google blocks an entire account — not one model — with 403 VALIDATION_REQUIRED until
24
+ * the account owner completes identity/phone verification. Neither re-login nor a model
25
+ * switch clears it, so the actionable `validation_url` in the error details has to reach
26
+ * the user instead of the generic "re-login or try another model" advice.
27
+ */
28
+ export interface AccountValidation {
29
+ message: string;
30
+ url?: string;
31
+ }
32
+ /** Exported for unit tests. */
33
+ export declare function extractAccountValidation(text: string): AccountValidation | undefined;
22
34
  /** Exported for unit tests. */
23
35
  export declare function friendlyAntigravityError(status: number | undefined, text: string): string;
24
36
  /** Exported for unit tests. */
@@ -1,6 +1,6 @@
1
1
  import { calculateCost, createAssistantMessageEventStream, } from "@earendil-works/pi-ai";
2
2
  import { getJsonSchemaToolParameters, resolveJsonSchemaStrictSampling } from "@earendil-works/pi-ai/api/constrained-sampling";
3
- import { requiresToolCallId, supportsGoogleStrictToolSampling } from "@earendil-works/pi-ai/api/google-shared";
3
+ import { requiresToolCallId } from "@earendil-works/pi-ai/api/google-shared";
4
4
  import { getCurrentSystemPrompt, getCurrentTools } from "./transcript.js";
5
5
  import { antigravityHeaders, endpointCandidates, fetchAvailableRuntimeModel, formatRequestDiagnostics, jsonOrTextError, loadCodeAssist, parseApiKey, resolveProjectId, } from "../client/client.js";
6
6
  import { getCurrentEndpoint, runWithDiagnostics, setLastEndpoint, setLastError, setLastLatencyMs, setLastProjectId, setLastResolvedRuntimeModel, setLastStatus, } from "../diagnostics/diagnostics.js";
@@ -8,7 +8,7 @@ import { AntigravityRequestType, AntigravityUserAgent, GeminiRole, GeminiToolCal
8
8
  import { ANTIGRAVITY_ROUTING, getMaxOutputTokens, getAntigravityRequestModelId, getFallbackRuntimeModel, getThinkingConfig, PROVIDER_ID, } from "../models/models.js";
9
9
  import { redactSecrets, safeError } from "../utils/security.js";
10
10
  import { ANTIGRAVITY_API, } from "../types/types.js";
11
- import { antigravityEnv, antigravityRequestEnvelope, deriveAntigravitySessionId, getOrCreateAntigravitySession, isRecord, persistAntigravitySessions, sanitizeText, } from "../utils/util.js";
11
+ import { antigravityEnv, antigravityRequestEnvelope, asString, deriveAntigravitySessionId, getOrCreateAntigravitySession, isRecord, persistAntigravitySessions, sanitizeText, } from "../utils/util.js";
12
12
  import { antigravityFetch } from "../utils/http.js";
13
13
  export { ANTIGRAVITY_API };
14
14
  const ANTIGRAVITY_SYSTEM_INSTRUCTION = "You are Antigravity, a powerful agentic AI coding assistant designed by Google DeepMind. " +
@@ -456,7 +456,9 @@ export function buildRequest(model, context, projectId, options, runtimeModel, s
456
456
  if (Object.keys(generationConfig).length)
457
457
  request.generationConfig = generationConfig;
458
458
  const isClaude = model.id.startsWith("claude-") || runtimeModel.startsWith("claude-");
459
- const tools = convertTools(getCurrentTools(context), isClaude || model.id.startsWith("gpt-oss-"), supportsGoogleStrictToolSampling(model.id));
459
+ const tools = convertTools(getCurrentTools(context), isClaude || model.id.startsWith("gpt-oss-"),
460
+ // Keep Antigravity on the plain-schema compatibility path with VALIDATED calls.
461
+ false);
460
462
  if (tools) {
461
463
  request.tools = tools;
462
464
  request.toolConfig = {
@@ -494,6 +496,70 @@ export function mapStopReason(reason) {
494
496
  return StopReason.Length;
495
497
  return reason ? StopReason.Error : StopReason.Stop;
496
498
  }
499
+ /**
500
+ * The URL is printed for the user to click, so only Google-owned https hosts are
501
+ * allowed. A response body is untrusted input just like any other; a foreign host here
502
+ * would be a ready-made phishing link.
503
+ */
504
+ function safeValidationUrl(raw) {
505
+ const trimmed = asString(raw)?.trim();
506
+ if (!trimmed)
507
+ return undefined;
508
+ let url;
509
+ try {
510
+ url = new URL(trimmed);
511
+ }
512
+ catch {
513
+ return undefined;
514
+ }
515
+ if (url.protocol !== "https:")
516
+ return undefined;
517
+ const host = url.hostname.toLowerCase();
518
+ const googleOwned = host === "google.com" ||
519
+ host.endsWith(".google.com") ||
520
+ host === "googleapis.com" ||
521
+ host.endsWith(".googleapis.com");
522
+ if (!googleOwned)
523
+ return undefined;
524
+ // Return the backend's exact string (not url.toString()) so Google's params survive
525
+ // verbatim; redactSecrets is the belt-and-braces check that no token rode along.
526
+ return redactSecrets(trimmed);
527
+ }
528
+ /** Exported for unit tests. */
529
+ export function extractAccountValidation(text) {
530
+ let parsed;
531
+ try {
532
+ parsed = JSON.parse(text);
533
+ }
534
+ catch {
535
+ return undefined;
536
+ }
537
+ const error = isRecord(parsed) ? parsed.error : undefined;
538
+ if (!isRecord(error) || !Array.isArray(error.details))
539
+ return undefined;
540
+ for (const detail of error.details) {
541
+ if (!isRecord(detail) || detail.reason !== "VALIDATION_REQUIRED")
542
+ continue;
543
+ const metadata = isRecord(detail.metadata) ? detail.metadata : {};
544
+ // Both candidates are response-body fields, so both are redacted like the rest of
545
+ // the backend text that reaches the user; neither can smuggle a token out.
546
+ const message = asString(metadata.validation_error_message) ?? asString(error.message) ?? "";
547
+ return {
548
+ message: redactSecrets(message).trim().slice(0, 200),
549
+ url: safeValidationUrl(metadata.validation_url),
550
+ };
551
+ }
552
+ return undefined;
553
+ }
554
+ function formatAccountValidation(validation) {
555
+ const next = validation.url
556
+ ? `complete verification at ${validation.url}`
557
+ : "complete Google account verification";
558
+ return ("Antigravity denied this account pending Google account verification (VALIDATION_REQUIRED). " +
559
+ `Re-login and switching models will not clear it. Next: ${next}, ` +
560
+ "or /login antigravity with another personal Google account." +
561
+ (validation.message ? ` Backend said: ${validation.message}` : ""));
562
+ }
497
563
  /** Exported for unit tests. */
498
564
  export function friendlyAntigravityError(status, text) {
499
565
  const full = redactSecrets(jsonOrTextError(text));
@@ -514,6 +580,15 @@ export function friendlyAntigravityError(status, text) {
514
580
  return "Antigravity authentication failed. Next: run /login antigravity, then retry.";
515
581
  }
516
582
  if (status === 403) {
583
+ // Account-level eligibility block. Checked before the generic permission test
584
+ // because a body can carry both signals and only this one is user-fixable.
585
+ const validation = extractAccountValidation(text);
586
+ if (validation)
587
+ return formatAccountValidation(validation);
588
+ // Fallback for gateways that strip `details` but keep the message.
589
+ if (/verify your account|VALIDATION_REQUIRED/i.test(msg)) {
590
+ return formatAccountValidation({ message: msg });
591
+ }
517
592
  if (/permission|forbidden|access/i.test(msg)) {
518
593
  return "Antigravity access was denied for this account or project. Next: try another model, re-login, or use an account with access.";
519
594
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@heyhuynhgiabuu/pi-oauth-antigravity",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
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",