tuxevil-rotator 3.0.0 → 3.1.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.
@@ -40,6 +40,17 @@ 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
+
43
54
  function renderQuotaBars(account) {
44
55
  var quota = account.quota;
45
56
  if (!quota || quota.length === 0) return "";
@@ -60,7 +71,7 @@ function renderQuotaBars(account) {
60
71
  : '<button class="btn-clear-flight" title="No in-flight requests for ' +
61
72
  escapeHtml(q.displayName) +
62
73
  '" disabled>Clear</button>';
63
- var idle = isIdleForKickstart(q, now);
74
+ var idle = isKickstartSupported(q) && isIdleForKickstart(q, now);
64
75
  var kickstartBtn = "";
65
76
  var color = quotaBarColor(q.percentRemaining);
66
77
  var timerClass = "timer-" + q.timerType;
@@ -472,7 +483,7 @@ function renderAccounts(data) {
472
483
  : "Allow Fresh On This Account") +
473
484
  "</button>" +
474
485
  ((a.quota || []).some(function (q) {
475
- return isIdleForKickstart(q, Date.now());
486
+ return isKickstartSupported(q) && isIdleForKickstart(q, Date.now());
476
487
  })
477
488
  ? '<button class="btn-enable" onclick="kickstartAllTimers(\'' +
478
489
  jsString(a.email) +
@@ -1032,22 +1043,99 @@ function renderAttentionItem(title, description, tags, type) {
1032
1043
  }
1033
1044
 
1034
1045
  var TOKEN_MODEL_COLORS = {
1035
- "claude-opus-4-6-thinking": "#ef4444", // Rojo
1036
- "claude-sonnet-4-6": "#f97316", // Naranja
1037
- "gemini-3.1-pro-high": "#3b82f6", // Azul
1038
- "gemini-3.1-pro-low": "#38bdf8", // Celeste
1039
- "gemini-3-flash": "#4ade80", // Verde
1040
- "gemini-3.5-flash-low": "#a3e635", // Lime (legacy alias)
1041
- "gemini-3.5-flash-medium": "#a3e635", // Lime
1042
- "gemini-3.5-flash-high": "#84cc16", // Darker Lime
1043
- "gemini-3.5-flash": "#84cc16",
1044
- "gemini-3.1-pro": "#fb923c", // Fallback genérico
1045
- "gpt-oss-120b-medium": "#a855f7", // Purpura
1046
- __other__: "#6b7280",
1046
+ // Claude Pool (Rojos) — de más caro a más barato
1047
+ "claude-opus-4-6-thinking": "#b91c1c", // Opus (Rojo intenso/oscuro)
1048
+ "claude-opus-4-5-thinking": "#b91c1c",
1049
+ "claude-opus-4-5": "#b91c1c",
1050
+ "claude-sonnet-4-6": "#ef4444", // Sonnet (Rojo vivo)
1051
+ "claude-sonnet-4-6-thinking": "#ef4444",
1052
+ "claude-sonnet-4-5": "#ef4444",
1053
+ "claude-sonnet-4-5-thinking": "#ef4444",
1054
+ "gpt-oss-120b-medium": "#f87171", // GPT-OSS Antigravity (Rojo claro/coral)
1055
+ "gpt-oss-120b": "#f87171",
1056
+
1057
+ // Gemini Pool (Azules) — de más caro a más barato
1058
+ "gemini-3.1-pro": "#1d4ed8", // Gemini 3.1 Pro (Azul rey oscuro/intenso)
1059
+ "gemini-3.1-pro-high": "#1d4ed8",
1060
+ "gemini-3.1-pro-low": "#1d4ed8",
1061
+ "gemini-3-pro-high": "#1d4ed8",
1062
+ "gemini-3-pro-low": "#1d4ed8",
1063
+ "gemini-3.5-flash": "#2563eb", // Gemini 3.5 Flash (Azul rey medio)
1064
+ "gemini-3.5-flash-high": "#2563eb",
1065
+ "gemini-3.5-flash-medium": "#2563eb",
1066
+ "gemini-3.5-flash-low": "#2563eb",
1067
+ "gemini-3-flash-agent": "#2563eb",
1068
+ "gemini-3.6-flash": "#38bdf8", // Gemini 3.6 Flash (Azul cielo brillante)
1069
+ "gemini-3.6-flash-high": "#38bdf8",
1070
+ "gemini-3.6-flash-medium": "#38bdf8",
1071
+ "gemini-3.6-flash-low": "#38bdf8",
1072
+ "gemini-3.6-flash-tiered": "#38bdf8",
1073
+ "gemini-3-flash": "#93c5fd", // Gemini 3 Flash (Azul pastel claro)
1074
+
1075
+ // Codex Pool (Amarillos) — de más caro a más barato
1076
+ "gpt-5.6-sol": "#a16207", // GPT-5.6 Sol (Amarillo oscuro/marrón mostaza)
1077
+ "gpt-5.6-terra": "#eab308", // GPT-5.6 Terra (Amarillo vivo)
1078
+ "gpt-5.6-luna": "#fde047", // GPT-5.6 Luna (Amarillo pastel suave)
1079
+
1080
+ // Ollama Pool (Verdes) — de más caro a más barato por familia
1081
+ "kimi-k3": "#047857", // Familia Kimi (Verde bosque/esmeralda oscuro)
1082
+ "kimi-k2.7-code": "#047857",
1083
+ "kimi-k2.6": "#047857",
1084
+ "qwen3.5:397b": "#0f766e", // Familia Qwen (Verde pino/teal oscuro)
1085
+ "glm-5.2": "#10b981", // Familia GLM (Verde esmeralda)
1086
+ "glm-5.1": "#10b981",
1087
+ "nemotron-3-ultra": "#15803d", // Nemotron Super/Ultra (Verde intenso)
1088
+ "nemotron-3-super": "#15803d",
1089
+ "mistral-large-3:675b": "#22c55e", // Mistral / Nemotron Nano (Verde brillante)
1090
+ "nemotron-3-nano:30b": "#22c55e",
1091
+ "gemma4:31b": "#65a30d", // Gemma 4 (Verde oliva/lima)
1092
+ "minimax-m3": "#84cc16", // Familia MiniMax (Verde lima)
1093
+ "minimax-m2.7": "#84cc16",
1094
+ "deepseek-v4-pro": "#2dd4bf", // DeepSeek Pro (Verde menta/teal claro)
1095
+ "gpt-oss:120b": "#86efac", // GPT-OSS 120B Ollama (Verde claro)
1096
+ "deepseek-v4-flash:preview": "#5eead4", // DeepSeek Flash (Verde menta suave)
1097
+ "deepseek-v4-flash:0731": "#5eead4",
1098
+ "gpt-oss:20b": "#dcfce7", // GPT-OSS 20B Ollama (Verde pastel muy claro)
1099
+
1100
+ __other__: "#10b981",
1047
1101
  };
1048
1102
 
1049
1103
  function getModelColor(model) {
1050
- return TOKEN_MODEL_COLORS[model] || TOKEN_MODEL_COLORS["__other__"];
1104
+ if (!model) return TOKEN_MODEL_COLORS["__other__"];
1105
+ if (TOKEN_MODEL_COLORS[model]) return TOKEN_MODEL_COLORS[model];
1106
+
1107
+ var lower = model.toLowerCase();
1108
+ // Family fallback resolution
1109
+ // Claude pool (Rojos)
1110
+ if (lower.indexOf("opus") !== -1) return "#b91c1c";
1111
+ if (lower.indexOf("sonnet") !== -1 || lower.indexOf("claude") !== -1) return "#ef4444";
1112
+ if (lower === "gpt-oss-120b" || lower === "gpt-oss-120b-medium") return "#f87171";
1113
+
1114
+ // Gemini pool (Azules)
1115
+ if (lower.indexOf("3.1-pro") !== -1 || lower.indexOf("3-pro") !== -1) return "#1d4ed8";
1116
+ if (lower.indexOf("3.5-flash") !== -1) return "#2563eb";
1117
+ if (lower.indexOf("3.6-flash") !== -1) return "#38bdf8";
1118
+ if (lower.indexOf("gemini") !== -1 || lower.indexOf("3-flash") !== -1) return "#93c5fd";
1119
+
1120
+ // Codex pool (Amarillos)
1121
+ if (lower.indexOf("gpt-5.6-sol") !== -1) return "#a16207";
1122
+ if (lower.indexOf("gpt-5.6-terra") !== -1) return "#eab308";
1123
+ if (lower.indexOf("gpt-5.6-luna") !== -1) return "#fde047";
1124
+
1125
+ // Ollama pool (Verdes)
1126
+ if (lower.indexOf("kimi") !== -1) return "#047857";
1127
+ if (lower.indexOf("qwen") !== -1) return "#0f766e";
1128
+ if (lower.indexOf("glm") !== -1) return "#10b981";
1129
+ if (lower.indexOf("nemotron-3-super") !== -1 || lower.indexOf("nemotron-3-ultra") !== -1) return "#15803d";
1130
+ if (lower.indexOf("mistral") !== -1 || lower.indexOf("nemotron") !== -1) return "#22c55e";
1131
+ if (lower.indexOf("gemma") !== -1) return "#65a30d";
1132
+ if (lower.indexOf("minimax") !== -1) return "#84cc16";
1133
+ if (lower.indexOf("deepseek-v4-pro") !== -1) return "#2dd4bf";
1134
+ if (lower.indexOf("deepseek") !== -1) return "#5eead4";
1135
+ if (lower.indexOf("gpt-oss:120b") !== -1) return "#86efac";
1136
+ if (lower.indexOf("gpt-oss") !== -1) return "#dcfce7";
1137
+
1138
+ return "#10b981";
1051
1139
  }
1052
1140
 
1053
1141
  function formatTokenCount(n) {
@@ -1074,6 +1162,10 @@ var MODEL_PRICING_CLIENT = {
1074
1162
  "gemini-3.6-flash-low": { input: 1.5, output: 7.5 },
1075
1163
  "gemini-3.6-flash-tiered": { input: 1.5, output: 7.5 },
1076
1164
  "gpt-oss-120b-medium": { input: 2.0, output: 10.0 },
1165
+ // OpenAI Codex GPT-5.6 models — mirrors MODEL_PRICING in types.ts.
1166
+ "gpt-5.6-sol": { input: 5.0, output: 30.0 },
1167
+ "gpt-5.6-terra": { input: 2.0, output: 12.0 },
1168
+ "gpt-5.6-luna": { input: 0.2, output: 1.2 },
1077
1169
  // Ollama Cloud models — mirrors MODEL_PRICING in src/types.ts
1078
1170
  "gpt-oss:20b": { input: 0.075, output: 0.3 },
1079
1171
  "gpt-oss:120b": { input: 0.15, output: 0.6 },
@@ -1127,6 +1219,23 @@ function calcSavingsFromBuckets(buckets) {
1127
1219
  return { totalUsd: totalUsd, byModel: byModel };
1128
1220
  }
1129
1221
 
1222
+ function formatSavingsUsd(usd) {
1223
+ if (!(usd > 0)) return "";
1224
+ if (usd >= 0.01) return usd.toFixed(2);
1225
+ if (usd >= 0.0001) return usd.toFixed(4);
1226
+ if (usd >= 0.000001) return usd.toFixed(6);
1227
+ return usd.toFixed(8);
1228
+ }
1229
+
1230
+ function formatModelSavingsLabel(modelSavings) {
1231
+ if (!modelSavings || !(modelSavings.totalUsd > 0)) return "";
1232
+ return (
1233
+ ' <span style="color:var(--green)">$' +
1234
+ formatSavingsUsd(modelSavings.totalUsd) +
1235
+ "</span>"
1236
+ );
1237
+ }
1238
+
1130
1239
  window.__tokenView = "1h";
1131
1240
 
1132
1241
  function exportData(format) {
@@ -1588,12 +1697,7 @@ function renderTokenChart(tokenUsage) {
1588
1697
  legend.innerHTML = models
1589
1698
  .map(function (m) {
1590
1699
  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
- : "";
1700
+ var savingsLabel = formatModelSavingsLabel(modelSavings);
1597
1701
  return (
1598
1702
  '<div style="display:flex;align-items:center;gap:4px">' +
1599
1703
  '<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 "ollama". */
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;
@@ -277,6 +285,18 @@ export const QUOTA_MODEL_KEYS: Record<
277
285
  // Map request model names to quota model keys (family buckets).
278
286
  export function resolveQuotaModelKey(requestModel: string): string | null {
279
287
  const lower = requestModel.toLowerCase();
288
+ if (
289
+ lower === "deepseek-v4-flash-free" ||
290
+ lower === "nemotron-3.5-lightning-free" ||
291
+ lower === "nemotron-3-ultra-free" ||
292
+ lower === "mimo-v2.5-free" ||
293
+ lower === "hy3-free" ||
294
+ lower === "ling-3.0-tiny-free" ||
295
+ lower === "laguna-s-2.1-free" ||
296
+ lower.endsWith("-free")
297
+ ) {
298
+ return "opencode-zen";
299
+ }
280
300
  // Claude family: every Claude variant and gpt-oss share one bucket.
281
301
  if (
282
302
  lower.includes("claude") ||
@@ -350,6 +370,14 @@ export interface AccountRuntime {
350
370
  config: AccountConfig;
351
371
  accessToken: string | null;
352
372
  tokenExpires: number;
373
+ /** Provider-scoped access tokens. Legacy Google/Ollama state still uses the fields above. */
374
+ providerTokens?: Record<
375
+ string,
376
+ { accessToken: string | null; tokenExpires: number }
377
+ >;
378
+ /** Provider-local auth failures/cooldowns; Google/Ollama remain routable. */
379
+ invalidProviders?: Record<string, string>;
380
+ providerCooldowns?: Record<string, number>;
353
381
  // Rotation tracking (per-model via rotator)
354
382
  requestsSinceRotation: number;
355
383
  totalRequests: number;
@@ -476,6 +504,7 @@ export interface StatusResponse {
476
504
  };
477
505
  routingDiagnostics: Record<string, RoutingModelDiagnostics>;
478
506
  ollamaModels: string[];
507
+ codexModels?: string[];
479
508
  // Present only when at least one account carries an ollama credential.
480
509
  modelTierAccess?: Record<string, ModelTierAccess>;
481
510
  predictions: Record<string, ExhaustionPrediction>;
@@ -538,6 +567,10 @@ export interface AccountStatus {
538
567
  lastError: string | null;
539
568
  consecutiveErrors: number;
540
569
  hasValidToken: boolean;
570
+ /** Provider-scoped authentication failures; sibling providers may remain usable. */
571
+ invalidProviders?: Record<string, string>;
572
+ /** Provider-scoped cooldown deadlines, kept separate from account breakers. */
573
+ providerCooldowns?: Record<string, number>;
541
574
  quota: ModelQuota[];
542
575
  inFlightRequests: number;
543
576
  inFlightByModel: Record<string, number>;
@@ -724,6 +757,25 @@ export const MODEL_PRICING: Record<
724
757
  },
725
758
  "gpt-oss-120b-medium": { inputPer1M: 2.0, outputPer1M: 10.0 },
726
759
 
760
+ // OpenAI Codex GPT-5.6 models — official OpenAI API pricing checked
761
+ // 2026-08-11. Token usage currently records aggregate input/output tokens;
762
+ // cache rates are retained for spend metadata but are not applied separately.
763
+ "gpt-5.6-sol": {
764
+ inputPer1M: 5.0,
765
+ outputPer1M: 30.0,
766
+ cachingPer1M: 0.50,
767
+ },
768
+ "gpt-5.6-terra": {
769
+ inputPer1M: 2.0,
770
+ outputPer1M: 12.0,
771
+ cachingPer1M: 0.20,
772
+ },
773
+ "gpt-5.6-luna": {
774
+ inputPer1M: 0.20,
775
+ outputPer1M: 1.20,
776
+ cachingPer1M: 0.02,
777
+ },
778
+
727
779
  // Ollama Cloud model pricing (USD per 1M tokens). Sourced from the
728
780
  // ~/ollama-rotator project (verified 2026-08-09).
729
781
  "gpt-oss:20b": { inputPer1M: 0.075, outputPer1M: 0.30 },
@@ -744,6 +796,15 @@ export const MODEL_PRICING: Record<
744
796
  "nemotron-3-nano:30b": { inputPer1M: 0.50, outputPer1M: 1.50 },
745
797
  "nemotron-3-super": { inputPer1M: 0.60, outputPer1M: 1.80 },
746
798
  "nemotron-3-ultra": { inputPer1M: 0.60, outputPer1M: 1.80 },
799
+
800
+ // OpenCode Zen free models (cost: 0 USD per 1M tokens)
801
+ "deepseek-v4-flash-free": { inputPer1M: 0.0, outputPer1M: 0.0 },
802
+ "nemotron-3.5-lightning-free": { inputPer1M: 0.0, outputPer1M: 0.0 },
803
+ "nemotron-3-ultra-free": { inputPer1M: 0.0, outputPer1M: 0.0 },
804
+ "mimo-v2.5-free": { inputPer1M: 0.0, outputPer1M: 0.0 },
805
+ "hy3-free": { inputPer1M: 0.0, outputPer1M: 0.0 },
806
+ "ling-3.0-tiny-free": { inputPer1M: 0.0, outputPer1M: 0.0 },
807
+ "laguna-s-2.1-free": { inputPer1M: 0.0, outputPer1M: 0.0 },
747
808
  };
748
809
 
749
810
  // 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`);