tuxevil-rotator 3.7.0 → 3.7.2

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.
@@ -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";
@@ -0,0 +1,85 @@
1
+ import type { ServerResponse } from "node:http";
2
+
3
+ export const STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1000;
4
+ export const STREAM_BACKPRESSURE_TIMEOUT_MS = 30 * 1000;
5
+
6
+ export class StreamIdleTimeoutError extends Error {
7
+ constructor(timeoutMs: number) {
8
+ super(`upstream stream idle timeout after ${Math.round(timeoutMs / 1000)}s`);
9
+ this.name = "StreamIdleTimeoutError";
10
+ }
11
+ }
12
+
13
+ /** Resettable guard used to release upstream streams that stop producing data. */
14
+ export function createStreamIdleGuard(
15
+ onTimeout: (error: StreamIdleTimeoutError) => void,
16
+ timeoutMs = STREAM_IDLE_TIMEOUT_MS,
17
+ ): { reset: () => void; clear: () => void } {
18
+ const effectiveTimeoutMs = Number.isFinite(timeoutMs)
19
+ ? Math.max(1, timeoutMs)
20
+ : STREAM_IDLE_TIMEOUT_MS;
21
+ let timer: ReturnType<typeof setTimeout> | null = null;
22
+
23
+ const reset = (): void => {
24
+ if (timer) clearTimeout(timer);
25
+ timer = setTimeout(() => {
26
+ timer = null;
27
+ onTimeout(new StreamIdleTimeoutError(effectiveTimeoutMs));
28
+ }, effectiveTimeoutMs);
29
+ };
30
+
31
+ const clear = (): void => {
32
+ if (timer) clearTimeout(timer);
33
+ timer = null;
34
+ };
35
+
36
+ reset();
37
+ return { reset, clear };
38
+ }
39
+
40
+ /**
41
+ * Respect the HTTP response's high-water mark so a client that stopped
42
+ * reading cannot make the proxy buffer an unbounded streamed response.
43
+ */
44
+ export function waitForResponseDrain(
45
+ res: ServerResponse,
46
+ timeoutMs = STREAM_BACKPRESSURE_TIMEOUT_MS,
47
+ ): Promise<void> {
48
+ if (res.destroyed || res.writableEnded || !res.writableNeedDrain) {
49
+ return Promise.resolve();
50
+ }
51
+
52
+ return new Promise<void>((resolve, reject) => {
53
+ let timer: ReturnType<typeof setTimeout> | null = null;
54
+ let settled = false;
55
+
56
+ const cleanup = (): void => {
57
+ if (timer) clearTimeout(timer);
58
+ res.off("drain", onDrain);
59
+ res.off("close", onClose);
60
+ res.off("error", onError);
61
+ };
62
+ const finish = (error?: Error): void => {
63
+ if (settled) return;
64
+ settled = true;
65
+ cleanup();
66
+ if (error) reject(error);
67
+ else resolve();
68
+ };
69
+ const onDrain = (): void => finish();
70
+ const onClose = (): void =>
71
+ finish(new Error("client response closed while draining backpressure"));
72
+ const onError = (error: Error): void => finish(error);
73
+
74
+ res.once("drain", onDrain);
75
+ res.once("close", onClose);
76
+ res.once("error", onError);
77
+ timer = setTimeout(() => {
78
+ finish(
79
+ new Error(
80
+ `client backpressure timeout after ${Math.round(timeoutMs / 1000)}s`,
81
+ ),
82
+ );
83
+ }, Math.max(1, timeoutMs));
84
+ });
85
+ }
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