@cartanova/qgrid-cli 2.19.0 → 2.19.2

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 (74) hide show
  1. package/bundle/dist/application/qgrid/qgrid-response-format.js +14 -5
  2. package/bundle/dist/application/qgrid/qgrid-run-lifecycle.js +12 -4
  3. package/bundle/dist/application/qgrid/qgrid.dispatcher.js +3 -1
  4. package/bundle/dist/application/qgrid/qgrid.frame.js +215 -6
  5. package/bundle/dist/application/qgrid/qgrid.types.js +65 -2
  6. package/bundle/dist/application/request-log/request-log.model.js +11 -1
  7. package/bundle/dist/application/sonamu.generated.js +5 -3
  8. package/bundle/dist/i18n/sd.generated.js +3 -2
  9. package/bundle/dist/utils/providers/common/model-cost.js +8 -2
  10. package/bundle/dist/utils/providers/openai/openai-dispatcher.js +18 -1
  11. package/bundle/dist/utils/providers/openai/openai-realtime-protocol.js +112 -2
  12. package/bundle/dist/utils/providers/openai/openai-voice-client.js +183 -6
  13. package/bundle/src/application/qgrid/qgrid-response-format.test.ts +14 -4
  14. package/bundle/src/application/qgrid/qgrid-response-format.ts +18 -2
  15. package/bundle/src/application/qgrid/qgrid-run-lifecycle.test.ts +36 -1
  16. package/bundle/src/application/qgrid/qgrid-run-lifecycle.ts +25 -3
  17. package/bundle/src/application/qgrid/qgrid.dispatcher.test.ts +17 -0
  18. package/bundle/src/application/qgrid/qgrid.dispatcher.ts +8 -0
  19. package/bundle/src/application/qgrid/qgrid.frame.test.ts +187 -0
  20. package/bundle/src/application/qgrid/qgrid.frame.ts +287 -3
  21. package/bundle/src/application/qgrid/qgrid.types.ts +103 -0
  22. package/bundle/src/application/request-log/request-log.entity.json +3 -2
  23. package/bundle/src/application/request-log/request-log.model.test.ts +19 -0
  24. package/bundle/src/application/request-log/request-log.model.ts +20 -1
  25. package/bundle/src/application/sonamu.generated.http +22 -0
  26. package/bundle/src/application/sonamu.generated.ts +2 -1
  27. package/bundle/src/i18n/sd.generated.ts +2 -1
  28. package/bundle/src/utils/providers/common/model-cost.ts +15 -0
  29. package/bundle/src/utils/providers/openai/openai-dispatcher.test.ts +16 -0
  30. package/bundle/src/utils/providers/openai/openai-dispatcher.ts +26 -0
  31. package/bundle/src/utils/providers/openai/openai-realtime-protocol.ts +125 -0
  32. package/bundle/src/utils/providers/openai/openai-voice-client.test.ts +184 -0
  33. package/bundle/src/utils/providers/openai/openai-voice-client.ts +277 -5
  34. package/bundle/web-dist/client/assets/index-BeceW0U9.js +104 -0
  35. package/bundle/web-dist/client/assets/index-hUNCpC11.css +1 -0
  36. package/bundle/web-dist/client/assets/logs-jMJnTwZn.js +1 -0
  37. package/bundle/web-dist/client/assets/monit-B1xRKwua.js +1 -0
  38. package/bundle/web-dist/client/assets/{routes-Dw227enb.js → routes-fsiyivXx.js} +2 -2
  39. package/bundle/web-dist/client/assets/{settings-BXmAToY1.js → settings-CHX44roa.js} +1 -1
  40. package/bundle/web-dist/client/assets/show-BDMwKfEY.js +2 -0
  41. package/bundle/web-dist/client/assets/{tokens-D8L8AC4v.js → tokens-zGl36OfE.js} +1 -1
  42. package/bundle/web-dist/client/assets/{use-oauth-login-flow-BcEUkszt.js → use-oauth-login-flow-DYWj4645.js} +1 -1
  43. package/bundle/web-dist/client/assets/use-update-token-mutation-BRXXrEf5.js +1 -0
  44. package/bundle/web-dist/client/assets/{vendor-tanstack-6B86itGS.js → vendor-tanstack-DMgmqjm4.js} +1 -1
  45. package/bundle/web-dist/client/assets/voice-Bwcp-KAu.js +1 -0
  46. package/bundle/web-dist/client/index.html +3 -3
  47. package/bundle/web-dist/server/assets/{TimedPlayer-DAwjkP4z.js → TimedPlayer-COqaTQSl.js} +1 -1
  48. package/bundle/web-dist/server/assets/{logs-BmBpBe-j.js → logs-HPho1SkC.js} +5 -6
  49. package/bundle/web-dist/server/assets/{monit-Db1WrIls.js → monit-Bl2kSkSF.js} +3 -3
  50. package/bundle/web-dist/server/assets/{plus-CW9y_K7l.js → plus-CQ8AHpih.js} +1 -1
  51. package/bundle/web-dist/server/assets/{refresh-cw-CRgcH5bT.js → refresh-cw-pYSuvt4c.js} +1 -1
  52. package/bundle/web-dist/server/assets/{request-model-DRF7hmJC.js → request-model-ZulJMbGm.js} +1 -1
  53. package/bundle/web-dist/server/assets/{routes-CARZj7or.js → routes-BNHCX4VI.js} +4 -4
  54. package/bundle/web-dist/server/assets/{services.generated-B6QpnL_N.js → services.generated-C3b31_vt.js} +23209 -22930
  55. package/bundle/web-dist/server/assets/{settings-B4jdpP5N.js → settings-NJUyaSrJ.js} +4 -4
  56. package/bundle/web-dist/server/assets/{show-CnLDFCtW.js → show-Dz5QGL7l.js} +8 -9
  57. package/bundle/web-dist/server/assets/{tokens-TDQguTdh.js → tokens-BPQvjIGq.js} +5 -5
  58. package/bundle/web-dist/server/assets/{use-oauth-login-flow-du7pOh_H.js → use-oauth-login-flow-CCc8LEmn.js} +1 -1
  59. package/bundle/web-dist/server/assets/{use-update-token-mutation-DA6HiiWS.js → use-update-token-mutation-Ba-sEhq1.js} +1 -1
  60. package/bundle/web-dist/server/assets/{voice-BvAl-vTr.js → voice-V-E3tRqD.js} +289 -22
  61. package/bundle/web-dist/server/entry-server.generated.js +5581 -71
  62. package/package.json +1 -1
  63. package/skills/qgrid/references/decision-rationale.md +5 -1
  64. package/skills/qgrid/references/openai-codex-runtime.md +15 -0
  65. package/skills/qgrid/references/request-log-run-lifecycle.md +3 -2
  66. package/skills/qgrid/references/sonamu-api-web-flow.md +2 -2
  67. package/bundle/web-dist/client/assets/index-Co8uAhSV.css +0 -1
  68. package/bundle/web-dist/client/assets/index-DYYtV8Qx.js +0 -104
  69. package/bundle/web-dist/client/assets/logs-CbDtQif1.js +0 -1
  70. package/bundle/web-dist/client/assets/monit-DtW8o_yF.js +0 -1
  71. package/bundle/web-dist/client/assets/show-5qj6wFgp.js +0 -2
  72. package/bundle/web-dist/client/assets/use-update-token-mutation-Ca0n_WnM.js +0 -1
  73. package/bundle/web-dist/client/assets/voice-D-c1Eyp3.js +0 -1
  74. 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,291 @@ 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 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 }) {
663
924
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
664
925
  className: "rounded-xl border border-sand-200/70 bg-white overflow-hidden",
665
926
  children: [
666
927
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
667
928
  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",
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 },
671
933
  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))
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))
677
938
  }),
678
939
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
679
940
  role: "tabpanel",
@@ -684,6 +945,11 @@ function VoicePlayground() {
684
945
  role: "tabpanel",
685
946
  hidden: tab !== "stt",
686
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, {})
687
953
  })
688
954
  ]
689
955
  });
@@ -691,9 +957,10 @@ function VoicePlayground() {
691
957
  //#endregion
692
958
  //#region src/routes/voice.tsx?tsr-split=component
693
959
  function VoicePage() {
960
+ const { tab = "tts" } = Route.useSearch();
694
961
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
695
962
  className: "max-w-3xl mx-auto",
696
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePlayground, {})
963
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VoicePlayground, { tab })
697
964
  });
698
965
  }
699
966
  //#endregion