@agent-native/toolkit 0.0.0-beta-20260819143124

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 (1070) hide show
  1. package/README.md +151 -0
  2. package/agent-native.eject.json +588 -0
  3. package/dist/app-shell/header-actions.d.ts +18 -0
  4. package/dist/app-shell/header-actions.d.ts.map +1 -0
  5. package/dist/app-shell/header-actions.js +52 -0
  6. package/dist/app-shell/header-actions.js.map +1 -0
  7. package/dist/app-shell/index.d.ts +3 -0
  8. package/dist/app-shell/index.d.ts.map +1 -0
  9. package/dist/app-shell/index.js +3 -0
  10. package/dist/app-shell/index.js.map +1 -0
  11. package/dist/app-shell/sidebar-footer-actions.d.ts +14 -0
  12. package/dist/app-shell/sidebar-footer-actions.d.ts.map +1 -0
  13. package/dist/app-shell/sidebar-footer-actions.js +10 -0
  14. package/dist/app-shell/sidebar-footer-actions.js.map +1 -0
  15. package/dist/app-shell/sidebar-footer-actions.spec.d.ts +2 -0
  16. package/dist/app-shell/sidebar-footer-actions.spec.d.ts.map +1 -0
  17. package/dist/app-shell/sidebar-footer-actions.spec.js +43 -0
  18. package/dist/app-shell/sidebar-footer-actions.spec.js.map +1 -0
  19. package/dist/canvas-annotations/CanvasCommentPins.d.ts +68 -0
  20. package/dist/canvas-annotations/CanvasCommentPins.d.ts.map +1 -0
  21. package/dist/canvas-annotations/CanvasCommentPins.js +513 -0
  22. package/dist/canvas-annotations/CanvasCommentPins.js.map +1 -0
  23. package/dist/canvas-annotations/DrawOverlay.d.ts +108 -0
  24. package/dist/canvas-annotations/DrawOverlay.d.ts.map +1 -0
  25. package/dist/canvas-annotations/DrawOverlay.js +746 -0
  26. package/dist/canvas-annotations/DrawOverlay.js.map +1 -0
  27. package/dist/canvas-annotations/DrawOverlay.spec.d.ts +2 -0
  28. package/dist/canvas-annotations/DrawOverlay.spec.d.ts.map +1 -0
  29. package/dist/canvas-annotations/DrawOverlay.spec.js +111 -0
  30. package/dist/canvas-annotations/DrawOverlay.spec.js.map +1 -0
  31. package/dist/canvas-annotations/index.d.ts +4 -0
  32. package/dist/canvas-annotations/index.d.ts.map +1 -0
  33. package/dist/canvas-annotations/index.js +3 -0
  34. package/dist/canvas-annotations/index.js.map +1 -0
  35. package/dist/canvas-annotations/types.d.ts +8 -0
  36. package/dist/canvas-annotations/types.d.ts.map +1 -0
  37. package/dist/canvas-annotations/types.js +2 -0
  38. package/dist/canvas-annotations/types.js.map +1 -0
  39. package/dist/canvas-interactions/canvas-interactions.d.ts +334 -0
  40. package/dist/canvas-interactions/canvas-interactions.d.ts.map +1 -0
  41. package/dist/canvas-interactions/canvas-interactions.js +486 -0
  42. package/dist/canvas-interactions/canvas-interactions.js.map +1 -0
  43. package/dist/canvas-interactions/canvas-interactions.spec.d.ts +2 -0
  44. package/dist/canvas-interactions/canvas-interactions.spec.d.ts.map +1 -0
  45. package/dist/canvas-interactions/canvas-interactions.spec.js +593 -0
  46. package/dist/canvas-interactions/canvas-interactions.spec.js.map +1 -0
  47. package/dist/canvas-interactions/index.d.ts +2 -0
  48. package/dist/canvas-interactions/index.d.ts.map +1 -0
  49. package/dist/canvas-interactions/index.js +2 -0
  50. package/dist/canvas-interactions/index.js.map +1 -0
  51. package/dist/chat-history/ChatHistoryList.d.ts +103 -0
  52. package/dist/chat-history/ChatHistoryList.d.ts.map +1 -0
  53. package/dist/chat-history/ChatHistoryList.js +102 -0
  54. package/dist/chat-history/ChatHistoryList.js.map +1 -0
  55. package/dist/chat-history/ChatHistoryList.spec.d.ts +2 -0
  56. package/dist/chat-history/ChatHistoryList.spec.d.ts.map +1 -0
  57. package/dist/chat-history/ChatHistoryList.spec.js +293 -0
  58. package/dist/chat-history/ChatHistoryList.spec.js.map +1 -0
  59. package/dist/chat-history/ChatHistoryRail.d.ts +33 -0
  60. package/dist/chat-history/ChatHistoryRail.d.ts.map +1 -0
  61. package/dist/chat-history/ChatHistoryRail.js +35 -0
  62. package/dist/chat-history/ChatHistoryRail.js.map +1 -0
  63. package/dist/chat-history/ChatHistoryRail.spec.d.ts +2 -0
  64. package/dist/chat-history/ChatHistoryRail.spec.d.ts.map +1 -0
  65. package/dist/chat-history/ChatHistoryRail.spec.js +157 -0
  66. package/dist/chat-history/ChatHistoryRail.spec.js.map +1 -0
  67. package/dist/chat-history/index.d.ts +4 -0
  68. package/dist/chat-history/index.d.ts.map +1 -0
  69. package/dist/chat-history/index.js +4 -0
  70. package/dist/chat-history/index.js.map +1 -0
  71. package/dist/chat-history/useChatHistoryRailController.d.ts +26 -0
  72. package/dist/chat-history/useChatHistoryRailController.d.ts.map +1 -0
  73. package/dist/chat-history/useChatHistoryRailController.js +36 -0
  74. package/dist/chat-history/useChatHistoryRailController.js.map +1 -0
  75. package/dist/chat-history/useChatHistoryRailController.spec.d.ts +2 -0
  76. package/dist/chat-history/useChatHistoryRailController.spec.d.ts.map +1 -0
  77. package/dist/chat-history/useChatHistoryRailController.spec.js +101 -0
  78. package/dist/chat-history/useChatHistoryRailController.spec.js.map +1 -0
  79. package/dist/chat-history.css +469 -0
  80. package/dist/collab-ui/AgentPresenceChip.d.ts +12 -0
  81. package/dist/collab-ui/AgentPresenceChip.d.ts.map +1 -0
  82. package/dist/collab-ui/AgentPresenceChip.js +42 -0
  83. package/dist/collab-ui/AgentPresenceChip.js.map +1 -0
  84. package/dist/collab-ui/LiveCursorOverlay.d.ts +46 -0
  85. package/dist/collab-ui/LiveCursorOverlay.d.ts.map +1 -0
  86. package/dist/collab-ui/LiveCursorOverlay.js +125 -0
  87. package/dist/collab-ui/LiveCursorOverlay.js.map +1 -0
  88. package/dist/collab-ui/PresenceBar.d.ts +30 -0
  89. package/dist/collab-ui/PresenceBar.d.ts.map +1 -0
  90. package/dist/collab-ui/PresenceBar.js +172 -0
  91. package/dist/collab-ui/PresenceBar.js.map +1 -0
  92. package/dist/collab-ui/PresenceBar.spec.d.ts +2 -0
  93. package/dist/collab-ui/PresenceBar.spec.d.ts.map +1 -0
  94. package/dist/collab-ui/PresenceBar.spec.js +30 -0
  95. package/dist/collab-ui/PresenceBar.spec.js.map +1 -0
  96. package/dist/collab-ui/RecentEditHighlights.d.ts +46 -0
  97. package/dist/collab-ui/RecentEditHighlights.d.ts.map +1 -0
  98. package/dist/collab-ui/RecentEditHighlights.js +154 -0
  99. package/dist/collab-ui/RecentEditHighlights.js.map +1 -0
  100. package/dist/collab-ui/RemoteSelectionRings.d.ts +53 -0
  101. package/dist/collab-ui/RemoteSelectionRings.d.ts.map +1 -0
  102. package/dist/collab-ui/RemoteSelectionRings.js +130 -0
  103. package/dist/collab-ui/RemoteSelectionRings.js.map +1 -0
  104. package/dist/collab-ui/agent-identity.d.ts +9 -0
  105. package/dist/collab-ui/agent-identity.d.ts.map +1 -0
  106. package/dist/collab-ui/agent-identity.js +9 -0
  107. package/dist/collab-ui/agent-identity.js.map +1 -0
  108. package/dist/collab-ui/index.d.ts +9 -0
  109. package/dist/collab-ui/index.d.ts.map +1 -0
  110. package/dist/collab-ui/index.js +9 -0
  111. package/dist/collab-ui/index.js.map +1 -0
  112. package/dist/collab-ui/lead-client.d.ts +3 -0
  113. package/dist/collab-ui/lead-client.d.ts.map +1 -0
  114. package/dist/collab-ui/lead-client.js +29 -0
  115. package/dist/collab-ui/lead-client.js.map +1 -0
  116. package/dist/collab-ui/types.d.ts +48 -0
  117. package/dist/collab-ui/types.d.ts.map +1 -0
  118. package/dist/collab-ui/types.js +52 -0
  119. package/dist/collab-ui/types.js.map +1 -0
  120. package/dist/collab-ui/types.spec.d.ts +2 -0
  121. package/dist/collab-ui/types.spec.d.ts.map +1 -0
  122. package/dist/collab-ui/types.spec.js +15 -0
  123. package/dist/collab-ui/types.spec.js.map +1 -0
  124. package/dist/composer/AgentComposerFrame.d.ts +19 -0
  125. package/dist/composer/AgentComposerFrame.d.ts.map +1 -0
  126. package/dist/composer/AgentComposerFrame.js +17 -0
  127. package/dist/composer/AgentComposerFrame.js.map +1 -0
  128. package/dist/composer/ComposerPlusMenu.d.ts +30 -0
  129. package/dist/composer/ComposerPlusMenu.d.ts.map +1 -0
  130. package/dist/composer/ComposerPlusMenu.js +635 -0
  131. package/dist/composer/ComposerPlusMenu.js.map +1 -0
  132. package/dist/composer/ComposerPlusMenu.spec.d.ts +2 -0
  133. package/dist/composer/ComposerPlusMenu.spec.d.ts.map +1 -0
  134. package/dist/composer/ComposerPlusMenu.spec.js +12 -0
  135. package/dist/composer/ComposerPlusMenu.spec.js.map +1 -0
  136. package/dist/composer/MentionPopover.d.ts +29 -0
  137. package/dist/composer/MentionPopover.d.ts.map +1 -0
  138. package/dist/composer/MentionPopover.js +221 -0
  139. package/dist/composer/MentionPopover.js.map +1 -0
  140. package/dist/composer/PastedTextChip.d.ts +9 -0
  141. package/dist/composer/PastedTextChip.d.ts.map +1 -0
  142. package/dist/composer/PastedTextChip.js +71 -0
  143. package/dist/composer/PastedTextChip.js.map +1 -0
  144. package/dist/composer/PastedTextChip.spec.d.ts +2 -0
  145. package/dist/composer/PastedTextChip.spec.d.ts.map +1 -0
  146. package/dist/composer/PastedTextChip.spec.js +42 -0
  147. package/dist/composer/PastedTextChip.spec.js.map +1 -0
  148. package/dist/composer/PromptComposer.d.ts +151 -0
  149. package/dist/composer/PromptComposer.d.ts.map +1 -0
  150. package/dist/composer/PromptComposer.js +322 -0
  151. package/dist/composer/PromptComposer.js.map +1 -0
  152. package/dist/composer/PromptComposer.spec.d.ts +2 -0
  153. package/dist/composer/PromptComposer.spec.d.ts.map +1 -0
  154. package/dist/composer/PromptComposer.spec.js +87 -0
  155. package/dist/composer/PromptComposer.spec.js.map +1 -0
  156. package/dist/composer/RealtimeVoiceMode.d.ts +108 -0
  157. package/dist/composer/RealtimeVoiceMode.d.ts.map +1 -0
  158. package/dist/composer/RealtimeVoiceMode.js +312 -0
  159. package/dist/composer/RealtimeVoiceMode.js.map +1 -0
  160. package/dist/composer/RealtimeVoiceMode.spec.d.ts +2 -0
  161. package/dist/composer/RealtimeVoiceMode.spec.d.ts.map +1 -0
  162. package/dist/composer/RealtimeVoiceMode.spec.js +540 -0
  163. package/dist/composer/RealtimeVoiceMode.spec.js.map +1 -0
  164. package/dist/composer/TiptapComposer.d.ts +288 -0
  165. package/dist/composer/TiptapComposer.d.ts.map +1 -0
  166. package/dist/composer/TiptapComposer.js +2233 -0
  167. package/dist/composer/TiptapComposer.js.map +1 -0
  168. package/dist/composer/TiptapComposer.spec.d.ts +2 -0
  169. package/dist/composer/TiptapComposer.spec.d.ts.map +1 -0
  170. package/dist/composer/TiptapComposer.spec.js +415 -0
  171. package/dist/composer/TiptapComposer.spec.js.map +1 -0
  172. package/dist/composer/VoiceButton.d.ts +27 -0
  173. package/dist/composer/VoiceButton.d.ts.map +1 -0
  174. package/dist/composer/VoiceButton.js +151 -0
  175. package/dist/composer/VoiceButton.js.map +1 -0
  176. package/dist/composer/VoiceButton.spec.d.ts +2 -0
  177. package/dist/composer/VoiceButton.spec.d.ts.map +1 -0
  178. package/dist/composer/VoiceButton.spec.js +27 -0
  179. package/dist/composer/VoiceButton.spec.js.map +1 -0
  180. package/dist/composer/asset-picker-url.d.ts +16 -0
  181. package/dist/composer/asset-picker-url.d.ts.map +1 -0
  182. package/dist/composer/asset-picker-url.js +64 -0
  183. package/dist/composer/asset-picker-url.js.map +1 -0
  184. package/dist/composer/asset-picker-url.spec.d.ts +2 -0
  185. package/dist/composer/asset-picker-url.spec.d.ts.map +1 -0
  186. package/dist/composer/asset-picker-url.spec.js +23 -0
  187. package/dist/composer/asset-picker-url.spec.js.map +1 -0
  188. package/dist/composer/attachment-accept.d.ts +9 -0
  189. package/dist/composer/attachment-accept.d.ts.map +1 -0
  190. package/dist/composer/attachment-accept.js +69 -0
  191. package/dist/composer/attachment-accept.js.map +1 -0
  192. package/dist/composer/attachment-accept.spec.d.ts +2 -0
  193. package/dist/composer/attachment-accept.spec.d.ts.map +1 -0
  194. package/dist/composer/attachment-accept.spec.js +24 -0
  195. package/dist/composer/attachment-accept.spec.js.map +1 -0
  196. package/dist/composer/draft-key.d.ts +2 -0
  197. package/dist/composer/draft-key.d.ts.map +1 -0
  198. package/dist/composer/draft-key.js +8 -0
  199. package/dist/composer/draft-key.js.map +1 -0
  200. package/dist/composer/draft-key.spec.d.ts +2 -0
  201. package/dist/composer/draft-key.spec.d.ts.map +1 -0
  202. package/dist/composer/draft-key.spec.js +13 -0
  203. package/dist/composer/draft-key.spec.js.map +1 -0
  204. package/dist/composer/extensions/FileReference.d.ts +3 -0
  205. package/dist/composer/extensions/FileReference.d.ts.map +1 -0
  206. package/dist/composer/extensions/FileReference.js +36 -0
  207. package/dist/composer/extensions/FileReference.js.map +1 -0
  208. package/dist/composer/extensions/MentionReference.d.ts +3 -0
  209. package/dist/composer/extensions/MentionReference.d.ts.map +1 -0
  210. package/dist/composer/extensions/MentionReference.js +66 -0
  211. package/dist/composer/extensions/MentionReference.js.map +1 -0
  212. package/dist/composer/extensions/SkillReference.d.ts +3 -0
  213. package/dist/composer/extensions/SkillReference.d.ts.map +1 -0
  214. package/dist/composer/extensions/SkillReference.js +40 -0
  215. package/dist/composer/extensions/SkillReference.js.map +1 -0
  216. package/dist/composer/index.d.ts +16 -0
  217. package/dist/composer/index.d.ts.map +1 -0
  218. package/dist/composer/index.js +14 -0
  219. package/dist/composer/index.js.map +1 -0
  220. package/dist/composer/model-selection.d.ts +12 -0
  221. package/dist/composer/model-selection.d.ts.map +1 -0
  222. package/dist/composer/model-selection.js +31 -0
  223. package/dist/composer/model-selection.js.map +1 -0
  224. package/dist/composer/model-selection.spec.d.ts +2 -0
  225. package/dist/composer/model-selection.spec.d.ts.map +1 -0
  226. package/dist/composer/model-selection.spec.js +38 -0
  227. package/dist/composer/model-selection.spec.js.map +1 -0
  228. package/dist/composer/pasted-text.d.ts +31 -0
  229. package/dist/composer/pasted-text.d.ts.map +1 -0
  230. package/dist/composer/pasted-text.js +130 -0
  231. package/dist/composer/pasted-text.js.map +1 -0
  232. package/dist/composer/pasted-text.spec.d.ts +2 -0
  233. package/dist/composer/pasted-text.spec.d.ts.map +1 -0
  234. package/dist/composer/pasted-text.spec.js +107 -0
  235. package/dist/composer/pasted-text.spec.js.map +1 -0
  236. package/dist/composer/prompt-attachments.d.ts +18 -0
  237. package/dist/composer/prompt-attachments.d.ts.map +1 -0
  238. package/dist/composer/prompt-attachments.js +65 -0
  239. package/dist/composer/prompt-attachments.js.map +1 -0
  240. package/dist/composer/prompt-attachments.spec.d.ts +2 -0
  241. package/dist/composer/prompt-attachments.spec.d.ts.map +1 -0
  242. package/dist/composer/prompt-attachments.spec.js +63 -0
  243. package/dist/composer/prompt-attachments.spec.js.map +1 -0
  244. package/dist/composer/realtime-voice-audio-level.d.ts +14 -0
  245. package/dist/composer/realtime-voice-audio-level.d.ts.map +1 -0
  246. package/dist/composer/realtime-voice-audio-level.js +48 -0
  247. package/dist/composer/realtime-voice-audio-level.js.map +1 -0
  248. package/dist/composer/realtime-voice-audio-level.spec.d.ts +2 -0
  249. package/dist/composer/realtime-voice-audio-level.spec.d.ts.map +1 -0
  250. package/dist/composer/realtime-voice-audio-level.spec.js +32 -0
  251. package/dist/composer/realtime-voice-audio-level.spec.js.map +1 -0
  252. package/dist/composer/realtime-voice-transcript.d.ts +26 -0
  253. package/dist/composer/realtime-voice-transcript.d.ts.map +1 -0
  254. package/dist/composer/realtime-voice-transcript.js +103 -0
  255. package/dist/composer/realtime-voice-transcript.js.map +1 -0
  256. package/dist/composer/realtime-voice-transcript.spec.d.ts +2 -0
  257. package/dist/composer/realtime-voice-transcript.spec.d.ts.map +1 -0
  258. package/dist/composer/realtime-voice-transcript.spec.js +76 -0
  259. package/dist/composer/realtime-voice-transcript.spec.js.map +1 -0
  260. package/dist/composer/runtime-adapters.d.ts +169 -0
  261. package/dist/composer/runtime-adapters.d.ts.map +1 -0
  262. package/dist/composer/runtime-adapters.js +141 -0
  263. package/dist/composer/runtime-adapters.js.map +1 -0
  264. package/dist/composer/runtime-adapters.spec.d.ts +2 -0
  265. package/dist/composer/runtime-adapters.spec.d.ts.map +1 -0
  266. package/dist/composer/runtime-adapters.spec.js +69 -0
  267. package/dist/composer/runtime-adapters.spec.js.map +1 -0
  268. package/dist/composer/types.d.ts +60 -0
  269. package/dist/composer/types.d.ts.map +1 -0
  270. package/dist/composer/types.js +2 -0
  271. package/dist/composer/types.js.map +1 -0
  272. package/dist/composer/use-file-search.d.ts +6 -0
  273. package/dist/composer/use-file-search.d.ts.map +1 -0
  274. package/dist/composer/use-file-search.js +53 -0
  275. package/dist/composer/use-file-search.js.map +1 -0
  276. package/dist/composer/use-mention-search.d.ts +6 -0
  277. package/dist/composer/use-mention-search.d.ts.map +1 -0
  278. package/dist/composer/use-mention-search.js +75 -0
  279. package/dist/composer/use-mention-search.js.map +1 -0
  280. package/dist/composer/use-skills.d.ts +7 -0
  281. package/dist/composer/use-skills.d.ts.map +1 -0
  282. package/dist/composer/use-skills.js +40 -0
  283. package/dist/composer/use-skills.js.map +1 -0
  284. package/dist/composer/useRealtimeVoiceMode.d.ts +189 -0
  285. package/dist/composer/useRealtimeVoiceMode.d.ts.map +1 -0
  286. package/dist/composer/useRealtimeVoiceMode.js +1899 -0
  287. package/dist/composer/useRealtimeVoiceMode.js.map +1 -0
  288. package/dist/composer/useRealtimeVoiceMode.spec.d.ts +2 -0
  289. package/dist/composer/useRealtimeVoiceMode.spec.d.ts.map +1 -0
  290. package/dist/composer/useRealtimeVoiceMode.spec.js +716 -0
  291. package/dist/composer/useRealtimeVoiceMode.spec.js.map +1 -0
  292. package/dist/composer/useVoiceDictation.browser.spec.d.ts +2 -0
  293. package/dist/composer/useVoiceDictation.browser.spec.d.ts.map +1 -0
  294. package/dist/composer/useVoiceDictation.browser.spec.js +220 -0
  295. package/dist/composer/useVoiceDictation.browser.spec.js.map +1 -0
  296. package/dist/composer/useVoiceDictation.d.ts +58 -0
  297. package/dist/composer/useVoiceDictation.d.ts.map +1 -0
  298. package/dist/composer/useVoiceDictation.js +1058 -0
  299. package/dist/composer/useVoiceDictation.js.map +1 -0
  300. package/dist/composer/useVoiceDictation.spec.d.ts +2 -0
  301. package/dist/composer/useVoiceDictation.spec.d.ts.map +1 -0
  302. package/dist/composer/useVoiceDictation.spec.js +32 -0
  303. package/dist/composer/useVoiceDictation.spec.js.map +1 -0
  304. package/dist/conformance/__fixtures__/css-in-js-adapter.d.ts +7 -0
  305. package/dist/conformance/__fixtures__/css-in-js-adapter.d.ts.map +1 -0
  306. package/dist/conformance/__fixtures__/css-in-js-adapter.js +84 -0
  307. package/dist/conformance/__fixtures__/css-in-js-adapter.js.map +1 -0
  308. package/dist/conformance/conformance.spec.d.ts +2 -0
  309. package/dist/conformance/conformance.spec.d.ts.map +1 -0
  310. package/dist/conformance/conformance.spec.js +87 -0
  311. package/dist/conformance/conformance.spec.js.map +1 -0
  312. package/dist/conformance/index.d.ts +4 -0
  313. package/dist/conformance/index.d.ts.map +1 -0
  314. package/dist/conformance/index.js +4 -0
  315. package/dist/conformance/index.js.map +1 -0
  316. package/dist/conformance/runner.d.ts +12 -0
  317. package/dist/conformance/runner.d.ts.map +1 -0
  318. package/dist/conformance/runner.js +515 -0
  319. package/dist/conformance/runner.js.map +1 -0
  320. package/dist/conformance/types.d.ts +26 -0
  321. package/dist/conformance/types.d.ts.map +1 -0
  322. package/dist/conformance/types.js +13 -0
  323. package/dist/conformance/types.js.map +1 -0
  324. package/dist/conformance/version.d.ts +6 -0
  325. package/dist/conformance/version.d.ts.map +1 -0
  326. package/dist/conformance/version.js +14 -0
  327. package/dist/conformance/version.js.map +1 -0
  328. package/dist/context-ui/ContextMeter.d.ts +11 -0
  329. package/dist/context-ui/ContextMeter.d.ts.map +1 -0
  330. package/dist/context-ui/ContextMeter.js +40 -0
  331. package/dist/context-ui/ContextMeter.js.map +1 -0
  332. package/dist/context-ui/ContextMeter.spec.d.ts +2 -0
  333. package/dist/context-ui/ContextMeter.spec.d.ts.map +1 -0
  334. package/dist/context-ui/ContextMeter.spec.js +52 -0
  335. package/dist/context-ui/ContextMeter.spec.js.map +1 -0
  336. package/dist/context-ui/ContextSegmentRow.d.ts +16 -0
  337. package/dist/context-ui/ContextSegmentRow.d.ts.map +1 -0
  338. package/dist/context-ui/ContextSegmentRow.js +92 -0
  339. package/dist/context-ui/ContextSegmentRow.js.map +1 -0
  340. package/dist/context-ui/ContextTreemap.d.ts +8 -0
  341. package/dist/context-ui/ContextTreemap.d.ts.map +1 -0
  342. package/dist/context-ui/ContextTreemap.js +58 -0
  343. package/dist/context-ui/ContextTreemap.js.map +1 -0
  344. package/dist/context-ui/ContextXRayPanel.d.ts +14 -0
  345. package/dist/context-ui/ContextXRayPanel.d.ts.map +1 -0
  346. package/dist/context-ui/ContextXRayPanel.js +209 -0
  347. package/dist/context-ui/ContextXRayPanel.js.map +1 -0
  348. package/dist/context-ui/format.d.ts +6 -0
  349. package/dist/context-ui/format.d.ts.map +1 -0
  350. package/dist/context-ui/format.js +58 -0
  351. package/dist/context-ui/format.js.map +1 -0
  352. package/dist/context-ui/index.d.ts +7 -0
  353. package/dist/context-ui/index.d.ts.map +1 -0
  354. package/dist/context-ui/index.js +6 -0
  355. package/dist/context-ui/index.js.map +1 -0
  356. package/dist/context-ui/types.d.ts +41 -0
  357. package/dist/context-ui/types.d.ts.map +1 -0
  358. package/dist/context-ui/types.js +8 -0
  359. package/dist/context-ui/types.js.map +1 -0
  360. package/dist/dashboard/DataTable.d.ts +20 -0
  361. package/dist/dashboard/DataTable.d.ts.map +1 -0
  362. package/dist/dashboard/DataTable.js +87 -0
  363. package/dist/dashboard/DataTable.js.map +1 -0
  364. package/dist/dashboard/DateRangePicker.d.ts +15 -0
  365. package/dist/dashboard/DateRangePicker.d.ts.map +1 -0
  366. package/dist/dashboard/DateRangePicker.js +15 -0
  367. package/dist/dashboard/DateRangePicker.js.map +1 -0
  368. package/dist/dashboard/GenericChartPanel.d.ts +57 -0
  369. package/dist/dashboard/GenericChartPanel.d.ts.map +1 -0
  370. package/dist/dashboard/GenericChartPanel.js +119 -0
  371. package/dist/dashboard/GenericChartPanel.js.map +1 -0
  372. package/dist/dashboard/GenericChartPanel.spec.d.ts +2 -0
  373. package/dist/dashboard/GenericChartPanel.spec.d.ts.map +1 -0
  374. package/dist/dashboard/GenericChartPanel.spec.js +41 -0
  375. package/dist/dashboard/GenericChartPanel.spec.js.map +1 -0
  376. package/dist/dashboard/MetricCard.d.ts +14 -0
  377. package/dist/dashboard/MetricCard.d.ts.map +1 -0
  378. package/dist/dashboard/MetricCard.js +10 -0
  379. package/dist/dashboard/MetricCard.js.map +1 -0
  380. package/dist/dashboard/StatsCard.d.ts +16 -0
  381. package/dist/dashboard/StatsCard.d.ts.map +1 -0
  382. package/dist/dashboard/StatsCard.js +8 -0
  383. package/dist/dashboard/StatsCard.js.map +1 -0
  384. package/dist/dashboard/dashboard-layout.d.ts +49 -0
  385. package/dist/dashboard/dashboard-layout.d.ts.map +1 -0
  386. package/dist/dashboard/dashboard-layout.js +231 -0
  387. package/dist/dashboard/dashboard-layout.js.map +1 -0
  388. package/dist/dashboard/dashboard-layout.spec.d.ts +2 -0
  389. package/dist/dashboard/dashboard-layout.spec.d.ts.map +1 -0
  390. package/dist/dashboard/dashboard-layout.spec.js +52 -0
  391. package/dist/dashboard/dashboard-layout.spec.js.map +1 -0
  392. package/dist/dashboard/index.d.ts +7 -0
  393. package/dist/dashboard/index.d.ts.map +1 -0
  394. package/dist/dashboard/index.js +7 -0
  395. package/dist/dashboard/index.js.map +1 -0
  396. package/dist/data-grid/DataGrid.d.ts +92 -0
  397. package/dist/data-grid/DataGrid.d.ts.map +1 -0
  398. package/dist/data-grid/DataGrid.js +315 -0
  399. package/dist/data-grid/DataGrid.js.map +1 -0
  400. package/dist/data-grid/DataGrid.spec.d.ts +2 -0
  401. package/dist/data-grid/DataGrid.spec.d.ts.map +1 -0
  402. package/dist/data-grid/DataGrid.spec.js +134 -0
  403. package/dist/data-grid/DataGrid.spec.js.map +1 -0
  404. package/dist/data-grid/index.d.ts +2 -0
  405. package/dist/data-grid/index.d.ts.map +1 -0
  406. package/dist/data-grid/index.js +2 -0
  407. package/dist/data-grid/index.js.map +1 -0
  408. package/dist/design-system/components.d.ts +58 -0
  409. package/dist/design-system/components.d.ts.map +1 -0
  410. package/dist/design-system/components.js +88 -0
  411. package/dist/design-system/components.js.map +1 -0
  412. package/dist/design-system/context.d.ts +11 -0
  413. package/dist/design-system/context.d.ts.map +1 -0
  414. package/dist/design-system/context.js +17 -0
  415. package/dist/design-system/context.js.map +1 -0
  416. package/dist/design-system/default-adapter.d.ts +3 -0
  417. package/dist/design-system/default-adapter.d.ts.map +1 -0
  418. package/dist/design-system/default-adapter.js +172 -0
  419. package/dist/design-system/default-adapter.js.map +1 -0
  420. package/dist/design-system/default-adapter.spec.d.ts +2 -0
  421. package/dist/design-system/default-adapter.spec.d.ts.map +1 -0
  422. package/dist/design-system/default-adapter.spec.js +108 -0
  423. package/dist/design-system/default-adapter.spec.js.map +1 -0
  424. package/dist/design-system/definition.d.ts +9 -0
  425. package/dist/design-system/definition.d.ts.map +1 -0
  426. package/dist/design-system/definition.js +4 -0
  427. package/dist/design-system/definition.js.map +1 -0
  428. package/dist/design-system/design-system.spec.d.ts +2 -0
  429. package/dist/design-system/design-system.spec.d.ts.map +1 -0
  430. package/dist/design-system/design-system.spec.js +208 -0
  431. package/dist/design-system/design-system.spec.js.map +1 -0
  432. package/dist/design-system/error-boundary.d.ts +18 -0
  433. package/dist/design-system/error-boundary.d.ts.map +1 -0
  434. package/dist/design-system/error-boundary.js +16 -0
  435. package/dist/design-system/error-boundary.js.map +1 -0
  436. package/dist/design-system/index.d.ts +8 -0
  437. package/dist/design-system/index.d.ts.map +1 -0
  438. package/dist/design-system/index.js +8 -0
  439. package/dist/design-system/index.js.map +1 -0
  440. package/dist/design-system/theme.d.ts +30 -0
  441. package/dist/design-system/theme.d.ts.map +1 -0
  442. package/dist/design-system/theme.js +95 -0
  443. package/dist/design-system/theme.js.map +1 -0
  444. package/dist/design-system/theme.spec.d.ts +2 -0
  445. package/dist/design-system/theme.spec.d.ts.map +1 -0
  446. package/dist/design-system/theme.spec.js +43 -0
  447. package/dist/design-system/theme.spec.js.map +1 -0
  448. package/dist/design-system/types.d.ts +292 -0
  449. package/dist/design-system/types.d.ts.map +1 -0
  450. package/dist/design-system/types.js +2 -0
  451. package/dist/design-system/types.js.map +1 -0
  452. package/dist/design-tweaks/index.d.ts +2 -0
  453. package/dist/design-tweaks/index.d.ts.map +1 -0
  454. package/dist/design-tweaks/index.js +2 -0
  455. package/dist/design-tweaks/index.js.map +1 -0
  456. package/dist/design-tweaks/scrub-input-utils.d.ts +61 -0
  457. package/dist/design-tweaks/scrub-input-utils.d.ts.map +1 -0
  458. package/dist/design-tweaks/scrub-input-utils.js +235 -0
  459. package/dist/design-tweaks/scrub-input-utils.js.map +1 -0
  460. package/dist/design-tweaks/scrub-input.d.ts +70 -0
  461. package/dist/design-tweaks/scrub-input.d.ts.map +1 -0
  462. package/dist/design-tweaks/scrub-input.js +319 -0
  463. package/dist/design-tweaks/scrub-input.js.map +1 -0
  464. package/dist/design-tweaks/visual-style-controls.d.ts +90 -0
  465. package/dist/design-tweaks/visual-style-controls.d.ts.map +1 -0
  466. package/dist/design-tweaks/visual-style-controls.js +423 -0
  467. package/dist/design-tweaks/visual-style-controls.js.map +1 -0
  468. package/dist/design-tweaks/visual-style-controls.spec.d.ts +2 -0
  469. package/dist/design-tweaks/visual-style-controls.spec.d.ts.map +1 -0
  470. package/dist/design-tweaks/visual-style-controls.spec.js +84 -0
  471. package/dist/design-tweaks/visual-style-controls.spec.js.map +1 -0
  472. package/dist/editor/BubbleToolbar.d.ts +37 -0
  473. package/dist/editor/BubbleToolbar.d.ts.map +1 -0
  474. package/dist/editor/BubbleToolbar.js +171 -0
  475. package/dist/editor/BubbleToolbar.js.map +1 -0
  476. package/dist/editor/CodeBlockNode.d.ts +49 -0
  477. package/dist/editor/CodeBlockNode.d.ts.map +1 -0
  478. package/dist/editor/CodeBlockNode.js +127 -0
  479. package/dist/editor/CodeBlockNode.js.map +1 -0
  480. package/dist/editor/DragHandle.d.ts +103 -0
  481. package/dist/editor/DragHandle.d.ts.map +1 -0
  482. package/dist/editor/DragHandle.js +1101 -0
  483. package/dist/editor/DragHandle.js.map +1 -0
  484. package/dist/editor/DragHandle.spec.d.ts +2 -0
  485. package/dist/editor/DragHandle.spec.d.ts.map +1 -0
  486. package/dist/editor/DragHandle.spec.js +495 -0
  487. package/dist/editor/DragHandle.spec.js.map +1 -0
  488. package/dist/editor/ImageExtension.d.ts +63 -0
  489. package/dist/editor/ImageExtension.d.ts.map +1 -0
  490. package/dist/editor/ImageExtension.js +243 -0
  491. package/dist/editor/ImageExtension.js.map +1 -0
  492. package/dist/editor/ImageExtension.roundtrip.spec.d.ts +2 -0
  493. package/dist/editor/ImageExtension.roundtrip.spec.d.ts.map +1 -0
  494. package/dist/editor/ImageExtension.roundtrip.spec.js +103 -0
  495. package/dist/editor/ImageExtension.roundtrip.spec.js.map +1 -0
  496. package/dist/editor/RegistryBlockContext.d.ts +68 -0
  497. package/dist/editor/RegistryBlockContext.d.ts.map +1 -0
  498. package/dist/editor/RegistryBlockContext.js +10 -0
  499. package/dist/editor/RegistryBlockContext.js.map +1 -0
  500. package/dist/editor/RegistryBlockNode.d.ts +66 -0
  501. package/dist/editor/RegistryBlockNode.d.ts.map +1 -0
  502. package/dist/editor/RegistryBlockNode.js +406 -0
  503. package/dist/editor/RegistryBlockNode.js.map +1 -0
  504. package/dist/editor/RegistryBlockNode.spec.d.ts +2 -0
  505. package/dist/editor/RegistryBlockNode.spec.d.ts.map +1 -0
  506. package/dist/editor/RegistryBlockNode.spec.js +215 -0
  507. package/dist/editor/RegistryBlockNode.spec.js.map +1 -0
  508. package/dist/editor/RichMarkdownEditor.collab.spec.d.ts +2 -0
  509. package/dist/editor/RichMarkdownEditor.collab.spec.d.ts.map +1 -0
  510. package/dist/editor/RichMarkdownEditor.collab.spec.js +65 -0
  511. package/dist/editor/RichMarkdownEditor.collab.spec.js.map +1 -0
  512. package/dist/editor/RichMarkdownEditor.d.ts +52 -0
  513. package/dist/editor/RichMarkdownEditor.d.ts.map +1 -0
  514. package/dist/editor/RichMarkdownEditor.js +38 -0
  515. package/dist/editor/RichMarkdownEditor.js.map +1 -0
  516. package/dist/editor/RichMarkdownEditor.roundtrip.spec.d.ts +2 -0
  517. package/dist/editor/RichMarkdownEditor.roundtrip.spec.d.ts.map +1 -0
  518. package/dist/editor/RichMarkdownEditor.roundtrip.spec.js +186 -0
  519. package/dist/editor/RichMarkdownEditor.roundtrip.spec.js.map +1 -0
  520. package/dist/editor/RunId.d.ts +28 -0
  521. package/dist/editor/RunId.d.ts.map +1 -0
  522. package/dist/editor/RunId.js +60 -0
  523. package/dist/editor/RunId.js.map +1 -0
  524. package/dist/editor/SharedRichEditor.d.ts +112 -0
  525. package/dist/editor/SharedRichEditor.d.ts.map +1 -0
  526. package/dist/editor/SharedRichEditor.js +159 -0
  527. package/dist/editor/SharedRichEditor.js.map +1 -0
  528. package/dist/editor/SharedRichEditor.spec.d.ts +2 -0
  529. package/dist/editor/SharedRichEditor.spec.d.ts.map +1 -0
  530. package/dist/editor/SharedRichEditor.spec.js +63 -0
  531. package/dist/editor/SharedRichEditor.spec.js.map +1 -0
  532. package/dist/editor/SlashCommandMenu.d.ts +59 -0
  533. package/dist/editor/SlashCommandMenu.d.ts.map +1 -0
  534. package/dist/editor/SlashCommandMenu.js +279 -0
  535. package/dist/editor/SlashCommandMenu.js.map +1 -0
  536. package/dist/editor/SlashCommandMenu.spec.d.ts +2 -0
  537. package/dist/editor/SlashCommandMenu.spec.d.ts.map +1 -0
  538. package/dist/editor/SlashCommandMenu.spec.js +67 -0
  539. package/dist/editor/SlashCommandMenu.spec.js.map +1 -0
  540. package/dist/editor/disableHistory.spec.d.ts +2 -0
  541. package/dist/editor/disableHistory.spec.d.ts.map +1 -0
  542. package/dist/editor/disableHistory.spec.js +73 -0
  543. package/dist/editor/disableHistory.spec.js.map +1 -0
  544. package/dist/editor/extensions.d.ts +178 -0
  545. package/dist/editor/extensions.d.ts.map +1 -0
  546. package/dist/editor/extensions.js +264 -0
  547. package/dist/editor/extensions.js.map +1 -0
  548. package/dist/editor/gfmDoc.d.ts +24 -0
  549. package/dist/editor/gfmDoc.d.ts.map +1 -0
  550. package/dist/editor/gfmDoc.js +83 -0
  551. package/dist/editor/gfmDoc.js.map +1 -0
  552. package/dist/editor/gfmDoc.spec.d.ts +2 -0
  553. package/dist/editor/gfmDoc.spec.d.ts.map +1 -0
  554. package/dist/editor/gfmDoc.spec.js +194 -0
  555. package/dist/editor/gfmDoc.spec.js.map +1 -0
  556. package/dist/editor/index.d.ts +16 -0
  557. package/dist/editor/index.d.ts.map +1 -0
  558. package/dist/editor/index.js +15 -0
  559. package/dist/editor/index.js.map +1 -0
  560. package/dist/editor/registrySlashCommands.d.ts +68 -0
  561. package/dist/editor/registrySlashCommands.d.ts.map +1 -0
  562. package/dist/editor/registrySlashCommands.js +51 -0
  563. package/dist/editor/registrySlashCommands.js.map +1 -0
  564. package/dist/editor/structuralReorderUndo.spec.d.ts +2 -0
  565. package/dist/editor/structuralReorderUndo.spec.d.ts.map +1 -0
  566. package/dist/editor/structuralReorderUndo.spec.js +120 -0
  567. package/dist/editor/structuralReorderUndo.spec.js.map +1 -0
  568. package/dist/editor/surgical-apply.d.ts +66 -0
  569. package/dist/editor/surgical-apply.d.ts.map +1 -0
  570. package/dist/editor/surgical-apply.js +147 -0
  571. package/dist/editor/surgical-apply.js.map +1 -0
  572. package/dist/editor/surgical-apply.spec.d.ts +2 -0
  573. package/dist/editor/surgical-apply.spec.d.ts.map +1 -0
  574. package/dist/editor/surgical-apply.spec.js +257 -0
  575. package/dist/editor/surgical-apply.spec.js.map +1 -0
  576. package/dist/editor/useCollabReconcile.concurrent.spec.d.ts +2 -0
  577. package/dist/editor/useCollabReconcile.concurrent.spec.d.ts.map +1 -0
  578. package/dist/editor/useCollabReconcile.concurrent.spec.js +641 -0
  579. package/dist/editor/useCollabReconcile.concurrent.spec.js.map +1 -0
  580. package/dist/editor/useCollabReconcile.d.ts +117 -0
  581. package/dist/editor/useCollabReconcile.d.ts.map +1 -0
  582. package/dist/editor/useCollabReconcile.idempotent.spec.d.ts +2 -0
  583. package/dist/editor/useCollabReconcile.idempotent.spec.d.ts.map +1 -0
  584. package/dist/editor/useCollabReconcile.idempotent.spec.js +248 -0
  585. package/dist/editor/useCollabReconcile.idempotent.spec.js.map +1 -0
  586. package/dist/editor/useCollabReconcile.js +521 -0
  587. package/dist/editor/useCollabReconcile.js.map +1 -0
  588. package/dist/editor.css +587 -0
  589. package/dist/hooks/index.d.ts +3 -0
  590. package/dist/hooks/index.d.ts.map +1 -0
  591. package/dist/hooks/index.js +3 -0
  592. package/dist/hooks/index.js.map +1 -0
  593. package/dist/hooks/use-mobile.d.ts +2 -0
  594. package/dist/hooks/use-mobile.d.ts.map +1 -0
  595. package/dist/hooks/use-mobile.js +16 -0
  596. package/dist/hooks/use-mobile.js.map +1 -0
  597. package/dist/hooks/use-toast.d.ts +45 -0
  598. package/dist/hooks/use-toast.d.ts.map +1 -0
  599. package/dist/hooks/use-toast.js +127 -0
  600. package/dist/hooks/use-toast.js.map +1 -0
  601. package/dist/index.d.ts +11 -0
  602. package/dist/index.d.ts.map +1 -0
  603. package/dist/index.js +11 -0
  604. package/dist/index.js.map +1 -0
  605. package/dist/onboarding/index.d.ts +2 -0
  606. package/dist/onboarding/index.d.ts.map +1 -0
  607. package/dist/onboarding/index.js +2 -0
  608. package/dist/onboarding/index.js.map +1 -0
  609. package/dist/provider.d.ts +15 -0
  610. package/dist/provider.d.ts.map +1 -0
  611. package/dist/provider.js +60 -0
  612. package/dist/provider.js.map +1 -0
  613. package/dist/sharing/SharePrimitives.d.ts +42 -0
  614. package/dist/sharing/SharePrimitives.d.ts.map +1 -0
  615. package/dist/sharing/SharePrimitives.js +53 -0
  616. package/dist/sharing/SharePrimitives.js.map +1 -0
  617. package/dist/sharing/VisibilityBadge.d.ts +11 -0
  618. package/dist/sharing/VisibilityBadge.d.ts.map +1 -0
  619. package/dist/sharing/VisibilityBadge.js +19 -0
  620. package/dist/sharing/VisibilityBadge.js.map +1 -0
  621. package/dist/sharing/VisibilityBadge.spec.d.ts +2 -0
  622. package/dist/sharing/VisibilityBadge.spec.d.ts.map +1 -0
  623. package/dist/sharing/VisibilityBadge.spec.js +60 -0
  624. package/dist/sharing/VisibilityBadge.spec.js.map +1 -0
  625. package/dist/sharing/index.d.ts +3 -0
  626. package/dist/sharing/index.d.ts.map +1 -0
  627. package/dist/sharing/index.js +3 -0
  628. package/dist/sharing/index.js.map +1 -0
  629. package/dist/styles.css +232 -0
  630. package/dist/ui/accordion.d.ts +8 -0
  631. package/dist/ui/accordion.d.ts.map +1 -0
  632. package/dist/ui/accordion.js +14 -0
  633. package/dist/ui/accordion.js.map +1 -0
  634. package/dist/ui/alert-dialog.d.ts +21 -0
  635. package/dist/ui/alert-dialog.d.ts.map +1 -0
  636. package/dist/ui/alert-dialog.js +27 -0
  637. package/dist/ui/alert-dialog.js.map +1 -0
  638. package/dist/ui/alert.d.ts +9 -0
  639. package/dist/ui/alert.d.ts.map +1 -0
  640. package/dist/ui/alert.js +23 -0
  641. package/dist/ui/alert.js.map +1 -0
  642. package/dist/ui/aspect-ratio.d.ts +4 -0
  643. package/dist/ui/aspect-ratio.d.ts.map +1 -0
  644. package/dist/ui/aspect-ratio.js +4 -0
  645. package/dist/ui/aspect-ratio.js.map +1 -0
  646. package/dist/ui/avatar.d.ts +7 -0
  647. package/dist/ui/avatar.d.ts.map +1 -0
  648. package/dist/ui/avatar.js +12 -0
  649. package/dist/ui/avatar.js.map +1 -0
  650. package/dist/ui/badge.d.ts +10 -0
  651. package/dist/ui/badge.d.ts.map +1 -0
  652. package/dist/ui/badge.js +21 -0
  653. package/dist/ui/badge.js.map +1 -0
  654. package/dist/ui/breadcrumb.d.ts +20 -0
  655. package/dist/ui/breadcrumb.d.ts.map +1 -0
  656. package/dist/ui/breadcrumb.js +24 -0
  657. package/dist/ui/breadcrumb.js.map +1 -0
  658. package/dist/ui/button.d.ts +18 -0
  659. package/dist/ui/button.d.ts.map +1 -0
  660. package/dist/ui/button.js +67 -0
  661. package/dist/ui/button.js.map +1 -0
  662. package/dist/ui/calendar.d.ts +9 -0
  663. package/dist/ui/calendar.d.ts.map +1 -0
  664. package/dist/ui/calendar.js +74 -0
  665. package/dist/ui/calendar.js.map +1 -0
  666. package/dist/ui/card.d.ts +9 -0
  667. package/dist/ui/card.d.ts.map +1 -0
  668. package/dist/ui/card.js +17 -0
  669. package/dist/ui/card.js.map +1 -0
  670. package/dist/ui/carousel.d.ts +19 -0
  671. package/dist/ui/carousel.d.ts.map +1 -0
  672. package/dist/ui/carousel.js +99 -0
  673. package/dist/ui/carousel.js.map +1 -0
  674. package/dist/ui/chart.d.ts +80 -0
  675. package/dist/ui/chart.d.ts.map +1 -0
  676. package/dist/ui/chart.js +131 -0
  677. package/dist/ui/chart.js.map +1 -0
  678. package/dist/ui/checkbox.d.ts +5 -0
  679. package/dist/ui/checkbox.d.ts.map +1 -0
  680. package/dist/ui/checkbox.js +9 -0
  681. package/dist/ui/checkbox.js.map +1 -0
  682. package/dist/ui/collapsible.d.ts +6 -0
  683. package/dist/ui/collapsible.d.ts.map +1 -0
  684. package/dist/ui/collapsible.js +6 -0
  685. package/dist/ui/collapsible.js.map +1 -0
  686. package/dist/ui/command.d.ts +85 -0
  687. package/dist/ui/command.d.ts.map +1 -0
  688. package/dist/ui/command.js +29 -0
  689. package/dist/ui/command.js.map +1 -0
  690. package/dist/ui/command.spec.d.ts +2 -0
  691. package/dist/ui/command.spec.d.ts.map +1 -0
  692. package/dist/ui/command.spec.js +29 -0
  693. package/dist/ui/command.spec.js.map +1 -0
  694. package/dist/ui/context-menu.d.ts +28 -0
  695. package/dist/ui/context-menu.d.ts.map +1 -0
  696. package/dist/ui/context-menu.js +34 -0
  697. package/dist/ui/context-menu.js.map +1 -0
  698. package/dist/ui/date-picker.d.ts +10 -0
  699. package/dist/ui/date-picker.d.ts.map +1 -0
  700. package/dist/ui/date-picker.js +20 -0
  701. package/dist/ui/date-picker.js.map +1 -0
  702. package/dist/ui/dialog.d.ts +32 -0
  703. package/dist/ui/dialog.d.ts.map +1 -0
  704. package/dist/ui/dialog.js +26 -0
  705. package/dist/ui/dialog.js.map +1 -0
  706. package/dist/ui/dialog.spec.d.ts +2 -0
  707. package/dist/ui/dialog.spec.d.ts.map +1 -0
  708. package/dist/ui/dialog.spec.js +21 -0
  709. package/dist/ui/dialog.spec.js.map +1 -0
  710. package/dist/ui/drawer.d.ts +35 -0
  711. package/dist/ui/drawer.d.ts.map +1 -0
  712. package/dist/ui/drawer.js +25 -0
  713. package/dist/ui/drawer.js.map +1 -0
  714. package/dist/ui/dropdown-menu.d.ts +32 -0
  715. package/dist/ui/dropdown-menu.d.ts.map +1 -0
  716. package/dist/ui/dropdown-menu.js +42 -0
  717. package/dist/ui/dropdown-menu.js.map +1 -0
  718. package/dist/ui/form.d.ts +26 -0
  719. package/dist/ui/form.d.ts.map +1 -0
  720. package/dist/ui/form.js +63 -0
  721. package/dist/ui/form.js.map +1 -0
  722. package/dist/ui/hover-card.d.ts +7 -0
  723. package/dist/ui/hover-card.d.ts.map +1 -0
  724. package/dist/ui/hover-card.js +10 -0
  725. package/dist/ui/hover-card.js.map +1 -0
  726. package/dist/ui/index.d.ts +53 -0
  727. package/dist/ui/index.d.ts.map +1 -0
  728. package/dist/ui/index.js +53 -0
  729. package/dist/ui/index.js.map +1 -0
  730. package/dist/ui/input-otp.d.ts +35 -0
  731. package/dist/ui/input-otp.d.ts.map +1 -0
  732. package/dist/ui/input-otp.js +19 -0
  733. package/dist/ui/input-otp.js.map +1 -0
  734. package/dist/ui/input.d.ts +4 -0
  735. package/dist/ui/input.d.ts.map +1 -0
  736. package/dist/ui/input.js +9 -0
  737. package/dist/ui/input.js.map +1 -0
  738. package/dist/ui/label.d.ts +6 -0
  739. package/dist/ui/label.d.ts.map +1 -0
  740. package/dist/ui/label.js +10 -0
  741. package/dist/ui/label.js.map +1 -0
  742. package/dist/ui/logo.d.ts +7 -0
  743. package/dist/ui/logo.d.ts.map +1 -0
  744. package/dist/ui/logo.js +10 -0
  745. package/dist/ui/logo.js.map +1 -0
  746. package/dist/ui/menubar.d.ts +29 -0
  747. package/dist/ui/menubar.d.ts.map +1 -0
  748. package/dist/ui/menubar.js +36 -0
  749. package/dist/ui/menubar.js.map +1 -0
  750. package/dist/ui/navigation-menu.d.ts +13 -0
  751. package/dist/ui/navigation-menu.d.ts.map +1 -0
  752. package/dist/ui/navigation-menu.js +25 -0
  753. package/dist/ui/navigation-menu.js.map +1 -0
  754. package/dist/ui/pagination.d.ts +29 -0
  755. package/dist/ui/pagination.d.ts.map +1 -0
  756. package/dist/ui/pagination.js +24 -0
  757. package/dist/ui/pagination.js.map +1 -0
  758. package/dist/ui/popover.d.ts +11 -0
  759. package/dist/ui/popover.d.ts.map +1 -0
  760. package/dist/ui/popover.js +16 -0
  761. package/dist/ui/popover.js.map +1 -0
  762. package/dist/ui/progress.d.ts +5 -0
  763. package/dist/ui/progress.d.ts.map +1 -0
  764. package/dist/ui/progress.js +8 -0
  765. package/dist/ui/progress.js.map +1 -0
  766. package/dist/ui/radio-group.d.ts +6 -0
  767. package/dist/ui/radio-group.d.ts.map +1 -0
  768. package/dist/ui/radio-group.js +15 -0
  769. package/dist/ui/radio-group.js.map +1 -0
  770. package/dist/ui/resizable.d.ts +8 -0
  771. package/dist/ui/resizable.d.ts.map +1 -0
  772. package/dist/ui/resizable.js +9 -0
  773. package/dist/ui/resizable.js.map +1 -0
  774. package/dist/ui/scroll-area.d.ts +6 -0
  775. package/dist/ui/scroll-area.d.ts.map +1 -0
  776. package/dist/ui/scroll-area.js +12 -0
  777. package/dist/ui/scroll-area.js.map +1 -0
  778. package/dist/ui/select.d.ts +16 -0
  779. package/dist/ui/select.d.ts.map +1 -0
  780. package/dist/ui/select.js +27 -0
  781. package/dist/ui/select.js.map +1 -0
  782. package/dist/ui/separator.d.ts +5 -0
  783. package/dist/ui/separator.d.ts.map +1 -0
  784. package/dist/ui/separator.js +8 -0
  785. package/dist/ui/separator.js.map +1 -0
  786. package/dist/ui/sheet.d.ts +29 -0
  787. package/dist/ui/sheet.d.ts.map +1 -0
  788. package/dist/ui/sheet.js +37 -0
  789. package/dist/ui/sheet.js.map +1 -0
  790. package/dist/ui/sidebar.d.ts +71 -0
  791. package/dist/ui/sidebar.d.ts.map +1 -0
  792. package/dist/ui/sidebar.js +230 -0
  793. package/dist/ui/sidebar.js.map +1 -0
  794. package/dist/ui/skeleton.d.ts +3 -0
  795. package/dist/ui/skeleton.d.ts.map +1 -0
  796. package/dist/ui/skeleton.js +7 -0
  797. package/dist/ui/skeleton.js.map +1 -0
  798. package/dist/ui/slider.d.ts +5 -0
  799. package/dist/ui/slider.d.ts.map +1 -0
  800. package/dist/ui/slider.js +8 -0
  801. package/dist/ui/slider.js.map +1 -0
  802. package/dist/ui/sonner.d.ts +5 -0
  803. package/dist/ui/sonner.d.ts.map +1 -0
  804. package/dist/ui/sonner.js +25 -0
  805. package/dist/ui/sonner.js.map +1 -0
  806. package/dist/ui/spinner.d.ts +3 -0
  807. package/dist/ui/spinner.d.ts.map +1 -0
  808. package/dist/ui/spinner.js +7 -0
  809. package/dist/ui/spinner.js.map +1 -0
  810. package/dist/ui/switch.d.ts +5 -0
  811. package/dist/ui/switch.d.ts.map +1 -0
  812. package/dist/ui/switch.js +8 -0
  813. package/dist/ui/switch.js.map +1 -0
  814. package/dist/ui/table.d.ts +11 -0
  815. package/dist/ui/table.d.ts.map +1 -0
  816. package/dist/ui/table.js +21 -0
  817. package/dist/ui/table.js.map +1 -0
  818. package/dist/ui/tabs.d.ts +8 -0
  819. package/dist/ui/tabs.d.ts.map +1 -0
  820. package/dist/ui/tabs.js +13 -0
  821. package/dist/ui/tabs.js.map +1 -0
  822. package/dist/ui/textarea.d.ts +6 -0
  823. package/dist/ui/textarea.d.ts.map +1 -0
  824. package/dist/ui/textarea.js +9 -0
  825. package/dist/ui/textarea.js.map +1 -0
  826. package/dist/ui/toast.d.ts +16 -0
  827. package/dist/ui/toast.d.ts.map +1 -0
  828. package/dist/ui/toast.js +34 -0
  829. package/dist/ui/toast.js.map +1 -0
  830. package/dist/ui/toaster.d.ts +2 -0
  831. package/dist/ui/toaster.d.ts.map +1 -0
  832. package/dist/ui/toaster.js +10 -0
  833. package/dist/ui/toaster.js.map +1 -0
  834. package/dist/ui/toggle-group.d.ts +13 -0
  835. package/dist/ui/toggle-group.d.ts.map +1 -0
  836. package/dist/ui/toggle-group.js +21 -0
  837. package/dist/ui/toggle-group.js.map +1 -0
  838. package/dist/ui/toggle.d.ts +13 -0
  839. package/dist/ui/toggle.d.ts.map +1 -0
  840. package/dist/ui/toggle.js +26 -0
  841. package/dist/ui/toggle.js.map +1 -0
  842. package/dist/ui/tooltip.d.ts +11 -0
  843. package/dist/ui/tooltip.d.ts.map +1 -0
  844. package/dist/ui/tooltip.js +18 -0
  845. package/dist/ui/tooltip.js.map +1 -0
  846. package/dist/ui/use-toast.d.ts +3 -0
  847. package/dist/ui/use-toast.d.ts.map +1 -0
  848. package/dist/ui/use-toast.js +3 -0
  849. package/dist/ui/use-toast.js.map +1 -0
  850. package/dist/utils.d.ts +4 -0
  851. package/dist/utils.d.ts.map +1 -0
  852. package/dist/utils.js +7 -0
  853. package/dist/utils.js.map +1 -0
  854. package/migration-manifest.json +4 -0
  855. package/package.json +369 -0
  856. package/src/app-shell/header-actions.tsx +84 -0
  857. package/src/app-shell/index.ts +2 -0
  858. package/src/app-shell/sidebar-footer-actions.spec.tsx +81 -0
  859. package/src/app-shell/sidebar-footer-actions.tsx +45 -0
  860. package/src/canvas-annotations/CanvasCommentPins.tsx +861 -0
  861. package/src/canvas-annotations/DrawOverlay.spec.tsx +145 -0
  862. package/src/canvas-annotations/DrawOverlay.tsx +1233 -0
  863. package/src/canvas-annotations/index.ts +15 -0
  864. package/src/canvas-annotations/types.ts +14 -0
  865. package/src/canvas-interactions/canvas-interactions.spec.ts +765 -0
  866. package/src/canvas-interactions/canvas-interactions.ts +965 -0
  867. package/src/canvas-interactions/index.ts +67 -0
  868. package/src/chat-history/ChatHistoryList.spec.tsx +485 -0
  869. package/src/chat-history/ChatHistoryList.tsx +481 -0
  870. package/src/chat-history/ChatHistoryRail.spec.tsx +312 -0
  871. package/src/chat-history/ChatHistoryRail.tsx +150 -0
  872. package/src/chat-history/index.ts +21 -0
  873. package/src/chat-history/useChatHistoryRailController.spec.tsx +131 -0
  874. package/src/chat-history/useChatHistoryRailController.ts +76 -0
  875. package/src/chat-history.css +469 -0
  876. package/src/collab-ui/AgentPresenceChip.tsx +69 -0
  877. package/src/collab-ui/LiveCursorOverlay.tsx +241 -0
  878. package/src/collab-ui/PresenceBar.spec.tsx +44 -0
  879. package/src/collab-ui/PresenceBar.tsx +373 -0
  880. package/src/collab-ui/RecentEditHighlights.tsx +239 -0
  881. package/src/collab-ui/RemoteSelectionRings.tsx +227 -0
  882. package/src/collab-ui/agent-identity.ts +16 -0
  883. package/src/collab-ui/index.ts +39 -0
  884. package/src/collab-ui/lead-client.ts +32 -0
  885. package/src/collab-ui/types.spec.ts +18 -0
  886. package/src/collab-ui/types.ts +96 -0
  887. package/src/composer/AgentComposerFrame.tsx +62 -0
  888. package/src/composer/ComposerPlusMenu.spec.ts +14 -0
  889. package/src/composer/ComposerPlusMenu.tsx +1266 -0
  890. package/src/composer/MentionPopover.tsx +483 -0
  891. package/src/composer/PastedTextChip.spec.tsx +58 -0
  892. package/src/composer/PastedTextChip.tsx +178 -0
  893. package/src/composer/PromptComposer.spec.ts +110 -0
  894. package/src/composer/PromptComposer.tsx +796 -0
  895. package/src/composer/RealtimeVoiceMode.spec.tsx +998 -0
  896. package/src/composer/RealtimeVoiceMode.tsx +1019 -0
  897. package/src/composer/TiptapComposer.spec.ts +592 -0
  898. package/src/composer/TiptapComposer.tsx +3746 -0
  899. package/src/composer/VoiceButton.spec.ts +49 -0
  900. package/src/composer/VoiceButton.tsx +329 -0
  901. package/src/composer/asset-picker-url.spec.ts +56 -0
  902. package/src/composer/asset-picker-url.ts +80 -0
  903. package/src/composer/attachment-accept.spec.ts +32 -0
  904. package/src/composer/attachment-accept.ts +75 -0
  905. package/src/composer/draft-key.spec.ts +19 -0
  906. package/src/composer/draft-key.ts +7 -0
  907. package/src/composer/extensions/FileReference.tsx +55 -0
  908. package/src/composer/extensions/MentionReference.tsx +93 -0
  909. package/src/composer/extensions/SkillReference.tsx +56 -0
  910. package/src/composer/index.ts +86 -0
  911. package/src/composer/model-selection.spec.ts +45 -0
  912. package/src/composer/model-selection.ts +51 -0
  913. package/src/composer/pasted-text.spec.ts +162 -0
  914. package/src/composer/pasted-text.ts +160 -0
  915. package/src/composer/prompt-attachments.spec.ts +80 -0
  916. package/src/composer/prompt-attachments.ts +93 -0
  917. package/src/composer/realtime-voice-audio-level.spec.ts +47 -0
  918. package/src/composer/realtime-voice-audio-level.ts +65 -0
  919. package/src/composer/realtime-voice-transcript.spec.ts +95 -0
  920. package/src/composer/realtime-voice-transcript.ts +134 -0
  921. package/src/composer/runtime-adapters.spec.tsx +102 -0
  922. package/src/composer/runtime-adapters.tsx +364 -0
  923. package/src/composer/types.ts +66 -0
  924. package/src/composer/use-file-search.ts +64 -0
  925. package/src/composer/use-mention-search.ts +90 -0
  926. package/src/composer/use-skills.ts +45 -0
  927. package/src/composer/useRealtimeVoiceMode.spec.ts +952 -0
  928. package/src/composer/useRealtimeVoiceMode.tsx +2388 -0
  929. package/src/composer/useVoiceDictation.browser.spec.tsx +265 -0
  930. package/src/composer/useVoiceDictation.spec.ts +45 -0
  931. package/src/composer/useVoiceDictation.ts +1256 -0
  932. package/src/conformance/__fixtures__/css-in-js-adapter.tsx +401 -0
  933. package/src/conformance/conformance.spec.tsx +143 -0
  934. package/src/conformance/index.ts +3 -0
  935. package/src/conformance/runner.tsx +862 -0
  936. package/src/conformance/types.ts +45 -0
  937. package/src/conformance/version.ts +22 -0
  938. package/src/context-ui/ContextMeter.spec.tsx +73 -0
  939. package/src/context-ui/ContextMeter.tsx +131 -0
  940. package/src/context-ui/ContextSegmentRow.tsx +273 -0
  941. package/src/context-ui/ContextTreemap.tsx +131 -0
  942. package/src/context-ui/ContextXRayPanel.tsx +491 -0
  943. package/src/context-ui/format.ts +42 -0
  944. package/src/context-ui/index.ts +15 -0
  945. package/src/context-ui/types.ts +57 -0
  946. package/src/dashboard/DataTable.tsx +273 -0
  947. package/src/dashboard/DateRangePicker.tsx +57 -0
  948. package/src/dashboard/GenericChartPanel.spec.tsx +53 -0
  949. package/src/dashboard/GenericChartPanel.tsx +461 -0
  950. package/src/dashboard/MetricCard.tsx +54 -0
  951. package/src/dashboard/StatsCard.tsx +49 -0
  952. package/src/dashboard/dashboard-layout.spec.ts +79 -0
  953. package/src/dashboard/dashboard-layout.ts +329 -0
  954. package/src/dashboard/index.ts +6 -0
  955. package/src/data-grid/DataGrid.spec.tsx +243 -0
  956. package/src/data-grid/DataGrid.tsx +754 -0
  957. package/src/data-grid/index.ts +15 -0
  958. package/src/design-system/components.tsx +196 -0
  959. package/src/design-system/context.tsx +31 -0
  960. package/src/design-system/default-adapter.spec.tsx +158 -0
  961. package/src/design-system/default-adapter.tsx +923 -0
  962. package/src/design-system/definition.ts +14 -0
  963. package/src/design-system/design-system.spec.tsx +356 -0
  964. package/src/design-system/error-boundary.tsx +37 -0
  965. package/src/design-system/index.ts +7 -0
  966. package/src/design-system/theme.spec.ts +61 -0
  967. package/src/design-system/theme.ts +145 -0
  968. package/src/design-system/types.ts +367 -0
  969. package/src/design-tweaks/index.ts +1 -0
  970. package/src/design-tweaks/scrub-input-utils.ts +311 -0
  971. package/src/design-tweaks/scrub-input.tsx +525 -0
  972. package/src/design-tweaks/visual-style-controls.spec.tsx +172 -0
  973. package/src/design-tweaks/visual-style-controls.tsx +1043 -0
  974. package/src/editor/BubbleToolbar.tsx +253 -0
  975. package/src/editor/CodeBlockNode.tsx +254 -0
  976. package/src/editor/DragHandle.spec.ts +694 -0
  977. package/src/editor/DragHandle.ts +1491 -0
  978. package/src/editor/ImageExtension.roundtrip.spec.ts +117 -0
  979. package/src/editor/ImageExtension.ts +306 -0
  980. package/src/editor/RegistryBlockContext.tsx +107 -0
  981. package/src/editor/RegistryBlockNode.spec.ts +279 -0
  982. package/src/editor/RegistryBlockNode.tsx +652 -0
  983. package/src/editor/RichMarkdownEditor.collab.spec.ts +79 -0
  984. package/src/editor/RichMarkdownEditor.roundtrip.spec.ts +226 -0
  985. package/src/editor/RichMarkdownEditor.tsx +81 -0
  986. package/src/editor/RunId.ts +61 -0
  987. package/src/editor/SharedRichEditor.spec.tsx +82 -0
  988. package/src/editor/SharedRichEditor.tsx +353 -0
  989. package/src/editor/SlashCommandMenu.spec.ts +90 -0
  990. package/src/editor/SlashCommandMenu.tsx +396 -0
  991. package/src/editor/disableHistory.spec.ts +85 -0
  992. package/src/editor/extensions.ts +454 -0
  993. package/src/editor/gfmDoc.spec.ts +230 -0
  994. package/src/editor/gfmDoc.ts +92 -0
  995. package/src/editor/index.ts +96 -0
  996. package/src/editor/registrySlashCommands.ts +131 -0
  997. package/src/editor/structuralReorderUndo.spec.ts +144 -0
  998. package/src/editor/surgical-apply.spec.ts +279 -0
  999. package/src/editor/surgical-apply.ts +192 -0
  1000. package/src/editor/useCollabReconcile.concurrent.spec.ts +781 -0
  1001. package/src/editor/useCollabReconcile.idempotent.spec.ts +324 -0
  1002. package/src/editor/useCollabReconcile.ts +684 -0
  1003. package/src/editor.css +587 -0
  1004. package/src/hooks/index.ts +2 -0
  1005. package/src/hooks/use-mobile.tsx +21 -0
  1006. package/src/hooks/use-toast.ts +188 -0
  1007. package/src/index.ts +10 -0
  1008. package/src/onboarding/index.ts +1 -0
  1009. package/src/provider.tsx +148 -0
  1010. package/src/sharing/SharePrimitives.tsx +224 -0
  1011. package/src/sharing/VisibilityBadge.spec.ts +96 -0
  1012. package/src/sharing/VisibilityBadge.tsx +37 -0
  1013. package/src/sharing/index.ts +16 -0
  1014. package/src/styles.css +232 -0
  1015. package/src/ui/accordion.tsx +56 -0
  1016. package/src/ui/alert-dialog.tsx +141 -0
  1017. package/src/ui/alert.tsx +59 -0
  1018. package/src/ui/aspect-ratio.tsx +5 -0
  1019. package/src/ui/avatar.tsx +48 -0
  1020. package/src/ui/badge.tsx +37 -0
  1021. package/src/ui/breadcrumb.tsx +115 -0
  1022. package/src/ui/button.tsx +167 -0
  1023. package/src/ui/calendar.tsx +214 -0
  1024. package/src/ui/card.tsx +86 -0
  1025. package/src/ui/carousel.tsx +260 -0
  1026. package/src/ui/chart.tsx +375 -0
  1027. package/src/ui/checkbox.tsx +28 -0
  1028. package/src/ui/collapsible.tsx +9 -0
  1029. package/src/ui/command.spec.tsx +51 -0
  1030. package/src/ui/command.tsx +174 -0
  1031. package/src/ui/context-menu.tsx +202 -0
  1032. package/src/ui/date-picker.tsx +67 -0
  1033. package/src/ui/dialog.spec.tsx +43 -0
  1034. package/src/ui/dialog.tsx +171 -0
  1035. package/src/ui/drawer.tsx +126 -0
  1036. package/src/ui/dropdown-menu.tsx +222 -0
  1037. package/src/ui/form.tsx +177 -0
  1038. package/src/ui/hover-card.tsx +27 -0
  1039. package/src/ui/index.ts +52 -0
  1040. package/src/ui/input-otp.tsx +69 -0
  1041. package/src/ui/input.tsx +22 -0
  1042. package/src/ui/label.tsx +24 -0
  1043. package/src/ui/logo.tsx +36 -0
  1044. package/src/ui/menubar.tsx +235 -0
  1045. package/src/ui/navigation-menu.tsx +128 -0
  1046. package/src/ui/pagination.tsx +121 -0
  1047. package/src/ui/popover.tsx +58 -0
  1048. package/src/ui/progress.tsx +27 -0
  1049. package/src/ui/radio-group.tsx +42 -0
  1050. package/src/ui/resizable.tsx +43 -0
  1051. package/src/ui/scroll-area.tsx +46 -0
  1052. package/src/ui/select.tsx +162 -0
  1053. package/src/ui/separator.tsx +29 -0
  1054. package/src/ui/sheet.tsx +160 -0
  1055. package/src/ui/sidebar.tsx +776 -0
  1056. package/src/ui/skeleton.tsx +18 -0
  1057. package/src/ui/slider.tsx +26 -0
  1058. package/src/ui/sonner.tsx +58 -0
  1059. package/src/ui/spinner.tsx +17 -0
  1060. package/src/ui/switch.tsx +27 -0
  1061. package/src/ui/table.tsx +110 -0
  1062. package/src/ui/tabs.tsx +53 -0
  1063. package/src/ui/textarea.tsx +23 -0
  1064. package/src/ui/toast.tsx +127 -0
  1065. package/src/ui/toaster.tsx +33 -0
  1066. package/src/ui/toggle-group.tsx +59 -0
  1067. package/src/ui/toggle.tsx +43 -0
  1068. package/src/ui/tooltip.tsx +57 -0
  1069. package/src/ui/use-toast.ts +3 -0
  1070. package/src/utils.ts +8 -0
