omnigateway 0.10.0 → 0.10.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/bin/omni.js +418 -50
- package/gateway.js +420 -52
- package/package.json +1 -1
package/bin/omni.js
CHANGED
|
@@ -23530,7 +23530,8 @@ var anthropicDescriptor = {
|
|
|
23530
23530
|
// packages/providers/src/antigravity/models.ts
|
|
23531
23531
|
var MAX_OUTPUT_TOKENS = 65536;
|
|
23532
23532
|
var PRO_MAX_OUTPUT_TOKENS = 65535;
|
|
23533
|
-
var
|
|
23533
|
+
var NO_CACHE_WRITE = { cacheWrite5m: 0, cacheWrite1h: 0 };
|
|
23534
|
+
var FREE = { input: 0, output: 0, cacheRead: 0, ...NO_CACHE_WRITE };
|
|
23534
23535
|
var FLASH_LIMITS = { contextWindow: 1048576, maxOutputTokens: MAX_OUTPUT_TOKENS };
|
|
23535
23536
|
var PRO_LIMITS = { contextWindow: 1048576, maxOutputTokens: PRO_MAX_OUTPUT_TOKENS };
|
|
23536
23537
|
var ANTIGRAVITY_MODELS = {
|
|
@@ -23540,73 +23541,73 @@ var ANTIGRAVITY_MODELS = {
|
|
|
23540
23541
|
{
|
|
23541
23542
|
id: "gemini-3.8-flash-high",
|
|
23542
23543
|
label: "Gemini 3.8 Flash (High)",
|
|
23543
|
-
pricing:
|
|
23544
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23544
23545
|
limits: FLASH_LIMITS
|
|
23545
23546
|
},
|
|
23546
23547
|
{
|
|
23547
23548
|
id: "gemini-3.8-flash-medium",
|
|
23548
23549
|
label: "Gemini 3.8 Flash (Medium)",
|
|
23549
|
-
pricing:
|
|
23550
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23550
23551
|
limits: FLASH_LIMITS
|
|
23551
23552
|
},
|
|
23552
23553
|
{
|
|
23553
23554
|
id: "gemini-3.8-flash-low",
|
|
23554
23555
|
label: "Gemini 3.8 Flash (Low)",
|
|
23555
|
-
pricing:
|
|
23556
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23556
23557
|
limits: FLASH_LIMITS
|
|
23557
23558
|
},
|
|
23558
23559
|
{
|
|
23559
23560
|
id: "gemini-3.7-flash-high",
|
|
23560
23561
|
label: "Gemini 3.7 Flash (High)",
|
|
23561
|
-
pricing:
|
|
23562
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23562
23563
|
limits: FLASH_LIMITS
|
|
23563
23564
|
},
|
|
23564
23565
|
{
|
|
23565
23566
|
id: "gemini-3.7-flash-medium",
|
|
23566
23567
|
label: "Gemini 3.7 Flash (Medium)",
|
|
23567
|
-
pricing:
|
|
23568
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23568
23569
|
limits: FLASH_LIMITS
|
|
23569
23570
|
},
|
|
23570
23571
|
{
|
|
23571
23572
|
id: "gemini-3.7-flash-low",
|
|
23572
23573
|
label: "Gemini 3.7 Flash (Low)",
|
|
23573
|
-
pricing:
|
|
23574
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23574
23575
|
limits: FLASH_LIMITS
|
|
23575
23576
|
},
|
|
23576
23577
|
{
|
|
23577
23578
|
id: "gemini-3.6-flash-high",
|
|
23578
23579
|
label: "Gemini 3.6 Flash (High)",
|
|
23579
|
-
pricing:
|
|
23580
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23580
23581
|
limits: FLASH_LIMITS
|
|
23581
23582
|
},
|
|
23582
23583
|
{
|
|
23583
23584
|
id: "gemini-3.6-flash-medium",
|
|
23584
23585
|
label: "Gemini 3.6 Flash (Medium)",
|
|
23585
|
-
pricing:
|
|
23586
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23586
23587
|
limits: FLASH_LIMITS
|
|
23587
23588
|
},
|
|
23588
23589
|
{
|
|
23589
23590
|
id: "gemini-3.6-flash-low",
|
|
23590
23591
|
label: "Gemini 3.6 Flash (Low)",
|
|
23591
|
-
pricing:
|
|
23592
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23592
23593
|
limits: FLASH_LIMITS
|
|
23593
23594
|
},
|
|
23594
23595
|
{
|
|
23595
23596
|
id: "gemini-3-flash-agent",
|
|
23596
23597
|
label: "Gemini 3.5 Flash (High)",
|
|
23597
|
-
pricing:
|
|
23598
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23598
23599
|
limits: FLASH_LIMITS
|
|
23599
23600
|
},
|
|
23600
23601
|
{
|
|
23601
23602
|
id: "gemini-3.5-flash-low",
|
|
23602
23603
|
label: "Gemini 3.5 Flash (Medium)",
|
|
23603
|
-
pricing:
|
|
23604
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23604
23605
|
limits: FLASH_LIMITS
|
|
23605
23606
|
},
|
|
23606
23607
|
{
|
|
23607
23608
|
id: "gemini-3.5-flash-extra-low",
|
|
23608
23609
|
label: "Gemini 3.5 Flash (Low)",
|
|
23609
|
-
pricing:
|
|
23610
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
23610
23611
|
limits: FLASH_LIMITS
|
|
23611
23612
|
},
|
|
23612
23613
|
{
|
|
@@ -23618,31 +23619,31 @@ var ANTIGRAVITY_MODELS = {
|
|
|
23618
23619
|
{
|
|
23619
23620
|
id: "gemini-3.5-flash-lite",
|
|
23620
23621
|
label: "Gemini 3.5 Flash Lite",
|
|
23621
|
-
pricing:
|
|
23622
|
+
pricing: { input: 0.3, output: 2.5, cacheRead: 0.03, ...NO_CACHE_WRITE },
|
|
23622
23623
|
limits: PRO_LIMITS
|
|
23623
23624
|
},
|
|
23624
23625
|
{
|
|
23625
|
-
id: "gemini-
|
|
23626
|
+
id: "gemini-pro-agent",
|
|
23626
23627
|
label: "Gemini 3.1 Pro (High)",
|
|
23627
|
-
pricing:
|
|
23628
|
+
pricing: { input: 2, output: 12, cacheRead: 0.2, ...NO_CACHE_WRITE },
|
|
23628
23629
|
limits: PRO_LIMITS
|
|
23629
23630
|
},
|
|
23630
23631
|
{
|
|
23631
23632
|
id: "gemini-3.1-pro-low",
|
|
23632
23633
|
label: "Gemini 3.1 Pro (Low)",
|
|
23633
|
-
pricing:
|
|
23634
|
+
pricing: { input: 2, output: 12, cacheRead: 0.2, ...NO_CACHE_WRITE },
|
|
23634
23635
|
limits: PRO_LIMITS
|
|
23635
23636
|
},
|
|
23636
23637
|
{
|
|
23637
23638
|
id: "gemini-3.1-flash-lite",
|
|
23638
23639
|
label: "Gemini 3.1 Flash Lite",
|
|
23639
|
-
pricing:
|
|
23640
|
+
pricing: { input: 0.25, output: 1.5, cacheRead: 0.025, ...NO_CACHE_WRITE },
|
|
23640
23641
|
limits: PRO_LIMITS
|
|
23641
23642
|
},
|
|
23642
23643
|
{
|
|
23643
23644
|
id: "gemini-2.5-pro",
|
|
23644
23645
|
label: "Gemini 2.5 Pro",
|
|
23645
|
-
pricing:
|
|
23646
|
+
pricing: { input: 1.25, output: 10, cacheRead: 0.125, ...NO_CACHE_WRITE },
|
|
23646
23647
|
limits: PRO_LIMITS
|
|
23647
23648
|
}
|
|
23648
23649
|
]
|
|
@@ -23655,13 +23656,13 @@ var antigravityDescriptor = {
|
|
|
23655
23656
|
writeOverInput: { fiveMinute: 0, oneHour: 0 },
|
|
23656
23657
|
catalog: ANTIGRAVITY_MODELS,
|
|
23657
23658
|
modelPrefixes: ["gemini-"],
|
|
23658
|
-
callback: { uri: "
|
|
23659
|
+
callback: { uri: "https://antigravity.google/oauth-callback", label: "Antigravity" },
|
|
23659
23660
|
presentation: {
|
|
23660
23661
|
label: "Antigravity",
|
|
23661
23662
|
order: 6,
|
|
23662
23663
|
tone: "violet",
|
|
23663
23664
|
colour: { light: "oklch(0.52 0.14 277)", dark: "oklch(0.74 0.14 277)" },
|
|
23664
|
-
pasteHint: "Approve in
|
|
23665
|
+
pasteHint: "Approve in any browser, then paste the whole URL it lands on. A code shown on its own works too."
|
|
23665
23666
|
}
|
|
23666
23667
|
};
|
|
23667
23668
|
|
|
@@ -26205,6 +26206,84 @@ var anthropicOAuthFlow = {
|
|
|
26205
26206
|
// packages/providers/src/antigravity/codec.ts
|
|
26206
26207
|
import { createHash as createHash2 } from "crypto";
|
|
26207
26208
|
|
|
26209
|
+
// packages/providers/src/antigravity/cloak.ts
|
|
26210
|
+
var FUNCTION_NAME = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
|
|
26211
|
+
var MAX_NAME = 128;
|
|
26212
|
+
var SUFFIX_LENGTH2 = 6;
|
|
26213
|
+
function aliasFor2(name) {
|
|
26214
|
+
let base = name.replace(/[^A-Za-z0-9_.-]+/g, "_");
|
|
26215
|
+
if (!/^[A-Za-z_]/.test(base))
|
|
26216
|
+
base = `_${base}`;
|
|
26217
|
+
if (base === "_")
|
|
26218
|
+
return { base: "_tool", forced: true };
|
|
26219
|
+
if (base.length > MAX_NAME) {
|
|
26220
|
+
return { base: base.slice(0, MAX_NAME - SUFFIX_LENGTH2), forced: true };
|
|
26221
|
+
}
|
|
26222
|
+
return { base, forced: false };
|
|
26223
|
+
}
|
|
26224
|
+
function clientToolNames2(request2) {
|
|
26225
|
+
const renamable = new Set;
|
|
26226
|
+
const reserved = new Set;
|
|
26227
|
+
const add = (name) => {
|
|
26228
|
+
(FUNCTION_NAME.test(name) ? reserved : renamable).add(name);
|
|
26229
|
+
};
|
|
26230
|
+
const called = new Set;
|
|
26231
|
+
for (const message of request2.messages) {
|
|
26232
|
+
for (const block of message.content) {
|
|
26233
|
+
if (block.type === "toolUse")
|
|
26234
|
+
called.add(block.id);
|
|
26235
|
+
}
|
|
26236
|
+
}
|
|
26237
|
+
for (const tool of request2.tools ?? []) {
|
|
26238
|
+
if (tool.kind === "portable")
|
|
26239
|
+
add(tool.name);
|
|
26240
|
+
}
|
|
26241
|
+
for (const message of request2.messages) {
|
|
26242
|
+
for (const block of message.content) {
|
|
26243
|
+
if (block.type === "toolUse")
|
|
26244
|
+
add(block.name);
|
|
26245
|
+
if (block.type === "toolResult" && !called.has(block.toolUseId))
|
|
26246
|
+
add(block.toolUseId);
|
|
26247
|
+
}
|
|
26248
|
+
}
|
|
26249
|
+
if (request2.toolChoice?.type === "tool")
|
|
26250
|
+
add(request2.toolChoice.name);
|
|
26251
|
+
return { renamable: [...renamable], reserved: [...reserved] };
|
|
26252
|
+
}
|
|
26253
|
+
function suffixFor2(name) {
|
|
26254
|
+
const digest = Bun.hash.xxHash64(Buffer.from(name, "utf8")) & 0xffffffn;
|
|
26255
|
+
return digest.toString(16).padStart(SUFFIX_LENGTH2, "0");
|
|
26256
|
+
}
|
|
26257
|
+
function buildToolCloak2(request2) {
|
|
26258
|
+
const { renamable, reserved } = clientToolNames2(request2);
|
|
26259
|
+
const claims = new Map;
|
|
26260
|
+
const claim2 = (name) => {
|
|
26261
|
+
claims.set(name, (claims.get(name) ?? 0) + 1);
|
|
26262
|
+
};
|
|
26263
|
+
for (const name of reserved)
|
|
26264
|
+
claim2(name);
|
|
26265
|
+
const bases = new Map;
|
|
26266
|
+
for (const name of renamable) {
|
|
26267
|
+
const derived = aliasFor2(name);
|
|
26268
|
+
bases.set(name, derived);
|
|
26269
|
+
claim2(derived.base);
|
|
26270
|
+
}
|
|
26271
|
+
const toWire2 = new Map;
|
|
26272
|
+
const fromWire = new Map;
|
|
26273
|
+
for (const [name, { base, forced }] of bases) {
|
|
26274
|
+
const alias = forced || (claims.get(base) ?? 0) > 1 ? base + suffixFor2(name) : base;
|
|
26275
|
+
toWire2.set(name, alias);
|
|
26276
|
+
fromWire.set(alias, name);
|
|
26277
|
+
}
|
|
26278
|
+
return toWire2.size === 0 ? null : { toWire: toWire2, fromWire };
|
|
26279
|
+
}
|
|
26280
|
+
function cloakName2(cloak, name) {
|
|
26281
|
+
return cloak?.toWire.get(name) ?? name;
|
|
26282
|
+
}
|
|
26283
|
+
function uncloakName2(cloak, name) {
|
|
26284
|
+
return cloak?.fromWire.get(name) ?? name;
|
|
26285
|
+
}
|
|
26286
|
+
|
|
26208
26287
|
// packages/providers/src/antigravity/decode.ts
|
|
26209
26288
|
var STOP_REASON2 = {
|
|
26210
26289
|
STOP: "endTurn",
|
|
@@ -26239,7 +26318,8 @@ function count(value) {
|
|
|
26239
26318
|
function usageOf(meta3) {
|
|
26240
26319
|
return usageFromPromptTotal(count(meta3?.promptTokenCount), count(meta3?.candidatesTokenCount) + count(meta3?.thoughtsTokenCount), count(meta3?.cachedContentTokenCount));
|
|
26241
26320
|
}
|
|
26242
|
-
async function* decodeAntigravityStream(messages) {
|
|
26321
|
+
async function* decodeAntigravityStream(messages, opts = {}) {
|
|
26322
|
+
const cloak = opts.cloak ?? null;
|
|
26243
26323
|
let started = false;
|
|
26244
26324
|
let terminal = false;
|
|
26245
26325
|
let nextIndex = 0;
|
|
@@ -26315,7 +26395,7 @@ async function* decodeAntigravityStream(messages) {
|
|
|
26315
26395
|
block: {
|
|
26316
26396
|
type: "toolUse",
|
|
26317
26397
|
id: typeof call.id === "string" && call.id.length > 0 ? call.id : `fc_${toolCalls}`,
|
|
26318
|
-
name: call.name
|
|
26398
|
+
name: uncloakName2(cloak, call.name)
|
|
26319
26399
|
}
|
|
26320
26400
|
};
|
|
26321
26401
|
yield {
|
|
@@ -26407,8 +26487,241 @@ function mergeSameRole(contents) {
|
|
|
26407
26487
|
}
|
|
26408
26488
|
return merged;
|
|
26409
26489
|
}
|
|
26490
|
+
function openingTurn(contents, note2) {
|
|
26491
|
+
const first = contents[0];
|
|
26492
|
+
if (first === undefined)
|
|
26493
|
+
return contents;
|
|
26494
|
+
const opensOnTool = first.role === "model" || first.parts[0] !== undefined && "functionResponse" in first.parts[0];
|
|
26495
|
+
if (!opensOnTool)
|
|
26496
|
+
return contents;
|
|
26497
|
+
note2("antigravity:opening-turn-added");
|
|
26498
|
+
return [{ role: "user", parts: [{ text: "" }] }, ...contents];
|
|
26499
|
+
}
|
|
26500
|
+
function closingTurn(contents, note2) {
|
|
26501
|
+
if (contents[contents.length - 1]?.role !== "model")
|
|
26502
|
+
return contents;
|
|
26503
|
+
note2("antigravity:closing-turn-added");
|
|
26504
|
+
return [...contents, { role: "user", parts: [{ text: " " }] }];
|
|
26505
|
+
}
|
|
26410
26506
|
var hasCacheControl = (block) => ("cacheControl" in block) && block.cacheControl !== undefined;
|
|
26411
|
-
|
|
26507
|
+
var PRUNED = "antigravity:tool-schema-pruned";
|
|
26508
|
+
var MAX_STOP_SEQUENCES = 5;
|
|
26509
|
+
var MAX_THINKING_BUDGET = 65535;
|
|
26510
|
+
function scalarValue(kind, value) {
|
|
26511
|
+
const numeric = (v, whole) => {
|
|
26512
|
+
if (typeof v === "number")
|
|
26513
|
+
return Number.isFinite(v) && (!whole || Number.isInteger(v));
|
|
26514
|
+
if (typeof v !== "string")
|
|
26515
|
+
return false;
|
|
26516
|
+
if (whole)
|
|
26517
|
+
return /^-?\d+$/.test(v);
|
|
26518
|
+
return v.trim().length > 0 && Number.isFinite(Number(v));
|
|
26519
|
+
};
|
|
26520
|
+
switch (kind) {
|
|
26521
|
+
case "free":
|
|
26522
|
+
return value;
|
|
26523
|
+
case "text":
|
|
26524
|
+
return typeof value === "string" ? value : undefined;
|
|
26525
|
+
case "texts": {
|
|
26526
|
+
if (typeof value === "string")
|
|
26527
|
+
return value;
|
|
26528
|
+
if (!Array.isArray(value))
|
|
26529
|
+
return;
|
|
26530
|
+
const members2 = value.filter((m) => typeof m === "string");
|
|
26531
|
+
return members2.length === 0 ? undefined : members2;
|
|
26532
|
+
}
|
|
26533
|
+
case "int":
|
|
26534
|
+
return numeric(value, true) ? value : undefined;
|
|
26535
|
+
case "double":
|
|
26536
|
+
return numeric(value, false) ? value : undefined;
|
|
26537
|
+
case "walked":
|
|
26538
|
+
return value;
|
|
26539
|
+
}
|
|
26540
|
+
}
|
|
26541
|
+
var SCHEMA_FIELDS = new Map([
|
|
26542
|
+
["type", "walked"],
|
|
26543
|
+
["items", "walked"],
|
|
26544
|
+
["properties", "walked"],
|
|
26545
|
+
["anyOf", "walked"],
|
|
26546
|
+
["allOf", "walked"],
|
|
26547
|
+
["additionalProperties", "walked"],
|
|
26548
|
+
["format", "text"],
|
|
26549
|
+
["title", "text"],
|
|
26550
|
+
["description", "text"],
|
|
26551
|
+
["pattern", "text"],
|
|
26552
|
+
["enum", "texts"],
|
|
26553
|
+
["required", "texts"],
|
|
26554
|
+
["propertyOrdering", "texts"],
|
|
26555
|
+
["minItems", "int"],
|
|
26556
|
+
["maxItems", "int"],
|
|
26557
|
+
["minLength", "int"],
|
|
26558
|
+
["maxLength", "int"],
|
|
26559
|
+
["minProperties", "int"],
|
|
26560
|
+
["maxProperties", "int"],
|
|
26561
|
+
["minimum", "double"],
|
|
26562
|
+
["maximum", "double"],
|
|
26563
|
+
["default", "free"],
|
|
26564
|
+
["example", "free"],
|
|
26565
|
+
["nullable", "free"]
|
|
26566
|
+
]);
|
|
26567
|
+
var SCHEMA_TYPES = new Set([
|
|
26568
|
+
"string",
|
|
26569
|
+
"number",
|
|
26570
|
+
"integer",
|
|
26571
|
+
"boolean",
|
|
26572
|
+
"array",
|
|
26573
|
+
"object",
|
|
26574
|
+
"null",
|
|
26575
|
+
"type_unspecified"
|
|
26576
|
+
]);
|
|
26577
|
+
var MAX_SCHEMA_DEPTH = 24;
|
|
26578
|
+
var isSchema = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
26579
|
+
function pruneSchema(node2, note2, depth = 0) {
|
|
26580
|
+
const out = {};
|
|
26581
|
+
const drop = () => note2(PRUNED);
|
|
26582
|
+
const sub = (v) => {
|
|
26583
|
+
if (!isSchema(v) || depth >= MAX_SCHEMA_DEPTH) {
|
|
26584
|
+
drop();
|
|
26585
|
+
return;
|
|
26586
|
+
}
|
|
26587
|
+
return pruneSchema(v, note2, depth + 1);
|
|
26588
|
+
};
|
|
26589
|
+
for (const [key, value] of Object.entries(node2)) {
|
|
26590
|
+
if (key === "const") {
|
|
26591
|
+
drop();
|
|
26592
|
+
if (typeof value === "string" && !Object.hasOwn(node2, "enum"))
|
|
26593
|
+
out.enum = [value];
|
|
26594
|
+
continue;
|
|
26595
|
+
}
|
|
26596
|
+
const kind = SCHEMA_FIELDS.get(key);
|
|
26597
|
+
if (kind === undefined) {
|
|
26598
|
+
drop();
|
|
26599
|
+
continue;
|
|
26600
|
+
}
|
|
26601
|
+
switch (key) {
|
|
26602
|
+
case "type": {
|
|
26603
|
+
if (typeof value === "string") {
|
|
26604
|
+
if (SCHEMA_TYPES.has(value.toLowerCase()))
|
|
26605
|
+
out.type = value;
|
|
26606
|
+
else
|
|
26607
|
+
drop();
|
|
26608
|
+
break;
|
|
26609
|
+
}
|
|
26610
|
+
const named = Array.isArray(value) ? value.filter((t) => typeof t === "string" && SCHEMA_TYPES.has(t.toLowerCase())) : [];
|
|
26611
|
+
const real = named.filter((t) => t.toLowerCase() !== "null");
|
|
26612
|
+
if (!Array.isArray(value) || named.length !== value.length || real.length !== 1)
|
|
26613
|
+
drop();
|
|
26614
|
+
if (real[0] !== undefined)
|
|
26615
|
+
out.type = real[0];
|
|
26616
|
+
if (named.length !== real.length)
|
|
26617
|
+
out.nullable = true;
|
|
26618
|
+
break;
|
|
26619
|
+
}
|
|
26620
|
+
case "properties": {
|
|
26621
|
+
if (!isSchema(value)) {
|
|
26622
|
+
drop();
|
|
26623
|
+
break;
|
|
26624
|
+
}
|
|
26625
|
+
const entries = [];
|
|
26626
|
+
for (const [name, member] of Object.entries(value)) {
|
|
26627
|
+
if (name.length === 0) {
|
|
26628
|
+
drop();
|
|
26629
|
+
continue;
|
|
26630
|
+
}
|
|
26631
|
+
const pruned = sub(member);
|
|
26632
|
+
if (pruned !== undefined)
|
|
26633
|
+
entries.push([name, pruned]);
|
|
26634
|
+
}
|
|
26635
|
+
out.properties = Object.fromEntries(entries);
|
|
26636
|
+
break;
|
|
26637
|
+
}
|
|
26638
|
+
case "items": {
|
|
26639
|
+
if (Array.isArray(value)) {
|
|
26640
|
+
drop();
|
|
26641
|
+
const first = sub(value[0]);
|
|
26642
|
+
if (first !== undefined)
|
|
26643
|
+
out.items = first;
|
|
26644
|
+
break;
|
|
26645
|
+
}
|
|
26646
|
+
const pruned = sub(value);
|
|
26647
|
+
if (pruned !== undefined)
|
|
26648
|
+
out.items = pruned;
|
|
26649
|
+
break;
|
|
26650
|
+
}
|
|
26651
|
+
case "anyOf":
|
|
26652
|
+
case "allOf": {
|
|
26653
|
+
if (!Array.isArray(value)) {
|
|
26654
|
+
drop();
|
|
26655
|
+
break;
|
|
26656
|
+
}
|
|
26657
|
+
const arms = [];
|
|
26658
|
+
for (const arm of value) {
|
|
26659
|
+
const pruned = sub(arm);
|
|
26660
|
+
if (pruned !== undefined)
|
|
26661
|
+
arms.push(pruned);
|
|
26662
|
+
}
|
|
26663
|
+
out[key] = arms;
|
|
26664
|
+
break;
|
|
26665
|
+
}
|
|
26666
|
+
case "additionalProperties": {
|
|
26667
|
+
if (typeof value === "boolean") {
|
|
26668
|
+
out[key] = value;
|
|
26669
|
+
break;
|
|
26670
|
+
}
|
|
26671
|
+
const pruned = sub(value);
|
|
26672
|
+
if (pruned !== undefined)
|
|
26673
|
+
out[key] = pruned;
|
|
26674
|
+
break;
|
|
26675
|
+
}
|
|
26676
|
+
default: {
|
|
26677
|
+
const kept = scalarValue(kind, value);
|
|
26678
|
+
if (kept === undefined)
|
|
26679
|
+
drop();
|
|
26680
|
+
else {
|
|
26681
|
+
if (Array.isArray(kept) && Array.isArray(value) && kept.length !== value.length)
|
|
26682
|
+
drop();
|
|
26683
|
+
out[key] = kept;
|
|
26684
|
+
}
|
|
26685
|
+
}
|
|
26686
|
+
}
|
|
26687
|
+
}
|
|
26688
|
+
const declared = typeof out.type === "string" ? out.type.toLowerCase() : undefined;
|
|
26689
|
+
const agree = (want, fields2) => {
|
|
26690
|
+
if (!fields2.some((f) => out[f] !== undefined))
|
|
26691
|
+
return;
|
|
26692
|
+
if (declared === want)
|
|
26693
|
+
return;
|
|
26694
|
+
if (declared === undefined) {
|
|
26695
|
+
out.type = want;
|
|
26696
|
+
return;
|
|
26697
|
+
}
|
|
26698
|
+
drop();
|
|
26699
|
+
for (const f of fields2)
|
|
26700
|
+
delete out[f];
|
|
26701
|
+
};
|
|
26702
|
+
agree("object", ["properties", "required", "propertyOrdering"]);
|
|
26703
|
+
agree("array", ["items"]);
|
|
26704
|
+
for (const key of ["required", "propertyOrdering"]) {
|
|
26705
|
+
const names = out[key];
|
|
26706
|
+
if (!Array.isArray(names))
|
|
26707
|
+
continue;
|
|
26708
|
+
const known = isSchema(out.properties) ? out.properties : {};
|
|
26709
|
+
const kept = names.filter((n) => typeof n === "string" && Object.hasOwn(known, n));
|
|
26710
|
+
if (kept.length === names.length)
|
|
26711
|
+
continue;
|
|
26712
|
+
drop();
|
|
26713
|
+
if (kept.length === 0)
|
|
26714
|
+
delete out[key];
|
|
26715
|
+
else
|
|
26716
|
+
out[key] = kept;
|
|
26717
|
+
}
|
|
26718
|
+
if (out.type === "array" && out.items === undefined) {
|
|
26719
|
+
drop();
|
|
26720
|
+
delete out.type;
|
|
26721
|
+
}
|
|
26722
|
+
return out;
|
|
26723
|
+
}
|
|
26724
|
+
function encodeToolChoice2(choice, cloak) {
|
|
26412
26725
|
switch (choice.type) {
|
|
26413
26726
|
case "auto":
|
|
26414
26727
|
return { functionCallingConfig: { mode: "AUTO" } };
|
|
@@ -26417,10 +26730,16 @@ function encodeToolChoice2(choice) {
|
|
|
26417
26730
|
case "none":
|
|
26418
26731
|
return { functionCallingConfig: { mode: "NONE" } };
|
|
26419
26732
|
case "tool":
|
|
26420
|
-
return {
|
|
26733
|
+
return {
|
|
26734
|
+
functionCallingConfig: {
|
|
26735
|
+
mode: "ANY",
|
|
26736
|
+
allowedFunctionNames: [cloakName2(cloak, choice.name)]
|
|
26737
|
+
}
|
|
26738
|
+
};
|
|
26421
26739
|
}
|
|
26422
26740
|
}
|
|
26423
26741
|
function toAntigravityWire(req, model, identity) {
|
|
26742
|
+
const cloak = identity.cloak ?? null;
|
|
26424
26743
|
const degradations = [];
|
|
26425
26744
|
const note2 = (d) => {
|
|
26426
26745
|
if (!degradations.includes(d))
|
|
@@ -26449,7 +26768,7 @@ function toAntigravityWire(req, model, identity) {
|
|
|
26449
26768
|
case "toolUse":
|
|
26450
26769
|
parts.push({
|
|
26451
26770
|
thoughtSignature: SIGNATURE_BYPASS,
|
|
26452
|
-
functionCall: { name: block.name, args: block.input }
|
|
26771
|
+
functionCall: { name: cloakName2(cloak, block.name), args: block.input }
|
|
26453
26772
|
});
|
|
26454
26773
|
break;
|
|
26455
26774
|
case "toolResult": {
|
|
@@ -26460,7 +26779,7 @@ function toAntigravityWire(req, model, identity) {
|
|
|
26460
26779
|
note2("antigravity:tool-result-error-flag-dropped");
|
|
26461
26780
|
parts.push({
|
|
26462
26781
|
functionResponse: {
|
|
26463
|
-
name: name ?? block.toolUseId,
|
|
26782
|
+
name: cloakName2(cloak, name ?? block.toolUseId),
|
|
26464
26783
|
response: { output: block.content }
|
|
26465
26784
|
}
|
|
26466
26785
|
});
|
|
@@ -26475,28 +26794,47 @@ function toAntigravityWire(req, model, identity) {
|
|
|
26475
26794
|
if (parts.length > 0)
|
|
26476
26795
|
contents.push({ role, parts });
|
|
26477
26796
|
}
|
|
26478
|
-
const request2 = {
|
|
26797
|
+
const request2 = {
|
|
26798
|
+
contents: closingTurn(openingTurn(mergeSameRole(contents), note2), note2)
|
|
26799
|
+
};
|
|
26479
26800
|
const system = systemText(req.system, "antigravity", note2);
|
|
26480
26801
|
if (system !== undefined && system.length > 0) {
|
|
26481
26802
|
request2.systemInstruction = { parts: [{ text: system }] };
|
|
26482
26803
|
}
|
|
26483
26804
|
const generationConfig = {};
|
|
26484
|
-
if (req.maxTokens !== undefined)
|
|
26485
|
-
|
|
26486
|
-
|
|
26487
|
-
|
|
26488
|
-
|
|
26489
|
-
|
|
26805
|
+
if (req.maxTokens !== undefined) {
|
|
26806
|
+
if (req.maxTokens > 0)
|
|
26807
|
+
generationConfig.maxOutputTokens = req.maxTokens;
|
|
26808
|
+
else
|
|
26809
|
+
note2("antigravity:max-tokens-dropped");
|
|
26810
|
+
}
|
|
26811
|
+
if (req.temperature !== undefined) {
|
|
26812
|
+
const clamped = Math.min(Math.max(req.temperature, 0), 2);
|
|
26813
|
+
if (clamped !== req.temperature)
|
|
26814
|
+
note2("antigravity:temperature-clamped");
|
|
26815
|
+
generationConfig.temperature = clamped;
|
|
26816
|
+
}
|
|
26817
|
+
if (req.stopSequences !== undefined) {
|
|
26818
|
+
generationConfig.stopSequences = req.stopSequences.slice(0, MAX_STOP_SEQUENCES);
|
|
26819
|
+
if (req.stopSequences.length > MAX_STOP_SEQUENCES)
|
|
26820
|
+
note2("antigravity:stop-sequences-dropped");
|
|
26821
|
+
}
|
|
26490
26822
|
if (req.reasoning !== undefined) {
|
|
26491
26823
|
switch (req.reasoning.mode) {
|
|
26492
26824
|
case "off":
|
|
26493
26825
|
generationConfig.thinkingConfig = { thinkingBudget: 0, includeThoughts: false };
|
|
26494
26826
|
break;
|
|
26495
26827
|
case "budget":
|
|
26496
|
-
|
|
26497
|
-
|
|
26498
|
-
|
|
26499
|
-
|
|
26828
|
+
{
|
|
26829
|
+
const asked = req.reasoning.budgetTokens;
|
|
26830
|
+
const budget2 = Math.min(Math.max(asked, -1), MAX_THINKING_BUDGET);
|
|
26831
|
+
if (budget2 !== asked)
|
|
26832
|
+
note2("antigravity:thinking-budget-clamped");
|
|
26833
|
+
generationConfig.thinkingConfig = {
|
|
26834
|
+
thinkingBudget: budget2,
|
|
26835
|
+
includeThoughts: budget2 !== 0
|
|
26836
|
+
};
|
|
26837
|
+
}
|
|
26500
26838
|
break;
|
|
26501
26839
|
case "adaptive":
|
|
26502
26840
|
generationConfig.thinkingConfig = {
|
|
@@ -26525,20 +26863,33 @@ function toAntigravityWire(req, model, identity) {
|
|
|
26525
26863
|
const portable = req.tools.filter((t) => t.kind === "portable");
|
|
26526
26864
|
if (portable.length !== req.tools.length)
|
|
26527
26865
|
note2("antigravity:provider-tool-dropped");
|
|
26528
|
-
|
|
26866
|
+
const seen = new Set;
|
|
26867
|
+
const named = [];
|
|
26868
|
+
for (const tool of portable) {
|
|
26869
|
+
const name = cloakName2(cloak, tool.name);
|
|
26870
|
+
if (seen.has(name)) {
|
|
26871
|
+
note2("antigravity:duplicate-tool-dropped");
|
|
26872
|
+
continue;
|
|
26873
|
+
}
|
|
26874
|
+
seen.add(name);
|
|
26875
|
+
named.push({ name, description: tool.description, inputSchema: tool.inputSchema });
|
|
26876
|
+
}
|
|
26877
|
+
if (cloak !== null && cloak.toWire.size > 0)
|
|
26878
|
+
note2("antigravity:tool-name-renamed");
|
|
26879
|
+
if (named.length > 0) {
|
|
26529
26880
|
request2.tools = [
|
|
26530
26881
|
{
|
|
26531
|
-
functionDeclarations:
|
|
26882
|
+
functionDeclarations: named.map((t) => ({
|
|
26532
26883
|
name: t.name,
|
|
26533
26884
|
description: t.description,
|
|
26534
|
-
parameters: t.inputSchema
|
|
26885
|
+
parameters: pruneSchema(t.inputSchema, note2)
|
|
26535
26886
|
}))
|
|
26536
26887
|
}
|
|
26537
26888
|
];
|
|
26538
26889
|
}
|
|
26539
26890
|
}
|
|
26540
26891
|
if (req.toolChoice !== undefined)
|
|
26541
|
-
request2.toolConfig = encodeToolChoice2(req.toolChoice);
|
|
26892
|
+
request2.toolConfig = encodeToolChoice2(req.toolChoice, cloak);
|
|
26542
26893
|
Object.assign(request2, req.vendor?.antigravity ?? {});
|
|
26543
26894
|
return {
|
|
26544
26895
|
body: {
|
|
@@ -26575,6 +26926,15 @@ function projectOf(input2) {
|
|
|
26575
26926
|
}
|
|
26576
26927
|
return project;
|
|
26577
26928
|
}
|
|
26929
|
+
function cloakOf2(state) {
|
|
26930
|
+
if (state === null || typeof state !== "object")
|
|
26931
|
+
return null;
|
|
26932
|
+
const cloak = state.cloak;
|
|
26933
|
+
if (cloak === null || cloak === undefined || typeof cloak !== "object")
|
|
26934
|
+
return null;
|
|
26935
|
+
const { toWire: toWire2, fromWire } = cloak;
|
|
26936
|
+
return toWire2 instanceof Map && fromWire instanceof Map ? cloak : null;
|
|
26937
|
+
}
|
|
26578
26938
|
var antigravityCodec = {
|
|
26579
26939
|
buildRequest(input2) {
|
|
26580
26940
|
const accessToken = input2.credentials.accessToken;
|
|
@@ -26583,9 +26943,11 @@ var antigravityCodec = {
|
|
|
26583
26943
|
}
|
|
26584
26944
|
const project = projectOf(input2);
|
|
26585
26945
|
const requestId = input2.requestId !== undefined && input2.requestId.length > 0 ? input2.requestId : derivedRequestId(`${input2.model}:${project}`);
|
|
26946
|
+
const cloak = buildToolCloak2(input2.request);
|
|
26586
26947
|
const { body, degradations } = toAntigravityWire(input2.request, input2.model, {
|
|
26587
26948
|
project,
|
|
26588
|
-
requestId
|
|
26949
|
+
requestId,
|
|
26950
|
+
cloak
|
|
26589
26951
|
});
|
|
26590
26952
|
const protocol = [["Authorization", `Bearer ${accessToken}`]];
|
|
26591
26953
|
const headers = orderHeaders(mergeHeaders(antigravityProfile.headers, protocol), antigravityProfile.order);
|
|
@@ -26596,11 +26958,13 @@ var antigravityCodec = {
|
|
|
26596
26958
|
headers,
|
|
26597
26959
|
body: JSON.stringify(body)
|
|
26598
26960
|
},
|
|
26599
|
-
|
|
26961
|
+
decodeState: { cloak },
|
|
26962
|
+
degradations,
|
|
26963
|
+
...cloak === null ? {} : { cloakedTools: cloak.toWire.size }
|
|
26600
26964
|
};
|
|
26601
26965
|
},
|
|
26602
|
-
decode({ body }) {
|
|
26603
|
-
return decodeAntigravityStream(parseSse(body));
|
|
26966
|
+
decode({ body, decodeState }) {
|
|
26967
|
+
return decodeAntigravityStream(parseSse(body), { cloak: cloakOf2(decodeState) });
|
|
26604
26968
|
}
|
|
26605
26969
|
};
|
|
26606
26970
|
|
|
@@ -26890,8 +27254,9 @@ function parseAntigravityQuota(value, now) {
|
|
|
26890
27254
|
var antigravityOAuthFlow = {
|
|
26891
27255
|
kind: "pkce",
|
|
26892
27256
|
supportsManualPaste: true,
|
|
26893
|
-
async* start({ redirectUri, randomState }) {
|
|
27257
|
+
async* start({ redirectUri, randomState, pkce }) {
|
|
26894
27258
|
const state = randomState();
|
|
27259
|
+
const { verifier, challenge } = pkce();
|
|
26895
27260
|
const url2 = new URL(AUTHORIZE_URL2);
|
|
26896
27261
|
url2.searchParams.set("client_id", CLIENT_ID2);
|
|
26897
27262
|
url2.searchParams.set("response_type", "code");
|
|
@@ -26900,9 +27265,11 @@ var antigravityOAuthFlow = {
|
|
|
26900
27265
|
url2.searchParams.set("state", state);
|
|
26901
27266
|
url2.searchParams.set("access_type", "offline");
|
|
26902
27267
|
url2.searchParams.set("prompt", "consent");
|
|
27268
|
+
url2.searchParams.set("code_challenge", challenge);
|
|
27269
|
+
url2.searchParams.set("code_challenge_method", "S256");
|
|
26903
27270
|
return {
|
|
26904
27271
|
authorizeUrl: url2.toString(),
|
|
26905
|
-
pending: { verifier
|
|
27272
|
+
pending: { verifier, challenge, state, redirectUri }
|
|
26906
27273
|
};
|
|
26907
27274
|
},
|
|
26908
27275
|
async* exchange({ code, pending, fail, now }) {
|
|
@@ -26915,7 +27282,8 @@ var antigravityOAuthFlow = {
|
|
|
26915
27282
|
client_id: CLIENT_ID2,
|
|
26916
27283
|
client_secret: CLIENT_SECRET,
|
|
26917
27284
|
code: (rawCode ?? "").trim(),
|
|
26918
|
-
redirect_uri: pending.redirectUri
|
|
27285
|
+
redirect_uri: pending.redirectUri,
|
|
27286
|
+
code_verifier: pending.verifier
|
|
26919
27287
|
}, fail);
|
|
26920
27288
|
const email3 = yield* readEmail(token.accessToken);
|
|
26921
27289
|
const { projectId, tier } = yield* bootstrapProject(token.accessToken);
|
|
@@ -35375,7 +35743,7 @@ function createServiceDeps(input2) {
|
|
|
35375
35743
|
}
|
|
35376
35744
|
|
|
35377
35745
|
// apps/cli/src/version.ts
|
|
35378
|
-
var VERSION = "0.10.
|
|
35746
|
+
var VERSION = "0.10.2";
|
|
35379
35747
|
|
|
35380
35748
|
// apps/cli/src/commands/service.ts
|
|
35381
35749
|
function gatewayArgv(root) {
|