@cartanova/qgrid-cli 2.19.1 → 2.19.3

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 (71) hide show
  1. package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +5 -2
  2. package/bundle/dist/application/qgrid/qgrid.dispatcher.js +3 -1
  3. package/bundle/dist/application/qgrid/qgrid.frame.js +225 -6
  4. package/bundle/dist/application/qgrid/qgrid.types.js +74 -2
  5. package/bundle/dist/application/request-log/request-log.model.js +11 -1
  6. package/bundle/dist/application/sonamu.generated.js +5 -3
  7. package/bundle/dist/i18n/sd.generated.js +3 -2
  8. package/bundle/dist/utils/providers/common/model-cost.js +8 -2
  9. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +18 -1
  10. package/bundle/dist/utils/providers/openai/openai-realtime-protocol.js +120 -2
  11. package/bundle/dist/utils/providers/openai/openai-voice-client.js +184 -6
  12. package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +13 -0
  13. package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +11 -1
  14. package/bundle/src/application/qgrid/qgrid.dispatcher.test.ts +17 -0
  15. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +8 -0
  16. package/bundle/src/application/qgrid/qgrid.frame.test.ts +223 -0
  17. package/bundle/src/application/qgrid/qgrid.frame.ts +304 -3
  18. package/bundle/src/application/qgrid/qgrid.types.ts +121 -0
  19. package/bundle/src/application/request-log/request-log.entity.json +3 -2
  20. package/bundle/src/application/request-log/request-log.model.test.ts +19 -0
  21. package/bundle/src/application/request-log/request-log.model.ts +20 -1
  22. package/bundle/src/application/sonamu.generated.http +28 -0
  23. package/bundle/src/application/sonamu.generated.ts +2 -1
  24. package/bundle/src/i18n/sd.generated.ts +2 -1
  25. package/bundle/src/utils/providers/common/model-cost.ts +15 -0
  26. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +16 -0
  27. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +26 -0
  28. package/bundle/src/utils/providers/openai/openai-realtime-protocol.ts +160 -0
  29. package/bundle/src/utils/providers/openai/openai-voice-client.test.ts +205 -0
  30. package/bundle/src/utils/providers/openai/openai-voice-client.ts +284 -5
  31. package/bundle/web-dist/client/assets/index-B5yorZqv.js +104 -0
  32. package/bundle/web-dist/client/assets/index-CpOwNalw.css +1 -0
  33. package/bundle/web-dist/client/assets/logs-Bx_jXEDZ.js +1 -0
  34. package/bundle/web-dist/client/assets/monit-CPQ18s_m.js +1 -0
  35. package/bundle/web-dist/client/assets/{routes--6kS1pgJ.js → routes-S4D5Ld4L.js} +2 -2
  36. package/bundle/web-dist/client/assets/{settings-Dah87LB2.js → settings-M4h_UV87.js} +1 -1
  37. package/bundle/web-dist/client/assets/show-BchF-T1a.js +2 -0
  38. package/bundle/web-dist/client/assets/{tokens-CIHja806.js → tokens-BgBD07ru.js} +1 -1
  39. package/bundle/web-dist/client/assets/{use-oauth-login-flow-DeJCqHDJ.js → use-oauth-login-flow-D_wI9MzM.js} +1 -1
  40. package/bundle/web-dist/client/assets/use-update-token-mutation-IvuH3Qje.js +1 -0
  41. package/bundle/web-dist/client/assets/{vendor-tanstack-6B86itGS.js → vendor-tanstack-DMgmqjm4.js} +1 -1
  42. package/bundle/web-dist/client/assets/voice-CnIiQMbo.js +1 -0
  43. package/bundle/web-dist/client/index.html +3 -3
  44. package/bundle/web-dist/server/assets/{TimedPlayer-DAwjkP4z.js → TimedPlayer-COqaTQSl.js} +1 -1
  45. package/bundle/web-dist/server/assets/{logs-BmBpBe-j.js → logs-HPho1SkC.js} +5 -6
  46. package/bundle/web-dist/server/assets/{monit-Db1WrIls.js → monit-Bl2kSkSF.js} +3 -3
  47. package/bundle/web-dist/server/assets/{plus-CW9y_K7l.js → plus-CQ8AHpih.js} +1 -1
  48. package/bundle/web-dist/server/assets/{refresh-cw-CRgcH5bT.js → refresh-cw-pYSuvt4c.js} +1 -1
  49. package/bundle/web-dist/server/assets/{request-model-DRF7hmJC.js → request-model-ZulJMbGm.js} +1 -1
  50. package/bundle/web-dist/server/assets/{routes-CARZj7or.js → routes-BNHCX4VI.js} +4 -4
  51. package/bundle/web-dist/server/assets/{services.generated-B6QpnL_N.js → services.generated-C3b31_vt.js} +23209 -22930
  52. package/bundle/web-dist/server/assets/{settings-B4jdpP5N.js → settings-NJUyaSrJ.js} +4 -4
  53. package/bundle/web-dist/server/assets/{show-CnLDFCtW.js → show-Dz5QGL7l.js} +8 -9
  54. package/bundle/web-dist/server/assets/{tokens-TDQguTdh.js → tokens-BPQvjIGq.js} +5 -5
  55. package/bundle/web-dist/server/assets/{use-oauth-login-flow-du7pOh_H.js → use-oauth-login-flow-CCc8LEmn.js} +1 -1
  56. package/bundle/web-dist/server/assets/{use-update-token-mutation-DA6HiiWS.js → use-update-token-mutation-Ba-sEhq1.js} +1 -1
  57. package/bundle/web-dist/server/assets/{voice-BvAl-vTr.js → voice-xFFT4zqK.js} +307 -22
  58. package/bundle/web-dist/server/entry-server.generated.js +5590 -71
  59. package/package.json +1 -1
  60. package/skills/qgrid/references/decision-rationale.md +4 -0
  61. package/skills/qgrid/references/openai-codex-runtime.md +16 -0
  62. package/skills/qgrid/references/request-log-run-lifecycle.md +2 -1
  63. package/skills/qgrid/references/sonamu-api-web-flow.md +2 -2
  64. package/bundle/web-dist/client/assets/index-Co8uAhSV.css +0 -1
  65. package/bundle/web-dist/client/assets/index-DvW4Yb82.js +0 -104
  66. package/bundle/web-dist/client/assets/logs-DAif2re1.js +0 -1
  67. package/bundle/web-dist/client/assets/monit-DYczkiu0.js +0 -1
  68. package/bundle/web-dist/client/assets/show-DQWFaVDW.js +0 -2
  69. package/bundle/web-dist/client/assets/use-update-token-mutation-Cn_Po_rH.js +0 -1
  70. package/bundle/web-dist/client/assets/voice-6i785ieC.js +0 -1
  71. package/bundle/web-dist/server/assets/link-DrdV092C.js +0 -4919
