tuxevil-rotator 4.0.0 → 4.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.
Files changed (44) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/README.md +6 -1
  3. package/package.json +1 -1
  4. package/src/audio-transcription.ts +44 -4
  5. package/src/compat.ts +196 -222
  6. package/src/config-defaults.ts +5 -0
  7. package/src/dashboard-live.ts +10 -8
  8. package/src/dashboard-types.ts +39 -1
  9. package/src/dashboard.ts +156 -1
  10. package/src/model-catalog-revision.ts +17 -0
  11. package/src/model-catalog.ts +302 -0
  12. package/src/providers/adapter.ts +18 -0
  13. package/src/providers/google-antigravity/catalog.ts +190 -1
  14. package/src/providers/google-antigravity/forward.ts +2 -0
  15. package/src/providers/google-antigravity/index.ts +11 -0
  16. package/src/providers/google-antigravity/translators.ts +4 -0
  17. package/src/providers/ollama/index.ts +11 -1
  18. package/src/providers/ollama/quota-poll-store.ts +22 -1
  19. package/src/providers/ollama/quota.ts +95 -23
  20. package/src/providers/openai-codex/index.ts +18 -2
  21. package/src/providers/opencode-zen/index.ts +11 -2
  22. package/src/proxy.ts +143 -28
  23. package/src/rotator.ts +219 -10
  24. package/src/settings-repository.ts +36 -5
  25. package/src/types.ts +68 -26
  26. package/src/validators.ts +35 -0
  27. package/src/web/app.tsx +4 -0
  28. package/src/web/components/icons.tsx +29 -0
  29. package/src/web/components/ui.tsx +6 -1
  30. package/src/web/lib/accounts.ts +1 -0
  31. package/src/web/lib/attention.ts +12 -0
  32. package/src/web/lib/models.ts +279 -0
  33. package/src/web/lib/pools.ts +53 -9
  34. package/src/web/lib/status.ts +13 -3
  35. package/src/web/nav.ts +1 -0
  36. package/src/web/pages/AccountDetail.tsx +16 -2
  37. package/src/web/pages/Models.tsx +852 -0
  38. package/src/web/pages/Overview.tsx +31 -15
  39. package/src/web/pages/Usage.tsx +3 -3
  40. package/src/web/state/api.ts +18 -0
  41. package/src/web/state/model-catalog.ts +103 -0
  42. package/src/web/state/router.ts +24 -16
  43. package/src/web/state/store.ts +6 -6
  44. package/src/web/styles/app.css +294 -0
