tuxevil-rotator 3.6.1 → 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/proxy.ts CHANGED
@@ -170,6 +170,10 @@ import {
170
170
  serveGeminiModels,
171
171
  serveOpenAIModels,
172
172
  } from "./compat.js";
173
+ import {
174
+ handleOpenAIAudioTranscriptions,
175
+ handleAudioWebSocket,
176
+ } from "./audio-transcription.js";
173
177
  import { applyConfigDefaults } from "./account-store.js";
174
178
  import {
175
179
  classifyRateLimitReason,
@@ -1229,8 +1233,13 @@ export async function withRotation<T>(
1229
1233
  );
1230
1234
 
1231
1235
  try {
1232
- const jitterMs = rotator.getSafetyJitterMs(account);
1233
- const globalDelayMs = rotator.getGlobalDelayMs();
1236
+ const skipJitter = Boolean(
1237
+ originalHeaders &&
1238
+ (originalHeaders["x-skip-safety-jitter"] === "true" ||
1239
+ originalHeaders["x-live-request"] === "true"),
1240
+ );
1241
+ const jitterMs = skipJitter ? 0 : rotator.getSafetyJitterMs(account);
1242
+ const globalDelayMs = skipJitter ? 0 : rotator.getGlobalDelayMs();
1234
1243
  const totalDelayMs = jitterMs + globalDelayMs;
1235
1244
  if (totalDelayMs > 0) {
1236
1245
  if (jitterMs > 0) {
@@ -1682,8 +1691,9 @@ async function handleProxyRequest(
1682
1691
  };
1683
1692
 
1684
1693
  try {
1685
- const jitterMs = rotator.getSafetyJitterMs(account);
1686
- const globalDelayMs = rotator.getGlobalDelayMs();
1694
+ const skipJitter = req.headers["x-skip-safety-jitter"] === "true" || req.headers["x-live-request"] === "true";
1695
+ const jitterMs = skipJitter ? 0 : rotator.getSafetyJitterMs(account);
1696
+ const globalDelayMs = skipJitter ? 0 : rotator.getGlobalDelayMs();
1687
1697
  const totalDelayMs = jitterMs + globalDelayMs;
1688
1698
  if (totalDelayMs > 0) {
1689
1699
  if (jitterMs > 0) {
@@ -2058,6 +2068,17 @@ export function startProxy(
2058
2068
  const url = req.url || "";
2059
2069
  const pathname = url.split("?")[0];
2060
2070
 
2071
+ // CORS headers for API consumers (e.g. MindWhisperAI, local frontends)
2072
+ res.setHeader("Access-Control-Allow-Origin", "*");
2073
+ res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
2074
+ res.setHeader("Access-Control-Allow-Headers", "*");
2075
+
2076
+ if (method === "OPTIONS") {
2077
+ res.writeHead(204);
2078
+ res.end();
2079
+ return;
2080
+ }
2081
+
2061
2082
  if (method === "GET" && (pathname === "/" || pathname === "/dashboard")) {
2062
2083
  if (!requireAdmin(req, res)) return;
2063
2084
  trackFeature("dashboard");
@@ -2475,6 +2496,23 @@ export function startProxy(
2475
2496
  return;
2476
2497
  }
2477
2498
 
2499
+ if (method === "POST" && pathname === "/v1/audio/transcriptions") {
2500
+ handleOpenAIAudioTranscriptions(req, res).catch((err) => {
2501
+ log(`Audio transcription error: ${err}`, rotator, "error");
2502
+ if (!res.headersSent)
2503
+ res.writeHead(500, { "Content-Type": "application/json" });
2504
+ res.end(
2505
+ JSON.stringify({
2506
+ error: {
2507
+ message: "Internal audio transcription error",
2508
+ type: "server_error",
2509
+ },
2510
+ }),
2511
+ );
2512
+ });
2513
+ return;
2514
+ }
2515
+
2478
2516
  if (method === "POST" && pathname === "/v1/responses") {
2479
2517
  handleOpenAIResponsesCreate(req, res, rotator).catch((err) => {
2480
2518
  log(`OpenAI responses compat error: ${err}`, rotator, "error");
@@ -2597,9 +2635,26 @@ export function startProxy(
2597
2635
  res.end(JSON.stringify({ error: "Not found" }));
2598
2636
  });
2599
2637
 
2638
+ server.on("upgrade", (req, socket) => {
2639
+ const url = req.url || "";
2640
+ const pathname = url.split("?")[0];
2641
+ if (
2642
+ pathname === "/ws" ||
2643
+ pathname === "/ws/audio" ||
2644
+ pathname === "/v1/audio/transcriptions/stream" ||
2645
+ pathname === "/v1/listen" ||
2646
+ pathname.startsWith("/ws/")
2647
+ ) {
2648
+ handleAudioWebSocket(req, socket).catch(() => socket.destroy());
2649
+ return;
2650
+ }
2651
+ socket.destroy();
2652
+ });
2653
+
2600
2654
  server.listen(port, bindHost, () => {
2601
2655
  log(`Listening on ${bindHost}:${port}`, rotator);
2602
2656
  log(`Dashboard: http://localhost:${port}/dashboard`, rotator);
2657
+ log(`Audio Stream WS: ws://localhost:${port}/ws`, rotator);
2603
2658
  log(`Hosted login: http://localhost:${port}/login`, rotator);
2604
2659
  });
2605
2660
  return server;
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
  ) {
@@ -1937,6 +1947,14 @@ export class AccountRotator {
1937
1947
  this.requestWaiterWakeAt = wakeAt;
1938
1948
  this.requestWaiterWakeTimer = setTimeout(() => {
1939
1949
  this.requestWaiterWakeTimer = null;
1950
+ if (this.requestWaiters.length === 0) {
1951
+ this.requestWaiterWakeAt = 0;
1952
+ return;
1953
+ }
1954
+ if (Date.now() < wakeAt) {
1955
+ this.scheduleRequestWaiterWake(wakeAt);
1956
+ return;
1957
+ }
1940
1958
  this.requestWaiterWakeAt = 0;
1941
1959
  this.requestWaiterDrain();
1942
1960
  }, Math.max(1, wakeAt - Date.now()));
@@ -2080,6 +2098,16 @@ export class AccountRotator {
2080
2098
  const hasActiveRequests = this.accounts.some(
2081
2099
  (account) => account.inFlightRequests > 0,
2082
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
+ }
2083
2111
  if (modelKey && hasActiveRequests) {
2084
2112
  const leastLoaded = this.pickLeastLoadedModelAccount(modelKey, now);
2085
2113
  if (leastLoaded && leastLoaded !== current) {
@@ -2607,11 +2635,14 @@ export class AccountRotator {
2607
2635
  }
2608
2636
  }
2609
2637
 
2610
- getPredictionSummary(): Record<string, ExhaustionPrediction> {
2638
+ getPredictionSummary(): Record<string, ExhaustionPrediction> {
2611
2639
  const result: Record<string, ExhaustionPrediction> = {};
2612
2640
  const now = Date.now();
2613
2641
  for (const account of this.accounts) {
2614
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.
2615
2646
  const session = account.quota.find((q) => q.modelKey === "session");
2616
2647
  const weekly = account.quota.find((q) => q.modelKey === "weekly");
2617
2648
  if (
@@ -2986,12 +3017,18 @@ export class AccountRotator {
2986
3017
  const quota = account.quota.find(
2987
3018
  (candidate) =>
2988
3019
  candidate.modelKey === modelKey &&
2989
- candidate.providerId === DEFAULT_PROVIDER,
3020
+ (candidate.providerId === DEFAULT_PROVIDER ||
3021
+ candidate.providerId === "ollama" ||
3022
+ candidate.providerId === undefined),
2990
3023
  );
2991
3024
  if (quota) {
2992
3025
  quota.percentRemaining = 0;
2993
3026
  quota.resetTime = new Date(now + cooldownMs).toISOString();
2994
- 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";
2995
3032
  }
2996
3033
  }
2997
3034
 
@@ -3017,7 +3054,9 @@ export class AccountRotator {
3017
3054
  const poolKey = model ? this.resolveAccountPoolKey(account, model) : null;
3018
3055
  const isAccountScopedProvider =
3019
3056
  providerResourceExhausted ||
3020
- (poolKey && (poolKey.startsWith("opencode-zen") || poolKey.startsWith("session")));
3057
+ (poolKey &&
3058
+ (poolKey.startsWith("opencode-zen") ||
3059
+ getProviderIdForPoolKey(poolKey) === "ollama"));
3021
3060
 
3022
3061
  if (isAccountScopedProvider) {
3023
3062
  // Account-level daily/weekly quota exhaustion or per-key rate limit is not a model outage:
@@ -3506,11 +3545,11 @@ export class AccountRotator {
3506
3545
  const modelCooldown =
3507
3546
  account.cooldownsByModel[this.resolveQuotaStateKey(modelKey)] ?? 0;
3508
3547
  if (modelCooldown > now) return false;
3509
- // Ollama Cloud (pool key "session") imposes no per-account concurrency
3548
+ // Ollama Cloud quota pools impose no per-account concurrency
3510
3549
  // limit. Antigravity keeps it so long streams don't pile up on a
3511
3550
  // single account while siblings sit idle.
3512
3551
  if (
3513
- modelKey !== "session" &&
3552
+ !isOllamaQuotaPoolKey(modelKey) &&
3514
3553
  account.inFlightRequests >=
3515
3554
  (this.config.maxConcurrentRequestsPerAccount ?? 5)
3516
3555
  )
@@ -3548,9 +3587,9 @@ export class AccountRotator {
3548
3587
  startRequest(account: AccountRuntime, modelKey?: string): void {
3549
3588
  const key = modelKey ?? "__default__";
3550
3589
  // Ollama Cloud imposes no per-account concurrency limit, so its
3551
- // requests must not activate in-flight tracking at all (pool key
3552
- // "session" and raw ollama model names from benchmark probes).
3553
- 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)) {
3554
3593
  this.consumeTokenBucket(account, Date.now());
3555
3594
  return;
3556
3595
  }
@@ -3562,7 +3601,7 @@ export class AccountRotator {
3562
3601
 
3563
3602
  finishRequest(account: AccountRuntime, modelKey?: string): void {
3564
3603
  const key = modelKey ?? "__default__";
3565
- if (key === "session" || this.ollamaModels.has(key)) return;
3604
+ if (isOllamaQuotaPoolKey(key) || this.ollamaModels.has(key)) return;
3566
3605
  account.inFlightByModel[key] = Math.max(
3567
3606
  0,
3568
3607
  (account.inFlightByModel[key] ?? 0) - 1,
@@ -3659,10 +3698,10 @@ export class AccountRotator {
3659
3698
  private resolvePoolKey(account: AccountRuntime, key: string): string {
3660
3699
  if (
3661
3700
  hasCredential(account.config, "ollama") &&
3662
- key !== "session" &&
3701
+ !isOllamaQuotaPoolKey(key) &&
3663
3702
  this.ollamaModels.has(key)
3664
3703
  ) {
3665
- return "session";
3704
+ return "monthly";
3666
3705
  }
3667
3706
  return key;
3668
3707
  }
@@ -4417,8 +4456,8 @@ export class AccountRotator {
4417
4456
  }
4418
4457
 
4419
4458
  /**
4420
- * Send a minimal single-token request to the upstream Antigravity endpoint for a specific
4421
- * 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.
4422
4461
  * Applies normal error handling (markExhausted, markFlagged, markError) so the account state
4423
4462
  * stays consistent with regular traffic.
4424
4463
  */
@@ -4463,7 +4502,8 @@ export class AccountRotator {
4463
4502
 
4464
4503
  const kickstartAdapter = target.adapter;
4465
4504
  const isOllamaAccount = kickstartAdapter.id === "ollama";
4466
- if (!account.accessToken && !isOllamaAccount) {
4505
+ const hasNativeKickstart = Boolean(kickstartAdapter.forwardKickstartRequest);
4506
+ if (!account.accessToken && !isOllamaAccount && !hasNativeKickstart) {
4467
4507
  return { ok: false, status: 401, upstreamModel: "", error: "no access token" };
4468
4508
  }
4469
4509
 
@@ -4487,7 +4527,22 @@ export class AccountRotator {
4487
4527
  const timeout = setTimeout(() => controller.abort(), 15_000);
4488
4528
 
4489
4529
  let response: Response;
4490
- 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) {
4491
4546
  const ollamaBody: RequestBody = {
4492
4547
  project: "",
4493
4548
  model: upstreamModel,
@@ -4597,11 +4652,12 @@ export class AccountRotator {
4597
4652
  }
4598
4653
 
4599
4654
  if (response.status === 401 || response.status === 403) {
4600
- this.markFlagged(
4601
- account,
4602
- `kickstart ${response.status} on ${upstreamModel}`,
4603
- { triggerProtectivePause: false },
4604
- );
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
+ }
4605
4661
  return { ok: false, status: response.status, upstreamModel };
4606
4662
  }
4607
4663
 
@@ -4612,6 +4668,7 @@ export class AccountRotator {
4612
4668
 
4613
4669
  if (response.ok) {
4614
4670
  this.recordRequest(account, poolKey);
4671
+ target.adapter.clearQuotaCache?.(account);
4615
4672
  this.log(
4616
4673
  `${label} [${poolKey}]: kickstart sent via ${upstreamModel} — ${refreshQuota ? "refreshing quota" : "bulk quota refresh pending"}`,
4617
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
@@ -171,6 +171,9 @@ export const MAX_QUOTA_POLL_INTERVAL_MS = 24 * 60 * 60 * 1000;
171
171
  const DEFAULT_MODEL_ALIASES: Record<string, string> = {
172
172
  "gemini-3.1-pro-high": "gemini-pro-agent",
173
173
  "gpt-oss-120b": "gpt-oss-120b-medium",
174
+ "whisper-1": "models/proactive-observer-v10",
175
+ "proactive-observer": "models/proactive-observer-v10",
176
+ "proactive-observer-v10": "models/proactive-observer-v10",
174
177
  };
175
178
  let modelAliasesOverride: Record<string, string> | null = null;
176
179
  type StoredEffortRoutingRule = {
@@ -316,9 +319,9 @@ export interface ModelQuota {
316
319
  /** Raw usage fraction (0..1) when the provider reports one (Ollama). */
317
320
  usageRaw?: number;
318
321
  resetTime: string | null;
319
- // Timer classification based on resetTime duration
320
- // "fresh" = no active timer, "5h" = short timer, "7d" = long timer
321
- 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";
322
325
  }
323
326
 
324
327
  // Model key mapping for the quota API. One entry per family: all Claude
@@ -378,11 +381,7 @@ export function isStaticAntigravityModel(model: string): boolean {
378
381
  export function resolveQuotaModelKey(requestModel: string): string | null {
379
382
  const lower = requestModel.toLowerCase();
380
383
  if (
381
- lower === "deepseek-v4-flash-free" ||
382
- lower === "nemotron-3.5-lightning-free" ||
383
- lower === "nemotron-3-ultra-free" ||
384
- lower === "mimo-v2.5-free" ||
385
- lower === "hy3-free" ||
384
+ lower === "big-pickle" ||
386
385
  lower.endsWith("-free")
387
386
  ) {
388
387
  return "opencode-zen";
@@ -910,11 +909,12 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
910
909
  cachingPer1M: 0.02,
911
910
  },
912
911
 
913
- // Ollama Cloud model pricing (USD per 1M tokens). Sourced from LiteLLM
914
- // (https://models.litellm.ai/) and verified 2026-08-30 via /api/tags
915
- // discovery + /api/chat probes. Run scripts/verify_ollama_models.ts to refresh.
916
- "gpt-oss:20b": { inputPer1M: 0.075, outputPer1M: 0.30 },
917
- "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 },
918
918
  "deepseek-v4-flash:0731": { inputPer1M: 0.14, outputPer1M: 0.28, cachingPer1M: 0.0028 },
919
919
  "deepseek-v4-pro:0813": { inputPer1M: 1.74, outputPer1M: 3.48 },
920
920
  "qwen3.5:397b": { inputPer1M: 0.60, outputPer1M: 3.60 },
@@ -922,23 +922,24 @@ export const MODEL_PRICING: Record<string, ModelPricing> = {
922
922
  "glm-5.2": { inputPer1M: 0.80, outputPer1M: 2.56 },
923
923
  "glm-5.3": { inputPer1M: 1.40, outputPer1M: 4.40 },
924
924
  "glm-5.3-flash": { inputPer1M: 0.15, outputPer1M: 0.50 },
925
- "gemma4:31b": { inputPer1M: 0.38, outputPer1M: 1.15 },
925
+ "gemma4:31b": { inputPer1M: 0.14, outputPer1M: 0.40, cachingPer1M: 0.05 },
926
926
  "kimi-k2.6": { inputPer1M: 0.95, outputPer1M: 4.00 },
927
927
  "kimi-k2.7-code": { inputPer1M: 0.95, outputPer1M: 4.00 },
928
928
  "kimi-k3": { inputPer1M: 0.95, outputPer1M: 4.00 },
929
929
  "minimax-m2.7": { inputPer1M: 0.30, outputPer1M: 1.20 },
930
930
  "minimax-m3": { inputPer1M: 0.30, outputPer1M: 1.20 },
931
931
  "mistral-large-3:675b": { inputPer1M: 0.50, outputPer1M: 1.50 },
932
- "nemotron-3-nano:30b": { inputPer1M: 0.50, outputPer1M: 1.50 },
933
- "nemotron-3-super": { inputPer1M: 0.60, outputPer1M: 1.80 },
934
- "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 },
935
935
 
936
- // OpenCode Zen free models — equivalent market rates (USD per 1M tokens) for savings tracking
937
- "deepseek-v4-flash-free": { inputPer1M: 0.14, outputPer1M: 0.28, cachingPer1M: 0.0028 },
938
- "nemotron-3.5-lightning-free": { inputPer1M: 0.35, outputPer1M: 1.05 },
939
- "nemotron-3-ultra-free": { inputPer1M: 0.60, outputPer1M: 1.80 },
940
- "mimo-v2.5-free": { inputPer1M: 0.15, outputPer1M: 0.60 },
941
- "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 },
942
943
 
943
944
  };
944
945