@@ -1,7 +1,7 @@
1
- import { J as require_react, K as useQueryClient, Q as __toESM, a as SettingService, o as TokenService, q as require_jsx_runtime } from "./services.generated-B6QpnL_N.js";
2
- import { s as ForwardRef$3 } from "../entry-server.generated.js";
3
- import { t as useUpdateTokenMutation } from "./use-update-token-mutation-DA6HiiWS.js";
4
- import { t as ForwardRef$4 } from "./plus-CW9y_K7l.js";
1
+ import { X as require_jsx_runtime, Y as useQueryClient, Z as require_react, a as SettingService, o as TokenService, tt as __toESM } from "./services.generated-C3b31_vt.js";
2
+ import { u as ForwardRef$3 } from "../entry-server.generated.js";
3
+ import { t as useUpdateTokenMutation } from "./use-update-token-mutation-Ba-sEhq1.js";
4
+ import { t as ForwardRef$4 } from "./plus-CQ8AHpih.js";
5
5
  //#region ~icons/lucide/eye.jsx
6
6
  var import_react = /* @__PURE__ */ __toESM(require_react());
7
7
  var import_jsx_runtime = require_jsx_runtime();
@@ -1,9 +1,8 @@
1
- import { C as number, E as union, J as require_react, Q as __toESM, S as looseObject, T as string, Y as __commonJSMin, b as json, h as array, i as RequestLogStepService, k as useQuery, l as isSonamuError, q as require_jsx_runtime, r as RequestLogService, w as object } from "./services.generated-B6QpnL_N.js";
2
- import { t as Link } from "./link-DrdV092C.js";
3
- import { a as ForwardRef$4, c as remarkGfm, l as Markdown, t as Route } from "../entry-server.generated.js";
1
+ import { C as looseObject, D as string, E as object, M as useQuery, Q as __commonJSMin, T as number, X as require_jsx_runtime, Z as require_react, h as array, i as RequestLogStepService, k as union, l as isSonamuError, r as RequestLogService, tt as __toESM, x as json } from "./services.generated-C3b31_vt.js";
2
+ import { _ as Link, c as ForwardRef$4, d as remarkGfm, f as Markdown, t as Route } from "../entry-server.generated.js";
4
3
  import { n as formatMicroUsd, t as cacheHitRate } from "./cost-oNK0T4Jo.js";
