tuxevil-rotator 4.4.7 → 4.4.9

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 CHANGED
@@ -2,6 +2,29 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## [4.4.9] - 2026-11-24
6
+
7
+ ### Fixed
8
+
9
+ - **Paid Claude kickstart fallback**: Select account-aware Claude kickstart models for paid Pro, Ultra, Plus, Max, and Team tiers, preferring advertised Sonnet 5.5 candidates while retaining the historical primary as a compatibility fallback. Retry model-specific 400/404/403 and 5xx failures with per-model backoff without counting them as consecutive account errors; quota-exhaustion 429s do not switch models, and an explicit Free tier takes precedence over legacy Pro metadata. Gemini keeps its existing primary model.
10
+ - **Telemetry receiver account and install aggregation**: Detect paid tiers in `proDetected`/`wasProAccount`, accept larger model catalogs and heartbeat payloads, preserve install state when processing flag events, and aggregate per-model token maxima consistently.
11
+ - **OpenCode discovery recovery**: Keep `ctx.provider.transform` registered and retry automatically (`retryMs`, default 5s) when the rotator is temporarily unreachable at startup; preserve the last known-good model catalog when refreshes return an empty list or transient error.
12
+
13
+ ## [4.4.8] - 2026-11-23
14
+
15
+ ### Fixed
16
+
17
+ - **Invalid-provider polling & kickstart flag loop**: Stop `pollAccountQuotaOnce()`, `kickstartAllFreshTimers()`, and `kickstartTimerForAccount()` from repeatedly hitting providers already marked invalid or disabled on an account, emit `reportQuotaPollFlag()` only on valid-to-invalid transitions, and clear `invalidProviders` across all providers when updated credentials are saved via `addOrUpdateAccount()`.
18
+ - **Telemetry receiver aggregation & live flag deduplication**: Fix double-counting of `flags.totalFlags` / `daily[].flags` (using `-flags.jsonl` as the canonical source), compute `totalRequestsAcrossAll` by summing each unique install's cumulative maximum instead of summing repeated hourly heartbeats, and deduplicate repeating flag loops within a 24-hour sliding window (`FLAG_DEDUP_WINDOW_MS`) with startup warm-up.
19
+
20
+ ### Changed
21
+
22
+ - **Telemetry receiver UX**: Redesign `/dashboard`, `/notifications`, and `/stats` in a unified cyberpunk/retro-console UI with tabbed views (`Overview`, `Flags & Forensics`, `Models & USD`, `Installs`), interactive incident/node inspector drawers, concentration alerts, semver notification targeting simulator, quick templates/expiry presets, shared token SSO, keyboard shortcuts, and enriched `/v1/stats` & `/v1/public-stats` payloads.
23
+
24
+ ### Security
25
+
26
+ - **Telemetry receiver hardening**: Fix unauthenticated Stored XSS in `/dashboard` (`proCount`/`freeCount`/`flaggedCount`/`disabledCount` validation + escaping), prevent `NaN` savings poisoning via prototype keys in `MODEL_PRICING` and `featuresCount`, enforce constant-time `timingSafeEqual` token comparison with `401` brute-force lockout, restrict `X-Forwarded-For` parsing to `TRUSTED_PROXIES` with bounded rate-limit maps and daily JSONL size caps, add CSP/XFO/nosniff/SRI headers and scoped CORS, add HTTP/body anti-Slowloris timeouts, enforce absolute `http(s)` notification URLs, write `notifications.json` atomically, and add incremental JSONL file caching.
27
+
5
28
  ## [4.4.7] - 2026-11-23
6
29
 
7
30
  ### Changed
package/README.md CHANGED
@@ -55,6 +55,8 @@ Originally built as a multi-account rotator for Google Antigravity. It now gener
55
55
 
56
56
  ## Current Model Update
57
57
 
