tuxevil-rotator 3.7.0 → 3.7.1

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.
@@ -48,7 +48,7 @@ export async function fetchOpenCodeZenQuota(
48
48
 
49
49
  const freshQuota: ModelQuota = {
50
50
  modelKey: OPENCODE_ZEN_PROVIDER_ID,
51
- displayName: "OpenCode Zen Free Pool",
51
+ displayName: "OpenCode",
52
52
  providerId: OPENCODE_ZEN_PROVIDER_ID,
53
53
  percentRemaining: 100,
54
54
  resetTime: null,
@@ -27,6 +27,8 @@ export {
27
27
  type AccountLike as ProviderCredentialLike,
28
28
  PROVIDER_ORDER,
29
29
  PROVIDER_ORDER_RANK,
30
+ OLLAMA_QUOTA_POOL_KEY,
31
+ isOllamaQuotaPoolKey,
30
32
  getProviderIdForPoolKey,
31
33
  getQuotaItemProviderId,
32
34
  sortQuotaPools,
package/src/rotator.ts CHANGED
@@ -59,6 +59,7 @@ import {
59
59
  primaryProviderId,
60
60
  findProviderForModel,
61
61
  getProviderIdForPoolKey,
62
+ isOllamaQuotaPoolKey,
62
63
  PROVIDER_ORDER,
63
64
  } from "./providers/registry.js";
64
65
  import type { QuotaFetchContext } from "./providers/adapter.js";
@@ -191,6 +192,9 @@ interface AccountRequestWaiter {
191
192
  const QUOTA_POOL_FOR_KICKSTART_MODEL: Record<string, string> = {
192
193
  "gpt-oss-120b-medium": "claude",
193
194
  "gemini-3-flash": "gemini",
195
+ "gpt-5.6-luna": CODEX_QUOTA_MODEL_KEY,
196
+ // Legacy manual kickstart compatibility. New Ollama quota polling/routes
197
+ // use `monthly`; this alias is only for callers that still name `session`.
194
198
  "gpt-oss:20b": "session",
195
199
  };
196
200
 
@@ -1044,10 +1048,9 @@ export class AccountRotator {
1044
1048
  ? account.quota.find((candidate) => candidate.providerId === OPENCODE_ZEN_PROVIDER_ID)
1045
1049
  : undefined);
1046
1050
  if (!q) return -1;
1047
- // Ollama: the session pool is gated by the weekly pool. If the weekly
1048
- // quota is fully exhausted (0%), the account cannot accept any requests
1049
- // regardless of how much session quota remains. Treat it as 0 so the
1050
- // account is skipped at all call sites that check `quota === 0`.
1051
+ // Legacy Ollama state used a session pool gated by a weekly pool. Keep
1052
+ // that compatibility rule only for old in-memory state; current Ollama
1053
+ // accounts expose one monthly pool and need no secondary gate.
1051
1054
  if (quotaKey === "session") {
1052
1055
  const weekly = account.quota.find((w) => w.modelKey === "weekly");
1053
1056
  if (weekly && weekly.percentRemaining === 0) return 0;
@@ -1059,7 +1062,7 @@ export class AccountRotator {
1059
1062
  private getModelTimerType(
1060
1063
  account: AccountRuntime,
1061
1064
  modelKey: string,
1062
- ): "fresh" | "5h" | "7d" {
1065
+ ): ModelQuota["timerType"] {
1063
1066
  const quotaKey = isStaticAntigravityModel(modelKey)
1064
1067
  ? modelKey
1065
1068
  : dynamicCatalog.resolveQuotaPool(modelKey) ?? modelKey;
@@ -1080,8 +1083,8 @@ export class AccountRotator {
1080
1083
 
1081
1084
  /**
1082
1085
  * Resolve kickstart by quota-pool owner, never by the account's primary
1083
- * provider. Parent accounts may hold several credentials, and Codex pools
1084
- * deliberately have no kickstart implementation.
1086
+ * provider. Parent accounts may hold several credentials, and each provider
1087
+ * supplies its own kickstart implementation.
1085
1088
  */
1086
1089
  private getKickstartTarget(
1087
1090
  account: AccountRuntime,
@@ -1096,12 +1099,7 @@ export class AccountRotator {
1096
1099
  const quota = account.quota.find((candidate) => candidate.modelKey === poolKey);
1097
1100
  const providerId =
1098
1101
  quota?.providerId ??
1099
- (poolKey === "session"
1100
- ? "ollama"
1101
- : poolKey === CODEX_QUOTA_MODEL_KEY ||
1102
- poolKey.startsWith(`${CODEX_QUOTA_MODEL_KEY}:`)
1103
- ? "openai-codex"
1104
- : DEFAULT_PROVIDER);
1102
+ getProviderIdForPoolKey(poolKey);
1105
1103
  if (!hasCredential(account.config, providerId)) return null;
1106
1104
 
1107
1105
  const adapter = getProviderAdapter(providerId);
@@ -1252,19 +1250,31 @@ export class AccountRotator {
1252
1250
  let best: AccountRuntime | null = null;
1253
1251
  let bestLoad = Infinity;
1254
1252
  let bestDistance = Infinity;
1253
+ let bestTier = Infinity;
1254
+ const policy = this.config.routingPolicy || "timer-first";
1255
1255
 
1256
1256
  for (let i = 0; i < this.accounts.length; i++) {
1257
1257
  const account = this.accounts[i];
1258
1258
  if (!this.isRoutableForModel(account, modelKey, now)) continue;
1259
1259
  const load = account.inFlightRequests;
1260
+ const tier = this.getTierRank(account);
1260
1261
  const distance = this.requestCursorIndex < 0
1261
1262
  ? i
1262
1263
  : (i - this.requestCursorIndex + this.accounts.length) %
1263
1264
  this.accounts.length || this.accounts.length;
1264
- if (load < bestLoad || (load === bestLoad && distance < bestDistance)) {
1265
+ // Concurrent balancing must keep tier-first's preference: load-balance
1266
+ // within the best eligible tier, and use lower tiers only as fallback.
1267
+ const betterTier = policy === "tier-first" && tier < bestTier;
1268
+ const sameTier = policy !== "tier-first" || tier === bestTier;
1269
+ if (
1270
+ betterTier ||
1271
+ (sameTier &&
1272
+ (load < bestLoad || (load === bestLoad && distance < bestDistance)))
1273
+ ) {
1265
1274
  best = account;
1266
1275
  bestLoad = load;
1267
1276
  bestDistance = distance;
1277
+ bestTier = tier;
1268
1278
  }
1269
1279
  }
1270
1280
 
@@ -1494,13 +1504,13 @@ export class AccountRotator {
1494
1504
  account.cooldownsByModel[this.resolveQuotaStateKey(modelKey)] ?? 0;
1495
1505
  if (modelCooldown > now)
1496
1506
  return { reason: "cooldown", detail: "model cooldown active" };
1497
- // Ollama Cloud (pool key "session") imposes no per-account
1507
+ // Ollama Cloud quota pools impose no per-account
1498
1508
  // concurrency limit — the in-flight check would otherwise wedge
1499
1509
  // long-running streams while the same model on another account is
1500
1510
  // still serving. Antigravity keeps the per-account limit.
1501
1511
  if (
1502
1512
  !ignoreConcurrency &&
1503
- modelKey !== "session" &&
1513
+ !isOllamaQuotaPoolKey(modelKey) &&
1504
1514
  account.inFlightRequests >=
1505
1515
  (this.config.maxConcurrentRequestsPerAccount ?? 5)
1506
1516
  ) {
@@ -2088,6 +2098,16 @@ export class AccountRotator {
2088
2098
  const hasActiveRequests = this.accounts.some(
2089
2099
  (account) => account.inFlightRequests > 0,
2090
2100
  );
2101
+ const policy = this.config.routingPolicy || "timer-first";
2102
+ if (modelKey && policy === "tier-first" && !hasActiveRequests) {
2103
+ const preferred = this.pickBestModelAccount(modelKey, now);
2104
+ if (preferred && preferred !== current) {
2105
+ // A persisted assignment may have been selected under a previous
2106
+ // policy or before account tiers were corrected. Re-evaluate it while
2107
+ // idle so tier-first does not keep serving a lower-tier account.
2108
+ return this.rotateModelForRequest(modelKey, now, idx);
2109
+ }
2110
+ }
2091
2111
  if (modelKey && hasActiveRequests) {
2092
2112
  const leastLoaded = this.pickLeastLoadedModelAccount(modelKey, now);
2093
2113
  if (leastLoaded && leastLoaded !== current) {
@@ -2615,11 +2635,14 @@ export class AccountRotator {
2615
2635
  }
2616
2636
  }
2617
2637
 
2618
- getPredictionSummary(): Record<string, ExhaustionPrediction> {
2638
+ getPredictionSummary(): Record<string, ExhaustionPrediction> {
2619
2639
  const result: Record<string, ExhaustionPrediction> = {};
2620
2640
  const now = Date.now();
2621
2641
  for (const account of this.accounts) {
2622
2642
  if (!hasCredential(account.config, "ollama")) continue;
2643
+ // The predictor is calibrated for the legacy dual-window response.
2644
+ // Current monthly usage remains routable, but has no calibrated token
2645
+ // budget yet, so do not publish a misleading forecast for it.
2623
2646
  const session = account.quota.find((q) => q.modelKey === "session");
2624
2647
  const weekly = account.quota.find((q) => q.modelKey === "weekly");
2625
2648
  if (
@@ -2994,12 +3017,18 @@ export class AccountRotator {
2994
3017
  const quota = account.quota.find(
2995
3018
  (candidate) =>
2996
3019
  candidate.modelKey === modelKey &&
2997
- candidate.providerId === DEFAULT_PROVIDER,
3020
+ (candidate.providerId === DEFAULT_PROVIDER ||
3021
+ candidate.providerId === "ollama" ||
3022
+ candidate.providerId === undefined),
2998
3023
  );
2999
3024
  if (quota) {
3000
3025
  quota.percentRemaining = 0;
3001
3026
  quota.resetTime = new Date(now + cooldownMs).toISOString();
3002
- quota.timerType = cooldownMs < 6 * 60 * 60 * 1000 ? "5h" : "7d";
3027
+ quota.timerType = quota.modelKey === "monthly"
3028
+ ? "monthly"
3029
+ : cooldownMs < 6 * 60 * 60 * 1000
3030
+ ? "5h"
3031
+ : "7d";
3003
3032
  }
3004
3033
  }
3005
3034
 
@@ -3025,7 +3054,9 @@ export class AccountRotator {
3025
3054
  const poolKey = model ? this.resolveAccountPoolKey(account, model) : null;
3026
3055
  const isAccountScopedProvider =
3027
3056
  providerResourceExhausted ||
3028
- (poolKey && (poolKey.startsWith("opencode-zen") || poolKey.startsWith("session")));
3057
+ (poolKey &&
3058
+ (poolKey.startsWith("opencode-zen") ||
3059
+ getProviderIdForPoolKey(poolKey) === "ollama"));
3029
3060
 
3030
3061
  if (isAccountScopedProvider) {
3031
3062
  // Account-level daily/weekly quota exhaustion or per-key rate limit is not a model outage:
@@ -3514,11 +3545,11 @@ export class AccountRotator {
3514
3545
  const modelCooldown =
3515
3546
  account.cooldownsByModel[this.resolveQuotaStateKey(modelKey)] ?? 0;
3516
3547
  if (modelCooldown > now) return false;
3517
- // Ollama Cloud (pool key "session") imposes no per-account concurrency
3548
+ // Ollama Cloud quota pools impose no per-account concurrency
3518
3549
  // limit. Antigravity keeps it so long streams don't pile up on a
3519
3550
  // single account while siblings sit idle.
3520
3551
  if (
3521
- modelKey !== "session" &&
3552
+ !isOllamaQuotaPoolKey(modelKey) &&
3522
3553
  account.inFlightRequests >=
3523
3554
  (this.config.maxConcurrentRequestsPerAccount ?? 5)
3524
3555
  )
@@ -3556,9 +3587,9 @@ export class AccountRotator {
3556
3587
  startRequest(account: AccountRuntime, modelKey?: string): void {
3557
3588
  const key = modelKey ?? "__default__";
3558
3589
  // Ollama Cloud imposes no per-account concurrency limit, so its
3559
- // requests must not activate in-flight tracking at all (pool key
3560
- // "session" and raw ollama model names from benchmark probes).
3561
- if (key === "session" || this.ollamaModels.has(key)) {
3590
+ // requests must not activate in-flight tracking at all (the monthly
3591
+ // pool and raw ollama model names from benchmark probes).
3592
+ if (isOllamaQuotaPoolKey(key) || this.ollamaModels.has(key)) {
3562
3593
  this.consumeTokenBucket(account, Date.now());
3563
3594
  return;
3564
3595
  }
@@ -3570,7 +3601,7 @@ export class AccountRotator {
3570
3601
 
3571
3602
  finishRequest(account: AccountRuntime, modelKey?: string): void {
3572
3603
  const key = modelKey ?? "__default__";
3573
- if (key === "session" || this.ollamaModels.has(key)) return;
3604
+ if (isOllamaQuotaPoolKey(key) || this.ollamaModels.has(key)) return;
3574
3605
  account.inFlightByModel[key] = Math.max(
3575
3606
  0,
3576
3607
  (account.inFlightByModel[key] ?? 0) - 1,
@@ -3667,10 +3698,10 @@ export class AccountRotator {
3667
3698
  private resolvePoolKey(account: AccountRuntime, key: string): string {
3668
3699
  if (
3669
3700
  hasCredential(account.config, "ollama") &&
3670
- key !== "session" &&
3701
+ !isOllamaQuotaPoolKey(key) &&
3671
3702
  this.ollamaModels.has(key)
3672
3703
  ) {
3673
- return "session";
3704
+ return "monthly";
3674
3705
  }
3675
3706
  return key;
3676
3707
  }
@@ -4425,8 +4456,8 @@ export class AccountRotator {
4425
4456
  }
4426
4457
 
4427
4458
  /**
4428
- * Send a minimal single-token request to the upstream Antigravity endpoint for a specific
4429
- * quota pool key on a given account. Uses the cheapest model in that pool to minimise cost.
4459
+ * Send a provider-native minimal request for a specific quota pool key on a given account.
4460
+ * Uses the cheapest model in that pool to minimise cost.
4430
4461
  * Applies normal error handling (markExhausted, markFlagged, markError) so the account state
4431
4462
  * stays consistent with regular traffic.
4432
4463
  */
@@ -4471,7 +4502,8 @@ export class AccountRotator {
4471
4502
 
4472
4503
  const kickstartAdapter = target.adapter;
4473
4504
  const isOllamaAccount = kickstartAdapter.id === "ollama";
4474
- if (!account.accessToken && !isOllamaAccount) {
4505
+ const hasNativeKickstart = Boolean(kickstartAdapter.forwardKickstartRequest);
4506
+ if (!account.accessToken && !isOllamaAccount && !hasNativeKickstart) {
4475
4507
  return { ok: false, status: 401, upstreamModel: "", error: "no access token" };
4476
4508
  }
4477
4509
 
@@ -4495,7 +4527,22 @@ export class AccountRotator {
4495
4527
  const timeout = setTimeout(() => controller.abort(), 15_000);
4496
4528
 
4497
4529
  let response: Response;
4498
- if (isOllamaAccount) {
4530
+ if (kickstartAdapter.forwardKickstartRequest) {
4531
+ try {
4532
+ const forwarded = await kickstartAdapter.forwardKickstartRequest(
4533
+ account,
4534
+ upstreamModel,
4535
+ controller.signal,
4536
+ );
4537
+ response = forwarded.response;
4538
+ } catch (err) {
4539
+ clearTimeout(timeout);
4540
+ const msg = `kickstart network error: ${err instanceof Error ? err.message : String(err)}`;
4541
+ this.markError(account, msg);
4542
+ return { ok: false, status: 0, upstreamModel, error: msg };
4543
+ }
4544
+ clearTimeout(timeout);
4545
+ } else if (isOllamaAccount) {
4499
4546
  const ollamaBody: RequestBody = {
4500
4547
  project: "",
4501
4548
  model: upstreamModel,
@@ -4605,11 +4652,12 @@ export class AccountRotator {
4605
4652
  }
4606
4653
 
4607
4654
  if (response.status === 401 || response.status === 403) {
4608
- this.markFlagged(
4609
- account,
4610
- `kickstart ${response.status} on ${upstreamModel}`,
4611
- { triggerProtectivePause: false },
4612
- );
4655
+ const reason = `kickstart ${response.status} on ${upstreamModel}`;
4656
+ if (target.providerId === "openai-codex") {
4657
+ this.markProviderInvalid(account, target.providerId, reason);
4658
+ } else {
4659
+ this.markFlagged(account, reason, { triggerProtectivePause: false });
4660
+ }
4613
4661
  return { ok: false, status: response.status, upstreamModel };
4614
4662
  }
4615
4663
 
@@ -4620,6 +4668,7 @@ export class AccountRotator {
4620
4668
 
4621
4669
  if (response.ok) {
4622
4670
  this.recordRequest(account, poolKey);
4671
+ target.adapter.clearQuotaCache?.(account);
4623
4672
  this.log(
4624
4673
  `${label} [${poolKey}]: kickstart sent via ${upstreamModel} — ${refreshQuota ? "refreshing quota" : "bulk quota refresh pending"}`,
4625
4674
  );
@@ -416,6 +416,7 @@
416
416
  .timer-fresh { background: rgba(52, 211, 153, 0.1); color: var(--green); }
417
417
  .timer-7d { background: rgba(96, 165, 250, 0.1); color: var(--blue); }
418
418
  .timer-5h { background: rgba(251, 191, 36, 0.1); color: var(--yellow); }
419
+ .timer-monthly { background: rgba(96, 165, 250, 0.1); color: var(--blue); }
419
420
 
420
421
  .quota-bar-bg {
421
422
  flex: 1;
@@ -32,13 +32,10 @@ function isIdleForKickstart(q) {
32
32
 
33
33
  function isKickstartSupported(q) {
34
34
  if (!q) return false;
35
- if (q.providerId === "openai-codex" || q.providerId === "opencode-zen") return false;
35
+ if (q.providerId === "opencode-zen") return false;
36
36
  if (q.providerId === "ollama" && q.modelKey !== "session") return false;
37
37
  var key = String(q.modelKey || "");
38
38
  return (
39
- key !== "openai-codex" &&
40
- key !== "openai-codex-spark" &&
41
- key.indexOf("openai-codex:") !== 0 &&
42
39
  key !== "opencode-zen" &&
43
40
  key.indexOf("opencode-zen:") !== 0 &&
44
41
  key !== "weekly"
@@ -50,7 +47,7 @@ function getQuotaItemProviderRank(q) {
50
47
  if (!p) {
51
48
  var k = String(q.modelKey || "");
52
49
  if (k === "claude" || k === "gemini") p = "google-antigravity";
53
- else if (k === "session" || k === "weekly") p = "ollama";
50
+ else if (k === "monthly" || k === "session" || k === "weekly") p = "ollama";
54
51
  else if (k.indexOf("opencode") === 0 || k === "opencode-zen") p = "opencode-zen";
55
52
  else if (k.indexOf("codex") === 0 || k.indexOf("openai-codex") === 0) p = "openai-codex";
56
53
  else p = "google-antigravity";
@@ -1190,7 +1187,7 @@ var MODEL_PRICING_CLIENT = {
1190
1187
  "gpt-5.6-terra": { input: 2.0, output: 12.0 },
1191
1188
  "gpt-5.6-luna": { input: 0.2, output: 1.2 },
1192
1189
  // Ollama Cloud models — mirrors MODEL_PRICING in src/types.ts
1193
- "gpt-oss:20b": { input: 0.075, output: 0.3 },
1190
+ "gpt-oss:20b": { input: 0.07, output: 0.3 },
1194
1191
  "gpt-oss:120b": { input: 0.15, output: 0.6 },
1195
1192
  "deepseek-v4-flash:preview": { input: 0.14, output: 0.28 },
1196
1193
  "deepseek-v4-flash:0731": { input: 0.14, output: 0.28 },
@@ -1198,22 +1195,23 @@ var MODEL_PRICING_CLIENT = {
1198
1195
  "qwen3.5:397b": { input: 0.6, output: 3.6 },
1199
1196
  "glm-5.1": { input: 0.8, output: 2.56 },
1200
1197
  "glm-5.2": { input: 0.8, output: 2.56 },
1201
- "gemma4:31b": { input: 0.38, output: 1.15 },
1198
+ "gemma4:31b": { input: 0.14, output: 0.4 },
1202
1199
  "kimi-k2.6": { input: 0.95, output: 4.0 },
1203
1200
  "kimi-k2.7-code": { input: 0.95, output: 4.0 },
1204
1201
  "kimi-k3": { input: 0.95, output: 4.0 },
1205
1202
  "minimax-m2.7": { input: 0.3, output: 1.2 },
1206
1203
  "minimax-m3": { input: 0.3, output: 1.2 },
1207
1204
  "mistral-large-3:675b": { input: 0.5, output: 1.5 },
1208
- "nemotron-3-nano:30b": { input: 0.5, output: 1.5 },
1209
- "nemotron-3-super": { input: 0.6, output: 1.8 },
1210
- "nemotron-3-ultra": { input: 0.6, output: 1.8 },
1205
+ "nemotron-3-nano:30b": { input: 0.06, output: 0.24 },
1206
+ "nemotron-3-super": { input: 0.015, output: 0.6 },
1207
+ "nemotron-3-ultra": { input: 0.1, output: 3.0 },
1211
1208
  // OpenCode Zen free models — mirrors MODEL_PRICING in src/types.ts
1212
- "deepseek-v4-flash-free": { input: 0.14, output: 0.28 },
1213
- "nemotron-3.5-lightning-free": { input: 0.35, output: 1.05 },
1214
- "nemotron-3-ultra-free": { input: 0.6, output: 1.8 },
1215
- "mimo-v2.5-free": { input: 0.15, output: 0.6 },
1216
- "hy3-free": { input: 0.25, output: 1.0 },
1209
+ "big-pickle": { input: 0, output: 0 },
1210
+ "mimo-v2.5-free": { input: 0, output: 0 },
1211
+ "ling-3.0-flash-fin-free": { input: 0, output: 0 },
1212
+ "nemotron-3-ultra-free": { input: 0, output: 0 },
1213
+ "nemotron-3.5-lightning-free": { input: 0, output: 0 },
1214
+ "muse-spark-1.3-contributor-free": { input: 0, output: 0 },
1217
1215
  "ling-3.0-tiny-free": { input: 0.05, output: 0.2 },
1218
1216
  "laguna-s-2.1-free": { input: 0.2, output: 0.8 },
1219
1217
  };
@@ -1997,6 +1995,7 @@ function renderForecastPanel(data) {
1997
1995
  var rate = burnByPool[m] || 0;
1998
1996
  var rateLabel = rate > 0 ? rate.toFixed(1) + " req/h" : "idle";
1999
1997
  var displayName = m;
1998
+ if (m === "monthly") displayName = "Ollama";
2000
1999
  if (m === "claude-opus-4-6-thinking") displayName = "claude";
2001
2000
  if (m === "gemini-3.1-pro") displayName = "gemini-3.1-pro";
2002
2001
  if (m === "gemini-3-flash") displayName = "gemini-3-flash";
package/src/telemetry.ts CHANGED
@@ -215,7 +215,7 @@ export interface FlagEventData {
215
215
 
216
216
  // What was happening
217
217
  model: string; // model key being requested
218
- timerType: "fresh" | "5h" | "7d" | "unknown"; // quota window state
218
+ timerType: "fresh" | "5h" | "7d" | "monthly" | "unknown"; // quota window state
219
219
  accountQuotaPercent: number; // quota % at time of flag (-1 if unknown)
220
220
 
221
221
  // Account state (anonymous — no email)
package/src/types.ts CHANGED
@@ -319,9 +319,9 @@ export interface ModelQuota {
319
319
  /** Raw usage fraction (0..1) when the provider reports one (Ollama). */
320
320
  usageRaw?: number;
321
321
  resetTime: string | null;
322
- // Timer classification based on resetTime duration
323
- // "fresh" = no active timer, "5h" = short timer, "7d" = long timer
324
- timerType: "fresh" | "5h" | "7d";
322
+ // Timer classification based on resetTime duration. Ollama's current
323
+ // account-wide pool is monthly and has no provider-supplied reset time.
324
+ timerType: "fresh" | "5h" | "7d" | "monthly";
325
325
  }
326
326
 
327
327
  // Model key mapping for the quota API. One entry per family: all Claude
@@ -381,11 +381,7 @@ export function isStaticAntigravityModel(model: string): boolean {
381
381
  export function resolveQuotaModelKey(requestModel: string): string | null {
382
382
  const lower = requestModel.toLowerCase();
383
383
  if (
384
- lower === "deepseek-v4-flash-free" ||
385
- lower === "nemotron-3.5-lightning-free" ||
386
- lower === "nemotron-3-ultra-free" ||
387
- lower === "mimo-v2.5-free" ||
388
- lower === "hy3-free" ||
384
+ lower === "big-pickle" ||
389
385
  lower.endsWith("-free")
390
386
  ) {
391
387
  return "opencode-zen";
@@ -913,11 +909,12 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
913
909
  cachingPer1M: 0.02,
914
910
  },
915
911
 
916
- // Ollama Cloud model pricing (USD per 1M tokens). Sourced from LiteLLM
917
- // (https://models.litellm.ai/) and verified 2026-08-30 via /api/tags
918
- // discovery + /api/chat probes. Run scripts/verify_ollama_models.ts to refresh.
919
- "gpt-oss:20b": { inputPer1M: 0.075, outputPer1M: 0.30 },
920
- "gpt-oss:120b": { inputPer1M: 0.15, outputPer1M: 0.60 },
912
+ // Ollama Cloud free-tier model pricing (USD per 1M tokens), supplied by
913
+ // the operator from Ollama Cloud's published rates. Cached-input rates are
914
+ // retained for spend metadata; aggregate token logs currently price input
915
+ // tokens at the regular input rate because they do not expose cache hits.
916
+ "gpt-oss:20b": { inputPer1M: 0.07, outputPer1M: 0.30, cachingPer1M: 0.035 },
917
+ "gpt-oss:120b": { inputPer1M: 0.15, outputPer1M: 0.60, cachingPer1M: 0.014 },
921
918
  "deepseek-v4-flash:0731": { inputPer1M: 0.14, outputPer1M: 0.28, cachingPer1M: 0.0028 },
922
919
  "deepseek-v4-pro:0813": { inputPer1M: 1.74, outputPer1M: 3.48 },
923
920
  "qwen3.5:397b": { inputPer1M: 0.60, outputPer1M: 3.60 },
@@ -925,23 +922,24 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
925
922
  "glm-5.2": { inputPer1M: 0.80, outputPer1M: 2.56 },
926
923
  "glm-5.3": { inputPer1M: 1.40, outputPer1M: 4.40 },
927
924
  "glm-5.3-flash": { inputPer1M: 0.15, outputPer1M: 0.50 },
928
- "gemma4:31b": { inputPer1M: 0.38, outputPer1M: 1.15 },
925
+ "gemma4:31b": { inputPer1M: 0.14, outputPer1M: 0.40, cachingPer1M: 0.05 },
929
926
  "kimi-k2.6": { inputPer1M: 0.95, outputPer1M: 4.00 },
930
927
  "kimi-k2.7-code": { inputPer1M: 0.95, outputPer1M: 4.00 },
931
928
  "kimi-k3": { inputPer1M: 0.95, outputPer1M: 4.00 },
932
929
  "minimax-m2.7": { inputPer1M: 0.30, outputPer1M: 1.20 },
933
930
  "minimax-m3": { inputPer1M: 0.30, outputPer1M: 1.20 },
934
931
  "mistral-large-3:675b": { inputPer1M: 0.50, outputPer1M: 1.50 },
935
- "nemotron-3-nano:30b": { inputPer1M: 0.50, outputPer1M: 1.50 },
936
- "nemotron-3-super": { inputPer1M: 0.60, outputPer1M: 1.80 },
937
- "nemotron-3-ultra": { inputPer1M: 0.60, outputPer1M: 1.80 },
932
+ "nemotron-3-nano:30b": { inputPer1M: 0.06, outputPer1M: 0.24 },
933
+ "nemotron-3-super": { inputPer1M: 0.015, outputPer1M: 0.60, cachingPer1M: 0.015 },
934
+ "nemotron-3-ultra": { inputPer1M: 0.10, outputPer1M: 3.00, cachingPer1M: 0.10 },
938
935
 
939
- // OpenCode Zen free models — equivalent market rates (USD per 1M tokens) for savings tracking
940
- "deepseek-v4-flash-free": { inputPer1M: 0.14, outputPer1M: 0.28, cachingPer1M: 0.0028 },
941
- "nemotron-3.5-lightning-free": { inputPer1M: 0.35, outputPer1M: 1.05 },
942
- "nemotron-3-ultra-free": { inputPer1M: 0.60, outputPer1M: 1.80 },
943
- "mimo-v2.5-free": { inputPer1M: 0.15, outputPer1M: 0.60 },
944
- "hy3-free": { inputPer1M: 0.25, outputPer1M: 1.00 },
936
+ // OpenCode Zen free models — zero provider cost (USD per 1M tokens)
937
+ "big-pickle": { inputPer1M: 0.00, outputPer1M: 0.00 },
938
+ "mimo-v2.5-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
939
+ "ling-3.0-flash-fin-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
940
+ "nemotron-3-ultra-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
941
+ "nemotron-3.5-lightning-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
942
+ "muse-spark-1.3-contributor-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
945
943
 
946
944
  };
947
945
 
@@ -343,8 +343,8 @@ const MODEL_PRICING = {
343
343
  "gemini-3.8-flash-high": { inputPer1M: 0.75, outputPer1M: 3.75 },
344
344
  "gpt-oss-120b-medium": { inputPer1M: 2.00, outputPer1M: 10.00 },
345
345
 
346
- // Ollama Cloud models — mirrors MODEL_PRICING in src/types.ts
347
- "gpt-oss:20b": { inputPer1M: 0.075, outputPer1M: 0.30 },
346
+ // Ollama Cloud free-tier models — mirrors MODEL_PRICING in src/types.ts
347
+ "gpt-oss:20b": { inputPer1M: 0.07, outputPer1M: 0.30 },
348
348
  "gpt-oss:120b": { inputPer1M: 0.15, outputPer1M: 0.60 },
349
349
  "deepseek-v4-flash:preview": { inputPer1M: 0.14, outputPer1M: 0.28 },
350
350
  "deepseek-v4-flash:0731": { inputPer1M: 0.14, outputPer1M: 0.28 },
@@ -352,23 +352,24 @@ const MODEL_PRICING = {
352
352
  "qwen3.5:397b": { inputPer1M: 0.60, outputPer1M: 3.60 },
353
353
  "glm-5.1": { inputPer1M: 0.80, outputPer1M: 2.56 },
354
354
  "glm-5.2": { inputPer1M: 0.80, outputPer1M: 2.56 },
355
- "gemma4:31b": { inputPer1M: 0.38, outputPer1M: 1.15 },
355
+ "gemma4:31b": { inputPer1M: 0.14, outputPer1M: 0.40 },
356
356
  "kimi-k2.6": { inputPer1M: 0.95, outputPer1M: 4.00 },
357
357
  "kimi-k2.7-code": { inputPer1M: 0.95, outputPer1M: 4.00 },
358
358
  "kimi-k3": { inputPer1M: 0.95, outputPer1M: 4.00 },
359
359
  "minimax-m2.7": { inputPer1M: 0.30, outputPer1M: 1.20 },
360
360
  "minimax-m3": { inputPer1M: 0.30, outputPer1M: 1.20 },
361
361
  "mistral-large-3:675b": { inputPer1M: 0.50, outputPer1M: 1.50 },
362
- "nemotron-3-nano:30b": { inputPer1M: 0.50, outputPer1M: 1.50 },
363
- "nemotron-3-super": { inputPer1M: 0.60, outputPer1M: 1.80 },
364
- "nemotron-3-ultra": { inputPer1M: 0.60, outputPer1M: 1.80 },
362
+ "nemotron-3-nano:30b": { inputPer1M: 0.06, outputPer1M: 0.24 },
363
+ "nemotron-3-super": { inputPer1M: 0.015, outputPer1M: 0.60 },
364
+ "nemotron-3-ultra": { inputPer1M: 0.10, outputPer1M: 3.00 },
365
365
 
366
366
  // OpenCode Zen free models — mirrors MODEL_PRICING in src/types.ts
367
- "deepseek-v4-flash-free": { inputPer1M: 0.14, outputPer1M: 0.28 },
368
- "nemotron-3.5-lightning-free": { inputPer1M: 0.35, outputPer1M: 1.05 },
369
- "nemotron-3-ultra-free": { inputPer1M: 0.60, outputPer1M: 1.80 },
370
- "mimo-v2.5-free": { inputPer1M: 0.15, outputPer1M: 0.60 },
371
- "hy3-free": { inputPer1M: 0.25, outputPer1M: 1.00 },
367
+ "big-pickle": { inputPer1M: 0.00, outputPer1M: 0.00 },
368
+ "mimo-v2.5-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
369
+ "ling-3.0-flash-fin-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
370
+ "nemotron-3-ultra-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
371
+ "nemotron-3.5-lightning-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
372
+ "muse-spark-1.3-contributor-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
372
373
  "ling-3.0-tiny-free": { inputPer1M: 0.05, outputPer1M: 0.20 },
373
374
  "laguna-s-2.1-free": { inputPer1M: 0.20, outputPer1M: 0.80 },
374
375