@cartanova/qgrid-cli 2.19.2 → 2.20.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 (42) hide show
  1. package/bundle/dist/application/qgrid/qgrid.frame.js +20 -9
  2. package/bundle/dist/application/qgrid/qgrid.types.js +84 -2
  3. package/bundle/dist/utils/providers/openai/openai-realtime-protocol.js +29 -53
  4. package/bundle/dist/utils/providers/openai/openai-voice-client.js +4 -3
  5. package/bundle/src/application/qgrid/qgrid.frame.test.ts +36 -0
  6. package/bundle/src/application/qgrid/qgrid.frame.ts +24 -5
  7. package/bundle/src/application/qgrid/qgrid.types.ts +90 -0
  8. package/bundle/src/application/sonamu.generated.http +6 -0
  9. package/bundle/src/utils/providers/openai/openai-realtime-protocol.ts +64 -56
  10. package/bundle/src/utils/providers/openai/openai-voice-client.test.ts +27 -2
  11. package/bundle/src/utils/providers/openai/openai-voice-client.ts +8 -1
  12. package/bundle/web-dist/client/assets/TimedPlayer-UGSsgTKj.js +1 -0
  13. package/bundle/web-dist/client/assets/{index-hUNCpC11.css → index-BITKCBxB.css} +1 -1
  14. package/bundle/web-dist/client/assets/{index-BeceW0U9.js → index-DjrhMvkM.js} +14 -14
  15. package/bundle/web-dist/client/assets/{logs-jMJnTwZn.js → logs-DN5BhglL.js} +1 -1
  16. package/bundle/web-dist/client/assets/{monit-B1xRKwua.js → monit-DZPRb015.js} +1 -1
  17. package/bundle/web-dist/client/assets/{routes-fsiyivXx.js → routes-DJAp0zIh.js} +1 -1
  18. package/bundle/web-dist/client/assets/{settings-CHX44roa.js → settings-WY3p1iSx.js} +1 -1
  19. package/bundle/web-dist/client/assets/show-DykCwUpU.js +2 -0
  20. package/bundle/web-dist/client/assets/{tokens-zGl36OfE.js → tokens-DSdQ7R5O.js} +1 -1
  21. package/bundle/web-dist/client/assets/{use-oauth-login-flow-DYWj4645.js → use-oauth-login-flow-gc2fKVxE.js} +1 -1
  22. package/bundle/web-dist/client/assets/{use-update-token-mutation-BRXXrEf5.js → use-update-token-mutation-BGVP43e8.js} +1 -1
  23. package/bundle/web-dist/client/assets/voice-DRzMbzHH.js +4 -0
  24. package/bundle/web-dist/client/index.html +2 -2
  25. package/bundle/web-dist/server/assets/TimedPlayer-CcClBzGi.js +193 -0
  26. package/bundle/web-dist/server/assets/{logs-HPho1SkC.js → logs-CxAwuDKc.js} +1 -1
  27. package/bundle/web-dist/server/assets/{routes-BNHCX4VI.js → routes-W-pd1Hps.js} +1 -1
  28. package/bundle/web-dist/server/assets/{settings-NJUyaSrJ.js → settings-CFdTg1_f.js} +1 -1
  29. package/bundle/web-dist/server/assets/{show-Dz5QGL7l.js → show-DVEIHsXh.js} +35 -157
  30. package/bundle/web-dist/server/assets/{tokens-BPQvjIGq.js → tokens-BO1hyBuB.js} +1 -1
  31. package/bundle/web-dist/server/assets/voice-BCF-Pkzo.js +1115 -0
  32. package/bundle/web-dist/server/entry-server.generated.js +90 -8
  33. package/package.json +1 -1
  34. package/skills/qgrid/references/ai-sdk-provider-contract.md +4 -0
  35. package/skills/qgrid/references/openai-codex-runtime.md +3 -1
  36. package/skills/qgrid/references/request-log-run-lifecycle.md +1 -1
  37. package/skills/qgrid/references/sonamu-api-web-flow.md +2 -2
  38. package/bundle/web-dist/client/assets/TimedPlayer-cuEgYA3Q.js +0 -1
  39. package/bundle/web-dist/client/assets/show-BDMwKfEY.js +0 -2
  40. package/bundle/web-dist/client/assets/voice-Bwcp-KAu.js +0 -1
  41. package/bundle/web-dist/server/assets/TimedPlayer-COqaTQSl.js +0 -54
  42. package/bundle/web-dist/server/assets/voice-V-E3tRqD.js +0 -967
