anygate 0.5.4 → 0.5.6
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/dist/{chunk-E2MV3GDX.js → chunk-ZEO4BR64.js} +234 -36
- package/dist/chunk-ZEO4BR64.js.map +1 -0
- package/dist/cli.js +75 -3
- package/dist/cli.js.map +1 -1
- package/dist/{command-GJYPBC6E.js → command-PW7KW3PP.js} +5 -3
- package/dist/command-PW7KW3PP.js.map +1 -0
- package/dist/ui/dist/assets/index-CfL9bOYD.css +1 -0
- package/dist/ui/dist/assets/index-Ck-e8hv_.js +5 -0
- package/dist/ui/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/chunk-E2MV3GDX.js.map +0 -1
- package/dist/command-GJYPBC6E.js.map +0 -1
- package/dist/ui/dist/assets/index-BXZwvwW9.css +0 -1
- package/dist/ui/dist/assets/index-CRD31gqp.js +0 -5
package/dist/cli.js
CHANGED
|
@@ -128,12 +128,14 @@ import {
|
|
|
128
128
|
readGlobalOpencodeCredential,
|
|
129
129
|
readOpencodeAuthFile,
|
|
130
130
|
recordLaunchSelection,
|
|
131
|
+
recordUsage,
|
|
131
132
|
refreshAllProviderModels,
|
|
132
133
|
refreshModelsDevCacheAsync,
|
|
133
134
|
refreshProviderModels,
|
|
134
135
|
removeProviderFromRegistry,
|
|
135
136
|
resolveApiKey,
|
|
136
137
|
resolveContextWindow,
|
|
138
|
+
resolveInputTypes,
|
|
137
139
|
resolveModelSource,
|
|
138
140
|
resolveProviderCredential,
|
|
139
141
|
resolveProviderTemplate,
|
|
@@ -168,7 +170,7 @@ import {
|
|
|
168
170
|
validateCustomEndpointUrl,
|
|
169
171
|
writeSecureLogLine,
|
|
170
172
|
zenRegistryStub
|
|
171
|
-
} from "./chunk-
|
|
173
|
+
} from "./chunk-ZEO4BR64.js";
|
|
172
174
|
import {
|
|
173
175
|
filterTemplates,
|
|
174
176
|
getTemplateById,
|
|
@@ -6459,6 +6461,7 @@ function applyRouteContextBounds(entry, route) {
|
|
|
6459
6461
|
);
|
|
6460
6462
|
entry.maxTokens = maxTokenLimit;
|
|
6461
6463
|
entry.maxOutputTokens = maxOutputTokens;
|
|
6464
|
+
entry.supportsImages = route.inputTypes?.includes("image") ?? false;
|
|
6462
6465
|
return withCascadeCheckpointer(entry, checkpointTokenLimit);
|
|
6463
6466
|
}
|
|
6464
6467
|
var GATEWAY_CASCADE_FALLBACK_ENTRY = withCascadeCheckpointer({
|
|
@@ -6589,6 +6592,8 @@ function buildAntigravityRoutes(resolvedFavorites, maxRoutes = MAX_MODEL_CATALOG
|
|
|
6589
6592
|
const baseURL = favModel.apiBaseUrl || favModel.completionsUrl || void 0;
|
|
6590
6593
|
const contextWindow = favModel.contextWindow;
|
|
6591
6594
|
const modelFormat = favModel.modelFormat;
|
|
6595
|
+
const family = favModel.family || favModel.brand || "";
|
|
6596
|
+
const inputTypes = resolveInputTypes(family, fav.providerId, modelId);
|
|
6592
6597
|
routes.push({
|
|
6593
6598
|
catalogId,
|
|
6594
6599
|
providerId: fav.providerId,
|
|
@@ -6603,7 +6608,8 @@ function buildAntigravityRoutes(resolvedFavorites, maxRoutes = MAX_MODEL_CATALOG
|
|
|
6603
6608
|
...fav.oauthAccountId ? { oauthAccountId: fav.oauthAccountId } : {},
|
|
6604
6609
|
...fav.providerData ? { providerData: fav.providerData } : {},
|
|
6605
6610
|
baseURL,
|
|
6606
|
-
contextWindow
|
|
6611
|
+
contextWindow,
|
|
6612
|
+
inputTypes
|
|
6607
6613
|
});
|
|
6608
6614
|
}
|
|
6609
6615
|
return applyUniqueAntigravityRouteLabels(routes);
|
|
@@ -8145,19 +8151,67 @@ async function handleCloudCodeForwardRequest(res, route, parsed, lowerUrl, log15
|
|
|
8145
8151
|
res.end();
|
|
8146
8152
|
return;
|
|
8147
8153
|
}
|
|
8154
|
+
let inputTokens2 = 0;
|
|
8155
|
+
let outputTokens2 = 0;
|
|
8156
|
+
const decoder = new TextDecoder();
|
|
8157
|
+
let buf = "";
|
|
8148
8158
|
for await (const chunk of upstream.body) {
|
|
8159
|
+
const text4 = decoder.decode(chunk, { stream: true });
|
|
8160
|
+
buf += text4;
|
|
8161
|
+
const lines = buf.split("\n");
|
|
8162
|
+
buf = lines.pop() ?? "";
|
|
8163
|
+
for (const line2 of lines) {
|
|
8164
|
+
const t = line2.startsWith("data: ") ? line2.slice(6).trim() : line2.trim();
|
|
8165
|
+
if (!t || t === "[DONE]") continue;
|
|
8166
|
+
try {
|
|
8167
|
+
const obj = JSON.parse(t);
|
|
8168
|
+
const u = obj.response?.usageMetadata;
|
|
8169
|
+
if (u) {
|
|
8170
|
+
inputTokens2 = u.promptTokenCount ?? inputTokens2;
|
|
8171
|
+
outputTokens2 = u.candidatesTokenCount ?? outputTokens2;
|
|
8172
|
+
}
|
|
8173
|
+
} catch {
|
|
8174
|
+
}
|
|
8175
|
+
}
|
|
8149
8176
|
res.write(chunk);
|
|
8150
8177
|
}
|
|
8151
8178
|
res.end();
|
|
8179
|
+
recordUsage({
|
|
8180
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8181
|
+
modelId: route.displayName,
|
|
8182
|
+
providerId: route.providerId,
|
|
8183
|
+
app: "Antigravity",
|
|
8184
|
+
inputTokens: inputTokens2,
|
|
8185
|
+
outputTokens: outputTokens2
|
|
8186
|
+
});
|
|
8152
8187
|
return;
|
|
8153
8188
|
}
|
|
8154
8189
|
const body = await upstream.text();
|
|
8190
|
+
let inputTokens = 0;
|
|
8191
|
+
let outputTokens = 0;
|
|
8192
|
+
try {
|
|
8193
|
+
const obj = JSON.parse(body);
|
|
8194
|
+
const u = obj.response?.usageMetadata;
|
|
8195
|
+
if (u) {
|
|
8196
|
+
inputTokens = u.promptTokenCount ?? 0;
|
|
8197
|
+
outputTokens = u.candidatesTokenCount ?? 0;
|
|
8198
|
+
}
|
|
8199
|
+
} catch {
|
|
8200
|
+
}
|
|
8155
8201
|
res.writeHead(200, {
|
|
8156
8202
|
"content-type": upstream.headers.get("content-type") ?? "application/json",
|
|
8157
8203
|
"content-length": String(Buffer.byteLength(body)),
|
|
8158
8204
|
"grpc-status": "0"
|
|
8159
8205
|
});
|
|
8160
8206
|
res.end(body);
|
|
8207
|
+
recordUsage({
|
|
8208
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8209
|
+
modelId: route.displayName,
|
|
8210
|
+
providerId: route.providerId,
|
|
8211
|
+
app: "Antigravity",
|
|
8212
|
+
inputTokens,
|
|
8213
|
+
outputTokens
|
|
8214
|
+
});
|
|
8161
8215
|
}
|
|
8162
8216
|
function emitThinkingDelta(res, route, responseId, text4, startSse) {
|
|
8163
8217
|
if (!text4) return;
|
|
@@ -8353,6 +8407,15 @@ async function handleStreamingRequest(res, route, providerOptions, parsed, log15
|
|
|
8353
8407
|
res.write(`data: ${JSON.stringify(chunk)}
|
|
8354
8408
|
|
|
8355
8409
|
`);
|
|
8410
|
+
recordUsage({
|
|
8411
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8412
|
+
modelId: route.displayName,
|
|
8413
|
+
npm: route.npm,
|
|
8414
|
+
providerId: route.providerId,
|
|
8415
|
+
app: "Antigravity",
|
|
8416
|
+
inputTokens: p16.totalUsage?.inputTokens ?? 0,
|
|
8417
|
+
outputTokens: p16.totalUsage?.outputTokens ?? 0
|
|
8418
|
+
});
|
|
8356
8419
|
} else if (p16.type === "error") {
|
|
8357
8420
|
const message = formatUpstreamError(p16.error);
|
|
8358
8421
|
log15(`[gateway] stream provider error: ${message}`);
|
|
@@ -8433,6 +8496,15 @@ async function handleUnaryRequest(res, route, providerOptions, parsed, _log, opt
|
|
|
8433
8496
|
responseId
|
|
8434
8497
|
};
|
|
8435
8498
|
respondJson(res, 200, { response, traceId: "gateway-trace", metadata: {} });
|
|
8499
|
+
recordUsage({
|
|
8500
|
+
ts: (/* @__PURE__ */ new Date()).toISOString(),
|
|
8501
|
+
modelId: route.displayName,
|
|
8502
|
+
npm: route.npm,
|
|
8503
|
+
providerId: route.providerId,
|
|
8504
|
+
app: "Antigravity",
|
|
8505
|
+
inputTokens: result.usage?.inputTokens ?? 0,
|
|
8506
|
+
outputTokens: result.usage?.outputTokens ?? 0
|
|
8507
|
+
});
|
|
8436
8508
|
}
|
|
8437
8509
|
|
|
8438
8510
|
// src/gateway/antigravity/launch-routes.ts
|
|
@@ -12802,7 +12874,7 @@ Error: ${parsed.error}
|
|
|
12802
12874
|
console.log("Usage: anygate ui [--trace]\n\nOpen the settings UI in your browser.");
|
|
12803
12875
|
return 0;
|
|
12804
12876
|
}
|
|
12805
|
-
const { runUiCommand } = await import("./command-
|
|
12877
|
+
const { runUiCommand } = await import("./command-PW7KW3PP.js");
|
|
12806
12878
|
return runUiCommand({ trace: parsed.trace });
|
|
12807
12879
|
}
|
|
12808
12880
|
if (parsed.command === "models") {
|