tuxevil-rotator 4.2.2 → 4.3.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 (39) hide show
  1. package/CHANGELOG.md +27 -1
  2. package/README.md +9 -4
  3. package/package.json +1 -1
  4. package/plugins/opencode-discovery/capabilities.d.mts +7 -0
  5. package/plugins/opencode-discovery/capabilities.mjs +54 -0
  6. package/plugins/opencode-discovery/index.d.mts +2 -1
  7. package/plugins/opencode-discovery/index.mjs +6 -1
  8. package/plugins/opencode-discovery/package.json +3 -1
  9. package/src/audio-transcription.ts +32 -6
  10. package/src/cli.ts +3 -3
  11. package/src/compat/model-specs.ts +4 -0
  12. package/src/compat.ts +30 -1
  13. package/src/dashboard-app.ts +1 -0
  14. package/src/install-agent.ts +211 -129
  15. package/src/install-opencode.ts +80 -18
  16. package/src/providers/google-antigravity/catalog.ts +14 -6
  17. package/src/providers/google-antigravity/dynamic-catalog.ts +79 -3
  18. package/src/providers/google-antigravity/forward.ts +4 -2
  19. package/src/providers/google-antigravity/quota.ts +4 -0
  20. package/src/providers/ollama/forward.ts +10 -0
  21. package/src/providers/openai-codex/catalog.ts +157 -18
  22. package/src/proxy.ts +35 -2
  23. package/src/rotator.ts +16 -2
  24. package/src/types.ts +78 -29
  25. package/src/web/app.tsx +4 -0
  26. package/src/web/lib/audio-recorder.ts +159 -0
  27. package/src/web/lib/colors.ts +4 -0
  28. package/src/web/lib/playground-storage.ts +261 -0
  29. package/src/web/lib/playground.ts +448 -0
  30. package/src/web/nav.ts +1 -0
  31. package/src/web/pages/Playground.tsx +1111 -0
  32. package/src/web/pages/Transcription.tsx +428 -0
  33. package/src/web/state/api.ts +3 -0
  34. package/src/web/state/playground-client.ts +136 -0
  35. package/src/web/state/playground.ts +69 -0
  36. package/src/web/state/router.ts +2 -2
  37. package/src/web/state/transcription-client.ts +93 -0
  38. package/src/web/styles/app.css +45 -0
  39. package/tools/telemetry-receiver/receiver.js +59 -46
package/CHANGELOG.md CHANGED
@@ -1,6 +1,32 @@
1
1
  # Changelog
2
2
 
