tuxevil-rotator 4.2.1 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +48 -1
- package/README.md +20 -6
- package/package.json +3 -3
- package/plugins/opencode-discovery/capabilities.d.mts +7 -0
- package/plugins/opencode-discovery/capabilities.mjs +54 -0
- package/plugins/opencode-discovery/index.d.mts +60 -0
- package/plugins/opencode-discovery/index.mjs +333 -0
- package/plugins/opencode-discovery/package.json +24 -0
- package/src/audio-transcription.ts +32 -6
- package/src/cli.ts +3 -3
- package/src/compat/model-specs.ts +4 -0
- package/src/compat.ts +34 -6
- package/src/dashboard-app.ts +1 -0
- package/src/install-agent.ts +252 -143
- package/src/install-opencode.ts +211 -43
- package/src/providers/google-antigravity/catalog.ts +45 -166
- package/src/providers/google-antigravity/dynamic-catalog.ts +107 -10
- package/src/providers/google-antigravity/forward.ts +4 -2
- package/src/providers/google-antigravity/index.ts +12 -4
- package/src/providers/google-antigravity/quota.ts +9 -7
- package/src/providers/ollama/forward.ts +10 -0
- package/src/providers/openai-codex/catalog.ts +157 -18
- package/src/proxy.ts +54 -5
- package/src/rotator.ts +32 -22
- package/src/types.ts +79 -67
- package/src/web/app.tsx +4 -0
- package/src/web/lib/audio-recorder.ts +159 -0
- package/src/web/lib/colors.ts +4 -0
- package/src/web/lib/playground-storage.ts +261 -0
- package/src/web/lib/playground.ts +448 -0
- package/src/web/nav.ts +1 -0
- package/src/web/pages/Playground.tsx +1111 -0
- package/src/web/pages/Transcription.tsx +428 -0
- package/src/web/state/api.ts +3 -0
- package/src/web/state/playground-client.ts +136 -0
- package/src/web/state/playground.ts +69 -0
- package/src/web/state/router.ts +2 -2
- package/src/web/state/transcription-client.ts +93 -0
- package/src/web/styles/app.css +45 -0
- package/tools/telemetry-receiver/receiver.js +59 -46
- package/plugins/opencode-discovery.js +0 -174
package/src/proxy.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { Readable, type Duplex } from "node:stream";
|
|
|
14
14
|
import {
|
|
15
15
|
classifyEffortRoutingModel,
|
|
16
16
|
getEffortRoutingRule,
|
|
17
|
+
applyModelAlias,
|
|
17
18
|
resolveQuotaModelKey,
|
|
18
19
|
resolveDisplayModelKey,
|
|
19
20
|
} from "./types.js";
|
|
@@ -40,6 +41,8 @@ import {
|
|
|
40
41
|
extractUsageFromSseEvent,
|
|
41
42
|
GOOGLE_BENCHMARK_CONSTANTS,
|
|
42
43
|
} from "./providers/google-antigravity/forward.js";
|
|
44
|
+
import { isDynamicallyAvailableAntigravityModel } from "./providers/google-antigravity/catalog.js";
|
|
45
|
+
import { dynamicCatalog } from "./providers/google-antigravity/dynamic-catalog.js";
|
|
43
46
|
export { forwardRequest, SseEventAccumulator, extractUsageFromSseEvent };
|
|
44
47
|
import {
|
|
45
48
|
serveStatusApi,
|
|
@@ -92,7 +95,7 @@ import {
|
|
|
92
95
|
handleCliLoginApi,
|
|
93
96
|
} from "./onboarding.js";
|
|
94
97
|
import { requireAdmin } from "./admin-auth.js";
|
|
95
|
-
import { PayloadTooLargeError, readLimitedBody } from "./body-limit.js";
|
|
98
|
+
import { getMaxBodyBytes, PayloadTooLargeError, readLimitedBody } from "./body-limit.js";
|
|
96
99
|
import { validateConfig, validateProxyRequestBody } from "./validators.js";
|
|
97
100
|
import { calculateBackoffMs } from "./fetch-with-retry.js";
|
|
98
101
|
import { logger } from "./logger.js";
|
|
@@ -188,6 +191,7 @@ import {
|
|
|
188
191
|
handleAnthropicMessages,
|
|
189
192
|
handleGeminiGenerateContent,
|
|
190
193
|
handleOpenAIChatCompletions,
|
|
194
|
+
handlePlaygroundChatCompletions,
|
|
191
195
|
handleOpenAIResponsesCancel,
|
|
192
196
|
handleOpenAIResponsesCreate,
|
|
193
197
|
handleOpenAIResponsesDelete,
|
|
@@ -198,6 +202,7 @@ import {
|
|
|
198
202
|
} from "./compat.js";
|
|
199
203
|
import {
|
|
200
204
|
handleOpenAIAudioTranscriptions,
|
|
205
|
+
handlePlaygroundAudioTranscriptions,
|
|
201
206
|
handleAudioWebSocket,
|
|
202
207
|
closeAllAudioWebSockets,
|
|
203
208
|
WS_SHUTDOWN_CLOSE_GRACE_MS,
|
|
@@ -1084,7 +1089,7 @@ export async function benchmarkAccount(
|
|
|
1084
1089
|
error: `${benchmarkProvider.displayName} is turned off on the Models page`,
|
|
1085
1090
|
};
|
|
1086
1091
|
if (turnedOff()) return turnedOffResult;
|
|
1087
|
-
rotator.startRequest(account, benchmarkSpec.body.model);
|
|
1092
|
+
rotator.startRequest(account, benchmarkSpec.body.model, benchmarkProvider.id);
|
|
1088
1093
|
const timeoutController = new AbortController();
|
|
1089
1094
|
const timeout = setTimeout(
|
|
1090
1095
|
() => timeoutController.abort(new Error("Benchmark timeout")),
|
|
@@ -1129,7 +1134,7 @@ export async function benchmarkAccount(
|
|
|
1129
1134
|
return benchmarkFailure(account, startedAt, formatError(err), ttfbMs);
|
|
1130
1135
|
} finally {
|
|
1131
1136
|
clearTimeout(timeout);
|
|
1132
|
-
rotator.finishRequest(account, benchmarkSpec.body.model);
|
|
1137
|
+
rotator.finishRequest(account, benchmarkSpec.body.model, benchmarkProvider.id);
|
|
1133
1138
|
}
|
|
1134
1139
|
}
|
|
1135
1140
|
|
|
@@ -1267,6 +1272,20 @@ export async function withRotation<T>(
|
|
|
1267
1272
|
ollamaModels: new Set(rotator.getOllamaModels?.() ?? []),
|
|
1268
1273
|
codexModels: new Set(rotator.getCodexModels?.() ?? []),
|
|
1269
1274
|
})?.id;
|
|
1275
|
+
const modelQuotaFamily = resolveQuotaModelKey(model) ??
|
|
1276
|
+
resolveQuotaModelKey(applyModelAlias(model));
|
|
1277
|
+
if (
|
|
1278
|
+
(providerId === DEFAULT_PROVIDER ||
|
|
1279
|
+
(!providerId && (modelQuotaFamily === "claude" || modelQuotaFamily === "gemini" ||
|
|
1280
|
+
dynamicCatalog.wasDiscovered(model) || dynamicCatalog.wasDiscovered(applyModelAlias(model))))) &&
|
|
1281
|
+
!isDynamicallyAvailableAntigravityModel(model)
|
|
1282
|
+
) {
|
|
1283
|
+
return {
|
|
1284
|
+
ok: false,
|
|
1285
|
+
status: 404,
|
|
1286
|
+
errorText: `Model '${body.displayModel || model}' is not available in the active Antigravity model catalog`,
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1270
1289
|
const requestIsOff = (selectedProviderId = providerId): boolean => isRequestOff(rotator, {
|
|
1271
1290
|
model,
|
|
1272
1291
|
requestedModel: body.requestedModel,
|
|
@@ -1335,7 +1354,7 @@ export async function withRotation<T>(
|
|
|
1335
1354
|
const releaseCurrentAccount = (): void => {
|
|
1336
1355
|
if (accountReleased) return;
|
|
1337
1356
|
accountReleased = true;
|
|
1338
|
-
rotator.finishRequest(account, modelKey);
|
|
1357
|
+
rotator.finishRequest(account, modelKey, providerId);
|
|
1339
1358
|
};
|
|
1340
1359
|
const rotateAndRelease = async (): Promise<AccountRuntime | null> => {
|
|
1341
1360
|
releaseCurrentAccount();
|
|
@@ -1855,7 +1874,7 @@ async function handleProxyRequest(
|
|
|
1855
1874
|
const releaseCurrentAccount = (): void => {
|
|
1856
1875
|
if (accountReleased) return;
|
|
1857
1876
|
accountReleased = true;
|
|
1858
|
-
rotator.finishRequest(account, modelKey);
|
|
1877
|
+
rotator.finishRequest(account, modelKey, providerId);
|
|
1859
1878
|
};
|
|
1860
1879
|
const rotateAndRelease = async (): Promise<AccountRuntime | null> => {
|
|
1861
1880
|
releaseCurrentAccount();
|
|
@@ -2209,6 +2228,7 @@ async function handleCodeAssistPassthrough(
|
|
|
2209
2228
|
rotator.finishRequest(
|
|
2210
2229
|
account,
|
|
2211
2230
|
resolveQuotaModelKey(CODE_ASSIST_ROUTING_MODEL) ?? undefined,
|
|
2231
|
+
DEFAULT_PROVIDER,
|
|
2212
2232
|
);
|
|
2213
2233
|
};
|
|
2214
2234
|
|
|
@@ -2757,6 +2777,35 @@ export function startProxy(
|
|
|
2757
2777
|
return;
|
|
2758
2778
|
}
|
|
2759
2779
|
|
|
2780
|
+
if (method === "GET" && pathname === "/api/playground/config") {
|
|
2781
|
+
if (!requireAdmin(req, res)) return;
|
|
2782
|
+
res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" });
|
|
2783
|
+
res.end(JSON.stringify({ maxBodyBytes: getMaxBodyBytes() }));
|
|
2784
|
+
return;
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
if (method === "POST" && pathname === "/api/playground/audio/transcriptions") {
|
|
2788
|
+
void handlePlaygroundAudioTranscriptions(req, res, rotator).catch((err) => {
|
|
2789
|
+
log(`Playground audio error: ${err}`, rotator, "error");
|
|
2790
|
+
if (!res.headersSent) {
|
|
2791
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
2792
|
+
res.end(JSON.stringify({ error: { message: "Internal transcription error", type: "server_error" } }));
|
|
2793
|
+
} else res.destroy();
|
|
2794
|
+
});
|
|
2795
|
+
return;
|
|
2796
|
+
}
|
|
2797
|
+
|
|
2798
|
+
if (method === "POST" && pathname === "/api/playground/chat/completions") {
|
|
2799
|
+
void handlePlaygroundChatCompletions(req, res, rotator).catch((err) => {
|
|
2800
|
+
log(`Playground compat error: ${err}`, rotator, "error");
|
|
2801
|
+
if (!res.headersSent) {
|
|
2802
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
2803
|
+
res.end(JSON.stringify({ error: { message: "Internal playground error", type: "server_error" } }));
|
|
2804
|
+
} else res.destroy();
|
|
2805
|
+
});
|
|
2806
|
+
return;
|
|
2807
|
+
}
|
|
2808
|
+
|
|
2760
2809
|
// OpenAI-compatible adapter route (additive; does not affect native v1internal route)
|
|
2761
2810
|
if (method === "GET" && pathname === "/v1/models") {
|
|
2762
2811
|
serveOpenAIModels(res, rotator);
|
package/src/rotator.ts
CHANGED
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
DEFAULT_QUOTA_POLL_INTERVAL_MS,
|
|
28
28
|
MAX_QUOTA_POLL_INTERVAL_MS,
|
|
29
29
|
MIN_QUOTA_POLL_INTERVAL_MS,
|
|
30
|
-
isStaticAntigravityModel,
|
|
31
30
|
resolveQuotaModelKey,
|
|
32
31
|
resolveDisplayModelKey,
|
|
33
32
|
} from "./types.js";
|
|
@@ -650,6 +649,12 @@ export class AccountRotator {
|
|
|
650
649
|
getCredentialGenerationFingerprint(account, DEFAULT_PROVIDER),
|
|
651
650
|
})),
|
|
652
651
|
);
|
|
652
|
+
dynamicCatalog.restorePersistedSnapshots(state.dynamicModelSnapshots,
|
|
653
|
+
this.accounts.filter((account) => hasCredential(account.config, DEFAULT_PROVIDER)).map((account) => ({
|
|
654
|
+
id: getAccountIdentity(account),
|
|
655
|
+
credentialGenerationFingerprint: getCredentialGenerationFingerprint(account, DEFAULT_PROVIDER),
|
|
656
|
+
})),
|
|
657
|
+
);
|
|
653
658
|
// Load per-model account assignments
|
|
654
659
|
if (state.modelAccounts) {
|
|
655
660
|
for (const [model, idx] of Object.entries(state.modelAccounts)) {
|
|
@@ -838,6 +843,13 @@ export class AccountRotator {
|
|
|
838
843
|
|
|
839
844
|
const disabledProvidersByAccount: Record<string, string[]> = {};
|
|
840
845
|
const state: PersistedState = {
|
|
846
|
+
dynamicModelSnapshots: dynamicCatalog.getPersistedSnapshots(
|
|
847
|
+
this.accounts.filter((account) => !account.disabled && !account.flagged &&
|
|
848
|
+
!account.invalidProviders?.[DEFAULT_PROVIDER] && hasCredential(account.config, DEFAULT_PROVIDER)).map((account) => ({
|
|
849
|
+
id: getAccountIdentity(account),
|
|
850
|
+
credentialGenerationFingerprint: getCredentialGenerationFingerprint(account, DEFAULT_PROVIDER),
|
|
851
|
+
})),
|
|
852
|
+
),
|
|
841
853
|
dynamicModelQuotaPools: dynamicCatalog.getDiscoveredQuotaPools(),
|
|
842
854
|
dynamicModelOwnership: dynamicCatalog.getPersistedModelOwnership(
|
|
843
855
|
this.accounts
|
|
@@ -1019,6 +1031,7 @@ export class AccountRotator {
|
|
|
1019
1031
|
|
|
1020
1032
|
private async pollAccountQuotaOnce(account: AccountRuntime): Promise<boolean> {
|
|
1021
1033
|
let quotaPublished = false;
|
|
1034
|
+
const snapshotRevision = dynamicCatalog.snapshotRevision;
|
|
1022
1035
|
try {
|
|
1023
1036
|
const quotaCtx: QuotaFetchContext = {
|
|
1024
1037
|
log: (message) => this.log(message),
|
|
@@ -1076,10 +1089,10 @@ export class AccountRotator {
|
|
|
1076
1089
|
cooldownChanged = true;
|
|
1077
1090
|
}
|
|
1078
1091
|
}
|
|
1079
|
-
if (cooldownChanged) {
|
|
1092
|
+
if (cooldownChanged || snapshotRevision !== dynamicCatalog.snapshotRevision) {
|
|
1080
1093
|
this.scheduleStateSave();
|
|
1081
|
-
this.requestWaiterDrain();
|
|
1082
1094
|
}
|
|
1095
|
+
if (cooldownChanged) this.requestWaiterDrain();
|
|
1083
1096
|
|
|
1084
1097
|
// Consolidated RAW POLL across all providers on this account:
|
|
1085
1098
|
// google first (Antigravity OAuth pools), then ollama (usage pools).
|
|
@@ -1199,9 +1212,8 @@ export class AccountRotator {
|
|
|
1199
1212
|
|
|
1200
1213
|
// Get quota % for a specific model on an account. Returns -1 if no data.
|
|
1201
1214
|
private getModelQuota(account: AccountRuntime, modelKey: string): number {
|
|
1202
|
-
const quotaKey =
|
|
1203
|
-
|
|
1204
|
-
: dynamicCatalog.resolveQuotaPool(modelKey) ?? modelKey;
|
|
1215
|
+
const quotaKey = dynamicCatalog.resolveQuotaPool(modelKey) ??
|
|
1216
|
+
resolveQuotaModelKey(modelKey) ?? modelKey;
|
|
1205
1217
|
const q = account.quota.find((q) => q.modelKey === quotaKey) ??
|
|
1206
1218
|
(quotaKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)
|
|
1207
1219
|
? account.quota.find((candidate) => candidate.modelKey === CODEX_QUOTA_MODEL_KEY)
|
|
@@ -1236,9 +1248,8 @@ export class AccountRotator {
|
|
|
1236
1248
|
account: AccountRuntime,
|
|
1237
1249
|
modelKey: string,
|
|
1238
1250
|
): ModelQuota["timerType"] {
|
|
1239
|
-
const quotaKey =
|
|
1240
|
-
|
|
1241
|
-
: dynamicCatalog.resolveQuotaPool(modelKey) ?? modelKey;
|
|
1251
|
+
const quotaKey = dynamicCatalog.resolveQuotaPool(modelKey) ??
|
|
1252
|
+
resolveQuotaModelKey(modelKey) ?? modelKey;
|
|
1242
1253
|
const q = account.quota.find((q) => q.modelKey === quotaKey) ??
|
|
1243
1254
|
(quotaKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)
|
|
1244
1255
|
? account.quota.find((candidate) => candidate.modelKey === CODEX_QUOTA_MODEL_KEY)
|
|
@@ -2204,6 +2215,7 @@ export class AccountRotator {
|
|
|
2204
2215
|
waiter.model
|
|
2205
2216
|
? this.resolveRequestPoolKey(waiter.model, waiter.providerId)
|
|
2206
2217
|
: undefined,
|
|
2218
|
+
waiter.providerId,
|
|
2207
2219
|
);
|
|
2208
2220
|
}
|
|
2209
2221
|
progressed = true;
|
|
@@ -2412,7 +2424,7 @@ export class AccountRotator {
|
|
|
2412
2424
|
}
|
|
2413
2425
|
}
|
|
2414
2426
|
}
|
|
2415
|
-
this.startRequest(current, modelKey ?? undefined);
|
|
2427
|
+
this.startRequest(current, modelKey ?? undefined, providerId);
|
|
2416
2428
|
if (modelKey && state) {
|
|
2417
2429
|
state.requestsOnActiveAccount++;
|
|
2418
2430
|
this.scheduleStateSave();
|
|
@@ -2426,7 +2438,7 @@ export class AccountRotator {
|
|
|
2426
2438
|
this.scheduleStateSave();
|
|
2427
2439
|
}
|
|
2428
2440
|
this.refundTokenBucket(current, Date.now());
|
|
2429
|
-
this.finishRequest(current, modelKey ?? undefined);
|
|
2441
|
+
this.finishRequest(current, modelKey ?? undefined, providerId);
|
|
2430
2442
|
if (modelKey && this.isCodexPoolKey(modelKey)) {
|
|
2431
2443
|
return this.rotateModelForRequest(modelKey, now, idx);
|
|
2432
2444
|
}
|
|
@@ -2598,7 +2610,7 @@ export class AccountRotator {
|
|
|
2598
2610
|
forRequest = false,
|
|
2599
2611
|
): Promise<AccountRuntime> {
|
|
2600
2612
|
if (forRequest) {
|
|
2601
|
-
this.startRequest(account, modelKey);
|
|
2613
|
+
this.startRequest(account, modelKey, getProviderIdForPoolKey(modelKey));
|
|
2602
2614
|
}
|
|
2603
2615
|
const newIdx = this.accounts.indexOf(account);
|
|
2604
2616
|
const quota = this.getModelQuota(account, modelKey);
|
|
@@ -2621,7 +2633,7 @@ export class AccountRotator {
|
|
|
2621
2633
|
state.requestsOnActiveAccount = Math.max(0, state.requestsOnActiveAccount - 1);
|
|
2622
2634
|
}
|
|
2623
2635
|
this.refundTokenBucket(account, Date.now());
|
|
2624
|
-
this.finishRequest(account, modelKey);
|
|
2636
|
+
this.finishRequest(account, modelKey, getProviderIdForPoolKey(modelKey));
|
|
2625
2637
|
}
|
|
2626
2638
|
throw err;
|
|
2627
2639
|
}
|
|
@@ -3939,12 +3951,13 @@ export class AccountRotator {
|
|
|
3939
3951
|
this.scheduleStateSave();
|
|
3940
3952
|
}
|
|
3941
3953
|
|
|
3942
|
-
startRequest(account: AccountRuntime, modelKey?: string): void {
|
|
3954
|
+
startRequest(account: AccountRuntime, modelKey?: string, providerId?: string): void {
|
|
3943
3955
|
const key = modelKey ?? "__default__";
|
|
3956
|
+
const requestProviderId = providerId ?? getProviderIdForPoolKey(key);
|
|
3944
3957
|
// Ollama Cloud imposes no per-account concurrency limit, so its
|
|
3945
3958
|
// requests must not activate in-flight tracking at all (the monthly
|
|
3946
3959
|
// pool and raw ollama model names from benchmark probes).
|
|
3947
|
-
if (isOllamaQuotaPoolKey(key) ||
|
|
3960
|
+
if (isOllamaQuotaPoolKey(key) || requestProviderId === "ollama") {
|
|
3948
3961
|
this.consumeTokenBucket(account, Date.now());
|
|
3949
3962
|
return;
|
|
3950
3963
|
}
|
|
@@ -3954,9 +3967,10 @@ export class AccountRotator {
|
|
|
3954
3967
|
this.consumeTokenBucket(account, Date.now());
|
|
3955
3968
|
}
|
|
3956
3969
|
|
|
3957
|
-
finishRequest(account: AccountRuntime, modelKey?: string): void {
|
|
3970
|
+
finishRequest(account: AccountRuntime, modelKey?: string, providerId?: string): void {
|
|
3958
3971
|
const key = modelKey ?? "__default__";
|
|
3959
|
-
|
|
3972
|
+
const requestProviderId = providerId ?? getProviderIdForPoolKey(key);
|
|
3973
|
+
if (isOllamaQuotaPoolKey(key) || requestProviderId === "ollama") return;
|
|
3960
3974
|
account.inFlightByModel[key] = Math.max(
|
|
3961
3975
|
0,
|
|
3962
3976
|
(account.inFlightByModel[key] ?? 0) - 1,
|
|
@@ -3987,7 +4001,6 @@ export class AccountRotator {
|
|
|
3987
4001
|
): { reason: RoutingRejectionReason; detail: string } | null {
|
|
3988
4002
|
const accountId = getAccountIdentity(account);
|
|
3989
4003
|
if (
|
|
3990
|
-
!isStaticAntigravityModel(modelKey) &&
|
|
3991
4004
|
dynamicCatalog.hasOwnershipForModel(modelKey) &&
|
|
3992
4005
|
!dynamicCatalog.hasModelForAccount(accountId, modelKey)
|
|
3993
4006
|
) {
|
|
@@ -4059,10 +4072,7 @@ export class AccountRotator {
|
|
|
4059
4072
|
// capture a request that is pinned or routed to another provider.
|
|
4060
4073
|
const provider = providerId ?? routedProviderId(this, model);
|
|
4061
4074
|
if (!provider || provider === DEFAULT_PROVIDER) {
|
|
4062
|
-
if (
|
|
4063
|
-
!isStaticAntigravityModel(model) &&
|
|
4064
|
-
dynamicCatalog.wasDiscovered(model)
|
|
4065
|
-
) return normalizedModel;
|
|
4075
|
+
if (dynamicCatalog.wasDiscovered(model)) return normalizedModel;
|
|
4066
4076
|
if (this.hasRelevantQuotaStateForModel(normalizedModel, Date.now())) {
|
|
4067
4077
|
return normalizedModel;
|
|
4068
4078
|
}
|
package/src/types.ts
CHANGED
|
@@ -363,55 +363,18 @@ export interface ModelQuota {
|
|
|
363
363
|
// variants (and gpt-oss) share one bucket, all Gemini variants share one.
|
|
364
364
|
export const QUOTA_MODEL_KEYS: Record<
|
|
365
365
|
string,
|
|
366
|
-
{ key: string;
|
|
366
|
+
{ key: string; display: string }
|
|
367
367
|
> = {
|
|
368
368
|
claude: {
|
|
369
369
|
key: "claude",
|
|
370
|
-
altKeys: [
|
|
371
|
-
"claude-opus-4-6-thinking",
|
|
372
|
-
"claude-opus-4-5-thinking",
|
|
373
|
-
"claude-opus-4-5",
|
|
374
|
-
"claude-sonnet-4-6-thinking",
|
|
375
|
-
"claude-sonnet-4-6",
|
|
376
|
-
"claude-sonnet-4-5-thinking",
|
|
377
|
-
"claude-sonnet-4-5",
|
|
378
|
-
"gpt-oss-120b-medium",
|
|
379
|
-
"gpt-oss-120b",
|
|
380
|
-
],
|
|
381
370
|
display: "Claude",
|
|
382
371
|
},
|
|
383
372
|
gemini: {
|
|
384
373
|
key: "gemini",
|
|
385
|
-
altKeys: [
|
|
386
|
-
"gemini-3.1-pro",
|
|
387
|
-
"gemini-3.1-pro-low",
|
|
388
|
-
"gemini-3.1-pro-high",
|
|
389
|
-
"gemini-3-pro-high",
|
|
390
|
-
"gemini-3-pro-low",
|
|
391
|
-
"gemini-3-flash-agent",
|
|
392
|
-
"gemini-3-flash",
|
|
393
|
-
"gemini-3.6-flash",
|
|
394
|
-
"gemini-3.6-flash-high",
|
|
395
|
-
"gemini-3.6-flash-medium",
|
|
396
|
-
"gemini-3.6-flash-low",
|
|
397
|
-
"gemini-3.6-flash-tiered",
|
|
398
|
-
"gemini-3.7-flash-tiered",
|
|
399
|
-
"gemini-3.8-flash-low",
|
|
400
|
-
"gemini-3.8-flash-medium",
|
|
401
|
-
"gemini-3.8-flash-high",
|
|
402
|
-
],
|
|
403
374
|
display: "Gemini",
|
|
404
375
|
},
|
|
405
376
|
};
|
|
406
377
|
|
|
407
|
-
const STATIC_ANTIGRAVITY_MODEL_IDS = new Set(
|
|
408
|
-
Object.values(QUOTA_MODEL_KEYS).flatMap(({ altKeys }) => altKeys),
|
|
409
|
-
);
|
|
410
|
-
|
|
411
|
-
export function isStaticAntigravityModel(model: string): boolean {
|
|
412
|
-
return STATIC_ANTIGRAVITY_MODEL_IDS.has(model.toLowerCase());
|
|
413
|
-
}
|
|
414
|
-
|
|
415
378
|
// Map request model names to quota model keys (family buckets).
|
|
416
379
|
export function resolveQuotaModelKey(requestModel: string): string | null {
|
|
417
380
|
const lower = requestModel.toLowerCase();
|
|
@@ -469,6 +432,17 @@ export function resolveDisplayModelKey(
|
|
|
469
432
|
if (lower.includes("-high")) return "gemini-3.1-pro-high";
|
|
470
433
|
return "gemini-3.1-pro"; // unspecified variant
|
|
471
434
|
}
|
|
435
|
+
// Gemini 4 Argon
|
|
436
|
+
if (
|
|
437
|
+
lower.includes("gemini") &&
|
|
438
|
+
lower.includes("4") &&
|
|
439
|
+
lower.includes("argon")
|
|
440
|
+
) {
|
|
441
|
+
if (lower.includes("-low")) return "gemini-4-argon-low";
|
|
442
|
+
if (lower.includes("-medium")) return "gemini-4-argon-medium";
|
|
443
|
+
if (lower.includes("-high")) return "gemini-4-argon-high";
|
|
444
|
+
return "gemini-4-argon";
|
|
445
|
+
}
|
|
472
446
|
// Gemini 3.8 Flash — Antigravity exposes separate reasoning-level ids.
|
|
473
447
|
if (
|
|
474
448
|
lower.includes("gemini") &&
|
|
@@ -592,7 +566,18 @@ export interface PersistedDynamicModelOwnership {
|
|
|
592
566
|
>;
|
|
593
567
|
}
|
|
594
568
|
|
|
569
|
+
export interface PersistedDynamicModelSnapshots {
|
|
570
|
+
version: 1;
|
|
571
|
+
accounts: Record<string, {
|
|
572
|
+
credentialGenerationFingerprint: string;
|
|
573
|
+
capturedAt: number;
|
|
574
|
+
models: import("./providers/google-antigravity/dynamic-catalog.js").DynamicModelEntry[];
|
|
575
|
+
defaultAgentModelId?: string;
|
|
576
|
+
}>;
|
|
577
|
+
}
|
|
578
|
+
|
|
595
579
|
export interface PersistedState {
|
|
580
|
+
dynamicModelSnapshots?: PersistedDynamicModelSnapshots;
|
|
596
581
|
// Historical dynamic model IDs mapped to their shared quota pools.
|
|
597
582
|
dynamicModelQuotaPools?: Record<string, string>;
|
|
598
583
|
// Exact account ownership for dynamically discovered model IDs.
|
|
@@ -874,7 +859,8 @@ export interface ModelPricing {
|
|
|
874
859
|
cachingStoragePer1MPerHour?: number;
|
|
875
860
|
}
|
|
876
861
|
|
|
877
|
-
// Pricing per 1M tokens (USD) — what these would cost on paid APIs
|
|
862
|
+
// Pricing per 1M tokens (USD) — what these would cost on paid APIs.
|
|
863
|
+
// Source audit and estimation limits: docs/model-pricing.md (2026-10-25).
|
|
878
864
|
export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
879
865
|
"claude-opus-4-6-thinking": { inputPer1M: 5.0, outputPer1M: 25.0 },
|
|
880
866
|
"claude-sonnet-4-6": { inputPer1M: 3.0, outputPer1M: 15.0 },
|
|
@@ -882,35 +868,37 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
|
882
868
|
"gemini-3.1-pro-low": { inputPer1M: 2.0, outputPer1M: 12.0 },
|
|
883
869
|
"gemini-3.1-pro-high": { inputPer1M: 2.0, outputPer1M: 12.0 },
|
|
884
870
|
"gemini-3-flash": { inputPer1M: 0.5, outputPer1M: 3.0 },
|
|
871
|
+
// Standard introductory rates verified 2026-10-25; double on 2027-01-01.
|
|
872
|
+
// https://ai.google.dev/gemini-api/docs/pricing
|
|
885
873
|
"gemini-3.6-flash": {
|
|
886
|
-
inputPer1M:
|
|
887
|
-
outputPer1M:
|
|
888
|
-
cachingPer1M: 0.
|
|
889
|
-
cachingStoragePer1MPerHour:
|
|
874
|
+
inputPer1M: 0.75,
|
|
875
|
+
outputPer1M: 3.75,
|
|
876
|
+
cachingPer1M: 0.075,
|
|
877
|
+
cachingStoragePer1MPerHour: 0.5,
|
|
890
878
|
},
|
|
891
879
|
"gemini-3.6-flash-high": {
|
|
892
|
-
inputPer1M:
|
|
893
|
-
outputPer1M:
|
|
894
|
-
cachingPer1M: 0.
|
|
895
|
-
cachingStoragePer1MPerHour:
|
|
880
|
+
inputPer1M: 0.75,
|
|
881
|
+
outputPer1M: 3.75,
|
|
882
|
+
cachingPer1M: 0.075,
|
|
883
|
+
cachingStoragePer1MPerHour: 0.5,
|
|
896
884
|
},
|
|
897
885
|
"gemini-3.6-flash-medium": {
|
|
898
|
-
inputPer1M:
|
|
899
|
-
outputPer1M:
|
|
900
|
-
cachingPer1M: 0.
|
|
901
|
-
cachingStoragePer1MPerHour:
|
|
886
|
+
inputPer1M: 0.75,
|
|
887
|
+
outputPer1M: 3.75,
|
|
888
|
+
cachingPer1M: 0.075,
|
|
889
|
+
cachingStoragePer1MPerHour: 0.5,
|
|
902
890
|
},
|
|
903
891
|
"gemini-3.6-flash-low": {
|
|
904
|
-
inputPer1M:
|
|
905
|
-
outputPer1M:
|
|
906
|
-
cachingPer1M: 0.
|
|
907
|
-
cachingStoragePer1MPerHour:
|
|
892
|
+
inputPer1M: 0.75,
|
|
893
|
+
outputPer1M: 3.75,
|
|
894
|
+
cachingPer1M: 0.075,
|
|
895
|
+
cachingStoragePer1MPerHour: 0.5,
|
|
908
896
|
},
|
|
909
897
|
"gemini-3.6-flash-tiered": {
|
|
910
|
-
inputPer1M:
|
|
911
|
-
outputPer1M:
|
|
912
|
-
cachingPer1M: 0.
|
|
913
|
-
cachingStoragePer1MPerHour:
|
|
898
|
+
inputPer1M: 0.75,
|
|
899
|
+
outputPer1M: 3.75,
|
|
900
|
+
cachingPer1M: 0.075,
|
|
901
|
+
cachingStoragePer1MPerHour: 0.5,
|
|
914
902
|
},
|
|
915
903
|
// Gemini 3.7 Flash tiered — public Gemini API equivalent-value pricing,
|
|
916
904
|
// verified on the official Gemini API / Google Cloud pricing pages
|
|
@@ -925,7 +913,7 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
|
925
913
|
cachingStoragePer1MPerHour: 0.5,
|
|
926
914
|
},
|
|
927
915
|
// Gemini 3.8 Flash — introductory public Gemini API pricing verified
|
|
928
|
-
// 2026-
|
|
916
|
+
// 2026-10-25. These rates double on 2027-01-01. Antigravity exposes
|
|
929
917
|
// separate low/medium/high model ids.
|
|
930
918
|
"gemini-3.8-flash-low": {
|
|
931
919
|
inputPer1M: 0.75,
|
|
@@ -945,10 +933,32 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
|
945
933
|
cachingPer1M: 0.075,
|
|
946
934
|
cachingStoragePer1MPerHour: 0.5,
|
|
947
935
|
},
|
|
936
|
+
// Standard rates through 2026-11-30; then 4/20/0.2. Implicit cache only.
|
|
937
|
+
// https://ai.google.dev/gemini-api/docs/pricing (verified 2026-10-25).
|
|
938
|
+
"gemini-4-argon": {
|
|
939
|
+
inputPer1M: 2.0,
|
|
940
|
+
outputPer1M: 10.0,
|
|
941
|
+
cachingPer1M: 0.1,
|
|
942
|
+
},
|
|
943
|
+
"gemini-4-argon-low": {
|
|
944
|
+
inputPer1M: 2.0,
|
|
945
|
+
outputPer1M: 10.0,
|
|
946
|
+
cachingPer1M: 0.1,
|
|
947
|
+
},
|
|
948
|
+
"gemini-4-argon-medium": {
|
|
949
|
+
inputPer1M: 2.0,
|
|
950
|
+
outputPer1M: 10.0,
|
|
951
|
+
cachingPer1M: 0.1,
|
|
952
|
+
},
|
|
953
|
+
"gemini-4-argon-high": {
|
|
954
|
+
inputPer1M: 2.0,
|
|
955
|
+
outputPer1M: 10.0,
|
|
956
|
+
cachingPer1M: 0.1,
|
|
957
|
+
},
|
|
948
958
|
"gpt-oss-120b-medium": { inputPer1M: 2.0, outputPer1M: 10.0 },
|
|
949
959
|
|
|
950
960
|
// OpenAI Codex API-equivalent standard rates, checked against
|
|
951
|
-
// https://developers.openai.com/api/docs/pricing on 2026-
|
|
961
|
+
// https://developers.openai.com/api/docs/pricing on 2026-10-25.
|
|
952
962
|
// Spend logs use aggregate input/output tokens;
|
|
953
963
|
// cache rates are metadata and are not applied separately.
|
|
954
964
|
"gpt-6-astra": {
|
|
@@ -966,10 +976,11 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
|
966
976
|
outputPer1M: 0.5,
|
|
967
977
|
cachingPer1M: 0.01,
|
|
968
978
|
},
|
|
979
|
+
// Promotional pricing available at least through 2026-11-21.
|
|
969
980
|
"gpt-5.6-sol": {
|
|
970
|
-
inputPer1M:
|
|
971
|
-
outputPer1M:
|
|
972
|
-
cachingPer1M: 0.
|
|
981
|
+
inputPer1M: 4.0,
|
|
982
|
+
outputPer1M: 20.0,
|
|
983
|
+
cachingPer1M: 0.40,
|
|
973
984
|
},
|
|
974
985
|
"gpt-5.6-terra": {
|
|
975
986
|
inputPer1M: 2.0,
|
|
@@ -982,7 +993,7 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
|
|
|
982
993
|
cachingPer1M: 0.02,
|
|
983
994
|
},
|
|
984
995
|
|
|
985
|
-
// Ollama Cloud standard USD/1M rates, verified 2026-10-
|
|
996
|
+
// Ollama Cloud standard USD/1M rates, verified 2026-10-25:
|
|
986
997
|
// https://ollama.com/pricing. Aggregates do not track cache hits or off-peak
|
|
987
998
|
// billing, so savings represent standard list-price value, not a net saving.
|
|
988
999
|
"gpt-oss:20b": { inputPer1M: 0.07, outputPer1M: 0.30, cachingPer1M: 0.035 },
|
|
@@ -1148,9 +1159,10 @@ export const TAGS_CACHE_TTL_MS = 5 * 60 * 1000;
|
|
|
1148
1159
|
export const ANTIGRAVITY_VERSION =
|
|
1149
1160
|
rotatorEnv("ANTIGRAVITY_VERSION") ||
|
|
1150
1161
|
process.env.PI_AI_ANTIGRAVITY_VERSION ||
|
|
1151
|
-
"2.
|
|
1162
|
+
"2.26.0";
|
|
1152
1163
|
export const DEFAULT_ANTIGRAVITY_USER_AGENT =
|
|
1153
|
-
|
|
1164
|
+
rotatorEnv("ANTIGRAVITY_USER_AGENT") ||
|
|
1165
|
+
`antigravity/hub/${ANTIGRAVITY_VERSION} (aidev_client; os_type=darwin; arch=arm64)`;
|
|
1154
1166
|
export const QUOTA_USER_AGENT =
|
|
1155
1167
|
rotatorEnv("QUOTA_USER_AGENT") ||
|
|
1156
1168
|
DEFAULT_ANTIGRAVITY_USER_AGENT;
|
package/src/web/app.tsx
CHANGED
|
@@ -34,6 +34,7 @@ import { ModelsPage } from "./pages/Models.js";
|
|
|
34
34
|
import { RequestsPage } from "./pages/Requests.js";
|
|
35
35
|
import { UsagePage } from "./pages/Usage.js";
|
|
36
36
|
import { KeysPage } from "./pages/Keys.js";
|
|
37
|
+
import { PlaygroundPage } from "./pages/Playground.js";
|
|
37
38
|
import { SettingsPage } from "./pages/Settings.js";
|
|
38
39
|
import { openAddAccount } from "./pages/shared.js";
|
|
39
40
|
|
|
@@ -137,6 +138,9 @@ function Shell(): JSX.Element {
|
|
|
137
138
|
case "keys":
|
|
138
139
|
page = <KeysPage />;
|
|
139
140
|
break;
|
|
141
|
+
case "playground":
|
|
142
|
+
page = <PlaygroundPage />;
|
|
143
|
+
break;
|
|
140
144
|
case "settings":
|
|
141
145
|
page = <SettingsPage />;
|
|
142
146
|
break;
|