5
- import { n as ForwardRef$5, t as requestModelDisplay } from "./request-model-DRF7hmJC.js";
6
- import { t as TimedPlayer } from "./TimedPlayer-DAwjkP4z.js";
4
+ import { n as ForwardRef$5, t as requestModelDisplay } from "./request-model-ZulJMbGm.js";
5
+ import { t as TimedPlayer } from "./TimedPlayer-COqaTQSl.js";
7
6
  //#region ../../node_modules/.pnpm/@babel+runtime@7.29.2/node_modules/@babel/runtime/helpers/extends.js
8
7
  var require_extends = /* @__PURE__ */ __commonJSMin(((exports, module) => {
9
8
  function _extends() {
@@ -2276,7 +2275,7 @@ function MetricsPanel({ data, toolCallCount }) {
2276
2275
  value: formatTokensPerSec(data.output_tokens, data.duration_ms, data.ttft_ms, tokensPerSecEnabled)
2277
2276
  }),
2278
2277
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Metric, {
2279
- label: data.media_kind === "stt" || data.media_kind === "tts" ? "Voice" : "Driver",
2278
+ label: data.media_kind === "stt" || data.media_kind === "tts" || data.media_kind === "live" ? "Voice" : "Driver",
2280
2279
  value: data.cost_usd !== null ? formatMicroUsd(data.cost_usd) : "—"
2281
2280
  }),
2282
2281
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Metric, {
@@ -3032,7 +3031,7 @@ function RequestDetail({ id }) {
3032
3031
  const promptSections = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3033
3032
  className: "space-y-4",
3034
3033
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, {
3035
- title: data.media_kind === "tts" ? "Style instructions" : data.media_kind === "stt" ? "Prompt" : "System",
3034
+ title: data.media_kind === "tts" ? "Style instructions" : data.media_kind === "stt" ? "Prompt" : data.media_kind === "live" ? "Instructions" : "System",
3036
3035
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3037
3036
  className: "relative",
3038
3037
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyButton, { text: data.system_prompt ?? "null" }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FormattedContent, {
@@ -3040,7 +3039,7 @@ function RequestDetail({ id }) {
3040
3039
  markdown: true
3041
3040
  })]
3042
3041
  })
3043
- }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, {
3042
+ }), data.media_kind !== "live" && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, {
3044
3043
  title: "User",
3045
3044
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3046
3045
  className: "space-y-3",
@@ -3096,7 +3095,7 @@ function RequestDetail({ id }) {
3096
3095
  promptSections
3097
3096
  ] }),
