@assistant-ui/react 0.11.53 → 0.11.55

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 (219) hide show
  1. package/README.md +6 -3
  2. package/dist/client/NoOpComposerClient.d.ts +1 -1
  3. package/dist/client/NoOpComposerClient.d.ts.map +1 -1
  4. package/dist/client/NoOpComposerClient.js +7 -0
  5. package/dist/client/NoOpComposerClient.js.map +1 -1
  6. package/dist/client/types/Composer.d.ts +18 -3
  7. package/dist/client/types/Composer.d.ts.map +1 -1
  8. package/dist/client/types/Message.d.ts +17 -3
  9. package/dist/client/types/Message.d.ts.map +1 -1
  10. package/dist/legacy-runtime/client/ComposerRuntimeClient.d.ts.map +1 -1
  11. package/dist/legacy-runtime/client/ComposerRuntimeClient.js +3 -0
  12. package/dist/legacy-runtime/client/ComposerRuntimeClient.js.map +1 -1
  13. package/dist/legacy-runtime/hooks/AssistantContext.d.ts +2 -2
  14. package/dist/legacy-runtime/hooks/AssistantContext.js +1 -1
  15. package/dist/legacy-runtime/hooks/AttachmentContext.d.ts +2 -2
  16. package/dist/legacy-runtime/hooks/AttachmentContext.js +1 -1
  17. package/dist/legacy-runtime/hooks/ComposerContext.d.ts +2 -2
  18. package/dist/legacy-runtime/hooks/ComposerContext.js +1 -1
  19. package/dist/legacy-runtime/hooks/MessageContext.d.ts +3 -3
  20. package/dist/legacy-runtime/hooks/MessageContext.js +2 -2
  21. package/dist/legacy-runtime/hooks/MessagePartContext.d.ts +2 -2
  22. package/dist/legacy-runtime/hooks/MessagePartContext.js +1 -1
  23. package/dist/legacy-runtime/hooks/ThreadContext.d.ts +4 -4
  24. package/dist/legacy-runtime/hooks/ThreadContext.js +2 -2
  25. package/dist/legacy-runtime/hooks/ThreadListItemContext.d.ts +2 -2
  26. package/dist/legacy-runtime/hooks/ThreadListItemContext.js +1 -1
  27. package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts +22 -6
  28. package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts.map +1 -1
  29. package/dist/legacy-runtime/runtime/ComposerRuntime.js +18 -2
  30. package/dist/legacy-runtime/runtime/ComposerRuntime.js.map +1 -1
  31. package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts +3 -0
  32. package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts.map +1 -1
  33. package/dist/legacy-runtime/runtime-cores/adapters/speech/SpeechAdapterTypes.d.ts +25 -3
  34. package/dist/legacy-runtime/runtime-cores/adapters/speech/SpeechAdapterTypes.d.ts.map +1 -1
  35. package/dist/legacy-runtime/runtime-cores/adapters/speech/WebSpeechDictationAdapter.d.ts +61 -0
  36. package/dist/legacy-runtime/runtime-cores/adapters/speech/WebSpeechDictationAdapter.d.ts.map +1 -0
  37. package/dist/legacy-runtime/runtime-cores/adapters/speech/WebSpeechDictationAdapter.js +152 -0
  38. package/dist/legacy-runtime/runtime-cores/adapters/speech/WebSpeechDictationAdapter.js.map +1 -0
  39. package/dist/legacy-runtime/runtime-cores/adapters/speech/index.d.ts +2 -1
  40. package/dist/legacy-runtime/runtime-cores/adapters/speech/index.d.ts.map +1 -1
  41. package/dist/legacy-runtime/runtime-cores/adapters/speech/index.js +1 -0
  42. package/dist/legacy-runtime/runtime-cores/adapters/speech/index.js.map +1 -1
  43. package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts +1 -1
  44. package/dist/legacy-runtime/runtime-cores/assistant-transport/types.d.ts.map +1 -1
  45. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
  46. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js +4 -1
  47. package/dist/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
  48. package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts +20 -5
  49. package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
  50. package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js +140 -0
  51. package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.js.map +1 -1
  52. package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.d.ts +6 -3
  53. package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  54. package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.js +3 -0
  55. package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  56. package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.d.ts +7 -4
  57. package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.d.ts.map +1 -1
  58. package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.js +3 -0
  59. package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
  60. package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts +35 -1
  61. package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts.map +1 -1
  62. package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts +1 -0
  63. package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts.map +1 -1
  64. package/dist/legacy-runtime/runtime-cores/core/index.d.ts +1 -0
  65. package/dist/legacy-runtime/runtime-cores/core/index.d.ts.map +1 -1
  66. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts +8 -7
  67. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts.map +1 -1
  68. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts +7 -6
  69. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
  70. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js +4 -2
  71. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
  72. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts +10 -8
  73. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts.map +1 -1
  74. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.js.map +1 -1
  75. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts +5 -3
  76. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts.map +1 -1
  77. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js +6 -0
  78. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.js.map +1 -1
  79. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts +1 -1
  80. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -1
  81. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js +8 -0
  82. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -1
  83. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  84. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js +8 -1
  85. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js.map +1 -1
  86. package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts +12 -0
  87. package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts.map +1 -0
  88. package/dist/primitives/actionBarMore/ActionBarMoreContent.js +11 -0
  89. package/dist/primitives/actionBarMore/ActionBarMoreContent.js.map +1 -0
  90. package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts +8 -0
  91. package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts.map +1 -0
  92. package/dist/primitives/actionBarMore/ActionBarMoreItem.js +11 -0
  93. package/dist/primitives/actionBarMore/ActionBarMoreItem.js.map +1 -0
  94. package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts +7 -0
  95. package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts.map +1 -0
  96. package/dist/primitives/actionBarMore/ActionBarMoreRoot.js +10 -0
  97. package/dist/primitives/actionBarMore/ActionBarMoreRoot.js.map +1 -0
  98. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts +8 -0
  99. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts.map +1 -0
  100. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js +12 -0
  101. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.js.map +1 -0
  102. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts +8 -0
  103. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts.map +1 -0
  104. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js +11 -0
  105. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.js.map +1 -0
  106. package/dist/primitives/actionBarMore/index.d.ts +6 -0
  107. package/dist/primitives/actionBarMore/index.d.ts.map +1 -0
  108. package/dist/primitives/actionBarMore/index.js +6 -0
  109. package/dist/primitives/actionBarMore/index.js.map +1 -0
  110. package/dist/primitives/actionBarMore/scope.d.ts +7 -0
  111. package/dist/primitives/actionBarMore/scope.d.ts.map +1 -0
  112. package/dist/primitives/actionBarMore/scope.js +3 -0
  113. package/dist/primitives/actionBarMore/scope.js.map +1 -0
  114. package/dist/primitives/composer/ComposerDictate.d.ts +23 -0
  115. package/dist/primitives/composer/ComposerDictate.d.ts.map +1 -0
  116. package/dist/primitives/composer/ComposerDictate.js +30 -0
  117. package/dist/primitives/composer/ComposerDictate.js.map +1 -0
  118. package/dist/primitives/composer/ComposerDictationTranscript.d.ts +25 -0
  119. package/dist/primitives/composer/ComposerDictationTranscript.d.ts.map +1 -0
  120. package/dist/primitives/composer/ComposerDictationTranscript.js +29 -0
  121. package/dist/primitives/composer/ComposerDictationTranscript.js.map +1 -0
  122. package/dist/primitives/composer/ComposerIf.d.ts +3 -0
  123. package/dist/primitives/composer/ComposerIf.d.ts.map +1 -1
  124. package/dist/primitives/composer/ComposerIf.js +5 -0
  125. package/dist/primitives/composer/ComposerIf.js.map +1 -1
  126. package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
  127. package/dist/primitives/composer/ComposerInput.js +1 -1
  128. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  129. package/dist/primitives/composer/ComposerStopDictation.d.ts +23 -0
  130. package/dist/primitives/composer/ComposerStopDictation.d.ts.map +1 -0
  131. package/dist/primitives/composer/ComposerStopDictation.js +28 -0
  132. package/dist/primitives/composer/ComposerStopDictation.js.map +1 -0
  133. package/dist/primitives/composer/index.d.ts +3 -0
  134. package/dist/primitives/composer/index.d.ts.map +1 -1
  135. package/dist/primitives/composer/index.js +3 -0
  136. package/dist/primitives/composer/index.js.map +1 -1
  137. package/dist/primitives/index.d.ts +2 -0
  138. package/dist/primitives/index.d.ts.map +1 -1
  139. package/dist/primitives/index.js +2 -0
  140. package/dist/primitives/index.js.map +1 -1
  141. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts +12 -0
  142. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts.map +1 -0
  143. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +12 -0
  144. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -0
  145. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts +8 -0
  146. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts.map +1 -0
  147. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js +12 -0
  148. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.js.map +1 -0
  149. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts +7 -0
  150. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts.map +1 -0
  151. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js +11 -0
  152. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.js.map +1 -0
  153. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts +8 -0
  154. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts.map +1 -0
  155. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js +12 -0
  156. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.js.map +1 -0
  157. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts +8 -0
  158. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts.map +1 -0
  159. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +12 -0
  160. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -0
  161. package/dist/primitives/threadListItemMore/index.d.ts +6 -0
  162. package/dist/primitives/threadListItemMore/index.d.ts.map +1 -0
  163. package/dist/primitives/threadListItemMore/index.js +6 -0
  164. package/dist/primitives/threadListItemMore/index.js.map +1 -0
  165. package/dist/primitives/threadListItemMore/scope.d.ts +7 -0
  166. package/dist/primitives/threadListItemMore/scope.d.ts.map +1 -0
  167. package/dist/primitives/threadListItemMore/scope.js +3 -0
  168. package/dist/primitives/threadListItemMore/scope.js.map +1 -0
  169. package/package.json +6 -5
  170. package/src/client/NoOpComposerClient.tsx +8 -1
  171. package/src/client/types/Composer.ts +21 -4
  172. package/src/client/types/Message.ts +17 -3
  173. package/src/legacy-runtime/client/ComposerRuntimeClient.ts +4 -0
  174. package/src/legacy-runtime/hooks/AssistantContext.ts +2 -2
  175. package/src/legacy-runtime/hooks/AttachmentContext.ts +2 -2
  176. package/src/legacy-runtime/hooks/ComposerContext.ts +2 -2
  177. package/src/legacy-runtime/hooks/MessageContext.ts +3 -3
  178. package/src/legacy-runtime/hooks/MessagePartContext.ts +2 -2
  179. package/src/legacy-runtime/hooks/ThreadContext.ts +4 -4
  180. package/src/legacy-runtime/hooks/ThreadListItemContext.ts +2 -2
  181. package/src/legacy-runtime/runtime/ComposerRuntime.ts +51 -14
  182. package/src/legacy-runtime/runtime-cores/adapters/speech/SpeechAdapterTypes.ts +26 -3
  183. package/src/legacy-runtime/runtime-cores/adapters/speech/WebSpeechDictationAdapter.ts +255 -0
  184. package/src/legacy-runtime/runtime-cores/adapters/speech/index.ts +5 -1
  185. package/src/legacy-runtime/runtime-cores/assistant-transport/types.ts +1 -1
  186. package/src/legacy-runtime/runtime-cores/assistant-transport/useAssistantTransportRuntime.tsx +5 -1
  187. package/src/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.tsx +171 -5
  188. package/src/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.tsx +14 -4
  189. package/src/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.tsx +15 -5
  190. package/src/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.tsx +39 -1
  191. package/src/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.tsx +1 -0
  192. package/src/legacy-runtime/runtime-cores/core/index.ts +2 -0
  193. package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.tsx +11 -7
  194. package/src/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.tsx +12 -7
  195. package/src/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.tsx +12 -8
  196. package/src/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.tsx +11 -4
  197. package/src/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.tsx +12 -1
  198. package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +11 -1
  199. package/src/primitives/actionBarMore/ActionBarMoreContent.tsx +46 -0
  200. package/src/primitives/actionBarMore/ActionBarMoreItem.tsx +31 -0
  201. package/src/primitives/actionBarMore/ActionBarMoreRoot.tsx +22 -0
  202. package/src/primitives/actionBarMore/ActionBarMoreSeparator.tsx +32 -0
  203. package/src/primitives/actionBarMore/ActionBarMoreTrigger.tsx +31 -0
  204. package/src/primitives/actionBarMore/index.ts +5 -0
  205. package/src/primitives/actionBarMore/scope.tsx +8 -0
  206. package/src/primitives/composer/ComposerDictate.tsx +48 -0
  207. package/src/primitives/composer/ComposerDictationTranscript.tsx +45 -0
  208. package/src/primitives/composer/ComposerIf.tsx +7 -0
  209. package/src/primitives/composer/ComposerInput.tsx +4 -1
  210. package/src/primitives/composer/ComposerStopDictation.tsx +45 -0
  211. package/src/primitives/composer/index.ts +3 -0
  212. package/src/primitives/index.ts +2 -0
  213. package/src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx +47 -0
  214. package/src/primitives/threadListItemMore/ThreadListItemMoreItem.tsx +32 -0
  215. package/src/primitives/threadListItemMore/ThreadListItemMoreRoot.tsx +23 -0
  216. package/src/primitives/threadListItemMore/ThreadListItemMoreSeparator.tsx +32 -0
  217. package/src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx +32 -0
  218. package/src/primitives/threadListItemMore/index.ts +5 -0
  219. package/src/primitives/threadListItemMore/scope.tsx +8 -0