package/CHANGELOG.md CHANGED
@@ -2,6 +2,43 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
+ ## [4.1.0] - 2026-10-13
6
+
7
+ ### Added
8
+
9
+ - **Models page**: a new dashboard page at `/dashboard/models` to manage connected providers and the models they serve. ([PR #39](https://github.com/tuxevil/tuxevil-rotator/pull/39) by [@CyR1en](https://github.com/CyR1en))
10
+ - Turn a provider off without signing its accounts out, turn it off for one account only, or turn individual models off. Models that are off leave `/v1/models` and `model: "auto"`, and requests for them get `404 model_not_found`.
11
+ - Set the provider order that decides who serves a model id more than one provider lists.
12
+ - Optionally hold models a provider adds later until you review them.
13
+ - Settings are saved as `providerOrder`, `disabledProviders`, `disabledModels`, `autoEnableNewModels` and `reviewedModels` in the configuration file; per-account switches are kept with the account's state. New `/api/catalog` admin endpoints back the page.
14
+ - The switches also cover requests that reach a model through an alias or effort routing, native `/v1internal` and `/api/chat` requests, audio transcription (with no Language Server fallback around them), benchmarks and warm-up requests.
15
+ - Accounts with every provider turned off show a new **Off** status instead of **Ready**.
16
+
17
+ ### Changed
18
+
19
+ - **One model-to-provider rule**: the proxy, the rotator and the OpenAI, Anthropic and Gemini endpoints now share one rule for which provider serves a model. Each provider lists its models, and ids no provider lists keep the old checks, so routing is unchanged by default.
20
+ - An Ollama model whose name ends in `-free` now goes to Ollama instead of OpenCode Zen when Zen does not list it.
21
+ - `/v1/models` lists an id that more than one provider serves once, under the provider its requests go to.
22
+ - `/v1/messages` answers a Codex model with `400` and a pointer to `/v1/chat/completions` and `/v1/responses`, instead of sending it to Codex in the wrong format.
23
+
24
+ ### Improved
25
+
26
+ - **Codex authentication visibility**: Rejected Codex credentials now appear in the dashboard's Needs you list and the Accounts Needs attention filter, with a direct link to the affected account.
27
+
28
+ ### Fixed
29
+
30
+ - **Dispatch-time switches**: recheck per-account provider switches after token validation in compatibility and native requests, release reservations, and re-admit another account when possible. HTTP audio transcription and WebSocket segments retain the requested model (including `whisper-1`) for dispatch-time checks, so switching it off prevents forwarding and Language Server fallback. Benchmarks also recheck switches after token validation. ([PR #39](https://github.com/tuxevil/tuxevil-rotator/pull/39) by [@CyR1en](https://github.com/CyR1en))
31
+ - **Dashboard provider visibility**: connected providers appear on Overview even before quota data arrives; removed redundant provider grouping headings.
32
+ - **Ollama savings estimates**: align estimated savings with official model pricing.
33
+ - **Dashboard dev server**: `npm run dashboard:dev` no longer crashes on `GET /v1/models`.
34
+ - **Settings writes**: writes to one settings key now run in order, so quick successive changes can no longer leave an older configuration or state on disk.
35
+ - **Ollama quota polling**: Read remaining credits and renewal dates from `/api/balance` instead of treating the consumption histogram at `/api/usage` as quota data. Overview and account details show actual credit balances, invalid responses preserve prior quotas, and purchased credits remain routable after the included balance runs out.
36
+ - **Codex reauthentication state**: A successful Codex login now clears the previous provider rejection and cached Codex access token, so reauthenticated accounts leave Needs attention immediately.
37
+
38
+ ### Contributors
39
+
40
+ - Thanks to [@CyR1en](https://github.com/CyR1en) for the Models page, shared provider catalogs, routing controls, account identity handling, switch-enforcement fixes, documentation, and regression tests in [PR #39](https://github.com/tuxevil/tuxevil-rotator/pull/39).
41
+
5
42
  ## [4.0.0] - 2026-10-05
6
43
 
7
44
  ### Changed
package/README.md CHANGED
@@ -53,6 +53,8 @@ Originally built as a multi-account rotator for Google Antigravity. It now gener
53
53
 
54
54
  ## Current Model Update
55
55
 
56
+ - **v4.1.0: Models and provider controls**: Manage provider order, provider and per-account switches, individual model availability, and review of newly discovered models at `/dashboard/models`. Controls apply to aliases, automatic routing, native requests, audio, benchmarks, and warm-up. Includes Ollama credit-balance polling and clearer Codex reauthentication status. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.1.0); [PR #39](https://github.com/tuxevil/tuxevil-rotator/pull/39) by [@CyR1en](https://github.com/CyR1en))
57
+
56
58
  - **v4.0.0: Redesigned WebUI**: A complete dashboard refresh with live routing health, account management, request history, usage analytics, shareable views, and a responsive Preact interface. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.0.0); [PR #38](https://github.com/tuxevil/tuxevil-rotator/pull/38) by [@CyR1en](https://github.com/CyR1en))
57
59
  - **v3.11.0: automatic agent setup and OpenCode model discovery**: Configure detected or selected agents locally or over SSH with `install-agent`; OpenCode can populate its model catalog from the rotator's live `/v1/models` endpoint. OpenCode Zen requests also forward the real session context and use a consistent User-Agent. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v3.11.0))
58
60
  - **v3.10.0: Claude tools, account-flag diagnostics, and audio reliability**: Fixed Claude Opus 4.6 Thinking tool-schema errors; account verification reasons now persist and flow into anonymous telemetry with a protected recent-incidents dashboard; audio transcription and WebSocket streaming use active Antigravity accounts with Language Server fallback. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v3.10.0); audio hardening in [PR #36](https://github.com/tuxevil/tuxevil-rotator/pull/36) by [@javargasm](https://github.com/javargasm))
@@ -267,6 +269,8 @@ graph LR
267
269
  I -.Usage API<br/>every 5 min.-> B
268
270
  ```
269
271
 
272
+ Ollama Cloud quotas come from `GET /api/balance`: the dashboard shows included credit balances, purchased credits, and provider-reported renewal dates. `GET /api/usage` now reports historical consumption rather than remaining quota. Unrecognized quota responses retain the last known values.
273
+
270
274
  Each model routes to its own best available account independently. The same email can hold both a Google OAuth credential and an Ollama Cloud API key (parent-account model) — the rotator picks the right credential at request time based on the destination model.
271
275
 
272
276
  How model routing works:
@@ -284,6 +288,7 @@ After starting the proxy, open `http://localhost:51200/dashboard` and sign in wi
284
288
 
285
289
  - **Overview** — whether routing works right now, one row per model pool (Claude, Gemini, Codex, Ollama, OpenCode) with pooled quota, the account serving it, what is next in line, the next reset and how long the quota lasts at the current rate, plus a list of what needs you with the fix one click away
286
290
  - **Accounts** — cards with each account's quota per model, or a compact sortable list; each account opens a drawer with its quota windows, routing decisions, health breakdown, limits and every action (re-enable, restore, start idle windows, tier, quarantine, remove)
291
+ - **Models** — provider order, provider and per-account switches, individual model switches, quota and health summaries, and optional review of newly discovered models
287
292
  - **Requests** — a live tail of requests and rotator events, and with PostgreSQL the full history with payloads and per-key totals
288
293
  - **Usage** — token volume by model with 1h–30d ranges, estimated savings at list prices, latency percentiles and a 60-day activity heatmap
289
294
  - **Virtual keys** and **Settings** — key management, routing controls and policy, a benchmark, and the raw configuration file
@@ -372,7 +377,7 @@ Thanks to these amazing people who have contributed to the project:
372
377
 
373
378
  - **[@CelestialCreator](https://github.com/CelestialCreator)** (Akshay) — Fixed admin token propagation on the hosted login landing page (`/login` to `/auth/antigravity/start`). ([PR #25](https://github.com/tuxevil/tuxevil-rotator/pull/25))
374
379
  - **[@Codder-hermes](https://github.com/Codder-hermes)** — Fixed Claude Code tool-schema requests by stripping the unsupported JSON Schema `propertyNames` keyword for Gemini and Claude-via-Gemini routes, with regression coverage for both compatibility paths. ([PR #19](https://github.com/tuxevil/tuxevil-rotator/pull/19))
375
- - **[@CyR1en](https://github.com/CyR1en)** (Ethan Bacurio) — Added Gemini 3.6, Gemini 3.7, and Gemini 3.8 Flash model families, shared quota-pool routing, pricing, dashboard support, integration documentation, effort-based model routing, the rebuilt WebUI, and regression coverage. ([PR #18](https://github.com/tuxevil/tuxevil-rotator/pull/18), [PR #21](https://github.com/tuxevil/tuxevil-rotator/pull/21), [PR #28](https://github.com/tuxevil/tuxevil-rotator/pull/28), [PR #32](https://github.com/tuxevil/tuxevil-rotator/pull/32), [PR #38](https://github.com/tuxevil/tuxevil-rotator/pull/38))
380
+ - **[@CyR1en](https://github.com/CyR1en)** (Ethan Bacurio) — Added Gemini 3.6, Gemini 3.7, and Gemini 3.8 Flash model families, shared quota-pool routing, pricing, dashboard support, integration documentation, effort-based model routing, the rebuilt WebUI, the Models page with provider/model controls and dispatch-time switch enforcement, and regression coverage. ([PR #18](https://github.com/tuxevil/tuxevil-rotator/pull/18), [PR #21](https://github.com/tuxevil/tuxevil-rotator/pull/21), [PR #28](https://github.com/tuxevil/tuxevil-rotator/pull/28), [PR #32](https://github.com/tuxevil/tuxevil-rotator/pull/32), [PR #38](https://github.com/tuxevil/tuxevil-rotator/pull/38), [PR #39](https://github.com/tuxevil/tuxevil-rotator/pull/39))
376
381
  - **[@josenicomaia](https://github.com/josenicomaia)** (José Nicodemos Maia Neto) — Modularized the compatibility layer architecture, added multimodal tool response support, fixed streaming pass-through for tool executions, and added PostgreSQL storage and weighted pool quota forecasting. ([PR #8](https://github.com/tuxevil/tuxevil-rotator/pull/8), [PR #9](https://github.com/tuxevil/tuxevil-rotator/pull/9), [PR #11](https://github.com/tuxevil/tuxevil-rotator/pull/11), [PR #13](https://github.com/tuxevil/tuxevil-rotator/pull/13), [PR #14](https://github.com/tuxevil/tuxevil-rotator/pull/14))
377
382
  - **[@yashyadav711](https://github.com/yashyadav711)** (Yash) — Fixed Draft-2020-12 inline JSON-Schema union type mapping for Gemini tools support. ([PR #10](https://github.com/tuxevil/tuxevil-rotator/pull/10))
378
383
  - **[@toRolex](https://github.com/toRolex)** (Rolex) — Added cached prompt-token extraction from Google Antigravity/Cloud Code usage and mapped it to OpenAI and Anthropic compatibility responses, with focused regression tests, plus transport-error retry recovery for single-account and exhausted-account pools. ([PR #34](https://github.com/tuxevil/tuxevil-rotator/pull/34), [PR #35](https://github.com/tuxevil/tuxevil-rotator/pull/35))
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuxevil-rotator",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
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",
@@ -14,6 +14,7 @@ import type { AccountRotator } from "./rotator.js";
14
14
  import { withRotation, type RequestBody } from "./proxy.js";
15
15
  import { extractRetryAfterSeconds } from "./compat.js";
16
16
  import { getModelSpec } from "./compat/model-specs.js";
17
+ import { isRequestOff, modelOffMessage } from "./model-catalog.js";
17
18
 
18
19
  const audioLogger = logger.child("audio-transcription");
19
20
  const AUDIO_SESSION_START_TIMEOUT_MS = 10_000;
@@ -111,6 +112,8 @@ export function resolveMimeType(fileName: string, mimeType?: string): string {
111
112
  export interface TranscribeOptions {
112
113
  mimeType?: string;
113
114
  model?: string;
115
+ /** Model the client asked for (e.g. whisper-1), rechecked against the switches at dispatch. */
116
+ catalogModel?: string;
114
117
  prompt?: string;
115
118
  language?: string;
116
119
  signal?: AbortSignal;
@@ -272,6 +275,7 @@ export async function transcribeAudioWithRotator(
272
275
 
273
276
  const body: RequestBody = {
274
277
  model: targetModel,
278
+ catalogModel: options.catalogModel,
275
279
  project: "",
276
280
  request: {
277
281
  contents: [
@@ -935,6 +939,21 @@ export async function handleOpenAIAudioTranscriptions(
935
939
  sendAuthErrorResponse(res, modelAuth);
936
940
  return;
937
941
  }
942
+ if (rotator && isRequestOff(rotator, { model: executedModel, catalogModel: requestedModel ?? "whisper-1" })) {
943
+ logRequest("failure");
944
+ res.writeHead(404, { "Content-Type": "application/json" });
945
+ res.end(
946
+ JSON.stringify({
947
+ error: {
948
+ message: modelOffMessage(requestedModel ?? "whisper-1"),
949
+ type: "invalid_request_error",
950
+ param: "model",
951
+ code: "model_not_found",
952
+ },
953
+ }),
954
+ );
955
+ return;
956
+ }
938
957
  // Every executed request is accounted to the model that actually ran upstream.
939
958
  spendModel = executedModel;
940
959
  apiKeyHash = modelAuth.key?.tokenHash || (modelAuth.rawKey ? hashKey(modelAuth.rawKey) : apiKeyHash);
@@ -976,6 +995,7 @@ export async function handleOpenAIAudioTranscriptions(
976
995
  transcribedText = await transcribeAudioWithRotator(rotator, audioBuffer, {
977
996
  mimeType,
978
997
  model: executedModel,
998
+ catalogModel: requestedModel ?? "whisper-1",
979
999
  prompt,
980
1000
  language,
981
1001
  signal: transcriptionSignal,
@@ -984,6 +1004,10 @@ export async function handleOpenAIAudioTranscriptions(
984
1004
  if (clientAbortController.signal.aborted || isRotatorTranscriptionTimeout(rotatorErr)) {
985
1005
  throw rotatorErr;
986
1006
  }
1007
+ // A switch turned off mid-request: the fallback would bypass it.
1008
+ if (isRequestOff(rotator, { model: executedModel, catalogModel: requestedModel ?? "whisper-1" })) {
1009
+ throw new AudioTranscriptionError(modelOffMessage(requestedModel ?? "whisper-1"), 404);
1010
+ }
987
1011
  audioLogger.warn(
988
1012
  `Rotator transcription failed: ${(rotatorErr as Error).message}, attempting Language Server fallback`,
989
1013
  );
@@ -1050,7 +1074,7 @@ export async function handleOpenAIAudioTranscriptions(
1050
1074
  logRequest("failure");
1051
1075
  audioLogger.error(`Transcription failed: ${error.message}`);
1052
1076
  const status =
1053
- err instanceof AudioTranscriptionError && [429, 502, 503, 504].includes(err.status) ? err.status : 500;
1077
+ err instanceof AudioTranscriptionError && [404, 429, 502, 503, 504].includes(err.status) ? err.status : 500;
1054
1078
  let retrySec: number | null = null;
1055
1079
  if (err instanceof AudioTranscriptionError && (status === 429 || status === 503)) {
1056
1080
  retrySec = err.retryAfterMs
@@ -1066,8 +1090,8 @@ export async function handleOpenAIAudioTranscriptions(
1066
1090
  JSON.stringify({
1067
1091
  error: {
1068
1092
  message: `Transcription error: ${error.message}`,
1069
- type: status === 429 ? "rate_limit_error" : "api_error",
1070
- code: status === 429 ? "rate_limit_exceeded" : null,
1093
+ type: status === 429 ? "rate_limit_error" : status === 404 ? "invalid_request_error" : "api_error",
1094
+ code: status === 429 ? "rate_limit_exceeded" : status === 404 ? "model_not_found" : null,
1071
1095
  ...(retrySec ? { retry_after_seconds: retrySec } : {}),
1072
1096
  },
1073
1097
  }),
@@ -1684,6 +1708,7 @@ export function appendDeduplicated(existing: string, addition: string): string {
1684
1708
  export class RotatorAudioSession implements AudioTranscriptionSession {
1685
1709
  public sessionId: string;
1686
1710
  public model: string;
1711
+ private catalogModel?: string;
1687
1712
  public continuous: boolean;
1688
1713
  public language?: string;
1689
1714
  private rotator: AccountRotator;
@@ -1725,6 +1750,7 @@ export class RotatorAudioSession implements AudioTranscriptionSession {
1725
1750
  rotator: AccountRotator,
1726
1751
  options: {
1727
1752
  model?: string;
1753
+ catalogModel?: string;
1728
1754
  continuous?: boolean;
1729
1755
  language?: string;
1730
1756
  onEvent?: (event: any) => void;
@@ -1734,6 +1760,7 @@ export class RotatorAudioSession implements AudioTranscriptionSession {
1734
1760
  this.rotator = rotator;
1735
1761
  this.sessionId = `session-rotator-${Date.now()}-${crypto.randomUUID()}`;
1736
1762
  this.model = resolveAudioTranscriptionModel(options.model);
1763
+ this.catalogModel = options.catalogModel;
1737
1764
  this.continuous = options.continuous ?? false;
1738
1765
  this.language = options.language;
1739
1766
  this.onEvent = options.onEvent || (() => {});
@@ -1892,6 +1919,7 @@ export class RotatorAudioSession implements AudioTranscriptionSession {
1892
1919
  try {
1893
1920
  rawText = await transcribeAudioWithRotator(this.rotator, wav, {
1894
1921
  model: this.model,
1922
+ catalogModel: this.catalogModel,
1895
1923
  language: this.language,
1896
1924
  timeoutMs: LIVE_ROTATOR_TRANSCRIPTION_TIMEOUT_MS,
1897
1925
  signal: segmentSignal,
@@ -1918,6 +1946,9 @@ export class RotatorAudioSession implements AudioTranscriptionSession {
1918
1946
  if (this.abortController.signal.aborted || segmentDeadlineController.signal.aborted) {
1919
1947
  throw rotatorErr;
1920
1948
  }
1949
+ if (isRequestOff(this.rotator, { model: this.model, catalogModel: this.catalogModel })) {
1950
+ throw new AudioTranscriptionError(modelOffMessage(this.catalogModel ?? this.model), 404);
1951
+ }
1921
1952
  audioLogger.warn(
1922
1953
  `[RotatorAudioSession] Segment #${item.seqId} rotator transcription failed: ${(rotatorErr as Error)?.message || rotatorErr}, attempting Language Server fallback`,
1923
1954
  );
@@ -2184,7 +2215,7 @@ async function authorizeClientModel(
2184
2215
  function createClientSession(
2185
2216
  client: AudioWsClient,
2186
2217
  model: string,
2187
- options: { preCursorText?: string; postCursorText?: string; continuous?: boolean; language?: string },
2218
+ options: { catalogModel?: string; preCursorText?: string; postCursorText?: string; continuous?: boolean; language?: string },
2188
2219
  ): AudioTranscriptionSession {
2189
2220
  client.tStartTime = Date.now();
2190
2221
  client.tFirstAntigravity = null;
@@ -2270,6 +2301,14 @@ async function handleClientCommand(client: AudioWsClient, cmd: any): Promise<voi
2270
2301
  const requested = cmd.antigravityModel || cmd.model ? String(cmd.antigravityModel || cmd.model) : undefined;
2271
2302
  const model = resolveClientExecutedModel(client, requested);
2272
2303
  if (!(await authorizeClientModel(client, model, requested))) return;
2304
+ if (
2305
+ client.rotator &&
2306
+ typeof client.rotator.getActiveAccount === "function" &&
2307
+ isRequestOff(client.rotator, { model, catalogModel: requested ?? "whisper-1" })
2308
+ ) {
2309
+ client.send({ type: "antigravity_error", event: "error", message: modelOffMessage(requested ?? model) });
2310
+ return;
2311
+ }
2273
2312
  if (client.antigravity) {
2274
2313
  finishClientSpend(client, "success");
2275
2314
  destroyClientSession(client);
@@ -2282,6 +2321,7 @@ async function handleClientCommand(client: AudioWsClient, cmd: any): Promise<voi
2282
2321
  });
2283
2322
 
2284
2323
  const session = createClientSession(client, model, {
2324
+ catalogModel: requested ?? "whisper-1",
2285
2325
  preCursorText: cmd.preCursorText || "",
2286
2326
  postCursorText: cmd.postCursorText || "",
2287
2327
  continuous: cmd.continuous ?? false,