58
+ - **v4.4.9: Claude paid-tier kickstart fallback, telemetry accuracy, and OpenCode recovery**: Use account-aware Claude Sonnet 5.5 kickstart candidates for paid tiers with safe model-specific fallbacks and backoff, without changing Gemini's primary or switching models on quota-exhaustion 429s. Correct paid-tier and install telemetry aggregation, and retry OpenCode model discovery after transient startup failures while retaining the last good catalog. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.4.9))
59
+ - **v4.4.8: Invalid-provider flag loop fix & telemetry receiver overhaul**: Stop quota polling and auto-warmup kickstarts from looping every 5 minutes on already-invalidated or disabled providers (emitting flag telemetry only on transitions and clearing invalidation across all providers on re-auth). Overhaul the standalone telemetry receiver with a cyberpunk/retro-console UX across `/dashboard`, `/notifications`, and `/stats`, fix flag double-counting and request inflation, add 24h sliding-window flag-loop deduplication, and harden security (Stored XSS fix, prototype-safe pricing, constant-time auth + brute-force lockout, trusted-proxy rate limiting, CSP/SRI, scoped CORS, and HTTP timeouts). ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.4.8))
58
60
  - **v4.4.7: Artificial Analysis scores, static specs, and dashboard colors**: Refresh the Artificial Analysis Intelligence Index routing-quality snapshot (`2026-11-23`) with exact per-effort scores for Gemini 4 (`neon`, `hydrogen`, `carbon`, `argon`), Gemini 3.8 Flash, Claude 5.5, and OpenAI `gpt-6.1`/`gpt-6.2`, and add static model specs, context windows, and distinct dashboard chart colors for Gemini 4, Claude 5.5, GPT-6.1/6.2, and newer Ollama Cloud models. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.4.7))
59
61
  - **v4.4.6: Model pricing refresh**: Add official November 2026 pricing and family fallbacks for Gemini 4 (`neon`, `hydrogen`, `carbon`, `argon`), Claude 5.5 (`opus`, `sonnet`), OpenAI `gpt-6.1`/`gpt-6.2`, and newly published Ollama Cloud models in both the rotator and standalone telemetry receiver. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.4.6))
60
62
  - **v4.4.5: Antigravity reasoning effort metadata**: Publish `meta.reasoning_efforts` and `meta.default_reasoning_effort` for Antigravity `effortRouting` aliases and adaptive `-tiered` Gemini models in `GET /v1/models`, and merge discovered effort controls in the OpenCode discovery plugin so Gemini and Claude models expose effort variants. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.4.5))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuxevil-rotator",
3
- "version": "4.4.7",
3
+ "version": "4.4.9",
4
4
  "description": "Multi-provider, multi-account AI proxy rotator with per-model routing, real-time quota tracking, and infringement detection (Google Antigravity, Ollama Cloud)",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -15,6 +15,7 @@
15
15
  * - providerName display name (default "Antigravity (rotator)")
16
16
  * - timeoutMs fetch timeout (default 3500)
17
17
  * - refreshMs background re-discovery interval (default 600000; 0 disables)
18
+ * - retryMs retry interval while initial discovery has not succeeded yet (default 5000)
18
19
  */
19
20
 
20
21
  import { openCodeReasoning, openCodeVariants } from "./capabilities.mjs"
@@ -138,12 +139,19 @@ export function resolvePluginOptions(options = {}, providerEntries = []) {
138
139
  let end = baseURLText.length
139
140
  while (end > 0 && baseURLText.charCodeAt(end - 1) === 47) end--
140
141
 
142
+ const refreshMs = options.refreshMs === 0 ? 0 : Number(options.refreshMs) || 600_000
143
+ const retryMs =
144
+ refreshMs <= 0
145
+ ? 0
146
+ : Math.min(refreshMs, Math.max(1, Number(options.retryMs) || 5_000))
147
+
141
148
  return {
142
149
  baseURL: baseURLText.slice(0, end),
143
150
  providerID: providerID || "antigravity",
144
151
  providerName: providerName || "Antigravity (rotator)",
145
152
  timeoutMs: Number(options.timeoutMs) || 3500,
146
- refreshMs: options.refreshMs === 0 ? 0 : Number(options.refreshMs) || 600_000,
153
+ refreshMs,
154
+ retryMs,
147
155
  }
148
156
  }
