tuxevil-rotator 3.6.1 → 3.7.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 +10 -0
- package/README.md +6 -2
- package/package.json +1 -1
- package/src/account-identity.ts +2 -3
- package/src/audio-transcription.ts +1538 -0
- package/src/compat.ts +16 -0
- package/src/proxy.ts +59 -4
- package/src/rotator.ts +8 -0
- package/src/types.ts +3 -0
package/src/compat.ts
CHANGED
|
@@ -2124,6 +2124,22 @@ const MODEL_CATALOG = [
|
|
|
2124
2124
|
multimodal: false,
|
|
2125
2125
|
tools: true,
|
|
2126
2126
|
},
|
|
2127
|
+
{
|
|
2128
|
+
id: "models/proactive-observer-v10",
|
|
2129
|
+
family: "proactive-observer",
|
|
2130
|
+
ctx: 1048576,
|
|
2131
|
+
quotaPool: "gemini",
|
|
2132
|
+
multimodal: true,
|
|
2133
|
+
tools: false,
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
id: "whisper-1",
|
|
2137
|
+
family: "proactive-observer",
|
|
2138
|
+
ctx: 1048576,
|
|
2139
|
+
quotaPool: "gemini",
|
|
2140
|
+
multimodal: true,
|
|
2141
|
+
tools: false,
|
|
2142
|
+
},
|
|
2127
2143
|
] as const;
|
|
2128
2144
|
|
|
2129
2145
|
export interface OpenAIModelCatalogEntry {
|
package/src/proxy.ts
CHANGED
|
@@ -170,6 +170,10 @@ import {
|
|
|
170
170
|
serveGeminiModels,
|
|
171
171
|
serveOpenAIModels,
|
|
172
172
|
} from "./compat.js";
|
|
173
|
+
import {
|
|
174
|
+
handleOpenAIAudioTranscriptions,
|
|
175
|
+
handleAudioWebSocket,
|
|
176
|
+
} from "./audio-transcription.js";
|
|
173
177
|
import { applyConfigDefaults } from "./account-store.js";
|
|
174
178
|
import {
|
|
175
179
|
classifyRateLimitReason,
|
|
@@ -1229,8 +1233,13 @@ export async function withRotation<T>(
|
|
|
1229
1233
|
);
|
|
1230
1234
|
|
|
1231
1235
|
try {
|
|
1232
|
-
const
|
|
1233
|
-
|
|
1236
|
+
const skipJitter = Boolean(
|
|
1237
|
+
originalHeaders &&
|
|
1238
|
+
(originalHeaders["x-skip-safety-jitter"] === "true" ||
|
|
1239
|
+
originalHeaders["x-live-request"] === "true"),
|
|
1240
|
+
);
|
|
1241
|
+
const jitterMs = skipJitter ? 0 : rotator.getSafetyJitterMs(account);
|
|
1242
|
+
const globalDelayMs = skipJitter ? 0 : rotator.getGlobalDelayMs();
|
|
1234
1243
|
const totalDelayMs = jitterMs + globalDelayMs;
|
|
1235
1244
|
if (totalDelayMs > 0) {
|
|
1236
1245
|
if (jitterMs > 0) {
|
|
@@ -1682,8 +1691,9 @@ async function handleProxyRequest(
|
|
|
1682
1691
|
};
|
|
1683
1692
|
|
|
1684
1693
|
try {
|
|
1685
|
-
const
|
|
1686
|
-
const
|
|
1694
|
+
const skipJitter = req.headers["x-skip-safety-jitter"] === "true" || req.headers["x-live-request"] === "true";
|
|
1695
|
+
const jitterMs = skipJitter ? 0 : rotator.getSafetyJitterMs(account);
|
|
1696
|
+
const globalDelayMs = skipJitter ? 0 : rotator.getGlobalDelayMs();
|
|
1687
1697
|
const totalDelayMs = jitterMs + globalDelayMs;
|
|
1688
1698
|
if (totalDelayMs > 0) {
|
|
1689
1699
|
if (jitterMs > 0) {
|
|
@@ -2058,6 +2068,17 @@ export function startProxy(
|
|
|
2058
2068
|
const url = req.url || "";
|
|
2059
2069
|
const pathname = url.split("?")[0];
|
|
2060
2070
|
|
|
2071
|
+
// CORS headers for API consumers (e.g. MindWhisperAI, local frontends)
|
|
2072
|
+
res.setHeader("Access-Control-Allow-Origin", "*");
|
|
2073
|
+
res.setHeader("Access-Control-Allow-Methods", "GET, POST, PUT, DELETE, OPTIONS");
|
|
2074
|
+
res.setHeader("Access-Control-Allow-Headers", "*");
|
|
2075
|
+
|
|
2076
|
+
if (method === "OPTIONS") {
|
|
2077
|
+
res.writeHead(204);
|
|
2078
|
+
res.end();
|
|
2079
|
+
return;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2061
2082
|
if (method === "GET" && (pathname === "/" || pathname === "/dashboard")) {
|
|
2062
2083
|
if (!requireAdmin(req, res)) return;
|
|
2063
2084
|
trackFeature("dashboard");
|
|
@@ -2475,6 +2496,23 @@ export function startProxy(
|
|
|
2475
2496
|
return;
|
|
2476
2497
|
}
|
|
2477
2498
|
|
|
2499
|
+
if (method === "POST" && pathname === "/v1/audio/transcriptions") {
|
|
2500
|
+
handleOpenAIAudioTranscriptions(req, res).catch((err) => {
|
|
2501
|
+
log(`Audio transcription error: ${err}`, rotator, "error");
|
|
2502
|
+
if (!res.headersSent)
|
|
2503
|
+
res.writeHead(500, { "Content-Type": "application/json" });
|
|
2504
|
+
res.end(
|
|
2505
|
+
JSON.stringify({
|
|
2506
|
+
error: {
|
|
2507
|
+
message: "Internal audio transcription error",
|
|
2508
|
+
type: "server_error",
|
|
2509
|
+
},
|
|
2510
|
+
}),
|
|
2511
|
+
);
|
|
2512
|
+
});
|
|
2513
|
+
return;
|
|
2514
|
+
}
|
|
2515
|
+
|
|
2478
2516
|
if (method === "POST" && pathname === "/v1/responses") {
|
|
2479
2517
|
handleOpenAIResponsesCreate(req, res, rotator).catch((err) => {
|
|
2480
2518
|
log(`OpenAI responses compat error: ${err}`, rotator, "error");
|
|
@@ -2597,9 +2635,26 @@ export function startProxy(
|
|
|
2597
2635
|
res.end(JSON.stringify({ error: "Not found" }));
|
|
2598
2636
|
});
|
|
2599
2637
|
|
|
2638
|
+
server.on("upgrade", (req, socket) => {
|
|
2639
|
+
const url = req.url || "";
|
|
2640
|
+
const pathname = url.split("?")[0];
|
|
2641
|
+
if (
|
|
2642
|
+
pathname === "/ws" ||
|
|
2643
|
+
pathname === "/ws/audio" ||
|
|
2644
|
+
pathname === "/v1/audio/transcriptions/stream" ||
|
|
2645
|
+
pathname === "/v1/listen" ||
|
|
2646
|
+
pathname.startsWith("/ws/")
|
|
2647
|
+
) {
|
|
2648
|
+
handleAudioWebSocket(req, socket).catch(() => socket.destroy());
|
|
2649
|
+
return;
|
|
2650
|
+
}
|
|
2651
|
+
socket.destroy();
|
|
2652
|
+
});
|
|
2653
|
+
|
|
2600
2654
|
server.listen(port, bindHost, () => {
|
|
2601
2655
|
log(`Listening on ${bindHost}:${port}`, rotator);
|
|
2602
2656
|
log(`Dashboard: http://localhost:${port}/dashboard`, rotator);
|
|
2657
|
+
log(`Audio Stream WS: ws://localhost:${port}/ws`, rotator);
|
|
2603
2658
|
log(`Hosted login: http://localhost:${port}/login`, rotator);
|
|
2604
2659
|
});
|
|
2605
2660
|
return server;
|
package/src/rotator.ts
CHANGED
|
@@ -1937,6 +1937,14 @@ export class AccountRotator {
|
|
|
1937
1937
|
this.requestWaiterWakeAt = wakeAt;
|
|
1938
1938
|
this.requestWaiterWakeTimer = setTimeout(() => {
|
|
1939
1939
|
this.requestWaiterWakeTimer = null;
|
|
1940
|
+
if (this.requestWaiters.length === 0) {
|
|
1941
|
+
this.requestWaiterWakeAt = 0;
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
if (Date.now() < wakeAt) {
|
|
1945
|
+
this.scheduleRequestWaiterWake(wakeAt);
|
|
1946
|
+
return;
|
|
1947
|
+
}
|
|
1940
1948
|
this.requestWaiterWakeAt = 0;
|
|
1941
1949
|
this.requestWaiterDrain();
|
|
1942
1950
|
}, Math.max(1, wakeAt - Date.now()));
|
package/src/types.ts
CHANGED
|
@@ -171,6 +171,9 @@ export const MAX_QUOTA_POLL_INTERVAL_MS = 24 * 60 * 60 * 1000;
|
|
|
171
171
|
const DEFAULT_MODEL_ALIASES: Record<string, string> = {
|
|
172
172
|
"gemini-3.1-pro-high": "gemini-pro-agent",
|
|
173
173
|
"gpt-oss-120b": "gpt-oss-120b-medium",
|
|
174
|
+
"whisper-1": "models/proactive-observer-v10",
|
|
175
|
+
"proactive-observer": "models/proactive-observer-v10",
|
|
176
|
+
"proactive-observer-v10": "models/proactive-observer-v10",
|
|
174
177
|
};
|
|
175
178
|
let modelAliasesOverride: Record<string, string> | null = null;
|
|
176
179
|
type StoredEffortRoutingRule = {
|