@cortexkit/pi-antigravity-auth 1.0.1 → 1.1.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/README.md +7 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +338 -61
- package/dist/index.js.map +4 -4
- package/dist/stream.d.ts +4 -1
- package/dist/stream.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Antigravity's endpoints.
|
|
|
11
11
|
## Install
|
|
12
12
|
|
|
13
13
|
```bash
|
|
14
|
-
pi
|
|
14
|
+
pi install npm:@cortexkit/pi-antigravity-auth
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
## Login
|
|
@@ -28,12 +28,17 @@ callback URL (or authorization code) back into the prompt.
|
|
|
28
28
|
The extension registers the Antigravity model catalog under the
|
|
29
29
|
`google-antigravity` provider, including:
|
|
30
30
|
|
|
31
|
+
- `antigravity-gemini-3.6-flash`
|
|
31
32
|
- `antigravity-gemini-3.5-flash`
|
|
32
33
|
- `antigravity-gemini-3.1-pro`
|
|
33
34
|
- `antigravity-claude-sonnet-4-6-thinking`
|
|
34
35
|
- `antigravity-claude-opus-4-6-thinking`
|
|
36
|
+
- `antigravity-gpt-oss-120b-medium`
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
The image-generation model is currently OpenCode-only because Pi's provider event
|
|
39
|
+
protocol does not expose image-output stream events.
|
|
40
|
+
|
|
41
|
+
Select a model with `/model` or `pi -m google-antigravity/antigravity-gemini-3.6-flash`.
|
|
37
42
|
|
|
38
43
|
## Configuration
|
|
39
44
|
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAkEnE,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAA;AAkEnE,MAAM,CAAC,OAAO,UAAU,0BAA0B,CAAC,EAAE,EAAE,YAAY,GAAG,IAAI,CAkCzE"}
|
package/dist/index.js
CHANGED
|
@@ -52,6 +52,41 @@ function createLogger(module) {
|
|
|
52
52
|
};
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
// ../core/src/fingerprint.ts
|
|
56
|
+
var AGY_CLI_VERSION = "1.1.5";
|
|
57
|
+
function normalizeHarnessPlatform(platform = process.platform) {
|
|
58
|
+
return platform === "win32" ? "windows" : platform || "unknown";
|
|
59
|
+
}
|
|
60
|
+
function normalizeHarnessArch(arch = process.arch) {
|
|
61
|
+
switch (arch) {
|
|
62
|
+
case "x64":
|
|
63
|
+
return "amd64";
|
|
64
|
+
case "ia32":
|
|
65
|
+
return "386";
|
|
66
|
+
default:
|
|
67
|
+
return arch || "unknown";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
function buildAntigravityHarnessUserAgent(version = AGY_CLI_VERSION, platform = process.platform, arch = process.arch, authMethod = "consumer") {
|
|
71
|
+
const osType = normalizeHarnessPlatform(platform);
|
|
72
|
+
const normalizedArch = normalizeHarnessArch(arch);
|
|
73
|
+
return `antigravity/cli/${version} (aidev_client; os_type=${osType}; arch=${normalizedArch}; auth_method=${authMethod})`;
|
|
74
|
+
}
|
|
75
|
+
function buildAntigravityHarnessLoadCodeAssistUserAgent(version = AGY_CLI_VERSION) {
|
|
76
|
+
return buildAntigravityHarnessUserAgent(version);
|
|
77
|
+
}
|
|
78
|
+
function buildAntigravityLoadCodeAssistMetadata() {
|
|
79
|
+
return { ideType: "ANTIGRAVITY" };
|
|
80
|
+
}
|
|
81
|
+
function buildAntigravityHarnessBootstrapHeaders(accessToken) {
|
|
82
|
+
return {
|
|
83
|
+
"User-Agent": buildAntigravityHarnessLoadCodeAssistUserAgent(),
|
|
84
|
+
Authorization: `Bearer ${accessToken}`,
|
|
85
|
+
"Content-Type": "application/json",
|
|
86
|
+
"Accept-Encoding": "gzip"
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
|
|
55
90
|
// ../core/src/constants.ts
|
|
56
91
|
var ANTIGRAVITY_CLIENT_ID = "1071006060591-tmhssin2h21lcre235vtolojh4g403ep.apps.googleusercontent.com";
|
|
57
92
|
var ANTIGRAVITY_CLIENT_SECRET = "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";
|
|
@@ -111,42 +146,6 @@ function calculateTokenExpiry(requestTimeMs, expiresInSeconds) {
|
|
|
111
146
|
return requestTimeMs + seconds * 1e3;
|
|
112
147
|
}
|
|
113
148
|
|
|
114
|
-
// ../core/src/fingerprint.ts
|
|
115
|
-
var AGY_CLI_VERSION = "1.0.4";
|
|
116
|
-
function normalizeHarnessPlatform(platform = process.platform) {
|
|
117
|
-
return platform === "win32" ? "windows" : platform || "unknown";
|
|
118
|
-
}
|
|
119
|
-
function normalizeHarnessArch(arch = process.arch) {
|
|
120
|
-
switch (arch) {
|
|
121
|
-
case "x64":
|
|
122
|
-
return "amd64";
|
|
123
|
-
case "ia32":
|
|
124
|
-
return "386";
|
|
125
|
-
default:
|
|
126
|
-
return arch || "unknown";
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
function buildAntigravityHarnessPlatformArch(platform = process.platform, arch = process.arch) {
|
|
130
|
-
return `${normalizeHarnessPlatform(platform)}/${normalizeHarnessArch(arch)}`;
|
|
131
|
-
}
|
|
132
|
-
function buildAntigravityHarnessUserAgent(version = AGY_CLI_VERSION, platform = process.platform, arch = process.arch) {
|
|
133
|
-
return `antigravity/cli/${version} ${buildAntigravityHarnessPlatformArch(platform, arch)}`;
|
|
134
|
-
}
|
|
135
|
-
function buildAntigravityHarnessLoadCodeAssistUserAgent(version = AGY_CLI_VERSION) {
|
|
136
|
-
return buildAntigravityHarnessUserAgent(version);
|
|
137
|
-
}
|
|
138
|
-
function buildAntigravityLoadCodeAssistMetadata() {
|
|
139
|
-
return { ideType: "ANTIGRAVITY" };
|
|
140
|
-
}
|
|
141
|
-
function buildAntigravityHarnessBootstrapHeaders(accessToken) {
|
|
142
|
-
return {
|
|
143
|
-
"User-Agent": buildAntigravityHarnessLoadCodeAssistUserAgent(),
|
|
144
|
-
Authorization: `Bearer ${accessToken}`,
|
|
145
|
-
"Content-Type": "application/json",
|
|
146
|
-
"Accept-Encoding": "gzip"
|
|
147
|
-
};
|
|
148
|
-
}
|
|
149
|
-
|
|
150
149
|
// ../core/src/agy-transport.ts
|
|
151
150
|
import * as net from "node:net";
|
|
152
151
|
import * as tls from "node:tls";
|
|
@@ -184,7 +183,7 @@ function buildAgyCliHeaderPairs(url, init = {}) {
|
|
|
184
183
|
const headers = headersToRecord(init.headers);
|
|
185
184
|
const body = bodyToBuffer(init.body);
|
|
186
185
|
const host = parsedUrl.port ? `${parsedUrl.hostname}:${parsedUrl.port}` : parsedUrl.hostname;
|
|
187
|
-
const userAgent = getHeader(headers, "User-Agent") ??
|
|
186
|
+
const userAgent = getHeader(headers, "User-Agent") ?? buildAntigravityHarnessUserAgent();
|
|
188
187
|
const authorization = getHeader(headers, "Authorization");
|
|
189
188
|
const contentType = getHeader(headers, "Content-Type") ?? "application/json";
|
|
190
189
|
const acceptEncoding = getHeader(headers, "Accept-Encoding") ?? "gzip";
|
|
@@ -586,6 +585,178 @@ async function connectTlsWithAbort(targetUrl, timeoutMs, signal, onDebug) {
|
|
|
586
585
|
}
|
|
587
586
|
}
|
|
588
587
|
|
|
588
|
+
// ../core/src/agy-request-metadata.ts
|
|
589
|
+
import { Buffer as Buffer3 } from "node:buffer";
|
|
590
|
+
import { randomUUID } from "node:crypto";
|
|
591
|
+
var FNV1A_64_OFFSET_BASIS = 0xcbf29ce484222325n;
|
|
592
|
+
var FNV1A_64_PRIME = 0x100000001b3n;
|
|
593
|
+
var DEFAULT_SESSION_STATE_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
594
|
+
var DEFAULT_MAX_SESSION_STATES = 256;
|
|
595
|
+
var AGY_REQUEST_FIELD_ORDER = [
|
|
596
|
+
"contents",
|
|
597
|
+
"systemInstruction",
|
|
598
|
+
"tools",
|
|
599
|
+
"toolConfig",
|
|
600
|
+
"labels",
|
|
601
|
+
"generationConfig",
|
|
602
|
+
"sessionId"
|
|
603
|
+
];
|
|
604
|
+
var AGY_MODEL_ENUM_BY_WIRE_MODEL = {
|
|
605
|
+
"gemini-3.5-flash-extra-low": "MODEL_PLACEHOLDER_M187",
|
|
606
|
+
"gemini-3.5-flash-low": "MODEL_PLACEHOLDER_M20",
|
|
607
|
+
"gemini-3-flash-agent": "MODEL_PLACEHOLDER_M84",
|
|
608
|
+
"gemini-3.6-flash-low": "MODEL_PLACEHOLDER_M266",
|
|
609
|
+
"gemini-3.6-flash-medium": "MODEL_PLACEHOLDER_M265",
|
|
610
|
+
"gemini-3.6-flash-high": "MODEL_PLACEHOLDER_M264",
|
|
611
|
+
"gemini-3.1-pro-low": "MODEL_PLACEHOLDER_M36",
|
|
612
|
+
"gemini-pro-agent": "MODEL_PLACEHOLDER_M16",
|
|
613
|
+
"claude-sonnet-4-6": "MODEL_PLACEHOLDER_M35",
|
|
614
|
+
"claude-opus-4-6-thinking": "MODEL_PLACEHOLDER_M26",
|
|
615
|
+
"gemini-3.1-flash-image": "MODEL_PLACEHOLDER_M21",
|
|
616
|
+
"gpt-oss-120b-medium": "MODEL_OPENAI_GPT_OSS_120B_MEDIUM"
|
|
617
|
+
};
|
|
618
|
+
function fnv1a64Signed(input) {
|
|
619
|
+
let hash = FNV1A_64_OFFSET_BASIS;
|
|
620
|
+
for (const byte of Buffer3.from(input, "utf8")) {
|
|
621
|
+
hash ^= BigInt(byte);
|
|
622
|
+
hash = BigInt.asUintN(64, hash * FNV1A_64_PRIME);
|
|
623
|
+
}
|
|
624
|
+
return BigInt.asIntN(64, hash).toString();
|
|
625
|
+
}
|
|
626
|
+
function createAgyRequestSessionContext(workspaceUri, ids = {}) {
|
|
627
|
+
return {
|
|
628
|
+
conversationId: ids.conversationId ?? randomUUID(),
|
|
629
|
+
trajectoryId: ids.trajectoryId ?? randomUUID(),
|
|
630
|
+
numericSessionId: fnv1a64Signed(workspaceUri)
|
|
631
|
+
};
|
|
632
|
+
}
|
|
633
|
+
var AgyRequestSessionStore = class {
|
|
634
|
+
entries = /* @__PURE__ */ new Map();
|
|
635
|
+
workspaceUri;
|
|
636
|
+
ttlMs;
|
|
637
|
+
maxEntries;
|
|
638
|
+
now;
|
|
639
|
+
constructor(workspaceUri, options = {}) {
|
|
640
|
+
this.workspaceUri = workspaceUri;
|
|
641
|
+
this.ttlMs = options.ttlMs ?? DEFAULT_SESSION_STATE_TTL_MS;
|
|
642
|
+
this.maxEntries = options.maxEntries ?? DEFAULT_MAX_SESSION_STATES;
|
|
643
|
+
this.now = options.now ?? Date.now;
|
|
644
|
+
}
|
|
645
|
+
getOrCreate(key) {
|
|
646
|
+
const timestamp = this.now();
|
|
647
|
+
this.prune(timestamp, key);
|
|
648
|
+
const existing = this.entries.get(key);
|
|
649
|
+
if (existing) {
|
|
650
|
+
existing.lastAccessedAt = timestamp;
|
|
651
|
+
return existing.context;
|
|
652
|
+
}
|
|
653
|
+
const context = createAgyRequestSessionContext(this.workspaceUri);
|
|
654
|
+
this.entries.set(key, {
|
|
655
|
+
context,
|
|
656
|
+
lastAccessedAt: timestamp,
|
|
657
|
+
lastRequestTimestamp: 0
|
|
658
|
+
});
|
|
659
|
+
return context;
|
|
660
|
+
}
|
|
661
|
+
beginRequest(key) {
|
|
662
|
+
const session = this.getOrCreate(key);
|
|
663
|
+
const stored = this.entries.get(key);
|
|
664
|
+
const timestamp = Math.max(stored.lastAccessedAt, stored.lastRequestTimestamp + 1);
|
|
665
|
+
stored.lastRequestTimestamp = timestamp;
|
|
666
|
+
return { session, timestamp };
|
|
667
|
+
}
|
|
668
|
+
has(key) {
|
|
669
|
+
return this.entries.has(key);
|
|
670
|
+
}
|
|
671
|
+
delete(key) {
|
|
672
|
+
this.entries.delete(key);
|
|
673
|
+
}
|
|
674
|
+
get size() {
|
|
675
|
+
return this.entries.size;
|
|
676
|
+
}
|
|
677
|
+
prune(timestamp, preservedKey) {
|
|
678
|
+
const expiry = timestamp - this.ttlMs;
|
|
679
|
+
for (const [key, value] of this.entries) {
|
|
680
|
+
if (key !== preservedKey && value.lastAccessedAt < expiry) {
|
|
681
|
+
this.entries.delete(key);
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
while (this.entries.size >= this.maxEntries && !this.entries.has(preservedKey)) {
|
|
685
|
+
let oldestKey = null;
|
|
686
|
+
let oldestAccess = Number.POSITIVE_INFINITY;
|
|
687
|
+
for (const [key, value] of this.entries) {
|
|
688
|
+
if (key !== preservedKey && value.lastAccessedAt < oldestAccess) {
|
|
689
|
+
oldestKey = key;
|
|
690
|
+
oldestAccess = value.lastAccessedAt;
|
|
691
|
+
}
|
|
692
|
+
}
|
|
693
|
+
if (!oldestKey) {
|
|
694
|
+
break;
|
|
695
|
+
}
|
|
696
|
+
this.entries.delete(oldestKey);
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
};
|
|
700
|
+
function getAgyModelEnum(model) {
|
|
701
|
+
return AGY_MODEL_ENUM_BY_WIRE_MODEL[model.toLowerCase()];
|
|
702
|
+
}
|
|
703
|
+
function orderAgyRequestPayloadInPlace(payload) {
|
|
704
|
+
const ordered = {};
|
|
705
|
+
const remaining = new Set(Object.keys(payload));
|
|
706
|
+
for (const key of AGY_REQUEST_FIELD_ORDER) {
|
|
707
|
+
if (key in payload) {
|
|
708
|
+
ordered[key] = payload[key];
|
|
709
|
+
remaining.delete(key);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
for (const key of remaining) {
|
|
713
|
+
ordered[key] = payload[key];
|
|
714
|
+
}
|
|
715
|
+
for (const key of Object.keys(payload)) {
|
|
716
|
+
delete payload[key];
|
|
717
|
+
}
|
|
718
|
+
Object.assign(payload, ordered);
|
|
719
|
+
}
|
|
720
|
+
function countAgyRequestSteps(payload) {
|
|
721
|
+
const contents = payload.contents;
|
|
722
|
+
if (!Array.isArray(contents)) {
|
|
723
|
+
return 1;
|
|
724
|
+
}
|
|
725
|
+
let partCount = 0;
|
|
726
|
+
for (const content of contents) {
|
|
727
|
+
if (!content || typeof content !== "object" || Array.isArray(content)) {
|
|
728
|
+
continue;
|
|
729
|
+
}
|
|
730
|
+
const parts = content.parts;
|
|
731
|
+
if (Array.isArray(parts)) {
|
|
732
|
+
partCount += parts.length;
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
return Math.max(1, partCount);
|
|
736
|
+
}
|
|
737
|
+
function buildAgyAgentRequestMetadata(session, payload, model, timestamp = Date.now()) {
|
|
738
|
+
const lastStepIndex = countAgyRequestSteps(payload);
|
|
739
|
+
const isClaude = model.toLowerCase().startsWith("claude-");
|
|
740
|
+
const isNonGemini = isClaude || model.toLowerCase().startsWith("gpt-");
|
|
741
|
+
session.usedClaude = session.usedClaude === true || isClaude;
|
|
742
|
+
session.usedNonGeminiModel = session.usedNonGeminiModel === true || isNonGemini;
|
|
743
|
+
const modelEnum = getAgyModelEnum(model);
|
|
744
|
+
const labels = {
|
|
745
|
+
last_step_index: String(lastStepIndex),
|
|
746
|
+
...modelEnum ? { model_enum: modelEnum } : {},
|
|
747
|
+
trajectory_id: session.trajectoryId,
|
|
748
|
+
used_claude: session.usedClaude ? "true" : "false",
|
|
749
|
+
used_claude_conservative: session.usedClaude ? "true" : "false",
|
|
750
|
+
used_non_gemini_model: session.usedNonGeminiModel ? "true" : "false"
|
|
751
|
+
};
|
|
752
|
+
return {
|
|
753
|
+
requestId: `agent/${session.conversationId}/${timestamp}/${session.trajectoryId}/${lastStepIndex + 1}`,
|
|
754
|
+
sessionId: session.numericSessionId,
|
|
755
|
+
labels,
|
|
756
|
+
lastStepIndex
|
|
757
|
+
};
|
|
758
|
+
}
|
|
759
|
+
|
|
589
760
|
// ../core/src/project.ts
|
|
590
761
|
var log = createLogger("project");
|
|
591
762
|
var PROJECT_CONTEXT_CACHE_TTL_MS = 30 * 60 * 1e3;
|
|
@@ -815,6 +986,16 @@ var ALL_MODEL_DEFINITIONS = {
|
|
|
815
986
|
high: { thinkingLevel: "high" }
|
|
816
987
|
}
|
|
817
988
|
}),
|
|
989
|
+
"antigravity-gemini-3.6-flash": defineModel("antigravity-gemini-3.6-flash", {
|
|
990
|
+
name: "Gemini 3.6 Flash (Antigravity)",
|
|
991
|
+
reasoning: true,
|
|
992
|
+
limit: { context: 1048576, output: 65536 },
|
|
993
|
+
modalities: DEFAULT_MODALITIES,
|
|
994
|
+
variants: {
|
|
995
|
+
low: { thinkingLevel: "low" },
|
|
996
|
+
high: { thinkingLevel: "high" }
|
|
997
|
+
}
|
|
998
|
+
}),
|
|
818
999
|
"antigravity-gemini-3.5-flash": defineModel("antigravity-gemini-3.5-flash", {
|
|
819
1000
|
name: "Gemini 3.5 Flash (Antigravity)",
|
|
820
1001
|
reasoning: true,
|
|
@@ -854,14 +1035,11 @@ var ALL_MODEL_DEFINITIONS = {
|
|
|
854
1035
|
output: ["text", "image"]
|
|
855
1036
|
}
|
|
856
1037
|
}),
|
|
857
|
-
"antigravity-gpt-oss-120b": defineModel("antigravity-gpt-oss-120b", {
|
|
858
|
-
name: "GPT-OSS 120B (Antigravity)",
|
|
859
|
-
reasoning:
|
|
860
|
-
limit: { context:
|
|
861
|
-
modalities: DEFAULT_MODALITIES
|
|
862
|
-
variants: {
|
|
863
|
-
medium: {}
|
|
864
|
-
}
|
|
1038
|
+
"antigravity-gpt-oss-120b-medium": defineModel("antigravity-gpt-oss-120b-medium", {
|
|
1039
|
+
name: "GPT-OSS 120B Medium (Antigravity)",
|
|
1040
|
+
reasoning: true,
|
|
1041
|
+
limit: { context: 131072, output: 32768 },
|
|
1042
|
+
modalities: DEFAULT_MODALITIES
|
|
865
1043
|
}),
|
|
866
1044
|
"gemini-2.5-flash": defineModel("gemini-2.5-flash", {
|
|
867
1045
|
name: "Gemini 2.5 Flash (Gemini CLI)",
|
|
@@ -927,6 +1105,9 @@ var RESOLVER_ALIASES = {
|
|
|
927
1105
|
"gemini-3.5-flash-low": "gemini-3.5-flash",
|
|
928
1106
|
"gemini-3.5-flash-medium": "gemini-3.5-flash",
|
|
929
1107
|
"gemini-3.5-flash-high": "gemini-3.5-flash",
|
|
1108
|
+
"gemini-3.6-flash-low": "gemini-3.6-flash",
|
|
1109
|
+
"gemini-3.6-flash-medium": "gemini-3.6-flash",
|
|
1110
|
+
"gemini-3.6-flash-high": "gemini-3.6-flash",
|
|
930
1111
|
"gemini-claude-opus-4-6-thinking-low": "claude-opus-4-6-thinking",
|
|
931
1112
|
"gemini-claude-opus-4-6-thinking-medium": "claude-opus-4-6-thinking",
|
|
932
1113
|
"gemini-claude-opus-4-6-thinking-high": "claude-opus-4-6-thinking",
|
|
@@ -937,7 +1118,8 @@ var RESOLVER_ALIASES = {
|
|
|
937
1118
|
"claude-sonnet-4-6-thinking": "claude-sonnet-4-6",
|
|
938
1119
|
"claude-sonnet-4-6-thinking-low": "claude-sonnet-4-6",
|
|
939
1120
|
"claude-sonnet-4-6-thinking-medium": "claude-sonnet-4-6",
|
|
940
|
-
"claude-sonnet-4-6-thinking-high": "claude-sonnet-4-6"
|
|
1121
|
+
"claude-sonnet-4-6-thinking-high": "claude-sonnet-4-6",
|
|
1122
|
+
"gpt-oss-120b": "gpt-oss-120b-medium"
|
|
941
1123
|
};
|
|
942
1124
|
var GEMINI_35_FLASH_ROUTES = {
|
|
943
1125
|
antigravity: {
|
|
@@ -950,11 +1132,22 @@ var GEMINI_35_FLASH_ROUTES = {
|
|
|
950
1132
|
},
|
|
951
1133
|
geminiCliFallbackModel: "gemini-3-flash-preview"
|
|
952
1134
|
};
|
|
1135
|
+
var GEMINI_36_FLASH_ROUTES = {
|
|
1136
|
+
defaultModel: "gemini-3.6-flash-medium",
|
|
1137
|
+
byTier: {
|
|
1138
|
+
low: "gemini-3.6-flash-low",
|
|
1139
|
+
medium: "gemini-3.6-flash-medium",
|
|
1140
|
+
high: "gemini-3.6-flash-high"
|
|
1141
|
+
}
|
|
1142
|
+
};
|
|
953
1143
|
var ANTIGRAVITY_OPENCODE_MODEL_IDS = [
|
|
1144
|
+
"antigravity-gemini-3.6-flash",
|
|
954
1145
|
"antigravity-gemini-3.5-flash",
|
|
955
1146
|
"antigravity-gemini-3.1-pro",
|
|
956
1147
|
"antigravity-claude-sonnet-4-6-thinking",
|
|
957
|
-
"antigravity-claude-opus-4-6-thinking"
|
|
1148
|
+
"antigravity-claude-opus-4-6-thinking",
|
|
1149
|
+
"antigravity-gemini-3.1-flash-image",
|
|
1150
|
+
"antigravity-gpt-oss-120b-medium"
|
|
958
1151
|
];
|
|
959
1152
|
function pickModelDefinitions(ids) {
|
|
960
1153
|
return Object.fromEntries(ids.map((id) => [id, ALL_MODEL_DEFINITIONS[id]]));
|
|
@@ -975,6 +1168,12 @@ function getGemini35FlashAntigravityModel(tier) {
|
|
|
975
1168
|
function getGemini35FlashGeminiCliFallbackModel() {
|
|
976
1169
|
return GEMINI_35_FLASH_ROUTES.geminiCliFallbackModel;
|
|
977
1170
|
}
|
|
1171
|
+
function getGemini36FlashAntigravityModel(tier) {
|
|
1172
|
+
if (!tier) {
|
|
1173
|
+
return GEMINI_36_FLASH_ROUTES.defaultModel;
|
|
1174
|
+
}
|
|
1175
|
+
return GEMINI_36_FLASH_ROUTES.byTier[tier] ?? GEMINI_36_FLASH_ROUTES.defaultModel;
|
|
1176
|
+
}
|
|
978
1177
|
|
|
979
1178
|
// ../core/src/transform/model-resolver.ts
|
|
980
1179
|
var THINKING_TIER_BUDGETS = {
|
|
@@ -1028,7 +1227,7 @@ function isGemini35FlashModel(model) {
|
|
|
1028
1227
|
function resolveGemini35FlashAntigravityModel(tier) {
|
|
1029
1228
|
return getGemini35FlashAntigravityModel(tier);
|
|
1030
1229
|
}
|
|
1031
|
-
function
|
|
1230
|
+
function getAgyGeminiFlashThinkingBudget(tier) {
|
|
1032
1231
|
switch (tier) {
|
|
1033
1232
|
case "low":
|
|
1034
1233
|
return 1e3;
|
|
@@ -1061,6 +1260,8 @@ function resolveModelWithTier(requestedModel, options = {}) {
|
|
|
1061
1260
|
const isGemini3Flash = isGemini3FlashModel(modelWithoutQuota);
|
|
1062
1261
|
const isGemini31Pro = /^gemini-3\.1-pro/i.test(baseName);
|
|
1063
1262
|
const isGemini35Flash = /^gemini-3\.5-flash/i.test(baseName);
|
|
1263
|
+
const isGemini36Flash = /^gemini-3\.6-flash/i.test(baseName);
|
|
1264
|
+
const isGptOss120b = /^gpt-oss-120b(?:-medium)?$/i.test(baseName);
|
|
1064
1265
|
if (isGemini31Pro && quotaPreference === "antigravity") {
|
|
1065
1266
|
return {
|
|
1066
1267
|
actualModel: getAgyGemini31ProModel(tier),
|
|
@@ -1074,13 +1275,32 @@ function resolveModelWithTier(requestedModel, options = {}) {
|
|
|
1074
1275
|
if (isGemini35Flash && quotaPreference === "antigravity") {
|
|
1075
1276
|
return {
|
|
1076
1277
|
actualModel: resolveGemini35FlashAntigravityModel(tier ?? "medium"),
|
|
1077
|
-
thinkingBudget:
|
|
1278
|
+
thinkingBudget: getAgyGeminiFlashThinkingBudget(tier),
|
|
1279
|
+
tier: tier ?? "medium",
|
|
1280
|
+
isThinkingModel: true,
|
|
1281
|
+
quotaPreference,
|
|
1282
|
+
explicitQuota
|
|
1283
|
+
};
|
|
1284
|
+
}
|
|
1285
|
+
if (isGemini36Flash && quotaPreference === "antigravity") {
|
|
1286
|
+
return {
|
|
1287
|
+
actualModel: getGemini36FlashAntigravityModel(tier ?? "medium"),
|
|
1288
|
+
thinkingBudget: getAgyGeminiFlashThinkingBudget(tier),
|
|
1078
1289
|
tier: tier ?? "medium",
|
|
1079
1290
|
isThinkingModel: true,
|
|
1080
1291
|
quotaPreference,
|
|
1081
1292
|
explicitQuota
|
|
1082
1293
|
};
|
|
1083
1294
|
}
|
|
1295
|
+
if (isGptOss120b && quotaPreference === "antigravity") {
|
|
1296
|
+
return {
|
|
1297
|
+
actualModel: "gpt-oss-120b-medium",
|
|
1298
|
+
thinkingBudget: 8192,
|
|
1299
|
+
isThinkingModel: true,
|
|
1300
|
+
quotaPreference,
|
|
1301
|
+
explicitQuota
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1084
1304
|
let antigravityModel = modelWithoutQuota;
|
|
1085
1305
|
if (skipAlias) {
|
|
1086
1306
|
if ((isGemini3Pro || isGemini3Flash) && !tier && !isImageModel) {
|
|
@@ -1222,12 +1442,26 @@ var UNSUPPORTED_SCHEMA_FIELDS = /* @__PURE__ */ new Set([
|
|
|
1222
1442
|
"minContains",
|
|
1223
1443
|
"maxContains"
|
|
1224
1444
|
]);
|
|
1225
|
-
|
|
1445
|
+
var NUMERIC_SCHEMA_CONSTRAINTS = /* @__PURE__ */ new Set([
|
|
1446
|
+
"minLength",
|
|
1447
|
+
"maxLength",
|
|
1448
|
+
"minItems",
|
|
1449
|
+
"maxItems",
|
|
1450
|
+
"minProperties",
|
|
1451
|
+
"maxProperties",
|
|
1452
|
+
"minimum",
|
|
1453
|
+
"maximum",
|
|
1454
|
+
"exclusiveMinimum",
|
|
1455
|
+
"exclusiveMaximum",
|
|
1456
|
+
"multipleOf"
|
|
1457
|
+
]);
|
|
1458
|
+
function toGeminiSchema(schema, options = {}) {
|
|
1226
1459
|
if (!schema || typeof schema !== "object" || Array.isArray(schema)) {
|
|
1227
1460
|
return schema;
|
|
1228
1461
|
}
|
|
1229
1462
|
const inputSchema = schema;
|
|
1230
1463
|
const result = {};
|
|
1464
|
+
const numericConstraintHints = [];
|
|
1231
1465
|
const propertyNames = /* @__PURE__ */ new Set();
|
|
1232
1466
|
if (inputSchema.properties && typeof inputSchema.properties === "object") {
|
|
1233
1467
|
for (const propName of Object.keys(inputSchema.properties)) {
|
|
@@ -1243,15 +1477,19 @@ function toGeminiSchema(schema) {
|
|
|
1243
1477
|
} else if (key === "properties" && typeof value === "object" && value !== null) {
|
|
1244
1478
|
const props = {};
|
|
1245
1479
|
for (const [propName, propSchema] of Object.entries(value)) {
|
|
1246
|
-
props[propName] = toGeminiSchema(propSchema);
|
|
1480
|
+
props[propName] = toGeminiSchema(propSchema, options);
|
|
1247
1481
|
}
|
|
1248
1482
|
result[key] = props;
|
|
1249
1483
|
} else if (key === "items" && typeof value === "object") {
|
|
1250
|
-
result[key] = toGeminiSchema(value);
|
|
1484
|
+
result[key] = toGeminiSchema(value, options);
|
|
1251
1485
|
} else if ((key === "anyOf" || key === "oneOf" || key === "allOf") && Array.isArray(value)) {
|
|
1252
|
-
result[key] = value.map((item) => toGeminiSchema(item));
|
|
1486
|
+
result[key] = value.map((item) => toGeminiSchema(item, options));
|
|
1253
1487
|
} else if (key === "enum" && Array.isArray(value)) {
|
|
1254
1488
|
result[key] = value;
|
|
1489
|
+
} else if (options.moveNumericConstraintsToDescription && NUMERIC_SCHEMA_CONSTRAINTS.has(key)) {
|
|
1490
|
+
if (typeof value === "string" || typeof value === "number") {
|
|
1491
|
+
numericConstraintHints.push(`${key}: ${value}`);
|
|
1492
|
+
}
|
|
1255
1493
|
} else if (key === "default" || key === "examples") {
|
|
1256
1494
|
result[key] = value;
|
|
1257
1495
|
} else if (key === "required" && Array.isArray(value)) {
|
|
@@ -1269,6 +1507,10 @@ function toGeminiSchema(schema) {
|
|
|
1269
1507
|
result[key] = value;
|
|
1270
1508
|
}
|
|
1271
1509
|
}
|
|
1510
|
+
if (numericConstraintHints.length > 0) {
|
|
1511
|
+
const hint = numericConstraintHints.join(", ");
|
|
1512
|
+
result.description = typeof result.description === "string" && result.description ? `${result.description} (${hint})` : hint;
|
|
1513
|
+
}
|
|
1272
1514
|
if (result.type === "ARRAY" && !result.items) {
|
|
1273
1515
|
result.items = { type: "STRING" };
|
|
1274
1516
|
}
|
|
@@ -1276,7 +1518,7 @@ function toGeminiSchema(schema) {
|
|
|
1276
1518
|
}
|
|
1277
1519
|
|
|
1278
1520
|
// ../../node_modules/jose/dist/node/esm/runtime/base64url.js
|
|
1279
|
-
import { Buffer as
|
|
1521
|
+
import { Buffer as Buffer4 } from "node:buffer";
|
|
1280
1522
|
|
|
1281
1523
|
// ../../node_modules/jose/dist/node/esm/lib/buffer_utils.js
|
|
1282
1524
|
var encoder = new TextEncoder();
|
|
@@ -1291,8 +1533,8 @@ function normalize(input) {
|
|
|
1291
1533
|
}
|
|
1292
1534
|
return encoded;
|
|
1293
1535
|
}
|
|
1294
|
-
var encode = (input) =>
|
|
1295
|
-
var decode = (input) => new Uint8Array(
|
|
1536
|
+
var encode = (input) => Buffer4.from(input).toString("base64url");
|
|
1537
|
+
var decode = (input) => new Uint8Array(Buffer4.from(normalize(input), "base64url"));
|
|
1296
1538
|
|
|
1297
1539
|
// ../../node_modules/jose/dist/node/esm/util/base64url.js
|
|
1298
1540
|
var base64url_exports = {};
|
|
@@ -1617,6 +1859,8 @@ function buildGeminiRequest(context) {
|
|
|
1617
1859
|
|
|
1618
1860
|
// src/stream.ts
|
|
1619
1861
|
var STREAM_ACTION = "streamGenerateContent";
|
|
1862
|
+
var FALLBACK_SESSION_KEY = "__default__";
|
|
1863
|
+
var requestSessions = new AgyRequestSessionStore("");
|
|
1620
1864
|
function mapFinishReason(reason) {
|
|
1621
1865
|
switch (reason) {
|
|
1622
1866
|
case "STOP":
|
|
@@ -1703,11 +1947,40 @@ async function* parseGeminiSse(response) {
|
|
|
1703
1947
|
reader.releaseLock();
|
|
1704
1948
|
}
|
|
1705
1949
|
}
|
|
1706
|
-
function
|
|
1707
|
-
|
|
1950
|
+
function getRequestSessionKey(context, options) {
|
|
1951
|
+
if (options?.sessionId) {
|
|
1952
|
+
return options.sessionId;
|
|
1953
|
+
}
|
|
1954
|
+
const firstTimestamp = context.messages[0]?.timestamp;
|
|
1955
|
+
return firstTimestamp !== void 0 ? `message:${firstTimestamp}` : FALLBACK_SESSION_KEY;
|
|
1956
|
+
}
|
|
1957
|
+
function finalizePiAntigravityRequest(request, wireModel, scope) {
|
|
1958
|
+
if (Array.isArray(request.tools) && request.tools.length > 0) {
|
|
1959
|
+
request.toolConfig = { functionCallingConfig: { mode: "VALIDATED" } };
|
|
1960
|
+
}
|
|
1961
|
+
const metadata = buildAgyAgentRequestMetadata(
|
|
1962
|
+
scope.session,
|
|
1963
|
+
request,
|
|
1964
|
+
wireModel,
|
|
1965
|
+
scope.timestamp
|
|
1966
|
+
);
|
|
1967
|
+
request.labels = metadata.labels;
|
|
1968
|
+
request.sessionId = metadata.sessionId;
|
|
1969
|
+
orderAgyRequestPayloadInPlace(request);
|
|
1970
|
+
return metadata.requestId;
|
|
1971
|
+
}
|
|
1972
|
+
function resolvePiAntigravityModel(model, reasoning) {
|
|
1973
|
+
const lower = model.id.toLowerCase();
|
|
1974
|
+
const supportsAgyTiers = model.reasoning && (lower.includes("gemini-3") || lower.includes("claude") && lower.includes("thinking"));
|
|
1975
|
+
if (!supportsAgyTiers || !reasoning) {
|
|
1976
|
+
return resolveModelForHeaderStyle(model.id, "antigravity");
|
|
1977
|
+
}
|
|
1978
|
+
const tier = reasoning === "minimal" ? "low" : reasoning === "xhigh" ? "high" : reasoning;
|
|
1979
|
+
const baseModel = model.id.replace(/-(minimal|low|medium|high|xhigh)$/i, "");
|
|
1980
|
+
return resolveModelForHeaderStyle(`${baseModel}-${tier}`, "antigravity");
|
|
1708
1981
|
}
|
|
1709
1982
|
async function sendAntigravityRequest(options) {
|
|
1710
|
-
const resolved =
|
|
1983
|
+
const resolved = resolvePiAntigravityModel(options.model, options.streamOptions?.reasoning);
|
|
1711
1984
|
const wireModel = resolved.actualModel;
|
|
1712
1985
|
const packedRefresh = getPackedRefresh(options.accessToken) ?? "";
|
|
1713
1986
|
const projectContext = await ensureProjectContext({
|
|
@@ -1736,9 +2009,13 @@ async function sendAntigravityRequest(options) {
|
|
|
1736
2009
|
if (Object.keys(generationConfig).length > 0) {
|
|
1737
2010
|
request.generationConfig = generationConfig;
|
|
1738
2011
|
}
|
|
2012
|
+
const requestScope = requestSessions.beginRequest(
|
|
2013
|
+
getRequestSessionKey(options.context, options.streamOptions)
|
|
2014
|
+
);
|
|
2015
|
+
const requestId = finalizePiAntigravityRequest(request, wireModel, requestScope);
|
|
1739
2016
|
const envelope = {
|
|
1740
2017
|
project: projectContext.effectiveProjectId,
|
|
1741
|
-
requestId
|
|
2018
|
+
requestId,
|
|
1742
2019
|
request,
|
|
1743
2020
|
model: wireModel,
|
|
1744
2021
|
userAgent: "antigravity",
|
|
@@ -1896,7 +2173,7 @@ async function refreshAntigravityCredentials(credentials) {
|
|
|
1896
2173
|
};
|
|
1897
2174
|
}
|
|
1898
2175
|
function cortexKitPiAntigravityAuth(pi) {
|
|
1899
|
-
const models = Object.values(getPublicModelDefinitions()).map((model) => ({
|
|
2176
|
+
const models = Object.values(getPublicModelDefinitions()).filter((model) => !model.modalities.output.includes("image")).map((model) => ({
|
|
1900
2177
|
id: model.id,
|
|
1901
2178
|
name: model.name,
|
|
1902
2179
|
reasoning: model.reasoning,
|