149
157
 
@@ -274,20 +282,29 @@ export default {
274
282
  async function load() {
275
283
  try {
276
284
  const models = await fetchRotatorModels(resolved.baseURL, resolved.timeoutMs)
277
- const list = Array.isArray(models) ? models : []
278
- const changed = lastSignature !== null && modelSignature(list) !== lastSignature
285
+ const list = Array.isArray(models) ? models.filter((m) => typeof m?.id === "string" && m.id.length > 0) : []
286
+ if (list.length === 0) {
287
+ // Never wipe the last known good catalog on a transient empty response
288
+ console.warn("[opencode-discovery] model discovery returned an empty catalog; keeping previous inventory")
289
+ return { ok: false, changed: false, invalidUrl: false }
290
+ }
291
+ const sig = modelSignature(list)
292
+ const changed = lastSignature !== sig
279
293
  source.models = list
280
- lastSignature = modelSignature(list)
281
- return { ok: true, changed }
294
+ lastSignature = sig
295
+ return { ok: true, changed, invalidUrl: false }
282
296
  } catch (err) {
297
+ const msg = err?.message ?? String(err)
298
+ const invalidUrl = msg.includes("fetch() URL is invalid") || msg.includes("Unsupported URL protocol")
283
299
  // Safe degrade: never fail OpenCode startup when the rotator is unreachable
284
- console.warn(`[opencode-discovery] model discovery skipped: ${err?.message ?? err}`)
285
- return { ok: false, changed: false }
300
+ console.warn(`[opencode-discovery] model discovery skipped: ${msg}`)
301
+ return { ok: false, changed: false, invalidUrl }
286
302
  }
287
303
  }
288
304
 
289
305
  const first = await load()
290
- if (!first.ok || !source.models?.length) return undefined
306
+ if (first.invalidUrl) return undefined
307
+ if (!first.ok && resolved.refreshMs <= 0) return undefined
291
308
 
292
309
  const toModelInfo = (raw, existingModel) => {
293
310
  const { id, modelDef } = mapModelToOpenCode(raw)
@@ -324,20 +341,32 @@ export default {
324
341
 
325
342
  if (resolved.refreshMs <= 0) return undefined
326
343
 
327
- const timer = setInterval(() => {
328
- void (async () => {
329
- const result = await load()
330
- if (!result.changed) return
331
- try {
332
- await ctx.provider.reload()
333
- } catch {
334
- // Registry reload unavailable; keep the last known inventory
335
- }
336
- })()
337
- }, resolved.refreshMs)
338
- if (typeof timer.unref === "function") timer.unref()
344
+ let stopped = false
345
+ let timer = null
346
+ const scheduleNext = () => {
347
+ if (stopped) return
348
+ const delayMs = source.models?.length ? resolved.refreshMs : resolved.retryMs
349
+ timer = setTimeout(() => {
350
+ void (async () => {
351
+ const result = await load()
352
+ if (!stopped && result.ok && result.changed) {
353
+ try {
354
+ await ctx.provider.reload()
355
+ } catch {
356
+ // Registry reload unavailable; keep the last known inventory
357
+ }
358
+ }
359
+ scheduleNext()
360
+ })()
361
+ }, delayMs)
362
+ if (typeof timer.unref === "function") timer.unref()
363
+ }
364
+ scheduleNext()
339
365
 
340
- return () => clearInterval(timer)
366
+ return () => {
367
+ stopped = true
368
+ if (timer) clearTimeout(timer)
369
+ }
341
370
  },
342
371
  }
343
372
 
@@ -168,6 +168,11 @@ export interface ProviderAdapter {
168
168
  getPoolKey?(model: string): string;
169
169
  /** Cheap upstream model that warms a quota pool during kickstart. */
170
170
  getKickstartModelForPool(quotaModelKey: string): string | undefined;
171
+ /** Ordered kickstart candidate models for a quota pool (primary + fallbacks), optionally tailored to an account. */
172
+ getKickstartModelsForPool?(
173
+ quotaModelKey: string,
174
+ account?: AccountRuntime,
175
+ ): string[];
171
176
  /** Benchmark request used to measure account latency/health. */
172
177
  getBenchmark(account: AccountRuntime): {
173
178
  body: RequestBody;
@@ -34,10 +34,16 @@ import {
34
34
  import {
35
35
  TOKEN_URL,
36
36
  KICKSTART_MODEL_FOR_QUOTA_POOL,
37
+ KICKSTART_FALLBACK_MODELS_FOR_QUOTA_POOL,
38
+ KICKSTART_PRO_MODELS_FOR_QUOTA_POOL,
37
39
  applyModelAlias,
38
40
  resolveQuotaModelKey,
39
41
  } from "../../types.js";
40
42
  import type { AccountRuntime } from "../../types.js";
43
+ import {
44
+ getAccountIdentity,
45
+ getCredentialGeneration,
46
+ } from "../../account-identity.js";
41
47
  import { fetchWithRetry } from "../../fetch-with-retry.js";
42
48
  import { logger } from "../../logger.js";
43
49
  import { getAccountProxyDispatcher } from "../proxy-dispatcher.js";
@@ -175,6 +181,57 @@ export const googleAntigravityAdapter: ProviderAdapter = {
175
181
  );
176
182
  },
177
183
 
184
+ getKickstartModelsForPool(
185
+ quotaModelKey: string,
186
+ account?: AccountRuntime,
187
+ ): string[] {
188
+ const pool = KICKSTART_MODEL_FOR_QUOTA_POOL[quotaModelKey]
189
+ ? quotaModelKey
190
+ : resolveQuotaModelKey(quotaModelKey) ?? "";
191
+ const primary = KICKSTART_MODEL_FOR_QUOTA_POOL[pool];
192
+ if (!pool || !primary) return [];
193
+
194
+ const snapshot = account
195
+ ? dynamicCatalog.getAccountSnapshot(
196
+ getAccountIdentity(account),
197
+ getCredentialGeneration(account.config, "google-antigravity"),
198
+ )
199
+ : undefined;
200
+ const snapshotSet = snapshot
201
+ ? new Set(snapshot.models.map((model) => model.toLowerCase()))
202
+ : null;
203
+
204
+ const tier = account?.config.tier;
205
+ const isExplicitlyFree = tier === "free";
206
+ const isProOrHigher = isExplicitlyFree
207
+ ? false
208
+ : tier === "pro" || tier === "ultra" || tier === "plus" ||
209
+ tier === "max" || tier === "team" || account?.config.type === "pro";
210
+ const snapshotHasSonnet55 = Boolean(
211
+ snapshotSet &&
212
+ (snapshotSet.has("claude-sonnet-5-5-low") ||
213
+ snapshotSet.has("claude-sonnet-5-5-medium")),
214
+ );
215
+ const useProOrder = pool === "claude" && !isExplicitlyFree &&
216
+ (isProOrHigher || snapshotHasSonnet55);
217
+ const preferred =
218
+ (useProOrder
219
+ ? KICKSTART_PRO_MODELS_FOR_QUOTA_POOL[pool]
220
+ : KICKSTART_FALLBACK_MODELS_FOR_QUOTA_POOL[pool]) ?? [primary];
221
+
222
+ if (snapshotSet) {
223
+ const inSnapshot = preferred.filter((model) =>
224
+ snapshotSet.has(model.toLowerCase()),
225
+ );
226
+ if (inSnapshot.length > 0) return inSnapshot;
227
+ return [primary];
228
+ }
229
+
230
+ // Without a per-account catalog, preserve only the existing primary.
231
+ if (pool === "gemini") return [primary];
232
+ return [...preferred];
233
+ },
234
+
178
235
  listModels(): ProviderModel[] {
179
236
  return getEffectiveAntigravityModels().map((model) => ({
180
237
  id: model.id,