omnigateway 0.10.0 → 0.10.1
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 +409 -45
- package/gateway.js +411 -47
- 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
|
]
|
|
@@ -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
|
|
|
@@ -35375,7 +35739,7 @@ function createServiceDeps(input2) {
|
|
|
35375
35739
|
}
|
|
35376
35740
|
|
|
35377
35741
|
// apps/cli/src/version.ts
|
|
35378
|
-
var VERSION = "0.10.
|
|
35742
|
+
var VERSION = "0.10.1";
|
|
35379
35743
|
|
|
35380
35744
|
// apps/cli/src/commands/service.ts
|
|
35381
35745
|
function gatewayArgv(root) {
|
package/gateway.js
CHANGED
|
@@ -28973,7 +28973,8 @@ var anthropicDescriptor = {
|
|
|
28973
28973
|
// packages/providers/src/antigravity/models.ts
|
|
28974
28974
|
var MAX_OUTPUT_TOKENS = 65536;
|
|
28975
28975
|
var PRO_MAX_OUTPUT_TOKENS = 65535;
|
|
28976
|
-
var
|
|
28976
|
+
var NO_CACHE_WRITE = { cacheWrite5m: 0, cacheWrite1h: 0 };
|
|
28977
|
+
var FREE = { input: 0, output: 0, cacheRead: 0, ...NO_CACHE_WRITE };
|
|
28977
28978
|
var FLASH_LIMITS = { contextWindow: 1048576, maxOutputTokens: MAX_OUTPUT_TOKENS };
|
|
28978
28979
|
var PRO_LIMITS = { contextWindow: 1048576, maxOutputTokens: PRO_MAX_OUTPUT_TOKENS };
|
|
28979
28980
|
var ANTIGRAVITY_MODELS = {
|
|
@@ -28983,73 +28984,73 @@ var ANTIGRAVITY_MODELS = {
|
|
|
28983
28984
|
{
|
|
28984
28985
|
id: "gemini-3.8-flash-high",
|
|
28985
28986
|
label: "Gemini 3.8 Flash (High)",
|
|
28986
|
-
pricing:
|
|
28987
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
28987
28988
|
limits: FLASH_LIMITS
|
|
28988
28989
|
},
|
|
28989
28990
|
{
|
|
28990
28991
|
id: "gemini-3.8-flash-medium",
|
|
28991
28992
|
label: "Gemini 3.8 Flash (Medium)",
|
|
28992
|
-
pricing:
|
|
28993
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
28993
28994
|
limits: FLASH_LIMITS
|
|
28994
28995
|
},
|
|
28995
28996
|
{
|
|
28996
28997
|
id: "gemini-3.8-flash-low",
|
|
28997
28998
|
label: "Gemini 3.8 Flash (Low)",
|
|
28998
|
-
pricing:
|
|
28999
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
28999
29000
|
limits: FLASH_LIMITS
|
|
29000
29001
|
},
|
|
29001
29002
|
{
|
|
29002
29003
|
id: "gemini-3.7-flash-high",
|
|
29003
29004
|
label: "Gemini 3.7 Flash (High)",
|
|
29004
|
-
pricing:
|
|
29005
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29005
29006
|
limits: FLASH_LIMITS
|
|
29006
29007
|
},
|
|
29007
29008
|
{
|
|
29008
29009
|
id: "gemini-3.7-flash-medium",
|
|
29009
29010
|
label: "Gemini 3.7 Flash (Medium)",
|
|
29010
|
-
pricing:
|
|
29011
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29011
29012
|
limits: FLASH_LIMITS
|
|
29012
29013
|
},
|
|
29013
29014
|
{
|
|
29014
29015
|
id: "gemini-3.7-flash-low",
|
|
29015
29016
|
label: "Gemini 3.7 Flash (Low)",
|
|
29016
|
-
pricing:
|
|
29017
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29017
29018
|
limits: FLASH_LIMITS
|
|
29018
29019
|
},
|
|
29019
29020
|
{
|
|
29020
29021
|
id: "gemini-3.6-flash-high",
|
|
29021
29022
|
label: "Gemini 3.6 Flash (High)",
|
|
29022
|
-
pricing:
|
|
29023
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29023
29024
|
limits: FLASH_LIMITS
|
|
29024
29025
|
},
|
|
29025
29026
|
{
|
|
29026
29027
|
id: "gemini-3.6-flash-medium",
|
|
29027
29028
|
label: "Gemini 3.6 Flash (Medium)",
|
|
29028
|
-
pricing:
|
|
29029
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29029
29030
|
limits: FLASH_LIMITS
|
|
29030
29031
|
},
|
|
29031
29032
|
{
|
|
29032
29033
|
id: "gemini-3.6-flash-low",
|
|
29033
29034
|
label: "Gemini 3.6 Flash (Low)",
|
|
29034
|
-
pricing:
|
|
29035
|
+
pricing: { input: 1.5, output: 7.5, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29035
29036
|
limits: FLASH_LIMITS
|
|
29036
29037
|
},
|
|
29037
29038
|
{
|
|
29038
29039
|
id: "gemini-3-flash-agent",
|
|
29039
29040
|
label: "Gemini 3.5 Flash (High)",
|
|
29040
|
-
pricing:
|
|
29041
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29041
29042
|
limits: FLASH_LIMITS
|
|
29042
29043
|
},
|
|
29043
29044
|
{
|
|
29044
29045
|
id: "gemini-3.5-flash-low",
|
|
29045
29046
|
label: "Gemini 3.5 Flash (Medium)",
|
|
29046
|
-
pricing:
|
|
29047
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29047
29048
|
limits: FLASH_LIMITS
|
|
29048
29049
|
},
|
|
29049
29050
|
{
|
|
29050
29051
|
id: "gemini-3.5-flash-extra-low",
|
|
29051
29052
|
label: "Gemini 3.5 Flash (Low)",
|
|
29052
|
-
pricing:
|
|
29053
|
+
pricing: { input: 1.5, output: 9, cacheRead: 0.15, ...NO_CACHE_WRITE },
|
|
29053
29054
|
limits: FLASH_LIMITS
|
|
29054
29055
|
},
|
|
29055
29056
|
{
|
|
@@ -29061,31 +29062,31 @@ var ANTIGRAVITY_MODELS = {
|
|
|
29061
29062
|
{
|
|
29062
29063
|
id: "gemini-3.5-flash-lite",
|
|
29063
29064
|
label: "Gemini 3.5 Flash Lite",
|
|
29064
|
-
pricing:
|
|
29065
|
+
pricing: { input: 0.3, output: 2.5, cacheRead: 0.03, ...NO_CACHE_WRITE },
|
|
29065
29066
|
limits: PRO_LIMITS
|
|
29066
29067
|
},
|
|
29067
29068
|
{
|
|
29068
|
-
id: "gemini-
|
|
29069
|
+
id: "gemini-pro-agent",
|
|
29069
29070
|
label: "Gemini 3.1 Pro (High)",
|
|
29070
|
-
pricing:
|
|
29071
|
+
pricing: { input: 2, output: 12, cacheRead: 0.2, ...NO_CACHE_WRITE },
|
|
29071
29072
|
limits: PRO_LIMITS
|
|
29072
29073
|
},
|
|
29073
29074
|
{
|
|
29074
29075
|
id: "gemini-3.1-pro-low",
|
|
29075
29076
|
label: "Gemini 3.1 Pro (Low)",
|
|
29076
|
-
pricing:
|
|
29077
|
+
pricing: { input: 2, output: 12, cacheRead: 0.2, ...NO_CACHE_WRITE },
|
|
29077
29078
|
limits: PRO_LIMITS
|
|
29078
29079
|
},
|
|
29079
29080
|
{
|
|
29080
29081
|
id: "gemini-3.1-flash-lite",
|
|
29081
29082
|
label: "Gemini 3.1 Flash Lite",
|
|
29082
|
-
pricing:
|
|
29083
|
+
pricing: { input: 0.25, output: 1.5, cacheRead: 0.025, ...NO_CACHE_WRITE },
|
|
29083
29084
|
limits: PRO_LIMITS
|
|
29084
29085
|
},
|
|
29085
29086
|
{
|
|
29086
29087
|
id: "gemini-2.5-pro",
|
|
29087
29088
|
label: "Gemini 2.5 Pro",
|
|
29088
|
-
pricing:
|
|
29089
|
+
pricing: { input: 1.25, output: 10, cacheRead: 0.125, ...NO_CACHE_WRITE },
|
|
29089
29090
|
limits: PRO_LIMITS
|
|
29090
29091
|
}
|
|
29091
29092
|
]
|
|
@@ -31772,6 +31773,84 @@ var anthropicOAuthFlow = {
|
|
|
31772
31773
|
// packages/providers/src/antigravity/codec.ts
|
|
31773
31774
|
import { createHash as createHash2 } from "crypto";
|
|
31774
31775
|
|
|
31776
|
+
// packages/providers/src/antigravity/cloak.ts
|
|
31777
|
+
var FUNCTION_NAME = /^[A-Za-z_][A-Za-z0-9_.-]{0,127}$/;
|
|
31778
|
+
var MAX_NAME = 128;
|
|
31779
|
+
var SUFFIX_LENGTH2 = 6;
|
|
31780
|
+
function aliasFor2(name) {
|
|
31781
|
+
let base = name.replace(/[^A-Za-z0-9_.-]+/g, "_");
|
|
31782
|
+
if (!/^[A-Za-z_]/.test(base))
|
|
31783
|
+
base = `_${base}`;
|
|
31784
|
+
if (base === "_")
|
|
31785
|
+
return { base: "_tool", forced: true };
|
|
31786
|
+
if (base.length > MAX_NAME) {
|
|
31787
|
+
return { base: base.slice(0, MAX_NAME - SUFFIX_LENGTH2), forced: true };
|
|
31788
|
+
}
|
|
31789
|
+
return { base, forced: false };
|
|
31790
|
+
}
|
|
31791
|
+
function clientToolNames2(request2) {
|
|
31792
|
+
const renamable = new Set;
|
|
31793
|
+
const reserved = new Set;
|
|
31794
|
+
const add = (name) => {
|
|
31795
|
+
(FUNCTION_NAME.test(name) ? reserved : renamable).add(name);
|
|
31796
|
+
};
|
|
31797
|
+
const called = new Set;
|
|
31798
|
+
for (const message of request2.messages) {
|
|
31799
|
+
for (const block of message.content) {
|
|
31800
|
+
if (block.type === "toolUse")
|
|
31801
|
+
called.add(block.id);
|
|
31802
|
+
}
|
|
31803
|
+
}
|
|
31804
|
+
for (const tool of request2.tools ?? []) {
|
|
31805
|
+
if (tool.kind === "portable")
|
|
31806
|
+
add(tool.name);
|
|
31807
|
+
}
|
|
31808
|
+
for (const message of request2.messages) {
|
|
31809
|
+
for (const block of message.content) {
|
|
31810
|
+
if (block.type === "toolUse")
|
|
31811
|
+
add(block.name);
|
|
31812
|
+
if (block.type === "toolResult" && !called.has(block.toolUseId))
|
|
31813
|
+
add(block.toolUseId);
|
|
31814
|
+
}
|
|
31815
|
+
}
|
|
31816
|
+
if (request2.toolChoice?.type === "tool")
|
|
31817
|
+
add(request2.toolChoice.name);
|
|
31818
|
+
return { renamable: [...renamable], reserved: [...reserved] };
|
|
31819
|
+
}
|
|
31820
|
+
function suffixFor2(name) {
|
|
31821
|
+
const digest = Bun.hash.xxHash64(Buffer.from(name, "utf8")) & 0xffffffn;
|
|
31822
|
+
return digest.toString(16).padStart(SUFFIX_LENGTH2, "0");
|
|
31823
|
+
}
|
|
31824
|
+
function buildToolCloak2(request2) {
|
|
31825
|
+
const { renamable, reserved } = clientToolNames2(request2);
|
|
31826
|
+
const claims = new Map;
|
|
31827
|
+
const claim2 = (name) => {
|
|
31828
|
+
claims.set(name, (claims.get(name) ?? 0) + 1);
|
|
31829
|
+
};
|
|
31830
|
+
for (const name of reserved)
|
|
31831
|
+
claim2(name);
|
|
31832
|
+
const bases = new Map;
|
|
31833
|
+
for (const name of renamable) {
|
|
31834
|
+
const derived = aliasFor2(name);
|
|
31835
|
+
bases.set(name, derived);
|
|
31836
|
+
claim2(derived.base);
|
|
31837
|
+
}
|
|
31838
|
+
const toWire2 = new Map;
|
|
31839
|
+
const fromWire = new Map;
|
|
31840
|
+
for (const [name, { base, forced }] of bases) {
|
|
31841
|
+
const alias = forced || (claims.get(base) ?? 0) > 1 ? base + suffixFor2(name) : base;
|
|
31842
|
+
toWire2.set(name, alias);
|
|
31843
|
+
fromWire.set(alias, name);
|
|
31844
|
+
}
|
|
31845
|
+
return toWire2.size === 0 ? null : { toWire: toWire2, fromWire };
|
|
31846
|
+
}
|
|
31847
|
+
function cloakName2(cloak, name) {
|
|
31848
|
+
return cloak?.toWire.get(name) ?? name;
|
|
31849
|
+
}
|
|
31850
|
+
function uncloakName2(cloak, name) {
|
|
31851
|
+
return cloak?.fromWire.get(name) ?? name;
|
|
31852
|
+
}
|
|
31853
|
+
|
|
31775
31854
|
// packages/providers/src/antigravity/decode.ts
|
|
31776
31855
|
var STOP_REASON2 = {
|
|
31777
31856
|
STOP: "endTurn",
|
|
@@ -31806,7 +31885,8 @@ function count(value) {
|
|
|
31806
31885
|
function usageOf(meta3) {
|
|
31807
31886
|
return usageFromPromptTotal(count(meta3?.promptTokenCount), count(meta3?.candidatesTokenCount) + count(meta3?.thoughtsTokenCount), count(meta3?.cachedContentTokenCount));
|
|
31808
31887
|
}
|
|
31809
|
-
async function* decodeAntigravityStream(messages) {
|
|
31888
|
+
async function* decodeAntigravityStream(messages, opts = {}) {
|
|
31889
|
+
const cloak = opts.cloak ?? null;
|
|
31810
31890
|
let started = false;
|
|
31811
31891
|
let terminal = false;
|
|
31812
31892
|
let nextIndex = 0;
|
|
@@ -31882,7 +31962,7 @@ async function* decodeAntigravityStream(messages) {
|
|
|
31882
31962
|
block: {
|
|
31883
31963
|
type: "toolUse",
|
|
31884
31964
|
id: typeof call.id === "string" && call.id.length > 0 ? call.id : `fc_${toolCalls}`,
|
|
31885
|
-
name: call.name
|
|
31965
|
+
name: uncloakName2(cloak, call.name)
|
|
31886
31966
|
}
|
|
31887
31967
|
};
|
|
31888
31968
|
yield {
|
|
@@ -31974,8 +32054,241 @@ function mergeSameRole(contents) {
|
|
|
31974
32054
|
}
|
|
31975
32055
|
return merged;
|
|
31976
32056
|
}
|
|
32057
|
+
function openingTurn(contents, note) {
|
|
32058
|
+
const first = contents[0];
|
|
32059
|
+
if (first === undefined)
|
|
32060
|
+
return contents;
|
|
32061
|
+
const opensOnTool = first.role === "model" || first.parts[0] !== undefined && "functionResponse" in first.parts[0];
|
|
32062
|
+
if (!opensOnTool)
|
|
32063
|
+
return contents;
|
|
32064
|
+
note("antigravity:opening-turn-added");
|
|
32065
|
+
return [{ role: "user", parts: [{ text: "" }] }, ...contents];
|
|
32066
|
+
}
|
|
32067
|
+
function closingTurn(contents, note) {
|
|
32068
|
+
if (contents[contents.length - 1]?.role !== "model")
|
|
32069
|
+
return contents;
|
|
32070
|
+
note("antigravity:closing-turn-added");
|
|
32071
|
+
return [...contents, { role: "user", parts: [{ text: " " }] }];
|
|
32072
|
+
}
|
|
31977
32073
|
var hasCacheControl = (block) => ("cacheControl" in block) && block.cacheControl !== undefined;
|
|
31978
|
-
|
|
32074
|
+
var PRUNED = "antigravity:tool-schema-pruned";
|
|
32075
|
+
var MAX_STOP_SEQUENCES = 5;
|
|
32076
|
+
var MAX_THINKING_BUDGET = 65535;
|
|
32077
|
+
function scalarValue(kind, value) {
|
|
32078
|
+
const numeric = (v, whole) => {
|
|
32079
|
+
if (typeof v === "number")
|
|
32080
|
+
return Number.isFinite(v) && (!whole || Number.isInteger(v));
|
|
32081
|
+
if (typeof v !== "string")
|
|
32082
|
+
return false;
|
|
32083
|
+
if (whole)
|
|
32084
|
+
return /^-?\d+$/.test(v);
|
|
32085
|
+
return v.trim().length > 0 && Number.isFinite(Number(v));
|
|
32086
|
+
};
|
|
32087
|
+
switch (kind) {
|
|
32088
|
+
case "free":
|
|
32089
|
+
return value;
|
|
32090
|
+
case "text":
|
|
32091
|
+
return typeof value === "string" ? value : undefined;
|
|
32092
|
+
case "texts": {
|
|
32093
|
+
if (typeof value === "string")
|
|
32094
|
+
return value;
|
|
32095
|
+
if (!Array.isArray(value))
|
|
32096
|
+
return;
|
|
32097
|
+
const members2 = value.filter((m) => typeof m === "string");
|
|
32098
|
+
return members2.length === 0 ? undefined : members2;
|
|
32099
|
+
}
|
|
32100
|
+
case "int":
|
|
32101
|
+
return numeric(value, true) ? value : undefined;
|
|
32102
|
+
case "double":
|
|
32103
|
+
return numeric(value, false) ? value : undefined;
|
|
32104
|
+
case "walked":
|
|
32105
|
+
return value;
|
|
32106
|
+
}
|
|
32107
|
+
}
|
|
32108
|
+
var SCHEMA_FIELDS = new Map([
|
|
32109
|
+
["type", "walked"],
|
|
32110
|
+
["items", "walked"],
|
|
32111
|
+
["properties", "walked"],
|
|
32112
|
+
["anyOf", "walked"],
|
|
32113
|
+
["allOf", "walked"],
|
|
32114
|
+
["additionalProperties", "walked"],
|
|
32115
|
+
["format", "text"],
|
|
32116
|
+
["title", "text"],
|
|
32117
|
+
["description", "text"],
|
|
32118
|
+
["pattern", "text"],
|
|
32119
|
+
["enum", "texts"],
|
|
32120
|
+
["required", "texts"],
|
|
32121
|
+
["propertyOrdering", "texts"],
|
|
32122
|
+
["minItems", "int"],
|
|
32123
|
+
["maxItems", "int"],
|
|
32124
|
+
["minLength", "int"],
|
|
32125
|
+
["maxLength", "int"],
|
|
32126
|
+
["minProperties", "int"],
|
|
32127
|
+
["maxProperties", "int"],
|
|
32128
|
+
["minimum", "double"],
|
|
32129
|
+
["maximum", "double"],
|
|
32130
|
+
["default", "free"],
|
|
32131
|
+
["example", "free"],
|
|
32132
|
+
["nullable", "free"]
|
|
32133
|
+
]);
|
|
32134
|
+
var SCHEMA_TYPES = new Set([
|
|
32135
|
+
"string",
|
|
32136
|
+
"number",
|
|
32137
|
+
"integer",
|
|
32138
|
+
"boolean",
|
|
32139
|
+
"array",
|
|
32140
|
+
"object",
|
|
32141
|
+
"null",
|
|
32142
|
+
"type_unspecified"
|
|
32143
|
+
]);
|
|
32144
|
+
var MAX_SCHEMA_DEPTH = 24;
|
|
32145
|
+
var isSchema = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
32146
|
+
function pruneSchema(node2, note, depth = 0) {
|
|
32147
|
+
const out = {};
|
|
32148
|
+
const drop = () => note(PRUNED);
|
|
32149
|
+
const sub = (v) => {
|
|
32150
|
+
if (!isSchema(v) || depth >= MAX_SCHEMA_DEPTH) {
|
|
32151
|
+
drop();
|
|
32152
|
+
return;
|
|
32153
|
+
}
|
|
32154
|
+
return pruneSchema(v, note, depth + 1);
|
|
32155
|
+
};
|
|
32156
|
+
for (const [key, value] of Object.entries(node2)) {
|
|
32157
|
+
if (key === "const") {
|
|
32158
|
+
drop();
|
|
32159
|
+
if (typeof value === "string" && !Object.hasOwn(node2, "enum"))
|
|
32160
|
+
out.enum = [value];
|
|
32161
|
+
continue;
|
|
32162
|
+
}
|
|
32163
|
+
const kind = SCHEMA_FIELDS.get(key);
|
|
32164
|
+
if (kind === undefined) {
|
|
32165
|
+
drop();
|
|
32166
|
+
continue;
|
|
32167
|
+
}
|
|
32168
|
+
switch (key) {
|
|
32169
|
+
case "type": {
|
|
32170
|
+
if (typeof value === "string") {
|
|
32171
|
+
if (SCHEMA_TYPES.has(value.toLowerCase()))
|
|
32172
|
+
out.type = value;
|
|
32173
|
+
else
|
|
32174
|
+
drop();
|
|
32175
|
+
break;
|
|
32176
|
+
}
|
|
32177
|
+
const named = Array.isArray(value) ? value.filter((t) => typeof t === "string" && SCHEMA_TYPES.has(t.toLowerCase())) : [];
|
|
32178
|
+
const real = named.filter((t) => t.toLowerCase() !== "null");
|
|
32179
|
+
if (!Array.isArray(value) || named.length !== value.length || real.length !== 1)
|
|
32180
|
+
drop();
|
|
32181
|
+
if (real[0] !== undefined)
|
|
32182
|
+
out.type = real[0];
|
|
32183
|
+
if (named.length !== real.length)
|
|
32184
|
+
out.nullable = true;
|
|
32185
|
+
break;
|
|
32186
|
+
}
|
|
32187
|
+
case "properties": {
|
|
32188
|
+
if (!isSchema(value)) {
|
|
32189
|
+
drop();
|
|
32190
|
+
break;
|
|
32191
|
+
}
|
|
32192
|
+
const entries = [];
|
|
32193
|
+
for (const [name, member] of Object.entries(value)) {
|
|
32194
|
+
if (name.length === 0) {
|
|
32195
|
+
drop();
|
|
32196
|
+
continue;
|
|
32197
|
+
}
|
|
32198
|
+
const pruned = sub(member);
|
|
32199
|
+
if (pruned !== undefined)
|
|
32200
|
+
entries.push([name, pruned]);
|
|
32201
|
+
}
|
|
32202
|
+
out.properties = Object.fromEntries(entries);
|
|
32203
|
+
break;
|
|
32204
|
+
}
|
|
32205
|
+
case "items": {
|
|
32206
|
+
if (Array.isArray(value)) {
|
|
32207
|
+
drop();
|
|
32208
|
+
const first = sub(value[0]);
|
|
32209
|
+
if (first !== undefined)
|
|
32210
|
+
out.items = first;
|
|
32211
|
+
break;
|
|
32212
|
+
}
|
|
32213
|
+
const pruned = sub(value);
|
|
32214
|
+
if (pruned !== undefined)
|
|
32215
|
+
out.items = pruned;
|
|
32216
|
+
break;
|
|
32217
|
+
}
|
|
32218
|
+
case "anyOf":
|
|
32219
|
+
case "allOf": {
|
|
32220
|
+
if (!Array.isArray(value)) {
|
|
32221
|
+
drop();
|
|
32222
|
+
break;
|
|
32223
|
+
}
|
|
32224
|
+
const arms = [];
|
|
32225
|
+
for (const arm of value) {
|
|
32226
|
+
const pruned = sub(arm);
|
|
32227
|
+
if (pruned !== undefined)
|
|
32228
|
+
arms.push(pruned);
|
|
32229
|
+
}
|
|
32230
|
+
out[key] = arms;
|
|
32231
|
+
break;
|
|
32232
|
+
}
|
|
32233
|
+
case "additionalProperties": {
|
|
32234
|
+
if (typeof value === "boolean") {
|
|
32235
|
+
out[key] = value;
|
|
32236
|
+
break;
|
|
32237
|
+
}
|
|
32238
|
+
const pruned = sub(value);
|
|
32239
|
+
if (pruned !== undefined)
|
|
32240
|
+
out[key] = pruned;
|
|
32241
|
+
break;
|
|
32242
|
+
}
|
|
32243
|
+
default: {
|
|
32244
|
+
const kept = scalarValue(kind, value);
|
|
32245
|
+
if (kept === undefined)
|
|
32246
|
+
drop();
|
|
32247
|
+
else {
|
|
32248
|
+
if (Array.isArray(kept) && Array.isArray(value) && kept.length !== value.length)
|
|
32249
|
+
drop();
|
|
32250
|
+
out[key] = kept;
|
|
32251
|
+
}
|
|
32252
|
+
}
|
|
32253
|
+
}
|
|
32254
|
+
}
|
|
32255
|
+
const declared = typeof out.type === "string" ? out.type.toLowerCase() : undefined;
|
|
32256
|
+
const agree = (want, fields) => {
|
|
32257
|
+
if (!fields.some((f) => out[f] !== undefined))
|
|
32258
|
+
return;
|
|
32259
|
+
if (declared === want)
|
|
32260
|
+
return;
|
|
32261
|
+
if (declared === undefined) {
|
|
32262
|
+
out.type = want;
|
|
32263
|
+
return;
|
|
32264
|
+
}
|
|
32265
|
+
drop();
|
|
32266
|
+
for (const f of fields)
|
|
32267
|
+
delete out[f];
|
|
32268
|
+
};
|
|
32269
|
+
agree("object", ["properties", "required", "propertyOrdering"]);
|
|
32270
|
+
agree("array", ["items"]);
|
|
32271
|
+
for (const key of ["required", "propertyOrdering"]) {
|
|
32272
|
+
const names = out[key];
|
|
32273
|
+
if (!Array.isArray(names))
|
|
32274
|
+
continue;
|
|
32275
|
+
const known = isSchema(out.properties) ? out.properties : {};
|
|
32276
|
+
const kept = names.filter((n) => typeof n === "string" && Object.hasOwn(known, n));
|
|
32277
|
+
if (kept.length === names.length)
|
|
32278
|
+
continue;
|
|
32279
|
+
drop();
|
|
32280
|
+
if (kept.length === 0)
|
|
32281
|
+
delete out[key];
|
|
32282
|
+
else
|
|
32283
|
+
out[key] = kept;
|
|
32284
|
+
}
|
|
32285
|
+
if (out.type === "array" && out.items === undefined) {
|
|
32286
|
+
drop();
|
|
32287
|
+
delete out.type;
|
|
32288
|
+
}
|
|
32289
|
+
return out;
|
|
32290
|
+
}
|
|
32291
|
+
function encodeToolChoice2(choice, cloak) {
|
|
31979
32292
|
switch (choice.type) {
|
|
31980
32293
|
case "auto":
|
|
31981
32294
|
return { functionCallingConfig: { mode: "AUTO" } };
|
|
@@ -31984,10 +32297,16 @@ function encodeToolChoice2(choice) {
|
|
|
31984
32297
|
case "none":
|
|
31985
32298
|
return { functionCallingConfig: { mode: "NONE" } };
|
|
31986
32299
|
case "tool":
|
|
31987
|
-
return {
|
|
32300
|
+
return {
|
|
32301
|
+
functionCallingConfig: {
|
|
32302
|
+
mode: "ANY",
|
|
32303
|
+
allowedFunctionNames: [cloakName2(cloak, choice.name)]
|
|
32304
|
+
}
|
|
32305
|
+
};
|
|
31988
32306
|
}
|
|
31989
32307
|
}
|
|
31990
32308
|
function toAntigravityWire(req, model, identity) {
|
|
32309
|
+
const cloak = identity.cloak ?? null;
|
|
31991
32310
|
const degradations = [];
|
|
31992
32311
|
const note = (d) => {
|
|
31993
32312
|
if (!degradations.includes(d))
|
|
@@ -32016,7 +32335,7 @@ function toAntigravityWire(req, model, identity) {
|
|
|
32016
32335
|
case "toolUse":
|
|
32017
32336
|
parts.push({
|
|
32018
32337
|
thoughtSignature: SIGNATURE_BYPASS,
|
|
32019
|
-
functionCall: { name: block.name, args: block.input }
|
|
32338
|
+
functionCall: { name: cloakName2(cloak, block.name), args: block.input }
|
|
32020
32339
|
});
|
|
32021
32340
|
break;
|
|
32022
32341
|
case "toolResult": {
|
|
@@ -32027,7 +32346,7 @@ function toAntigravityWire(req, model, identity) {
|
|
|
32027
32346
|
note("antigravity:tool-result-error-flag-dropped");
|
|
32028
32347
|
parts.push({
|
|
32029
32348
|
functionResponse: {
|
|
32030
|
-
name: name ?? block.toolUseId,
|
|
32349
|
+
name: cloakName2(cloak, name ?? block.toolUseId),
|
|
32031
32350
|
response: { output: block.content }
|
|
32032
32351
|
}
|
|
32033
32352
|
});
|
|
@@ -32042,28 +32361,47 @@ function toAntigravityWire(req, model, identity) {
|
|
|
32042
32361
|
if (parts.length > 0)
|
|
32043
32362
|
contents.push({ role, parts });
|
|
32044
32363
|
}
|
|
32045
|
-
const request2 = {
|
|
32364
|
+
const request2 = {
|
|
32365
|
+
contents: closingTurn(openingTurn(mergeSameRole(contents), note), note)
|
|
32366
|
+
};
|
|
32046
32367
|
const system = systemText(req.system, "antigravity", note);
|
|
32047
32368
|
if (system !== undefined && system.length > 0) {
|
|
32048
32369
|
request2.systemInstruction = { parts: [{ text: system }] };
|
|
32049
32370
|
}
|
|
32050
32371
|
const generationConfig = {};
|
|
32051
|
-
if (req.maxTokens !== undefined)
|
|
32052
|
-
|
|
32053
|
-
|
|
32054
|
-
|
|
32055
|
-
|
|
32056
|
-
|
|
32372
|
+
if (req.maxTokens !== undefined) {
|
|
32373
|
+
if (req.maxTokens > 0)
|
|
32374
|
+
generationConfig.maxOutputTokens = req.maxTokens;
|
|
32375
|
+
else
|
|
32376
|
+
note("antigravity:max-tokens-dropped");
|
|
32377
|
+
}
|
|
32378
|
+
if (req.temperature !== undefined) {
|
|
32379
|
+
const clamped = Math.min(Math.max(req.temperature, 0), 2);
|
|
32380
|
+
if (clamped !== req.temperature)
|
|
32381
|
+
note("antigravity:temperature-clamped");
|
|
32382
|
+
generationConfig.temperature = clamped;
|
|
32383
|
+
}
|
|
32384
|
+
if (req.stopSequences !== undefined) {
|
|
32385
|
+
generationConfig.stopSequences = req.stopSequences.slice(0, MAX_STOP_SEQUENCES);
|
|
32386
|
+
if (req.stopSequences.length > MAX_STOP_SEQUENCES)
|
|
32387
|
+
note("antigravity:stop-sequences-dropped");
|
|
32388
|
+
}
|
|
32057
32389
|
if (req.reasoning !== undefined) {
|
|
32058
32390
|
switch (req.reasoning.mode) {
|
|
32059
32391
|
case "off":
|
|
32060
32392
|
generationConfig.thinkingConfig = { thinkingBudget: 0, includeThoughts: false };
|
|
32061
32393
|
break;
|
|
32062
32394
|
case "budget":
|
|
32063
|
-
|
|
32064
|
-
|
|
32065
|
-
|
|
32066
|
-
|
|
32395
|
+
{
|
|
32396
|
+
const asked = req.reasoning.budgetTokens;
|
|
32397
|
+
const budget2 = Math.min(Math.max(asked, -1), MAX_THINKING_BUDGET);
|
|
32398
|
+
if (budget2 !== asked)
|
|
32399
|
+
note("antigravity:thinking-budget-clamped");
|
|
32400
|
+
generationConfig.thinkingConfig = {
|
|
32401
|
+
thinkingBudget: budget2,
|
|
32402
|
+
includeThoughts: budget2 !== 0
|
|
32403
|
+
};
|
|
32404
|
+
}
|
|
32067
32405
|
break;
|
|
32068
32406
|
case "adaptive":
|
|
32069
32407
|
generationConfig.thinkingConfig = {
|
|
@@ -32092,20 +32430,33 @@ function toAntigravityWire(req, model, identity) {
|
|
|
32092
32430
|
const portable = req.tools.filter((t) => t.kind === "portable");
|
|
32093
32431
|
if (portable.length !== req.tools.length)
|
|
32094
32432
|
note("antigravity:provider-tool-dropped");
|
|
32095
|
-
|
|
32433
|
+
const seen = new Set;
|
|
32434
|
+
const named = [];
|
|
32435
|
+
for (const tool of portable) {
|
|
32436
|
+
const name = cloakName2(cloak, tool.name);
|
|
32437
|
+
if (seen.has(name)) {
|
|
32438
|
+
note("antigravity:duplicate-tool-dropped");
|
|
32439
|
+
continue;
|
|
32440
|
+
}
|
|
32441
|
+
seen.add(name);
|
|
32442
|
+
named.push({ name, description: tool.description, inputSchema: tool.inputSchema });
|
|
32443
|
+
}
|
|
32444
|
+
if (cloak !== null && cloak.toWire.size > 0)
|
|
32445
|
+
note("antigravity:tool-name-renamed");
|
|
32446
|
+
if (named.length > 0) {
|
|
32096
32447
|
request2.tools = [
|
|
32097
32448
|
{
|
|
32098
|
-
functionDeclarations:
|
|
32449
|
+
functionDeclarations: named.map((t) => ({
|
|
32099
32450
|
name: t.name,
|
|
32100
32451
|
description: t.description,
|
|
32101
|
-
parameters: t.inputSchema
|
|
32452
|
+
parameters: pruneSchema(t.inputSchema, note)
|
|
32102
32453
|
}))
|
|
32103
32454
|
}
|
|
32104
32455
|
];
|
|
32105
32456
|
}
|
|
32106
32457
|
}
|
|
32107
32458
|
if (req.toolChoice !== undefined)
|
|
32108
|
-
request2.toolConfig = encodeToolChoice2(req.toolChoice);
|
|
32459
|
+
request2.toolConfig = encodeToolChoice2(req.toolChoice, cloak);
|
|
32109
32460
|
Object.assign(request2, req.vendor?.antigravity ?? {});
|
|
32110
32461
|
return {
|
|
32111
32462
|
body: {
|
|
@@ -32142,6 +32493,15 @@ function projectOf(input2) {
|
|
|
32142
32493
|
}
|
|
32143
32494
|
return project;
|
|
32144
32495
|
}
|
|
32496
|
+
function cloakOf2(state) {
|
|
32497
|
+
if (state === null || typeof state !== "object")
|
|
32498
|
+
return null;
|
|
32499
|
+
const cloak = state.cloak;
|
|
32500
|
+
if (cloak === null || cloak === undefined || typeof cloak !== "object")
|
|
32501
|
+
return null;
|
|
32502
|
+
const { toWire: toWire2, fromWire } = cloak;
|
|
32503
|
+
return toWire2 instanceof Map && fromWire instanceof Map ? cloak : null;
|
|
32504
|
+
}
|
|
32145
32505
|
var antigravityCodec = {
|
|
32146
32506
|
buildRequest(input2) {
|
|
32147
32507
|
const accessToken = input2.credentials.accessToken;
|
|
@@ -32150,9 +32510,11 @@ var antigravityCodec = {
|
|
|
32150
32510
|
}
|
|
32151
32511
|
const project = projectOf(input2);
|
|
32152
32512
|
const requestId = input2.requestId !== undefined && input2.requestId.length > 0 ? input2.requestId : derivedRequestId(`${input2.model}:${project}`);
|
|
32513
|
+
const cloak = buildToolCloak2(input2.request);
|
|
32153
32514
|
const { body, degradations } = toAntigravityWire(input2.request, input2.model, {
|
|
32154
32515
|
project,
|
|
32155
|
-
requestId
|
|
32516
|
+
requestId,
|
|
32517
|
+
cloak
|
|
32156
32518
|
});
|
|
32157
32519
|
const protocol = [["Authorization", `Bearer ${accessToken}`]];
|
|
32158
32520
|
const headers = orderHeaders(mergeHeaders(antigravityProfile.headers, protocol), antigravityProfile.order);
|
|
@@ -32163,11 +32525,13 @@ var antigravityCodec = {
|
|
|
32163
32525
|
headers,
|
|
32164
32526
|
body: JSON.stringify(body)
|
|
32165
32527
|
},
|
|
32166
|
-
|
|
32528
|
+
decodeState: { cloak },
|
|
32529
|
+
degradations,
|
|
32530
|
+
...cloak === null ? {} : { cloakedTools: cloak.toWire.size }
|
|
32167
32531
|
};
|
|
32168
32532
|
},
|
|
32169
|
-
decode({ body }) {
|
|
32170
|
-
return decodeAntigravityStream(parseSse(body));
|
|
32533
|
+
decode({ body, decodeState }) {
|
|
32534
|
+
return decodeAntigravityStream(parseSse(body), { cloak: cloakOf2(decodeState) });
|
|
32171
32535
|
}
|
|
32172
32536
|
};
|
|
32173
32537
|
|
|
@@ -52339,7 +52703,7 @@ var _Elysia = class _Elysia2 {
|
|
|
52339
52703
|
scoped: [...this.standaloneValidator.scoped ?? []],
|
|
52340
52704
|
global: [...this.standaloneValidator.global ?? []]
|
|
52341
52705
|
};
|
|
52342
|
-
const
|
|
52706
|
+
const isSchema2 = typeof schemaOrRun == "object", sandbox = (isSchema2 ? run : schemaOrRun)(instance);
|
|
52343
52707
|
return this.singleton = mergeDeep(this.singleton, instance.singleton), this.definitions = mergeDeep(this.definitions, instance.definitions), sandbox.event.request?.length && (this.event.request = [
|
|
52344
52708
|
...this.event.request || [],
|
|
52345
52709
|
...sandbox.event.request || []
|
|
@@ -52347,7 +52711,7 @@ var _Elysia = class _Elysia2 {
|
|
|
52347
52711
|
...this.event.mapResponse || [],
|
|
52348
52712
|
...sandbox.event.mapResponse || []
|
|
52349
52713
|
]), this.model(sandbox.definitions.type), Object.values(instance.router.history).forEach(({ method, path, handler, hooks }) => {
|
|
52350
|
-
if (path = (
|
|
52714
|
+
if (path = (isSchema2 ? "" : this.config.prefix ?? "") + prefix + path, isSchema2) {
|
|
52351
52715
|
const {
|
|
52352
52716
|
body: body2,
|
|
52353
52717
|
headers,
|
|
@@ -60280,7 +60644,7 @@ function createRing(limits) {
|
|
|
60280
60644
|
}
|
|
60281
60645
|
|
|
60282
60646
|
// apps/gateway/src/version.ts
|
|
60283
|
-
var VERSION = "0.10.
|
|
60647
|
+
var VERSION = "0.10.1";
|
|
60284
60648
|
|
|
60285
60649
|
// apps/gateway/src/app.ts
|
|
60286
60650
|
var ADMIN_SESSION_TTL_MS = 12 * 60 * 60 * 1000;
|
package/package.json
CHANGED