3098
3097
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Section, {
3099
- title: "Response",
3098
+ title: data.media_kind === "live" ? "Conversation" : "Response",
3100
3099
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
3101
3100
  className: "relative",
3102
3101
  children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyButton, { text: data.response }), data.media_kind === "tts" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoiceAwareContent, {
@@ -1,8 +1,8 @@
1
- import { J as require_react, K as useQueryClient, Q as __toESM, n as QgridService, o as TokenService, q as require_jsx_runtime } from "./services.generated-B6QpnL_N.js";
2
- import { i as o, n as useOAuthLoginFlow, r as OAuthCodeEntry } from "./use-oauth-login-flow-du7pOh_H.js";
3
- import { u as ForwardRef$2 } from "../entry-server.generated.js";
4
- import { t as useUpdateTokenMutation } from "./use-update-token-mutation-DA6HiiWS.js";
5
- import { t as ForwardRef$3 } from "./plus-CW9y_K7l.js";
1
+ import { X as require_jsx_runtime, Y as useQueryClient, Z as require_react, n as QgridService, o as TokenService, tt as __toESM } from "./services.generated-C3b31_vt.js";
2
+ import { i as o, n as useOAuthLoginFlow, r as OAuthCodeEntry } from "./use-oauth-login-flow-CCc8LEmn.js";
3
+ import { h as ForwardRef$2 } from "../entry-server.generated.js";
4
+ import { t as useUpdateTokenMutation } from "./use-update-token-mutation-Ba-sEhq1.js";
5
+ import { t as ForwardRef$3 } from "./plus-CQ8AHpih.js";
6
6
  //#region src/components/qgrid/DeviceCodeEntry.tsx
7
7
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
8
8
  var import_jsx_runtime = require_jsx_runtime();
@@ -1,4 +1,4 @@
1
- import { J as require_react, K as useQueryClient, Q as __toESM, n as QgridService, o as TokenService, q as require_jsx_runtime } from "./services.generated-B6QpnL_N.js";
1
+ import { X as require_jsx_runtime, Y as useQueryClient, Z as require_react, n as QgridService, o as TokenService, tt as __toESM } from "./services.generated-C3b31_vt.js";
2
2
  import { t as clsx } from "./clsx-DgIEfj3H.js";
3
3
  //#region ../../node_modules/.pnpm/tailwind-merge@3.7.0/node_modules/tailwind-merge/dist/bundle-mjs.mjs
4
4
  var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
@@ -1,4 +1,4 @@
1
- import { O as useMutation, n as QgridService } from "./services.generated-B6QpnL_N.js";
1
+ import { j as useMutation, n as QgridService } from "./services.generated-C3b31_vt.js";
2
2
  //#region src/services/token/use-update-token-mutation.ts
3
3
  function useUpdateTokenMutation() {
4
4
  return useMutation({ mutationFn: ({ id, name, quotaThreshold, weight, keepaliveEnabled }) => QgridService.updateToken(id, name, quotaThreshold, weight, keepaliveEnabled) });
@@ -1,7 +1,6 @@
1
- import { J as require_react, Q as __toESM, n as QgridService, q as require_jsx_runtime } from "./services.generated-B6QpnL_N.js";
2
- import { t as Link } from "./link-DrdV092C.js";
3
- import { a as ForwardRef$4, o as ForwardRef$5 } from "../entry-server.generated.js";
4
- import { t as TimedPlayer } from "./TimedPlayer-DAwjkP4z.js";
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";
5
4
  //#region ~icons/lucide/external-link.jsx
6
5
  var import_react = /* @__PURE__ */ __toESM(require_react());
7
6
  var import_jsx_runtime = require_jsx_runtime();
@@ -651,29 +650,309 @@ function SttPanel() {
651
650
  })
652
651
  })] });
653
652
  }
