tuxevil-rotator 4.0.0 → 4.2.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.
- package/CHANGELOG.md +62 -0
- package/README.md +8 -1
- package/package.json +1 -1
- package/src/audio-transcription.ts +44 -4
- package/src/compat.ts +196 -222
- package/src/config-defaults.ts +5 -0
- package/src/config-overrides.ts +16 -0
- package/src/dashboard-live.ts +10 -8
- package/src/dashboard-types.ts +94 -1
- package/src/dashboard.ts +194 -1
- package/src/effort-levels.ts +43 -0
- package/src/effort-routing.ts +304 -0
- package/src/index.ts +2 -5
- package/src/model-catalog-revision.ts +20 -0
- package/src/model-catalog.ts +304 -0
- package/src/providers/adapter.ts +18 -0
- package/src/providers/google-antigravity/catalog.ts +190 -1
- package/src/providers/google-antigravity/forward.ts +2 -0
- package/src/providers/google-antigravity/index.ts +11 -0
- package/src/providers/google-antigravity/translators.ts +67 -14
- package/src/providers/ollama/index.ts +11 -1
- package/src/providers/ollama/quota-poll-store.ts +22 -1
- package/src/providers/ollama/quota.ts +95 -23
- package/src/providers/openai-codex/catalog.ts +9 -4
- package/src/providers/openai-codex/index.ts +18 -2
- package/src/providers/opencode-zen/index.ts +11 -2
- package/src/proxy.ts +143 -28
- package/src/rotator.ts +296 -21
- package/src/settings-repository.ts +36 -5
- package/src/types.ts +72 -26
- package/src/validators.ts +37 -1
- package/src/web/app.tsx +6 -1
- package/src/web/components/icons.tsx +29 -0
- package/src/web/components/overlays.tsx +13 -1
- package/src/web/components/ui.tsx +6 -1
- package/src/web/lib/accounts.ts +1 -0
- package/src/web/lib/attention.ts +12 -0
- package/src/web/lib/effort.ts +407 -0
- package/src/web/lib/models.ts +284 -0
- package/src/web/lib/pools.ts +53 -9
- package/src/web/lib/status.ts +13 -3
- package/src/web/nav.ts +1 -0
- package/src/web/pages/AccountDetail.tsx +16 -2
- package/src/web/pages/EffortRouting.tsx +1130 -0
- package/src/web/pages/Models.tsx +888 -0
- package/src/web/pages/Overview.tsx +31 -15
- package/src/web/pages/Usage.tsx +3 -3
- package/src/web/state/api.ts +31 -0
- package/src/web/state/model-catalog.ts +103 -0
- package/src/web/state/router.ts +150 -19
- package/src/web/state/store.ts +6 -6
- package/src/web/styles/app.css +854 -0
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,68 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [4.2.0] - 2026-10-14
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- **Effort routing editor**: the Models page gains an **Effort routing** panel and editor, so effort aliases no longer need hand-edited JSON. ([PR #40](https://github.com/tuxevil/tuxevil-rotator/pull/40) by [@CyR1en](https://github.com/CyR1en))
|
|
10
|
+
- It suggests model families with effort variants, such as `gemini-3.6-flash-low`, `-medium` and `-high`, and sets them up in one step.
|
|
11
|
+
- Pick a model for each effort level and choose the default. The editor previews where every kind of request goes and what changes in `/v1/models`.
|
|
12
|
+
- An alias can be turned off, renamed or deleted, and the Models table tags the variants each alias uses. Leaving the editor with unsaved changes, including with Back or Forward, asks first.
|
|
13
|
+
- New `POST`, `PUT` and `DELETE /api/catalog/effort-routes` admin endpoints back it, and `/api/catalog` now reports effort routes and suggestions.
|
|
14
|
+
- **Claude-style effort routing**: `/v1/messages` requests now pick an effort alias's target. `output_config.effort` decides first. Without it, `thinking.budget_tokens` does (under 4,000 is `low`, under 16,000 is `medium`, otherwise `high`), and disabled thinking asks for `low`. Previously these requests always used the default.
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- **Configuration edits apply immediately**: `effortRouting`, `modelAliases` and `modelSpecs` saved from the dashboard now take effect without a restart. Previously the Settings editor reported "Saved and applied" while requests kept the old rules.
|
|
19
|
+
- **Switched-off effort aliases**: requests for an effort alias that is turned off now get `404 model_not_found` (`not_found_error` on `/v1/messages`) whatever its name looks like. Before, an alias whose name didn't look like a Gemini or Claude id was refused later with a generic upstream error.
|
|
20
|
+
- **Gemini 3.5 Flash Lite usage**: requests are now recorded under `gemini-3.5-flash-lite` instead of `gemini-3-flash`, so the Models page and effort routes show its traffic. Pricing is unchanged.
|
|
21
|
+
- **Automatic Codex model discovery**: send the required `client_version` query parameter, accept future numbered GPT versions including `gpt-6.1-sol`, and parse Codex catalog `slug` entries. Refresh discovery during quota polling with a five-minute cache and shared concurrent requests, retaining the last catalog when discovery fails.
|
|
22
|
+
- **Codex account catalogs**: merge model discoveries from all eligible accounts, with at most four concurrent queries, so a restricted first account does not hide models available through other plans.
|
|
23
|
+
- **Effort alias validation**: reject the reserved ID `auto` and URL dot segments `.` and `..`, with errors beside the model ID field.
|
|
24
|
+
- **Unsaved effort edits**: guard Back, Forward, in-app navigation and page unload; confirmed history navigation waits for restoration before proceeding, including immediate confirmations.
|
|
25
|
+
|
|
26
|
+
### Contributors
|
|
27
|
+
|
|
28
|
+
- Thanks to [@CyR1en](https://github.com/CyR1en) for the effort routing editor, Claude-style effort selection, live configuration updates, API and documentation, and regression coverage in [PR #40](https://github.com/tuxevil/tuxevil-rotator/pull/40), including the fixes and browser validation throughout review.
|
|
29
|
+
|
|
30
|
+
## [4.1.0] - 2026-10-13
|
|
31
|
+
|
|
32
|
+
### Added
|
|
33
|
+
|
|
34
|
+
- **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))
|
|
35
|
+
- 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`.
|
|
36
|
+
- Set the provider order that decides who serves a model id more than one provider lists.
|
|
37
|
+
- Optionally hold models a provider adds later until you review them.
|
|
38
|
+
- 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.
|
|
39
|
+
- 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.
|
|
40
|
+
- Accounts with every provider turned off show a new **Off** status instead of **Ready**.
|
|
41
|
+
|
|
42
|
+
### Changed
|
|
43
|
+
|
|
44
|
+
- **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.
|
|
45
|
+
- An Ollama model whose name ends in `-free` now goes to Ollama instead of OpenCode Zen when Zen does not list it.
|
|
46
|
+
- `/v1/models` lists an id that more than one provider serves once, under the provider its requests go to.
|
|
47
|
+
- `/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.
|
|
48
|
+
|
|
49
|
+
### Improved
|
|
50
|
+
|
|
51
|
+
- **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.
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- **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))
|
|
56
|
+
- **Dashboard provider visibility**: connected providers appear on Overview even before quota data arrives; removed redundant provider grouping headings.
|
|
57
|
+
- **Ollama savings estimates**: align estimated savings with official model pricing.
|
|
58
|
+
- **Dashboard dev server**: `npm run dashboard:dev` no longer crashes on `GET /v1/models`.
|
|
59
|
+
- **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.
|
|
60
|
+
- **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.
|
|
61
|
+
- **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.
|
|
62
|
+
|
|
63
|
+
### Contributors
|
|
64
|
+
|
|
65
|
+
- 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).
|
|
66
|
+
|
|
5
67
|
## [4.0.0] - 2026-10-05
|
|
6
68
|
|
|
7
69
|
### Changed
|
package/README.md
CHANGED
|
@@ -53,6 +53,10 @@ Originally built as a multi-account rotator for Google Antigravity. It now gener
|
|
|
53
53
|
|
|
54
54
|
## Current Model Update
|
|
55
55
|
|
|
56
|
+
- **v4.2.0: Effort routing editor**: Create, edit, rename and disable effort aliases from the Models page, with route previews and unsaved-edit protection. Claude-style requests now select variants from `output_config.effort` or thinking budgets, and model configuration edits apply immediately. Includes automatic discovery of future Codex GPT models across account catalogs. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.2.0); [PR #40](https://github.com/tuxevil/tuxevil-rotator/pull/40) by [@CyR1en](https://github.com/CyR1en))
|
|
57
|
+
|
|
58
|
+
- **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))
|
|
59
|
+
|
|
56
60
|
- **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
61
|
- **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
62
|
- **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 +271,8 @@ graph LR
|
|
|
267
271
|
I -.Usage API<br/>every 5 min.-> B
|
|
268
272
|
```
|
|
269
273
|
|
|
274
|
+
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.
|
|
275
|
+
|
|
270
276
|
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
277
|
|
|
272
278
|
How model routing works:
|
|
@@ -284,6 +290,7 @@ After starting the proxy, open `http://localhost:51200/dashboard` and sign in wi
|
|
|
284
290
|
|
|
285
291
|
- **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
292
|
- **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)
|
|
293
|
+
- **Models** — provider order, provider and per-account switches, individual model switches, quota and health summaries, and optional review of newly discovered models
|
|
287
294
|
- **Requests** — a live tail of requests and rotator events, and with PostgreSQL the full history with payloads and per-key totals
|
|
288
295
|
- **Usage** — token volume by model with 1h–30d ranges, estimated savings at list prices, latency percentiles and a 60-day activity heatmap
|
|
289
296
|
- **Virtual keys** and **Settings** — key management, routing controls and policy, a benchmark, and the raw configuration file
|
|
@@ -372,7 +379,7 @@ Thanks to these amazing people who have contributed to the project:
|
|
|
372
379
|
|
|
373
380
|
- **[@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
381
|
- **[@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))
|
|
382
|
+
- **[@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, the effort routing editor, Claude-style effort selection, live configuration updates, unsaved-edit navigation protection, 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), [PR #40](https://github.com/tuxevil/tuxevil-rotator/pull/40))
|
|
376
383
|
- **[@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
384
|
- **[@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
385
|
- **[@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.
|
|
3
|
+
"version": "4.2.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,
|