tuxevil-rotator 3.1.0 → 3.2.1

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
@@ -1,5 +1,45 @@
1
1
  # Changelog
2
2
 
3
+ ## [3.2.1] - 2026-08-16
4
+
5
+ ### Fixed
6
+
7
+ - **Credential persistence across restarts with PostgreSQL**: When PostgreSQL is configured as the account store, credentials added via the login panel (`ollama`, `opencode-zen`, `openai-codex`) were stored using the legacy flat `apiKey` field instead of the structured `credentials[{provider, apiKey}]` shape. On the next quota poll, the rotator read back the correct structured credential from the database but the Ollama provider adapter found nothing, flagging the account with 401. The `handleOllamaCliLogin` onboarding handler now always persists as `credentials: [{ provider: "ollama", apiKey }]`.
8
+
9
+ - **OpenCode Zen and sibling credentials lost on `replaceConfig`**: When the dashboard config editor saved a new config (e.g. after changing routing settings), `replaceConfig()` merged credentials correctly in memory but then persisted the original unmerged `config.accounts` payload to PostgreSQL. After the next restart the database-sourced config lacked the `opencode-zen` (or `ollama`) credential entirely. The fix builds the merged account list first and persists that merged list, so no credential is ever dropped by a config save.
10
+
11
+ - **Legacy Ollama JSON re-imported on every boot with PostgreSQL**: `importLegacyOllamaRotatorAccounts()` ran unconditionally at startup, allowing a stale `~/.ollama-rotator/accounts.json` to re-introduce revoked API keys each time the service restarted. The import is now skipped when `TUXEVIL_ROTATOR_DATABASE_URL` is configured, making PostgreSQL the sole authoritative source.
12
+
13
+ - **`accounts.json` disk file migrated into PostgreSQL on startup**: `PostgresSettingsRepository.init()` migrated any on-disk `accounts.json` into the database on first boot. If the file contained an outdated credential it would silently overwrite the database value. The `accounts_json` key is now excluded from the disk-to-database migration path; only non-credential settings (state, token usage, admin token) are migrated from disk.
14
+
15
+ - **PostgreSQL writes were fire-and-forget**: Account config writes to PostgreSQL were non-blocking background promises. A service restart occurring within the write window could lose the latest credential update. All settings writes are now awaited before returning a success response.
16
+
17
+ - **`mergeCredentials` called on pre-normalization data in `addAccountToConfig`**: The merge was applied against the raw (possibly legacy-shaped) existing account instead of its normalized form, causing duplicate or missing credentials in edge cases. The existing account is now normalized before merging.
18
+
19
+ ### Changed
20
+
21
+ - **`replaceConfig` syncs in-memory and persisted accounts atomically**: The merged account list is computed once and used for both `this.accounts`/`this.config` and the PostgreSQL write, preventing divergence.
22
+
23
+ ## [3.2.0] - 2026-08-14
24
+
25
+ ### Added
26
+ - **Gemini 3.7 Flash Model Support**: Full support for Google's Gemini 3.7 Flash models (`gemini-3.7-flash`, `gemini-3.7-flash-tiered`, `gemini-3.7-flash-high`, `gemini-3.7-flash-medium`, `gemini-3.7-flash-low`). Includes thinking level and reasoning effort mapping, token cost tracking, dashboard visualization, and telemetry support ([#21](https://github.com/tuxevil/tuxevil-rotator/pull/21) by [@CyR1en](https://github.com/CyR1en)).
27
+ - **OpenCode Zen Provider Support**: Integrated `opencode-zen` as a supported free-tier provider for `deepseek-v4-flash-free`, `nemotron-3.5-lightning-free`, `nemotron-3-ultra-free`, `mimo-v2.5-free`, and `hy3-free`. Includes API key validation via `opencode.ai/zen/v1`, quota polling, streaming and non-streaming chat completions, market pricing to calculate USD savings, and an OpenCode Zen tab in `/login` and `/login-cli`.
28
+ - **429 Rate-Limit Retry Headers**: Convey `retryAfterMs` and `retry_after_seconds` in rate-limited error responses to allow clients to respect upstream cooldowns accurately.
29
+
30
+ ### Fixed
31
+ - **Streaming Tool Call Assembly**: Statefully preserve tool call names and IDs across SSE deltas, preventing split chunks from dropping function metadata in multi-turn tool calling.
32
+ - **OpenCode Zen Account Rotation & Rate Limits**: Scope OpenCode Zen rate limits per-model to prevent single-model 429 errors from locking out the entire provider pool, and ensure proper account rotation on upstream 429s.
33
+ - **OpenCode Zen Content-Type & Streaming**: Strip duplicate content-type headers, fix Accept header negotiation, and fix token refresh and format handling for `deepseek-v4-flash-free`.
34
+ - **Dashboard Generate Key Modal**: Dynamically populate the Virtual Key generation model grid from `/api/models` to include only active providers and registered models.
35
+ - **Dashboard UI & Cache Control**: Restored missing card header closing `<div>` tag and added static asset cache control headers.
36
+ - **Test Isolation**: Isolated `TUXEVIL_ROTATOR_DIR` in `db-store` tests to prevent test suites from modifying local user configurations.
37
+
38
+ ### Changed
39
+ - **Provider Ordering**: Standardized provider order precedence across quota pools, credentials, and UI displays (`google-antigravity` -> `ollama` -> `opencode-zen` -> `openai-codex`).
40
+ - **Catalog Cleanup**: Removed deprecated `ling-3.0-tiny-free` and `laguna-s-2.1-free` models from the OpenCode Zen catalog to avoid false-positive account flag warnings.
41
+ - **Provider Architecture**: Decoupled provider eligibility checks and routing logic from rotator core into modular provider adapters.
42
+
3
43
  ## [3.1.0] - 2026-08-12