654
- var TABS = [{
655
- id: "tts",
656
- label: "Text to speech"
657
- }, {
658
- id: "stt",
659
- label: "Speech to text"
660
- }];
661
- function VoicePlayground() {
662
- const [tab, setTab] = (0, import_react.useState)("tts");
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 [earlier, setEarlier] = (0, import_react.useState)([]);
684
+ const searchable = !delegateModel.startsWith("anthropic/");
685
+ const [status, setStatus] = (0, import_react.useState)("idle");
686
+ const [error, setError] = (0, import_react.useState)();
687
+ const [turns, setTurns] = (0, import_react.useState)([]);
688
+ const [requestLogId, setRequestLogId] = (0, import_react.useState)();
689
+ const [elapsedSec, setElapsedSec] = (0, import_react.useState)(0);
690
+ const session = (0, import_react.useRef)(null);
691
+ const audioRef = (0, import_react.useRef)(null);
692
+ const liveCall = QgridService.useLiveCallMutation();
693
+ (0, import_react.useEffect)(() => () => {
694
+ if (session.current) endLiveSession(session.current);
695
+ }, []);
696
+ (0, import_react.useEffect)(() => {
697
+ if (status !== "live") return;
698
+ const startedAt = Date.now();
699
+ const timer = setInterval(() => setElapsedSec(Math.floor((Date.now() - startedAt) / 1e3)), 1e3);
700
+ return () => clearInterval(timer);
701
+ }, [status]);
702
+ const stop = () => {
703
+ if (session.current) endLiveSession(session.current);
704
+ session.current = null;
705
+ setStatus("idle");
706
+ };
707
+ const onEvent = (raw) => {
708
+ let json;
709
+ try {
710
+ json = LiveEvent.safeParse(JSON.parse(raw)).data;
711
+ } catch {
712
+ return;
713
+ }
714
+ if (!json) return;
715
+ const { type, turn, turn_id: turnId, delta } = json;
716
+ if (type === "session.closed") {
717
+ stop();
718
+ return;
719
+ }
720
+ if (turn && (type === "turn.created" || type === "turn.done")) {
721
+ const next = {
722
+ id: turn.id,
723
+ role: turn.role,
724
+ text: turn.transcript
725
+ };
726
+ setTurns((items) => items.some((item) => item.id === turn.id) ? items.map((item) => item.id === turn.id ? next : item) : [...items, next]);
727
+ } else if (type === "turn.delta" && turnId && delta) setTurns((items) => items.map((item) => item.id === turnId ? {
728
+ ...item,
729
+ text: item.text + delta
730
+ } : item));
731
+ };
732
+ const start = async (continueConversation) => {
733
+ const history = continueConversation ? [...earlier, ...turns.flatMap((turn) => turn.text.trim() ? [{
734
+ role: turn.role === "assistant" ? "assistant" : "user",
735
+ text: turn.text.trim()
736
+ }] : [])].slice(-128) : [];
737
+ setEarlier(history);
738
+ setError(void 0);
739
+ setTurns([]);
740
+ setRequestLogId(void 0);
741
+ setElapsedSec(0);
742
+ setStatus("connecting");
743
+ let mic;
744
+ let pc;
745
+ try {
746
+ mic = await navigator.mediaDevices.getUserMedia({ audio: true });
747
+ const peer = new RTCPeerConnection();
748
+ pc = peer;
749
+ mic.getTracks().forEach((track) => peer.addTrack(track));
750
+ peer.addEventListener("track", (event) => {
751
+ if (audioRef.current) audioRef.current.srcObject = new MediaStream([event.track]);
752
+ });
753
+ const channel = peer.createDataChannel("oai-events");
754
+ channel.addEventListener("message", (event) => onEvent(String(event.data)));
755
+ const offer = await peer.createOffer();
756
+ await peer.setLocalDescription(offer);
757
+ const params = {
758
+ sdp: offer.sdp ?? "",
759
+ voice,
760
+ delegation: {
761
+ model: delegateModel,
762
+ effort,
763
+ webSearch: searchable && webSearch
764
+ },
765
+ projectName: PROJECT_NAME
766
+ };
767
+ if (instructions.trim()) params.instructions = instructions.trim();
768
+ if (history.length) params.history = history;
769
+ if (!logged) params.logger = false;
770
+ const out = await liveCall.mutateAsync({ params });
771
+ await peer.setRemoteDescription({
772
+ type: "answer",
773
+ sdp: out.sdp
774
+ });
775
+ session.current = {
776
+ pc: peer,
777
+ channel,
778
+ mic
779
+ };
780
+ setRequestLogId(out.requestLogId);
781
+ setStatus("live");
782
+ } catch (e) {
783
+ mic?.getTracks().forEach((track) => track.stop());
784
+ pc?.close();
785
+ setError(e instanceof Error ? e.message : String(e));
786
+ setStatus("idle");
787
+ }
788
+ };
789
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
790
+ className: "flex flex-col gap-3 p-4",
791
+ children: [
792
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
793
+ className: "grid grid-cols-2 gap-2",
794
+ children: [
795
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
796
+ label: "Voice",
797
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
798
+ value: voice,
799
+ onChange: (e) => setVoice(e.target.value),
800
+ disabled: status !== "idle",
801
+ className: CONTROL,
802
+ children: LIVE_VOICES.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
803
+ value: v,
804
+ children: v
805
+ }, v))
806
+ })
807
+ }),
808
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
809
+ label: "Instructions",
810
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
811
+ value: instructions,
812
+ onChange: (e) => setInstructions(e.target.value),
813
+ disabled: status !== "idle",
814
+ placeholder: "e.g. You are a friendly English tutor. Keep answers short.",
815
+ className: CONTROL
816
+ })
817
+ }),
818
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
819
+ label: "Delegation model (answers lookups and reasoning)",
820
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
821
+ value: delegateModel,
822
+ onChange: (e) => setDelegateModel(e.target.value),
823
+ disabled: status !== "idle",
824
+ className: CONTROL,
825
+ children: QGRID_MODEL_GROUPS.map((group) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("optgroup", {
826
+ label: group.label,
827
+ children: group.models.map((m) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
828
+ value: m,
829
+ children: m
830
+ }, m))
831
+ }, group.label))
832
+ })
833
+ }),
834
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
835
+ className: "flex items-end gap-3",
836
+ children: [
837
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Field, {
838
+ label: "Effort",
839
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", {
840
+ value: effort,
841
+ onChange: (e) => setEffort(Effort.options.find((v) => v === e.target.value) ?? "low"),
842
+ disabled: status !== "idle",
843
+ className: CONTROL,
844
+ children: Effort.options.map((v) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", {
845
+ value: v,
846
+ children: v
847
+ }, v))
848
+ })
849
+ }),
850
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
851
+ className: "flex h-8 items-center gap-1.5 text-[12px] text-sand-600",
852
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
853
+ type: "checkbox",
854
+ checked: searchable && webSearch,
855
+ onChange: (e) => setWebSearch(e.target.checked),
856
+ disabled: status !== "idle" || !searchable,
857
+ className: "accent-sienna-500"
858
+ }), "Web search"]
859
+ }),
860
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
861
+ className: "flex h-8 items-center gap-1.5 text-[12px] text-sand-600",
862
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
863
+ type: "checkbox",
864
+ checked: logged,
865
+ onChange: (e) => setLogged(e.target.checked),
866
+ disabled: status !== "idle",
867
+ className: "accent-sienna-500"
868
+ }), "Request log"]
869
+ })
870
+ ]
871
+ })
872
+ ]
873
+ }),
874
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
875
+ className: "flex flex-wrap items-center gap-3",
876
+ children: [
877
+ status === "idle" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
878
+ type: "button",
879
+ onClick: () => start(false),
880
+ className: BUTTON,
881
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$1, { className: "size-3.5" }), "Start conversation"]
882
+ }), turns.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
883
+ type: "button",
884
+ onClick: () => start(true),
885
+ className: "text-[12px] font-medium text-sienna-600 hover:text-sienna-700",
886
+ children: "Continue this conversation"
887
+ })] }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
888
+ type: "button",
889
+ onClick: stop,
890
+ disabled: status === "connecting",
891
+ className: `${BUTTON} bg-danger-500 hover:bg-danger-500`,
892
+ 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"]
893
+ }),
894
+ status === "live" && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
895
+ className: "tabular-nums text-[12px] text-sand-500",
896
+ children: [clock(elapsedSec), " · openai/gpt-live-1 · speak any time (ends by itself after 2 h)"]
897
+ }),
898
+ requestLogId !== void 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
899
+ to: "/requests/show",
900
+ search: { id: requestLogId },
901
+ target: "_blank",
902
+ className: "inline-flex items-center gap-1 text-[12px] tabular-nums text-sand-500 hover:text-sienna-500",
903
+ children: [
904
+ "request log #",
905
+ requestLogId,
906
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ForwardRef$3, { className: "size-3" })
907
+ ]
908
+ }),
909
+ error && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
910
+ className: "text-[12px] text-danger-500 break-words",
911
+ children: error
912
+ })
913
+ ]
914
+ }),
915
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("audio", {
916
+ ref: audioRef,
917
+ autoPlay: true
918
+ }),
919
+ earlier.length === 0 && turns.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
920
+ className: "py-6 text-center text-[12px] text-sand-400",
921
+ children: "Start a conversation and talk; both sides of the transcript appear here."
922
+ }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", {
923
+ className: "flex flex-col gap-1.5",
924
+ children: [earlier.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
925
+ className: "rounded-lg bg-sand-50/60 px-3 py-2 text-[13px] text-sand-500",
926
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
927
+ className: "mr-2 text-[10px] font-medium uppercase tracking-wider text-sand-400",
928
+ children: item.role
929
+ }), item.text]
930
+ }, `earlier-${index}`)), turns.map((turn) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
931
+ className: `rounded-lg px-3 py-2 text-[13px] text-sand-800 ${turn.role === "assistant" ? "bg-sage-50" : "bg-sand-50"}`,
932
+ children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
933
+ className: "mr-2 text-[10px] font-medium uppercase tracking-wider text-sand-500",
934
+ children: turn.role
935
+ }), turn.text.trim()]
936
+ }, turn.id))]
937
+ })
938
+ ]
939
+ });
940
+ }
941
+ function VoicePlayground({ tab }) {
663
942
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
664
943
  className: "rounded-xl border border-sand-200/70 bg-white overflow-hidden",
665
944
  children: [
666
945
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
667
946
  role: "tablist",
668
- className: "flex gap-1 border-b border-sand-100 px-3 pt-2",
669
- children: TABS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
670
- type: "button",
947
+ className: "flex gap-1 border-b border-sand-100 px-3 pt-2 md:hidden",
948
+ children: VOICE_TAB_IDS.map((id) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
949
+ to: "/voice",
950
+ search: { tab: id },
671
951
  role: "tab",
672
- "aria-selected": tab === t.id,
673
- onClick: () => setTab(t.id),
674
- className: `-mb-px border-b-2 px-3 py-2 text-[13px] transition-colors duration-150 ${tab === t.id ? "border-sienna-500 font-medium text-sand-800" : "border-transparent text-sand-500 hover:text-sand-700"}`,
675
- children: t.label
676
- }, t.id))
952
+ "aria-selected": tab === id,
953
+ 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"}`,
954
+ children: VOICE_TAB_TITLES[id]
955
+ }, id))
677
956
  }),
678
957
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
679
958
  role: "tabpanel",
@@ -684,6 +963,11 @@ function VoicePlayground() {
684
963
  role: "tabpanel",
685
964
  hidden: tab !== "stt",
686
965
  children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(SttPanel, {})
966
+ }),
967
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
968
+ role: "tabpanel",
969
+ hidden: tab !== "live",
970
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LivePanel, {})
687
971
  })
688
972
  ]
689
973
  });
@@ -691,9 +975,10 @@ function VoicePlayground() {
691
975
  //#endregion
692
976
  //#region src/routes/voice.tsx?tsr-split=component
693
977
  function VoicePage() {
978
+ const { tab = "tts" } = Route.useSearch();
694
979
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
695
980
  className: "max-w-3xl mx-auto",
696
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePlayground, {})
981
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePlayground, { tab })
697
982
  });
698
983
  }
699
984
  //#endregion