tuxevil-rotator 4.2.1 → 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 (41) hide show
  1. package/CHANGELOG.md +48 -1
  2. package/README.md +20 -6
  3. package/package.json +3 -3
  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 +60 -0
  7. package/plugins/opencode-discovery/index.mjs +333 -0
  8. package/plugins/opencode-discovery/package.json +24 -0
  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 +34 -6
  13. package/src/dashboard-app.ts +1 -0
  14. package/src/install-agent.ts +252 -143
  15. package/src/install-opencode.ts +211 -43
  16. package/src/providers/google-antigravity/catalog.ts +45 -166
  17. package/src/providers/google-antigravity/dynamic-catalog.ts +107 -10
  18. package/src/providers/google-antigravity/forward.ts +4 -2
  19. package/src/providers/google-antigravity/index.ts +12 -4
  20. package/src/providers/google-antigravity/quota.ts +9 -7
  21. package/src/providers/ollama/forward.ts +10 -0
  22. package/src/providers/openai-codex/catalog.ts +157 -18
  23. package/src/proxy.ts +54 -5
  24. package/src/rotator.ts +32 -22
  25. package/src/types.ts +79 -67
  26. package/src/web/app.tsx +4 -0
  27. package/src/web/lib/audio-recorder.ts +159 -0
  28. package/src/web/lib/colors.ts +4 -0
  29. package/src/web/lib/playground-storage.ts +261 -0
  30. package/src/web/lib/playground.ts +448 -0
  31. package/src/web/nav.ts +1 -0
  32. package/src/web/pages/Playground.tsx +1111 -0
  33. package/src/web/pages/Transcription.tsx +428 -0
  34. package/src/web/state/api.ts +3 -0
  35. package/src/web/state/playground-client.ts +136 -0
  36. package/src/web/state/playground.ts +69 -0
  37. package/src/web/state/router.ts +2 -2
  38. package/src/web/state/transcription-client.ts +93 -0
  39. package/src/web/styles/app.css +45 -0
  40. package/tools/telemetry-receiver/receiver.js +59 -46
  41. package/plugins/opencode-discovery.js +0 -174
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "tuxevil-opencode-discovery",
3
+ "version": "1.0.0",
4
+ "description": "OpenCode V2 plugin that discovers tuxevil-rotator models and registers the provider",
5
+ "type": "module",
6
+ "main": "./index.mjs",
7
+ "exports": {
8
+ ".": "./index.mjs"
9
+ },
10
+ "files": [
11
+ "index.mjs",
12
+ "index.d.mts",
13
+ "capabilities.mjs",
14
+ "capabilities.d.mts"
15
+ ],
16
+ "keywords": [
17
+ "opencode",
18
+ "opencode-plugin",
19
+ "openviking",
20
+ "rotator",
21
+ "model-discovery"
22
+ ],
23
+ "license": "Apache-2.0"
24
+ }
@@ -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,
@@ -2602,11 +2603,10 @@ function getOpenAIAntigravityModels(
2602
2603
  /**
2603
2604
  * Build the OpenAI-compatible `/v1/models` catalog for the proxy.
2604
2605
  *
2605
- * The static Antigravity baseline and dynamically-discovered Antigravity models
2606
- * are included unless Antigravity is turned off. An active rotator also
2607
- * contributes its other providers. Models turned off on the dashboard's Models
2608
- * page are left out, and an id more than one provider lists appears once, owned
2609
- * by the provider its requests go to.
2606
+ * Dynamically discovered Antigravity models are included unless Antigravity is
2607
+ * turned off. An active rotator also contributes its other providers. Models
2608
+ * turned off on the dashboard's Models page are left out, and an id more than
2609
+ * one provider lists appears once, owned by the provider its requests go to.
2610
2610
  */
2611
2611
  export function buildOpenAIModelCatalog(
2612
2612
  rotator?: AccountRotator,
@@ -2670,6 +2670,8 @@ export function buildOpenAIModelCatalog(
2670
2670
  family: "openai-codex",
2671
2671
  provider: "openai-codex",
2672
2672
  reasoning: model.reasoning,
2673
+ ...(model.reasoning && model.reasoningEfforts ? { reasoning_efforts: model.reasoningEfforts } : {}),
2674
+ ...(model.reasoning && model.defaultReasoningEffort ? { default_reasoning_effort: model.defaultReasoningEffort } : {}),
2673
2675
  multimodal: model.multimodal,
2674
2676
  tool_calling: model.tools,
2675
2677
  },
@@ -2936,10 +2938,34 @@ export async function handleGeminiGenerateContent(
2936
2938
  }, rotatorHeaders);
2937
2939
  }
2938
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
+
2939
2956
  export async function handleOpenAIChatCompletions(
2940
2957
  req: IncomingMessage,
2941
2958
  res: ServerResponse,
2942
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,
2943
2969
  ): Promise<void> {
2944
2970
  let parsed: unknown;
2945
2971
  try {
@@ -2966,7 +2992,9 @@ export async function handleOpenAIChatCompletions(
2966
2992
 
2967
2993
  const requestedModel = validation.value.model;
2968
2994
  const autoRequested = isAutoModel(requestedModel);
2969
- 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);
2970
2998
  if (!auth.authenticated) {
2971
2999
  sendAuthErrorResponse(res, auth);
2972
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'",