@opengeni/react 1.3.0 → 1.4.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 (240) hide show
  1. package/README.md +29 -1
  2. package/dist/accounts.js +2 -0
  3. package/dist/accounts.js.map +1 -1
  4. package/dist/artifacts-document.js +5 -4
  5. package/dist/artifacts-presentation.js +5 -4
  6. package/dist/artifacts-spreadsheet.js +4 -3
  7. package/dist/artifacts.js +14 -13
  8. package/dist/artifacts.js.map +1 -1
  9. package/dist/browser-viewer-WGJ43YGI.js +17 -0
  10. package/dist/chat-interactive-block-ZFHOKTMS.js +12 -0
  11. package/dist/{chunk-WEHMPOXK.js → chunk-2DDJ6YH6.js} +3 -1
  12. package/dist/{chunk-WEHMPOXK.js.map → chunk-2DDJ6YH6.js.map} +1 -1
  13. package/dist/{chunk-C5X5AJXK.js → chunk-2HVLQ26H.js} +5 -4
  14. package/dist/{chunk-C5X5AJXK.js.map → chunk-2HVLQ26H.js.map} +1 -1
  15. package/dist/{chunk-A4UJB2MM.js → chunk-32CGLXW2.js} +4 -3
  16. package/dist/{chunk-A4UJB2MM.js.map → chunk-32CGLXW2.js.map} +1 -1
  17. package/dist/{chunk-5CVXZA3Y.js → chunk-45NUOSXQ.js} +3 -2
  18. package/dist/{chunk-5CVXZA3Y.js.map → chunk-45NUOSXQ.js.map} +1 -1
  19. package/dist/{chunk-WUISZ3WU.js → chunk-53KJBGPZ.js} +5 -4
  20. package/dist/{chunk-WUISZ3WU.js.map → chunk-53KJBGPZ.js.map} +1 -1
  21. package/dist/{chunk-TMYGL6X5.js → chunk-55DXD22O.js} +73 -7
  22. package/dist/chunk-55DXD22O.js.map +1 -0
  23. package/dist/{chunk-JT4JW7BC.js → chunk-5I4VRWBB.js} +3 -1
  24. package/dist/{chunk-JT4JW7BC.js.map → chunk-5I4VRWBB.js.map} +1 -1
  25. package/dist/{chunk-UK4TINKT.js → chunk-B27E3V37.js} +3 -1
  26. package/dist/{chunk-UK4TINKT.js.map → chunk-B27E3V37.js.map} +1 -1
  27. package/dist/{chunk-J6DBS4T3.js → chunk-BNKV5ZLF.js} +5 -4
  28. package/dist/{chunk-J6DBS4T3.js.map → chunk-BNKV5ZLF.js.map} +1 -1
  29. package/dist/{chunk-YM2DE7BQ.js → chunk-C5BF4L26.js} +13 -12
  30. package/dist/{chunk-YM2DE7BQ.js.map → chunk-C5BF4L26.js.map} +1 -1
  31. package/dist/{chunk-YBXQDQFX.js → chunk-C7CMD56T.js} +6 -5
  32. package/dist/{chunk-YBXQDQFX.js.map → chunk-C7CMD56T.js.map} +1 -1
  33. package/dist/{chunk-UGLEYEMP.js → chunk-CM7LVUKC.js} +3 -1
  34. package/dist/{chunk-UGLEYEMP.js.map → chunk-CM7LVUKC.js.map} +1 -1
  35. package/dist/{chunk-PGSX7UCP.js → chunk-CREMJMVN.js} +1502 -833
  36. package/dist/chunk-CREMJMVN.js.map +1 -0
  37. package/dist/{chunk-JVYQRRC4.js → chunk-CVYCLFMH.js} +3 -1
  38. package/dist/{chunk-JVYQRRC4.js.map → chunk-CVYCLFMH.js.map} +1 -1
  39. package/dist/{chunk-Y2PRMYLC.js → chunk-G3U2A6GS.js} +3 -2
  40. package/dist/{chunk-Y2PRMYLC.js.map → chunk-G3U2A6GS.js.map} +1 -1
  41. package/dist/{chunk-WWEUO2PL.js → chunk-G6YRCIYJ.js} +202 -14
  42. package/dist/chunk-G6YRCIYJ.js.map +1 -0
  43. package/dist/{chunk-B3V6TG77.js → chunk-GC3PH6N7.js} +3 -1
  44. package/dist/{chunk-B3V6TG77.js.map → chunk-GC3PH6N7.js.map} +1 -1
  45. package/dist/{chunk-FZCP527Y.js → chunk-HXYOSSQO.js} +3 -2
  46. package/dist/{chunk-FZCP527Y.js.map → chunk-HXYOSSQO.js.map} +1 -1
  47. package/dist/{chunk-BRM6FVZA.js → chunk-IEE7WCLN.js} +4 -3
  48. package/dist/{chunk-BRM6FVZA.js.map → chunk-IEE7WCLN.js.map} +1 -1
  49. package/dist/{chunk-DYWBUX5Q.js → chunk-IMSUVYQB.js} +6 -5
  50. package/dist/{chunk-DYWBUX5Q.js.map → chunk-IMSUVYQB.js.map} +1 -1
  51. package/dist/{chunk-CY7WK5FD.js → chunk-IUHHPMAX.js} +203 -46
  52. package/dist/chunk-IUHHPMAX.js.map +1 -0
  53. package/dist/{chunk-SGKD2OCN.js → chunk-IYQCWGU5.js} +6 -5
  54. package/dist/{chunk-SGKD2OCN.js.map → chunk-IYQCWGU5.js.map} +1 -1
  55. package/dist/{chunk-J2QWVSQY.js → chunk-JH7V627O.js} +8 -7
  56. package/dist/{chunk-J2QWVSQY.js.map → chunk-JH7V627O.js.map} +1 -1
  57. package/dist/{chunk-EESD3PY3.js → chunk-JHTIMBOL.js} +6 -5
  58. package/dist/{chunk-EESD3PY3.js.map → chunk-JHTIMBOL.js.map} +1 -1
  59. package/dist/{chunk-LNIRAOA3.js → chunk-L2J3PU7A.js} +7 -6
  60. package/dist/{chunk-LNIRAOA3.js.map → chunk-L2J3PU7A.js.map} +1 -1
  61. package/dist/{chunk-ZYRGEKWS.js → chunk-LJUMYUBO.js} +3 -1
  62. package/dist/{chunk-ZYRGEKWS.js.map → chunk-LJUMYUBO.js.map} +1 -1
  63. package/dist/{chunk-4RVYOY4O.js → chunk-LSW2OJVV.js} +4 -3
  64. package/dist/{chunk-4RVYOY4O.js.map → chunk-LSW2OJVV.js.map} +1 -1
  65. package/dist/{chunk-UTRTG6LH.js → chunk-LVS3MH5T.js} +3 -1
  66. package/dist/{chunk-UTRTG6LH.js.map → chunk-LVS3MH5T.js.map} +1 -1
  67. package/dist/chunk-M357MHH3.js +2 -0
  68. package/dist/{chunk-GYVRFZDY.js → chunk-MDIXFKA3.js} +9 -8
  69. package/dist/{chunk-GYVRFZDY.js.map → chunk-MDIXFKA3.js.map} +1 -1
  70. package/dist/{chunk-WRHIZYZF.js → chunk-MEQM4LI3.js} +6 -5
  71. package/dist/{chunk-WRHIZYZF.js.map → chunk-MEQM4LI3.js.map} +1 -1
  72. package/dist/chunk-NX4ADH73.js +14 -0
  73. package/dist/chunk-NX4ADH73.js.map +1 -0
  74. package/dist/{chunk-XCHWDJ22.js → chunk-OGTTUYNT.js} +3 -1
  75. package/dist/{chunk-XCHWDJ22.js.map → chunk-OGTTUYNT.js.map} +1 -1
  76. package/dist/{chunk-GIMRELBW.js → chunk-OYQQJL3J.js} +3 -1
  77. package/dist/{chunk-GIMRELBW.js.map → chunk-OYQQJL3J.js.map} +1 -1
  78. package/dist/{chunk-RSI7XYXL.js → chunk-PBCZL4JP.js} +6 -5
  79. package/dist/{chunk-RSI7XYXL.js.map → chunk-PBCZL4JP.js.map} +1 -1
  80. package/dist/{chunk-I7IWRQLN.js → chunk-PHBFJCEU.js} +17 -11
  81. package/dist/chunk-PHBFJCEU.js.map +1 -0
  82. package/dist/{chunk-3CTRFMAK.js → chunk-PKCAYHDC.js} +5 -4
  83. package/dist/{chunk-3CTRFMAK.js.map → chunk-PKCAYHDC.js.map} +1 -1
  84. package/dist/{chunk-K3HQAKQX.js → chunk-PMV53IMM.js} +3 -1
  85. package/dist/{chunk-K3HQAKQX.js.map → chunk-PMV53IMM.js.map} +1 -1
  86. package/dist/{chunk-YQEAA6LT.js → chunk-QHUE7E4N.js} +3 -2
  87. package/dist/{chunk-YQEAA6LT.js.map → chunk-QHUE7E4N.js.map} +1 -1
  88. package/dist/{chunk-RC6BZ44Q.js → chunk-QMMCJGFI.js} +4 -3
  89. package/dist/{chunk-RC6BZ44Q.js.map → chunk-QMMCJGFI.js.map} +1 -1
  90. package/dist/{chunk-YV4L3ILF.js → chunk-QV3DJVRZ.js} +3 -1
  91. package/dist/{chunk-YV4L3ILF.js.map → chunk-QV3DJVRZ.js.map} +1 -1
  92. package/dist/{chunk-447JLCBU.js → chunk-S2QH6EZ5.js} +3 -1
  93. package/dist/{chunk-447JLCBU.js.map → chunk-S2QH6EZ5.js.map} +1 -1
  94. package/dist/{chunk-PNY3JKBJ.js → chunk-SFH43JT2.js} +5 -4
  95. package/dist/{chunk-PNY3JKBJ.js.map → chunk-SFH43JT2.js.map} +1 -1
  96. package/dist/{chunk-ERGYJIBB.js → chunk-T46QZH3E.js} +4 -2
  97. package/dist/{chunk-ERGYJIBB.js.map → chunk-T46QZH3E.js.map} +1 -1
  98. package/dist/{chunk-5J4FOW6Q.js → chunk-TNEZNMSN.js} +3 -1
  99. package/dist/{chunk-5J4FOW6Q.js.map → chunk-TNEZNMSN.js.map} +1 -1
  100. package/dist/{chunk-22KP6LR5.js → chunk-TXS65BB2.js} +3 -1
  101. package/dist/{chunk-22KP6LR5.js.map → chunk-TXS65BB2.js.map} +1 -1
  102. package/dist/{chunk-742CZ3L3.js → chunk-UDPH5SLV.js} +19 -202
  103. package/dist/chunk-UDPH5SLV.js.map +1 -0
  104. package/dist/{chunk-HDJWDK7W.js → chunk-VCSERYXH.js} +10 -9
  105. package/dist/{chunk-HDJWDK7W.js.map → chunk-VCSERYXH.js.map} +1 -1
  106. package/dist/{chunk-VZTQ73XT.js → chunk-XEA5BCMA.js} +3 -1
  107. package/dist/{chunk-VZTQ73XT.js.map → chunk-XEA5BCMA.js.map} +1 -1
  108. package/dist/{chunk-5F4WR7X7.js → chunk-XS67YG5R.js} +3 -1
  109. package/dist/{chunk-5F4WR7X7.js.map → chunk-XS67YG5R.js.map} +1 -1
  110. package/dist/{chunk-TKOTKRWY.js → chunk-XTD7TZHW.js} +3 -1
  111. package/dist/{chunk-TKOTKRWY.js.map → chunk-XTD7TZHW.js.map} +1 -1
  112. package/dist/{chunk-A2PI6UMY.js → chunk-YSRBFJMQ.js} +3 -1
  113. package/dist/{chunk-A2PI6UMY.js.map → chunk-YSRBFJMQ.js.map} +1 -1
  114. package/dist/chunk-YVFRBXST.js +1420 -0
  115. package/dist/chunk-YVFRBXST.js.map +1 -0
  116. package/dist/{chunk-SCOTPE2I.js → chunk-YYLBXXTE.js} +3 -1
  117. package/dist/{chunk-SCOTPE2I.js.map → chunk-YYLBXXTE.js.map} +1 -1
  118. package/dist/{chunk-RHREZ7BO.js → chunk-ZUWF4NF7.js} +3 -1
  119. package/dist/{chunk-RHREZ7BO.js.map → chunk-ZUWF4NF7.js.map} +1 -1
  120. package/dist/clipboard.js +3 -2
  121. package/dist/components/composer-transcription-control.d.ts +7 -0
  122. package/dist/components/open-geni-chat.d.ts +6 -2
  123. package/dist/components/session-conversation.d.ts +31 -19
  124. package/dist/components/session-list.d.ts +4 -1
  125. package/dist/components/tool-action-review.d.ts +29 -2
  126. package/dist/components/tool-review-history.d.ts +8 -4
  127. package/dist/composer-voice-events.d.ts +8 -0
  128. package/dist/composer.js +15 -13
  129. package/dist/computer-viewer-46UIN7F3.js +20 -0
  130. package/dist/connect.js +15 -12
  131. package/dist/connect.js.map +1 -1
  132. package/dist/desktop.js +6 -5
  133. package/dist/desktop.js.map +1 -1
  134. package/dist/diffs.js +2 -1
  135. package/dist/diffs.js.map +1 -1
  136. package/dist/editor.js +4 -3
  137. package/dist/editor.js.map +1 -1
  138. package/dist/embedded-voice-NIL4RDX3.js +69 -0
  139. package/dist/embedded-voice-NIL4RDX3.js.map +1 -0
  140. package/dist/{fleet-decision-row-YZ3ZKWMM.js → fleet-decision-row-SI63O5V4.js} +3 -1
  141. package/dist/{fleet-decision-row-YZ3ZKWMM.js.map → fleet-decision-row-SI63O5V4.js.map} +1 -1
  142. package/dist/hooks/use-client-config-flags.d.ts +43 -0
  143. package/dist/hooks/use-realtime-voice-models.d.ts +9 -0
  144. package/dist/hooks/use-voice-input.d.ts +8 -1
  145. package/dist/index.d.ts +3 -3
  146. package/dist/index.js +60 -48
  147. package/dist/index.js.map +1 -1
  148. package/dist/interaction.js +14 -13
  149. package/dist/interaction.js.map +1 -1
  150. package/dist/{latest-question-YTOBHCWR.js → latest-question-2POFPYNB.js} +5 -4
  151. package/dist/{latest-question-YTOBHCWR.js.map → latest-question-2POFPYNB.js.map} +1 -1
  152. package/dist/machines.js +8 -7
  153. package/dist/{markdown-table-layout-QXSLK4BY.js → markdown-table-layout-DQ4DRNVT.js} +3 -1
  154. package/dist/{markdown-table-layout-QXSLK4BY.js.map → markdown-table-layout-DQ4DRNVT.js.map} +1 -1
  155. package/dist/model-policy-picker-menu-WRNSRFQC.js +15 -0
  156. package/dist/model-policy.js +2 -1
  157. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js → noto-sans-arabic-loader-XSH2KYWJ.js} +3 -1
  158. package/dist/{noto-sans-arabic-loader-IA2T4X2A.js.map → noto-sans-arabic-loader-XSH2KYWJ.js.map} +1 -1
  159. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js → noto-sans-jp-loader.generated-MR5L6V7K.js} +3 -1
  160. package/dist/{noto-sans-jp-loader.generated-HFGLYBR3.js.map → noto-sans-jp-loader.generated-MR5L6V7K.js.map} +1 -1
  161. package/dist/{platform-activity-row-627BFZ46.js → platform-activity-row-PJJVATTZ.js} +3 -1
  162. package/dist/{platform-activity-row-627BFZ46.js.map → platform-activity-row-PJJVATTZ.js.map} +1 -1
  163. package/dist/{queue-surface-implementation-ZHFI5JBP.js → queue-surface-implementation-67FS7FUI.js} +10 -9
  164. package/dist/{queue-surface-implementation-ZHFI5JBP.js.map → queue-surface-implementation-67FS7FUI.js.map} +1 -1
  165. package/dist/realtime/embedded-voice.d.ts +20 -0
  166. package/dist/realtime/realtime-control.d.ts +2 -0
  167. package/dist/realtime.js +22 -1332
  168. package/dist/realtime.js.map +1 -1
  169. package/dist/sandbox-files-34CJJNOY.js +21 -0
  170. package/dist/session-capability-policy.d.ts +20 -1
  171. package/dist/session-ui.js +32 -30
  172. package/dist/session-ui.js.map +1 -1
  173. package/dist/session.js +12 -11
  174. package/dist/sites.js +2 -1
  175. package/dist/terminal.js +6 -5
  176. package/dist/terminal.js.map +1 -1
  177. package/dist/timeline/index.d.ts +2 -0
  178. package/dist/timeline/retained-loaders.d.ts +27 -0
  179. package/dist/{timeline-annotation-markers-GNDHTGBD.js → timeline-annotation-markers-U3G66KUD.js} +5 -4
  180. package/dist/{timeline-annotation-markers-GNDHTGBD.js.map → timeline-annotation-markers-U3G66KUD.js.map} +1 -1
  181. package/dist/{timeline-annotation-selection-DMLMM2TX.js → timeline-annotation-selection-BI7QTPTZ.js} +4 -3
  182. package/dist/{timeline-annotation-selection-DMLMM2TX.js.map → timeline-annotation-selection-BI7QTPTZ.js.map} +1 -1
  183. package/dist/{timeline-annotations-dialog-ELRDBHTS.js → timeline-annotations-dialog-FOMHSDTE.js} +7 -6
  184. package/dist/{timeline-annotations-dialog-ELRDBHTS.js.map → timeline-annotations-dialog-FOMHSDTE.js.map} +1 -1
  185. package/dist/usage.js +6 -5
  186. package/dist/usage.js.map +1 -1
  187. package/dist/voice-recording-owner.d.ts +7 -0
  188. package/package.json +3 -3
  189. package/src/components/approval-surface.tsx +190 -79
  190. package/src/components/artifacts/session-artifact-viewer.tsx +4 -2
  191. package/src/components/composer-transcription-control.tsx +121 -25
  192. package/src/components/composer.tsx +1 -0
  193. package/src/components/markdown.tsx +7 -2
  194. package/src/components/message-timeline.tsx +10 -1
  195. package/src/components/open-geni-chat.tsx +53 -13
  196. package/src/components/session-conversation.tsx +273 -63
  197. package/src/components/session-list.tsx +9 -2
  198. package/src/components/session-proxy-scope.tsx +26 -5
  199. package/src/components/tool-action-review.tsx +502 -239
  200. package/src/components/tool-review-history.tsx +18 -43
  201. package/src/composer-voice-events.ts +12 -0
  202. package/src/connection-discovery.tsx +4 -1
  203. package/src/hooks/use-client-config-flags.ts +110 -0
  204. package/src/hooks/use-goal.ts +12 -1
  205. package/src/hooks/use-realtime-voice-models.ts +67 -0
  206. package/src/hooks/use-session-events.ts +19 -16
  207. package/src/hooks/use-transcription.ts +6 -0
  208. package/src/hooks/use-voice-input.ts +115 -18
  209. package/src/index.ts +9 -0
  210. package/src/realtime/embedded-voice.tsx +81 -0
  211. package/src/realtime/realtime-control.tsx +109 -17
  212. package/src/session-capability-policy.ts +119 -6
  213. package/src/timeline/index.ts +10 -0
  214. package/src/timeline/retained-loaders.ts +86 -0
  215. package/src/timeline/tool-display-name.ts +5 -1
  216. package/src/timeline/tool-renderers.tsx +143 -10
  217. package/src/voice-recording-owner.ts +22 -0
  218. package/styles/compiled.css +135 -37
  219. package/styles/index.css +49 -0
  220. package/styles/responsive.css +61 -4
  221. package/styles/session-capability.css +1 -1
  222. package/styles/tokens.css +1 -1
  223. package/dist/browser-viewer-SHYKQRNX.js +0 -16
  224. package/dist/chat-interactive-block-UGBTNB3L.js +0 -11
  225. package/dist/chunk-742CZ3L3.js.map +0 -1
  226. package/dist/chunk-CY7WK5FD.js.map +0 -1
  227. package/dist/chunk-I7IWRQLN.js.map +0 -1
  228. package/dist/chunk-IWIDV7SB.js +0 -1
  229. package/dist/chunk-PGSX7UCP.js.map +0 -1
  230. package/dist/chunk-TMYGL6X5.js.map +0 -1
  231. package/dist/chunk-WWEUO2PL.js.map +0 -1
  232. package/dist/computer-viewer-6SRGWRUX.js +0 -19
  233. package/dist/model-policy-picker-menu-DXHUL73H.js +0 -14
  234. package/dist/sandbox-files-GORZOUUJ.js +0 -20
  235. /package/dist/{browser-viewer-SHYKQRNX.js.map → browser-viewer-WGJ43YGI.js.map} +0 -0
  236. /package/dist/{chat-interactive-block-UGBTNB3L.js.map → chat-interactive-block-ZFHOKTMS.js.map} +0 -0
  237. /package/dist/{chunk-IWIDV7SB.js.map → chunk-M357MHH3.js.map} +0 -0
  238. /package/dist/{computer-viewer-6SRGWRUX.js.map → computer-viewer-46UIN7F3.js.map} +0 -0
  239. /package/dist/{model-policy-picker-menu-DXHUL73H.js.map → model-policy-picker-menu-WRNSRFQC.js.map} +0 -0
  240. /package/dist/{sandbox-files-GORZOUUJ.js.map → sandbox-files-34CJJNOY.js.map} +0 -0