4
44
 
5
45
  ### Added
@@ -14,6 +54,9 @@
14
54
  - **Codex usage & spend tracking**: Fixed recording of usage and spend for Codex compat requests.
15
55
  - **Gemini turn bug fix**: Prevented model-ending compat requests for Gemini models.
16
56
 
57
+ ### Changed
58
+ - **Dashboard account cards**: Removed the legacy `FLASH` / `PRO` / `CLAUDE` model badges that previously indicated which model each account was last active for. The tier selector (`UNKNOWN` / `FREE` / `PLUS` / `PRO` / `ULTRA`) is unchanged.
59
+
17
60
  ## [3.0.0] - 2026-08-11
18
61
 
19
62
  ### Changed
package/README.md CHANGED
@@ -28,7 +28,7 @@
28
28
 
29
29
  Multi-account load balancing, per-model quota routing, account health scoring, access control with Virtual Keys, and cost auditing — via a single local endpoint that any agent can use. Even with a single account.
30
30
 
31
- Originally built as a multi-account rotator for Google Antigravity. It now generalizes that rotation layer across any free-tier LLM provider with per-account credentials: today Google Antigravity and Ollama Cloud, designed so the next free-tier provider slots in without forking the engine.
31
+ Originally built as a multi-account rotator for Google Antigravity. It now generalizes that rotation layer across free-tier LLM providers with per-account credentials: Google Antigravity, Ollama Cloud, OpenAI Codex, and OpenCode Zen, designed so new providers slot in without modifying core engine logic.
32
32
 
33
33
  > **⚠️ WARNING:** Using this proxy may put connected accounts at risk of Terms of Service enforcement, including restriction, suspension, or permanent bans. Use at your own risk.
34
34
 
@@ -51,6 +51,14 @@ Originally built as a multi-account rotator for Google Antigravity. It now gener
51
51
 
52
52
  ---
53
53
 
54
+ ## v3.2 Highlights
55
+
56
+ - **Gemini 3.7 Flash Support**: Full support for Google's Gemini 3.7 Flash models (`gemini-3.7-flash`, `gemini-3.7-flash-tiered`, `gemini-3.7-flash-high`, `gemini-3.7-flash-medium`, `gemini-3.7-flash-low`) with reasoning effort / thinking level translation, pricing, dashboard visualization, and telemetry.
57
+ - **OpenCode Zen Provider**: Added `opencode-zen` provider support (`deepseek-v4-flash-free`, `nemotron-3.5-lightning-free`, `nemotron-3-ultra-free`, `mimo-v2.5-free`, `hy3-free`) with static API key validation, onboarding UI tabs in `/login` and `/login-cli`, real-time quota tracking, and market-based cost savings estimates.
58
+ - **Streaming Tool Call Reliability**: Stateful preservation of tool call names and IDs across fragmented SSE chunks in multi-turn tool calling sessions.
59
+ - **Standardized Rate-Limit Retries**: Error responses for 429 now provide `retryAfterMs` and `retry_after_seconds` headers and payload data for fine-grained cooldown handling.
60
+ - **Provider Precedence Order**: Standardized provider order across quota pools, credentials, and UI displays (`google-antigravity` -> `ollama` -> `opencode-zen` -> `openai-codex`).
61
+
54
62
  ## v3.0 Highlights
55
63
 
56
64
  - **Parent-Account Credential Model**: Each account (email) is now the parent entity and may hold per-provider credentials — a single human with both a Google Antigravity OAuth token and an Ollama Cloud API key lives in one account row. Login (`login --provider <id>`) and the legacy importer merge credentials onto existing accounts instead of duplicating by email.
@@ -145,6 +153,7 @@ npm install -g tuxevil-rotator
145
153
  tuxevil-rotator login # Google Antigravity (default)
146
154
  tuxevil-rotator login --provider ollama # Ollama Cloud (static API key)
147
155
  tuxevil-rotator login --provider openai-codex # ChatGPT OAuth (isolated Codex pool)
156
+ tuxevil-rotator login --provider opencode-zen # OpenCode Zen (static API key)
148
157
  tuxevil-rotator start
