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/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
|
]
|
|
@@ -29098,13 +29099,13 @@ var antigravityDescriptor = {
|
|
|
29098
29099
|
writeOverInput: { fiveMinute: 0, oneHour: 0 },
|
|
29099
29100
|
catalog: ANTIGRAVITY_MODELS,
|
|
29100
29101
|
modelPrefixes: ["gemini-"],
|
|
29101
|
-
callback: { uri: "
|
|
29102
|
+
callback: { uri: "https://antigravity.google/oauth-callback", label: "Antigravity" },
|
|
29102
29103
|
presentation: {
|
|
29103
29104
|
label: "Antigravity",
|
|
29104
29105
|
order: 6,
|
|
29105
29106
|
tone: "violet",
|
|
29106
29107
|
colour: { light: "oklch(0.52 0.14 277)", dark: "oklch(0.74 0.14 277)" },
|
|
29107
|
-
pasteHint: "Approve in
|
|
29108
|
+
pasteHint: "Approve in any browser, then paste the whole URL it lands on. A code shown on its own works too."
|
|
29108
29109
|
}
|
|
29109
29110
|
};
|
|
29110
29111
|
|
|
@@ -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
|
|
|
@@ -32457,8 +32821,9 @@ function parseAntigravityQuota(value, now) {
|
|
|
32457
32821
|
var antigravityOAuthFlow = {
|
|
32458
32822
|
kind: "pkce",
|
|
32459
32823
|
supportsManualPaste: true,
|
|
32460
|
-
async* start({ redirectUri, randomState }) {
|
|
32824
|
+
async* start({ redirectUri, randomState, pkce }) {
|
|
32461
32825
|
const state = randomState();
|
|
32826
|
+
const { verifier, challenge } = pkce();
|
|
32462
32827
|
const url2 = new URL(AUTHORIZE_URL2);
|
|
32463
32828
|
url2.searchParams.set("client_id", CLIENT_ID2);
|
|
32464
32829
|
url2.searchParams.set("response_type", "code");
|
|
@@ -32467,9 +32832,11 @@ var antigravityOAuthFlow = {
|
|
|
32467
32832
|
url2.searchParams.set("state", state);
|
|
32468
32833
|
url2.searchParams.set("access_type", "offline");
|
|
32469
32834
|
url2.searchParams.set("prompt", "consent");
|
|
32835
|
+
url2.searchParams.set("code_challenge", challenge);
|
|
32836
|
+
url2.searchParams.set("code_challenge_method", "S256");
|
|
32470
32837
|
return {
|
|
32471
32838
|
authorizeUrl: url2.toString(),
|
|
32472
|
-
pending: { verifier
|
|
32839
|
+
pending: { verifier, challenge, state, redirectUri }
|
|
32473
32840
|
};
|
|
32474
32841
|
},
|
|
32475
32842
|
async* exchange({ code, pending, fail, now }) {
|
|
@@ -32482,7 +32849,8 @@ var antigravityOAuthFlow = {
|
|
|
32482
32849
|
client_id: CLIENT_ID2,
|
|
32483
32850
|
client_secret: CLIENT_SECRET,
|
|
32484
32851
|
code: (rawCode ?? "").trim(),
|
|
32485
|
-
redirect_uri: pending.redirectUri
|
|
32852
|
+
redirect_uri: pending.redirectUri,
|
|
32853
|
+
code_verifier: pending.verifier
|
|
32486
32854
|
}, fail);
|
|
32487
32855
|
const email3 = yield* readEmail(token.accessToken);
|
|
32488
32856
|
const { projectId, tier } = yield* bootstrapProject(token.accessToken);
|
|
@@ -52339,7 +52707,7 @@ var _Elysia = class _Elysia2 {
|
|
|
52339
52707
|
scoped: [...this.standaloneValidator.scoped ?? []],
|
|
52340
52708
|
global: [...this.standaloneValidator.global ?? []]
|
|
52341
52709
|
};
|
|
52342
|
-
const
|
|
52710
|
+
const isSchema2 = typeof schemaOrRun == "object", sandbox = (isSchema2 ? run : schemaOrRun)(instance);
|
|
52343
52711
|
return this.singleton = mergeDeep(this.singleton, instance.singleton), this.definitions = mergeDeep(this.definitions, instance.definitions), sandbox.event.request?.length && (this.event.request = [
|
|
52344
52712
|
...this.event.request || [],
|
|
52345
52713
|
...sandbox.event.request || []
|
|
@@ -52347,7 +52715,7 @@ var _Elysia = class _Elysia2 {
|
|
|
52347
52715
|
...this.event.mapResponse || [],
|
|
52348
52716
|
...sandbox.event.mapResponse || []
|
|
52349
52717
|
]), this.model(sandbox.definitions.type), Object.values(instance.router.history).forEach(({ method, path, handler, hooks }) => {
|
|
52350
|
-
if (path = (
|
|
52718
|
+
if (path = (isSchema2 ? "" : this.config.prefix ?? "") + prefix + path, isSchema2) {
|
|
52351
52719
|
const {
|
|
52352
52720
|
body: body2,
|
|
52353
52721
|
headers,
|
|
@@ -60280,7 +60648,7 @@ function createRing(limits) {
|
|
|
60280
60648
|
}
|
|
60281
60649
|
|
|
60282
60650
|
// apps/gateway/src/version.ts
|
|
60283
|
-
var VERSION = "0.10.
|
|
60651
|
+
var VERSION = "0.10.2";
|
|
60284
60652
|
|
|
60285
60653
|
// apps/gateway/src/app.ts
|
|
60286
60654
|
var ADMIN_SESSION_TTL_MS = 12 * 60 * 60 * 1000;
|