package/dist/realtime.js CHANGED
@@ -1,1336 +1,26 @@
1
+ "use client";
1
2
  import {
2
- BillingClassMark,
3
- PickerAnimatedPage,
4
- PickerBackHeader,
5
- PickerNavRow
6
- } from "./chunk-LNIRAOA3.js";
7
- import {
8
- MENU_CHECK_CLASS,
9
- MENU_CHEVRON_CLASS,
10
- MENU_ITEM_CLASS,
11
- MENU_SEPARATOR_CLASS,
12
- MENU_SURFACE_CLASS
13
- } from "./chunk-K3HQAKQX.js";
14
- import "./chunk-5F4WR7X7.js";
15
- import {
16
- usePortalTokenSource,
17
- usePortalTokenStyle
18
- } from "./chunk-VZTQ73XT.js";
19
- import {
20
- useEmbeddedRealtimeSession
21
- } from "./chunk-TKOTKRWY.js";
22
- import {
23
- cn
24
- } from "./chunk-22KP6LR5.js";
25
-
26
- // src/realtime/realtime-control.tsx
27
- import {
28
- hasStoredSessionRealtimeOwnerProof,
29
- projectSessionRealtimeLifecycle
30
- } from "@opengeni/sdk/realtime";
31
- import {
32
- AudioLinesIcon,
33
- CheckIcon,
34
- ChevronDownIcon,
35
- CircleAlertIcon,
36
- LoaderCircleIcon,
37
- MicIcon,
38
- MicOffIcon,
39
- RotateCcwIcon,
40
- SquareIcon,
41
- Volume2Icon,
42
- VolumeXIcon
43
- } from "lucide-react";
44
- import { AnimatePresence, motion, useReducedMotion } from "motion/react";
45
- import {
46
- useCallback,
47
- useEffect,
48
- useMemo,
49
- useRef,
50
- useState
51
- } from "react";
52
-
53
- // src/realtime/dropdown-menu.tsx
54
- import { ChevronRightIcon } from "lucide-react";
55
- import { DropdownMenu as DropdownMenuPrimitive } from "radix-ui";
56
- import { createContext, useContext } from "react";
57
- import { jsx, jsxs } from "react/jsx-runtime";
58
- var MENU_MOTION_CLASS = "data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95";
59
- var DropdownMenuSourceContext = createContext(null);
60
- function assignRef(ref, value) {
61
- if (typeof ref === "function") ref(value);
62
- else if (ref) ref.current = value;
63
- }
64
- function DropdownMenu(props) {
65
- const source = usePortalTokenSource();
66
- return /* @__PURE__ */ jsx(DropdownMenuSourceContext.Provider, { value: source, children: /* @__PURE__ */ jsx(DropdownMenuPrimitive.Root, { "data-slot": "dropdown-menu", ...props }) });
67
- }
68
- function DropdownMenuTrigger({
69
- ref,
70
- ...props
71
- }) {
72
- const sourceRef = useContext(DropdownMenuSourceContext);
73
- return /* @__PURE__ */ jsx(
74
- DropdownMenuPrimitive.Trigger,
75
- {
76
- "data-slot": "dropdown-menu-trigger",
77
- ref: (node) => {
78
- sourceRef?.ref(node);
79
- assignRef(ref, node);
80
- },
81
- ...props
82
- }
83
- );
84
- }
85
- function DropdownMenuContent({
86
- className,
87
- sideOffset = 4,
88
- style,
89
- ...props
90
- }) {
91
- const source = useContext(DropdownMenuSourceContext);
92
- const portalStyle = usePortalTokenStyle(source?.source ?? null);
93
- return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Portal, { children: /* @__PURE__ */ jsx(
94
- DropdownMenuPrimitive.Content,
95
- {
96
- "data-slot": "dropdown-menu-content",
97
- sideOffset,
98
- className: cn(
99
- "og-root z-50 max-h-(--radix-dropdown-menu-content-available-height) min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-x-hidden overflow-y-auto",
100
- MENU_SURFACE_CLASS,
101
- MENU_MOTION_CLASS,
102
- className
103
- ),
104
- style: { ...portalStyle, ...style },
105
- ...props
106
- }
107
- ) });
108
- }
109
- function DropdownMenuItem({
110
- className,
111
- inset,
112
- variant = "default",
113
- ...props
114
- }) {
115
- return /* @__PURE__ */ jsx(
116
- DropdownMenuPrimitive.Item,
117
- {
118
- "data-slot": "dropdown-menu-item",
119
- "data-inset": inset,
120
- "data-variant": variant,
121
- className: cn(MENU_ITEM_CLASS, "data-[inset]:pl-9", className),
122
- ...props
123
- }
124
- );
125
- }
126
- function DropdownMenuSeparator({
127
- className,
128
- ...props
129
- }) {
130
- return /* @__PURE__ */ jsx(
131
- DropdownMenuPrimitive.Separator,
132
- {
133
- "data-slot": "dropdown-menu-separator",
134
- className: cn(MENU_SEPARATOR_CLASS, className),
135
- ...props
136
- }
137
- );
138
- }
139
- function DropdownMenuSub(props) {
140
- return /* @__PURE__ */ jsx(DropdownMenuPrimitive.Sub, { "data-slot": "dropdown-menu-sub", ...props });
141
- }
142
- function DropdownMenuSubTrigger({
143
- className,
144
- inset,
145
- children,
146
- ...props
147
- }) {
148
- return /* @__PURE__ */ jsxs(
149
- DropdownMenuPrimitive.SubTrigger,
150
- {
151
- "data-slot": "dropdown-menu-sub-trigger",
152
- "data-inset": inset,
153
- className: cn(MENU_ITEM_CLASS, "data-[inset]:pl-9", className),
154
- ...props,
155
- children: [
156
- children,
157
- /* @__PURE__ */ jsx(ChevronRightIcon, { "aria-hidden": "true", className: cn(MENU_CHEVRON_CLASS, "ml-auto") })
158
- ]
159
- }
160
- );
161
- }
162
- function DropdownMenuSubContent({
163
- className,
164
- style,
165
- ...props
166
- }) {
167
- const source = useContext(DropdownMenuSourceContext);
168
- const portalStyle = usePortalTokenStyle(source?.source ?? null);
169
- return /* @__PURE__ */ jsx(
170
- DropdownMenuPrimitive.SubContent,
171
- {
172
- "data-slot": "dropdown-menu-sub-content",
173
- className: cn(
174
- "og-root z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden",
175
- MENU_SURFACE_CLASS,
176
- MENU_MOTION_CLASS,
177
- className
178
- ),
179
- style: { ...portalStyle, ...style },
180
- ...props
181
- }
182
- );
183
- }
184
-
185
- // src/realtime/realtime-control.tsx
186
- import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
187
- var CODEX_LIVE_MODEL = {
188
- id: "gpt-live-1-boulder-alpha",
189
- label: "Codex Live",
190
- provider: "Connected Codex",
191
- description: "Deep session integration",
192
- available: false,
193
- unavailableReason: "Connect Codex to use this voice model",
194
- recommended: false
195
- };
196
- var REALTIME_MODEL_PROVIDERS = [
197
- "OpenGeni",
198
- "Connected Codex",
199
- "Connected SuperGrok",
200
- "Your Gateway"
201
- ];
202
- var REALTIME_PROVIDER_META = {
203
- OpenGeni: { billingClass: "opengeni_credits", hint: "Will use credits" },
204
- "Connected Codex": {
205
- billingClass: "codex_subscription",
206
- hint: "ChatGPT / Codex plan"
207
- },
208
- "Connected SuperGrok": {
209
- billingClass: "supergrok_subscription",
210
- hint: "SuperGrok / xAI plan"
211
- },
212
- "Your Gateway": { billingClass: "byok", hint: "Billed to your AI Gateway" }
213
- };
214
- var REALTIME_MODEL_STORAGE_PREFIX = "opengeni:realtime-model";
215
- var REALTIME_MODEL_CATALOG_CACHE_TTL_MS = 6e4;
216
- var REALTIME_MODEL_CATALOG_CACHE_MAX_WORKSPACES = 64;
217
- var realtimeModelCatalogCache = /* @__PURE__ */ new WeakMap();
218
- function realtimeModelFallback(codexConnected) {
219
- return [
220
- {
221
- ...CODEX_LIVE_MODEL,
222
- available: codexConnected,
223
- unavailableReason: codexConnected ? null : CODEX_LIVE_MODEL.unavailableReason
224
- }
225
- ];
226
- }
227
- function realtimeModelCatalogCacheFor(client) {
228
- const existing = realtimeModelCatalogCache.get(client);
229
- if (existing) return existing;
230
- const created = /* @__PURE__ */ new Map();
231
- realtimeModelCatalogCache.set(client, created);
232
- return created;
233
- }
234
- function readCachedRealtimeModelCatalog(client, workspaceId, now = Date.now()) {
235
- const cache = realtimeModelCatalogCache.get(client);
236
- const entry = cache?.get(workspaceId);
237
- if (!entry || entry.state === "loading") return null;
238
- if (entry.expiresAt > now) return entry.models;
239
- cache?.delete(workspaceId);
240
- return null;
241
- }
242
- function pruneRealtimeModelCatalogCache(cache, now) {
243
- for (const [workspaceId, entry] of cache) {
244
- if (entry.state === "ready" && entry.expiresAt <= now) cache.delete(workspaceId);
245
- }
246
- while (cache.size >= REALTIME_MODEL_CATALOG_CACHE_MAX_WORKSPACES) {
247
- const oldestWorkspaceId = cache.keys().next().value;
248
- if (oldestWorkspaceId === void 0) return;
249
- cache.delete(oldestWorkspaceId);
250
- }
251
- }
252
- function loadRealtimeModelCatalog(client, workspaceId, signal) {
253
- const load = client.getWorkspaceRealtimeModelCatalog;
254
- if (!load) return null;
255
- if (signal?.aborted) {
256
- return Promise.reject(signal.reason ?? new DOMException("Request aborted", "AbortError"));
257
- }
258
- const now = Date.now();
259
- const cache = realtimeModelCatalogCacheFor(client);
260
- const entry = cache.get(workspaceId);
261
- if (entry?.state === "loading" && !entry.controller.signal.aborted) {
262
- return consumeRealtimeModelCatalog(entry, signal);
263
- }
264
- if (entry?.state === "ready" && entry.expiresAt > now) return Promise.resolve(entry.models);
265
- if (entry) cache.delete(workspaceId);
266
- pruneRealtimeModelCatalogCache(cache, now);
267
- const controller = new AbortController();
268
- const promise = load.call(client, workspaceId, { signal: controller.signal }).then((response) => response.models.map(toRealtimeModelOption)).then((models) => {
269
- const current = cache.get(workspaceId);
270
- if (current?.state === "loading" && current.promise === promise) {
271
- cache.delete(workspaceId);
272
- cache.set(workspaceId, {
273
- state: "ready",
274
- models,
275
- expiresAt: Date.now() + REALTIME_MODEL_CATALOG_CACHE_TTL_MS
276
- });
277
- }
278
- return models;
279
- }).catch((error) => {
280
- const current = cache.get(workspaceId);
281
- if (current?.state === "loading" && current.promise === promise) cache.delete(workspaceId);
282
- throw error;
283
- });
284
- const loading = {
285
- state: "loading",
286
- promise,
287
- controller,
288
- consumers: 0
289
- };
290
- cache.set(workspaceId, loading);
291
- return consumeRealtimeModelCatalog(loading, signal);
292
- }
293
- function consumeRealtimeModelCatalog(entry, signal) {
294
- entry.consumers += 1;
295
- return new Promise((resolve, reject) => {
296
- let released = false;
297
- const release = (abandoned) => {
298
- if (released) return;
299
- released = true;
300
- entry.consumers = Math.max(0, entry.consumers - 1);
301
- if (abandoned && entry.consumers === 0) {
302
- entry.controller.abort(
303
- signal?.reason ?? new DOMException("Request abandoned", "AbortError")
304
- );
305
- }
306
- };
307
- const onAbort = () => {
308
- release(true);
309
- reject(signal?.reason ?? new DOMException("Request aborted", "AbortError"));
310
- };
311
- signal?.addEventListener("abort", onAbort, { once: true });
312
- void entry.promise.then(resolve, reject).finally(() => {
313
- signal?.removeEventListener("abort", onAbort);
314
- release(false);
315
- });
316
- });
317
- }
318
- function codexRealtimeAdmissionAllowed(input) {
319
- return codexRealtimeAdmissionBlocker(input) === null;
320
- }
321
- function codexRealtimeAdmissionBlocker(input) {
322
- if (input.sessionStatus === "cancelled") return "This session was cancelled.";
323
- if (input.controlState !== "active") return "Resume this session before starting voice.";
324
- if (input.settlement !== null) return "Wait for the current session transition to finish.";
325
- if (!input.codexConnected) return "Connect Codex to use this voice model.";
326
- if (input.lifecycleActive) return "Voice is already active for this session.";
327
- return null;
328
- }
329
- function useSessionRealtime(options) {
330
- const { client, workspaceId } = useEmbeddedRealtimeSession({
331
- client: options.client,
332
- workspaceId: options.workspaceId
333
- });
334
- const model = options.model ?? CODEX_LIVE_MODEL.id;
335
- const audioRef = useRef(null);
336
- const controllerRef = useRef(null);
337
- const controllerModelRef = useRef(null);
338
- const modelContextProviderRef = useRef(options.getModelContext);
339
- modelContextProviderRef.current = options.getModelContext;
340
- const [snapshot, setSnapshot] = useState(() => ({
341
- status: hasStoredSessionRealtimeOwnerProof({
342
- workspaceId,
343
- sessionId: options.sessionId,
344
- model
345
- }) ? "recovering" : "idle",
346
- realtimeId: null,
347
- mode: null,
348
- bridge: null,
349
- microphone: "inactive",
350
- inputMuted: false,
351
- audibleOutput: "inactive",
352
- outputMuted: false,
353
- connectionGeneration: 0,
354
- reconnectAttempt: 0,
355
- diagnostic: null,
356
- error: null
357
- }));
358
- const lifecycle = useMemo(
359
- () => projectSessionRealtimeLifecycle(options.events),
360
- [options.events]
361
- );
362
- const lifecycleRef = useRef(lifecycle);
363
- const eventsReadyRef = useRef(options.eventsReady);
364
- lifecycleRef.current = lifecycle;
365
- eventsReadyRef.current = options.eventsReady;
366
- const lifecycleActive = sessionRealtimeLifecycleIsActive(lifecycle);
367
- useEffect(() => {
368
- let disposed = false;
369
- let controller = null;
370
- let unsubscribe = null;
371
- void import("@opengeni/sdk/realtime").then(({ createSessionRealtimeController }) => {
372
- if (disposed) return;
373
- const controllerFactory = options.controllerFactory ?? createSessionRealtimeController;
374
- controller = controllerFactory({
375
- client,
376
- workspaceId,
377
- sessionId: options.sessionId,
378
- ...audioRef.current ? { remoteAudio: audioRef.current } : {},
379
- model,
380
- getModelContext: () => modelContextProviderRef.current?.()
381
- });
382
- controllerRef.current = controller;
383
- controllerModelRef.current = model;
384
- unsubscribe = controller.subscribe(setSnapshot);
385
- if (eventsReadyRef.current) {
386
- void controller.observeLifecycle(lifecycleRef.current).catch(() => void 0);
387
- }
388
- }).catch((error) => {
389
- if (disposed) return;
390
- setSnapshot({
391
- status: "error",
392
- realtimeId: null,
393
- mode: null,
394
- bridge: null,
395
- microphone: "inactive",
396
- inputMuted: false,
397
- audibleOutput: "inactive",
398
- outputMuted: false,
399
- connectionGeneration: 0,
400
- reconnectAttempt: 0,
401
- diagnostic: {
402
- kind: "negotiation_failure",
403
- message: error instanceof Error ? error.message : "Codex realtime controller failed to load",
404
- recoverable: false,
405
- connectionGeneration: 0,
406
- attempt: 0
407
- },
408
- error: error instanceof Error ? error.message : "Codex realtime controller failed to load"
409
- });
410
- });
411
- return () => {
412
- disposed = true;
413
- unsubscribe?.();
414
- controller?.close();
415
- if (controllerRef.current === controller) {
416
- controllerRef.current = null;
417
- controllerModelRef.current = null;
418
- }
419
- };
420
- }, [client, model, options.controllerFactory, options.sessionId, workspaceId]);
421
- useEffect(() => {
422
- if (!options.eventsReady) return;
423
- void controllerRef.current?.observeLifecycle(lifecycle).catch(() => void 0);
424
- }, [lifecycle, options.eventsReady]);
425
- const start = useCallback(async () => {
426
- const controller = controllerRef.current;
427
- if (!controller || controllerModelRef.current !== model) {
428
- throw new Error("The selected voice model is still preparing");
429
- }
430
- await controller.start();
431
- }, [model]);
432
- const stop = useCallback(async () => {
433
- await controllerRef.current?.stop();
434
- }, []);
435
- const retry = useCallback(async () => {
436
- await controllerRef.current?.retry();
437
- }, []);
438
- const retryAudibleOutput = useCallback(async () => {
439
- await controllerRef.current?.retryAudibleOutput();
440
- }, []);
441
- const setInputMuted = useCallback((muted) => {
442
- controllerRef.current?.setInputMuted(muted);
443
- }, []);
444
- const setOutputMuted = useCallback((muted) => {
445
- controllerRef.current?.setOutputMuted(muted);
446
- }, []);
447
- const admissionInput = {
448
- sessionStatus: options.sessionStatus,
449
- controlState: options.effectiveControl.state,
450
- settlement: options.effectiveControl.settlement,
451
- codexConnected: options.modelAvailable ?? options.codexConnected,
452
- lifecycleActive
453
- };
454
- const admissionBlocker = options.modelAvailable === false ? options.modelUnavailableReason ?? "This voice model is unavailable." : codexRealtimeAdmissionBlocker(admissionInput);
455
- const canStart = controllerRef.current !== null && controllerModelRef.current === model && ["idle", "error"].includes(snapshot.status) && admissionBlocker === null;
456
- return {
457
- snapshot,
458
- lifecycleActive,
459
- canStart,
460
- admissionBlocker,
461
- codexConnected: options.codexConnected,
462
- audioRef,
463
- start,
464
- stop,
465
- retry,
466
- retryAudibleOutput,
467
- setInputMuted,
468
- setOutputMuted
469
- };
470
- }
471
- function sessionRealtimeLifecycleIsActive(lifecycle) {
472
- if (lifecycle?.state !== "active") return false;
473
- const leaseExpiresAt = Date.parse(lifecycle.leaseExpiresAt);
474
- return !Number.isFinite(leaseExpiresAt) || leaseExpiresAt > Date.now();
475
- }
476
- function SessionRealtimeControl(props) {
477
- const lifecycle = useMemo(() => projectSessionRealtimeLifecycle(props.events), [props.events]);
478
- const lifecycleActive = sessionRealtimeLifecycleIsActive(lifecycle);
479
- const selection = useRealtimeModelSelection({
480
- client: props.client,
481
- workspaceId: props.workspaceId,
482
- codexConnected: props.codexConnected,
483
- activeModel: lifecycleActive && lifecycle?.state === "active" ? lifecycle.model : null
484
- });
485
- const selectedModel = selection.selectedModel;
486
- const realtime = useSessionRealtime({
487
- ...props,
488
- model: selectedModel.id,
489
- modelAvailable: selectedModel.available,
490
- modelUnavailableReason: selectedModel.unavailableReason
491
- });
492
- const autostartModelRef = useRef(props.realtimeAutostartModel ?? null);
493
- const autostartStartedRef = useRef(false);
494
- const { models, selectedModel: selectedRealtimeModel, selectModel } = selection;
495
- const { canStart, start } = realtime;
496
- const onRealtimeAutostartConsumed = props.onRealtimeAutostartConsumed;
497
- const onVoiceActiveChange = props.onVoiceActiveChange;
498
- const voiceActive = realtime.snapshot.mode?.state === "active";
499
- useEffect(() => {
500
- onVoiceActiveChange?.(voiceActive);
501
- }, [onVoiceActiveChange, voiceActive]);
502
- useEffect(() => {
503
- const pending = autostartModelRef.current;
504
- if (!pending || autostartStartedRef.current || lifecycleActive) return;
505
- const available = models.some((model) => model.id === pending && model.available);
506
- if (!available) return;
507
- if (selectedRealtimeModel.id !== pending) {
508
- selectModel(pending);
509
- return;
510
- }
511
- if (!canStart) return;
512
- autostartStartedRef.current = true;
513
- void start().then(() => {
514
- autostartModelRef.current = null;
515
- onRealtimeAutostartConsumed?.();
516
- }).catch(() => {
517
- autostartStartedRef.current = false;
518
- });
519
- }, [
520
- canStart,
521
- lifecycleActive,
522
- models,
523
- props.sessionId,
524
- props.workspaceId,
525
- onRealtimeAutostartConsumed,
526
- selectModel,
527
- selectedRealtimeModel.id,
528
- start
529
- ]);
530
- return /* @__PURE__ */ jsx2(
531
- RealtimeVoiceControl,
532
- {
533
- snapshot: realtime.snapshot,
534
- canStart: realtime.canStart,
535
- admissionBlocker: realtime.admissionBlocker,
536
- modelAvailable: selectedModel.available,
537
- menuSide: "top",
538
- modelMenu: props.modelMenu ?? "split",
539
- showDiagnostics: props.showDiagnostics,
540
- audioRef: realtime.audioRef,
541
- selectedModel,
542
- models: selection.models,
543
- onSelectModel: realtime.lifecycleActive ? void 0 : selection.selectModel,
544
- onStart: realtime.start,
545
- onStop: realtime.stop,
546
- onRetry: realtime.retry,
547
- onRetryAudibleOutput: realtime.retryAudibleOutput,
548
- onSetInputMuted: realtime.setInputMuted,
549
- onSetOutputMuted: realtime.setOutputMuted
550
- }
551
- );
552
- }
553
- function useRealtimeModelSelection(options) {
554
- const { client, workspaceId } = useEmbeddedRealtimeSession({
555
- client: options.client,
556
- workspaceId: options.workspaceId
557
- });
558
- const activeModel = options.activeModel;
559
- const initialCachedCatalog = readCachedRealtimeModelCatalog(client, workspaceId);
560
- const [catalog, setCatalog] = useState(
561
- () => initialCachedCatalog ?? realtimeModelFallback(options.codexConnected)
562
- );
563
- const catalogScopeRef = useRef({
564
- client,
565
- workspaceId,
566
- source: initialCachedCatalog ? "cache" : "fallback"
567
- });
568
- const [selectedModelId, setSelectedModelId] = useState(() => {
569
- const preferred = readRealtimeModelPreference(workspaceId) ?? CODEX_LIVE_MODEL.id;
570
- if (!initialCachedCatalog) return preferred;
571
- if (initialCachedCatalog.some((model) => model.id === preferred && model.available)) {
572
- return preferred;
573
- }
574
- return initialCachedCatalog.find((model) => model.available)?.id ?? CODEX_LIVE_MODEL.id;
575
- });
576
- useEffect(() => {
577
- let disposed = false;
578
- const requestAbort = new AbortController();
579
- const applyCatalog = (models) => {
580
- catalogScopeRef.current = { client, workspaceId, source: "cache" };
581
- setCatalog(models);
582
- setSelectedModelId((current) => {
583
- if (models.some((model) => model.id === current && model.available)) return current;
584
- return models.find((model) => model.available)?.id ?? CODEX_LIVE_MODEL.id;
585
- });
586
- };
587
- const cached = readCachedRealtimeModelCatalog(client, workspaceId);
588
- if (cached) {
589
- const scope = catalogScopeRef.current;
590
- if (scope.client !== client || scope.workspaceId !== workspaceId || scope.source !== "cache") {
591
- applyCatalog(cached);
592
- }
593
- return;
594
- }
595
- const loading = loadRealtimeModelCatalog(client, workspaceId, requestAbort.signal);
596
- if (!loading) return;
597
- void loading.then((models) => {
598
- if (disposed) return;
599
- applyCatalog(models);
600
- }).catch(() => void 0);
601
- return () => {
602
- disposed = true;
603
- requestAbort.abort();
604
- };
605
- }, [client, workspaceId]);
606
- useEffect(() => {
607
- if (activeModel) setSelectedModelId(activeModel);
608
- }, [activeModel]);
609
- const selectedModel = catalog.find((model) => model.id === selectedModelId) ?? {
610
- ...CODEX_LIVE_MODEL,
611
- available: options.codexConnected,
612
- unavailableReason: options.codexConnected ? null : CODEX_LIVE_MODEL.unavailableReason
613
- };
614
- const selectModel = useCallback(
615
- (value) => {
616
- const model = catalog.find((candidate) => candidate.id === value);
617
- if (!model || !model.available || activeModel) return;
618
- setSelectedModelId(model.id);
619
- writeRealtimeModelPreference(workspaceId, model.id);
620
- },
621
- [activeModel, catalog, workspaceId]
622
- );
623
- return { models: catalog, selectedModel, selectModel };
624
- }
625
- var IDLE_REALTIME_SNAPSHOT = {
626
- status: "idle",
627
- realtimeId: null,
628
- mode: null,
629
- bridge: null,
630
- microphone: "inactive",
631
- inputMuted: false,
632
- audibleOutput: "inactive",
633
- outputMuted: false,
634
- connectionGeneration: 0,
635
- reconnectAttempt: 0,
636
- diagnostic: null,
637
- error: null
638
- };
639
- function NewSessionRealtimeControl(props) {
640
- if (props.models && props.selectedModel && props.onSelectModel) {
641
- return /* @__PURE__ */ jsx2(
642
- NewSessionRealtimeControlView,
643
- {
644
- ...props,
645
- selection: {
646
- models: props.models,
647
- selectedModel: props.selectedModel,
648
- selectModel: props.onSelectModel
649
- }
650
- }
651
- );
652
- }
653
- return /* @__PURE__ */ jsx2(NewSessionRealtimeControlWithInternalSelection, { ...props });
654
- }
655
- function NewSessionRealtimeControlWithInternalSelection(props) {
656
- const selection = useRealtimeModelSelection({
657
- client: props.client,
658
- workspaceId: props.workspaceId,
659
- codexConnected: props.codexConnected
660
- });
661
- return /* @__PURE__ */ jsx2(NewSessionRealtimeControlView, { ...props, selection });
662
- }
663
- function NewSessionRealtimeControlView(props) {
664
- const selection = props.selection;
665
- const audioRef = useRef(null);
666
- const [starting, setStarting] = useState(false);
667
- const [error, setError] = useState(null);
668
- const snapshot = useMemo(
669
- () => starting ? { ...IDLE_REALTIME_SNAPSHOT, status: "starting" } : error ? { ...IDLE_REALTIME_SNAPSHOT, status: "error", error } : IDLE_REALTIME_SNAPSHOT,
670
- [error, starting]
671
- );
672
- const canStart = selection.selectedModel.available && props.disabled !== true && !starting;
673
- const onStart = props.onStart;
674
- const selectedModelId = selection.selectedModel.id;
675
- const start = useCallback(async () => {
676
- if (!canStart) return;
677
- setStarting(true);
678
- setError(null);
679
- try {
680
- const started = await onStart(selectedModelId);
681
- if (!started) setError("The voice session could not be created.");
682
- } catch (cause) {
683
- setError(cause instanceof Error ? cause.message : String(cause));
684
- } finally {
685
- setStarting(false);
686
- }
687
- }, [canStart, onStart, selectedModelId]);
688
- return /* @__PURE__ */ jsx2(
689
- RealtimeVoiceControl,
690
- {
691
- snapshot,
692
- canStart,
693
- admissionBlocker: selection.selectedModel.unavailableReason ?? props.disabledReason ?? null,
694
- modelAvailable: selection.selectedModel.available,
695
- selectionDisabled: starting,
696
- menuSide: "bottom",
697
- modelMenu: props.modelMenu ?? "split",
698
- showDiagnostics: false,
699
- audioRef,
700
- selectedModel: selection.selectedModel,
701
- models: selection.models,
702
- onSelectModel: selection.selectModel,
703
- onStart: start,
704
- onStop: async () => void 0,
705
- onRetry: start,
706
- onRetryAudibleOutput: async () => void 0,
707
- onSetInputMuted: () => void 0,
708
- onSetOutputMuted: () => void 0
709
- }
710
- );
711
- }
712
- function RealtimeVoiceControl(props) {
713
- const reduceMotion = useReducedMotion();
714
- const selectedModel = props.selectedModel ?? {
715
- ...CODEX_LIVE_MODEL,
716
- available: props.modelAvailable,
717
- unavailableReason: props.modelAvailable ? null : CODEX_LIVE_MODEL.unavailableReason
718
- };
719
- const models = props.models ?? [selectedModel];
720
- const status = statusContent(
721
- props.snapshot,
722
- props.modelAvailable,
723
- props.canStart,
724
- props.admissionBlocker ?? null,
725
- selectedModel.label
726
- );
727
- const modeOwned = props.snapshot.mode?.state === "active";
728
- const retryConnection = modeOwned && props.snapshot.status !== "stopping" && props.snapshot.status !== "active" && props.snapshot.diagnostic?.recoverable === true;
729
- const audioBlocked = props.snapshot.audibleOutput === "blocked" && !props.snapshot.outputMuted;
730
- const mainDisabled = props.snapshot.status === "stopping" || props.snapshot.status === "lost_owner" || !modeOwned && !props.canStart || props.snapshot.status === "starting" && !modeOwned;
731
- const mainLabel = audioBlocked ? "Resume voice audio" : retryConnection ? "Retry voice connection" : modeOwned ? "End voice conversation" : `Start voice with ${selectedModel.label}`;
732
- const runMainAction = audioBlocked ? props.onRetryAudibleOutput : retryConnection ? props.onRetry : modeOwned ? props.onStop : props.onStart;
733
- const diagnosticsVisible = props.showDiagnostics ?? false;
734
- const modelMenu = props.modelMenu ?? "split";
735
- const showAttachedModelMenu = modelMenu === "split" || modelMenu === "split-desktop";
736
- const desktopOnlyModelMenu = modelMenu === "split-desktop";
737
- const [pickerOpen, setPickerOpen] = useState(false);
738
- const [pickerProvider, setPickerProvider] = useState(
739
- selectedModel.provider
740
- );
741
- const [pickerDirection, setPickerDirection] = useState(1);
742
- useEffect(() => {
743
- if (!pickerOpen) setPickerProvider(selectedModel.provider);
744
- }, [pickerOpen, selectedModel.provider]);
745
- return /* @__PURE__ */ jsxs2(
746
- "div",
747
- {
748
- role: "group",
749
- "aria-label": "Realtime voice",
750
- "data-picker-side": props.menuSide ?? "top",
751
- "data-model-menu": modelMenu,
752
- className: "og-realtime-control inline-flex shrink-0 items-center",
753
- children: [
754
- /* @__PURE__ */ jsx2("audio", { ref: props.audioRef, autoPlay: true, className: "hidden", "aria-hidden": "true" }),
755
- /* @__PURE__ */ jsx2(RealtimeComposerGlow, { phase: status.phase, reduceMotion: reduceMotion === true }),
756
- /* @__PURE__ */ jsx2(AnimatePresence, { initial: false, children: modeOwned ? /* @__PURE__ */ jsx2(
757
- motion.div,
758
- {
759
- "data-testid": "realtime-mute-controls",
760
- initial: reduceMotion ? false : { opacity: 0, width: 0 },
761
- animate: {
762
- opacity: 1,
763
- width: "auto",
764
- transition: reduceMotion ? { duration: 0 } : { delay: 0.3, duration: 0.48, ease: [0.22, 1, 0.36, 1] }
765
- },
766
- ...reduceMotion ? {} : {
767
- exit: {
768
- opacity: 0,
769
- width: 0,
770
- transition: { duration: 0.28, ease: [0.4, 0, 1, 1] }
771
- }
772
- },
773
- className: cn(
774
- "inline-flex shrink-0 items-center overflow-hidden",
775
- props.muteControlsClassName
776
- ),
777
- children: /* @__PURE__ */ jsxs2(
778
- motion.div,
779
- {
780
- className: "inline-flex items-center gap-0.5 pr-1",
781
- initial: reduceMotion ? false : { x: 18, opacity: 0 },
782
- animate: {
783
- x: 0,
784
- opacity: 1,
785
- transition: reduceMotion ? { duration: 0 } : {
786
- delay: 0.32,
787
- type: "spring",
788
- stiffness: 320,
789
- damping: 30,
790
- mass: 0.8
791
- }
792
- },
793
- ...reduceMotion ? {} : {
794
- exit: {
795
- x: 14,
796
- opacity: 0,
797
- transition: { duration: 0.22, ease: [0.4, 0, 1, 1] }
798
- }
799
- },
800
- children: [
801
- /* @__PURE__ */ jsx2(
802
- RealtimeMuteButton,
803
- {
804
- muted: props.snapshot.inputMuted,
805
- kind: "microphone",
806
- reduceMotion: reduceMotion === true,
807
- enterDelay: reduceMotion ? 0 : 0.34,
808
- onToggle: () => props.onSetInputMuted(!props.snapshot.inputMuted)
809
- }
810
- ),
811
- /* @__PURE__ */ jsx2(
812
- RealtimeMuteButton,
813
- {
814
- muted: props.snapshot.outputMuted,
815
- kind: "output",
816
- reduceMotion: reduceMotion === true,
817
- enterDelay: reduceMotion ? 0 : 0.4,
818
- onToggle: () => props.onSetOutputMuted(!props.snapshot.outputMuted)
819
- }
820
- )
821
- ]
822
- }
823
- )
824
- },
825
- "realtime-mute-controls"
826
- ) : null }),
827
- /* @__PURE__ */ jsxs2("div", { className: "inline-flex shrink-0 items-center", children: [
828
- /* @__PURE__ */ jsx2(
829
- motion.button,
830
- {
831
- type: "button",
832
- "data-testid": "realtime-primary-action",
833
- "data-phase": status.phase,
834
- "aria-label": mainLabel,
835
- "aria-pressed": modeOwned,
836
- title: mainLabel,
837
- disabled: mainDisabled,
838
- ...reduceMotion ? {} : { whileTap: { scale: 0.92 } },
839
- transition: { type: "spring", stiffness: 520, damping: 30 },
840
- onClick: () => void runMainAction().catch(() => void 0),
841
- className: cn(
842
- // Match transcription mic: ghost icon when idle; filled only when live.
843
- // Public contract: coarse pointers keep a 44px target; split menu uses
844
- // left-only rounding at `sm+` where the chevron attaches.
845
- "og-realtime-primary relative inline-flex size-8 items-center justify-center outline-hidden",
846
- "rounded-og-md transition-[background-color,border-color,color,box-shadow] duration-200 ease-og-out",
847
- "focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-og-accent/45",
848
- "disabled:cursor-not-allowed disabled:opacity-45 pointer-coarse:size-11",
849
- showAttachedModelMenu && (desktopOnlyModelMenu ? "sm:rounded-l-og-md sm:rounded-r-none" : "rounded-l-og-md rounded-r-none"),
850
- voiceButtonTone(status.phase)
851
- ),
852
- children: /* @__PURE__ */ jsx2(
853
- RealtimeActionGlyph,
854
- {
855
- phase: status.phase,
856
- audioBlocked,
857
- reduceMotion: reduceMotion === true
858
- }
859
- )
860
- }
861
- ),
862
- showAttachedModelMenu ? /* @__PURE__ */ jsxs2(DropdownMenu, { open: pickerOpen, onOpenChange: setPickerOpen, children: [
863
- /* @__PURE__ */ jsx2(DropdownMenuTrigger, { asChild: true, children: /* @__PURE__ */ jsx2(
864
- "button",
865
- {
866
- type: "button",
867
- "aria-label": "Choose voice model and options",
868
- title: `Voice model: ${selectedModel.label}`,
869
- disabled: props.selectionDisabled,
870
- className: cn(
871
- // Keep the split trigger compact on desktop while preserving a
872
- // full 44px mobile target independent of pointer-media support.
873
- "og-realtime-model-trigger inline-flex h-11 w-11 items-center justify-center rounded-r-og-md outline-hidden sm:h-8 sm:w-6",
874
- "transition-[background-color,border-color,color] duration-200 ease-og-out",
875
- "focus-visible:z-10 focus-visible:ring-2 focus-visible:ring-og-accent/45",
876
- desktopOnlyModelMenu && "hidden sm:inline-flex",
877
- voiceChevronTone(status.phase)
878
- ),
879
- children: /* @__PURE__ */ jsx2(ChevronDownIcon, { className: "size-3", "aria-hidden": true })
880
- }
881
- ) }),
882
- /* @__PURE__ */ jsxs2(
883
- DropdownMenuContent,
884
- {
885
- side: props.menuSide ?? "top",
886
- align: "end",
887
- sideOffset: 8,
888
- collisionPadding: 12,
889
- className: "og-realtime-menu flex w-72 max-h-[min(20rem,var(--radix-dropdown-menu-content-available-height))] flex-col overflow-hidden",
890
- onCloseAutoFocus: (event) => event.preventDefault(),
891
- children: [
892
- /* @__PURE__ */ jsx2("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: /* @__PURE__ */ jsx2(
893
- RealtimeModelPickerMenu,
894
- {
895
- models,
896
- selectedModel,
897
- provider: pickerProvider,
898
- direction: pickerDirection,
899
- disabled: props.selectionDisabled === true || props.snapshot.mode?.state === "active",
900
- onProviderChange: (provider, direction) => {
901
- setPickerDirection(direction);
902
- setPickerProvider(provider);
903
- },
904
- onSelect: (modelId) => {
905
- props.onSelectModel?.(modelId);
906
- setPickerOpen(false);
907
- }
908
- }
909
- ) }),
910
- status.phase !== "idle" && // Say it once: the selected model's row already carries its reason.
911
- !(status.phase === "unavailable" && pickerProvider === selectedModel.provider && selectedModel.unavailableReason === status.detail) ? /* @__PURE__ */ jsxs2(Fragment, { children: [
912
- /* @__PURE__ */ jsx2(DropdownMenuSeparator, {}),
913
- /* @__PURE__ */ jsxs2("div", { className: "px-2.5 py-2", role: "status", "aria-live": "polite", children: [
914
- /* @__PURE__ */ jsxs2("div", { className: "flex items-center gap-2 text-og-sm font-medium text-og-fg", children: [
915
- /* @__PURE__ */ jsx2(
916
- RealtimeStatusDot,
917
- {
918
- phase: status.phase,
919
- reduceMotion: reduceMotion === true
920
- }
921
- ),
922
- status.label
923
- ] }),
924
- /* @__PURE__ */ jsx2("p", { className: "mt-1 text-og-xs leading-5 text-og-fg-subtle", children: status.detail })
925
- ] })
926
- ] }) : null,
927
- audioBlocked ? /* @__PURE__ */ jsxs2(
928
- DropdownMenuItem,
929
- {
930
- onSelect: () => void props.onRetryAudibleOutput().catch(() => void 0),
931
- children: [
932
- /* @__PURE__ */ jsx2(Volume2Icon, {}),
933
- "Resume audio"
934
- ]
935
- }
936
- ) : null,
937
- retryConnection ? /* @__PURE__ */ jsxs2(DropdownMenuItem, { onSelect: () => void props.onRetry().catch(() => void 0), children: [
938
- /* @__PURE__ */ jsx2(RotateCcwIcon, {}),
939
- "Retry connection"
940
- ] }) : null,
941
- modeOwned && props.snapshot.status !== "lost_owner" ? /* @__PURE__ */ jsxs2(
942
- DropdownMenuItem,
943
- {
944
- variant: "destructive",
945
- disabled: props.snapshot.status === "stopping",
946
- onSelect: () => void props.onStop().catch(() => void 0),
947
- children: [
948
- /* @__PURE__ */ jsx2(SquareIcon, {}),
949
- "End voice conversation"
950
- ]
951
- }
952
- ) : null,
953
- diagnosticsVisible ? /* @__PURE__ */ jsx2(RealtimeDiagnosticsMenu, { snapshot: props.snapshot }) : null
954
- ]
955
- }
956
- )
957
- ] }) : null
958
- ] }),
959
- /* @__PURE__ */ jsxs2("span", { className: "sr-only", role: "status", "aria-live": "polite", children: [
960
- status.label,
961
- ". ",
962
- status.detail
963
- ] }),
964
- props.snapshot.error ? /* @__PURE__ */ jsx2("span", { className: "sr-only", role: "alert", children: props.snapshot.error }) : null
965
- ]
966
- }
967
- );
968
- }
969
- function RealtimeVoiceModelPanel(props) {
970
- const [provider, setProvider] = useState(null);
971
- const [direction, setDirection] = useState(1);
972
- return /* @__PURE__ */ jsxs2("div", { className: "flex min-h-0 flex-1 flex-col", "data-testid": "realtime-voice-model-panel", children: [
973
- /* @__PURE__ */ jsxs2("div", { className: "flex min-h-10 shrink-0 items-center gap-2 border-b border-og-border px-2 pb-2", children: [
974
- props.leading,
975
- /* @__PURE__ */ jsx2("div", { className: "min-w-0 flex-1 text-og-menu font-medium text-og-fg", children: "Voice model" })
976
- ] }),
977
- /* @__PURE__ */ jsxs2("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain p-2", children: [
978
- /* @__PURE__ */ jsx2("p", { className: "mb-3 text-og-control text-og-fg-muted", children: "Used when you start a voice conversation." }),
979
- /* @__PURE__ */ jsx2(
980
- RealtimeModelPickerMenu,
981
- {
982
- models: props.models,
983
- selectedModel: props.selectedModel,
984
- provider,
985
- direction,
986
- disabled: props.disabled === true,
987
- onProviderChange: (next, nextDirection) => {
988
- setDirection(nextDirection);
989
- setProvider(next);
990
- },
991
- onSelect: props.onSelect
992
- }
993
- )
994
- ] })
995
- ] });
996
- }
997
- function RealtimeMuteButton(props) {
998
- const microphone = props.kind === "microphone";
999
- const label = microphone ? props.muted ? "Unmute microphone" : "Mute microphone" : props.muted ? "Unmute voice audio" : "Mute voice audio";
1000
- const Icon = microphone ? props.muted ? MicOffIcon : MicIcon : props.muted ? VolumeXIcon : Volume2Icon;
1001
- return /* @__PURE__ */ jsx2(
1002
- motion.button,
1003
- {
1004
- type: "button",
1005
- "aria-label": label,
1006
- "aria-pressed": props.muted,
1007
- title: label,
1008
- initial: props.reduceMotion ? false : { scale: 0.72, opacity: 0 },
1009
- animate: { scale: 1, opacity: 1 },
1010
- transition: {
1011
- delay: props.enterDelay ?? 0,
1012
- type: "spring",
1013
- stiffness: 420,
1014
- damping: 26,
1015
- mass: 0.7
1016
- },
1017
- ...props.reduceMotion ? {} : { whileTap: { scale: 0.92 } },
1018
- onClick: props.onToggle,
1019
- className: cn(
1020
- "inline-flex size-8 shrink-0 items-center justify-center rounded-og-md outline-hidden",
1021
- "transition-[background-color,border-color,color] duration-150 ease-og-out",
1022
- "focus-visible:ring-2 focus-visible:ring-og-accent/45 pointer-coarse:size-11",
1023
- props.muted ? "border border-og-accent/35 bg-og-accent-soft text-og-accent" : "text-og-fg-muted hover:bg-og-surface-2 hover:text-og-fg"
1024
- ),
1025
- children: /* @__PURE__ */ jsx2(Icon, { className: "size-3.5", "aria-hidden": true })
1026
- }
1027
- );
1028
- }
1029
- function RealtimeModelPickerMenu(props) {
1030
- const providers = REALTIME_MODEL_PROVIDERS.filter(
1031
- (provider) => props.models.some((model) => model.provider === provider)
1032
- );
1033
- const pageKey = props.provider ? `voice-models:${props.provider}` : "voice-providers";
1034
- const body = props.provider ? /* @__PURE__ */ jsxs2("div", { "data-testid": "realtime-model-picker-models", children: [
1035
- /* @__PURE__ */ jsx2(
1036
- PickerBackHeader,
1037
- {
1038
- label: props.provider,
1039
- icon: /* @__PURE__ */ jsx2(
1040
- BillingClassMark,
1041
- {
1042
- billingClass: REALTIME_PROVIDER_META[props.provider].billingClass,
1043
- "aria-label": ""
1044
- }
1045
- ),
1046
- onBack: () => props.onProviderChange(null, -1)
1047
- }
1048
- ),
1049
- /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-0.5", children: props.models.filter((model) => model.provider === props.provider).map((model) => {
1050
- const selected = model.id === props.selectedModel.id;
1051
- return /* @__PURE__ */ jsx2(
1052
- PickerNavRow,
1053
- {
1054
- label: model.label,
1055
- hint: model.unavailableReason ?? (model.recommended ? `Recommended \xB7 ${model.description}` : model.description),
1056
- disabled: props.disabled || !model.available,
1057
- title: model.unavailableReason ?? model.description,
1058
- active: selected,
1059
- showChevron: false,
1060
- trailing: selected ? /* @__PURE__ */ jsx2(CheckIcon, { className: MENU_CHECK_CLASS, "aria-hidden": true }) : void 0,
1061
- testId: `realtime-model-choice-${model.id}`,
1062
- onClick: () => props.onSelect(model.id)
1063
- },
1064
- model.id
1065
- );
1066
- }) })
1067
- ] }) : /* @__PURE__ */ jsx2("div", { className: "flex flex-col gap-0.5", "data-testid": "realtime-model-picker-providers", children: providers.map((provider) => {
1068
- const meta = REALTIME_PROVIDER_META[provider];
1069
- return /* @__PURE__ */ jsx2(
1070
- PickerNavRow,
1071
- {
1072
- label: provider,
1073
- hint: meta.hint,
1074
- icon: /* @__PURE__ */ jsx2(BillingClassMark, { billingClass: meta.billingClass, "aria-label": "" }),
1075
- active: props.selectedModel.provider === provider,
1076
- testId: `realtime-model-provider-${meta.billingClass}`,
1077
- onClick: () => props.onProviderChange(provider, 1)
1078
- },
1079
- provider
1080
- );
1081
- }) });
1082
- return /* @__PURE__ */ jsx2("div", { className: "relative overflow-hidden", "data-testid": "realtime-model-picker-menu", children: /* @__PURE__ */ jsx2(PickerAnimatedPage, { pageKey, direction: props.direction, children: body }) });
1083
- }
1084
- function RealtimeDiagnosticsMenu({ snapshot }) {
1085
- const bridge = snapshot.bridge;
1086
- const rows = [
1087
- ["controller", snapshot.status],
1088
- ["microphone", snapshot.microphone],
1089
- ["microphone muted", String(snapshot.inputMuted)],
1090
- ["audio", snapshot.audibleOutput],
1091
- ["audio muted", String(snapshot.outputMuted)],
1092
- ["generation", String(snapshot.connectionGeneration)],
1093
- ["reconnect attempt", String(snapshot.reconnectAttempt)],
1094
- ["mode", snapshot.mode?.state ?? "none"],
1095
- ["mode version", snapshot.mode ? String(snapshot.mode.version) : "\u2014"],
1096
- ["connection epoch", snapshot.mode ? String(snapshot.mode.connectionEpoch) : "\u2014"],
1097
- ["provider started", bridge ? String(bridge.providerStarted) : "false"],
1098
- ["provider speaking", bridge ? String(bridge.speaking) : "false"],
1099
- ["delegation", bridge?.activeDelegationId ? "active" : "none"],
1100
- ["pending durable events", bridge ? String(bridge.pendingInbound) : "0"],
1101
- ["pending bytes", bridge ? String(bridge.pendingInboundBytes) : "0"],
1102
- ["client ack", bridge?.clientAckThroughSequence?.toString() ?? "\u2014"],
1103
- ["ignored provider events", bridge ? String(bridge.ignoredEventCount) : "0"],
1104
- ["last ignored event", bridge?.lastIgnoredEventType ?? "none"],
1105
- ["bridge error", bridge?.lastError ?? "none"],
1106
- ["diagnostic", snapshot.diagnostic?.kind ?? "none"]
1107
- ];
1108
- return /* @__PURE__ */ jsxs2(Fragment, { children: [
1109
- /* @__PURE__ */ jsx2(DropdownMenuSeparator, {}),
1110
- /* @__PURE__ */ jsxs2(DropdownMenuSub, { children: [
1111
- /* @__PURE__ */ jsx2(DropdownMenuSubTrigger, { className: "text-og-fg-muted", children: "Realtime diagnostics" }),
1112
- /* @__PURE__ */ jsx2(DropdownMenuSubContent, { className: "max-h-80 w-72 overflow-y-auto", children: rows.map(([label, value]) => /* @__PURE__ */ jsxs2(
1113
- DropdownMenuItem,
1114
- {
1115
- disabled: true,
1116
- className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-3 rounded-og-md font-mono text-[11px] opacity-100",
1117
- children: [
1118
- /* @__PURE__ */ jsx2("span", { className: "truncate text-og-fg-subtle", children: label }),
1119
- /* @__PURE__ */ jsx2("span", { className: "truncate text-right text-og-fg", children: value })
1120
- ]
1121
- },
1122
- label
1123
- )) })
1124
- ] })
1125
- ] });
1126
- }
1127
- function statusContent(snapshot, modelAvailable, canStart, admissionBlocker, modelLabel) {
1128
- if (snapshot.audibleOutput === "blocked" && !snapshot.outputMuted) {
1129
- return {
1130
- phase: "blocked",
1131
- label: "Audio output blocked",
1132
- detail: "Resume audio to hear the existing voice connection."
1133
- };
1134
- }
1135
- switch (snapshot.status) {
1136
- case "starting":
1137
- return {
1138
- phase: "connecting",
1139
- label: "Connecting\u2026",
1140
- detail: "Preparing your microphone and live voice."
1141
- };
1142
- case "active":
1143
- return snapshot.bridge?.speaking ? {
1144
- phase: "speaking",
1145
- label: "Speaking",
1146
- detail: "Interrupt naturally whenever you want."
1147
- } : {
1148
- phase: "listening",
1149
- label: "Listening",
1150
- detail: "Voice and typed messages share this session."
1151
- };
1152
- case "stopping":
1153
- return {
1154
- phase: "stopping",
1155
- label: "Ending voice\u2026",
1156
- detail: "Saving the remaining conversation context."
1157
- };
1158
- case "recovering":
1159
- return {
1160
- phase: "reconnecting",
1161
- label: "Reconnecting\u2026",
1162
- detail: snapshot.error ?? "Keeping this voice conversation connected."
1163
- };
1164
- case "lost_owner":
1165
- return {
1166
- phase: "elsewhere",
1167
- label: "Voice active elsewhere",
1168
- detail: "Return to the browser that started it, or wait for that connection to expire."
1169
- };
1170
- case "error":
1171
- return {
1172
- phase: "error",
1173
- label: "Voice unavailable",
1174
- detail: snapshot.error ?? "The connection could not be started."
1175
- };
1176
- case "idle":
1177
- if (!modelAvailable) {
1178
- return {
1179
- phase: "unavailable",
1180
- label: "Voice model unavailable",
1181
- detail: admissionBlocker ?? "Choose another voice model."
1182
- };
1183
- }
1184
- if (!canStart && admissionBlocker) {
1185
- return {
1186
- phase: "unavailable",
1187
- label: "Voice unavailable",
1188
- detail: admissionBlocker
1189
- };
1190
- }
1191
- return {
1192
- phase: "idle",
1193
- label: "Start voice",
1194
- detail: `Talk live with ${modelLabel}.`
1195
- };
1196
- }
1197
- }
1198
- function RealtimeComposerGlow(props) {
1199
- const visible = [
1200
- "connecting",
1201
- "listening",
1202
- "speaking",
1203
- "reconnecting",
1204
- "blocked",
1205
- "error",
1206
- "stopping"
1207
- ].includes(props.phase);
1208
- return /* @__PURE__ */ jsx2(AnimatePresence, { initial: false, children: visible ? /* @__PURE__ */ jsx2(
1209
- motion.span,
1210
- {
1211
- "aria-hidden": true,
1212
- initial: { opacity: 0 },
1213
- animate: props.reduceMotion ? { opacity: 0.48 } : props.phase === "speaking" ? { opacity: [0.42, 0.82, 0.52] } : props.phase === "listening" ? { opacity: [0.34, 0.62, 0.42] } : { opacity: [0.28, 0.58, 0.28] },
1214
- exit: { opacity: 0 },
1215
- transition: props.reduceMotion ? { duration: 0.12 } : {
1216
- duration: props.phase === "speaking" ? 1.15 : 2.1,
1217
- ease: "easeInOut",
1218
- repeat: Number.POSITIVE_INFINITY
1219
- },
1220
- className: cn(
1221
- "pointer-events-none absolute -inset-px z-[1] rounded-og-lg ring-1 ring-inset shadow-og-glow",
1222
- props.phase === "speaking" ? "ring-og-status-running/50" : props.phase === "blocked" || props.phase === "error" ? "ring-og-status-waiting/45" : "ring-og-accent/45"
1223
- )
1224
- },
1225
- props.phase
1226
- ) : null });
1227
- }
1228
- function RealtimeActionGlyph(props) {
1229
- if (["connecting", "reconnecting", "stopping"].includes(props.phase)) {
1230
- return /* @__PURE__ */ jsx2(LoaderCircleIcon, { className: "size-3.5 animate-og-spin", "aria-hidden": true });
1231
- }
1232
- if (props.phase === "blocked") {
1233
- return props.audioBlocked ? /* @__PURE__ */ jsx2(Volume2Icon, { className: "size-3.5", "aria-hidden": true }) : /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-3.5", "aria-hidden": true });
1234
- }
1235
- if (props.phase === "error" || props.phase === "elsewhere" || props.phase === "unavailable") {
1236
- return /* @__PURE__ */ jsx2(CircleAlertIcon, { className: "size-3.5", "aria-hidden": true });
1237
- }
1238
- if (props.phase === "listening" || props.phase === "speaking") {
1239
- return /* @__PURE__ */ jsxs2("span", { className: "relative inline-flex size-4 items-center justify-center", children: [
1240
- !props.reduceMotion ? /* @__PURE__ */ jsx2(
1241
- motion.span,
1242
- {
1243
- "aria-hidden": true,
1244
- className: "absolute inset-0 rounded-full border border-current",
1245
- animate: { opacity: [0.65, 0], scale: [0.65, 1.45] },
1246
- transition: {
1247
- duration: props.phase === "speaking" ? 0.9 : 1.5,
1248
- ease: "easeOut",
1249
- repeat: Number.POSITIVE_INFINITY
1250
- }
1251
- }
1252
- ) : null,
1253
- /* @__PURE__ */ jsx2(SquareIcon, { className: "relative size-2.5 fill-current", "aria-hidden": true })
1254
- ] });
1255
- }
1256
- return /* @__PURE__ */ jsx2(AudioLinesIcon, { className: "size-4", "aria-hidden": true });
1257
- }
1258
- function RealtimeStatusDot(props) {
1259
- const live = props.phase === "listening" || props.phase === "speaking";
1260
- return /* @__PURE__ */ jsxs2("span", { className: "relative inline-flex size-2 shrink-0", "aria-hidden": true, children: [
1261
- live && !props.reduceMotion ? /* @__PURE__ */ jsx2(
1262
- motion.span,
1263
- {
1264
- className: "absolute inset-0 rounded-full bg-og-status-running",
1265
- animate: { opacity: [0.45, 0], scale: [1, 2.2] },
1266
- transition: {
1267
- duration: 1.4,
1268
- ease: "easeOut",
1269
- repeat: Number.POSITIVE_INFINITY
1270
- }
1271
- }
1272
- ) : null,
1273
- /* @__PURE__ */ jsx2(
1274
- "span",
1275
- {
1276
- className: cn(
1277
- "relative size-2 rounded-full",
1278
- live ? "bg-og-status-running" : props.phase === "blocked" || props.phase === "error" ? "bg-og-status-waiting" : props.phase === "elsewhere" || props.phase === "unavailable" ? "bg-og-fg-subtle" : "bg-og-accent"
1279
- )
1280
- }
1281
- )
1282
- ] });
1283
- }
1284
- function voiceButtonTone(phase) {
1285
- if (phase === "listening" || phase === "speaking") {
1286
- return "border border-og-primary-border bg-og-primary text-og-primary-fg hover:bg-og-primary-hover";
1287
- }
1288
- if (phase === "blocked" || phase === "error") {
1289
- return "border border-og-status-waiting/35 bg-og-status-waiting/10 text-og-status-waiting hover:bg-og-status-waiting/15";
1290
- }
1291
- if (phase === "connecting" || phase === "reconnecting" || phase === "stopping") {
1292
- return "border border-og-accent/35 bg-og-accent-soft text-og-accent";
1293
- }
1294
- return "text-og-fg-muted hover:bg-og-surface-2 hover:text-og-fg";
1295
- }
1296
- function voiceChevronTone(phase) {
1297
- if (phase === "listening" || phase === "speaking") {
1298
- return "border border-l-0 border-og-primary-border bg-og-primary text-og-primary-fg hover:bg-og-primary-hover";
1299
- }
1300
- if (phase === "blocked" || phase === "error") {
1301
- return "border border-l-0 border-og-status-waiting/35 bg-og-status-waiting/10 text-og-status-waiting hover:bg-og-status-waiting/15";
1302
- }
1303
- if (phase === "connecting" || phase === "reconnecting" || phase === "stopping") {
1304
- return "border border-l-0 border-og-accent/35 bg-og-accent-soft text-og-accent";
1305
- }
1306
- return "text-og-fg-muted hover:bg-og-surface-2 hover:text-og-fg";
1307
- }
1308
- function toRealtimeModelOption(model) {
1309
- return { ...model };
1310
- }
1311
- function readRealtimeModelPreference(workspaceId) {
1312
- if (typeof localStorage === "undefined") return null;
1313
- try {
1314
- const value = localStorage.getItem(`${REALTIME_MODEL_STORAGE_PREFIX}:${workspaceId}`);
1315
- return isRealtimeModel(value) ? value : null;
1316
- } catch {
1317
- return null;
1318
- }
1319
- }
1320
- function writeRealtimeModelPreference(workspaceId, model) {
1321
- if (typeof localStorage === "undefined") return;
1322
- try {
1323
- localStorage.setItem(`${REALTIME_MODEL_STORAGE_PREFIX}:${workspaceId}`, model);
1324
- } catch {
1325
- }
1326
- }
1327
- function isRealtimeModel(value) {
1328
- return value === "gpt-live-1-boulder-alpha" || value === "opengeni-gateway/openai/gpt-realtime-2.1" || value === "opengeni-gateway/openai/gpt-realtime-mini" || value === "opengeni-gateway/xai/grok-voice-think-fast-2.0" || value === "supergrok/grok-voice-think-fast-2.0" || value === "workspace-gateway/openai/gpt-realtime-2.1" || value === "workspace-gateway/openai/gpt-realtime-mini" || value === "workspace-gateway/xai/grok-voice-think-fast-2.0";
1329
- }
1330
- var useSessionCodexRealtime = useSessionRealtime;
1331
- var useWorkspaceRealtimeModelSelection = useRealtimeModelSelection;
1332
- var SessionCodexRealtimeControl = SessionRealtimeControl;
1333
- var CodexRealtimeControl = RealtimeVoiceControl;
3
+ CodexRealtimeControl,
4
+ NewSessionRealtimeControl,
5
+ RealtimeModelPickerMenu,
6
+ RealtimeVoiceControl,
7
+ RealtimeVoiceModelPanel,
8
+ SessionCodexRealtimeControl,
9
+ SessionRealtimeControl,
10
+ codexRealtimeAdmissionAllowed,
11
+ codexRealtimeAdmissionBlocker,
12
+ useRealtimeModelSelection,
13
+ useSessionCodexRealtime,
14
+ useSessionRealtime,
15
+ useWorkspaceRealtimeModelSelection
16
+ } from "./chunk-YVFRBXST.js";
17
+ import "./chunk-NX4ADH73.js";
18
+ import "./chunk-L2J3PU7A.js";
19
+ import "./chunk-PMV53IMM.js";
20
+ import "./chunk-XS67YG5R.js";
21
+ import "./chunk-XEA5BCMA.js";
22
+ import "./chunk-XTD7TZHW.js";
23
+ import "./chunk-TXS65BB2.js";
1334
24
  export {
1335
25
  CodexRealtimeControl,
1336
26
  NewSessionRealtimeControl,