tuxevil-rotator 3.3.1 → 3.4.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 +24 -0
- package/README.md +6 -2
- package/package.json +1 -1
- package/src/compat/model-specs.ts +3 -4
- package/src/compat.ts +22 -14
- package/src/dashboard.ts +4 -4
- package/src/providers/google-antigravity/catalog.ts +3 -5
- package/src/providers/google-antigravity/index.ts +4 -1
- package/src/providers/google-antigravity/quota.ts +6 -4
- package/src/providers/google-antigravity/translators.ts +1 -2
- package/src/providers/ollama/index.ts +5 -2
- package/src/providers/ollama/prediction.ts +1 -1
- package/src/proxy.ts +11 -2
- package/src/rate-limit-parser.ts +12 -3
- package/src/rotator.ts +249 -116
- package/src/spend-logger.ts +2 -2
- package/src/static/dashboard-keys.js +4 -3
- package/src/static/dashboard-logs.js +5 -2
- package/src/static/dashboard.js +68 -51
- package/src/types.ts +57 -63
- package/tools/telemetry-receiver/receiver.js +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [Unreleased]
|
|
4
|
+
|
|
5
|
+
## [3.4.0] - 2026-09-03
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
- **Gemini 3.8 Flash support**: Added the native Antigravity IDs `gemini-3.8-flash-high`, `gemini-3.8-flash-medium`, and `gemini-3.8-flash-low` across model discovery, routing, context limits, pricing, dashboards, telemetry, and integration documentation. All three IDs were discovered across nine configured accounts and verified with live generation ([#28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en)).
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
- **Antigravity client version**: Updated the default Antigravity user agent from `1.107.0` to `2.11.0`; the newer user agent is required for Gemini 3.8 Flash discovery and generation ([#28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en)).
|
|
12
|
+
- **Gemini 3.5 Flash catalog removal**: Removed Gemini 3.5 Flash from the user-facing supported-model catalog and defaults to match Antigravity 2.11. Backend discovery may still return legacy 3.5 quota entries ([#28](https://github.com/tuxevil/tuxevil-rotator/pull/28) by [@CyR1en](https://github.com/CyR1en)).
|
|
13
|
+
|
|
14
|
+
## [3.3.2] - 2026-08-28
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
- **Model-scoped Antigravity cooldowns**: `RESOURCE_EXHAUSTED` 429s now cool only the exhausted Claude or Gemini pool; sibling pools on the same account remain routable immediately ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
18
|
+
- **Explicit reset duration honored on `RESOURCE_EXHAUSTED`**: The rotator parses `Resets in Xh Ym Zs` from Antigravity error messages and applies that exact cooldown instead of the generic 30-minute cap. Falls back to 30 minutes when no duration is present ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
19
|
+
- **Persisted Antigravity pool deadlines survive restarts**: `claude` and `gemini` cooldown deadlines are no longer truncated to 30 minutes on startup; only generic model cooldowns are capped ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
20
|
+
- **Untouched 100% pools show idle instead of a fake countdown**: When Google reports `remainingFraction >= 1` the reset timestamp is discarded and the pool renders as `idle` with no timer ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
21
|
+
- **RAW POLL reconciliation of exhausted pool deadlines**: A successful quota poll reporting 0% with a valid future reset replaces the stale cooldown deadline for that pool; invalid, past, or unchanged resets are ignored ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
22
|
+
- **Serialized per-account quota polling with trailing repoll**: Overlapping `pollAccountQuota` calls for the same account queue a single trailing repoll instead of running concurrently; `pollAllQuotas` is now single-flighted ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
23
|
+
- **`gpt-oss:20b` kickstarts routed through Ollama**: On multi-provider accounts (Google + Ollama), the kickstart for the Ollama session pool is correctly sent to the Ollama endpoint with the Ollama API key ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
24
|
+
- **Kickstart actions hidden for disabled/flagged accounts**: The dashboard no longer renders `▶ Start` or `Start Idle Timers` buttons for accounts that are not eligible for kickstart ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
25
|
+
- **`gemini-3.7-flash-tiered` added to OpenCode integration docs**: Context window updated to 1,000,000 tokens; set as the recommended default model ([#26](https://github.com/tuxevil/tuxevil-rotator/pull/26) by [@javargasm](https://github.com/javargasm)).
|
|
26
|
+
|
|
3
27
|
## [3.3.1] - 2026-08-27
|
|
4
28
|
|
|
5
29
|
### Fixed
|
package/README.md
CHANGED
|
@@ -51,6 +51,10 @@ Originally built as a multi-account rotator for Google Antigravity. It now gener
|
|
|
51
51
|
|
|
52
52
|
---
|
|
53
53
|
|
|
54
|
+
## Current Model Update
|
|
55
|
+
|
|
56
|
+
- **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))
|
|
57
|
+
|
|
54
58
|
## v3.2 Highlights
|
|
55
59
|
|
|
56
60
|
- **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.
|
|
@@ -341,10 +345,10 @@ Thanks to these amazing people who have contributed to the project:
|
|
|
341
345
|
|
|
342
346
|
- **[@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))
|
|
343
347
|
- **[@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))
|
|
344
|
-
- **[@CyR1en](https://github.com/CyR1en)** (Ethan Bacurio) — Added Gemini 3.6
|
|
348
|
+
- **[@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, 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))
|
|
345
349
|
- **[@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))
|
|
346
350
|
- **[@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))
|
|
347
|
-
- **[@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, 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,
|
|
351
|
+
- **[@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, 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, and Ollama kickstart routing for multi-provider accounts. ([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))
|
|
348
352
|
|
|
349
353
|
## Development
|
|
350
354
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tuxevil-rotator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.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",
|
|
@@ -15,15 +15,14 @@ export const DEFAULT_MODEL_SPECS: Record<string, ModelSpec> = {
|
|
|
15
15
|
"gemini-3.1-pro-high": { maxOutputTokens: 65535, thinkingBudget: 10001, isThinking: true, contextWindow: 1_000_000 },
|
|
16
16
|
"gemini-3.1-pro-low": { maxOutputTokens: 65535, thinkingBudget: 1001, isThinking: true, contextWindow: 1_000_000 },
|
|
17
17
|
"gemini-3.1-pro-preview": { maxOutputTokens: 65535, thinkingBudget: 10001, isThinking: true, contextWindow: 1_000_000 },
|
|
18
|
-
"gemini-3.5-flash": { maxOutputTokens: 65536, thinkingBudget: 10000, isThinking: true, contextWindow: 1_000_000 },
|
|
19
|
-
"gemini-3.5-flash-medium": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
|
|
20
|
-
"gemini-3.5-flash-low": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
|
|
21
|
-
"gemini-3.5-flash-high": { maxOutputTokens: 65536, thinkingBudget: 10000, isThinking: true, contextWindow: 1_000_000 },
|
|
22
18
|
"gemini-3.6-flash-high": { maxOutputTokens: 65536, thinkingBudget: 10000, isThinking: true, contextWindow: 1_000_000 },
|
|
23
19
|
"gemini-3.6-flash-medium": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
|
|
24
20
|
"gemini-3.6-flash-low": { maxOutputTokens: 65536, thinkingBudget: 1000, isThinking: true, contextWindow: 1_000_000 },
|
|
25
21
|
"gemini-3.6-flash-tiered": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
|
|
26
22
|
"gemini-3.7-flash-tiered": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
|
|
23
|
+
"gemini-3.8-flash-high": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
|
|
24
|
+
"gemini-3.8-flash-medium": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
|
|
25
|
+
"gemini-3.8-flash-low": { maxOutputTokens: 65536, thinkingBudget: -1, isThinking: true, contextWindow: 1_000_000 },
|
|
27
26
|
"gemini-3-flash": { maxOutputTokens: 65536, thinkingBudget: 4000, isThinking: true, contextWindow: 1_000_000 },
|
|
28
27
|
"gemini-2.5-flash": { maxOutputTokens: 65535, thinkingBudget: 24576, isThinking: true, contextWindow: 1_000_000 },
|
|
29
28
|
"gemini-2.5-pro": { maxOutputTokens: 65535, thinkingBudget: 1024, isThinking: true, contextWindow: 1_000_000 },
|
package/src/compat.ts
CHANGED
|
@@ -1966,31 +1966,31 @@ async function completeViaRotator(
|
|
|
1966
1966
|
|
|
1967
1967
|
const MODEL_CATALOG = [
|
|
1968
1968
|
{
|
|
1969
|
-
id: "gemini-3
|
|
1970
|
-
family: "gemini-3
|
|
1969
|
+
id: "gemini-3-flash",
|
|
1970
|
+
family: "gemini-3-flash",
|
|
1971
1971
|
ctx: 1048576,
|
|
1972
1972
|
quotaPool: "gemini",
|
|
1973
1973
|
multimodal: true,
|
|
1974
1974
|
tools: true,
|
|
1975
1975
|
},
|
|
1976
1976
|
{
|
|
1977
|
-
id: "gemini-3.
|
|
1978
|
-
family: "gemini-3.
|
|
1977
|
+
id: "gemini-3.6-flash-high",
|
|
1978
|
+
family: "gemini-3.6-flash",
|
|
1979
1979
|
ctx: 1048576,
|
|
1980
1980
|
quotaPool: "gemini",
|
|
1981
1981
|
multimodal: true,
|
|
1982
1982
|
tools: true,
|
|
1983
1983
|
},
|
|
1984
1984
|
{
|
|
1985
|
-
id: "gemini-3-flash",
|
|
1986
|
-
family: "gemini-3.
|
|
1985
|
+
id: "gemini-3.6-flash-medium",
|
|
1986
|
+
family: "gemini-3.6-flash",
|
|
1987
1987
|
ctx: 1048576,
|
|
1988
1988
|
quotaPool: "gemini",
|
|
1989
1989
|
multimodal: true,
|
|
1990
1990
|
tools: true,
|
|
1991
1991
|
},
|
|
1992
1992
|
{
|
|
1993
|
-
id: "gemini-3.6-flash-
|
|
1993
|
+
id: "gemini-3.6-flash-low",
|
|
1994
1994
|
family: "gemini-3.6-flash",
|
|
1995
1995
|
ctx: 1048576,
|
|
1996
1996
|
quotaPool: "gemini",
|
|
@@ -1998,7 +1998,7 @@ const MODEL_CATALOG = [
|
|
|
1998
1998
|
tools: true,
|
|
1999
1999
|
},
|
|
2000
2000
|
{
|
|
2001
|
-
id: "gemini-3.6-flash-
|
|
2001
|
+
id: "gemini-3.6-flash-tiered",
|
|
2002
2002
|
family: "gemini-3.6-flash",
|
|
2003
2003
|
ctx: 1048576,
|
|
2004
2004
|
quotaPool: "gemini",
|
|
@@ -2006,24 +2006,32 @@ const MODEL_CATALOG = [
|
|
|
2006
2006
|
tools: true,
|
|
2007
2007
|
},
|
|
2008
2008
|
{
|
|
2009
|
-
id: "gemini-3.
|
|
2010
|
-
family: "gemini-3.
|
|
2009
|
+
id: "gemini-3.7-flash-tiered",
|
|
2010
|
+
family: "gemini-3.7-flash",
|
|
2011
2011
|
ctx: 1048576,
|
|
2012
2012
|
quotaPool: "gemini",
|
|
2013
2013
|
multimodal: true,
|
|
2014
2014
|
tools: true,
|
|
2015
2015
|
},
|
|
2016
2016
|
{
|
|
2017
|
-
id: "gemini-3.
|
|
2018
|
-
family: "gemini-3.
|
|
2017
|
+
id: "gemini-3.8-flash-high",
|
|
2018
|
+
family: "gemini-3.8-flash",
|
|
2019
2019
|
ctx: 1048576,
|
|
2020
2020
|
quotaPool: "gemini",
|
|
2021
2021
|
multimodal: true,
|
|
2022
2022
|
tools: true,
|
|
2023
2023
|
},
|
|
2024
2024
|
{
|
|
2025
|
-
id: "gemini-3.
|
|
2026
|
-
family: "gemini-3.
|
|
2025
|
+
id: "gemini-3.8-flash-medium",
|
|
2026
|
+
family: "gemini-3.8-flash",
|
|
2027
|
+
ctx: 1048576,
|
|
2028
|
+
quotaPool: "gemini",
|
|
2029
|
+
multimodal: true,
|
|
2030
|
+
tools: true,
|
|
2031
|
+
},
|
|
2032
|
+
{
|
|
2033
|
+
id: "gemini-3.8-flash-low",
|
|
2034
|
+
family: "gemini-3.8-flash",
|
|
2027
2035
|
ctx: 1048576,
|
|
2028
2036
|
quotaPool: "gemini",
|
|
2029
2037
|
multimodal: true,
|
package/src/dashboard.ts
CHANGED
|
@@ -281,17 +281,17 @@ export function serveKickstartApi(
|
|
|
281
281
|
rotator.kickstartTimerForAccount(email, modelKey).then((result) => {
|
|
282
282
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
283
283
|
res.end(JSON.stringify(result));
|
|
284
|
-
}).catch((
|
|
284
|
+
}).catch(() => {
|
|
285
285
|
res.writeHead(500, { "Content-Type": "application/json" });
|
|
286
|
-
res.end(JSON.stringify({ ok: false, error:
|
|
286
|
+
res.end(JSON.stringify({ ok: false, error: "Kickstart failed" }));
|
|
287
287
|
});
|
|
288
288
|
} else {
|
|
289
289
|
rotator.kickstartAllFreshTimers(email).then((result) => {
|
|
290
290
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
291
291
|
res.end(JSON.stringify(result));
|
|
292
|
-
}).catch((
|
|
292
|
+
}).catch(() => {
|
|
293
293
|
res.writeHead(500, { "Content-Type": "application/json" });
|
|
294
|
-
res.end(JSON.stringify({ ok: false, error:
|
|
294
|
+
res.end(JSON.stringify({ ok: false, error: "Kickstart failed", results: [] }));
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
297
|
}
|
|
@@ -36,6 +36,9 @@ export const ANTIGRAVITY_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
36
36
|
"gpt-oss-120b": 131_072,
|
|
37
37
|
"gpt-oss-120b-medium": 131_072,
|
|
38
38
|
// Google Gemini 3.x — 1M context window per deepmind.google/models/gemini/*.
|
|
39
|
+
"gemini-3.8-flash-high": 1_000_000,
|
|
40
|
+
"gemini-3.8-flash-medium": 1_000_000,
|
|
41
|
+
"gemini-3.8-flash-low": 1_000_000,
|
|
39
42
|
"gemini-3.7-flash": 1_000_000,
|
|
40
43
|
"gemini-3.7-flash-tiered": 1_000_000,
|
|
41
44
|
"gemini-3.6-flash": 1_000_000,
|
|
@@ -43,11 +46,6 @@ export const ANTIGRAVITY_CONTEXT_WINDOWS: Record<string, number> = {
|
|
|
43
46
|
"gemini-3.6-flash-medium": 1_000_000,
|
|
44
47
|
"gemini-3.6-flash-low": 1_000_000,
|
|
45
48
|
"gemini-3.6-flash-tiered": 1_000_000,
|
|
46
|
-
"gemini-3.5-flash": 1_000_000,
|
|
47
|
-
"gemini-3.5-flash-medium": 1_000_000,
|
|
48
|
-
"gemini-3.5-flash-low": 1_000_000,
|
|
49
|
-
"gemini-3.5-flash-high": 1_000_000,
|
|
50
|
-
"gemini-3.5-flash-lite": 1_000_000,
|
|
51
49
|
"gemini-3-flash": 1_000_000,
|
|
52
50
|
"gemini-3-flash-agent": 1_000_000,
|
|
53
51
|
"gemini-3-pro": 1_000_000,
|
|
@@ -162,7 +162,10 @@ export const googleAntigravityAdapter: ProviderAdapter = {
|
|
|
162
162
|
createStreamAccumulator: createGoogleStreamAccumulator,
|
|
163
163
|
|
|
164
164
|
getKickstartModelForPool(quotaModelKey: string): string | undefined {
|
|
165
|
-
return
|
|
165
|
+
return (
|
|
166
|
+
KICKSTART_MODEL_FOR_QUOTA_POOL[quotaModelKey] ??
|
|
167
|
+
KICKSTART_MODEL_FOR_QUOTA_POOL[resolveQuotaModelKey(quotaModelKey) ?? ""]
|
|
168
|
+
);
|
|
166
169
|
},
|
|
167
170
|
|
|
168
171
|
ownsModel(model: string): boolean {
|
|
@@ -39,7 +39,11 @@ export function extractQuotas(
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if (modelInfo?.quotaInfo) {
|
|
42
|
-
const
|
|
42
|
+
const remainingFraction = modelInfo.quotaInfo.remainingFraction ?? 0;
|
|
43
|
+
// Google can publish a nominal reset for an untouched pool; no usage means
|
|
44
|
+
// there is no active quota window yet.
|
|
45
|
+
const resetTime =
|
|
46
|
+
remainingFraction >= 1 ? null : modelInfo.quotaInfo.resetTime ?? null;
|
|
43
47
|
let timerType: ModelQuota["timerType"] = "fresh";
|
|
44
48
|
|
|
45
49
|
if (resetTime) {
|
|
@@ -63,9 +67,7 @@ export function extractQuotas(
|
|
|
63
67
|
quotas.push({
|
|
64
68
|
modelKey: config.key,
|
|
65
69
|
displayName: config.display,
|
|
66
|
-
percentRemaining: Math.round(
|
|
67
|
-
(modelInfo.quotaInfo.remainingFraction ?? 0) * 100,
|
|
68
|
-
),
|
|
70
|
+
percentRemaining: Math.round(remainingFraction * 100),
|
|
69
71
|
resetTime,
|
|
70
72
|
timerType,
|
|
71
73
|
});
|
|
@@ -1418,8 +1418,7 @@ export function mapReasoningEffortToThinkingLevel(
|
|
|
1418
1418
|
const lowerModel = modelId.toLowerCase();
|
|
1419
1419
|
const isGemini31Pro = /gemini-3\.1-pro/i.test(modelId);
|
|
1420
1420
|
const isGemini3Flash =
|
|
1421
|
-
lowerModel.includes("gemini-3-flash")
|
|
1422
|
-
lowerModel.includes("gemini-3.5-flash");
|
|
1421
|
+
lowerModel.includes("gemini-3-flash");
|
|
1423
1422
|
|
|
1424
1423
|
let effectiveEffort = effort;
|
|
1425
1424
|
if (!effectiveEffort) {
|
|
@@ -27,6 +27,8 @@ const OLLAMA_TIER_RANKING = {
|
|
|
27
27
|
unknown: 4,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
+
const OLLAMA_KICKSTART_MODEL = "gpt-oss:20b";
|
|
31
|
+
|
|
30
32
|
export const ollamaAdapter: ProviderAdapter = {
|
|
31
33
|
id: "ollama",
|
|
32
34
|
displayName: "Ollama Cloud",
|
|
@@ -74,11 +76,12 @@ export const ollamaAdapter: ProviderAdapter = {
|
|
|
74
76
|
|
|
75
77
|
getKickstartModelForPool(quotaModelKey: string): string | undefined {
|
|
76
78
|
// Only the session pool can be kickstarted for Ollama accounts.
|
|
77
|
-
return quotaModelKey === "session" ?
|
|
79
|
+
return quotaModelKey === "session" ? OLLAMA_KICKSTART_MODEL : undefined;
|
|
78
80
|
},
|
|
79
81
|
|
|
80
82
|
ownsModel(model: string, context?: { ollamaModels?: Set<string> }): boolean {
|
|
81
|
-
return
|
|
83
|
+
return model === OLLAMA_KICKSTART_MODEL ||
|
|
84
|
+
(context?.ollamaModels?.has(model) ?? false);
|
|
82
85
|
},
|
|
83
86
|
|
|
84
87
|
getPoolKey(): string {
|
|
@@ -21,13 +21,13 @@ export interface PoolBudgetEntry {
|
|
|
21
21
|
// Measured on 2026-08-09 with controlled burns (see docs/usage-calibration.md).
|
|
22
22
|
// Two gpt-oss:20b runs on different accounts agreed within ~1%, so these are
|
|
23
23
|
// per-account, per-model budgets, not per-IP.
|
|
24
|
+
// minimax-m3 removed 2026-08-30: moved to subscription tier (HTTP 402 on free).
|
|
24
25
|
export const CALIBRATED_MODEL_BUDGETS: Readonly<Record<string, PoolBudgetEntry>> = {
|
|
25
26
|
"gpt-oss:20b": { sessionTokens: 1_560_000, weeklyTokens: 4_210_000 },
|
|
26
27
|
"gemma4:31b": { sessionTokens: 1_150_000, weeklyTokens: 3_110_000 },
|
|
27
28
|
"nemotron-3-nano:30b": { sessionTokens: 1_930_000, weeklyTokens: 5_190_000 },
|
|
28
29
|
"gpt-oss:120b": { sessionTokens: 760_000, weeklyTokens: 2_050_000 },
|
|
29
30
|
"nemotron-3-super": { sessionTokens: 740_000, weeklyTokens: 2_010_000 },
|
|
30
|
-
"minimax-m3": { sessionTokens: 190_000, weeklyTokens: 520_000 },
|
|
31
31
|
"nemotron-3-ultra": { sessionTokens: 120_000, weeklyTokens: 330_000 },
|
|
32
32
|
};
|
|
33
33
|
|
package/src/proxy.ts
CHANGED
|
@@ -150,6 +150,7 @@ import { applyConfigDefaults } from "./account-store.js";
|
|
|
150
150
|
import {
|
|
151
151
|
classifyRateLimitReason,
|
|
152
152
|
parseRetryAfterMs,
|
|
153
|
+
RESOURCE_EXHAUSTED_FALLBACK_MS,
|
|
153
154
|
} from "./rate-limit-parser.js";
|
|
154
155
|
import { authenticateVirtualKey, sendAuthErrorResponse } from "./key-auth.js";
|
|
155
156
|
import { logSpend } from "./spend-logger.js";
|
|
@@ -160,7 +161,6 @@ const GENERIC_UPSTREAM_ERROR = "Upstream request failed";
|
|
|
160
161
|
|
|
161
162
|
const DEFAULT_STREAM_RECOVERY_MAX_RETRIES = 2;
|
|
162
163
|
const MAX_COOLDOWN_MS = 30 * 60 * 1000; // 30 minutes max cooldown
|
|
163
|
-
const RESOURCE_EXHAUSTED_COOLDOWN_MS = 30 * 60 * 1000; // Stop hammering provider-side daily/request buckets
|
|
164
164
|
const STREAM_IDLE_TIMEOUT_MS = 2 * 60 * 1000; // Release account if a stream goes silent.
|
|
165
165
|
const LARGE_CONTEXT_WARN_BYTES = 1 * 1024 * 1024;
|
|
166
166
|
|
|
@@ -299,13 +299,20 @@ export async function classifyUpstreamResponse(
|
|
|
299
299
|
account: AccountRuntime,
|
|
300
300
|
model: string,
|
|
301
301
|
modelKey: string,
|
|
302
|
+
providerId = DEFAULT_PROVIDER,
|
|
302
303
|
): Promise<UpstreamAction> {
|
|
303
304
|
if (response.status === 429) {
|
|
304
305
|
const errorText = await response.text().catch(() => "");
|
|
305
306
|
const rateLimitReason = classifyRateLimitReason(errorText, response.status);
|
|
306
307
|
const providerResourceExhausted = rateLimitReason === "quota-exhausted";
|
|
307
308
|
const cooldownMs = providerResourceExhausted
|
|
308
|
-
?
|
|
309
|
+
? providerId === DEFAULT_PROVIDER
|
|
310
|
+
? parseRetryAfterMs(
|
|
311
|
+
errorText,
|
|
312
|
+
response.headers,
|
|
313
|
+
RESOURCE_EXHAUSTED_FALLBACK_MS,
|
|
314
|
+
)
|
|
315
|
+
: RESOURCE_EXHAUSTED_FALLBACK_MS
|
|
309
316
|
: capCooldown(parseRetryAfterMs(errorText, response.headers));
|
|
310
317
|
return {
|
|
311
318
|
kind: "rate-limited",
|
|
@@ -1248,6 +1255,7 @@ export async function withRotation<T>(
|
|
|
1248
1255
|
account,
|
|
1249
1256
|
model,
|
|
1250
1257
|
modelKey,
|
|
1258
|
+
provider.id,
|
|
1251
1259
|
);
|
|
1252
1260
|
|
|
1253
1261
|
if (action.kind !== "success") {
|
|
@@ -1680,6 +1688,7 @@ async function handleProxyRequest(
|
|
|
1680
1688
|
account,
|
|
1681
1689
|
body.model,
|
|
1682
1690
|
modelKey,
|
|
1691
|
+
provider.id,
|
|
1683
1692
|
);
|
|
1684
1693
|
|
|
1685
1694
|
if (action.kind !== "success") {
|
package/src/rate-limit-parser.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
export type RateLimitReason = "rate-limit" | "quota-exhausted" | "model-capacity" | "server-error" | "unknown";
|
|
2
2
|
|
|
3
|
+
export const RESOURCE_EXHAUSTED_FALLBACK_MS = 30 * 60 * 1000;
|
|
4
|
+
|
|
3
5
|
function parseDurationToMs(errorText: string): number | null {
|
|
4
6
|
const durationMatch = errorText.match(/(?:(\d+)h)?(?:(\d+)m)?(\d+(?:\.\d+)?)s/i);
|
|
5
7
|
if (!durationMatch) return null;
|
|
@@ -7,7 +9,8 @@ function parseDurationToMs(errorText: string): number | null {
|
|
|
7
9
|
const minutes = durationMatch[2] ? parseInt(durationMatch[2], 10) : 0;
|
|
8
10
|
const seconds = parseFloat(durationMatch[3]);
|
|
9
11
|
if (!Number.isFinite(seconds)) return null;
|
|
10
|
-
|
|
12
|
+
const durationMs = ((hours * 60 + minutes) * 60 + seconds) * 1000;
|
|
13
|
+
return Number.isFinite(durationMs) ? Math.ceil(durationMs) : null;
|
|
11
14
|
}
|
|
12
15
|
|
|
13
16
|
export function classifyRateLimitReason(errorText: string, status?: number): RateLimitReason {
|
|
@@ -54,7 +57,11 @@ export function classifyRateLimitReason(errorText: string, status?: number): Rat
|
|
|
54
57
|
return "unknown";
|
|
55
58
|
}
|
|
56
59
|
|
|
57
|
-
export function parseRetryAfterMs(
|
|
60
|
+
export function parseRetryAfterMs(
|
|
61
|
+
errorText: string,
|
|
62
|
+
headers: Headers,
|
|
63
|
+
fallbackMs = 60_000,
|
|
64
|
+
): number {
|
|
58
65
|
const retryAfter = headers.get("retry-after");
|
|
59
66
|
if (retryAfter) {
|
|
60
67
|
const seconds = Number(retryAfter);
|
|
@@ -123,5 +130,7 @@ export function parseRetryAfterMs(errorText: string, headers: Headers): number {
|
|
|
123
130
|
const duration = parseDurationToMs(errorText);
|
|
124
131
|
if (duration && duration > 0) return Math.ceil(duration + 1000);
|
|
125
132
|
|
|
126
|
-
return
|
|
133
|
+
return Number.isFinite(fallbackMs) && fallbackMs > 0
|
|
134
|
+
? Math.ceil(fallbackMs)
|
|
135
|
+
: 60_000;
|
|
127
136
|
}
|