149
158
  ```
150
159
 
@@ -176,6 +185,7 @@ npm install
176
185
  npm run login # Google Antigravity
177
186
  npm run login -- --provider ollama # Ollama Cloud
178
187
  npm run login -- --provider openai-codex # OpenAI Codex OAuth
188
+ npm run login -- --provider opencode-zen # OpenCode Zen
179
189
  npm start
180
190
  ```
181
191
 
@@ -330,8 +340,8 @@ To donate an authorized account for testing across supported providers, see [CON
330
340
  Thanks to these amazing people who have contributed to the project:
331
341
 
332
342
  - **[@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))
333
- - **[@CyR1en](https://github.com/CyR1en)** (Ethan Bacurio) — Added the Gemini 3.6 Flash model family, shared quota-pool routing, pricing, dashboard support, and regression coverage. ([PR #18](https://github.com/tuxevil/tuxevil-rotator/pull/18))
334
- - **[@josenicomaia](https://github.com/josenicomaia)** (José Nicodemos Maia Neto) — Modularized the compatibility layer architecture, added multimodal tool response support, and fixed streaming pass-through for tool executions. ([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))
343
+ - **[@CyR1en](https://github.com/CyR1en)** (Ethan Bacurio) — Added Gemini 3.6 Flash and Gemini 3.7 Flash model families, shared quota-pool routing, pricing, dashboard support, and regression coverage. ([PR #18](https://github.com/tuxevil/tuxevil-rotator/pull/18), [PR #21](https://github.com/tuxevil/tuxevil-rotator/pull/21))
344
+ - **[@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))
335
345
  - **[@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))
336
346
  - **[@javargasm](https://github.com/javargasm)** (Jeisson Alexander Vargas Marroquin) — Anthropic tool-use compatibility layer (`tool_use`/`tool_result` content block conversion), JSON schema round-trip fixes, and compat test suite expansion. ([PR #3](https://github.com/tuxevil/tuxevil-rotator/pull/3), [PR #7](https://github.com/tuxevil/tuxevil-rotator/pull/7))
337
347
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tuxevil-rotator",
3
- "version": "3.1.0",
3
+ "version": "3.2.1",
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",
@@ -10,7 +10,7 @@ import {
10
10
  saveAccountsConfig,
11
11
  } from "./config-storage.js";
12
12
  import { applyConfigDefaults, getDefaultConfig } from "./config-defaults.js";
13
- import { hasCredential } from "./providers/credential-helpers.js";
13
+ import { hasCredential, sortAccountCredentials } from "./providers/credential-helpers.js";
14
14
  import { normalizeAccountConfig } from "./config-normalize.js";
15
15
  import { validateAccountConfig } from "./validators.js";
16
16
 
@@ -92,7 +92,7 @@ function validateCredentialLengths(
92
92
 
93
93
  export { validateAccountConfigLengths };
94
94
 
95
- function mergeCredentials(
95
+ export function mergeCredentials(
96
96
  existing: AccountConfig["credentials"] | undefined,
97
97
  incoming: AccountConfig["credentials"] | undefined,
98
98
  ): AccountConfig["credentials"] {
@@ -107,7 +107,7 @@ function mergeCredentials(
107
107
  incomingByProvider.delete(cred.provider);
108
108
  }
109
109
  for (const cred of incomingByProvider.values()) out.push(cred);
110
- return out;
110
+ return sortAccountCredentials(out);
111
111
  }
112
112
 
113
113
  function assertCodexIdentityCompatible(
@@ -141,10 +141,11 @@ export async function addAccountToConfig(
141
141
  if (existing) {
142
142
  assertCodexIdentityCompatible(existing, entryNorm);
143
143
  validateCredentialLengths(entryNorm.credentials);
144
+ const existingNorm = normalizeAccountConfig(existing);
144
145
  config.accounts[config.accounts.indexOf(existing)] = {
145
- ...normalizeAccountConfig(existing),
146
+ ...existingNorm,
146
147
  ...entryNorm,
147
- credentials: mergeCredentials(existing.credentials, entryNorm.credentials),
148
+ credentials: mergeCredentials(existingNorm.credentials, entryNorm.credentials),
148
149
  };
149
150
  await saveAccountsConfig(config);
150
151
  return { isNew: false };
@@ -21,6 +21,7 @@ export const DEFAULT_MODEL_SPECS: Record<string, ModelSpec> = {
21
21
  "gemini-3.6-flash-medium": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true },
22
22
  "gemini-3.6-flash-low": { maxOutputTokens: 65536, thinkingBudget: 1000, isThinking: true },
23
23
  "gemini-3.6-flash-tiered": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true },
24
+ "gemini-3.7-flash-tiered": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true },
24
25
  "gemini-3-flash": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true },
25
26
  "gemini-2.5-flash": { maxOutputTokens: 65535, thinkingBudget: 24576, isThinking: true },
26
27
  "gemini-2.5-pro": { maxOutputTokens: 65535, thinkingBudget: 1024, isThinking: true },