tuxevil-rotator 4.3.0 → 4.4.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 +33 -0
- package/README.md +5 -2
- package/package.json +5 -1
- package/src/access-evidence.ts +153 -0
- package/src/access-probe.ts +85 -0
- package/src/admin-auth.ts +4 -1
- package/src/auto-access-shadow.ts +11 -0
- package/src/auto-model-access.ts +185 -0
- package/src/auto-output-health.ts +12 -0
- package/src/auto-routing-evaluation.ts +80 -0
- package/src/auto-routing-quality.ts +308 -0
- package/src/auto-routing.ts +403 -26
- package/src/compat.ts +223 -36
- package/src/compression/index.ts +6 -6
- package/src/compression/lite.ts +3 -9
- package/src/compression/rtk/index.ts +0 -3
- package/src/config-defaults.ts +7 -0
- package/src/dashboard.ts +5 -0
- package/src/db-store.ts +10 -0
- package/src/index.ts +2 -0
- package/src/model-access-api.ts +74 -0
- package/src/model-access.ts +56 -0
- package/src/ollama-output-gate.ts +18 -0
- package/src/onboarding.ts +1 -1
- package/src/provider-catalog-evidence.ts +26 -0
- package/src/providers/google-antigravity/dynamic-catalog.ts +8 -0
- package/src/providers/google-antigravity/quota.ts +3 -0
- package/src/providers/ollama/context-window.ts +13 -0
- package/src/providers/ollama/quota.ts +4 -0
- package/src/providers/ollama/translators.ts +19 -2
- package/src/providers/openai-codex/compat.ts +5 -1
- package/src/providers/openai-codex/credentials.ts +22 -6
- package/src/providers/openai-codex/index.ts +9 -1
- package/src/providers/openai-codex/quota.ts +19 -6
- package/src/providers/opencode-zen/forward.ts +1 -1
- package/src/providers/opencode-zen/quota.ts +2 -0
- package/src/proxy.ts +78 -3
- package/src/quota-observation.ts +26 -0
- package/src/quota-pools.ts +322 -0
- package/src/rotator.ts +151 -38
- package/src/settings-repository.ts +1 -0
- package/src/telemetry.ts +3 -1
- package/src/types.ts +28 -0
- package/src/usage-limits-auth.ts +24 -0
- package/src/usage-limits.ts +148 -0
- package/src/validators.ts +26 -0
- package/src/web/components/icons.tsx +15 -0
- package/src/web/components/overlays.tsx +4 -0
- package/src/web/components/ui.tsx +9 -9
- package/src/web/lib/playground.ts +35 -0
- package/src/web/lib/pool-navigation.ts +4 -0
- package/src/web/lib/pools.ts +2 -243
- package/src/web/pages/AccountDetail.tsx +2 -1
- package/src/web/pages/ModelAccess.tsx +88 -0
- package/src/web/pages/Models.tsx +2 -0
- package/src/web/pages/Overview.tsx +26 -9
- package/src/web/pages/Playground.tsx +1132 -551
- package/src/web/pages/Transcription.tsx +304 -170
- package/src/web/state/api.ts +3 -0
- package/src/web/styles/app.css +501 -45
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { JSX } from "preact";
|
|
2
2
|
import { useEffect, useRef, useState } from "preact/hooks";
|
|
3
|
-
import { Button, Panel, Pill } from "../components/ui.js";
|
|
3
|
+
import { Button, EmptyState, Panel, Pill } from "../components/ui.js";
|
|
4
|
+
import { Icon } from "../components/icons.js";
|
|
4
5
|
import { copyText, downloadText } from "./shared.js";
|
|
5
6
|
import { toast } from "../state/actions.js";
|
|
6
7
|
import { masked, masker } from "../state/store.js";
|
|
@@ -14,7 +15,7 @@ import {
|
|
|
14
15
|
validateAudioFile,
|
|
15
16
|
type RecordingState,
|
|
16
17
|
} from "../lib/audio-recorder.js";
|
|
17
|
-
import { formatMs } from "../lib/format.js";
|
|
18
|
+
import { formatDateTime, formatMs, pluralize } from "../lib/format.js";
|
|
18
19
|
|
|
19
20
|
interface Props {
|
|
20
21
|
state: TranscriptionState;
|
|
@@ -25,6 +26,17 @@ interface Props {
|
|
|
25
26
|
onBusyChange: (busy: boolean) => void;
|
|
26
27
|
controllers: Map<string, AbortController>;
|
|
27
28
|
}
|
|
29
|
+
interface Problem {
|
|
30
|
+
title: string;
|
|
31
|
+
message: string;
|
|
32
|
+
}
|
|
33
|
+
const message = (err: unknown): string =>
|
|
34
|
+
err instanceof Error ? err.message : String(err);
|
|
35
|
+
function clock(ms: number): string {
|
|
36
|
+
const seconds = Math.floor(ms / 1000);
|
|
37
|
+
return `${Math.floor(seconds / 60)}:${String(seconds % 60).padStart(2, "0")}`;
|
|
38
|
+
}
|
|
39
|
+
|
|
28
40
|
export function TranscriptionPage({
|
|
29
41
|
state,
|
|
30
42
|
models,
|
|
@@ -39,11 +51,13 @@ export function TranscriptionPage({
|
|
|
39
51
|
const [recording, setRecording] = useState<RecordingState>("idle");
|
|
40
52
|
const [elapsed, setElapsed] = useState(0);
|
|
41
53
|
const [sending, setSending] = useState(false);
|
|
42
|
-
const [error, setError] = useState(
|
|
54
|
+
const [error, setError] = useState<Problem | null>(null);
|
|
43
55
|
const inputRef = useRef<HTMLInputElement>(null);
|
|
56
|
+
const formRef = useRef<HTMLDivElement>(null);
|
|
44
57
|
const capture = useRef<AudioRecorder | null>(null);
|
|
45
58
|
const request = useRef<AbortController | null>(null);
|
|
46
59
|
const mounted = useRef(true);
|
|
60
|
+
const refocus = useRef(false);
|
|
47
61
|
const maxBytes = audioFileLimit(maxBodyBytes);
|
|
48
62
|
const available = models.filter(
|
|
49
63
|
(id) =>
|
|
@@ -73,11 +87,12 @@ export function TranscriptionPage({
|
|
|
73
87
|
onFile: (audio) => {
|
|
74
88
|
if (mounted.current) {
|
|
75
89
|
setFile(audio);
|
|
76
|
-
setError(
|
|
90
|
+
setError(null);
|
|
77
91
|
}
|
|
78
92
|
},
|
|
79
|
-
onError: (
|
|
80
|
-
if (mounted.current)
|
|
93
|
+
onError: (text) => {
|
|
94
|
+
if (mounted.current)
|
|
95
|
+
setError({ title: "Couldn't record audio", message: text });
|
|
81
96
|
},
|
|
82
97
|
});
|
|
83
98
|
capture.current = recorder;
|
|
@@ -106,19 +121,58 @@ export function TranscriptionPage({
|
|
|
106
121
|
const timer = setInterval(() => setElapsed(Date.now() - started), 1000);
|
|
107
122
|
return () => clearInterval(timer);
|
|
108
123
|
}, [recording]);
|
|
124
|
+
// Record, Stop, Cancel, Remove and Transcribe hide or disable themselves.
|
|
125
|
+
// When that drops keyboard focus, move it to the next useful control.
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
const root = formRef.current;
|
|
128
|
+
const focused = document.activeElement;
|
|
129
|
+
if (!refocus.current || !root) return;
|
|
130
|
+
// Cancel holds focus only while permission is pending; once recording
|
|
131
|
+
// starts, Enter should stop (and keep) the clip rather than discard it.
|
|
132
|
+
if (recording === "recording" && focused && root.contains(focused)) {
|
|
133
|
+
root
|
|
134
|
+
.querySelector<HTMLElement>(".pg-audio-actions button:not(:disabled)")
|
|
135
|
+
?.focus();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (
|
|
139
|
+
focused &&
|
|
140
|
+
focused !== document.body &&
|
|
141
|
+
!(focused instanceof HTMLButtonElement && focused.disabled)
|
|
142
|
+
)
|
|
143
|
+
return;
|
|
144
|
+
const next =
|
|
145
|
+
sending || (recording === "idle" && file)
|
|
146
|
+
? ".config-actions button:not(:disabled)"
|
|
147
|
+
: ".pg-audio-actions button:not(:disabled)";
|
|
148
|
+
root.querySelector<HTMLElement>(next)?.focus();
|
|
149
|
+
}, [recording, sending, file]);
|
|
150
|
+
// Once the user moves on (clicks or tabs elsewhere), stop pulling focus back.
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
const release = (event: Event): void => {
|
|
153
|
+
if (!formRef.current?.contains(event.target as Node))
|
|
154
|
+
refocus.current = false;
|
|
155
|
+
};
|
|
156
|
+
document.addEventListener("pointerdown", release, true);
|
|
157
|
+
document.addEventListener("focusin", release, true);
|
|
158
|
+
return () => {
|
|
159
|
+
document.removeEventListener("pointerdown", release, true);
|
|
160
|
+
document.removeEventListener("focusin", release, true);
|
|
161
|
+
};
|
|
162
|
+
}, []);
|
|
109
163
|
|
|
110
164
|
function selectFile(next: File): void {
|
|
111
165
|
try {
|
|
112
166
|
validateAudioFile(next, maxBytes);
|
|
113
167
|
setFile(next);
|
|
114
|
-
setError(
|
|
168
|
+
setError(null);
|
|
115
169
|
} catch (err) {
|
|
116
|
-
setError(
|
|
170
|
+
setError({ title: "Couldn't use this file", message: message(err) });
|
|
117
171
|
}
|
|
118
172
|
}
|
|
119
173
|
function startRecording(): void {
|
|
120
174
|
if (!canRecord || locked) return;
|
|
121
|
-
setError(
|
|
175
|
+
setError(null);
|
|
122
176
|
setFile(null);
|
|
123
177
|
const controller = new AbortController();
|
|
124
178
|
controller.signal.addEventListener(
|
|
@@ -132,14 +186,17 @@ export function TranscriptionPage({
|
|
|
132
186
|
async function transcribe(): Promise<void> {
|
|
133
187
|
if (!file || locked) return;
|
|
134
188
|
if (!available.includes(selected)) {
|
|
135
|
-
setError(
|
|
189
|
+
setError({
|
|
190
|
+
title: "Transcription failed",
|
|
191
|
+
message: "Choose an enabled audio model.",
|
|
192
|
+
});
|
|
136
193
|
return;
|
|
137
194
|
}
|
|
138
195
|
const controller = new AbortController();
|
|
139
196
|
request.current = controller;
|
|
140
197
|
controllers.set("transcription", controller);
|
|
141
198
|
setSending(true);
|
|
142
|
-
setError(
|
|
199
|
+
setError(null);
|
|
143
200
|
try {
|
|
144
201
|
const result = await transcribeAudio(
|
|
145
202
|
{
|
|
@@ -162,7 +219,14 @@ export function TranscriptionPage({
|
|
|
162
219
|
}));
|
|
163
220
|
} catch (err) {
|
|
164
221
|
if (mounted.current)
|
|
165
|
-
setError(
|
|
222
|
+
setError(
|
|
223
|
+
controller.signal.aborted
|
|
224
|
+
? {
|
|
225
|
+
title: "Transcription cancelled",
|
|
226
|
+
message: "No transcript was saved.",
|
|
227
|
+
}
|
|
228
|
+
: { title: "Transcription failed", message: message(err) },
|
|
229
|
+
);
|
|
166
230
|
} finally {
|
|
167
231
|
controllers.delete("transcription");
|
|
168
232
|
request.current = null;
|
|
@@ -170,18 +234,39 @@ export function TranscriptionPage({
|
|
|
170
234
|
}
|
|
171
235
|
}
|
|
172
236
|
|
|
237
|
+
const fileName = file && (masked.value ? "Audio file" : file.name);
|
|
238
|
+
const hint = `WAV, MP3, M4A/MP4, WebM, OGG/OGA, FLAC or PCM up to ${(
|
|
239
|
+
maxBytes /
|
|
240
|
+
1024 /
|
|
241
|
+
1024
|
|
242
|
+
).toFixed(1)} MiB. ${
|
|
243
|
+
canRecord
|
|
244
|
+
? `Recording stops after ${pluralize(MAX_RECORDING_MS / 60_000, "minute")}.`
|
|
245
|
+
: "Recording needs HTTPS or localhost and a browser with MediaRecorder support."
|
|
246
|
+
}`;
|
|
247
|
+
const announcement =
|
|
248
|
+
recording === "requesting"
|
|
249
|
+
? "Waiting for microphone permission…"
|
|
250
|
+
: recording === "recording"
|
|
251
|
+
? "Recording"
|
|
252
|
+
: recording === "finalizing"
|
|
253
|
+
? "Preparing recording…"
|
|
254
|
+
: sending
|
|
255
|
+
? "Transcribing…"
|
|
256
|
+
: "";
|
|
257
|
+
|
|
173
258
|
return (
|
|
174
|
-
|
|
259
|
+
<>
|
|
175
260
|
<Panel
|
|
176
261
|
title="Transcription"
|
|
177
|
-
subtitle="Upload
|
|
262
|
+
subtitle="Upload or record audio to transcribe it. Audio isn't saved; only transcripts are."
|
|
178
263
|
>
|
|
179
|
-
<div class="form">
|
|
180
|
-
<div class="form-
|
|
264
|
+
<div class="form" ref={formRef}>
|
|
265
|
+
<div class="form-row">
|
|
181
266
|
<label class="field">
|
|
182
267
|
<span class="field-label">Audio model</span>
|
|
183
268
|
<select
|
|
184
|
-
class="
|
|
269
|
+
class="select"
|
|
185
270
|
aria-label="Audio model"
|
|
186
271
|
value={selected}
|
|
187
272
|
disabled={locked}
|
|
@@ -231,8 +316,8 @@ export function TranscriptionPage({
|
|
|
231
316
|
<label class="field">
|
|
232
317
|
<span class="field-label">Vocabulary context (optional)</span>
|
|
233
318
|
<textarea
|
|
234
|
-
class="input
|
|
235
|
-
rows={
|
|
319
|
+
class="input"
|
|
320
|
+
rows={3}
|
|
236
321
|
maxLength={1000}
|
|
237
322
|
value={state.prompt}
|
|
238
323
|
disabled={locked}
|
|
@@ -245,85 +330,108 @@ export function TranscriptionPage({
|
|
|
245
330
|
}
|
|
246
331
|
/>
|
|
247
332
|
</label>
|
|
248
|
-
<div class="
|
|
249
|
-
<
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
333
|
+
<div class="field">
|
|
334
|
+
<div class="pg-audio-actions">
|
|
335
|
+
{recording === "idle" ? (
|
|
336
|
+
<>
|
|
337
|
+
<Button
|
|
338
|
+
key="upload"
|
|
339
|
+
icon="upload"
|
|
340
|
+
disabled={locked}
|
|
341
|
+
onClick={() => inputRef.current?.click()}
|
|
342
|
+
>
|
|
343
|
+
Upload audio
|
|
344
|
+
</Button>
|
|
345
|
+
<Button
|
|
346
|
+
key="record"
|
|
347
|
+
icon="mic"
|
|
348
|
+
disabled={locked || !canRecord}
|
|
349
|
+
onClick={() => {
|
|
350
|
+
refocus.current = true;
|
|
351
|
+
startRecording();
|
|
352
|
+
}}
|
|
353
|
+
>
|
|
354
|
+
Record
|
|
355
|
+
</Button>
|
|
356
|
+
</>
|
|
357
|
+
) : (
|
|
358
|
+
<>
|
|
359
|
+
{recording === "recording" ? (
|
|
360
|
+
<Pill tone="bad">Recording {clock(elapsed)}</Pill>
|
|
361
|
+
) : (
|
|
362
|
+
<Pill tone="muted">
|
|
363
|
+
{recording === "requesting"
|
|
364
|
+
? "Waiting for microphone permission…"
|
|
365
|
+
: "Preparing recording…"}
|
|
366
|
+
</Pill>
|
|
367
|
+
)}
|
|
368
|
+
{recording === "recording" && (
|
|
369
|
+
<Button
|
|
370
|
+
key="stop"
|
|
371
|
+
onClick={() => {
|
|
372
|
+
refocus.current = true;
|
|
373
|
+
capture.current?.stop();
|
|
374
|
+
}}
|
|
375
|
+
>
|
|
376
|
+
Stop recording
|
|
377
|
+
</Button>
|
|
378
|
+
)}
|
|
379
|
+
<Button
|
|
380
|
+
key="cancel"
|
|
381
|
+
variant="ghost"
|
|
382
|
+
aria-label="Cancel recording"
|
|
383
|
+
onClick={() => {
|
|
384
|
+
refocus.current = true;
|
|
385
|
+
capture.current?.cancel();
|
|
386
|
+
}}
|
|
387
|
+
>
|
|
388
|
+
Cancel
|
|
389
|
+
</Button>
|
|
390
|
+
</>
|
|
391
|
+
)}
|
|
392
|
+
<input
|
|
393
|
+
ref={inputRef}
|
|
394
|
+
class="sr-only"
|
|
395
|
+
type="file"
|
|
396
|
+
accept={AUDIO_ACCEPT}
|
|
397
|
+
aria-label="Audio file"
|
|
398
|
+
disabled={locked}
|
|
399
|
+
onChange={(e) => {
|
|
400
|
+
const next = e.currentTarget.files?.[0];
|
|
401
|
+
e.currentTarget.value = "";
|
|
402
|
+
if (next) selectFile(next);
|
|
403
|
+
}}
|
|
404
|
+
/>
|
|
405
|
+
<span class="sr-only" role="status">
|
|
406
|
+
{announcement}
|
|
407
|
+
</span>
|
|
408
|
+
</div>
|
|
409
|
+
<span class="field-hint">{hint}</span>
|
|
304
410
|
</div>
|
|
305
|
-
{!canRecord && (
|
|
306
|
-
<p class="field-hint">
|
|
307
|
-
Microphone recording requires HTTPS or localhost and a browser
|
|
308
|
-
with MediaRecorder support. You can still upload an audio file.
|
|
309
|
-
</p>
|
|
310
|
-
)}
|
|
311
|
-
<p class="field-hint">
|
|
312
|
-
WAV, MP3, M4A/MP4, WebM, OGG/OGA, FLAC or PCM. Up to{" "}
|
|
313
|
-
{(maxBytes / 1024 / 1024).toFixed(1)} MiB per file. Recording stops
|
|
314
|
-
automatically after {MAX_RECORDING_MS / 60_000} minutes.
|
|
315
|
-
</p>
|
|
316
411
|
{file && (
|
|
317
|
-
<div class="pg-audio-
|
|
318
|
-
<div class="pg-
|
|
319
|
-
<
|
|
320
|
-
|
|
412
|
+
<div class="pg-audio-file">
|
|
413
|
+
<div class="pg-audio-file-head">
|
|
414
|
+
<div class="pg-audio-file-name">
|
|
415
|
+
<strong class="truncate" title={fileName ?? undefined}>
|
|
416
|
+
{fileName}
|
|
417
|
+
</strong>
|
|
418
|
+
<div class="cell-sub">
|
|
419
|
+
{(file.size / 1024).toFixed(1)} KiB
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
321
422
|
<Button
|
|
423
|
+
variant="ghost"
|
|
322
424
|
size="sm"
|
|
425
|
+
icon="x"
|
|
426
|
+
iconOnly
|
|
427
|
+
title={`Remove ${fileName}`}
|
|
323
428
|
disabled={locked}
|
|
324
|
-
onClick={() =>
|
|
429
|
+
onClick={() => {
|
|
430
|
+
refocus.current = true;
|
|
431
|
+
setFile(null);
|
|
432
|
+
}}
|
|
325
433
|
>
|
|
326
|
-
Remove
|
|
434
|
+
{`Remove ${fileName}`}
|
|
327
435
|
</Button>
|
|
328
436
|
</div>
|
|
329
437
|
{url && (
|
|
@@ -337,92 +445,118 @@ export function TranscriptionPage({
|
|
|
337
445
|
</div>
|
|
338
446
|
)}
|
|
339
447
|
{error && (
|
|
340
|
-
<
|
|
341
|
-
{
|
|
342
|
-
|
|
448
|
+
<div class="callout tone-bad" role="alert">
|
|
449
|
+
<Icon name="critical" size={16} />
|
|
450
|
+
<div>
|
|
451
|
+
<strong>{error.title}</strong>
|
|
452
|
+
<p>{masker.value.text(error.message)}</p>
|
|
453
|
+
</div>
|
|
454
|
+
</div>
|
|
343
455
|
)}
|
|
344
|
-
<div class="
|
|
456
|
+
<div class="config-actions">
|
|
457
|
+
<span class="spacer" />
|
|
458
|
+
{sending && (
|
|
459
|
+
<Button
|
|
460
|
+
variant="ghost"
|
|
461
|
+
onClick={() => {
|
|
462
|
+
refocus.current = true;
|
|
463
|
+
request.current?.abort();
|
|
464
|
+
}}
|
|
465
|
+
>
|
|
466
|
+
Cancel transcription
|
|
467
|
+
</Button>
|
|
468
|
+
)}
|
|
345
469
|
<Button
|
|
346
470
|
variant="primary"
|
|
471
|
+
loading={sending}
|
|
347
472
|
disabled={locked || !file || !available.includes(selected)}
|
|
348
|
-
onClick={() =>
|
|
473
|
+
onClick={() => {
|
|
474
|
+
refocus.current = true;
|
|
475
|
+
void transcribe();
|
|
476
|
+
}}
|
|
349
477
|
>
|
|
350
|
-
Transcribe
|
|
478
|
+
{sending ? "Transcribing…" : "Transcribe"}
|
|
351
479
|
</Button>
|
|
352
|
-
{sending && (
|
|
353
|
-
<>
|
|
354
|
-
<span role="status">Transcribing…</span>
|
|
355
|
-
<Button
|
|
356
|
-
variant="danger"
|
|
357
|
-
onClick={() => request.current?.abort()}
|
|
358
|
-
>
|
|
359
|
-
Cancel transcription
|
|
360
|
-
</Button>
|
|
361
|
-
</>
|
|
362
|
-
)}
|
|
363
480
|
</div>
|
|
364
|
-
<p class="field-hint">
|
|
365
|
-
Audio is sent only when you press Transcribe. Only results and
|
|
366
|
-
settings are saved in local history; audio files and recordings stay
|
|
367
|
-
in this tab.
|
|
368
|
-
</p>
|
|
369
481
|
</div>
|
|
370
482
|
</Panel>
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
483
|
+
<Panel title="Transcripts" flush>
|
|
484
|
+
{state.results.length ? (
|
|
485
|
+
<ul class="pg-transcripts">
|
|
486
|
+
{state.results.map((result) => (
|
|
487
|
+
<li key={result.id} class="pg-transcript">
|
|
488
|
+
<div class="pg-transcript-main">
|
|
489
|
+
<strong class="pg-transcript-name">
|
|
490
|
+
{masked.value ? "Transcript" : result.filename}
|
|
491
|
+
</strong>
|
|
492
|
+
<div class="cell-sub">
|
|
493
|
+
{result.model} · {formatDateTime(result.createdAt)} ·{" "}
|
|
494
|
+
{formatMs(result.elapsedMs)}
|
|
495
|
+
</div>
|
|
496
|
+
<p
|
|
497
|
+
class={`pg-transcript-text${result.text ? "" : " muted"}`}
|
|
498
|
+
>
|
|
499
|
+
{result.text
|
|
500
|
+
? masker.value.text(result.text)
|
|
501
|
+
: "No clear speech detected."}
|
|
502
|
+
</p>
|
|
503
|
+
</div>
|
|
504
|
+
<div class="pg-transcript-actions">
|
|
505
|
+
<Button
|
|
506
|
+
variant="ghost"
|
|
507
|
+
size="sm"
|
|
508
|
+
icon="copy"
|
|
509
|
+
onClick={() =>
|
|
510
|
+
void copyText(result.text).then((ok) =>
|
|
511
|
+
toast(
|
|
512
|
+
ok ? "Transcript copied" : "Could not copy transcript",
|
|
513
|
+
ok ? "success" : "error",
|
|
514
|
+
),
|
|
515
|
+
)
|
|
516
|
+
}
|
|
517
|
+
>
|
|
518
|
+
Copy
|
|
519
|
+
</Button>
|
|
520
|
+
<Button
|
|
521
|
+
variant="ghost"
|
|
522
|
+
size="sm"
|
|
523
|
+
icon="download"
|
|
524
|
+
onClick={() =>
|
|
525
|
+
downloadText(
|
|
526
|
+
`transcript-${result.id}.txt`,
|
|
527
|
+
result.text,
|
|
528
|
+
"text/plain;charset=utf-8",
|
|
529
|
+
)
|
|
530
|
+
}
|
|
531
|
+
>
|
|
532
|
+
Download
|
|
533
|
+
</Button>
|
|
534
|
+
<Button
|
|
535
|
+
variant="ghost"
|
|
536
|
+
size="sm"
|
|
537
|
+
icon="trash"
|
|
538
|
+
iconOnly
|
|
539
|
+
title="Delete transcript"
|
|
540
|
+
disabled={locked}
|
|
541
|
+
onClick={() =>
|
|
542
|
+
onChange((current) => ({
|
|
543
|
+
...current,
|
|
544
|
+
results: current.results.filter(
|
|
545
|
+
(r) => r.id !== result.id,
|
|
546
|
+
),
|
|
547
|
+
}))
|
|
548
|
+
}
|
|
549
|
+
>
|
|
550
|
+
Delete transcript
|
|
551
|
+
</Button>
|
|
552
|
+
</div>
|
|
553
|
+
</li>
|
|
554
|
+
))}
|
|
555
|
+
</ul>
|
|
556
|
+
) : (
|
|
557
|
+
<EmptyState icon="mic" title="No transcripts yet" />
|
|
558
|
+
)}
|
|
559
|
+
</Panel>
|
|
560
|
+
</>
|
|
427
561
|
);
|
|
428
562
|
}
|
package/src/web/state/api.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AccessReport } from "../../model-access-api.js";
|
|
1
2
|
// Typed client for the admin API. Auth rides on the HttpOnly session cookie,
|
|
2
3
|
// so no token is ever handled in page JavaScript.
|
|
3
4
|
|
|
@@ -189,6 +190,8 @@ export const api = {
|
|
|
189
190
|
deleteKey: (hash: string) => request("DELETE", `/api/keys/${enc(hash)}`),
|
|
190
191
|
models: () => request<{ ok: true; data: ModelCatalogEntry[] }>("GET", "/api/models"),
|
|
191
192
|
|
|
193
|
+
declareProviderPlan: (accountId: string, provider: string, plan: string) => request<AccessReport>("PUT", "/api/model-access/plan", { accountId, provider, plan }),
|
|
194
|
+
modelAccess: (params = new URLSearchParams()) => request<AccessReport>("GET", `/api/model-access?${params}`),
|
|
192
195
|
catalog: () => request<ModelCatalogResponse>("GET", "/api/catalog"),
|
|
193
196
|
refreshCatalog: () => request<ModelCatalogResponse>("POST", "/api/catalog/refresh"),
|
|
194
197
|
setProviderEnabled: (id: string, on: boolean) =>
|