tuxevil-rotator 3.6.1 → 3.7.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 +25 -0
- package/README.md +12 -5
- package/package.json +1 -1
- package/src/account-identity.ts +2 -3
- package/src/audio-transcription.ts +1538 -0
- package/src/compat.ts +231 -8
- package/src/providers/adapter.ts +9 -0
- package/src/providers/credential-helpers.ts +12 -1
- package/src/providers/ollama/index.ts +5 -3
- package/src/providers/ollama/quota-poll-store.ts +14 -6
- package/src/providers/ollama/quota.ts +31 -5
- package/src/providers/openai-codex/forward.ts +48 -0
- package/src/providers/openai-codex/index.ts +26 -2
- package/src/providers/openai-codex/quota.ts +32 -6
- package/src/providers/opencode-zen/catalog.ts +15 -4
- package/src/providers/opencode-zen/forward.ts +704 -13
- package/src/providers/opencode-zen/quota.ts +1 -1
- package/src/providers/registry.ts +2 -0
- package/src/proxy.ts +59 -4
- package/src/rotator.ts +94 -37
- package/src/static/dashboard.css +1 -0
- package/src/static/dashboard.js +14 -15
- package/src/telemetry.ts +1 -1
- package/src/types.ts +24 -23
- package/tools/telemetry-receiver/receiver.js +12 -11
|
@@ -10,6 +10,11 @@ export const CODEX_SPARK_QUOTA_MODEL_KEY = "openai-codex-spark";
|
|
|
10
10
|
export const CODEX_USAGE_URL = "https://chatgpt.com/backend-api/wham/usage";
|
|
11
11
|
export const CODEX_QUOTA_CACHE_TTL_MS = 60_000;
|
|
12
12
|
export const CODEX_QUOTA_TIMEOUT_MS = 8_000;
|
|
13
|
+
// The Codex usage API reports roughly 30 days for a window that has not been
|
|
14
|
+
// started yet. Treat anything above 29d 23h 55m as that sentinel rather than
|
|
15
|
+
// exposing a fictitious long-running timer.
|
|
16
|
+
export const CODEX_UNSTARTED_TIMER_THRESHOLD_SECONDS =
|
|
17
|
+
30 * 24 * 60 * 60 - 5 * 60;
|
|
13
18
|
|
|
14
19
|
export interface CodexQuotaWindow {
|
|
15
20
|
usedPercent: number;
|
|
@@ -110,10 +115,25 @@ function dominantWindow(snapshot: CodexQuotaSnapshot): CodexQuotaWindow {
|
|
|
110
115
|
: snapshot.secondary;
|
|
111
116
|
}
|
|
112
117
|
|
|
118
|
+
function remainingSeconds(window: CodexQuotaWindow): number | null {
|
|
119
|
+
if (window.resetAfterSeconds !== null) return window.resetAfterSeconds;
|
|
120
|
+
if (!window.resetAt) return null;
|
|
121
|
+
return Math.round((new Date(window.resetAt).getTime() - Date.now()) / 1000);
|
|
122
|
+
}
|
|
123
|
+
|
|
113
124
|
function timerType(window: CodexQuotaWindow): "fresh" | "5h" | "7d" {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
125
|
+
const remaining = remainingSeconds(window);
|
|
126
|
+
if (
|
|
127
|
+
remaining === null ||
|
|
128
|
+
remaining > CODEX_UNSTARTED_TIMER_THRESHOLD_SECONDS
|
|
129
|
+
) {
|
|
130
|
+
return "fresh";
|
|
131
|
+
}
|
|
132
|
+
return remaining > 24 * 60 * 60 ? "7d" : "5h";
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function visibleResetTime(window: CodexQuotaWindow): string | null {
|
|
136
|
+
return timerType(window) === "fresh" ? null : window.resetAt;
|
|
117
137
|
}
|
|
118
138
|
|
|
119
139
|
export function codexQuotaRows(snapshot: CodexQuotaSnapshot): ModelQuota[] {
|
|
@@ -123,7 +143,7 @@ export function codexQuotaRows(snapshot: CodexQuotaSnapshot): ModelQuota[] {
|
|
|
123
143
|
displayName: "Codex",
|
|
124
144
|
providerId: CODEX_PROVIDER_ID,
|
|
125
145
|
percentRemaining: dominant.percentRemaining,
|
|
126
|
-
resetTime: dominant
|
|
146
|
+
resetTime: visibleResetTime(dominant),
|
|
127
147
|
timerType: timerType(dominant),
|
|
128
148
|
}];
|
|
129
149
|
if (snapshot.spark) {
|
|
@@ -135,7 +155,7 @@ export function codexQuotaRows(snapshot: CodexQuotaSnapshot): ModelQuota[] {
|
|
|
135
155
|
displayName: "Codex Spark",
|
|
136
156
|
providerId: CODEX_PROVIDER_ID,
|
|
137
157
|
percentRemaining: spark.percentRemaining,
|
|
138
|
-
resetTime: spark
|
|
158
|
+
resetTime: visibleResetTime(spark),
|
|
139
159
|
timerType: timerType(spark),
|
|
140
160
|
});
|
|
141
161
|
}
|
|
@@ -161,7 +181,13 @@ function cacheKey(account: AccountRuntime): string {
|
|
|
161
181
|
return `${account.config.email.toLowerCase()}:${getCodexAccountId(account.config) ?? "unknown"}`;
|
|
162
182
|
}
|
|
163
183
|
|
|
164
|
-
export function clearCodexQuotaCache(): void {
|
|
184
|
+
export function clearCodexQuotaCache(account?: AccountRuntime): void {
|
|
185
|
+
if (account) {
|
|
186
|
+
quotaCache.delete(cacheKey(account));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
quotaCache.clear();
|
|
190
|
+
}
|
|
165
191
|
|
|
166
192
|
export async function fetchCodexQuota(
|
|
167
193
|
account: AccountRuntime,
|
|
@@ -3,13 +3,19 @@
|
|
|
3
3
|
export const OPENCODE_ZEN_BASE_URL = "https://opencode.ai/zen/v1";
|
|
4
4
|
export const OPENCODE_ZEN_MODELS_URL = "https://opencode.ai/zen/v1/models";
|
|
5
5
|
export const OPENCODE_ZEN_CHAT_URL = "https://opencode.ai/zen/v1/chat/completions";
|
|
6
|
+
export const OPENCODE_ZEN_RESPONSES_URL = "https://opencode.ai/zen/v1/responses";
|
|
6
7
|
|
|
7
8
|
export const OPENCODE_ZEN_FREE_MODELS = [
|
|
8
|
-
"
|
|
9
|
-
"nemotron-3.5-lightning-free",
|
|
10
|
-
"nemotron-3-ultra-free",
|
|
9
|
+
"big-pickle",
|
|
11
10
|
"mimo-v2.5-free",
|
|
12
|
-
"
|
|
11
|
+
"ling-3.0-flash-fin-free",
|
|
12
|
+
"nemotron-3-ultra-free",
|
|
13
|
+
"nemotron-3.5-lightning-free",
|
|
14
|
+
"muse-spark-1.3-contributor-free",
|
|
15
|
+
] as const;
|
|
16
|
+
|
|
17
|
+
export const OPENCODE_ZEN_RESPONSES_MODELS = [
|
|
18
|
+
"muse-spark-1.3-contributor-free",
|
|
13
19
|
] as const;
|
|
14
20
|
|
|
15
21
|
export type OpenCodeZenModel = (typeof OPENCODE_ZEN_FREE_MODELS)[number];
|
|
@@ -41,9 +47,14 @@ export function getOpenCodeZenContextWindow(_model: string): number {
|
|
|
41
47
|
}
|
|
42
48
|
|
|
43
49
|
const OPENCODE_ZEN_MODEL_SET = new Set<string>(OPENCODE_ZEN_FREE_MODELS);
|
|
50
|
+
const OPENCODE_ZEN_RESPONSES_MODEL_SET = new Set<string>(OPENCODE_ZEN_RESPONSES_MODELS);
|
|
44
51
|
|
|
45
52
|
export function isOpenCodeZenModel(model: string): boolean {
|
|
46
53
|
if (!model) return false;
|
|
47
54
|
if (OPENCODE_ZEN_MODEL_SET.has(model)) return true;
|
|
48
55
|
return model.endsWith("-free");
|
|
49
56
|
}
|
|
57
|
+
|
|
58
|
+
export function isOpenCodeZenResponsesModel(model: string): boolean {
|
|
59
|
+
return OPENCODE_ZEN_RESPONSES_MODEL_SET.has(model);
|
|
60
|
+
}
|