@@ -0,0 +1,1256 @@
1
+ /**
2
+ * Voice dictation hook for the agent composer.
3
+ *
4
+ * Wires voice providers behind a single state machine:
5
+ * - "auto" / "openai" / "builder" / "builder-gemini" / "gemini" / "groq"
6
+ * — MediaRecorder → POST /_agent-native/transcribe-voice
7
+ * - "google-realtime"
8
+ * — MediaRecorder chunks → POST /_agent-native/transcribe-stream/session
9
+ * → managed WebSocket → Google Speech-to-Text streaming
10
+ * - "browser" — Web Speech API (low quality, offline capable)
11
+ *
12
+ * Provider preference lives in application_state under
13
+ * `voice-transcription-prefs` (`{ transcriptionMode, provider, instructions }`).
14
+ * The composer reads it on every start so settings changes take effect
15
+ * immediately without unmounting the composer.
16
+ *
17
+ * The hook exposes amplitude (0..1) and duration (ms) so the composer can
18
+ * render the Lovable-style live waveform + MM:SS timer.
19
+ */
20
+
21
+ import { useCallback, useEffect, useRef, useState } from "react";
22
+
23
+ import {
24
+ applyVoiceContextReplacements,
25
+ type VoiceContextPack,
26
+ useComposerRuntimeAdapters,
27
+ } from "./runtime-adapters.js";
28
+
29
+ export type VoiceProvider =
30
+ | "auto"
31
+ | "openai"
32
+ | "browser"
33
+ | "google-realtime"
34
+ | "builder-gemini"
35
+ | "builder"
36
+ | "gemini"
37
+ | "groq";
38
+
39
+ export type TranscriptionMode = "mac-native" | "google-realtime" | "batch";
40
+
41
+ export interface VoicePrefs {
42
+ provider: VoiceProvider;
43
+ transcriptionMode?: TranscriptionMode;
44
+ instructions?: string;
45
+ cleanupEnabled?: boolean;
46
+ }
47
+
48
+ export interface VoiceCleanupPrefs {
49
+ enabled?: boolean;
50
+ }
51
+
52
+ type VoiceContextPackSource =
53
+ | VoiceContextPack
54
+ | (() => VoiceContextPack | undefined | Promise<VoiceContextPack | undefined>)
55
+ | undefined;
56
+
57
+ const PREFS_KEY = "voice-transcription-prefs";
58
+ const CLEANUP_PREFS_KEY = "voice-cleanup-prefs";
59
+ const PREFS_URL = `/_agent-native/application-state/${PREFS_KEY}`;
60
+ const CLEANUP_PREFS_URL = `/_agent-native/application-state/${CLEANUP_PREFS_KEY}`;
61
+ const TRANSCRIBE_URL = "/_agent-native/transcribe-voice";
62
+ const GOOGLE_REALTIME_SESSION_URL = "/_agent-native/transcribe-stream/session";
63
+ const GOOGLE_REALTIME_WS_PROTOCOL = "google-realtime.v1";
64
+ function isVoiceProvider(value: unknown): value is VoiceProvider {
65
+ return (
66
+ value === "auto" ||
67
+ value === "openai" ||
68
+ value === "browser" ||
69
+ value === "google-realtime" ||
70
+ value === "builder-gemini" ||
71
+ value === "builder" ||
72
+ value === "gemini" ||
73
+ value === "groq"
74
+ );
75
+ }
76
+
77
+ function isTranscriptionMode(value: unknown): value is TranscriptionMode {
78
+ return (
79
+ value === "mac-native" || value === "google-realtime" || value === "batch"
80
+ );
81
+ }
82
+
83
+ async function defaultProvider(): Promise<VoiceProvider> {
84
+ return "auto";
85
+ }
86
+
87
+ function normalizeProviderForMode(
88
+ mode: TranscriptionMode | undefined,
89
+ provider: VoiceProvider | null,
90
+ ): VoiceProvider | null {
91
+ if (mode === "mac-native") return "browser";
92
+ if (mode === "google-realtime") return "google-realtime";
93
+ if (mode === "batch") {
94
+ if (!provider || provider === "browser") return "auto";
95
+ return provider === "builder" ? "builder-gemini" : provider;
96
+ }
97
+ if (!provider) return null;
98
+ return provider === "builder" ? "builder-gemini" : provider;
99
+ }
100
+
101
+ export type VoiceState =
102
+ | "idle"
103
+ | "starting"
104
+ | "recording"
105
+ | "transcribing"
106
+ | "error";
107
+
108
+ export interface UseVoiceDictationOptions {
109
+ onTranscript: (text: string) => void;
110
+ onError?: (message: string) => void;
111
+ /** Called with (accumulatedFinalText, currentInterimText) as speech is recognized in real time. */
112
+ onLiveUpdate?: (finalText: string, interimText: string) => void;
113
+ contextPack?: VoiceContextPackSource;
114
+ }
115
+
116
+ export interface VoiceDictationApi {
117
+ state: VoiceState;
118
+ amplitude: number;
119
+ durationMs: number;
120
+ errorMessage: string | null;
121
+ provider: VoiceProvider;
122
+ supported: boolean;
123
+ start: () => Promise<void>;
124
+ stop: () => void;
125
+ cancel: () => void;
126
+ dismissError: () => void;
127
+ }
128
+
129
+ async function readVoicePrefs(
130
+ resolvePath: (path: string) => string,
131
+ ): Promise<VoicePrefs> {
132
+ const cleanupPrefs = await readVoiceCleanupPrefs(resolvePath);
133
+ try {
134
+ const res = await fetch(resolvePath(PREFS_URL));
135
+ if (!res.ok) {
136
+ return {
137
+ provider: await defaultProvider(),
138
+ cleanupEnabled: cleanupPrefs.enabled,
139
+ };
140
+ }
141
+ const body = (await res.json()) as
142
+ | VoicePrefs
143
+ | { value?: VoicePrefs }
144
+ | null;
145
+ const value =
146
+ (body as { value?: VoicePrefs } | null)?.value ??
147
+ (body as VoicePrefs | null);
148
+ const mode = isTranscriptionMode(value?.transcriptionMode)
149
+ ? value.transcriptionMode
150
+ : undefined;
151
+ const p =
152
+ (body as VoicePrefs | null)?.provider ??
153
+ (body as { value?: VoicePrefs } | null)?.value?.provider;
154
+ const instructions =
155
+ (body as VoicePrefs | null)?.instructions ??
156
+ (body as { value?: VoicePrefs } | null)?.value?.instructions;
157
+ const provider = normalizeProviderForMode(
158
+ mode,
159
+ isVoiceProvider(p) ? p : null,
160
+ );
161
+ if (provider) {
162
+ return {
163
+ transcriptionMode: mode,
164
+ provider,
165
+ cleanupEnabled: cleanupPrefs.enabled,
166
+ instructions:
167
+ typeof instructions === "string" ? instructions.trim() : undefined,
168
+ };
169
+ }
170
+ } catch {
171
+ /* fall through */
172
+ }
173
+ return {
174
+ provider: await defaultProvider(),
175
+ cleanupEnabled: cleanupPrefs.enabled,
176
+ };
177
+ }
178
+
179
+ async function readVoiceCleanupPrefs(
180
+ resolvePath: (path: string) => string,
181
+ ): Promise<VoiceCleanupPrefs> {
182
+ try {
183
+ const res = await fetch(resolvePath(CLEANUP_PREFS_URL));
184
+ if (!res.ok) return {};
185
+ const body = (await res.json()) as
186
+ | VoiceCleanupPrefs
187
+ | { value?: VoiceCleanupPrefs }
188
+ | null;
189
+ const value =
190
+ (body as { value?: VoiceCleanupPrefs } | null)?.value ??
191
+ (body as VoiceCleanupPrefs | null);
192
+ return { enabled: value?.enabled === true };
193
+ } catch {
194
+ return {};
195
+ }
196
+ }
197
+
198
+ function getSpeechRecognitionCtor(): any {
199
+ if (typeof window === "undefined") return null;
200
+ return (
201
+ (window as any).SpeechRecognition ||
202
+ (window as any).webkitSpeechRecognition ||
203
+ null
204
+ );
205
+ }
206
+
207
+ function pickMimeType(): string {
208
+ if (typeof MediaRecorder === "undefined") return "audio/webm";
209
+ const candidates = [
210
+ "audio/webm;codecs=opus",
211
+ "audio/webm",
212
+ "audio/mp4",
213
+ "audio/ogg;codecs=opus",
214
+ ];
215
+ for (const mime of candidates) {
216
+ try {
217
+ if (MediaRecorder.isTypeSupported(mime)) return mime;
218
+ } catch {
219
+ /* ignore */
220
+ }
221
+ }
222
+ return "audio/webm";
223
+ }
224
+
225
+ async function resolveVoiceContextPack(
226
+ source: VoiceContextPackSource,
227
+ ): Promise<VoiceContextPack | undefined> {
228
+ try {
229
+ const value = typeof source === "function" ? await source() : source;
230
+ return value && typeof value === "object" ? value : undefined;
231
+ } catch {
232
+ return undefined;
233
+ }
234
+ }
235
+
236
+ function appendVoiceContext(
237
+ form: FormData,
238
+ contextPack: VoiceContextPack | undefined,
239
+ ): void {
240
+ if (!contextPack) return;
241
+ try {
242
+ form.append("voiceContext", JSON.stringify(contextPack));
243
+ } catch {
244
+ /* best effort */
245
+ }
246
+ }
247
+
248
+ export function providerForTextCleanup(provider: VoiceProvider): VoiceProvider {
249
+ return provider === "google-realtime" ? "auto" : provider;
250
+ }
251
+
252
+ async function cleanupRecognizedText({
253
+ text,
254
+ provider,
255
+ instructions,
256
+ contextPack,
257
+ resolvePath,
258
+ replaceContext,
259
+ }: {
260
+ text: string;
261
+ provider: VoiceProvider;
262
+ instructions?: string;
263
+ contextPack?: VoiceContextPack;
264
+ resolvePath: (path: string) => string;
265
+ replaceContext: (
266
+ text: string,
267
+ context: VoiceContextPack | undefined,
268
+ ) => string;
269
+ }): Promise<string> {
270
+ if (provider === "browser") {
271
+ return replaceContext(text, contextPack);
272
+ }
273
+
274
+ const form = new FormData();
275
+ form.append("text", text);
276
+ form.append("provider", providerForTextCleanup(provider));
277
+ if (instructions?.trim()) {
278
+ form.append("instructions", instructions.trim());
279
+ }
280
+ appendVoiceContext(form, contextPack);
281
+
282
+ const res = await fetch(resolvePath(TRANSCRIBE_URL), {
283
+ method: "POST",
284
+ body: form,
285
+ });
286
+ if (!res.ok) {
287
+ const body = await res
288
+ .json()
289
+ .catch(() => ({ error: `HTTP ${res.status}` }));
290
+ throw new Error(body.error || `Transcript cleanup failed (${res.status})`);
291
+ }
292
+ const data = (await res.json()) as { text?: string };
293
+ return (data.text ?? "").trim() || text;
294
+ }
295
+
296
+ type BrowserDocumentPolicy = {
297
+ allowsFeature: (feature: string) => boolean;
298
+ };
299
+
300
+ function microphoneBlockedByPermissionsPolicy(): boolean {
301
+ if (typeof document === "undefined") return false;
302
+ const doc = document as Document & {
303
+ permissionsPolicy?: BrowserDocumentPolicy;
304
+ featurePolicy?: BrowserDocumentPolicy;
305
+ };
306
+ const policy = doc.permissionsPolicy ?? doc.featurePolicy ?? null;
307
+ if (!policy?.allowsFeature) return false;
308
+ try {
309
+ return !policy.allowsFeature("microphone");
310
+ } catch {
311
+ return false;
312
+ }
313
+ }
314
+
315
+ export function voiceDictationStartErrorMessage(error: unknown): string {
316
+ const name =
317
+ typeof (error as { name?: unknown } | null)?.name === "string"
318
+ ? (error as { name: string }).name
319
+ : "";
320
+ const message =
321
+ typeof (error as { message?: unknown } | null)?.message === "string"
322
+ ? (error as { message: string }).message
323
+ : "";
324
+
325
+ if (
326
+ microphoneBlockedByPermissionsPolicy() ||
327
+ /permissions[- ]policy|feature policy/i.test(message)
328
+ ) {
329
+ return "This app is blocking microphone access through its browser permissions policy. Reload the app, or open it directly in a browser tab.";
330
+ }
331
+
332
+ if (
333
+ name === "NotAllowedError" ||
334
+ name === "SecurityError" ||
335
+ /permission|denied|not allowed/i.test(message)
336
+ ) {
337
+ return "Microphone access is blocked. Click the site controls icon in the address bar, set Microphone to Allow for this app, then try again.";
338
+ }
339
+
340
+ if (name === "NotFoundError" || name === "DevicesNotFoundError") {
341
+ return "No microphone was found. Plug one in or choose a different input, then try again.";
342
+ }
343
+
344
+ if (name === "NotReadableError" || name === "TrackStartError") {
345
+ return "Your microphone is busy in another app. Close the other app or choose a different input, then try again.";
346
+ }
347
+
348
+ return message || "Could not start recording";
349
+ }
350
+
351
+ /** Retrying these through another provider re-prompts and fails the same way. */
352
+ function isMicPermissionError(error: string | undefined): boolean {
353
+ return (
354
+ error === "not-allowed" ||
355
+ error === "service-not-allowed" ||
356
+ error === "audio-capture"
357
+ );
358
+ }
359
+
360
+ export function voiceDictationSpeechErrorMessage(
361
+ error: string | undefined,
362
+ ): string {
363
+ if (error === "not-allowed" || error === "service-not-allowed") {
364
+ return voiceDictationStartErrorMessage({
365
+ name: "NotAllowedError",
366
+ message: error,
367
+ });
368
+ }
369
+ if (error === "audio-capture") {
370
+ return "No microphone was found. Plug one in or choose a different input, then try again.";
371
+ }
372
+ if (error === "network") {
373
+ return "Speech recognition couldn't reach its service. Check your connection, or pick a different source in Settings → Voice Transcription.";
374
+ }
375
+ if (error === "aborted" || error === undefined) {
376
+ return "Dictation stopped before it captured any audio. Another app or tab may be holding the microphone — close it, or pick a different source in Settings → Voice Transcription.";
377
+ }
378
+ return `Speech recognition error: ${error}`;
379
+ }
380
+
381
+ export function useVoiceDictation(
382
+ options: UseVoiceDictationOptions,
383
+ ): VoiceDictationApi {
384
+ const adapters = useComposerRuntimeAdapters();
385
+ const resolvePath = adapters.resolvePath!;
386
+ const replaceContext =
387
+ adapters.voice!.applyContextReplacements ?? applyVoiceContextReplacements;
388
+ const { onTranscript, onError, onLiveUpdate, contextPack } = options;
389
+ const onTranscriptRef = useRef(onTranscript);
390
+ const onErrorRef = useRef(onError);
391
+ const onLiveUpdateRef = useRef(onLiveUpdate);
392
+ const contextPackRef = useRef(contextPack);
393
+ onTranscriptRef.current = onTranscript;
394
+ onErrorRef.current = onError;
395
+ onLiveUpdateRef.current = onLiveUpdate;
396
+ contextPackRef.current = contextPack;
397
+
398
+ const [state, setState] = useState<VoiceState>("idle");
399
+ const [amplitude, setAmplitude] = useState(0);
400
+ const [durationMs, setDurationMs] = useState(0);
401
+ const [errorMessage, setErrorMessage] = useState<string | null>(null);
402
+ const [provider, setProvider] = useState<VoiceProvider>("auto");
403
+
404
+ // Keep refs for teardown / cross-branch access.
405
+ const mediaStreamRef = useRef<MediaStream | null>(null);
406
+ const mediaRecorderRef = useRef<MediaRecorder | null>(null);
407
+ const chunksRef = useRef<Blob[]>([]);
408
+ const audioContextRef = useRef<AudioContext | null>(null);
409
+ const analyserRef = useRef<AnalyserNode | null>(null);
410
+ const rafRef = useRef<number | null>(null);
411
+ const timerRef = useRef<ReturnType<typeof setInterval> | null>(null);
412
+ const startedAtRef = useRef<number>(0);
413
+ const cancelledRef = useRef(false);
414
+ const speechRef = useRef<any>(null);
415
+ const speechTranscriptRef = useRef<string>("");
416
+ const activeProviderRef = useRef<VoiceProvider>("browser");
417
+ // Parallel live recognition for OpenAI mode (provides instant preview while MediaRecorder captures)
418
+ const liveSpeechRef = useRef<any>(null);
419
+ const liveTextRef = useRef<string>("");
420
+ const realtimeSocketRef = useRef<WebSocket | null>(null);
421
+ const realtimeFinalRef = useRef<string>("");
422
+ const realtimeInterimRef = useRef<string>("");
423
+ const realtimeStopTimeoutRef = useRef<number | null>(null);
424
+
425
+ const mediaRecorderSupported =
426
+ typeof window !== "undefined" &&
427
+ typeof navigator !== "undefined" &&
428
+ !!navigator.mediaDevices?.getUserMedia &&
429
+ typeof (window as any).MediaRecorder !== "undefined";
430
+ const speechSupported = !!getSpeechRecognitionCtor();
431
+ const supported = mediaRecorderSupported || speechSupported;
432
+
433
+ const teardown = useCallback(() => {
434
+ if (rafRef.current != null) {
435
+ cancelAnimationFrame(rafRef.current);
436
+ rafRef.current = null;
437
+ }
438
+ if (timerRef.current != null) {
439
+ clearInterval(timerRef.current);
440
+ timerRef.current = null;
441
+ }
442
+ if (mediaStreamRef.current) {
443
+ for (const track of mediaStreamRef.current.getTracks()) {
444
+ track.stop();
445
+ }
446
+ mediaStreamRef.current = null;
447
+ }
448
+ if (audioContextRef.current) {
449
+ audioContextRef.current.close().catch(() => {});
450
+ audioContextRef.current = null;
451
+ }
452
+ if (speechRef.current) {
453
+ // Stop the Web Speech session before dropping the ref so the browser
454
+ // releases the mic and stops dispatching onresult events into a stale
455
+ // closure. abort() is fire-and-forget (no final result); stop() would
456
+ // deliver remaining partials but we've already cleared state.
457
+ try {
458
+ speechRef.current.abort?.();
459
+ } catch {
460
+ /* ignore */
461
+ }
462
+ }
463
+ if (liveSpeechRef.current) {
464
+ try {
465
+ liveSpeechRef.current.abort?.();
466
+ } catch {
467
+ /* ignore */
468
+ }
469
+ liveSpeechRef.current = null;
470
+ }
471
+ if (realtimeSocketRef.current) {
472
+ const socket = realtimeSocketRef.current;
473
+ realtimeSocketRef.current = null;
474
+ try {
475
+ socket.close();
476
+ } catch {
477
+ /* ignore */
478
+ }
479
+ }
480
+ if (realtimeStopTimeoutRef.current) {
481
+ clearTimeout(realtimeStopTimeoutRef.current);
482
+ realtimeStopTimeoutRef.current = null;
483
+ }
484
+ analyserRef.current = null;
485
+ mediaRecorderRef.current = null;
486
+ chunksRef.current = [];
487
+ speechRef.current = null;
488
+ speechTranscriptRef.current = "";
489
+ liveTextRef.current = "";
490
+ realtimeFinalRef.current = "";
491
+ realtimeInterimRef.current = "";
492
+ setAmplitude(0);
493
+ }, []);
494
+
495
+ useEffect(() => teardown, [teardown]);
496
+
497
+ const failWith = useCallback(
498
+ (message: string) => {
499
+ setErrorMessage(message);
500
+ setState("error");
501
+ onErrorRef.current?.(message);
502
+ teardown();
503
+ },
504
+ [teardown],
505
+ );
506
+
507
+ const getVoiceContextPack = useCallback(
508
+ () => resolveVoiceContextPack(contextPackRef.current),
509
+ [],
510
+ );
511
+
512
+ const startMeter = useCallback((stream: MediaStream) => {
513
+ try {
514
+ const AudioCtor =
515
+ typeof window !== "undefined"
516
+ ? window.AudioContext || (window as any).webkitAudioContext || null
517
+ : null;
518
+ if (!AudioCtor) return;
519
+ const ctx: AudioContext = new AudioCtor();
520
+ const source = ctx.createMediaStreamSource(stream);
521
+ const analyser = ctx.createAnalyser();
522
+ analyser.fftSize = 512;
523
+ source.connect(analyser);
524
+ audioContextRef.current = ctx;
525
+ analyserRef.current = analyser;
526
+
527
+ const buffer = new Uint8Array(analyser.frequencyBinCount);
528
+ const tick = () => {
529
+ if (!analyserRef.current) return;
530
+ analyserRef.current.getByteTimeDomainData(buffer);
531
+ let sumSquares = 0;
532
+ for (let i = 0; i < buffer.length; i++) {
533
+ const n = (buffer[i] - 128) / 128;
534
+ sumSquares += n * n;
535
+ }
536
+ const rms = Math.sqrt(sumSquares / buffer.length);
537
+ setAmplitude(Math.min(1, rms * 2.5));
538
+ rafRef.current = requestAnimationFrame(tick);
539
+ };
540
+ rafRef.current = requestAnimationFrame(tick);
541
+ } catch {
542
+ /* analyser is best-effort */
543
+ }
544
+ }, []);
545
+
546
+ const startTimer = useCallback(() => {
547
+ startedAtRef.current = Date.now();
548
+ setDurationMs(0);
549
+ timerRef.current = setInterval(() => {
550
+ setDurationMs(Date.now() - startedAtRef.current);
551
+ }, 100);
552
+ }, []);
553
+
554
+ const startOpenAi = useCallback(
555
+ async (providerPref: VoiceProvider, instructions?: string) => {
556
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
557
+ // User may have pressed Escape (cancel) while the permission prompt was
558
+ // open. If so, stop the stream and bail before we start recording.
559
+ if (cancelledRef.current) {
560
+ for (const track of stream.getTracks()) track.stop();
561
+ cancelledRef.current = false;
562
+ setState("idle");
563
+ return;
564
+ }
565
+ mediaStreamRef.current = stream;
566
+ const mimeType = pickMimeType();
567
+ const recorder = new MediaRecorder(stream, { mimeType });
568
+ mediaRecorderRef.current = recorder;
569
+ chunksRef.current = [];
570
+
571
+ recorder.ondataavailable = (e) => {
572
+ if (e.data && e.data.size > 0) chunksRef.current.push(e.data);
573
+ };
574
+ recorder.onstop = async () => {
575
+ const localChunks = chunksRef.current.slice();
576
+ const localMime = recorder.mimeType || mimeType;
577
+ const liveSnapshot = liveTextRef.current;
578
+ teardown();
579
+ if (cancelledRef.current) {
580
+ cancelledRef.current = false;
581
+ setState("idle");
582
+ return;
583
+ }
584
+ if (localChunks.length === 0) {
585
+ if (liveSnapshot) onTranscriptRef.current?.(liveSnapshot.trim());
586
+ setState("idle");
587
+ return;
588
+ }
589
+ setState("transcribing");
590
+ try {
591
+ const audioBlob = new Blob(localChunks, { type: localMime });
592
+ const form = new FormData();
593
+ form.append(
594
+ "audio",
595
+ audioBlob,
596
+ `voice.${localMime.split("/")[1] ?? "webm"}`,
597
+ );
598
+ form.append("provider", providerPref);
599
+ if (instructions?.trim()) {
600
+ form.append("instructions", instructions.trim());
601
+ }
602
+ appendVoiceContext(form, await getVoiceContextPack());
603
+ const res = await fetch(resolvePath(TRANSCRIBE_URL), {
604
+ method: "POST",
605
+ body: form,
606
+ });
607
+ if (!res.ok) {
608
+ const body = await res
609
+ .json()
610
+ .catch(() => ({ error: `HTTP ${res.status}` }));
611
+ throw new Error(
612
+ body.error || `Transcription failed (${res.status})`,
613
+ );
614
+ }
615
+ if (cancelledRef.current) {
616
+ cancelledRef.current = false;
617
+ setState("idle");
618
+ return;
619
+ }
620
+ const data = (await res.json()) as { text?: string };
621
+ const text = (data.text ?? "").trim();
622
+ if (text) {
623
+ onTranscriptRef.current?.(text);
624
+ } else if (liveSnapshot) {
625
+ onTranscriptRef.current?.(liveSnapshot.trim());
626
+ }
627
+ setState("idle");
628
+ } catch (err) {
629
+ if (cancelledRef.current) {
630
+ cancelledRef.current = false;
631
+ setState("idle");
632
+ return;
633
+ }
634
+ if (liveSnapshot) {
635
+ onTranscriptRef.current?.(liveSnapshot.trim());
636
+ setState("idle");
637
+ } else {
638
+ failWith(
639
+ (err as Error)?.message ??
640
+ "Transcription failed. Check your voice transcription provider in settings.",
641
+ );
642
+ }
643
+ }
644
+ };
645
+
646
+ startMeter(stream);
647
+ startTimer();
648
+ setState("recording");
649
+ recorder.start();
650
+
651
+ // Start parallel Web Speech recognition for live preview text.
652
+ // This runs alongside MediaRecorder so the user sees words appear
653
+ // immediately while the server provider processes the full recording later.
654
+ const SpeechCtor = getSpeechRecognitionCtor();
655
+ if (SpeechCtor) {
656
+ const liveSpeech = new SpeechCtor();
657
+ liveSpeech.continuous = true;
658
+ liveSpeech.interimResults = true;
659
+ liveSpeech.lang =
660
+ (typeof navigator !== "undefined" && navigator.language) || "en-US";
661
+ liveSpeechRef.current = liveSpeech;
662
+ liveTextRef.current = "";
663
+
664
+ liveSpeech.onresult = (event: any) => {
665
+ let interim = "";
666
+ for (let i = event.resultIndex; i < event.results.length; i++) {
667
+ const result = event.results[i];
668
+ const text = result[0]?.transcript ?? "";
669
+ if (result.isFinal) {
670
+ liveTextRef.current += text;
671
+ } else {
672
+ interim += text;
673
+ }
674
+ }
675
+ onLiveUpdateRef.current?.(liveTextRef.current, interim);
676
+ };
677
+
678
+ liveSpeech.onend = () => {
679
+ if (liveSpeechRef.current === liveSpeech) {
680
+ try {
681
+ liveSpeech.start();
682
+ } catch {
683
+ /* ignore */
684
+ }
685
+ }
686
+ };
687
+
688
+ liveSpeech.onerror = () => {};
689
+
690
+ try {
691
+ liveSpeech.start();
692
+ } catch {
693
+ /* best effort — live preview just won't appear */
694
+ }
695
+ }
696
+ },
697
+ [
698
+ startMeter,
699
+ startTimer,
700
+ teardown,
701
+ failWith,
702
+ getVoiceContextPack,
703
+ resolvePath,
704
+ ],
705
+ );
706
+
707
+ const startBrowser = useCallback(
708
+ async (
709
+ prefs: VoicePrefs,
710
+ /** Return true to take over when the recognizer never opened the mic.
711
+ * Brave ships `webkitSpeechRecognition` with no speech backend, so
712
+ * feature detection alone cannot tell dictation will work. */
713
+ onUnavailable?: (error: string | undefined) => boolean,
714
+ ) => {
715
+ const Ctor = getSpeechRecognitionCtor();
716
+ if (!Ctor) {
717
+ throw new Error(
718
+ "Your browser doesn't support speech recognition. Add an OpenAI API key in settings for Whisper transcription.",
719
+ );
720
+ }
721
+ if (cancelledRef.current) {
722
+ cancelledRef.current = false;
723
+ setState("idle");
724
+ return;
725
+ }
726
+
727
+ const recognition = new Ctor();
728
+ recognition.continuous = true;
729
+ recognition.interimResults = true;
730
+ recognition.lang =
731
+ (typeof navigator !== "undefined" && navigator.language) || "en-US";
732
+ speechRef.current = recognition;
733
+ speechTranscriptRef.current = "";
734
+
735
+ let capturing = false;
736
+ let fatal = false;
737
+ let lastError: string | undefined;
738
+
739
+ // Opening our own capture before the speech service has claimed the
740
+ // device makes Chrome abort the session outright. Attach the meter only
741
+ // once recognition is actually listening.
742
+ recognition.onaudiostart = () => {
743
+ capturing = true;
744
+ if (cancelledRef.current) return;
745
+ void Promise.resolve()
746
+ .then(() => navigator.mediaDevices?.getUserMedia({ audio: true }))
747
+ .then((stream) => {
748
+ if (!stream) return;
749
+ if (cancelledRef.current || speechRef.current !== recognition) {
750
+ for (const track of stream.getTracks()) track.stop();
751
+ return;
752
+ }
753
+ mediaStreamRef.current = stream;
754
+ startMeter(stream);
755
+ })
756
+ .catch(() => {
757
+ /* the meter is decoration; recognition owns the real capture */
758
+ });
759
+ };
760
+
761
+ recognition.onresult = (event: any) => {
762
+ capturing = true;
763
+ let interim = "";
764
+ for (let i = event.resultIndex; i < event.results.length; i++) {
765
+ const result = event.results[i];
766
+ const text = result[0]?.transcript ?? "";
767
+ if (result.isFinal) {
768
+ speechTranscriptRef.current += text;
769
+ } else {
770
+ interim += text;
771
+ }
772
+ }
773
+ onLiveUpdateRef.current?.(speechTranscriptRef.current, interim);
774
+ };
775
+ // `end` always follows `error`, so every outcome is decided there. Acting
776
+ // here too would either pre-empt the fallback or be overwritten by it.
777
+ recognition.onerror = (event: any) => {
778
+ lastError = event?.error;
779
+ if (event?.error === "no-speech" || event?.error === "aborted") return;
780
+ fatal = true;
781
+ };
782
+ recognition.onend = () => {
783
+ const text = speechTranscriptRef.current.trim();
784
+ const wasCancelled = cancelledRef.current;
785
+ cancelledRef.current = false;
786
+ teardown();
787
+ if (wasCancelled) {
788
+ setState("idle");
789
+ return;
790
+ }
791
+ if (!text) {
792
+ // A recognizer that failed, or that ended before the mic ever opened,
793
+ // produced nothing usable — that is not the same as hearing silence.
794
+ if (fatal || !capturing) {
795
+ if (onUnavailable?.(lastError)) return;
796
+ failWith(voiceDictationSpeechErrorMessage(lastError));
797
+ return;
798
+ }
799
+ setState("idle");
800
+ return;
801
+ }
802
+ void (async () => {
803
+ let finalText = text;
804
+ if (prefs.cleanupEnabled) {
805
+ setState("transcribing");
806
+ try {
807
+ finalText = await cleanupRecognizedText({
808
+ text,
809
+ provider: prefs.provider,
810
+ instructions: prefs.instructions,
811
+ contextPack: await getVoiceContextPack(),
812
+ resolvePath,
813
+ replaceContext,
814
+ });
815
+ } catch {
816
+ finalText = text;
817
+ }
818
+ }
819
+ if (!cancelledRef.current && finalText) {
820
+ onTranscriptRef.current?.(finalText);
821
+ }
822
+ cancelledRef.current = false;
823
+ setState("idle");
824
+ })();
825
+ };
826
+
827
+ startTimer();
828
+ setState("recording");
829
+ recognition.start();
830
+ },
831
+ [
832
+ startMeter,
833
+ startTimer,
834
+ teardown,
835
+ failWith,
836
+ getVoiceContextPack,
837
+ replaceContext,
838
+ resolvePath,
839
+ ],
840
+ );
841
+
842
+ const startGoogleRealtime = useCallback(
843
+ async (prefs: VoicePrefs) => {
844
+ const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
845
+ if (cancelledRef.current) {
846
+ for (const track of stream.getTracks()) track.stop();
847
+ cancelledRef.current = false;
848
+ setState("idle");
849
+ return;
850
+ }
851
+
852
+ const sessionRes = await fetch(resolvePath(GOOGLE_REALTIME_SESSION_URL), {
853
+ method: "POST",
854
+ headers: { "Content-Type": "application/json" },
855
+ body: JSON.stringify({
856
+ language:
857
+ (typeof navigator !== "undefined" && navigator.language) || "en-US",
858
+ }),
859
+ });
860
+ const sessionBody = (await sessionRes
861
+ .json()
862
+ .catch(() => ({ error: `HTTP ${sessionRes.status}` }))) as {
863
+ websocketUrl?: string;
864
+ websocketProtocol?: string;
865
+ sessionToken?: string;
866
+ error?: string;
867
+ };
868
+ if (
869
+ !sessionRes.ok ||
870
+ !sessionBody.websocketUrl ||
871
+ !sessionBody.sessionToken
872
+ ) {
873
+ for (const track of stream.getTracks()) track.stop();
874
+ throw new Error(
875
+ sessionBody.error ||
876
+ `Could not start Google realtime transcription (${sessionRes.status})`,
877
+ );
878
+ }
879
+ if (cancelledRef.current) {
880
+ for (const track of stream.getTracks()) track.stop();
881
+ cancelledRef.current = false;
882
+ setState("idle");
883
+ return;
884
+ }
885
+
886
+ mediaStreamRef.current = stream;
887
+ const mimeType = pickMimeType();
888
+ const recorder = new MediaRecorder(stream, { mimeType });
889
+ mediaRecorderRef.current = recorder;
890
+ realtimeFinalRef.current = "";
891
+ realtimeInterimRef.current = "";
892
+
893
+ let finalized = false;
894
+ let recorderStarted = false;
895
+ const finish = (errorMessage?: string) => {
896
+ if (finalized) return;
897
+ finalized = true;
898
+ void (async () => {
899
+ const finalText = realtimeFinalRef.current.trim();
900
+ const interimText = realtimeInterimRef.current.trim();
901
+ const text = [finalText, interimText]
902
+ .filter(Boolean)
903
+ .join(" ")
904
+ .trim();
905
+ teardown();
906
+ if (cancelledRef.current) {
907
+ cancelledRef.current = false;
908
+ setState("idle");
909
+ return;
910
+ }
911
+ if (text) {
912
+ let cleanedText = text;
913
+ if (prefs.cleanupEnabled) {
914
+ setState("transcribing");
915
+ try {
916
+ cleanedText = await cleanupRecognizedText({
917
+ text,
918
+ provider: prefs.provider,
919
+ instructions: prefs.instructions,
920
+ contextPack: await getVoiceContextPack(),
921
+ resolvePath,
922
+ replaceContext,
923
+ });
924
+ } catch {
925
+ cleanedText = text;
926
+ }
927
+ }
928
+ if (!cancelledRef.current && cleanedText) {
929
+ onTranscriptRef.current?.(cleanedText);
930
+ }
931
+ cancelledRef.current = false;
932
+ setState("idle");
933
+ return;
934
+ }
935
+ if (errorMessage) {
936
+ failWith(errorMessage);
937
+ return;
938
+ }
939
+ setState("idle");
940
+ })();
941
+ };
942
+
943
+ recorder.ondataavailable = async (event) => {
944
+ if (!event.data || event.data.size === 0) return;
945
+ const socket = realtimeSocketRef.current;
946
+ if (!socket || socket.readyState !== WebSocket.OPEN) return;
947
+ try {
948
+ socket.send(await event.data.arrayBuffer());
949
+ } catch (err) {
950
+ finish((err as Error)?.message ?? "Realtime audio upload failed");
951
+ }
952
+ };
953
+
954
+ recorder.onstop = () => {
955
+ const socket = realtimeSocketRef.current;
956
+ if (!socket || socket.readyState !== WebSocket.OPEN) {
957
+ finish();
958
+ return;
959
+ }
960
+ setState("transcribing");
961
+ try {
962
+ socket.send(JSON.stringify({ type: "stop" }));
963
+ } catch {
964
+ finish();
965
+ return;
966
+ }
967
+ realtimeStopTimeoutRef.current = window.setTimeout(() => {
968
+ const activeSocket = realtimeSocketRef.current;
969
+ if (activeSocket?.readyState === WebSocket.OPEN) {
970
+ try {
971
+ activeSocket.close();
972
+ } catch {
973
+ finish();
974
+ }
975
+ return;
976
+ }
977
+ finish();
978
+ }, 10000);
979
+ };
980
+
981
+ const socket = new WebSocket(sessionBody.websocketUrl, [
982
+ sessionBody.websocketProtocol || GOOGLE_REALTIME_WS_PROTOCOL,
983
+ sessionBody.sessionToken,
984
+ ]);
985
+ socket.binaryType = "arraybuffer";
986
+ realtimeSocketRef.current = socket;
987
+
988
+ socket.onmessage = (event) => {
989
+ if (cancelledRef.current) {
990
+ finish();
991
+ return;
992
+ }
993
+ const raw =
994
+ typeof event.data === "string"
995
+ ? event.data
996
+ : event.data instanceof Blob
997
+ ? null
998
+ : new TextDecoder().decode(event.data);
999
+ if (!raw) return;
1000
+ let message:
1001
+ | {
1002
+ type?: string;
1003
+ text?: string;
1004
+ error?: string;
1005
+ }
1006
+ | undefined;
1007
+ try {
1008
+ message = JSON.parse(raw);
1009
+ } catch {
1010
+ return;
1011
+ }
1012
+ if (!message?.type) return;
1013
+ if (message.type === "ready") {
1014
+ if (!recorderStarted) {
1015
+ recorderStarted = true;
1016
+ startMeter(stream);
1017
+ startTimer();
1018
+ setState("recording");
1019
+ recorder.start(100);
1020
+ }
1021
+ return;
1022
+ }
1023
+ if (message.type === "partial") {
1024
+ realtimeInterimRef.current = (message.text ?? "").trim();
1025
+ onLiveUpdateRef.current?.(
1026
+ realtimeFinalRef.current,
1027
+ realtimeInterimRef.current,
1028
+ );
1029
+ return;
1030
+ }
1031
+ if (message.type === "final") {
1032
+ const next = (message.text ?? "").trim();
1033
+ if (next) {
1034
+ realtimeFinalRef.current = [realtimeFinalRef.current.trim(), next]
1035
+ .filter(Boolean)
1036
+ .join(" ");
1037
+ }
1038
+ realtimeInterimRef.current = "";
1039
+ onLiveUpdateRef.current?.(realtimeFinalRef.current, "");
1040
+ return;
1041
+ }
1042
+ if (message.type === "error") {
1043
+ finish(message.error || "Google realtime transcription failed");
1044
+ return;
1045
+ }
1046
+ if (message.type === "end") {
1047
+ finish();
1048
+ }
1049
+ };
1050
+
1051
+ socket.onerror = () => {
1052
+ finish("Google realtime transcription connection failed");
1053
+ };
1054
+
1055
+ socket.onclose = () => {
1056
+ finish();
1057
+ };
1058
+
1059
+ socket.onopen = () => {
1060
+ if (cancelledRef.current) {
1061
+ finish();
1062
+ return;
1063
+ }
1064
+ try {
1065
+ socket.send(
1066
+ JSON.stringify({
1067
+ type: "start",
1068
+ language:
1069
+ (typeof navigator !== "undefined" && navigator.language) ||
1070
+ "en-US",
1071
+ interimResults: true,
1072
+ mimeType,
1073
+ }),
1074
+ );
1075
+ } catch (err) {
1076
+ finish((err as Error)?.message ?? "Could not start realtime stream");
1077
+ }
1078
+ };
1079
+ },
1080
+ [
1081
+ startMeter,
1082
+ startTimer,
1083
+ teardown,
1084
+ failWith,
1085
+ getVoiceContextPack,
1086
+ replaceContext,
1087
+ resolvePath,
1088
+ ],
1089
+ );
1090
+
1091
+ const start = useCallback(async () => {
1092
+ if (state === "recording" || state === "starting") return;
1093
+ setErrorMessage(null);
1094
+ setState("starting");
1095
+ cancelledRef.current = false;
1096
+
1097
+ const prefs = await readVoicePrefs(resolvePath);
1098
+ const pref = prefs.provider;
1099
+ setProvider(pref);
1100
+
1101
+ // In "auto" mode, prefer browser-native SpeechRecognition when available.
1102
+ // It requires no server-side API key, streams words incrementally into the
1103
+ // composer, and matches the macros-app record-button experience. Fall back
1104
+ // to the server upload path only when SpeechRecognition isn't supported.
1105
+ // Explicit server providers (builder, gemini, groq, openai) always use the
1106
+ // MediaRecorder → server upload path regardless.
1107
+ const resolvedProvider: VoiceProvider =
1108
+ pref === "auto" && speechSupported
1109
+ ? "browser"
1110
+ : pref === "auto" ||
1111
+ pref === "builder" ||
1112
+ pref === "builder-gemini" ||
1113
+ pref === "gemini" ||
1114
+ pref === "groq"
1115
+ ? "openai"
1116
+ : pref;
1117
+ activeProviderRef.current = resolvedProvider;
1118
+
1119
+ try {
1120
+ if (resolvedProvider === "openai") {
1121
+ if (!mediaRecorderSupported) {
1122
+ throw new Error(
1123
+ "Your browser doesn't support audio recording. Use the browser provider in Settings → Voice Transcription.",
1124
+ );
1125
+ }
1126
+ await startOpenAi(pref, prefs.instructions);
1127
+ } else if (resolvedProvider === "google-realtime") {
1128
+ if (!mediaRecorderSupported) {
1129
+ throw new Error(
1130
+ "Your browser doesn't support audio recording, so Google realtime transcription can't start.",
1131
+ );
1132
+ }
1133
+ await startGoogleRealtime(prefs);
1134
+ } else {
1135
+ // Only "auto" promised a working recognizer of any kind; an explicit
1136
+ // browser preference must surface its own failure instead.
1137
+ await startBrowser(
1138
+ prefs,
1139
+ pref === "auto" && mediaRecorderSupported
1140
+ ? (error) => {
1141
+ if (isMicPermissionError(error)) return false;
1142
+ activeProviderRef.current = "openai";
1143
+ setState("starting");
1144
+ void startOpenAi("auto", prefs.instructions).catch((err) =>
1145
+ failWith(voiceDictationStartErrorMessage(err)),
1146
+ );
1147
+ return true;
1148
+ }
1149
+ : undefined,
1150
+ );
1151
+ }
1152
+ } catch (err) {
1153
+ if (cancelledRef.current) {
1154
+ cancelledRef.current = false;
1155
+ teardown();
1156
+ setState("idle");
1157
+ return;
1158
+ }
1159
+ failWith(voiceDictationStartErrorMessage(err));
1160
+ }
1161
+ }, [
1162
+ state,
1163
+ speechSupported,
1164
+ mediaRecorderSupported,
1165
+ startOpenAi,
1166
+ startGoogleRealtime,
1167
+ startBrowser,
1168
+ failWith,
1169
+ ]);
1170
+
1171
+ const stop = useCallback(() => {
1172
+ if (state !== "recording") return;
1173
+ cancelledRef.current = false;
1174
+ if (
1175
+ (activeProviderRef.current === "openai" ||
1176
+ activeProviderRef.current === "google-realtime") &&
1177
+ mediaRecorderRef.current
1178
+ ) {
1179
+ try {
1180
+ mediaRecorderRef.current.stop();
1181
+ } catch {
1182
+ teardown();
1183
+ setState("idle");
1184
+ }
1185
+ } else if (speechRef.current) {
1186
+ try {
1187
+ speechRef.current.stop();
1188
+ } catch {
1189
+ teardown();
1190
+ setState("idle");
1191
+ }
1192
+ } else {
1193
+ teardown();
1194
+ setState("idle");
1195
+ }
1196
+ }, [state, teardown]);
1197
+
1198
+ const cancel = useCallback(() => {
1199
+ if (
1200
+ state !== "recording" &&
1201
+ state !== "starting" &&
1202
+ state !== "transcribing"
1203
+ )
1204
+ return;
1205
+ cancelledRef.current = true;
1206
+ if (
1207
+ (activeProviderRef.current === "openai" ||
1208
+ activeProviderRef.current === "google-realtime") &&
1209
+ mediaRecorderRef.current
1210
+ ) {
1211
+ try {
1212
+ mediaRecorderRef.current.stop();
1213
+ } catch {
1214
+ /* ignore */
1215
+ }
1216
+ } else if (speechRef.current) {
1217
+ try {
1218
+ speechRef.current.abort?.();
1219
+ } catch {
1220
+ /* ignore */
1221
+ }
1222
+ }
1223
+ teardown();
1224
+ setState("idle");
1225
+ }, [state, teardown]);
1226
+
1227
+ // Auto-dismiss error after 8s so a stale "permission denied" message doesn't
1228
+ // sit forever after the user fixes the underlying permission. Manual dismiss
1229
+ // (via dismissError) and click-to-retry both also clear the error sooner.
1230
+ useEffect(() => {
1231
+ if (state !== "error") return;
1232
+ const handle = setTimeout(() => {
1233
+ setErrorMessage(null);
1234
+ setState("idle");
1235
+ }, 8000);
1236
+ return () => clearTimeout(handle);
1237
+ }, [state]);
1238
+
1239
+ const dismissError = useCallback(() => {
1240
+ setErrorMessage(null);
1241
+ if (state === "error") setState("idle");
1242
+ }, [state]);
1243
+
1244
+ return {
1245
+ state,
1246
+ amplitude,
1247
+ durationMs,
1248
+ errorMessage,
1249
+ provider,
1250
+ supported,
1251
+ start,
1252
+ stop,
1253
+ cancel,
1254
+ dismissError,
1255
+ };
1256
+ }