@@ -5,7 +5,7 @@ import { createStateHookForRuntime } from "../../context/react/utils/createState
5
5
  import { useAssistantApi, useAssistantState } from "../../context/react";
6
6
 
7
7
  /**
8
- * @deprecated Use `useAssistantApi()` with `api.attachment()` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
8
+ * @deprecated Use `useAssistantApi()` with `api.attachment()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
9
9
  */
10
10
  export function useAttachmentRuntime(options?: {
11
11
  optional?: false | undefined;
@@ -84,7 +84,7 @@ export function useMessageAttachmentRuntime(options?: {
84
84
  }
85
85
 
86
86
  /**
87
- * @deprecated Use `useAssistantState(({ attachment }) => attachment)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
87
+ * @deprecated Use `useAssistantState(({ attachment }) => attachment)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
88
88
  */
89
89
  export const useAttachment = createStateHookForRuntime(useAttachmentRuntime);
90
90
 
@@ -5,7 +5,7 @@ import { ComposerRuntime } from "../runtime/ComposerRuntime";
5
5
  import { createStateHookForRuntime } from "../../context/react/utils/createStateHookForRuntime";
6
6
 
7
7
  /**
8
- * @deprecated Use `useAssistantApi()` with `api.composer()` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
8
+ * @deprecated Use `useAssistantApi()` with `api.composer()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
9
9
  *
10
10
  * Hook to access the ComposerRuntime from the current context.
11
11
  *
@@ -87,7 +87,7 @@ export function useComposerRuntime(options?: {
87
87
  }
88
88
 
89
89
  /**
90
- * @deprecated Use `useAssistantState(({ composer }) => composer)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
90
+ * @deprecated Use `useAssistantState(({ composer }) => composer)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
91
91
  *
92
92
  * Hook to access the current composer state.
93
93
  *
@@ -6,7 +6,7 @@ import { createStateHookForRuntime } from "../../context/react/utils/createState
6
6
  import { EditComposerRuntime } from "../runtime";
7
7
 
8
8
  /**
9
- * @deprecated Use `useAssistantApi()` with `api.message()` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
9
+ * @deprecated Use `useAssistantApi()` with `api.message()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
10
10
  *
11
11
  * Hook to access the MessageRuntime from the current context.
12
12
  *
@@ -76,7 +76,7 @@ export function useMessageRuntime(options?: {
76
76
  }
77
77
 
78
78
  /**
79
- * @deprecated Use `useAssistantState(({ message }) => message)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
79
+ * @deprecated Use `useAssistantState(({ message }) => message)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
80
80
  *
81
81
  * Hook to access the current message state.
82
82
  *
@@ -120,7 +120,7 @@ const useEditComposerRuntime = (opt: {
120
120
  }): EditComposerRuntime | null => useMessageRuntime(opt)?.composer ?? null;
121
121
 
122
122
  /**
123
- * @deprecated Use `useAssistantState(({ message }) => message.composer)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
123
+ * @deprecated Use `useAssistantState(({ message }) => message.composer)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
124
124
  */
125
125
  export const useEditComposer = createStateHookForRuntime(
126
126
  useEditComposerRuntime,
@@ -5,7 +5,7 @@ import { createStateHookForRuntime } from "../../context/react/utils/createState
5
5
  import { useAssistantApi, useAssistantState } from "../../context/react";
6
6
 
7
7
  /**
8
- * @deprecated Use `useAssistantApi()` with `api.part()` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
8
+ * @deprecated Use `useAssistantApi()` with `api.part()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
9
9
  */
10
10
  export function useMessagePartRuntime(options?: {
11
11
  optional?: false | undefined;
@@ -27,6 +27,6 @@ export function useMessagePartRuntime(options?: {
27
27
  }
28
28
 
29
29
  /**
30
- * @deprecated Use `useAssistantState(({ part }) => part)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
30
+ * @deprecated Use `useAssistantState(({ part }) => part)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
31
31
  */
32
32
  export const useMessagePart = createStateHookForRuntime(useMessagePartRuntime);
@@ -12,7 +12,7 @@ import {
12
12
  } from "../../context/react";
13
13
 
14
14
  /**
15
- * @deprecated Use `useAssistantApi()` with `api.thread()` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
15
+ * @deprecated Use `useAssistantApi()` with `api.thread()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
16
16
  *
17
17
  * Hook to access the ThreadRuntime from the current context.
18
18
  *
@@ -62,7 +62,7 @@ export function useThreadRuntime(options?: { optional?: boolean | undefined }) {
62
62
  }
63
63
 
64
64
  /**
65
- * @deprecated Use `useAssistantState(({ thread }) => thread)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
65
+ * @deprecated Use `useAssistantState(({ thread }) => thread)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
66
66
  *
67
67
  * Hook to access the current thread state.
68
68
  *
@@ -96,14 +96,14 @@ const useThreadComposerRuntime = (opt: {
96
96
  }): ThreadComposerRuntime | null => useThreadRuntime(opt)?.composer ?? null;
97
97
 
98
98
  /**
99
- * @deprecated Use `useAssistantState(({ thread }) => thread.composer)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
99
+ * @deprecated Use `useAssistantState(({ thread }) => thread.composer)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
100
100
  */
101
101
  export const useThreadComposer = createStateHookForRuntime(
102
102
  useThreadComposerRuntime,
103
103
  );
104
104
 
105
105
  /**
106
- * @deprecated Use `useAssistantState(({ thread }) => thread.modelContext)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
106
+ * @deprecated Use `useAssistantState(({ thread }) => thread.modelContext)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
107
107
  */
108
108
  export function useThreadModelContext(options?: {
109
109
  optional?: false | undefined;
@@ -5,7 +5,7 @@ import { createStateHookForRuntime } from "../../context/react/utils/createState
5
5
  import { useAssistantApi, useAssistantState } from "../../context/react";
6
6
 
7
7
  /**
8
- * @deprecated Use `useAssistantApi()` with `api.threadListItem()` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
8
+ * @deprecated Use `useAssistantApi()` with `api.threadListItem()` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
9
9
  */
10
10
  export function useThreadListItemRuntime(options?: {
11
11
  optional?: false | undefined;
@@ -29,7 +29,7 @@ export function useThreadListItemRuntime(options?: {
29
29
  }
30
30
 
31
31
  /**
32
- * @deprecated Use `useAssistantState(({ threadListItem }) => threadListItem)` instead. See migration guide: https://docs.assistant-ui.com/docs/migrations/v0-12
32
+ * @deprecated Use `useAssistantState(({ threadListItem }) => threadListItem)` instead. See migration guide: https://assistant-ui.com/docs/migrations/v0-12
33
33
  */
34
34
  export const useThreadListItem = createStateHookForRuntime(
35
35
  useThreadListItemRuntime,
@@ -1,28 +1,32 @@
1
- import { Attachment, PendingAttachment } from "../../types/AttachmentTypes";
2
- import {
1
+ import type {
2
+ Attachment,
3
+ PendingAttachment,
4
+ } from "../../types/AttachmentTypes";
5
+ import type {
3
6
  ComposerRuntimeCore,
4
7
  ComposerRuntimeEventType,
8
+ DictationState,
5
9
  ThreadComposerRuntimeCore,
6
10
  } from "../runtime-cores/core/ComposerRuntimeCore";
7
- import { Unsubscribe } from "../../types";
11
+ import type { Unsubscribe } from "../../types";
12
+ import type { MessageRole, RunConfig } from "../../types/AssistantTypes";
13
+ import type {
14
+ ThreadComposerRuntimeCoreBinding,
15
+ EditComposerRuntimeCoreBinding,
16
+ ComposerRuntimeCoreBinding,
17
+ } from "./RuntimeBindings";
18
+ import type { ComposerRuntimePath } from "./RuntimePathTypes";
8
19
 
9
20
  import { LazyMemoizeSubject } from "./subscribable/LazyMemoizeSubject";
10
21
  import {
11
- AttachmentRuntime,
12
- AttachmentState,
22
+ type AttachmentRuntime,
23
+ type AttachmentState,
13
24
  EditComposerAttachmentRuntimeImpl,
14
25
  ThreadComposerAttachmentRuntimeImpl,
15
26
  } from "./AttachmentRuntime";
16
27
  import { ShallowMemoizeSubject } from "./subscribable/ShallowMemoizeSubject";
17
28
  import { SKIP_UPDATE } from "./subscribable/SKIP_UPDATE";
18
- import { ComposerRuntimePath } from "./RuntimePathTypes";
19
- import { MessageRole, RunConfig } from "../../types/AssistantTypes";
20
29
  import { EventSubscriptionSubject } from "./subscribable/EventSubscriptionSubject";
21
- import type {
22
- ThreadComposerRuntimeCoreBinding,
23
- EditComposerRuntimeCoreBinding,
24
- ComposerRuntimeCoreBinding,
25
- } from "./RuntimeBindings";
26
30
 
27
31
  export type {
28
32
  ThreadComposerRuntimeCoreBinding,
@@ -41,6 +45,12 @@ type BaseComposerState = {
41
45
  readonly runConfig: RunConfig;
42
46
 
43
47
  readonly attachmentAccept: string;
48
+
49
+ /**
50
+ * The current state of dictation.
51
+ * Undefined when dictation is not active.
52
+ */
53
+ readonly dictation: DictationState | undefined;
44
54
  };
45
55
 
46
56
  export type ThreadComposerState = BaseComposerState & {
@@ -72,6 +82,7 @@ const getThreadComposerState = (
72
82
  role: runtime?.role ?? "user",
73
83
  runConfig: runtime?.runConfig ?? EMPTY_OBJECT,
74
84
  attachmentAccept: runtime?.attachmentAccept ?? "",
85
+ dictation: runtime?.dictation,
75
86
 
76
87
  value: runtime?.text ?? "",
77
88
  });
@@ -92,6 +103,7 @@ const getEditComposerState = (
92
103
  attachments: runtime?.attachments ?? EMPTY_ARRAY,
93
104
  runConfig: runtime?.runConfig ?? EMPTY_OBJECT,
94
105
  attachmentAccept: runtime?.attachmentAccept ?? "",
106
+ dictation: runtime?.dictation,
95
107
 
96
108
  value: runtime?.text ?? "",
97
109
  });
@@ -169,6 +181,17 @@ export type ComposerRuntime = {
169
181
  */
170
182
  getAttachmentByIndex(idx: number): AttachmentRuntime;
171
183
 
184
+ /**
185
+ * Start dictation to convert voice to text input.
186
+ * Requires a DictationAdapter to be configured.
187
+ */
188
+ startDictation(): void;
189
+
190
+ /**
191
+ * Stop the current dictation session.
192
+ */
193
+ stopDictation(): void;
194
+
172
195
  /**
173
196
  * @deprecated This API is still under active development and might change without notice.
174
197
  */
@@ -199,6 +222,8 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
199
222
  this.cancel = this.cancel.bind(this);
200
223
  this.setRole = this.setRole.bind(this);
201
224
  this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);
225
+ this.startDictation = this.startDictation.bind(this);
226
+ this.stopDictation = this.stopDictation.bind(this);
202
227
  this.unstable_on = this.unstable_on.bind(this);
203
228
  }
204
229
 
@@ -252,6 +277,18 @@ export abstract class ComposerRuntimeImpl implements ComposerRuntime {
252
277
  core.setRole(role);
253
278
  }
254
279
 
280
+ public startDictation() {
281
+ const core = this._core.getState();
282
+ if (!core) throw new Error("Composer is not available");
283
+ core.startDictation();
284
+ }
285
+
286
+ public stopDictation() {
287
+ const core = this._core.getState();
288
+ if (!core) throw new Error("Composer is not available");
289
+ core.stopDictation();
290
+ }
291
+
255
292
  public subscribe(callback: () => void) {
256
293
  return this._core.subscribe(callback);
257
294
  }
@@ -335,7 +372,7 @@ export class ThreadComposerRuntimeImpl
335
372
  ...this.path,
336
373
  attachmentSource: "thread-composer",
337
374
  attachmentSelector: { type: "index", index: idx },
338
- ref: `${this.path.ref}${this.path.ref}.attachments[${idx}]`,
375
+ ref: `${this.path.ref}.attachments[${idx}]`,
339
376
  },
340
377
  getState: () => {
341
378
  const attachments = this.getState().attachments;
@@ -423,7 +460,7 @@ export class EditComposerRuntimeImpl
423
460
  ...this.path,
424
461
  attachmentSource: "edit-composer",
425
462
  attachmentSelector: { type: "index", index: idx },
426
- ref: `${this.path.ref}${this.path.ref}.attachments[${idx}]`,
463
+ ref: `${this.path.ref}.attachments[${idx}]`,
427
464
  },
428
465
  getState: () => {
429
466
  const attachments = this.getState().attachments;
@@ -69,7 +69,7 @@ export type SpeechSynthesisAdapter = {
69
69
  speak: (text: string) => SpeechSynthesisAdapter.Utterance;
70
70
  };
71
71
 
72
- export namespace SpeechRecognitionAdapter {
72
+ export namespace DictationAdapter {
73
73
  export type Status =
74
74
  | {
75
75
  type: "starting" | "running";
@@ -80,7 +80,22 @@ export namespace SpeechRecognitionAdapter {
80
80
  };
81
81
 
82
82
  export type Result = {
83
+ /** The transcribed text */
83
84
  transcript: string;
85
+ /**
86
+ * Whether this is a final (committed) result or an interim (partial) result.
87
+ *
88
+ * - `true` (final): The text should be appended to the composer input.
89
+ * This text is finalized and won't change.
90
+ *
91
+ * - `false` (interim/partial): The text is a preview that may change.
92
+ * It should be displayed as a preview but not appended to the input yet.
93
+ * Subsequent interim results replace the previous interim result.
94
+ *
95
+ * Defaults to `true` for backwards compatibility with adapters that
96
+ * don't set this flag.
97
+ */
98
+ isFinal?: boolean;
84
99
  };
85
100
 
86
101
  export type Session = {
@@ -93,6 +108,14 @@ export namespace SpeechRecognitionAdapter {
93
108
  };
94
109
  }
95
110
 
96
- export type SpeechRecognitionAdapter = {
97
- listen: () => SpeechRecognitionAdapter.Session;
111
+ export type DictationAdapter = {
112
+ listen: () => DictationAdapter.Session;
113
+
114
+ /**
115
+ * Whether to disable text input while dictation is active.
116
+ * Some adapters (like ElevenLabs Scribe) return cumulative transcripts
117
+ * that conflict with simultaneous typing.
118
+ * @default false
119
+ */
120
+ disableInputDuringDictation?: boolean;
98
121
  };
@@ -0,0 +1,255 @@
1
+ import type { Unsubscribe } from "../../../../types";
2
+ import type { DictationAdapter } from "./SpeechAdapterTypes";
3
+
4
+ // Type definitions for Web Speech API
5
+ // Users can install @types/dom-speech-recognition for full type support
6
+ interface SpeechRecognitionResultItem {
7
+ transcript: string;
8
+ confidence: number;
9
+ }
10
+
11
+ interface SpeechRecognitionResult {
12
+ readonly length: number;
13
+ item(index: number): SpeechRecognitionResultItem;
14
+ readonly isFinal: boolean;
15
+ [index: number]: SpeechRecognitionResultItem;
16
+ }
17
+
18
+ interface SpeechRecognitionResultList {
19
+ readonly length: number;
20
+ item(index: number): SpeechRecognitionResult;
21
+ [index: number]: SpeechRecognitionResult;
22
+ }
23
+
24
+ interface SpeechRecognitionEvent extends Event {
25
+ readonly resultIndex: number;
26
+ readonly results: SpeechRecognitionResultList;
27
+ }
28
+
29
+ interface SpeechRecognitionErrorEvent extends Event {
30
+ readonly error: string;
31
+ readonly message: string;
32
+ }
33
+
34
+ interface SpeechRecognitionInstance extends EventTarget {
35
+ lang: string;
36
+ continuous: boolean;
37
+ interimResults: boolean;
38
+ start(): void;
39
+ stop(): void;
40
+ abort(): void;
41
+ }
42
+
43
+ interface SpeechRecognitionConstructor {
44
+ new (): SpeechRecognitionInstance;
45
+ }
46
+
47
+ declare global {
48
+ interface Window {
49
+ SpeechRecognition?: SpeechRecognitionConstructor;
50
+ webkitSpeechRecognition?: SpeechRecognitionConstructor;
51
+ }
52
+ }
53
+
54
+ const getSpeechRecognitionAPI = ():
55
+ | SpeechRecognitionConstructor
56
+ | undefined => {
57
+ if (typeof window === "undefined") return undefined;
58
+ return window.SpeechRecognition ?? window.webkitSpeechRecognition;
59
+ };
60
+
61
+ /**
62
+ * WebSpeechDictationAdapter provides speech-to-text (dictation) functionality using
63
+ * the browser's Web Speech API (SpeechRecognition).
64
+ *
65
+ * @example
66
+ * ```tsx
67
+ * const runtime = useChatRuntime({
68
+ * api: "/api/chat",
69
+ * adapters: {
70
+ * dictation: new WebSpeechDictationAdapter(),
71
+ * },
72
+ * });
73
+ * ```
74
+ */
75
+ export class WebSpeechDictationAdapter implements DictationAdapter {
76
+ private _language: string;
77
+ private _continuous: boolean;
78
+ private _interimResults: boolean;
79
+
80
+ constructor(
81
+ options: {
82
+ /**
83
+ * The language for dictation (e.g., "en-US", "zh-CN").
84
+ * Defaults to the browser's language.
85
+ */
86
+ language?: string;
87
+ /**
88
+ * Whether to keep recording after the user stops speaking.
89
+ * Defaults to true.
90
+ */
91
+ continuous?: boolean;
92
+ /**
93
+ * Whether to return interim (partial) results.
94
+ * Defaults to true for real-time feedback.
95
+ */
96
+ interimResults?: boolean;
97
+ } = {},
98
+ ) {
99
+ const defaultLanguage =
100
+ typeof navigator !== "undefined" && navigator.language
101
+ ? navigator.language
102
+ : "en-US";
103
+ this._language = options.language ?? defaultLanguage;
104
+ this._continuous = options.continuous ?? true;
105
+ this._interimResults = options.interimResults ?? true;
106
+ }
107
+
108
+ /**
109
+ * Check if the browser supports the Web Speech Recognition API.
110
+ */
111
+ static isSupported(): boolean {
112
+ return getSpeechRecognitionAPI() !== undefined;
113
+ }
114
+
115
+ listen(): DictationAdapter.Session {
116
+ const SpeechRecognitionAPI = getSpeechRecognitionAPI();
117
+ if (!SpeechRecognitionAPI) {
118
+ throw new Error(
119
+ "SpeechRecognition is not supported in this browser. " +
120
+ "Try using Chrome, Edge, or Safari.",
121
+ );
122
+ }
123
+
124
+ const recognition = new SpeechRecognitionAPI();
125
+ recognition.lang = this._language;
126
+ recognition.continuous = this._continuous;
127
+ recognition.interimResults = this._interimResults;
128
+
129
+ const speechStartCallbacks = new Set<() => void>();
130
+ const speechEndCallbacks = new Set<
131
+ (result: DictationAdapter.Result) => void
132
+ >();
133
+ const speechCallbacks = new Set<
134
+ (result: DictationAdapter.Result) => void
135
+ >();
136
+
137
+ let finalTranscript = "";
138
+
139
+ const session: DictationAdapter.Session = {
140
+ status: { type: "starting" },
141
+
142
+ stop: async () => {
143
+ recognition.stop();
144
+ return new Promise<void>((resolve) => {
145
+ const checkEnded = () => {
146
+ if (session.status.type === "ended") {
147
+ resolve();
148
+ } else {
149
+ setTimeout(checkEnded, 50);
150
+ }
151
+ };
152
+ checkEnded();
153
+ });
154
+ },
155
+
156
+ cancel: () => {
157
+ recognition.abort();
158
+ },
159
+
160
+ onSpeechStart: (callback: () => void): Unsubscribe => {
161
+ speechStartCallbacks.add(callback);
162
+ return () => {
163
+ speechStartCallbacks.delete(callback);
164
+ };
165
+ },
166
+
167
+ onSpeechEnd: (
168
+ callback: (result: DictationAdapter.Result) => void,
169
+ ): Unsubscribe => {
170
+ speechEndCallbacks.add(callback);
171
+ return () => {
172
+ speechEndCallbacks.delete(callback);
173
+ };
174
+ },
175
+
176
+ onSpeech: (
177
+ callback: (result: DictationAdapter.Result) => void,
178
+ ): Unsubscribe => {
179
+ speechCallbacks.add(callback);
180
+ return () => {
181
+ speechCallbacks.delete(callback);
182
+ };
183
+ },
184
+ };
185
+
186
+ const updateStatus = (newStatus: DictationAdapter.Status) => {
187
+ session.status = newStatus;
188
+ };
189
+
190
+ recognition.addEventListener("speechstart", () => {
191
+ for (const cb of speechStartCallbacks) cb();
192
+ });
193
+
194
+ recognition.addEventListener("start", () => {
195
+ updateStatus({ type: "running" });
196
+ });
197
+
198
+ recognition.addEventListener("result", (event) => {
199
+ const speechEvent = event as unknown as SpeechRecognitionEvent;
200
+
201
+ for (
202
+ let i = speechEvent.resultIndex;
203
+ i < speechEvent.results.length;
204
+ i++
205
+ ) {
206
+ const result = speechEvent.results[i];
207
+ if (!result) continue;
208
+
209
+ const transcript = result[0]?.transcript ?? "";
210
+
211
+ if (result.isFinal) {
212
+ finalTranscript += transcript;
213
+ for (const cb of speechCallbacks) cb({ transcript, isFinal: true });
214
+ } else {
215
+ for (const cb of speechCallbacks) cb({ transcript, isFinal: false });
216
+ }
217
+ }
218
+ });
219
+
220
+ recognition.addEventListener("speechend", () => {
221
+ // speechend fires when user stops speaking, but 'end' handles final cleanup
222
+ });
223
+
224
+ recognition.addEventListener("end", () => {
225
+ const currentStatus = session.status;
226
+ if (currentStatus.type !== "ended") {
227
+ updateStatus({ type: "ended", reason: "stopped" });
228
+ }
229
+ if (finalTranscript) {
230
+ for (const cb of speechEndCallbacks)
231
+ cb({ transcript: finalTranscript });
232
+ finalTranscript = "";
233
+ }
234
+ });
235
+
236
+ recognition.addEventListener("error", (event) => {
237
+ const errorEvent = event as unknown as SpeechRecognitionErrorEvent;
238
+ if (errorEvent.error === "aborted") {
239
+ updateStatus({ type: "ended", reason: "cancelled" });
240
+ } else {
241
+ updateStatus({ type: "ended", reason: "error" });
242
+ console.error("Dictation error:", errorEvent.error, errorEvent.message);
243
+ }
244
+ });
245
+
246
+ try {
247
+ recognition.start();
248
+ } catch (error) {
249
+ updateStatus({ type: "ended", reason: "error" });
250
+ throw error;
251
+ }
252
+
253
+ return session;
254
+ }
255
+ }
@@ -1,2 +1,6 @@
1
- export type { SpeechSynthesisAdapter } from "./SpeechAdapterTypes";
1
+ export type {
2
+ SpeechSynthesisAdapter,
3
+ DictationAdapter,
4
+ } from "./SpeechAdapterTypes";
2
5
  export { WebSpeechSynthesisAdapter } from "./WebSpeechSynthesisAdapter";
6
+ export { WebSpeechDictationAdapter } from "./WebSpeechDictationAdapter";
@@ -88,7 +88,7 @@ export type AssistantTransportOptions<T> = {
88
88
  protocol?: AssistantTransportProtocol;
89
89
  converter: AssistantTransportStateConverter<T>;
90
90
  headers: HeadersValue | (() => Promise<HeadersValue>);
91
- body?: object;
91
+ body?: object | (() => Promise<object | undefined>);
92
92
  onResponse?: (response: Response) => void;
93
93
  onFinish?: () => void;
94
94
  onError?: (
@@ -97,6 +97,10 @@ const useAssistantTransportThreadRuntime = <T,>(
97
97
  throw new Error("No commands to send");
98
98
 
99
99
  const headers = await createRequestHeaders(options.headers);
100
+ const bodyValue =
101
+ typeof options.body === "function"
102
+ ? await options.body()
103
+ : options.body;
100
104
  const context = runtime.thread.getModelContext();
101
105
 
102
106
  const response = await fetch(
@@ -113,7 +117,7 @@ const useAssistantTransportThreadRuntime = <T,>(
113
117
  : undefined,
114
118
  ...context.callSettings,
115
119
  ...context.config,
116
- ...options.body,
120
+ ...(bodyValue ?? {}),
117
121
  }),
118
122
  signal,
119
123
  },