@@ -1,967 +0,0 @@
1
- import { C as looseObject, D as string, X as require_jsx_runtime, Z as require_react, n as QgridService, tt as __toESM } from "./services.generated-C3b31_vt.js";
2
- import { _ as Link, c as ForwardRef$4, l as ForwardRef$5, m as VOICE_TAB_TITLES, n as Route, o as Effort, p as VOICE_TAB_IDS, s as QGRID_MODEL_GROUPS } from "../entry-server.generated.js";
3
- import { t as TimedPlayer } from "./TimedPlayer-COqaTQSl.js";
4
- //#region ~icons/lucide/external-link.jsx
5
- var import_react = /* @__PURE__ */ __toESM(require_react());
6
- var import_jsx_runtime = require_jsx_runtime();
7
- var lucideExternalLink = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
8
- viewBox: "0 0 24 24",
9
- width: "1.2em",
10
- height: "1.2em",
11
- ref,
12
- "aria-labelledby": titleId,
13
- ...props,
14
- children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
15
- id: titleId,
16
- children: title
17
- }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
18
- fill: "none",
19
- stroke: "currentColor",
20
- strokeLinecap: "round",
21
- strokeLinejoin: "round",
22
- strokeWidth: 2,
23
- d: "M15 3h6v6m-11 5L21 3m-3 10v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"
24
- })]
25
- });
26
- var ForwardRef$3 = (0, import_react.forwardRef)(lucideExternalLink);
27
- //#endregion
28
- //#region ~icons/lucide/loader-circle.jsx
29
- var lucideLoaderCircle = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
30
- viewBox: "0 0 24 24",
31
- width: "1.2em",
32
- height: "1.2em",
33
- ref,
34
- "aria-labelledby": titleId,
35
- ...props,
36
- children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
37
- id: titleId,
38
- children: title
39
- }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
40
- fill: "none",
41
- stroke: "currentColor",
42
- strokeLinecap: "round",
43
- strokeLinejoin: "round",
44
- strokeWidth: 2,
45
- d: "M21 12a9 9 0 1 1-6.219-8.56"
46
- })]
47
- });
48
- var ForwardRef$2 = (0, import_react.forwardRef)(lucideLoaderCircle);
49
- //#endregion
50
- //#region ~icons/lucide/mic.jsx
51
- var lucideMic = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
52
- viewBox: "0 0 24 24",
53
- width: "1.2em",
54
- height: "1.2em",
55
- ref,
56
- "aria-labelledby": titleId,
57
- ...props,
58
- children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
59
- id: titleId,
60
- children: title
61
- }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("g", {
62
- fill: "none",
63
- stroke: "currentColor",
64
- strokeLinecap: "round",
65
- strokeLinejoin: "round",
66
- strokeWidth: 2,
67
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M12 19v3m7-12v2a7 7 0 0 1-14 0v-2" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", {
68
- width: 6,
69
- height: 13,
70
- x: 9,
71
- y: 2,
72
- rx: 3
73
- })]
74
- })]
75
- });
76
- var ForwardRef$1 = (0, import_react.forwardRef)(lucideMic);
77
- //#endregion
78
- //#region ~icons/lucide/play.jsx
79
- var lucidePlay = ({ title, titleId, ...props }, ref) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", {
80
- viewBox: "0 0 24 24",
81
- width: "1.2em",
82
- height: "1.2em",
83
- ref,
84
- "aria-labelledby": titleId,
85
- ...props,
86
- children: [title ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("title", {
87
- id: titleId,
88
- children: title
89
- }) : null, /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", {
90
- fill: "none",
91
- stroke: "currentColor",
92
- strokeLinecap: "round",
93
- strokeLinejoin: "round",
94
- strokeWidth: 2,
95
- d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z"
96
- })]
97
- });
98
- var ForwardRef = (0, import_react.forwardRef)(lucidePlay);
99
- //#endregion
100
- //#region src/components/qgrid/voice-audio.ts
101
- var VOICE_SAMPLE_RATE = 24e3;
102
- /** Mono PCM16 WAV from float samples in [-1, 1]; out-of-range samples are clipped. */
103
- function encodeWav(samples, sampleRate = VOICE_SAMPLE_RATE) {
104
- const out = new Uint8Array(44 + samples.length * 2);
105
- const view = new DataView(out.buffer);
106
- const ascii = (offset, text) => {
107
- for (let i = 0; i < text.length; i++) view.setUint8(offset + i, text.charCodeAt(i));
108
- };
109
- ascii(0, "RIFF");
110
- view.setUint32(4, 36 + samples.length * 2, true);
111
- ascii(8, "WAVE");
112
- ascii(12, "fmt ");
113
- view.setUint32(16, 16, true);
114
- view.setUint16(20, 1, true);
115
- view.setUint16(22, 1, true);
116
- view.setUint32(24, sampleRate, true);
117
- view.setUint32(28, sampleRate * 2, true);
118
- view.setUint16(32, 2, true);
119
- view.setUint16(34, 16, true);
120
- ascii(36, "data");
121
- view.setUint32(40, samples.length * 2, true);
122
- samples.forEach((sample, i) => {
123
- const clipped = Math.max(-1, Math.min(1, sample));
124
- view.setInt16(44 + i * 2, clipped < 0 ? clipped * 32768 : clipped * 32767, true);
125
- });
126
- return out;
127
- }
128
- function bytesToBase64(bytes) {
129
- let binary = "";
130
- for (let i = 0; i < bytes.length; i += 32768) binary += String.fromCharCode(...bytes.subarray(i, i + 32768));
131
- return btoa(binary);
132
- }
133
- /** Decodes any browser-playable audio, mixes it to mono at 24 kHz, and returns base64 WAV. */
134
- async function audioToWavBase64(blob) {
135
- const context = new AudioContext({ sampleRate: VOICE_SAMPLE_RATE });
136
- try {
137
- const buffer = await context.decodeAudioData(await blob.arrayBuffer());
138
- const mono = new Float32Array(buffer.length);
139
- for (let channel = 0; channel < buffer.numberOfChannels; channel++) {
140
- const data = buffer.getChannelData(channel);
141
- for (let i = 0; i < data.length; i++) mono[i] += data[i] / buffer.numberOfChannels;
142
- }
143
- return bytesToBase64(encodeWav(mono));
144
- } finally {
145
- await context.close();
146
- }
147
- }
148
- //#endregion
149
- //#region src/components/qgrid/VoicePlayground.tsx
150
- var PROJECT_NAME = "qgrid_voice_playground";
151
- var TTS_MODELS = [
152
- "grok/grok-tts",
153
- "openai/gpt-realtime-2.1-mini",
154
- "openai/gpt-realtime-2.1"
155
- ];
156
- var STT_MODELS = [
157
- "openai/gpt-4o-transcribe",
158
- "openai/gpt-4o-mini-transcribe",
159
- "grok/grok-voice-transcribe-2.0"
160
- ];
161
- var OPENAI_VOICES = "marin cedar alloy ash ballad coral echo sage shimmer verse".split(" ");
162
- var GROK_VOICE_GROUPS = [{
163
- label: "Female",
164
- voices: "ara aurora carina celeste eve iris liora luna ursa".split(" ")
165
- }, {
166
- label: "Male",
167
- voices: "altair atlas castor cosmo helios helix kepler leo lumen lux naksh orion perseus rex rigel sal sirius zagan zenith".split(" ")
168
- }];
169
- var OPENAI_VOICE_GROUPS = [{
170
- label: "",
171
- voices: OPENAI_VOICES
172
- }];
173
- var TIMING_SOURCE = {
174
- provider: "timing from Grok TTS",
175
- aligned: "timing from qgrid aligner"
176
- };
177
- var isOpenAI = (model) => model.startsWith("openai/");
178
- var FIELD = "w-full rounded-lg border border-sand-200/80 bg-white px-2.5 py-1.5 text-[12px] text-sand-800 placeholder:text-sand-400 focus:outline-none focus:border-sienna-300 disabled:opacity-50";
179
- var CONTROL = `${FIELD} h-8`;
180
- var BUTTON = "px-3.5 py-1.5 text-[12px] font-medium rounded-lg bg-sienna-500 text-white hover:bg-sienna-600 disabled:opacity-50 transition-all duration-150 active:scale-[0.97] inline-flex items-center gap-1.5 shadow-sm";
181
- function Field({ label, children }) {
182
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
183
- className: "flex flex-col gap-1",
184
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
185
- className: "text-[11px] font-medium text-sand-500",
186
- children: label
187
- }), children]
188
- });
189
- }
190
- var shortModel = (model) => model.slice(model.indexOf("/") + 1);
191
- /**
192
- * One past result. The request-log link opens a new tab so leaving the playground does not drop
193
- * the in-memory history.
194
- */
195
- function HistoryRow({ title, meta, requestLogId, onRemove, children }) {
196
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
197
- className: "flex flex-col gap-1.5 px-4 py-3",
198
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
199
- className: "flex items-center gap-2 text-[12px]",
200
- children: [
201
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
202
- className: "font-medium text-sand-800",
203
- children: title
204
- }),
205
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
206
- className: "tabular-nums text-sand-400",
207
- children: meta
208
- }),
209
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
210
- className: "ml-auto flex items-center gap-2",
211
- children: [requestLogId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
212
- to: "/requests/show",
213
- search: { id: requestLogId },
214
- target: "_blank",
215
- className: "inline-flex items-center gap-1 tabular-nums text-sand-500 hover:text-sienna-500",
216
- children: [
217
- "request log #",
218
- requestLogId,
219
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$3, { className: "size-3" })
220
- ]
221
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
222
- type: "button",
223
- onClick: onRemove,
224
- title: "Remove from history",
225
- className: "text-sand-300 hover:text-sand-600",
226
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$4, { className: "size-3.5" })
227
- })]
228
- })
229
- ]
230
- }), children]
231
- });
232
- }
233
- function History({ empty, children }) {
234
- return children.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
235
- className: "px-4 py-6 text-center text-[12px] text-sand-400",
236
- children: empty
237
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
238
- className: "divide-y divide-sand-100",
239
- children
240
- });
241
- }
242
- /** Words from per-character timing (Grok TTS shape): each run of non-space characters is a word. */
243
- function wordsFromCharTimes(timestamps) {
244
- if (!timestamps) return void 0;
245
- const words = [];
246
- let current;
247
- timestamps.graphChars.forEach((char, i) => {
248
- const [start, end] = timestamps.graphTimes[i];
249
- if (/\s/.test(char)) {
250
- current = void 0;
251
- return;
252
- }
253
- if (current) {
254
- current.text += char;
255
- current.end = end;
256
- } else {
257
- current = {
258
- text: char,
259
- start,
260
- end
261
- };
262
- words.push(current);
263
- }
264
- });
265
- return words;
266
- }
267
- function TtsPanel() {
268
- const [model, setModel] = (0, import_react.useState)(TTS_MODELS[0]);
269
- const [voice, setVoice] = (0, import_react.useState)("ara");
270
- const [instructions, setInstructions] = (0, import_react.useState)("");
271
- const [text, setText] = (0, import_react.useState)("Hi! What did you do this weekend?");
272
- const [history, setHistory] = (0, import_react.useState)([]);
273
- const [withTimestamps, setWithTimestamps] = (0, import_react.useState)(true);
274
- const [speed, setSpeed] = (0, import_react.useState)(1);
275
- const nextKey = (0, import_react.useRef)(0);
276
- const speak = QgridService.useSpeakMutation();
277
- const openai = isOpenAI(model);
278
- const changeModel = (next) => {
279
- if (isOpenAI(next) !== openai) setVoice(isOpenAI(next) ? OPENAI_VOICES[0] : "ara");
280
- setModel(next);
281
- };
282
- const style = openai && instructions.trim() ? instructions.trim() : void 0;
283
- const generate = (voiceId) => {
284
- const startedAt = performance.now();
285
- const params = {
286
- model,
287
- text,
288
- voice: voiceId,
289
- projectName: PROJECT_NAME
290
- };
291
- if (style) params.instructions = style;
292
- if (withTimestamps) params.withTimestamps = true;
293
- if (!openai && speed !== 1) params.speed = speed;
294
- speak.mutate({ params }, { onSuccess: (out) => {
295
- const item = {
296
- key: nextKey.current++,
297
- src: `data:${out.mimeType};base64,${out.audio}`,
298
- model,
299
- voice: voiceId,
300
- instructions: params.instructions,
301
- speed: params.speed,
302
- text,
303
- elapsedMs: performance.now() - startedAt,
304
- requestLogId: out.requestLogId,
305
- words: wordsFromCharTimes(out.audioTimestamps),
306
- timing: out.timestampsError ? `timing failed: ${out.timestampsError}` : out.timestampsSource && TIMING_SOURCE[out.timestampsSource]
307
- };
308
- setHistory((items) => [item, ...items]);
309
- } });
310
- };
311
- const sampleRef = (0, import_react.useRef)(null);
312
- const [playing, setPlaying] = (0, import_react.useState)();
313
- (0, import_react.useEffect)(() => () => sampleRef.current?.pause(), []);
314
- const playSample = (voiceId) => {
315
- setVoice(voiceId);
316
- sampleRef.current?.pause();
317
- if (playing === voiceId) {
318
- setPlaying(void 0);
319
- return;
320
- }
321
- const audio = new Audio(`/voice-samples/${openai ? "openai" : "grok"}/${voiceId}.mp3`);
322
- audio.addEventListener("ended", () => setPlaying((current) => current === voiceId ? void 0 : current), { once: true });
323
- sampleRef.current = audio;
324
- setPlaying(voiceId);
325
- audio.play();
326
- };
327
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
328
- className: "flex flex-col gap-3 p-4",
329
- children: [
330
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
331
- className: "grid grid-cols-2 gap-2",
332
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
333
- label: "Model",
334
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
335
- value: model,
336
- onChange: (e) => changeModel(e.target.value),
337
- className: CONTROL,
338
- children: TTS_MODELS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
339
- value: m,
340
- children: m
341
- }, m))
342
- })
343
- }), openai ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
344
- label: "Style instructions (OpenAI only)",
345
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
346
- value: instructions,
347
- onChange: (e) => setInstructions(e.target.value),
348
- placeholder: "e.g. Speak with a gentle Irish accent.",
349
- className: CONTROL
350
- })
351
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
352
- label: `Speed (Grok only) — ${speed.toFixed(2)}×`,
353
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
354
- type: "range",
355
- min: .7,
356
- max: 1.5,
357
- step: .05,
358
- value: speed,
359
- onChange: (e) => setSpeed(Number(e.target.value)),
360
- className: "h-8 accent-sienna-500"
361
- })
362
- })]
363
- }),
364
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
365
- className: "flex flex-col gap-1.5",
366
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
367
- className: "text-[11px] font-medium text-sand-500",
368
- children: "Voice — ▶ plays a short self-introduction sample, a name selects it"
369
- }), (openai ? OPENAI_VOICE_GROUPS : GROK_VOICE_GROUPS).map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
370
- className: "flex items-start gap-2",
371
- children: [group.label && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
372
- className: "w-12 shrink-0 pt-1 text-[11px] text-sand-400",
373
- children: group.label
374
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
375
- className: "flex flex-wrap gap-1.5",
376
- children: group.voices.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
377
- className: `inline-flex items-center overflow-hidden rounded-full border text-[12px] ${voice === v ? "border-sienna-400 bg-sienna-50 text-sienna-700" : "border-sand-200/80 bg-white text-sand-700"}`,
378
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
379
- type: "button",
380
- onClick: () => setVoice(v),
381
- "aria-pressed": voice === v,
382
- className: "py-0.5 pl-2.5 pr-1 hover:text-sienna-600",
383
- children: v
384
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
385
- type: "button",
386
- onClick: () => playSample(v),
387
- title: playing === v ? `Stop "${v}"` : `Play a "${v}" sample`,
388
- className: `py-1 pl-1 pr-2 hover:text-sienna-500 ${playing === v ? "text-sienna-500" : "text-sand-400"}`,
389
- children: playing === v ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$5, { className: "size-3" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef, { className: "size-3" })
390
- })]
391
- }, v))
392
- })]
393
- }, group.label))]
394
- }),
395
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
396
- label: "Text",
397
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
398
- value: text,
399
- onChange: (e) => setText(e.target.value),
400
- rows: 3,
401
- className: `${FIELD} resize-y`
402
- })
403
- }),
404
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
405
- className: "flex items-center gap-3",
406
- children: [
407
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
408
- type: "button",
409
- onClick: () => generate(voice),
410
- disabled: speak.isPending || !text.trim(),
411
- className: BUTTON,
412
- children: [
413
- speak.isPending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$2, { className: "size-3.5 animate-spin" }),
414
- "Generate with ",
415
- voice
416
- ]
417
- }),
418
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
419
- className: "flex items-center gap-1.5 text-[12px] text-sand-600",
420
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
421
- type: "checkbox",
422
- checked: withTimestamps,
423
- onChange: (e) => setWithTimestamps(e.target.checked),
424
- className: "accent-sienna-500"
425
- }), "Word timing"]
426
- }),
427
- speak.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
428
- className: "text-[12px] text-danger-500 break-words",
429
- children: speak.error?.message
430
- })
431
- ]
432
- })
433
- ]
434
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
435
- className: "border-t border-sand-100",
436
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
437
- empty: "Generated clips stack here, newest first, so voices can be compared side by side.",
438
- children: history.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(HistoryRow, {
439
- title: [
440
- item.voice,
441
- shortModel(item.model),
442
- item.speed && `${item.speed}×`
443
- ].filter(Boolean).join(" · "),
444
- meta: [`${(item.elapsedMs / 1e3).toFixed(1)}s`, item.timing].filter(Boolean).join(" · "),
445
- requestLogId: item.requestLogId,
446
- onRemove: () => setHistory((items) => items.filter((i) => i.key !== item.key)),
447
- children: [(!item.words || item.instructions) && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
448
- className: "truncate text-[12px] text-sand-600",
449
- title: item.text,
450
- children: [!item.words && item.text, item.instructions && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
451
- className: "text-sand-400",
452
- children: [" — ", item.instructions]
453
- })]
454
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimedPlayer, {
455
- src: item.src,
456
- words: item.words,
457
- autoPlay: true
458
- })]
459
- }, item.key))
460
- })
461
- })] });
462
- }
463
- function SttPanel() {
464
- const [model, setModel] = (0, import_react.useState)(STT_MODELS[0]);
465
- const [prompt, setPrompt] = (0, import_react.useState)("");
466
- const [audio, setAudio] = (0, import_react.useState)();
467
- const [recording, setRecording] = (0, import_react.useState)(false);
468
- const [audioError, setAudioError] = (0, import_react.useState)();
469
- const [history, setHistory] = (0, import_react.useState)([]);
470
- const recorderRef = (0, import_react.useRef)(null);
471
- const clipUrls = (0, import_react.useRef)([]);
472
- const nextKey = (0, import_react.useRef)(0);
473
- const transcribe = QgridService.useTranscribeMutation();
474
- const openai = isOpenAI(model);
475
- (0, import_react.useEffect)(() => () => {
476
- recorderRef.current?.stream.getTracks().forEach((track) => track.stop());
477
- clipUrls.current.forEach((url) => URL.revokeObjectURL(url));
478
- }, []);
479
- const takeAudio = (blob) => {
480
- const url = URL.createObjectURL(blob);
481
- clipUrls.current.push(url);
482
- setAudio({
483
- blob,
484
- url,
485
- clip: clipUrls.current.length
486
- });
487
- };
488
- const toggleRecording = async () => {
489
- if (recording) {
490
- recorderRef.current?.stop();
491
- setRecording(false);
492
- return;
493
- }
494
- setAudioError(void 0);
495
- try {
496
- const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
497
- const recorder = new MediaRecorder(stream);
498
- const chunks = [];
499
- recorder.ondataavailable = (e) => chunks.push(e.data);
500
- recorder.onstop = () => {
501
- stream.getTracks().forEach((track) => track.stop());
502
- takeAudio(new Blob(chunks, { type: recorder.mimeType }));
503
- };
504
- recorder.start();
505
- recorderRef.current = recorder;
506
- setRecording(true);
507
- } catch (error) {
508
- setAudioError(error instanceof Error ? error.message : String(error));
509
- }
510
- };
511
- const submit = async () => {
512
- if (!audio) return;
513
- setAudioError(void 0);
514
- const originalType = audio.blob.type.split(";")[0];
515
- let clip;
516
- try {
517
- clip = !openai && originalType.startsWith("audio/") ? {
518
- audio: bytesToBase64(new Uint8Array(await audio.blob.arrayBuffer())),
519
- mediaType: originalType
520
- } : {
521
- audio: await audioToWavBase64(audio.blob),
522
- mediaType: "audio/wav"
523
- };
524
- } catch (error) {
525
- setAudioError(`could not decode audio: ${error instanceof Error ? error.message : String(error)}`);
526
- return;
527
- }
528
- const params = {
529
- model,
530
- ...clip,
531
- projectName: PROJECT_NAME
532
- };
533
- if (openai && prompt.trim()) params.prompt = prompt.trim();
534
- const startedAt = performance.now();
535
- transcribe.mutate({ params }, { onSuccess: (out) => {
536
- const item = {
537
- key: nextKey.current++,
538
- clip: audio.clip,
539
- clipUrl: audio.url,
540
- model,
541
- prompt: params.prompt,
542
- text: out.text,
543
- elapsedMs: performance.now() - startedAt,
544
- durationSec: out.durationSec,
545
- requestLogId: out.requestLogId,
546
- words: out.words
547
- };
548
- setHistory((items) => [item, ...items]);
549
- } });
550
- };
551
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
552
- className: "flex flex-col gap-3 p-4",
553
- children: [
554
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
555
- className: "grid grid-cols-2 gap-2",
556
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
557
- label: "Model",
558
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
559
- value: model,
560
- onChange: (e) => setModel(e.target.value),
561
- className: CONTROL,
562
- children: STT_MODELS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
563
- value: m,
564
- children: m
565
- }, m))
566
- })
567
- }), openai && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
568
- label: "Prompt (OpenAI only)",
569
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
570
- value: prompt,
571
- onChange: (e) => setPrompt(e.target.value),
572
- placeholder: "domain words, e.g. qgrid, Kuma",
573
- className: CONTROL
574
- })
575
- })]
576
- }),
577
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
578
- className: "flex flex-wrap items-center gap-2",
579
- children: [
580
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
581
- type: "button",
582
- onClick: toggleRecording,
583
- className: `${BUTTON} ${recording ? "bg-danger-500 hover:bg-danger-500" : ""}`,
584
- children: [recording ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$5, { className: "size-3.5" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3.5" }), recording ? "Stop" : "Record"]
585
- }),
586
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
587
- className: "text-[12px] text-sand-600 cursor-pointer hover:text-sienna-500",
588
- children: ["or upload a file", /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
589
- type: "file",
590
- accept: "audio/*",
591
- className: "hidden",
592
- onChange: (e) => {
593
- const file = e.target.files?.[0];
594
- if (file) takeAudio(file);
595
- }
596
- })]
597
- }),
598
- audioError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
599
- className: "text-[12px] text-danger-500 break-words",
600
- children: audioError
601
- })
602
- ]
603
- }),
604
- audio && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
605
- className: "flex items-center gap-2",
606
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
607
- className: "shrink-0 text-[11px] font-medium text-sand-500",
608
- children: ["clip ", audio.clip]
609
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("audio", {
610
- controls: true,
611
- src: audio.url,
612
- className: "h-8 w-full"
613
- })]
614
- }),
615
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
616
- className: "flex items-center gap-3",
617
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
618
- type: "button",
619
- onClick: submit,
620
- disabled: !audio || recording || transcribe.isPending,
621
- className: BUTTON,
622
- children: [transcribe.isPending && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$2, { className: "size-3.5 animate-spin" }), "Transcribe"]
623
- }), transcribe.isError && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
624
- className: "text-[12px] text-danger-500 break-words",
625
- children: transcribe.error?.message
626
- })]
627
- })
628
- ]
629
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
630
- className: "border-t border-sand-100",
631
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(History, {
632
- empty: "Transcripts stack here, newest first; run one clip through several models to compare.",
633
- children: history.map((item) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(HistoryRow, {
634
- title: `clip ${item.clip} · ${shortModel(item.model)}`,
635
- meta: [
636
- `${(item.elapsedMs / 1e3).toFixed(1)}s`,
637
- item.durationSec !== void 0 ? `${item.durationSec.toFixed(1)}s audio` : "",
638
- item.prompt ? `prompt: ${item.prompt}` : ""
639
- ].filter(Boolean).join(" · "),
640
- requestLogId: item.requestLogId,
641
- onRemove: () => setHistory((items) => items.filter((i) => i.key !== item.key)),
642
- children: item.words && item.words.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TimedPlayer, {
643
- src: item.clipUrl,
644
- words: item.words
645
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
646
- className: "rounded-lg bg-sand-50 px-3 py-2 text-[13px] text-sand-800 whitespace-pre-wrap",
647
- children: item.text || "(empty transcript)"
648
- })
649
- }, item.key))
650
- })
651
- })] });
652
- }
653
- var LIVE_VOICES = "cove juniper maple spruce ember vale breeze arbor sol aube bubbie haetsal hanul himari leher miko neer porto rindo rio rivage selva sonna tinta viola".split(" ");
654
- var DEFAULT_DELEGATION_MODEL = "openai/gpt-6-luna";
655
- var LiveEvent = looseObject({
656
- type: string(),
657
- turn: looseObject({
658
- id: string(),
659
- role: string(),
660
- transcript: string()
661
- }).optional(),
662
- turn_id: string().optional(),
663
- delta: string().optional()
664
- });
665
- var clock = (sec) => `${Math.floor(sec / 60)}:${String(sec % 60).padStart(2, "0")}`;
666
- /** Ends the session at once; a peer that only disconnects keeps it (and its billed time) ~30 s. */
667
- function endLiveSession({ pc, channel, mic }) {
668
- if (channel.readyState === "open") channel.send(JSON.stringify({ type: "session.close" }));
669
- mic.getTracks().forEach((track) => track.stop());
670
- setTimeout(() => pc.close(), 500);
671
- }
672
- /**
673
- * A GPT-Live conversation. The browser's own WebRTC peer talks to OpenAI; qgrid only exchanges the
674
- * SDP offer with the subscription token and logs the transcript when the session ends.
675
- */
676
- function LivePanel() {
677
- const [voice, setVoice] = (0, import_react.useState)(LIVE_VOICES[0]);
678
- const [instructions, setInstructions] = (0, import_react.useState)("");
679
- const [delegateModel, setDelegateModel] = (0, import_react.useState)(DEFAULT_DELEGATION_MODEL);
680
- const [effort, setEffort] = (0, import_react.useState)("low");
681
- const [webSearch, setWebSearch] = (0, import_react.useState)(false);
682
- const [logged, setLogged] = (0, import_react.useState)(true);
683
- const searchable = !delegateModel.startsWith("anthropic/");
684
- const [status, setStatus] = (0, import_react.useState)("idle");
685
- const [error, setError] = (0, import_react.useState)();
686
- const [turns, setTurns] = (0, import_react.useState)([]);
687
- const [requestLogId, setRequestLogId] = (0, import_react.useState)();
688
- const [elapsedSec, setElapsedSec] = (0, import_react.useState)(0);
689
- const session = (0, import_react.useRef)(null);
690
- const audioRef = (0, import_react.useRef)(null);
691
- const liveCall = QgridService.useLiveCallMutation();
692
- (0, import_react.useEffect)(() => () => {
693
- if (session.current) endLiveSession(session.current);
694
- }, []);
695
- (0, import_react.useEffect)(() => {
696
- if (status !== "live") return;
697
- const startedAt = Date.now();
698
- const timer = setInterval(() => setElapsedSec(Math.floor((Date.now() - startedAt) / 1e3)), 1e3);
699
- return () => clearInterval(timer);
700
- }, [status]);
701
- const stop = () => {
702
- if (session.current) endLiveSession(session.current);
703
- session.current = null;
704
- setStatus("idle");
705
- };
706
- const onEvent = (raw) => {
707
- let json;
708
- try {
709
- json = LiveEvent.safeParse(JSON.parse(raw)).data;
710
- } catch {
711
- return;
712
- }
713
- if (!json) return;
714
- const { type, turn, turn_id: turnId, delta } = json;
715
- if (type === "session.closed") {
716
- stop();
717
- return;
718
- }
719
- if (turn && (type === "turn.created" || type === "turn.done")) {
720
- const next = {
721
- id: turn.id,
722
- role: turn.role,
723
- text: turn.transcript
724
- };
725
- setTurns((items) => items.some((item) => item.id === turn.id) ? items.map((item) => item.id === turn.id ? next : item) : [...items, next]);
726
- } else if (type === "turn.delta" && turnId && delta) setTurns((items) => items.map((item) => item.id === turnId ? {
727
- ...item,
728
- text: item.text + delta
729
- } : item));
730
- };
731
- const start = async () => {
732
- setError(void 0);
733
- setTurns([]);
734
- setRequestLogId(void 0);
735
- setElapsedSec(0);
736
- setStatus("connecting");
737
- let mic;
738
- let pc;
739
- try {
740
- mic = await navigator.mediaDevices.getUserMedia({ audio: true });
741
- const peer = new RTCPeerConnection();
742
- pc = peer;
743
- mic.getTracks().forEach((track) => peer.addTrack(track));
744
- peer.addEventListener("track", (event) => {
745
- if (audioRef.current) audioRef.current.srcObject = new MediaStream([event.track]);
746
- });
747
- const channel = peer.createDataChannel("oai-events");
748
- channel.addEventListener("message", (event) => onEvent(String(event.data)));
749
- const offer = await peer.createOffer();
750
- await peer.setLocalDescription(offer);
751
- const params = {
752
- sdp: offer.sdp ?? "",
753
- voice,
754
- delegation: {
755
- model: delegateModel,
756
- effort,
757
- webSearch: searchable && webSearch
758
- },
759
- projectName: PROJECT_NAME
760
- };
761
- if (instructions.trim()) params.instructions = instructions.trim();
762
- if (!logged) params.logger = false;
763
- const out = await liveCall.mutateAsync({ params });
764
- await peer.setRemoteDescription({
765
- type: "answer",
766
- sdp: out.sdp
767
- });
768
- session.current = {
769
- pc: peer,
770
- channel,
771
- mic
772
- };
773
- setRequestLogId(out.requestLogId);
774
- setStatus("live");
775
- } catch (e) {
776
- mic?.getTracks().forEach((track) => track.stop());
777
- pc?.close();
778
- setError(e instanceof Error ? e.message : String(e));
779
- setStatus("idle");
780
- }
781
- };
782
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
783
- className: "flex flex-col gap-3 p-4",
784
- children: [
785
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
786
- className: "grid grid-cols-2 gap-2",
787
- children: [
788
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
789
- label: "Voice",
790
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
791
- value: voice,
792
- onChange: (e) => setVoice(e.target.value),
793
- disabled: status !== "idle",
794
- className: CONTROL,
795
- children: LIVE_VOICES.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
796
- value: v,
797
- children: v
798
- }, v))
799
- })
800
- }),
801
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
802
- label: "Instructions",
803
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
804
- value: instructions,
805
- onChange: (e) => setInstructions(e.target.value),
806
- disabled: status !== "idle",
807
- placeholder: "e.g. You are a friendly English tutor. Keep answers short.",
808
- className: CONTROL
809
- })
810
- }),
811
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
812
- label: "Delegation model (answers lookups and reasoning)",
813
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
814
- value: delegateModel,
815
- onChange: (e) => setDelegateModel(e.target.value),
816
- disabled: status !== "idle",
817
- className: CONTROL,
818
- children: QGRID_MODEL_GROUPS.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("optgroup", {
819
- label: group.label,
820
- children: group.models.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
821
- value: m,
822
- children: m
823
- }, m))
824
- }, group.label))
825
- })
826
- }),
827
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
828
- className: "flex items-end gap-3",
829
- children: [
830
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
831
- label: "Effort",
832
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
833
- value: effort,
834
- onChange: (e) => setEffort(Effort.options.find((v) => v === e.target.value) ?? "low"),
835
- disabled: status !== "idle",
836
- className: CONTROL,
837
- children: Effort.options.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
838
- value: v,
839
- children: v
840
- }, v))
841
- })
842
- }),
843
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
844
- className: "flex h-8 items-center gap-1.5 text-[12px] text-sand-600",
845
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
846
- type: "checkbox",
847
- checked: searchable && webSearch,
848
- onChange: (e) => setWebSearch(e.target.checked),
849
- disabled: status !== "idle" || !searchable,
850
- className: "accent-sienna-500"
851
- }), "Web search"]
852
- }),
853
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
854
- className: "flex h-8 items-center gap-1.5 text-[12px] text-sand-600",
855
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
856
- type: "checkbox",
857
- checked: logged,
858
- onChange: (e) => setLogged(e.target.checked),
859
- disabled: status !== "idle",
860
- className: "accent-sienna-500"
861
- }), "Request log"]
862
- })
863
- ]
864
- })
865
- ]
866
- }),
867
- /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
868
- className: "flex flex-wrap items-center gap-3",
869
- children: [
870
- status === "idle" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
871
- type: "button",
872
- onClick: start,
873
- className: BUTTON,
874
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3.5" }), "Start conversation"]
875
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
876
- type: "button",
877
- onClick: stop,
878
- disabled: status === "connecting",
879
- className: `${BUTTON} bg-danger-500 hover:bg-danger-500`,
880
- children: [status === "connecting" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$2, { className: "size-3.5 animate-spin" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$5, { className: "size-3.5" }), status === "connecting" ? "Connecting" : "End"]
881
- }),
882
- status === "live" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
883
- className: "tabular-nums text-[12px] text-sand-500",
884
- children: [clock(elapsedSec), " · openai/gpt-live-1 · speak any time (ends by itself after 2 h)"]
885
- }),
886
- requestLogId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
887
- to: "/requests/show",
888
- search: { id: requestLogId },
889
- target: "_blank",
890
- className: "inline-flex items-center gap-1 text-[12px] tabular-nums text-sand-500 hover:text-sienna-500",
891
- children: [
892
- "request log #",
893
- requestLogId,
894
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$3, { className: "size-3" })
895
- ]
896
- }),
897
- error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
898
- className: "text-[12px] text-danger-500 break-words",
899
- children: error
900
- })
901
- ]
902
- }),
903
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("audio", {
904
- ref: audioRef,
905
- autoPlay: true
906
- }),
907
- turns.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
908
- className: "py-6 text-center text-[12px] text-sand-400",
909
- children: "Start a conversation and talk; both sides of the transcript appear here."
910
- }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ul", {
911
- className: "flex flex-col gap-1.5",
912
- children: turns.map((turn) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
913
- className: `rounded-lg px-3 py-2 text-[13px] text-sand-800 ${turn.role === "assistant" ? "bg-sage-50" : "bg-sand-50"}`,
914
- children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
915
- className: "mr-2 text-[10px] font-medium uppercase tracking-wider text-sand-500",
916
- children: turn.role
917
- }), turn.text.trim()]
918
- }, turn.id))
919
- })
920
- ]
921
- });
922
- }
923
- function VoicePlayground({ tab }) {
924
- return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
925
- className: "rounded-xl border border-sand-200/70 bg-white overflow-hidden",
926
- children: [
927
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
928
- role: "tablist",
929
- className: "flex gap-1 border-b border-sand-100 px-3 pt-2 md:hidden",
930
- children: VOICE_TAB_IDS.map((id) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
931
- to: "/voice",
932
- search: { tab: id },
933
- role: "tab",
934
- "aria-selected": tab === id,
935
- className: `-mb-px border-b-2 px-3 py-2 text-[13px] no-underline transition-colors duration-150 ${tab === id ? "border-sienna-500 font-medium text-sand-800" : "border-transparent text-sand-500 hover:text-sand-700"}`,
936
- children: VOICE_TAB_TITLES[id]
937
- }, id))
938
- }),
939
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
940
- role: "tabpanel",
941
- hidden: tab !== "tts",
942
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TtsPanel, {})
943
- }),
944
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
945
- role: "tabpanel",
946
- hidden: tab !== "stt",
947
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SttPanel, {})
948
- }),
949
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
950
- role: "tabpanel",
951
- hidden: tab !== "live",
952
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LivePanel, {})
953
- })
954
- ]
955
- });
956
- }
957
- //#endregion
958
- //#region src/routes/voice.tsx?tsr-split=component
959
- function VoicePage() {
960
- const { tab = "tts" } = Route.useSearch();
961
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
962
- className: "max-w-3xl mx-auto",
963
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePlayground, { tab })
964
- });
965
- }
966
- //#endregion
967
- export { VoicePage as component };