3
- ## [Unreleased]
3
+ ## [4.3.0] - 2026-10-29
4
+
5
+ ### Added
6
+
7
+ - **Dashboard Playground**: New `/dashboard/playground` workspace (`?tab=chat|compare|compliance|transcription`) for testing enabled models directly from an authenticated admin session via same-origin `/api/playground/chat/completions`, `/api/playground/audio/transcriptions`, and `/api/playground/config` routes without requiring a virtual key. ([PR #43](https://github.com/tuxevil/tuxevil-rotator/pull/43))
8
+ - **Chat & Compare**: Multi-turn chat with PNG/JPEG/WebP vision attachments, system prompt, streaming, temperature, max output tokens, reasoning effort, and OpenAI tools JSON inspection, plus side-by-side 2–3 model comparison with synchronized or per-panel controls.
9
+ - **API Compliance**: Five-case Chat Completions verification suite (basic response structure, SSE streaming, system instruction, JSON mode output, and forced tool calling) across up to three concurrent model workers.
10
+ - **Transcription**: Audio file upload (`.wav`, `.mp3`, `.m4a`, `.webm`, `.ogg`, `.oga`, `.flac`, `.pcm`) and browser `MediaRecorder` microphone capture with preview, lifecycle cleanup, and transcript export.
11
+ - **Local workspaces**: Browser IndexedDB persistence with versioned JSON export/import and privacy-mask redaction; raw audio stays in-tab only.
12
+ - **Codex reasoning metadata & agent connectors**: Expose `meta.reasoning`, `meta.reasoning_efforts` (`low`, `medium`, `high`, `xhigh`, `max`), and `meta.default_reasoning_effort` on Codex entries in `GET /v1/models` from upstream discovery and known-model defaults (excluding harness-only `ultra`). Propagate reasoning capabilities across `install-opencode`, the OpenCode 2 discovery plugin (including metadata-only refreshes), and `install-agent` for OpenCode, Hermes, Pi, and the new `openclaw` target (`--target openclaw`, `auto`, and `all`) while preserving existing user configs. ([PR #43](https://github.com/tuxevil/tuxevil-rotator/pull/43))
13
+
14
+ ### Fixed
15
+
16
+ - **Ollama vision base64 payloads**: Strip `data:<mime>;base64,` prefixes when building Ollama `images[]` payloads so multimodal requests (such as `gemma4:31b`) no longer fail upstream with `illegal base64 data`.
17
+ - **OGA audio uploads**: Accept `.oga` files in the transcription playground and preserve `audio/ogg` MIME type and raw Ogg bytes without PCM/WAV re-wrapping. ([PR #43](https://github.com/tuxevil/tuxevil-rotator/pull/43))
18
+ - **Persistent Antigravity catalogs**: Save versioned model snapshots per account with credential fingerprints and validated metadata, restoring availability before the first quota poll. Persist successful catalog updates even without quota values, reject malformed saved snapshots, and exclude disabled or flagged accounts. Historical model IDs without an active snapshot return 404 without forwarding. ([PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42) by [@javargasm](https://github.com/javargasm))
19
+ - **Antigravity benchmark responses**: Extract visible text from the upstream `response.candidates` envelope, omit thinking parts, and count cumulative output-token usage once instead of summing repeated totals. Verified with a live `gemini-3-flash` response returning `OK` and one output token.
20
+
21
+ ### Changed
22
+
23
+ - **Dynamic model metadata**: Allow upstream-advertised Gemini 3.5 IDs, preserve exact model variants and explicit effort aliases, and prefer dynamic context metadata after operator overrides. Add Gemini 4 Argon metadata without inventing availability for unadvertised variants. ([PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42))
24
+ - **Antigravity client headers**: Update the default client version to 2.26.0 with the `antigravity/hub` User-Agent and include client metadata headers on quota requests. ([PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42))
25
+ - **Pricing estimates**: Refresh model pricing and synchronize the standalone telemetry receiver table; document official sources, historical estimates, promotional windows, and estimation limits in [the pricing audit](docs/model-pricing.md). ([PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42))
26
+
27
+ ### Contributors
28
+
29
+ - Thanks to [@javargasm](https://github.com/javargasm) for persistent Antigravity catalog snapshots, snapshot-based admission, model metadata and client-header updates, pricing maintenance, and restart/HTTP routing regression coverage in [PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42).
4
30
 
5
31
  ## [4.2.2] - 2026-10-24
6
32
 
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.3.0: Dashboard Playground, Codex reasoning connectors, and persistent Antigravity catalogs**: Test enabled models from `/dashboard/playground` across Chat, 2–3 model Compare, 5-case Chat Completions Compliance, and Audio Transcription (file upload including `.oga`/`.ogg` plus browser microphone recording) with IndexedDB workspaces and JSON export/import. `GET /v1/models` now publishes Codex reasoning effort metadata (`low`, `medium`, `high`, `xhigh`, `max`) and propagates it through `install-opencode`, the OpenCode 2 discovery plugin, and `install-agent` (including the new `openclaw` target). Also strips data URL prefixes on Ollama vision image payloads and restores validated Antigravity model snapshots per account before the first quota poll with updated client headers and pricing estimates. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.3.0); [PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42) by [@javargasm](https://github.com/javargasm), [PR #43](https://github.com/tuxevil/tuxevil-rotator/pull/43))
59
+
58
60
  - **v4.2.2: Security updates and dynamic model discovery**: Requires patched Node.js releases (22.23.4+, 24.22.1+, or 26.12.1+ on their supported release lines), updates Undici to 7.30.1, and prevents long URL slash sequences from blocking the OpenCode discovery plugin. Antigravity models now follow live account catalogs, and installers use the OpenCode 2 plugin API. Upgrade Node.js and restart existing rotator services after updating the package. ([Release notes](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v4.2.2); [PR #41](https://github.com/tuxevil/tuxevil-rotator/pull/41) by [@CyR1en](https://github.com/CyR1en))
59
61
 
60
62
  - **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))
@@ -73,7 +75,7 @@ Originally built as a multi-account rotator for Google Antigravity. It now gener
73
75
  - **Tier-first routing under concurrency**: Concurrent least-loaded account selection now enforces tier priority, and persisted lower-tier assignments are re-evaluated while idle. ([v3.7.1](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v3.7.1))
74
76
  - **Codex kickstart lifecycle**: Unstarted Codex quota timers are kicked off on startup and stale kickstart responses are drained to avoid blocking subsequent requests. ([v3.7.1](https://github.com/tuxevil/tuxevil-rotator/releases/tag/v3.7.1))
75
77
  - **Gemini 3.8 Flash Support**: Native Antigravity model IDs `gemini-3.8-flash-high`, `gemini-3.8-flash-medium`, and `gemini-3.8-flash-low`, with 1M-token context, 65,536-token output, pricing, quota routing, dashboard visualization, and telemetry support. Gemini 3.5 Flash has been removed from the user-facing catalog to match Antigravity 2.11. ([PR #28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en))
76
- - **Dynamic Antigravity Discovery**: Successful quota polls reconcile live model IDs and metadata per full account identity. Newly advertised models appear in `/v1/models` and route only to accounts that advertised them; removed models disappear without falling back to the generic Gemini pool. Legacy `gemini-3.5-*` IDs stay hidden, and configured `modelSpecs` substring overrides retain precedence. ([PR #29](https://github.com/tuxevil/tuxevil-rotator/pull/29) by [@javargasm](https://github.com/javargasm))
78
+ - **Dynamic Antigravity Discovery**: Successful quota polls reconcile live model IDs and metadata per full account identity. Newly advertised models appear in `/v1/models` and route only to accounts that advertised them; removed models disappear without falling back to the generic Gemini pool. Configured `modelSpecs` substring overrides retain precedence. The original Gemini 3.5 discovery restriction was lifted in [PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42); availability now follows upstream snapshots. ([PR #29](https://github.com/tuxevil/tuxevil-rotator/pull/29) by [@javargasm](https://github.com/javargasm))
77
79
  - **Dynamic Catalog Hardening**: Quota snapshots reject malformed data while preserving the last known-good state, stale account responses are ignored, and dynamic model ownership and quota-safety state survive restarts without routing a model through an account that did not advertise it. ([PR #30](https://github.com/tuxevil/tuxevil-rotator/pull/30) by [@javargasm](https://github.com/javargasm))
78
80
  - **Partial Model Specification Overrides**: `modelSpecs` entries can override selected output, thinking, and context fields while inheriting the remaining effective runtime, static, or family metadata. Overrides are preserved through configuration normalization and persistence. ([PR #31](https://github.com/tuxevil/tuxevil-rotator/pull/31) by [@javargasm](https://github.com/javargasm))
79
81
  - **Effort-Based Model Routing**: Optional `effortRouting` aliases dispatch requests to concrete model variants from `reasoning_effort`, while preserving the alias for clients and tracking quotas against the resolved target. See [Effort-Based Model Routing](docs/configuration.md#effort-based-model-routing). ([PR #32](https://github.com/tuxevil/tuxevil-rotator/pull/32) by [@CyR1en](https://github.com/CyR1en))
@@ -236,9 +238,11 @@ You can configure supported local agents automatically with:
236
238
 
237
239
  ```bash
238
240
  tuxevil-rotator install-agent --target auto
241
+ # Select agents explicitly (includes model reasoning capabilities):
242
+ tuxevil-rotator install-agent --target opencode,hermes,openclaw
239
243
  ```
240
244
 
241
- Use `--target all` or a comma-separated list (`opencode,hermes,pi,codex`) to choose clients. Add `--host <hostname> --user <ssh-user>` to configure them over SSH, or `--dry-run` to review the generated installer first. For OpenCode's live model catalog, use `tuxevil-rotator install-opencode`; see the [OpenCode integration guide](docs/integrations/opencode.md).
245
+ Use `--target all` or a comma-separated list (`opencode,hermes,openclaw,pi,codex`) to choose clients. Add `--host <hostname> --user <ssh-user>` to configure them over SSH, or `--dry-run` to review the generated installer first. For OpenCode's live model catalog, use `tuxevil-rotator install-opencode`; see the [OpenCode integration guide](docs/integrations/opencode.md).
242
246
 
243
247
  > **Rather have your agent do all of this?** The [`agent-install-prompt`](docs/agent-install-prompt.md) is a copy-paste prompt (English/Spanish) that makes any coding agent perform the whole setup for a non-technical user: install, account logins with hand-holding, background service, agent wiring, and verification.
244
248
 
@@ -299,6 +303,7 @@ After starting the proxy, open `http://localhost:51200/dashboard` and sign in wi
299
303
  - **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
300
304
  - **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)
301
305
  - **Models** — provider order, provider and per-account switches, individual model switches, quota and health summaries, and optional review of newly discovered models
306
+ - **Playground** — interactive Chat (with vision and tools inspection), side-by-side 2–3 model Compare, 5-case Chat Completions API Compliance, and Audio Transcription (file upload and microphone recording) with browser-saved workspaces and JSON export/import
302
307
  - **Requests** — a live tail of requests and rotator events, and with PostgreSQL the full history with payloads and per-key totals
303
308
  - **Usage** — token volume by model with 1h–30d ranges, estimated savings at list prices, latency percentiles and a 60-day activity heatmap
304
309
  - **Virtual keys** and **Settings** — key management, routing controls and policy, a benchmark, and the raw configuration file
@@ -388,11 +393,11 @@ Thanks to these amazing people who have contributed to the project:
388
393
 
389
394
  - **[@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))
390
395
  - **[@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))
391
- - **[@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))
396
+ - **[@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, regression coverage, and Node.js/Undici security updates with deployment guidance. ([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), [PR #41](https://github.com/tuxevil/tuxevil-rotator/pull/41))
392
397
  - **[@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))
393
398
  - **[@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))
394
399
  - **[@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))
395
- - **[@javargasm](https://github.com/javargasm)** (Jeisson Alexander Vargas Marroquin) — Queued multi-request Antigravity account pooling (5×5 concurrent streams), strict FIFO overflow queue, dashboard concurrency metrics, canonical project ID resolution, account-scoped dynamic Antigravity discovery and routing, dynamic catalog and quota-safety hardening, persistent dynamic model ownership across restarts, 429 quota resilience with account-scoped retry, synchronous leasing, snapshot-based token refresh with generation validation, provider-scoped token publication, spend-logger memory leak fix, atomic PostgreSQL CTE daily spend aggregation with idempotent retries, virtual-key cache bounding, Anthropic tool-use compatibility layer (`tool_use`/`tool_result` content block conversion), JSON schema round-trip fixes, compat test suite expansion, model-scoped cooldowns, explicit Antigravity reset-duration parsing, idle pool normalization, RAW POLL deadline reconciliation, serialized per-account quota polling, Ollama kickstart routing for multi-provider accounts, and OpenAI-compatible audio transcription plus bidirectional live WebSocket streaming through the local Antigravity observer model, with PR #36 adding rotator-backed transcription, Language Server fallback, model-scope checks, and live timeout/control-frame hardening. ([PR #3](https://github.com/tuxevil/tuxevil-rotator/pull/3), [PR #7](https://github.com/tuxevil/tuxevil-rotator/pull/7), [PR #22](https://github.com/tuxevil/tuxevil-rotator/pull/22), [PR #23](https://github.com/tuxevil/tuxevil-rotator/pull/23), [PR #24](https://github.com/tuxevil/tuxevil-rotator/pull/24), [PR #26](https://github.com/tuxevil/tuxevil-rotator/pull/26), [PR #29](https://github.com/tuxevil/tuxevil-rotator/pull/29), [PR #30](https://github.com/tuxevil/tuxevil-rotator/pull/30), [PR #31](https://github.com/tuxevil/tuxevil-rotator/pull/31), [PR #33](https://github.com/tuxevil/tuxevil-rotator/pull/33), [PR #36](https://github.com/tuxevil/tuxevil-rotator/pull/36))
400
+ - **[@javargasm](https://github.com/javargasm)** (Jeisson Alexander Vargas Marroquin) — Queued multi-request Antigravity account pooling (5×5 concurrent streams), strict FIFO overflow queue, dashboard concurrency metrics, canonical project ID resolution, account-scoped dynamic Antigravity discovery and routing, dynamic catalog and quota-safety hardening, persistent dynamic model ownership and validated catalog snapshots across restarts, exact upstream variant preservation, snapshot-based request admission, 429 quota resilience with account-scoped retry, synchronous leasing, snapshot-based token refresh with generation validation, provider-scoped token publication, spend-logger memory leak fix, atomic PostgreSQL CTE daily spend aggregation with idempotent retries, virtual-key cache bounding, Anthropic tool-use compatibility layer (`tool_use`/`tool_result` content block conversion), JSON schema round-trip fixes, compat test suite expansion, model-scoped cooldowns, explicit Antigravity reset-duration parsing, idle pool normalization, RAW POLL deadline reconciliation, serialized per-account quota polling, Ollama kickstart routing for multi-provider accounts, and OpenAI-compatible audio transcription plus bidirectional live WebSocket streaming through the local Antigravity observer model, with PR #36 adding rotator-backed transcription, Language Server fallback, model-scope checks, and live timeout/control-frame hardening. ([PR #3](https://github.com/tuxevil/tuxevil-rotator/pull/3), [PR #7](https://github.com/tuxevil/tuxevil-rotator/pull/7), [PR #22](https://github.com/tuxevil/tuxevil-rotator/pull/22), [PR #23](https://github.com/tuxevil/tuxevil-rotator/pull/23), [PR #24](https://github.com/tuxevil/tuxevil-rotator/pull/24), [PR #26](https://github.com/tuxevil/tuxevil-rotator/pull/26), [PR #29](https://github.com/tuxevil/tuxevil-rotator/pull/29), [PR #30](https://github.com/tuxevil/tuxevil-rotator/pull/30), [PR #31](https://github.com/tuxevil/tuxevil-rotator/pull/31), [PR #33](https://github.com/tuxevil/tuxevil-rotator/pull/33), [PR #36](https://github.com/tuxevil/tuxevil-rotator/pull/36), [PR #42](https://github.com/tuxevil/tuxevil-rotator/pull/42))
396
401
 
397
402
  ## Development
398
403
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuxevil-rotator",
3
- "version": "4.2.2",
3
+ "version": "4.3.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",
@@ -0,0 +1,7 @@
1
+ import type { RawRotatorModel } from "./index.mjs";
2
+ export function reasoningCapabilities(raw: RawRotatorModel): { supported: boolean; efforts: string[]; defaultEffort?: string };
3
+ export function openCodeReasoning(raw: RawRotatorModel): Record<string, unknown>;
4
+ export function openCodeVariants(raw: RawRotatorModel): Array<{ id: string; settings: { reasoningEffort: string } }>;
5
+ export function mergeOpenCodeModels(existing?: Record<string, unknown>, models?: RawRotatorModel[]): Record<string, unknown>;
6
+ export function mapAgentModel(raw: RawRotatorModel): Record<string, unknown>;
7
+ export function fetchModels(baseURL: string, apiKey?: string, timeoutMs?: number): Promise<RawRotatorModel[]>;
@@ -0,0 +1,54 @@
1
+ // Model capability translation shared by discovery and standalone installers.
2
+ // Scalar API efforts only: harness modes such as "ultra" are not wire values.
3
+ const EFFORTS = new Set(["none", "minimal", "low", "medium", "high", "xhigh", "max"])
4
+ export function reasoningCapabilities(raw) {
5
+ const meta = raw.meta || raw.info || {}
6
+ const supported = Boolean(meta.reasoning ?? meta.thinking)
7
+ const efforts = supported && Array.isArray(meta.reasoning_efforts)
8
+ ? [...new Set(meta.reasoning_efforts.filter(value => EFFORTS.has(value)))] : []
9
+ return { supported, efforts, defaultEffort: efforts.includes(meta.default_reasoning_effort) ? meta.default_reasoning_effort : undefined }
10
+ }
11
+ export function openCodeReasoning(raw) {
12
+ const { supported, efforts } = reasoningCapabilities(raw)
13
+ if (!supported) return {}
14
+ return { reasoning: { supported: true, ...(efforts.length ? { effort: efforts.filter(e => e !== "none"), ...(efforts.includes("none") ? { toggle: true } : {}) } : {}) } }
15
+ }
16
+ export function openCodeVariants(raw) {
17
+ return reasoningCapabilities(raw).efforts.map(effort => ({ id: effort, settings: { reasoningEffort: effort } }))
18
+ }
19
+ /** Legacy OpenCode config is migrated by V2; keep user options/variants authoritative. */
20
+ export function mergeOpenCodeModels(existing = {}, rawModels = []) {
21
+ const merged = { ...existing }
22
+ for (const raw of rawModels) {
23
+ const meta = raw.meta || {}
24
+ const prior = merged[raw.id] || {}
25
+ const reasoning = reasoningCapabilities(raw)
26
+ const variants = Object.fromEntries(reasoning.efforts.map(effort => [effort, { reasoningEffort: effort }]))
27
+ merged[raw.id] = { name: raw.id, ...prior,
28
+ limit: { context: meta.context_length || raw.context_window || 128000, output: meta.max_output_tokens || 8192, ...prior.limit },
29
+ ...(reasoning.supported && prior.reasoning === undefined ? { reasoning: true } : {}),
30
+ ...(reasoning.efforts.length ? { variants: { ...variants, ...prior.variants } } : {}),
31
+ }
32
+ }
33
+ return merged
34
+ }
35
+ export function mapAgentModel(raw) {
36
+ const meta = raw.meta || {}
37
+ const reasoning = reasoningCapabilities(raw)
38
+ return { id: raw.id, name: raw.name || raw.id, reasoning: reasoning.supported,
39
+ input: meta.multimodal ? ["text", "image"] : ["text"],
40
+ contextWindow: meta.context_length || raw.context_window || 128000,
41
+ maxTokens: meta.max_output_tokens || 8192,
42
+ ...(reasoning.efforts.length ? { compat: { supportsReasoningEffort: true, supportedReasoningEfforts: reasoning.efforts } } : {}),
43
+ }
44
+ }
45
+ export async function fetchModels(baseURL, apiKey, timeoutMs = 3500) {
46
+ const response = await fetch(baseURL.replace(/\/+$/, "") + "/models", {
47
+ signal: AbortSignal.timeout(timeoutMs),
48
+ headers: { Accept: "application/json", ...(apiKey && apiKey !== "no-key" ? { Authorization: `Bearer ${apiKey}` } : {}) },
49
+ })
50
+ if (!response.ok) throw new Error(`Model catalog HTTP ${response.status}`)
51
+ const body = await response.json()
52
+ if (!Array.isArray(body.data)) throw new Error("Invalid model catalog")
53
+ return body.data.filter(model => typeof model?.id === "string" && model.id.length > 0)
54
+ }
@@ -41,7 +41,8 @@ export interface RawRotatorModel {
41
41
  export interface ModelDef {
42
42
  name: string;
43
43
  limit: { context: number; output: number };
44
- capabilities: { tools: boolean; input: string[]; output: string[] };
44
+ capabilities: { tools: boolean; input: string[]; output: string[]; reasoning?: unknown };
45
+ variants?: Array<{ id: string; settings: { reasoningEffort: string } }>;
45
46
  }
46
47
 
47
48
  export function normalizeProviderEntries(input: unknown): ProviderEntry[];
@@ -17,6 +17,8 @@
17
17
  * - refreshMs background re-discovery interval (default 600000; 0 disables)
18
18
  */
19
19
 
20
+ import { openCodeReasoning, openCodeVariants } from "./capabilities.mjs"
21
+
20
22
  const PLUGIN_ID = "tuxevil.model-discovery"
21
23
  const DEFAULT_BASE_URL = "http://127.0.0.1:51200/v1"
22
24
  const DEFAULT_PROVIDER_PACKAGE = "@opencode/ai/providers/openai-compatible"
@@ -208,7 +210,9 @@ export function mapModelToOpenCode(rawModel) {
208
210
  tools: toolCalling,
209
211
  input: isMultimodal ? ["text", "image"] : ["text"],
210
212
  output: ["text"],
213
+ ...openCodeReasoning(rawModel),
211
214
  },
215
+ ...(openCodeVariants(rawModel).length ? { variants: openCodeVariants(rawModel) } : {}),
212
216
  },
213
217
  }
214
218
  }
@@ -230,7 +234,7 @@ function safeGet(editor, id) {
230
234
  function modelSignature(models) {
231
235
  return JSON.stringify(
232
236
  (models ?? [])
233
- .map((model) => model?.id)
237
+ .map((model) => [model?.id, model?.meta])
234
238
  .filter(Boolean)
235
239
  .sort(),
236
240
  )
@@ -294,6 +298,7 @@ export default {
294
298
  name: existingModel?.name || modelDef.name,
295
299
  capabilities: { ...modelDef.capabilities, ...(existingModel?.capabilities ?? {}) },
296
300
  limit: { ...modelDef.limit, ...(existingModel?.limit ?? {}) },
301
+ ...(modelDef.variants ? { variants: [...new Map([...modelDef.variants, ...(Array.isArray(existingModel?.variants) ? existingModel.variants : [])].map(v => [v.id, v])).values()] } : {}),
297
302
  }
298
303
  }
299
304
 
@@ -9,7 +9,9 @@
9
9
  },
10
10
  "files": [
11
11
  "index.mjs",
12
- "index.d.mts"
12
+ "index.d.mts",
13
+ "capabilities.mjs",
14
+ "capabilities.d.mts"
13
15
  ],
14
16
  "keywords": [
15
17
  "opencode",
@@ -4,6 +4,7 @@ import https from "node:https";
4
4
  import cp from "node:child_process";
5
5
  import crypto from "node:crypto";
6
6
  import fs from "node:fs";
7
+ import { requireAdmin, isSameOriginRequest } from "./admin-auth.js";
7
8
  import { readLimitedBody } from "./body-limit.js";
8
9
  import { authenticateVirtualKey, sendAuthErrorResponse, type KeyAuthResult } from "./key-auth.js";
9
10
  import { logger } from "./logger.js";
@@ -103,7 +104,7 @@ export function resolveMimeType(fileName: string, mimeType?: string): string {
103
104
  if (lower.endsWith(".mp3")) return "audio/mp3";
104
105
  if (lower.endsWith(".m4a")) return "audio/m4a";
105
106
  if (lower.endsWith(".webm")) return "audio/webm;codecs=opus";
106
- if (lower.endsWith(".ogg")) return "audio/ogg";
107
+ if (lower.endsWith(".ogg") || lower.endsWith(".oga")) return "audio/ogg";
107
108
  if (lower.endsWith(".flac")) return "audio/flac";
108
109
  if (lower.endsWith(".pcm")) return "audio/pcm;rate=16000";
109
110
  return "audio/wav";
@@ -819,16 +820,41 @@ export function getAudioDurationSeconds(audioBuffer: Buffer, mimeType: string):
819
820
  return undefined;
820
821
  }
821
822
 
822
- /**
823
- * Handles standard OpenAI-compatible POST /v1/audio/transcriptions
824
- */
823
+ /** Browser-only admin inference; public audio routes still require virtual keys. */
824
+ export async function handlePlaygroundAudioTranscriptions(
825
+ req: IncomingMessage,
826
+ res: ServerResponse,
827
+ rotator: AccountRotator,
828
+ ): Promise<void> {
829
+ if (!requireAdmin(req, res)) return;
830
+ if (!isSameOriginRequest(req)) {
831
+ res.writeHead(403, { "Content-Type": "application/json" });
832
+ res.end(JSON.stringify({ error: { message: "Transcription requests must come from the dashboard's own origin" } }));
833
+ return;
834
+ }
835
+ res.setHeader("Cache-Control", "no-store");
836
+ await handleAudioTranscriptions(req, res, rotator, true);
837
+ }
838
+
839
+ /** Handles standard OpenAI-compatible POST /v1/audio/transcriptions. */
825
840
  export async function handleOpenAIAudioTranscriptions(
826
841
  req: IncomingMessage,
827
842
  res: ServerResponse,
828
843
  rotator?: AccountRotator,
844
+ ): Promise<void> {
845
+ await handleAudioTranscriptions(req, res, rotator, false);
846
+ }
847
+
848
+ async function handleAudioTranscriptions(
849
+ req: IncomingMessage,
850
+ res: ServerResponse,
851
+ rotator: AccountRotator | undefined,
852
+ dashboardAdmin: boolean,
829
853
  ): Promise<void> {
830
854
  const requestStartedAt = Date.now();
831
- const initialAuth = await authenticateVirtualKey(req);
855
+ const initialAuth: KeyAuthResult = dashboardAdmin
856
+ ? { authenticated: true, key: null }
857
+ : await authenticateVirtualKey(req);
832
858
  if (!initialAuth.authenticated) {
833
859
  sendAuthErrorResponse(res, initialAuth);
834
860
  return;
@@ -933,7 +959,7 @@ export async function handleOpenAIAudioTranscriptions(
933
959
  ? resolveAudioTranscriptionModel(requestedModel ?? "whisper-1")
934
960
  : applyModelAlias(requestedModel ?? "whisper-1");
935
961
  spendModel = requestedModel ?? "whisper-1";
936
- const modelAuth = await authorizeAudioModel(req, executedModel, requestedModel);
962
+ const modelAuth = dashboardAdmin ? initialAuth : await authorizeAudioModel(req, executedModel, requestedModel);
937
963
  if (!modelAuth.authenticated) {
938
964
  logRequest("failure");
939
965
  sendAuthErrorResponse(res, modelAuth);
package/src/cli.ts CHANGED
@@ -275,8 +275,8 @@ switch (command) {
275
275
 
276
276
  const targetIdx = args.indexOf("--target") >= 0 ? args.indexOf("--target") : args.indexOf("-t");
277
277
  const targetStr = targetIdx >= 0 ? args[targetIdx + 1] : undefined;
278
- const targets: ("opencode" | "hermes" | "pi" | "codex" | "auto" | "all")[] = targetStr
279
- ? (targetStr.split(",").map((s) => s.trim().toLowerCase()) as ("opencode" | "hermes" | "pi" | "codex" | "auto" | "all")[])
278
+ const targets: ("opencode" | "hermes" | "pi" | "codex" | "openclaw" | "auto" | "all")[] = targetStr
279
+ ? (targetStr.split(",").map((s) => s.trim().toLowerCase()) as ("opencode" | "hermes" | "pi" | "codex" | "openclaw" | "auto" | "all")[])
280
280
  : ["auto"];
281
281
 
282
282
  const hostIdx = args.indexOf("--host");
@@ -406,7 +406,7 @@ switch (command) {
406
406
  console.log(
407
407
  " delete <hash> - Delete a virtual key",
408
408
  );
409
- console.log(" tuxevil-rotator install-agent Install rotator config across multiple agents");
409
+ console.log(" tuxevil-rotator install-agent Connect opencode, hermes, openclaw, pi or codex (--target auto|all|name)");
410
410
  console.log(
411
411
  " [--target <auto|all|opencode,hermes,pi,codex>]",
412
412
  );
@@ -28,6 +28,10 @@ export const DEFAULT_MODEL_SPECS: Record<string, ModelSpec> = {
28
28
  "gemini-3.8-flash-high": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
29
29
  "gemini-3.8-flash-medium": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
30
30
  "gemini-3.8-flash-low": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
31
+ "gemini-4-argon": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
32
+ "gemini-4-argon-high": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
33
+ "gemini-4-argon-medium": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
34
+ "gemini-4-argon-low": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
31
35
  "gemini-3.5-flash-lite": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
32
36
  "gemini-3-flash": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
33
37
  "gemini-2.5-flash": { maxOutputTokens: 65535, thinkingBudget: 24576, isThinking: true, contextWindow: 1_000_000 },
package/src/compat.ts CHANGED
@@ -10,6 +10,7 @@ import {
10
10
  type CompressionStats,
11
11
  } from "./compression/index.js";
12
12
  import { idempotencyManager } from "./idempotency.js";
13
+ import { requireAdmin, isSameOriginRequest } from "./admin-auth.js";
13
14
  import {
14
15
  authenticateVirtualKey,
15
16
  isVirtualKeyModelAllowed,
@@ -2669,6 +2670,8 @@ export function buildOpenAIModelCatalog(
2669
2670
  family: "openai-codex",
2670
2671
  provider: "openai-codex",
2671
2672
  reasoning: model.reasoning,
2673
+ ...(model.reasoning && model.reasoningEfforts ? { reasoning_efforts: model.reasoningEfforts } : {}),
2674
+ ...(model.reasoning && model.defaultReasoningEffort ? { default_reasoning_effort: model.defaultReasoningEffort } : {}),
2672
2675
  multimodal: model.multimodal,
2673
2676
  tool_calling: model.tools,
2674
2677
  },
@@ -2935,10 +2938,34 @@ export async function handleGeminiGenerateContent(
2935
2938
  }, rotatorHeaders);
2936
2939
  }
2937
2940
 
2941
+ /** Dashboard inference: authorization is checked here, never from a client flag. */
2942
+ export async function handlePlaygroundChatCompletions(
2943
+ req: IncomingMessage,
2944
+ res: ServerResponse,
2945
+ rotator: AccountRotator,
2946
+ ): Promise<void> {
2947
+ if (!requireAdmin(req, res)) return;
2948
+ if (!isSameOriginRequest(req)) {
2949
+ return writeJson(res, 403, { error: { message: "Playground requests must come from the dashboard's own origin" } });
2950
+ }
2951
+ res.setHeader("Cache-Control", "no-store");
2952
+ req.headers["x-rotator-no-deduplicate"] = "true";
2953
+ await handleChatCompletions(req, res, rotator, true);
2954
+ }
2955
+
2938
2956
  export async function handleOpenAIChatCompletions(
2939
2957
  req: IncomingMessage,
2940
2958
  res: ServerResponse,
2941
2959
  rotator: AccountRotator,
2960
+ ): Promise<void> {
2961
+ await handleChatCompletions(req, res, rotator, false);
2962
+ }
2963
+
2964
+ async function handleChatCompletions(
2965
+ req: IncomingMessage,
2966
+ res: ServerResponse,
2967
+ rotator: AccountRotator,
2968
+ dashboardAdmin: boolean,
2942
2969
  ): Promise<void> {
2943
2970
  let parsed: unknown;
2944
2971
  try {
@@ -2965,7 +2992,9 @@ export async function handleOpenAIChatCompletions(
2965
2992
 
2966
2993
  const requestedModel = validation.value.model;
2967
2994
  const autoRequested = isAutoModel(requestedModel);
2968
- const auth = await authenticateVirtualKey(req, autoRequested ? undefined : requestedModel);
2995
+ const auth = dashboardAdmin
2996
+ ? { authenticated: true, key: null, rawKey: undefined }
2997
+ : await authenticateVirtualKey(req, autoRequested ? undefined : requestedModel);
2969
2998
  if (!auth.authenticated) {
2970
2999
  sendAuthErrorResponse(res, auth);
2971
3000
  return;
@@ -48,6 +48,7 @@ export const DASHBOARD_CSP = [
48
48
  "script-src 'self'",
49
49
  "style-src 'self'",
50
50
  "img-src 'self' data:",
51
+ "media-src 'self' blob:",
51
52
  "font-src 'self'",
52
53
  "connect-src 'self'",
53
54
  "manifest-src 'self'",