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.
- package/CHANGELOG.md +48 -1
- package/README.md +20 -6
- package/package.json +3 -3
- package/plugins/opencode-discovery/capabilities.d.mts +7 -0
- package/plugins/opencode-discovery/capabilities.mjs +54 -0
- package/plugins/opencode-discovery/index.d.mts +60 -0
- package/plugins/opencode-discovery/index.mjs +333 -0
- package/plugins/opencode-discovery/package.json +24 -0
- package/src/audio-transcription.ts +32 -6
- package/src/cli.ts +3 -3
- package/src/compat/model-specs.ts +4 -0
- package/src/compat.ts +34 -6
- package/src/dashboard-app.ts +1 -0
- package/src/install-agent.ts +252 -143
- package/src/install-opencode.ts +211 -43
- package/src/providers/google-antigravity/catalog.ts +45 -166
- package/src/providers/google-antigravity/dynamic-catalog.ts +107 -10
- package/src/providers/google-antigravity/forward.ts +4 -2
- package/src/providers/google-antigravity/index.ts +12 -4
- package/src/providers/google-antigravity/quota.ts +9 -7
- package/src/providers/ollama/forward.ts +10 -0
- package/src/providers/openai-codex/catalog.ts +157 -18
- package/src/proxy.ts +54 -5
- package/src/rotator.ts +32 -22
- package/src/types.ts +79 -67
- package/src/web/app.tsx +4 -0
- package/src/web/lib/audio-recorder.ts +159 -0
- package/src/web/lib/colors.ts +4 -0
- package/src/web/lib/playground-storage.ts +261 -0
- package/src/web/lib/playground.ts +448 -0
- package/src/web/nav.ts +1 -0
- package/src/web/pages/Playground.tsx +1111 -0
- package/src/web/pages/Transcription.tsx +428 -0
- package/src/web/state/api.ts +3 -0
- package/src/web/state/playground-client.ts +136 -0
- package/src/web/state/playground.ts +69 -0
- package/src/web/state/router.ts +2 -2
- package/src/web/state/transcription-client.ts +93 -0
- package/src/web/styles/app.css +45 -0
- package/tools/telemetry-receiver/receiver.js +59 -46
- package/plugins/opencode-discovery.js +0 -174
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import { ApiError, notifyUnauthorized } from "./api.js";
|
|
2
|
+
import {
|
|
3
|
+
apiErrorMessage,
|
|
4
|
+
record,
|
|
5
|
+
type TranscriptionResult,
|
|
6
|
+
} from "../lib/playground.js";
|
|
7
|
+
import { validateAudioFile, audioFileLimit } from "../lib/audio-recorder.js";
|
|
8
|
+
|
|
9
|
+
export interface TranscriptionInput {
|
|
10
|
+
file: File;
|
|
11
|
+
model: string;
|
|
12
|
+
language: string;
|
|
13
|
+
prompt: string;
|
|
14
|
+
maxBodyBytes: number;
|
|
15
|
+
}
|
|
16
|
+
export async function transcribeAudio(
|
|
17
|
+
input: TranscriptionInput,
|
|
18
|
+
signal: AbortSignal,
|
|
19
|
+
fetcher: typeof fetch = fetch,
|
|
20
|
+
): Promise<Omit<TranscriptionResult, "id" | "createdAt">> {
|
|
21
|
+
validateAudioFile(input.file, audioFileLimit(input.maxBodyBytes));
|
|
22
|
+
if (!input.model) throw new Error("Choose an audio model first.");
|
|
23
|
+
if (input.language && !/^[a-z]{2,3}(?:-[a-zA-Z]{2,4})?$/.test(input.language))
|
|
24
|
+
throw new Error(
|
|
25
|
+
"Use a language code such as es or en, or leave it blank for automatic detection.",
|
|
26
|
+
);
|
|
27
|
+
if (input.prompt.length > 1000)
|
|
28
|
+
throw new Error("Vocabulary context must be 1000 characters or fewer.");
|
|
29
|
+
const form = new FormData();
|
|
30
|
+
form.append("file", input.file);
|
|
31
|
+
form.append("model", input.model);
|
|
32
|
+
form.append("response_format", "json");
|
|
33
|
+
if (input.language) form.append("language", input.language);
|
|
34
|
+
if (input.prompt) form.append("prompt", input.prompt);
|
|
35
|
+
const controller = new AbortController();
|
|
36
|
+
const abort = () => controller.abort();
|
|
37
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
38
|
+
if (signal.aborted) abort();
|
|
39
|
+
const started = performance.now();
|
|
40
|
+
let timedOut = false;
|
|
41
|
+
const timeout = setTimeout(() => {
|
|
42
|
+
timedOut = true;
|
|
43
|
+
controller.abort();
|
|
44
|
+
}, 40_000);
|
|
45
|
+
try {
|
|
46
|
+
const response = await fetcher("/api/playground/audio/transcriptions", {
|
|
47
|
+
method: "POST",
|
|
48
|
+
credentials: "same-origin",
|
|
49
|
+
body: form,
|
|
50
|
+
signal: controller.signal,
|
|
51
|
+
});
|
|
52
|
+
if (response.status === 401) {
|
|
53
|
+
notifyUnauthorized();
|
|
54
|
+
throw new ApiError(401, "Your session ended. Sign in again.");
|
|
55
|
+
}
|
|
56
|
+
let body: unknown;
|
|
57
|
+
try {
|
|
58
|
+
body = await response.json();
|
|
59
|
+
} catch {
|
|
60
|
+
throw new Error(
|
|
61
|
+
`Invalid transcription response (HTTP ${response.status}).`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
if (!response.ok)
|
|
65
|
+
throw new Error(
|
|
66
|
+
apiErrorMessage(body) ||
|
|
67
|
+
`Transcription failed (HTTP ${response.status}).`,
|
|
68
|
+
);
|
|
69
|
+
if (!record(body) || typeof body.text !== "string")
|
|
70
|
+
throw new Error("Transcription response is missing text.");
|
|
71
|
+
if (controller.signal.aborted) throw new Error("Request cancelled.");
|
|
72
|
+
return {
|
|
73
|
+
filename: input.file.name,
|
|
74
|
+
model: input.model,
|
|
75
|
+
language: input.language,
|
|
76
|
+
prompt: input.prompt,
|
|
77
|
+
text: body.text,
|
|
78
|
+
elapsedMs: performance.now() - started,
|
|
79
|
+
};
|
|
80
|
+
} catch (err) {
|
|
81
|
+
if (timedOut)
|
|
82
|
+
throw new Error(
|
|
83
|
+
"Transcription request timed out. Try a shorter recording.",
|
|
84
|
+
{ cause: err },
|
|
85
|
+
);
|
|
86
|
+
if (signal.aborted)
|
|
87
|
+
throw new Error("Transcription cancelled.", { cause: err });
|
|
88
|
+
throw err;
|
|
89
|
+
} finally {
|
|
90
|
+
clearTimeout(timeout);
|
|
91
|
+
signal.removeEventListener("abort", abort);
|
|
92
|
+
}
|
|
93
|
+
}
|
package/src/web/styles/app.css
CHANGED
|
@@ -5895,3 +5895,48 @@ dialog::backdrop {
|
|
|
5895
5895
|
box-shadow: none;
|
|
5896
5896
|
}
|
|
5897
5897
|
}
|
|
5898
|
+
|
|
5899
|
+
/* Playground: the same controls and surfaces as the rest of the dashboard. */
|
|
5900
|
+
.playground { display: flex; flex-direction: column; gap: 18px; }
|
|
5901
|
+
.pg-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
|
|
5902
|
+
.pg-toolbar label { display: inline-flex; align-items: center; gap: 6px; }
|
|
5903
|
+
.pg-toolbar .pg-history { display: block; flex: 1; min-width: 0; max-width: 440px; }
|
|
5904
|
+
.pg-history select { text-overflow: ellipsis; min-width: 0; width: 100%; max-width: 100%; }
|
|
5905
|
+
.pg-panels { display: grid; gap: 16px; align-items: start; }
|
|
5906
|
+
.pg-panels-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
|
|
5907
|
+
.pg-panels-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
|
|
5908
|
+
.pg-panels > .panel { min-width: 0; }
|
|
5909
|
+
.pg-parameters { margin: 14px 0; padding: 12px 0; border-block: 1px solid var(--border); }
|
|
5910
|
+
.pg-parameters summary, .pg-inspect summary { color: var(--text-2); cursor: pointer; font-size: 12px; }
|
|
5911
|
+
.pg-parameters fieldset { border: 0; padding: 14px 0 0; margin: 0; min-width: 0; }
|
|
5912
|
+
.pg-turns { max-height: 65vh; overflow: auto; margin-block: 14px; overflow-wrap: anywhere; }
|
|
5913
|
+
.pg-turn { border-top: 1px solid var(--border); padding-block: 14px; }
|
|
5914
|
+
.pg-user { background: var(--surface-2); border-radius: 10px; padding: 12px; margin-bottom: 12px; }
|
|
5915
|
+
.pg-user p { white-space: pre-wrap; }
|
|
5916
|
+
.pg-user img, .pg-images img { display: block; max-width: 100%; max-height: 180px; object-fit: contain; border-radius: 8px; margin-block: 8px; }
|
|
5917
|
+
.pg-answer { white-space: pre-wrap; overflow-wrap: anywhere; font-family: inherit; line-height: 1.65; font-size: 13px; margin-block: 10px; }
|
|
5918
|
+
.pg-code { font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto; }
|
|
5919
|
+
.pg-metrics { display: flex; flex-wrap: wrap; gap: 6px 14px; color: var(--text-3); font-size: 11px; margin-block: 12px; }
|
|
5920
|
+
.pg-composer { background: var(--surface-2); border: 1px solid var(--border); border-radius: 14px; padding: 16px; display: grid; gap: 12px; }
|
|
5921
|
+
.pg-images { display: flex; flex-wrap: wrap; gap: 14px; }
|
|
5922
|
+
.pg-images > div { max-width: 220px; }
|
|
5923
|
+
.pg-check-models { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; max-height: 240px; overflow: auto; margin-bottom: 18px; }
|
|
5924
|
+
.pg-check-models label { display: flex; align-items: start; gap: 8px; overflow-wrap: anywhere; font-size: 12px; }
|
|
5925
|
+
.pg-check-models + .pg-toolbar { margin-bottom: 18px; }
|
|
5926
|
+
.pg-results { display: grid; gap: 16px; }
|
|
5927
|
+
.playground input[type="checkbox"] { accent-color: var(--accent); }
|
|
5928
|
+
@media (max-width: 1100px) { .pg-panels-3 { grid-template-columns: 1fr; } }
|
|
5929
|
+
@media (max-width: 760px) {
|
|
5930
|
+
.pg-panels-2 { grid-template-columns: 1fr; }
|
|
5931
|
+
.pg-toolbar .pg-history { max-width: 100%; flex: 1 0 100%; }
|
|
5932
|
+
.pg-check-models { grid-template-columns: 1fr; }
|
|
5933
|
+
}
|
|
5934
|
+
.pg-composer textarea.input { min-height: 100px; height: auto; resize: vertical; }
|
|
5935
|
+
.pg-parameters textarea.input { min-height: 90px; height: auto; resize: vertical; }
|
|
5936
|
+
|
|
5937
|
+
/* Audio preview and results share the existing playground surfaces. */
|
|
5938
|
+
.pg-transcription { display: grid; gap: 16px; }
|
|
5939
|
+
.pg-audio-preview { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); overflow-wrap: anywhere; }
|
|
5940
|
+
.pg-audio-preview audio { width: 100%; max-width: 600px; }
|
|
5941
|
+
.pg-audio-context.input { min-height: 72px; height: auto; resize: vertical; }
|
|
5942
|
+
@media (max-width: 760px) { .playground > .pg-toolbar > .segmented { flex-wrap: wrap; } }
|
|
@@ -334,61 +334,74 @@ function sanitizeTokensByModel(raw) {
|
|
|
334
334
|
|
|
335
335
|
// Pricing per 1M tokens (USD) — mirrors MODEL_PRICING in the rotator
|
|
336
336
|
const MODEL_PRICING = {
|
|
337
|
-
"claude-opus-4-6-thinking": { inputPer1M: 5.
|
|
338
|
-
"claude-sonnet-4-6":
|
|
339
|
-
"gemini-3.1-pro":
|
|
340
|
-
"gemini-3.1-pro-low":
|
|
341
|
-
"gemini-3.1-pro-high":
|
|
342
|
-
"gemini-3-flash":
|
|
343
|
-
"gemini-3.6-flash":
|
|
344
|
-
"gemini-3.6-flash-high":
|
|
345
|
-
"gemini-3.6-flash-medium":
|
|
346
|
-
"gemini-3.6-flash-low":
|
|
347
|
-
"gemini-3.6-flash-tiered":
|
|
348
|
-
// Gemini
|
|
349
|
-
|
|
350
|
-
// these double to input 1.50 / output 7.50 per 1M tokens.
|
|
351
|
-
"gemini-3.7-flash-tiered": { inputPer1M: 0.75, outputPer1M: 3.75 },
|
|
337
|
+
"claude-opus-4-6-thinking": { inputPer1M: 5.0, outputPer1M: 25.0 },
|
|
338
|
+
"claude-sonnet-4-6": { inputPer1M: 3.0, outputPer1M: 15.0 },
|
|
339
|
+
"gemini-3.1-pro": { inputPer1M: 2.0, outputPer1M: 12.0 },
|
|
340
|
+
"gemini-3.1-pro-low": { inputPer1M: 2.0, outputPer1M: 12.0 },
|
|
341
|
+
"gemini-3.1-pro-high": { inputPer1M: 2.0, outputPer1M: 12.0 },
|
|
342
|
+
"gemini-3-flash": { inputPer1M: 0.5, outputPer1M: 3.0 },
|
|
343
|
+
"gemini-3.6-flash": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
344
|
+
"gemini-3.6-flash-high": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
345
|
+
"gemini-3.6-flash-medium": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
346
|
+
"gemini-3.6-flash-low": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
347
|
+
"gemini-3.6-flash-tiered": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
348
|
+
// Gemini introductory pricing: see docs/model-pricing.md (2026-10-25).
|
|
349
|
+
"gemini-3.7-flash-tiered": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
352
350
|
// Gemini 3.8 Flash uses the same introductory window and doubles on 2027-01-01.
|
|
353
|
-
"gemini-3.8-flash-low":
|
|
354
|
-
"gemini-3.8-flash-medium":
|
|
355
|
-
"gemini-3.8-flash-high":
|
|
356
|
-
"gpt-oss-120b-medium":
|
|
357
|
-
|
|
358
|
-
// Ollama Cloud
|
|
359
|
-
"gpt-oss:20b":
|
|
360
|
-
"gpt-oss:120b":
|
|
351
|
+
"gemini-3.8-flash-low": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
352
|
+
"gemini-3.8-flash-medium": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
353
|
+
"gemini-3.8-flash-high": { inputPer1M: 0.75, outputPer1M: 3.75, cachingPer1M: 0.075, cachingStoragePer1MPerHour: 0.5 },
|
|
354
|
+
"gpt-oss-120b-medium": { inputPer1M: 2.0, outputPer1M: 10.0 },
|
|
355
|
+
|
|
356
|
+
// Ollama Cloud standard-price models — mirrors MODEL_PRICING in src/types.ts
|
|
357
|
+
"gpt-oss:20b": { inputPer1M: 0.07, outputPer1M: 0.30, cachingPer1M: 0.035 },
|
|
358
|
+
"gpt-oss:120b": { inputPer1M: 0.15, outputPer1M: 0.60, cachingPer1M: 0.014 },
|
|
361
359
|
"deepseek-v4-flash:preview": { inputPer1M: 0.14, outputPer1M: 0.28 },
|
|
362
|
-
"deepseek-v4-flash:0731":
|
|
363
|
-
"deepseek-v4-pro":
|
|
364
|
-
"qwen3.5:397b":
|
|
365
|
-
"glm-5.1":
|
|
366
|
-
"glm-5.2":
|
|
367
|
-
"gemma4:31b":
|
|
368
|
-
"kimi-k2.6":
|
|
369
|
-
"kimi-k2.7-code":
|
|
370
|
-
"kimi-k3":
|
|
371
|
-
"minimax-m2.7":
|
|
372
|
-
"minimax-m3":
|
|
373
|
-
"mistral-large-3:675b":
|
|
374
|
-
"nemotron-3-nano:30b":
|
|
375
|
-
"nemotron-3-super":
|
|
376
|
-
"nemotron-3-ultra":
|
|
360
|
+
"deepseek-v4-flash:0731": { inputPer1M: 0.14, outputPer1M: 0.28, cachingPer1M: 0.0028 },
|
|
361
|
+
"deepseek-v4-pro": { inputPer1M: 1.32, outputPer1M: 3.96, cachingPer1M: 0.044 },
|
|
362
|
+
"qwen3.5:397b": { inputPer1M: 0.60, outputPer1M: 3.60 },
|
|
363
|
+
"glm-5.1": { inputPer1M: 0.80, outputPer1M: 2.56 },
|
|
364
|
+
"glm-5.2": { inputPer1M: 1.40, outputPer1M: 4.40, cachingPer1M: 0.26 },
|
|
365
|
+
"gemma4:31b": { inputPer1M: 0.14, outputPer1M: 0.40, cachingPer1M: 0.05 },
|
|
366
|
+
"kimi-k2.6": { inputPer1M: 0.95, outputPer1M: 4.00, cachingPer1M: 0.16 },
|
|
367
|
+
"kimi-k2.7-code": { inputPer1M: 0.95, outputPer1M: 4.00, cachingPer1M: 0.19 },
|
|
368
|
+
"kimi-k3": { inputPer1M: 3.00, outputPer1M: 15.00, cachingPer1M: 0.30 },
|
|
369
|
+
"minimax-m2.7": { inputPer1M: 0.30, outputPer1M: 1.20, cachingPer1M: 0.06 },
|
|
370
|
+
"minimax-m3": { inputPer1M: 0.60, outputPer1M: 2.40, cachingPer1M: 0.12 },
|
|
371
|
+
"mistral-large-3:675b": { inputPer1M: 0.50, outputPer1M: 1.50 },
|
|
372
|
+
"nemotron-3-nano:30b": { inputPer1M: 0.06, outputPer1M: 0.24 },
|
|
373
|
+
"nemotron-3-super": { inputPer1M: 0.015, outputPer1M: 0.60, cachingPer1M: 0.015 },
|
|
374
|
+
"nemotron-3-ultra": { inputPer1M: 0.10, outputPer1M: 3.00, cachingPer1M: 0.10 },
|
|
377
375
|
|
|
378
376
|
// OpenCode Zen free models — mirrors MODEL_PRICING in src/types.ts
|
|
379
|
-
"big-pickle":
|
|
380
|
-
"mimo-v2.5-free":
|
|
381
|
-
"ling-3.0-flash-fin-free":
|
|
382
|
-
"nemotron-3-ultra-free":
|
|
383
|
-
"nemotron-3.5-lightning-free":
|
|
377
|
+
"big-pickle": { inputPer1M: 0.00, outputPer1M: 0.00 },
|
|
378
|
+
"mimo-v2.5-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
|
|
379
|
+
"ling-3.0-flash-fin-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
|
|
380
|
+
"nemotron-3-ultra-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
|
|
381
|
+
"nemotron-3.5-lightning-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
|
|
384
382
|
"muse-spark-1.3-contributor-free": { inputPer1M: 0.00, outputPer1M: 0.00 },
|
|
385
383
|
"ling-3.0-tiny-free": { inputPer1M: 0.05, outputPer1M: 0.20 },
|
|
386
384
|
"laguna-s-2.1-free": { inputPer1M: 0.20, outputPer1M: 0.80 },
|
|
387
385
|
|
|
388
386
|
// OpenAI Codex models — mirrors MODEL_PRICING in src/types.ts
|
|
389
|
-
"gpt-5.6-sol":
|
|
390
|
-
"gpt-5.6-terra": { inputPer1M: 2.
|
|
391
|
-
"gpt-5.6-luna":
|
|
387
|
+
"gpt-5.6-sol": { inputPer1M: 4.0, outputPer1M: 20.0, cachingPer1M: 0.40 },
|
|
388
|
+
"gpt-5.6-terra": { inputPer1M: 2.0, outputPer1M: 12.0, cachingPer1M: 0.20 },
|
|
389
|
+
"gpt-5.6-luna": { inputPer1M: 0.20, outputPer1M: 1.20, cachingPer1M: 0.02 },
|
|
390
|
+
"gemini-4-argon": { inputPer1M: 2.0, outputPer1M: 10.0, cachingPer1M: 0.1 },
|
|
391
|
+
"gemini-4-argon-low": { inputPer1M: 2.0, outputPer1M: 10.0, cachingPer1M: 0.1 },
|
|
392
|
+
"gemini-4-argon-medium": { inputPer1M: 2.0, outputPer1M: 10.0, cachingPer1M: 0.1 },
|
|
393
|
+
"gemini-4-argon-high": { inputPer1M: 2.0, outputPer1M: 10.0, cachingPer1M: 0.1 },
|
|
394
|
+
"gpt-6-astra": { inputPer1M: 10.0, outputPer1M: 50.0, cachingPer1M: 1.0 },
|
|
395
|
+
"gpt-6-sol": { inputPer1M: 2.0, outputPer1M: 10.0, cachingPer1M: 0.2 },
|
|
396
|
+
"gpt-6-luna": { inputPer1M: 0.1, outputPer1M: 0.5, cachingPer1M: 0.01 },
|
|
397
|
+
"deepseek-v4.1-flash": { inputPer1M: 0.30, outputPer1M: 1.20, cachingPer1M: 0.006 },
|
|
398
|
+
"glm-5.3": { inputPer1M: 1.40, outputPer1M: 4.40, cachingPer1M: 0.26 },
|
|
399
|
+
"glm-5.3-flash": { inputPer1M: 0.15, outputPer1M: 0.50, cachingPer1M: 0.03 },
|
|
400
|
+
"gemma4": { inputPer1M: 0.14, outputPer1M: 0.40, cachingPer1M: 0.05 },
|
|
401
|
+
"mistral-large-4": { inputPer1M: 0.68, outputPer1M: 2.09, cachingPer1M: 0.07 },
|
|
402
|
+
"mistral-large-3": { inputPer1M: 0.50, outputPer1M: 1.50 },
|
|
403
|
+
"nemotron-3-nano": { inputPer1M: 0.06, outputPer1M: 0.24 },
|
|
404
|
+
"deepseek-v4-pro:0813": { inputPer1M: 1.74, outputPer1M: 3.48 },
|
|
392
405
|
};
|
|
393
406
|
|
|
394
407
|
function getModelPricing(model) {
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* OpenCode Model Discovery Plugin for tuxevil-rotator
|
|
3
|
-
*
|
|
4
|
-
* Automatically fetches the active model list from a tuxevil-rotator instance
|
|
5
|
-
* (or any compatible endpoint) and injects the models with their limits and capabilities
|
|
6
|
-
* into the OpenCode configuration at startup.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Resolves the configuration options for the discovery plugin.
|
|
11
|
-
* Precedence:
|
|
12
|
-
* 1. Explicit plugin options passed in opencode.json
|
|
13
|
-
* 2. Environment variables (TUXEVIL_ROTATOR_BASE_URL, ROTATOR_URL)
|
|
14
|
-
* 3. Existing provider with baseURL matching rotator port or localhost in config
|
|
15
|
-
* 4. Default: http://127.0.0.1:51200/v1
|
|
16
|
-
*/
|
|
17
|
-
export function resolvePluginOptions(config = {}, options = {}) {
|
|
18
|
-
const envBaseURL = process.env.TUXEVIL_ROTATOR_BASE_URL || process.env.ROTATOR_URL;
|
|
19
|
-
|
|
20
|
-
let discoveredBaseURL = options.baseURL || envBaseURL;
|
|
21
|
-
let providerID = options.providerID;
|
|
22
|
-
let providerName = options.providerName;
|
|
23
|
-
|
|
24
|
-
if (!discoveredBaseURL && config.provider) {
|
|
25
|
-
for (const [id, prov] of Object.entries(config.provider)) {
|
|
26
|
-
const url = prov?.options?.baseURL;
|
|
27
|
-
if (typeof url === "string" && (url.includes("51200") || url.includes("rotator") || url.includes("antigravity"))) {
|
|
28
|
-
discoveredBaseURL = url;
|
|
29
|
-
if (!providerID) providerID = id;
|
|
30
|
-
if (!providerName && prov.name) providerName = prov.name;
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (!discoveredBaseURL) {
|
|
37
|
-
discoveredBaseURL = "http://127.0.0.1:51200/v1";
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Normalize baseURL (remove trailing slashes)
|
|
41
|
-
discoveredBaseURL = discoveredBaseURL.replace(/\/+$/, "");
|
|
42
|
-
|
|
43
|
-
if (!providerID) {
|
|
44
|
-
providerID = options.providerID || "antigravity";
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
if (!providerName) {
|
|
48
|
-
providerName = options.providerName || "Antigravity (rotator)";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const timeoutMs = Number(options.timeoutMs) || 3500;
|
|
52
|
-
|
|
53
|
-
return {
|
|
54
|
-
baseURL: discoveredBaseURL,
|
|
55
|
-
providerID,
|
|
56
|
-
providerName,
|
|
57
|
-
timeoutMs,
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Maps raw model object from rotator /v1/models to OpenCode model definition.
|
|
63
|
-
*/
|
|
64
|
-
export function mapModelToOpenCode(rawModel) {
|
|
65
|
-
const id = rawModel.id;
|
|
66
|
-
const meta = rawModel.meta || {};
|
|
67
|
-
|
|
68
|
-
const contextLimit = Number(meta.context_length) || Number(rawModel.context_window) || Number(rawModel.max_model_len) || 128000;
|
|
69
|
-
const outputLimit = Number(meta.max_output_tokens) || 8192;
|
|
70
|
-
|
|
71
|
-
const isMultimodal = Boolean(meta.multimodal);
|
|
72
|
-
const toolCalling = meta.tool_calling !== false;
|
|
73
|
-
|
|
74
|
-
const modelDef = {
|
|
75
|
-
name: id,
|
|
76
|
-
limit: {
|
|
77
|
-
context: contextLimit,
|
|
78
|
-
output: outputLimit,
|
|
79
|
-
},
|
|
80
|
-
capabilities: {
|
|
81
|
-
tools: toolCalling,
|
|
82
|
-
input: isMultimodal ? ["text", "image"] : ["text"],
|
|
83
|
-
output: ["text"],
|
|
84
|
-
},
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
return { id, modelDef };
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Fetches available models from the target rotator endpoint.
|
|
92
|
-
*/
|
|
93
|
-
export async function fetchRotatorModels(baseURL, timeoutMs = 3500) {
|
|
94
|
-
const modelsUrl = `${baseURL}/models`;
|
|
95
|
-
const controller = new AbortController();
|
|
96
|
-
const timer = setTimeout(() => controller.abort(), timeoutMs);
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
const res = await fetch(modelsUrl, {
|
|
100
|
-
signal: controller.signal,
|
|
101
|
-
headers: {
|
|
102
|
-
Accept: "application/json",
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
if (!res.ok) {
|
|
107
|
-
throw new Error(`Endpoint returned status ${res.status}: ${res.statusText}`);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const json = await res.json();
|
|
111
|
-
if (!json || !Array.isArray(json.data)) {
|
|
112
|
-
throw new Error("Invalid response format: 'data' array not found");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return json.data;
|
|
116
|
-
} finally {
|
|
117
|
-
clearTimeout(timer);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
/**
|
|
122
|
-
* OpenCode Plugin Entrypoint
|
|
123
|
-
*/
|
|
124
|
-
export default async function RotatorDiscoveryPlugin(_input, options = {}) {
|
|
125
|
-
return {
|
|
126
|
-
config: async (config) => {
|
|
127
|
-
try {
|
|
128
|
-
const resolved = resolvePluginOptions(config, options);
|
|
129
|
-
const rawModels = await fetchRotatorModels(resolved.baseURL, resolved.timeoutMs);
|
|
130
|
-
|
|
131
|
-
if (!config.provider) {
|
|
132
|
-
config.provider = {};
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const existingProvider = config.provider[resolved.providerID] || {};
|
|
136
|
-
const models = { ...(existingProvider.models || {}) };
|
|
137
|
-
|
|
138
|
-
for (const raw of rawModels) {
|
|
139
|
-
if (!raw || !raw.id) continue;
|
|
140
|
-
const { id, modelDef } = mapModelToOpenCode(raw);
|
|
141
|
-
// Preserve any user-customized options or limits while merging capabilities
|
|
142
|
-
models[id] = {
|
|
143
|
-
...modelDef,
|
|
144
|
-
...(models[id] || {}),
|
|
145
|
-
capabilities: {
|
|
146
|
-
...modelDef.capabilities,
|
|
147
|
-
...(models[id]?.capabilities || {}),
|
|
148
|
-
},
|
|
149
|
-
limit: {
|
|
150
|
-
...modelDef.limit,
|
|
151
|
-
...(models[id]?.limit || {}),
|
|
152
|
-
},
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
config.provider[resolved.providerID] = {
|
|
157
|
-
npm: "@ai-sdk/openai-compatible",
|
|
158
|
-
name: resolved.providerName,
|
|
159
|
-
...existingProvider,
|
|
160
|
-
options: {
|
|
161
|
-
baseURL: resolved.baseURL,
|
|
162
|
-
...(existingProvider.options || {}),
|
|
163
|
-
},
|
|
164
|
-
models,
|
|
165
|
-
};
|
|
166
|
-
} catch (err) {
|
|
167
|
-
// Safe degrade: do not fail OpenCode startup if rotator is unreachable
|
|
168
|
-
if (process.env.DEBUG || process.env.NODE_ENV === "development") {
|
|
169
|
-
console.warn("[rotator-discovery-plugin] Could not auto-discover models:", err?.message || err);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
};
|
|
174
|
-
}
|