tuxevil-rotator 3.0.0 → 3.2.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 +37 -0
- package/README.md +20 -6
- package/package.json +1 -1
- package/src/account-store.ts +37 -5
- package/src/cli.ts +24 -3
- package/src/compat/model-specs.ts +1 -0
- package/src/compat.ts +540 -24
- package/src/config-normalize.ts +73 -30
- package/src/dashboard.ts +43 -42
- package/src/index.ts +1 -0
- package/src/onboarding.ts +349 -21
- package/src/providers/adapter.ts +18 -0
- package/src/providers/credential-helpers.ts +64 -0
- package/src/providers/google-antigravity/index.ts +9 -0
- package/src/providers/google-antigravity/quota.ts +2 -1
- package/src/providers/google-antigravity/translators.ts +83 -24
- package/src/providers/ollama/index.ts +8 -0
- package/src/providers/ollama/quota.ts +2 -1
- package/src/providers/openai-codex/catalog.ts +117 -0
- package/src/providers/openai-codex/compat.ts +556 -0
- package/src/providers/openai-codex/credentials.ts +82 -0
- package/src/providers/openai-codex/forward.ts +240 -0
- package/src/providers/openai-codex/index.ts +153 -0
- package/src/providers/openai-codex/login.ts +172 -0
- package/src/providers/openai-codex/oauth.ts +359 -0
- package/src/providers/openai-codex/quota.ts +231 -0
- package/src/providers/opencode-zen/catalog.ts +37 -0
- package/src/providers/opencode-zen/credentials.ts +31 -0
- package/src/providers/opencode-zen/forward.ts +214 -0
- package/src/providers/opencode-zen/index.ts +73 -0
- package/src/providers/opencode-zen/login.ts +81 -0
- package/src/providers/opencode-zen/quota.ts +67 -0
- package/src/providers/registry.ts +24 -5
- package/src/proxy.ts +75 -27
- package/src/rate-limit-parser.ts +2 -1
- package/src/rotator.ts +259 -48
- package/src/spend-logger.ts +2 -0
- package/src/static/dashboard-keys.js +152 -2
- package/src/static/dashboard.js +161 -37
- package/src/types.ts +83 -1
- package/src/validators.ts +11 -2
- package/tools/telemetry-receiver/receiver.js +14 -0
|
@@ -149,6 +149,151 @@ function setCheckedModels(models) {
|
|
|
149
149
|
updateModelsCountBadge();
|
|
150
150
|
}
|
|
151
151
|
|
|
152
|
+
// ── Dynamic model grid (fetched from /api/models) ──────────────────
|
|
153
|
+
//
|
|
154
|
+
// The Generate/Edit Virtual Key modal used to ship with a hardcoded list
|
|
155
|
+
// of legacy Gemini/Claude/GPT-OSS models, so adding new providers
|
|
156
|
+
// (Ollama, OpenAI Codex, OpenCode Zen, ...) silently hid those models
|
|
157
|
+
// from the Allowed Models picker. The grid is now rendered from
|
|
158
|
+
// /api/models, which returns every model the rotator can route today
|
|
159
|
+
// grouped by `owned_by` provider. A static fallback is used only when
|
|
160
|
+
// the API is unreachable (e.g. dashboard served from a stale build).
|
|
161
|
+
|
|
162
|
+
// Provider id → human-readable group title for the modal UI.
|
|
163
|
+
var PROVIDER_LABELS = {
|
|
164
|
+
"tuxevil-rotator": "Google Antigravity",
|
|
165
|
+
"openai-codex": "OpenAI Codex",
|
|
166
|
+
"ollama": "Ollama Cloud",
|
|
167
|
+
"opencode-zen": "OpenCode Zen",
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
function providerLabel(ownedBy) {
|
|
171
|
+
if (PROVIDER_LABELS[ownedBy]) return PROVIDER_LABELS[ownedBy];
|
|
172
|
+
if (typeof ownedBy === "string" && ownedBy.length > 0) {
|
|
173
|
+
return ownedBy.charAt(0).toUpperCase() + ownedBy.slice(1);
|
|
174
|
+
}
|
|
175
|
+
return "Other";
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
function renderModelGridFromCatalog(catalog) {
|
|
179
|
+
var grid = document.getElementById("modelGrid");
|
|
180
|
+
var empty = document.getElementById("modelGridEmpty");
|
|
181
|
+
if (!grid) return false;
|
|
182
|
+
|
|
183
|
+
// Group models by `owned_by` provider while preserving the order in
|
|
184
|
+
// which the API returned them (static catalog first, then dynamic
|
|
185
|
+
// provider catalogs in the order they were enabled).
|
|
186
|
+
var groups = [];
|
|
187
|
+
var byKey = {};
|
|
188
|
+
(catalog || []).forEach(function(m) {
|
|
189
|
+
if (!m || !m.id) return;
|
|
190
|
+
var key = m.owned_by || "other";
|
|
191
|
+
if (!byKey[key]) {
|
|
192
|
+
byKey[key] = { key: key, label: providerLabel(key), models: [] };
|
|
193
|
+
groups.push(byKey[key]);
|
|
194
|
+
}
|
|
195
|
+
byKey[key].models.push(m);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
if (groups.length === 0) {
|
|
199
|
+
grid.innerHTML = "";
|
|
200
|
+
if (empty) empty.style.display = "";
|
|
201
|
+
updateModelsCountBadge();
|
|
202
|
+
return false;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (empty) empty.style.display = "none";
|
|
206
|
+
|
|
207
|
+
grid.innerHTML = groups.map(function(group) {
|
|
208
|
+
var cards = group.models.map(function(m) {
|
|
209
|
+
var id = "model-" + m.id.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
210
|
+
return '<label class="model-card">' +
|
|
211
|
+
'<input type="checkbox" id="' + escapeHtml(id) + '" value="' + escapeHtml(m.id) + '" class="modelCb" onchange="updateModelsCountBadge()">' +
|
|
212
|
+
'<span class="model-name" title="' + escapeHtml(m.id) + '">' + escapeHtml(m.id) + '</span>' +
|
|
213
|
+
'</label>';
|
|
214
|
+
}).join("");
|
|
215
|
+
return '<div class="model-category">' +
|
|
216
|
+
'<div class="cat-title">' + escapeHtml(group.label) + '</div>' +
|
|
217
|
+
'<div class="cat-grid">' + cards + '</div>' +
|
|
218
|
+
'</div>';
|
|
219
|
+
}).join("");
|
|
220
|
+
|
|
221
|
+
updateModelsCountBadge();
|
|
222
|
+
return true;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Last successful catalog (cached so the Edit modal opens instantly
|
|
226
|
+
// without re-fetching when the user clicks Edit right after Generate).
|
|
227
|
+
var lastModelCatalog = null;
|
|
228
|
+
var modelCatalogInflight = null;
|
|
229
|
+
|
|
230
|
+
function fetchModelCatalog() {
|
|
231
|
+
if (modelCatalogInflight) return modelCatalogInflight;
|
|
232
|
+
modelCatalogInflight = fetch("/api/models", { headers: authHeaders() })
|
|
233
|
+
.then(function(r) {
|
|
234
|
+
if (!r.ok) throw new Error("HTTP " + r.status);
|
|
235
|
+
return r.json();
|
|
236
|
+
})
|
|
237
|
+
.then(function(d) {
|
|
238
|
+
var catalog = Array.isArray(d && d.data) ? d.data : [];
|
|
239
|
+
lastModelCatalog = catalog;
|
|
240
|
+
return catalog;
|
|
241
|
+
})
|
|
242
|
+
.finally(function() {
|
|
243
|
+
modelCatalogInflight = null;
|
|
244
|
+
});
|
|
245
|
+
return modelCatalogInflight;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Static fallback used only when /api/models is unreachable. Mirrors
|
|
249
|
+
// the pre-refactor hardcoded list so the modal still works against an
|
|
250
|
+
// older server build that hasn't been restarted with this change.
|
|
251
|
+
var FALLBACK_MODEL_CATALOG = [
|
|
252
|
+
{ id: "gemini-3.1-pro-low", owned_by: "tuxevil-rotator" },
|
|
253
|
+
{ id: "gemini-3.1-pro-high", owned_by: "tuxevil-rotator" },
|
|
254
|
+
{ id: "gemini-3.5-flash-medium", owned_by: "tuxevil-rotator" },
|
|
255
|
+
{ id: "gemini-3.5-flash-high", owned_by: "tuxevil-rotator" },
|
|
256
|
+
{ id: "gemini-3-flash", owned_by: "tuxevil-rotator" },
|
|
257
|
+
{ id: "gemini-3.6-flash-low", owned_by: "tuxevil-rotator" },
|
|
258
|
+
{ id: "gemini-3.6-flash-medium", owned_by: "tuxevil-rotator" },
|
|
259
|
+
{ id: "gemini-3.6-flash-high", owned_by: "tuxevil-rotator" },
|
|
260
|
+
{ id: "gemini-3.6-flash-tiered", owned_by: "tuxevil-rotator" },
|
|
261
|
+
{ id: "gemini-3.7-flash-tiered", owned_by: "tuxevil-rotator" },
|
|
262
|
+
{ id: "claude-sonnet-4-6", owned_by: "tuxevil-rotator" },
|
|
263
|
+
{ id: "claude-opus-4-6-thinking", owned_by: "tuxevil-rotator" },
|
|
264
|
+
{ id: "gpt-oss-120b-medium", owned_by: "tuxevil-rotator" },
|
|
265
|
+
];
|
|
266
|
+
|
|
267
|
+
function ensureModelGridRendered(preselectedModels, callback) {
|
|
268
|
+
function applySelection() {
|
|
269
|
+
if (typeof preselectedModels !== "undefined") {
|
|
270
|
+
setCheckedModels(preselectedModels || []);
|
|
271
|
+
} else {
|
|
272
|
+
updateModelsCountBadge();
|
|
273
|
+
}
|
|
274
|
+
if (typeof callback === "function") callback();
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (lastModelCatalog && lastModelCatalog.length > 0) {
|
|
278
|
+
renderModelGridFromCatalog(lastModelCatalog);
|
|
279
|
+
applySelection();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
fetchModelCatalog()
|
|
284
|
+
.then(function(catalog) {
|
|
285
|
+
renderModelGridFromCatalog(catalog);
|
|
286
|
+
applySelection();
|
|
287
|
+
})
|
|
288
|
+
.catch(function() {
|
|
289
|
+
// Stale build or network glitch: fall back to the static list so
|
|
290
|
+
// the modal is never empty. The fallback lacks Ollama/Codex/Zen
|
|
291
|
+
// models, but at least existing keys can still be edited.
|
|
292
|
+
renderModelGridFromCatalog(FALLBACK_MODEL_CATALOG);
|
|
293
|
+
applySelection();
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
|
|
152
297
|
function loadKeys() {
|
|
153
298
|
fetch("/api/keys", { headers: authHeaders() })
|
|
154
299
|
.then(function(r) { return r.json(); })
|
|
@@ -248,7 +393,6 @@ function showGenerateModal() {
|
|
|
248
393
|
document.getElementById("keyFormAlias").disabled = false;
|
|
249
394
|
document.getElementById("keyFormUserId").value = "";
|
|
250
395
|
document.getElementById("keyFormUserId").disabled = false;
|
|
251
|
-
selectNoModels();
|
|
252
396
|
document.getElementById("keyFormError").textContent = "";
|
|
253
397
|
document.getElementById("generatedKeyResult").style.display = "none";
|
|
254
398
|
document.getElementById("submitKeyBtn").textContent = "Generate Key";
|
|
@@ -257,6 +401,10 @@ function showGenerateModal() {
|
|
|
257
401
|
var sub = document.getElementById("modalSubtitle");
|
|
258
402
|
if (sub) sub.textContent = "Configure key access and model restrictions";
|
|
259
403
|
document.getElementById("keyModal").classList.add("open");
|
|
404
|
+
// Render the live provider catalog and default to "all models allowed"
|
|
405
|
+
// (empty selection). ensureModelGridRendered reuses the cached catalog
|
|
406
|
+
// when possible, so this opens instantly on the second open.
|
|
407
|
+
ensureModelGridRendered([]);
|
|
260
408
|
}
|
|
261
409
|
|
|
262
410
|
function showEditModal(hash) {
|
|
@@ -271,7 +419,6 @@ function showEditModal(hash) {
|
|
|
271
419
|
document.getElementById("keyFormAlias").disabled = true;
|
|
272
420
|
document.getElementById("keyFormUserId").value = k.userId || "";
|
|
273
421
|
document.getElementById("keyFormUserId").disabled = true;
|
|
274
|
-
setCheckedModels(k.models || []);
|
|
275
422
|
document.getElementById("keyFormError").textContent = "";
|
|
276
423
|
document.getElementById("generatedKeyResult").style.display = "none";
|
|
277
424
|
document.getElementById("submitKeyBtn").textContent = "Save Changes";
|
|
@@ -280,6 +427,9 @@ function showEditModal(hash) {
|
|
|
280
427
|
var sub = document.getElementById("modalSubtitle");
|
|
281
428
|
if (sub) sub.textContent = "Updating model restrictions for alias: " + k.keyAlias;
|
|
282
429
|
document.getElementById("keyModal").classList.add("open");
|
|
430
|
+
// Render the live catalog and preselect the key's existing allowlist
|
|
431
|
+
// (or all models when the key is unrestricted).
|
|
432
|
+
ensureModelGridRendered(k.models || []);
|
|
283
433
|
}
|
|
284
434
|
|
|
285
435
|
function hideModal() {
|
package/src/static/dashboard.js
CHANGED
|
@@ -40,11 +40,44 @@ function isIdleForKickstart(q, now) {
|
|
|
40
40
|
return isRolling5h || isRolling7d;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
function isKickstartSupported(q) {
|
|
44
|
+
if (!q) return false;
|
|
45
|
+
if (q.providerId === "openai-codex") return false;
|
|
46
|
+
var key = String(q.modelKey || "");
|
|
47
|
+
return (
|
|
48
|
+
key !== "openai-codex" &&
|
|
49
|
+
key !== "openai-codex-spark" &&
|
|
50
|
+
key.indexOf("openai-codex:") !== 0
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function getQuotaItemProviderRank(q) {
|
|
55
|
+
var p = q.providerId;
|
|
56
|
+
if (!p) {
|
|
57
|
+
var k = String(q.modelKey || "");
|
|
58
|
+
if (k === "claude" || k === "gemini") p = "google-antigravity";
|
|
59
|
+
else if (k === "session" || k === "weekly") p = "ollama";
|
|
60
|
+
else if (k.indexOf("opencode") === 0 || k === "opencode-zen") p = "opencode-zen";
|
|
61
|
+
else if (k.indexOf("codex") === 0 || k.indexOf("openai-codex") === 0) p = "openai-codex";
|
|
62
|
+
else p = "google-antigravity";
|
|
63
|
+
}
|
|
64
|
+
var ranks = {
|
|
65
|
+
"google-antigravity": 1,
|
|
66
|
+
"ollama": 2,
|
|
67
|
+
"opencode-zen": 3,
|
|
68
|
+
"openai-codex": 4
|
|
69
|
+
};
|
|
70
|
+
return ranks[p] || 99;
|
|
71
|
+
}
|
|
72
|
+
|
|
43
73
|
function renderQuotaBars(account) {
|
|
44
74
|
var quota = account.quota;
|
|
45
75
|
if (!quota || quota.length === 0) return "";
|
|
76
|
+
var sortedQuota = quota.slice().sort(function (a, b) {
|
|
77
|
+
return getQuotaItemProviderRank(a) - getQuotaItemProviderRank(b);
|
|
78
|
+
});
|
|
46
79
|
var now = Date.now();
|
|
47
|
-
var rows =
|
|
80
|
+
var rows = sortedQuota
|
|
48
81
|
.map(function (q) {
|
|
49
82
|
var inFlightForModel = (account.inFlightByModel || {})[q.modelKey] || 0;
|
|
50
83
|
var clearButton =
|
|
@@ -60,7 +93,7 @@ function renderQuotaBars(account) {
|
|
|
60
93
|
: '<button class="btn-clear-flight" title="No in-flight requests for ' +
|
|
61
94
|
escapeHtml(q.displayName) +
|
|
62
95
|
'" disabled>Clear</button>';
|
|
63
|
-
var idle = isIdleForKickstart(q, now);
|
|
96
|
+
var idle = isKickstartSupported(q) && isIdleForKickstart(q, now);
|
|
64
97
|
var kickstartBtn = "";
|
|
65
98
|
var color = quotaBarColor(q.percentRemaining);
|
|
66
99
|
var timerClass = "timer-" + q.timerType;
|
|
@@ -320,20 +353,6 @@ function renderAccounts(data) {
|
|
|
320
353
|
Math.min(100, (cooldownRemaining / Math.max(totalCooldown, 1)) * 100),
|
|
321
354
|
);
|
|
322
355
|
}
|
|
323
|
-
var modelBadges = (a.activeForModels || [])
|
|
324
|
-
.map(function (m) {
|
|
325
|
-
if (m.startsWith("claude")) {
|
|
326
|
-
return '<span class="badge badge-model">CLAUDE</span>';
|
|
327
|
-
}
|
|
328
|
-
if (m === "gemini-3.1-pro") {
|
|
329
|
-
return '<span class="badge badge-model">PRO</span>';
|
|
330
|
-
}
|
|
331
|
-
if (m === "gemini-3.5-flash") {
|
|
332
|
-
return '<span class="badge badge-model">FLASH</span>';
|
|
333
|
-
}
|
|
334
|
-
return "";
|
|
335
|
-
})
|
|
336
|
-
.join("");
|
|
337
356
|
var tierLabel = a.tier ? String(a.tier).toUpperCase() : "UNKNOWN";
|
|
338
357
|
|
|
339
358
|
return (
|
|
@@ -382,7 +401,6 @@ function renderAccounts(data) {
|
|
|
382
401
|
"ULTRA</div>" +
|
|
383
402
|
"</div>" +
|
|
384
403
|
"</div>" +
|
|
385
|
-
modelBadges +
|
|
386
404
|
"</div>" +
|
|
387
405
|
"</div>" +
|
|
388
406
|
'<div class="card-email">' +
|
|
@@ -472,7 +490,7 @@ function renderAccounts(data) {
|
|
|
472
490
|
: "Allow Fresh On This Account") +
|
|
473
491
|
"</button>" +
|
|
474
492
|
((a.quota || []).some(function (q) {
|
|
475
|
-
return isIdleForKickstart(q, Date.now());
|
|
493
|
+
return isKickstartSupported(q) && isIdleForKickstart(q, Date.now());
|
|
476
494
|
})
|
|
477
495
|
? '<button class="btn-enable" onclick="kickstartAllTimers(\'' +
|
|
478
496
|
jsString(a.email) +
|
|
@@ -1032,22 +1050,99 @@ function renderAttentionItem(title, description, tags, type) {
|
|
|
1032
1050
|
}
|
|
1033
1051
|
|
|
1034
1052
|
var TOKEN_MODEL_COLORS = {
|
|
1035
|
-
|
|
1036
|
-
"claude-
|
|
1037
|
-
"
|
|
1038
|
-
"
|
|
1039
|
-
"
|
|
1040
|
-
"
|
|
1041
|
-
"
|
|
1042
|
-
"
|
|
1043
|
-
"
|
|
1044
|
-
"
|
|
1045
|
-
|
|
1046
|
-
|
|
1053
|
+
// Claude Pool (Rojos) — de más caro a más barato
|
|
1054
|
+
"claude-opus-4-6-thinking": "#b91c1c", // Opus (Rojo intenso/oscuro)
|
|
1055
|
+
"claude-opus-4-5-thinking": "#b91c1c",
|
|
1056
|
+
"claude-opus-4-5": "#b91c1c",
|
|
1057
|
+
"claude-sonnet-4-6": "#ef4444", // Sonnet (Rojo vivo)
|
|
1058
|
+
"claude-sonnet-4-6-thinking": "#ef4444",
|
|
1059
|
+
"claude-sonnet-4-5": "#ef4444",
|
|
1060
|
+
"claude-sonnet-4-5-thinking": "#ef4444",
|
|
1061
|
+
"gpt-oss-120b-medium": "#f87171", // GPT-OSS Antigravity (Rojo claro/coral)
|
|
1062
|
+
"gpt-oss-120b": "#f87171",
|
|
1063
|
+
|
|
1064
|
+
// Gemini Pool (Azules) — de más caro a más barato
|
|
1065
|
+
"gemini-3.1-pro": "#1d4ed8", // Gemini 3.1 Pro (Azul rey oscuro/intenso)
|
|
1066
|
+
"gemini-3.1-pro-high": "#1d4ed8",
|
|
1067
|
+
"gemini-3.1-pro-low": "#1d4ed8",
|
|
1068
|
+
"gemini-3-pro-high": "#1d4ed8",
|
|
1069
|
+
"gemini-3-pro-low": "#1d4ed8",
|
|
1070
|
+
"gemini-3.5-flash": "#2563eb", // Gemini 3.5 Flash (Azul rey medio)
|
|
1071
|
+
"gemini-3.5-flash-high": "#2563eb",
|
|
1072
|
+
"gemini-3.5-flash-medium": "#2563eb",
|
|
1073
|
+
"gemini-3.5-flash-low": "#2563eb",
|
|
1074
|
+
"gemini-3-flash-agent": "#2563eb",
|
|
1075
|
+
"gemini-3.6-flash": "#38bdf8", // Gemini 3.6 Flash (Azul cielo brillante)
|
|
1076
|
+
"gemini-3.6-flash-high": "#38bdf8",
|
|
1077
|
+
"gemini-3.6-flash-medium": "#38bdf8",
|
|
1078
|
+
"gemini-3.6-flash-low": "#38bdf8",
|
|
1079
|
+
"gemini-3.6-flash-tiered": "#38bdf8",
|
|
1080
|
+
"gemini-3-flash": "#93c5fd", // Gemini 3 Flash (Azul pastel claro)
|
|
1081
|
+
|
|
1082
|
+
// Codex Pool (Amarillos) — de más caro a más barato
|
|
1083
|
+
"gpt-5.6-sol": "#a16207", // GPT-5.6 Sol (Amarillo oscuro/marrón mostaza)
|
|
1084
|
+
"gpt-5.6-terra": "#eab308", // GPT-5.6 Terra (Amarillo vivo)
|
|
1085
|
+
"gpt-5.6-luna": "#fde047", // GPT-5.6 Luna (Amarillo pastel suave)
|
|
1086
|
+
|
|
1087
|
+
// Ollama Pool (Verdes) — de más caro a más barato por familia
|
|
1088
|
+
"kimi-k3": "#047857", // Familia Kimi (Verde bosque/esmeralda oscuro)
|
|
1089
|
+
"kimi-k2.7-code": "#047857",
|
|
1090
|
+
"kimi-k2.6": "#047857",
|
|
1091
|
+
"qwen3.5:397b": "#0f766e", // Familia Qwen (Verde pino/teal oscuro)
|
|
1092
|
+
"glm-5.2": "#10b981", // Familia GLM (Verde esmeralda)
|
|
1093
|
+
"glm-5.1": "#10b981",
|
|
1094
|
+
"nemotron-3-ultra": "#15803d", // Nemotron Super/Ultra (Verde intenso)
|
|
1095
|
+
"nemotron-3-super": "#15803d",
|
|
1096
|
+
"mistral-large-3:675b": "#22c55e", // Mistral / Nemotron Nano (Verde brillante)
|
|
1097
|
+
"nemotron-3-nano:30b": "#22c55e",
|
|
1098
|
+
"gemma4:31b": "#65a30d", // Gemma 4 (Verde oliva/lima)
|
|
1099
|
+
"minimax-m3": "#84cc16", // Familia MiniMax (Verde lima)
|
|
1100
|
+
"minimax-m2.7": "#84cc16",
|
|
1101
|
+
"deepseek-v4-pro": "#2dd4bf", // DeepSeek Pro (Verde menta/teal claro)
|
|
1102
|
+
"gpt-oss:120b": "#86efac", // GPT-OSS 120B Ollama (Verde claro)
|
|
1103
|
+
"deepseek-v4-flash:preview": "#5eead4", // DeepSeek Flash (Verde menta suave)
|
|
1104
|
+
"deepseek-v4-flash:0731": "#5eead4",
|
|
1105
|
+
"gpt-oss:20b": "#dcfce7", // GPT-OSS 20B Ollama (Verde pastel muy claro)
|
|
1106
|
+
|
|
1107
|
+
__other__: "#10b981",
|
|
1047
1108
|
};
|
|
1048
1109
|
|
|
1049
1110
|
function getModelColor(model) {
|
|
1050
|
-
|
|
1111
|
+
if (!model) return TOKEN_MODEL_COLORS["__other__"];
|
|
1112
|
+
if (TOKEN_MODEL_COLORS[model]) return TOKEN_MODEL_COLORS[model];
|
|
1113
|
+
|
|
1114
|
+
var lower = model.toLowerCase();
|
|
1115
|
+
// Family fallback resolution
|
|
1116
|
+
// Claude pool (Rojos)
|
|
1117
|
+
if (lower.indexOf("opus") !== -1) return "#b91c1c";
|
|
1118
|
+
if (lower.indexOf("sonnet") !== -1 || lower.indexOf("claude") !== -1) return "#ef4444";
|
|
1119
|
+
if (lower === "gpt-oss-120b" || lower === "gpt-oss-120b-medium") return "#f87171";
|
|
1120
|
+
|
|
1121
|
+
// Gemini pool (Azules)
|
|
1122
|
+
if (lower.indexOf("3.1-pro") !== -1 || lower.indexOf("3-pro") !== -1) return "#1d4ed8";
|
|
1123
|
+
if (lower.indexOf("3.5-flash") !== -1) return "#2563eb";
|
|
1124
|
+
if (lower.indexOf("3.6-flash") !== -1) return "#38bdf8";
|
|
1125
|
+
if (lower.indexOf("gemini") !== -1 || lower.indexOf("3-flash") !== -1) return "#93c5fd";
|
|
1126
|
+
|
|
1127
|
+
// Codex pool (Amarillos)
|
|
1128
|
+
if (lower.indexOf("gpt-5.6-sol") !== -1) return "#a16207";
|
|
1129
|
+
if (lower.indexOf("gpt-5.6-terra") !== -1) return "#eab308";
|
|
1130
|
+
if (lower.indexOf("gpt-5.6-luna") !== -1) return "#fde047";
|
|
1131
|
+
|
|
1132
|
+
// Ollama pool (Verdes)
|
|
1133
|
+
if (lower.indexOf("kimi") !== -1) return "#047857";
|
|
1134
|
+
if (lower.indexOf("qwen") !== -1) return "#0f766e";
|
|
1135
|
+
if (lower.indexOf("glm") !== -1) return "#10b981";
|
|
1136
|
+
if (lower.indexOf("nemotron-3-super") !== -1 || lower.indexOf("nemotron-3-ultra") !== -1) return "#15803d";
|
|
1137
|
+
if (lower.indexOf("mistral") !== -1 || lower.indexOf("nemotron") !== -1) return "#22c55e";
|
|
1138
|
+
if (lower.indexOf("gemma") !== -1) return "#65a30d";
|
|
1139
|
+
if (lower.indexOf("minimax") !== -1) return "#84cc16";
|
|
1140
|
+
if (lower.indexOf("deepseek-v4-pro") !== -1) return "#2dd4bf";
|
|
1141
|
+
if (lower.indexOf("deepseek") !== -1) return "#5eead4";
|
|
1142
|
+
if (lower.indexOf("gpt-oss:120b") !== -1) return "#86efac";
|
|
1143
|
+
if (lower.indexOf("gpt-oss") !== -1) return "#dcfce7";
|
|
1144
|
+
|
|
1145
|
+
return "#10b981";
|
|
1051
1146
|
}
|
|
1052
1147
|
|
|
1053
1148
|
function formatTokenCount(n) {
|
|
@@ -1073,7 +1168,15 @@ var MODEL_PRICING_CLIENT = {
|
|
|
1073
1168
|
"gemini-3.6-flash-medium": { input: 1.5, output: 7.5 },
|
|
1074
1169
|
"gemini-3.6-flash-low": { input: 1.5, output: 7.5 },
|
|
1075
1170
|
"gemini-3.6-flash-tiered": { input: 1.5, output: 7.5 },
|
|
1171
|
+
// Gemini 3.7 Flash tiered — public Gemini API pricing, verified 2026-08-13.
|
|
1172
|
+
// Introductory rates through 2026-12-31; from 2027-01-01 these double to
|
|
1173
|
+
// input 1.50 / output 7.50 per 1M tokens — update this entry then.
|
|
1174
|
+
"gemini-3.7-flash-tiered": { input: 0.75, output: 3.75 },
|
|
1076
1175
|
"gpt-oss-120b-medium": { input: 2.0, output: 10.0 },
|
|
1176
|
+
// OpenAI Codex GPT-5.6 models — mirrors MODEL_PRICING in types.ts.
|
|
1177
|
+
"gpt-5.6-sol": { input: 5.0, output: 30.0 },
|
|
1178
|
+
"gpt-5.6-terra": { input: 2.0, output: 12.0 },
|
|
1179
|
+
"gpt-5.6-luna": { input: 0.2, output: 1.2 },
|
|
1077
1180
|
// Ollama Cloud models — mirrors MODEL_PRICING in src/types.ts
|
|
1078
1181
|
"gpt-oss:20b": { input: 0.075, output: 0.3 },
|
|
1079
1182
|
"gpt-oss:120b": { input: 0.15, output: 0.6 },
|
|
@@ -1093,6 +1196,14 @@ var MODEL_PRICING_CLIENT = {
|
|
|
1093
1196
|
"nemotron-3-nano:30b": { input: 0.5, output: 1.5 },
|
|
1094
1197
|
"nemotron-3-super": { input: 0.6, output: 1.8 },
|
|
1095
1198
|
"nemotron-3-ultra": { input: 0.6, output: 1.8 },
|
|
1199
|
+
// OpenCode Zen free models — mirrors MODEL_PRICING in src/types.ts
|
|
1200
|
+
"deepseek-v4-flash-free": { input: 0.14, output: 0.28 },
|
|
1201
|
+
"nemotron-3.5-lightning-free": { input: 0.35, output: 1.05 },
|
|
1202
|
+
"nemotron-3-ultra-free": { input: 0.6, output: 1.8 },
|
|
1203
|
+
"mimo-v2.5-free": { input: 0.15, output: 0.6 },
|
|
1204
|
+
"hy3-free": { input: 0.25, output: 1.0 },
|
|
1205
|
+
"ling-3.0-tiny-free": { input: 0.05, output: 0.2 },
|
|
1206
|
+
"laguna-s-2.1-free": { input: 0.2, output: 0.8 },
|
|
1096
1207
|
};
|
|
1097
1208
|
|
|
1098
1209
|
function getModelPricingClient(m) {
|
|
@@ -1100,6 +1211,7 @@ function getModelPricingClient(m) {
|
|
|
1100
1211
|
var lower = (m || "").toLowerCase();
|
|
1101
1212
|
if (lower.indexOf("opus") !== -1) return MODEL_PRICING_CLIENT["claude-opus-4-6-thinking"];
|
|
1102
1213
|
if (lower.indexOf("sonnet") !== -1) return MODEL_PRICING_CLIENT["claude-sonnet-4-6"];
|
|
1214
|
+
if (lower.indexOf("3.7-flash") !== -1) return MODEL_PRICING_CLIENT["gemini-3.7-flash-tiered"];
|
|
1103
1215
|
if (lower.indexOf("3.6-flash") !== -1) return MODEL_PRICING_CLIENT["gemini-3.6-flash-high"];
|
|
1104
1216
|
if (lower.indexOf("3.5-flash") !== -1) return MODEL_PRICING_CLIENT["gemini-3.5-flash-high"];
|
|
1105
1217
|
if (lower.indexOf("flash") !== -1) return MODEL_PRICING_CLIENT["gemini-3-flash"];
|
|
@@ -1127,6 +1239,23 @@ function calcSavingsFromBuckets(buckets) {
|
|
|
1127
1239
|
return { totalUsd: totalUsd, byModel: byModel };
|
|
1128
1240
|
}
|
|
1129
1241
|
|
|
1242
|
+
function formatSavingsUsd(usd) {
|
|
1243
|
+
if (!(usd > 0)) return "";
|
|
1244
|
+
if (usd >= 0.01) return usd.toFixed(2);
|
|
1245
|
+
if (usd >= 0.0001) return usd.toFixed(4);
|
|
1246
|
+
if (usd >= 0.000001) return usd.toFixed(6);
|
|
1247
|
+
return usd.toFixed(8);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
function formatModelSavingsLabel(modelSavings) {
|
|
1251
|
+
if (!modelSavings || !(modelSavings.totalUsd > 0)) return "";
|
|
1252
|
+
return (
|
|
1253
|
+
' <span style="color:var(--green)">$' +
|
|
1254
|
+
formatSavingsUsd(modelSavings.totalUsd) +
|
|
1255
|
+
"</span>"
|
|
1256
|
+
);
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1130
1259
|
window.__tokenView = "1h";
|
|
1131
1260
|
|
|
1132
1261
|
function exportData(format) {
|
|
@@ -1588,12 +1717,7 @@ function renderTokenChart(tokenUsage) {
|
|
|
1588
1717
|
legend.innerHTML = models
|
|
1589
1718
|
.map(function (m) {
|
|
1590
1719
|
var modelSavings = (savings.byModel || {})[m];
|
|
1591
|
-
var savingsLabel =
|
|
1592
|
-
modelSavings && modelSavings.totalUsd > 0.01
|
|
1593
|
-
? ' <span style="color:var(--green)">$' +
|
|
1594
|
-
modelSavings.totalUsd.toFixed(2) +
|
|
1595
|
-
"</span>"
|
|
1596
|
-
: "";
|
|
1720
|
+
var savingsLabel = formatModelSavingsLabel(modelSavings);
|
|
1597
1721
|
return (
|
|
1598
1722
|
'<div style="display:flex;align-items:center;gap:4px">' +
|
|
1599
1723
|
'<div style="width:10px;height:10px;border-radius:2px;background:' +
|
package/src/types.ts
CHANGED
|
@@ -42,7 +42,7 @@ export type RoutingRejectionReason =
|
|
|
42
42
|
* and an Ollama Cloud API key).
|
|
43
43
|
*/
|
|
44
44
|
export interface ProviderCredential {
|
|
45
|
-
/** Provider id: "google-antigravity" or "
|
|
45
|
+
/** Provider id: "google-antigravity", "ollama", or "openai-codex". */
|
|
46
46
|
provider: string;
|
|
47
47
|
/** Ollama Cloud: static API key (never expires). */
|
|
48
48
|
apiKey?: string;
|
|
@@ -50,6 +50,8 @@ export interface ProviderCredential {
|
|
|
50
50
|
refreshToken?: string;
|
|
51
51
|
/** Google Antigravity: Cloud project id. */
|
|
52
52
|
projectId?: string;
|
|
53
|
+
/** Codex/ChatGPT workspace or account id from the OAuth identity claim. */
|
|
54
|
+
providerAccountId?: string;
|
|
53
55
|
// How the projectId was obtained.
|
|
54
56
|
projectSource?: "google" | "manual";
|
|
55
57
|
/** Optional HTTP(S) or SOCKS5 egress proxy for this provider credential. */
|
|
@@ -79,6 +81,10 @@ export interface AccountConfig {
|
|
|
79
81
|
refreshToken?: string;
|
|
80
82
|
/** @deprecated legacy Google Antigravity Cloud project id. */
|
|
81
83
|
projectId?: string;
|
|
84
|
+
/** @deprecated legacy Codex refresh token, migrated into credentials. */
|
|
85
|
+
codexRefreshToken?: string;
|
|
86
|
+
/** @deprecated legacy Codex account id, migrated into credentials. */
|
|
87
|
+
codexAccountId?: string;
|
|
82
88
|
/** @deprecated migrated into credentials. */
|
|
83
89
|
projectSource?: "google" | "manual";
|
|
84
90
|
/** @deprecated use credentials[].proxyUrl for provider-scoped routing. */
|
|
@@ -220,6 +226,8 @@ export interface ModelSpecConfig {
|
|
|
220
226
|
export interface ModelQuota {
|
|
221
227
|
modelKey: string;
|
|
222
228
|
displayName: string;
|
|
229
|
+
/** Owner of this quota pool when the account has several providers. */
|
|
230
|
+
providerId?: string;
|
|
223
231
|
percentRemaining: number;
|
|
224
232
|
/** Raw usage fraction (0..1) when the provider reports one (Ollama). */
|
|
225
233
|
usageRaw?: number;
|
|
@@ -269,6 +277,7 @@ export const QUOTA_MODEL_KEYS: Record<
|
|
|
269
277
|
"gemini-3.6-flash-medium",
|
|
270
278
|
"gemini-3.6-flash-low",
|
|
271
279
|
"gemini-3.6-flash-tiered",
|
|
280
|
+
"gemini-3.7-flash-tiered",
|
|
272
281
|
],
|
|
273
282
|
display: "Gemini",
|
|
274
283
|
},
|
|
@@ -277,6 +286,16 @@ export const QUOTA_MODEL_KEYS: Record<
|
|
|
277
286
|
// Map request model names to quota model keys (family buckets).
|
|
278
287
|
export function resolveQuotaModelKey(requestModel: string): string | null {
|
|
279
288
|
const lower = requestModel.toLowerCase();
|
|
289
|
+
if (
|
|
290
|
+
lower === "deepseek-v4-flash-free" ||
|
|
291
|
+
lower === "nemotron-3.5-lightning-free" ||
|
|
292
|
+
lower === "nemotron-3-ultra-free" ||
|
|
293
|
+
lower === "mimo-v2.5-free" ||
|
|
294
|
+
lower === "hy3-free" ||
|
|
295
|
+
lower.endsWith("-free")
|
|
296
|
+
) {
|
|
297
|
+
return "opencode-zen";
|
|
298
|
+
}
|
|
280
299
|
// Claude family: every Claude variant and gpt-oss share one bucket.
|
|
281
300
|
if (
|
|
282
301
|
lower.includes("claude") ||
|
|
@@ -327,6 +346,17 @@ export function resolveDisplayModelKey(requestModel: string): string {
|
|
|
327
346
|
if (lower.includes("-high")) return "gemini-3.6-flash-high";
|
|
328
347
|
return "gemini-3.6-flash-high"; // unspecified variant
|
|
329
348
|
}
|
|
349
|
+
// Gemini 3.7 Flash — only the tiered variant exists. Unsupported
|
|
350
|
+
// virtual variants (low/medium/high) intentionally fall through to the
|
|
351
|
+
// generic Flash fallback below instead of resolving as supported models.
|
|
352
|
+
if (
|
|
353
|
+
lower.includes("gemini") &&
|
|
354
|
+
lower.includes("3.7") &&
|
|
355
|
+
lower.includes("flash") &&
|
|
356
|
+
lower.includes("-tiered")
|
|
357
|
+
) {
|
|
358
|
+
return "gemini-3.7-flash-tiered";
|
|
359
|
+
}
|
|
330
360
|
// Gemini 3.5 Flash — distinguish medium vs high
|
|
331
361
|
if (
|
|
332
362
|
lower.includes("gemini") &&
|
|
@@ -350,6 +380,14 @@ export interface AccountRuntime {
|
|
|
350
380
|
config: AccountConfig;
|
|
351
381
|
accessToken: string | null;
|
|
352
382
|
tokenExpires: number;
|
|
383
|
+
/** Provider-scoped access tokens. Legacy Google/Ollama state still uses the fields above. */
|
|
384
|
+
providerTokens?: Record<
|
|
385
|
+
string,
|
|
386
|
+
{ accessToken: string | null; tokenExpires: number }
|
|
387
|
+
>;
|
|
388
|
+
/** Provider-local auth failures/cooldowns; Google/Ollama remain routable. */
|
|
389
|
+
invalidProviders?: Record<string, string>;
|
|
390
|
+
providerCooldowns?: Record<string, number>;
|
|
353
391
|
// Rotation tracking (per-model via rotator)
|
|
354
392
|
requestsSinceRotation: number;
|
|
355
393
|
totalRequests: number;
|
|
@@ -476,6 +514,7 @@ export interface StatusResponse {
|
|
|
476
514
|
};
|
|
477
515
|
routingDiagnostics: Record<string, RoutingModelDiagnostics>;
|
|
478
516
|
ollamaModels: string[];
|
|
517
|
+
codexModels?: string[];
|
|
479
518
|
// Present only when at least one account carries an ollama credential.
|
|
480
519
|
modelTierAccess?: Record<string, ModelTierAccess>;
|
|
481
520
|
predictions: Record<string, ExhaustionPrediction>;
|
|
@@ -538,6 +577,10 @@ export interface AccountStatus {
|
|
|
538
577
|
lastError: string | null;
|
|
539
578
|
consecutiveErrors: number;
|
|
540
579
|
hasValidToken: boolean;
|
|
580
|
+
/** Provider-scoped authentication failures; sibling providers may remain usable. */
|
|
581
|
+
invalidProviders?: Record<string, string>;
|
|
582
|
+
/** Provider-scoped cooldown deadlines, kept separate from account breakers. */
|
|
583
|
+
providerCooldowns?: Record<string, number>;
|
|
541
584
|
quota: ModelQuota[];
|
|
542
585
|
inFlightRequests: number;
|
|
543
586
|
inFlightByModel: Record<string, number>;
|
|
@@ -722,8 +765,39 @@ export const MODEL_PRICING: Record<
|
|
|
722
765
|
cachingPer1M: 0.15,
|
|
723
766
|
cachingStoragePer1MPerHour: 1.0,
|
|
724
767
|
},
|
|
768
|
+
// Gemini 3.7 Flash tiered — public Gemini API equivalent-value pricing,
|
|
769
|
+
// verified on the official Gemini API / Google Cloud pricing pages
|
|
770
|
+
// 2026-08-13. Introductory rates through 2026-12-31. From 2027-01-01
|
|
771
|
+
// these double to: input 1.50, output 7.50, cached input 0.15, cache
|
|
772
|
+
// storage 1.00 (USD per 1M tokens / per 1M tokens/hour) — update this
|
|
773
|
+
// static entry when the introductory period ends.
|
|
774
|
+
"gemini-3.7-flash-tiered": {
|
|
775
|
+
inputPer1M: 0.75,
|
|
776
|
+
outputPer1M: 3.75,
|
|
777
|
+
cachingPer1M: 0.075,
|
|
778
|
+
cachingStoragePer1MPerHour: 0.5,
|
|
779
|
+
},
|
|
725
780
|
"gpt-oss-120b-medium": { inputPer1M: 2.0, outputPer1M: 10.0 },
|
|
726
781
|
|
|
782
|
+
// OpenAI Codex GPT-5.6 models — official OpenAI API pricing checked
|
|
783
|
+
// 2026-08-11. Token usage currently records aggregate input/output tokens;
|
|
784
|
+
// cache rates are retained for spend metadata but are not applied separately.
|
|
785
|
+
"gpt-5.6-sol": {
|
|
786
|
+
inputPer1M: 5.0,
|
|
787
|
+
outputPer1M: 30.0,
|
|
788
|
+
cachingPer1M: 0.50,
|
|
789
|
+
},
|
|
790
|
+
"gpt-5.6-terra": {
|
|
791
|
+
inputPer1M: 2.0,
|
|
792
|
+
outputPer1M: 12.0,
|
|
793
|
+
cachingPer1M: 0.20,
|
|
794
|
+
},
|
|
795
|
+
"gpt-5.6-luna": {
|
|
796
|
+
inputPer1M: 0.20,
|
|
797
|
+
outputPer1M: 1.20,
|
|
798
|
+
cachingPer1M: 0.02,
|
|
799
|
+
},
|
|
800
|
+
|
|
727
801
|
// Ollama Cloud model pricing (USD per 1M tokens). Sourced from the
|
|
728
802
|
// ~/ollama-rotator project (verified 2026-08-09).
|
|
729
803
|
"gpt-oss:20b": { inputPer1M: 0.075, outputPer1M: 0.30 },
|
|
@@ -744,6 +818,14 @@ export const MODEL_PRICING: Record<
|
|
|
744
818
|
"nemotron-3-nano:30b": { inputPer1M: 0.50, outputPer1M: 1.50 },
|
|
745
819
|
"nemotron-3-super": { inputPer1M: 0.60, outputPer1M: 1.80 },
|
|
746
820
|
"nemotron-3-ultra": { inputPer1M: 0.60, outputPer1M: 1.80 },
|
|
821
|
+
|
|
822
|
+
// OpenCode Zen free models — equivalent market rates (USD per 1M tokens) for savings tracking
|
|
823
|
+
"deepseek-v4-flash-free": { inputPer1M: 0.14, outputPer1M: 0.28, cachingPer1M: 0.0028 },
|
|
824
|
+
"nemotron-3.5-lightning-free": { inputPer1M: 0.35, outputPer1M: 1.05 },
|
|
825
|
+
"nemotron-3-ultra-free": { inputPer1M: 0.60, outputPer1M: 1.80 },
|
|
826
|
+
"mimo-v2.5-free": { inputPer1M: 0.15, outputPer1M: 0.60 },
|
|
827
|
+
"hy3-free": { inputPer1M: 0.25, outputPer1M: 1.00 },
|
|
828
|
+
|
|
747
829
|
};
|
|
748
830
|
|
|
749
831
|
// Which Ollama Cloud models respond on which subscription tiers, verified
|
package/src/validators.ts
CHANGED
|
@@ -66,8 +66,13 @@ export function validateAccountConfig(value: unknown, path = "account"): Validat
|
|
|
66
66
|
if (!isNonEmptyString(cred.provider)) errors.push(`${cpath}.provider must be a non-empty string`);
|
|
67
67
|
const proxyError = getProxyConfigurationError(cred.proxyUrl);
|
|
68
68
|
if (proxyError) errors.push(`${cpath}.${proxyError}`);
|
|
69
|
-
if (cred.provider === "ollama") {
|
|
69
|
+
if (cred.provider === "ollama" || cred.provider === "opencode-zen") {
|
|
70
70
|
if (!isNonEmptyString(cred.apiKey)) errors.push(`${cpath}.apiKey must be a non-empty string`);
|
|
71
|
+
} else if (cred.provider === "openai-codex") {
|
|
72
|
+
if (!isNonEmptyString(cred.refreshToken)) errors.push(`${cpath}.refreshToken must be a non-empty string`);
|
|
73
|
+
if (cred.providerAccountId !== undefined && !isNonEmptyString(cred.providerAccountId)) {
|
|
74
|
+
errors.push(`${cpath}.providerAccountId must be a non-empty string when provided`);
|
|
75
|
+
}
|
|
71
76
|
} else {
|
|
72
77
|
if (!isNonEmptyString(cred.refreshToken)) errors.push(`${cpath}.refreshToken must be a non-empty string`);
|
|
73
78
|
if (!isNonEmptyString(cred.projectId)) errors.push(`${cpath}.projectId must be a non-empty string`);
|
|
@@ -75,8 +80,12 @@ export function validateAccountConfig(value: unknown, path = "account"): Validat
|
|
|
75
80
|
}
|
|
76
81
|
} else {
|
|
77
82
|
const provider = typeof value.provider === "string" ? value.provider : "google-antigravity";
|
|
78
|
-
if (provider === "ollama") {
|
|
83
|
+
if (provider === "ollama" || provider === "opencode-zen") {
|
|
79
84
|
if (!isNonEmptyString(value.apiKey)) errors.push(`${path}.apiKey must be a non-empty string`);
|
|
85
|
+
} else if (provider === "openai-codex") {
|
|
86
|
+
if (!isNonEmptyString(value.codexRefreshToken ?? value.refreshToken)) {
|
|
87
|
+
errors.push(`${path}.codexRefreshToken or refreshToken must be a non-empty string`);
|
|
88
|
+
}
|
|
80
89
|
} else {
|
|
81
90
|
if (!isNonEmptyString(value.refreshToken)) errors.push(`${path}.refreshToken must be a non-empty string`);
|
|
82
91
|
if (!isNonEmptyString(value.projectId)) errors.push(`${path}.projectId must be a non-empty string`);
|