@assistant-ui/core 0.3.18 → 0.3.20

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 (804) hide show
  1. package/dist/adapters/attachment.d.ts +9 -10
  2. package/dist/adapters/attachment.d.ts.map +1 -1
  3. package/dist/adapters/attachment.js +2 -1
  4. package/dist/adapters/attachment.js.map +1 -1
  5. package/dist/adapters/directive-formatter.d.ts +1 -2
  6. package/dist/adapters/directive-formatter.d.ts.map +1 -1
  7. package/dist/adapters/feedback.d.ts +2 -2
  8. package/dist/adapters/feedback.d.ts.map +1 -1
  9. package/dist/adapters/speech.d.ts +6 -7
  10. package/dist/adapters/speech.d.ts.map +1 -1
  11. package/dist/adapters/speech.js +13 -3
  12. package/dist/adapters/speech.js.map +1 -1
  13. package/dist/adapters/suggestion.d.ts +5 -6
  14. package/dist/adapters/suggestion.d.ts.map +1 -1
  15. package/dist/adapters/thread-history.d.ts +10 -7
  16. package/dist/adapters/thread-history.d.ts.map +1 -1
  17. package/dist/adapters/trigger.d.ts +1 -2
  18. package/dist/adapters/trigger.d.ts.map +1 -1
  19. package/dist/adapters/voice.d.ts +5 -6
  20. package/dist/adapters/voice.d.ts.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/internal/duplicate-detection.d.ts +1 -2
  24. package/dist/internal/duplicate-detection.d.ts.map +1 -1
  25. package/dist/internal.d.ts +1 -1
  26. package/dist/model-context/frame/host.d.ts +1 -2
  27. package/dist/model-context/frame/host.d.ts.map +1 -1
  28. package/dist/model-context/frame/host.js +26 -11
  29. package/dist/model-context/frame/host.js.map +1 -1
  30. package/dist/model-context/frame/provider.d.ts +1 -2
  31. package/dist/model-context/frame/provider.d.ts.map +1 -1
  32. package/dist/model-context/frame/types.d.ts +5 -6
  33. package/dist/model-context/frame/types.d.ts.map +1 -1
  34. package/dist/model-context/interactable-composer-metadata.d.ts +9 -10
  35. package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
  36. package/dist/model-context/interactable-composer-metadata.js +11 -9
  37. package/dist/model-context/interactable-composer-metadata.js.map +1 -1
  38. package/dist/model-context/registry-handles.d.ts +3 -4
  39. package/dist/model-context/registry-handles.d.ts.map +1 -1
  40. package/dist/model-context/registry.d.ts +1 -2
  41. package/dist/model-context/registry.d.ts.map +1 -1
  42. package/dist/model-context/tool-call-text.d.ts +2 -3
  43. package/dist/model-context/tool-call-text.d.ts.map +1 -1
  44. package/dist/model-context/tool.d.ts +2 -3
  45. package/dist/model-context/tool.d.ts.map +1 -1
  46. package/dist/model-context/types.d.ts +8 -9
  47. package/dist/model-context/types.d.ts.map +1 -1
  48. package/dist/react/AssistantProvider.d.ts +3 -4
  49. package/dist/react/AssistantProvider.d.ts.map +1 -1
  50. package/dist/react/AssistantRuntimeProvider.d.ts +1 -2
  51. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  52. package/dist/react/RuntimeAdapter.d.ts +2 -3
  53. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  54. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +4 -5
  55. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  56. package/dist/react/adapters/LocalStorageThreadListAdapter.js +43 -19
  57. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  58. package/dist/react/adapters/TitleGenerationAdapter.d.ts +2 -3
  59. package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
  60. package/dist/react/client/AdaptedRemoteThread.d.ts +1 -2
  61. package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
  62. package/dist/react/client/DataRenderers.d.ts +1 -2
  63. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  64. package/dist/react/client/DataRenderers.js +20 -15
  65. package/dist/react/client/DataRenderers.js.map +1 -1
  66. package/dist/react/client/InMemoryThreadList.d.ts +3 -4
  67. package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
  68. package/dist/react/client/Interactables.d.ts +1 -2
  69. package/dist/react/client/Interactables.d.ts.map +1 -1
  70. package/dist/react/client/Interactables.js +11 -5
  71. package/dist/react/client/Interactables.js.map +1 -1
  72. package/dist/react/client/RemoteThreadList.d.ts +2 -3
  73. package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
  74. package/dist/react/client/RemoteThreadList.js +3 -2
  75. package/dist/react/client/RemoteThreadList.js.map +1 -1
  76. package/dist/react/client/Tools.d.ts +2 -2
  77. package/dist/react/client/Tools.d.ts.map +1 -1
  78. package/dist/react/client/interactable-model-context.d.ts +2 -3
  79. package/dist/react/client/interactable-model-context.d.ts.map +1 -1
  80. package/dist/react/client/interactable-model-context.js +3 -2
  81. package/dist/react/client/interactable-model-context.js.map +1 -1
  82. package/dist/react/index.d.ts +2 -2
  83. package/dist/react/index.js +2 -2
  84. package/dist/react/interactables-legacy/Interactables.d.ts +1 -2
  85. package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
  86. package/dist/react/interactables-legacy/interactable-model-context.d.ts +2 -3
  87. package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
  88. package/dist/react/interactables-legacy/scopes.d.ts +9 -10
  89. package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
  90. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +2 -3
  91. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
  92. package/dist/react/interactables-legacy/useAssistantInteractable.js +3 -0
  93. package/dist/react/interactables-legacy/useAssistantInteractable.js.map +1 -1
  94. package/dist/react/interactables-legacy/useInteractableState.d.ts +1 -2
  95. package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
  96. package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +1 -2
  97. package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
  98. package/dist/react/model-context/define-mcp-toolkit.d.ts +4 -5
  99. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
  100. package/dist/react/model-context/define-toolkit.d.ts +2 -3
  101. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  102. package/dist/react/model-context/external-tool.d.ts +1 -2
  103. package/dist/react/model-context/external-tool.d.ts.map +1 -1
  104. package/dist/react/model-context/human-tool.d.ts +3 -4
  105. package/dist/react/model-context/human-tool.d.ts.map +1 -1
  106. package/dist/react/model-context/interactableTool.d.ts +3 -4
  107. package/dist/react/model-context/interactableTool.d.ts.map +1 -1
  108. package/dist/react/model-context/makeAssistantDataUI.d.ts +2 -3
  109. package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
  110. package/dist/react/model-context/makeAssistantTool.d.ts +2 -3
  111. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  112. package/dist/react/model-context/makeAssistantToolUI.d.ts +2 -3
  113. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  114. package/dist/react/model-context/provider-tool.d.ts +2 -3
  115. package/dist/react/model-context/provider-tool.d.ts.map +1 -1
  116. package/dist/react/model-context/stub-tool.d.ts +1 -2
  117. package/dist/react/model-context/stub-tool.d.ts.map +1 -1
  118. package/dist/react/model-context/toolbox.d.ts +9 -10
  119. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  120. package/dist/react/model-context/useAssistantContext.d.ts +2 -2
  121. package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
  122. package/dist/react/model-context/useAssistantDataUI.d.ts +2 -3
  123. package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
  124. package/dist/react/model-context/useAssistantInstructions.d.ts +2 -2
  125. package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
  126. package/dist/react/model-context/useAssistantTool.d.ts +2 -3
  127. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  128. package/dist/react/model-context/useAssistantToolUI.d.ts +2 -3
  129. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  130. package/dist/react/model-context/useAuiToolOverrides.d.ts +1 -2
  131. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
  132. package/dist/react/model-context/useInlineRender.d.ts +1 -2
  133. package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
  134. package/dist/react/model-context/useInteractable.d.ts +4 -5
  135. package/dist/react/model-context/useInteractable.d.ts.map +1 -1
  136. package/dist/react/model-context/useInteractable.js +4 -1
  137. package/dist/react/model-context/useInteractable.js.map +1 -1
  138. package/dist/react/model-context/useInteractableState.d.ts +1 -2
  139. package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
  140. package/dist/react/model-context/useInteractableVersions.d.ts +1 -2
  141. package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
  142. package/dist/react/model-context/useInteractableVersions.js +1 -1
  143. package/dist/react/model-context/useToolArgsStatus.d.ts +2 -3
  144. package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
  145. package/dist/react/primitive-hooks/useActionBarCopy.d.ts +2 -3
  146. package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
  147. package/dist/react/primitive-hooks/useActionBarEdit.d.ts +1 -2
  148. package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
  149. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +2 -3
  150. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
  151. package/dist/react/primitive-hooks/useActionBarReload.d.ts +1 -2
  152. package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
  153. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +1 -2
  154. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
  155. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +1 -2
  156. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
  157. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +1 -2
  158. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
  159. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +1 -2
  160. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
  161. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +1 -2
  162. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
  163. package/dist/react/primitive-hooks/useComposerCancel.d.ts +1 -2
  164. package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
  165. package/dist/react/primitive-hooks/useComposerDictate.d.ts +1 -2
  166. package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
  167. package/dist/react/primitive-hooks/useComposerSend.d.ts +1 -2
  168. package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
  169. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +1 -2
  170. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
  171. package/dist/react/primitive-hooks/useEditComposerSend.d.ts +1 -2
  172. package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
  173. package/dist/react/primitive-hooks/useMessageBranching.d.ts +1 -2
  174. package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
  175. package/dist/react/primitive-hooks/useMessageError.d.ts +1 -2
  176. package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
  177. package/dist/react/primitive-hooks/useMessageReload.d.ts +1 -2
  178. package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
  179. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +2 -3
  180. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
  181. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +1 -2
  182. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
  183. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +1 -2
  184. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
  185. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +1 -2
  186. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
  187. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +1 -2
  188. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
  189. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +1 -2
  190. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
  191. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +1 -2
  192. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
  193. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +1 -2
  194. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
  195. package/dist/react/primitive-hooks/useThreadListNew.d.ts +1 -2
  196. package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
  197. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +1 -2
  198. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
  199. package/dist/react/primitive-hooks/useThreadMessages.d.ts +1 -2
  200. package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
  201. package/dist/react/primitive-hooks/useVoice.d.ts +3 -4
  202. package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
  203. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +2 -3
  204. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
  205. package/dist/react/primitives/composer/ComposerAttachments.d.ts +4 -5
  206. package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
  207. package/dist/react/primitives/composer/ComposerIf.d.ts +4 -5
  208. package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
  209. package/dist/react/primitives/composer/ComposerQueue.d.ts +2 -3
  210. package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
  211. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +4 -5
  212. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
  213. package/dist/react/primitives/generativeUI/GenerativeUI.js +27 -28
  214. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  215. package/dist/react/primitives/message/MessageAttachments.d.ts +4 -5
  216. package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
  217. package/dist/react/primitives/message/MessageGroupedParts.d.ts +13 -5
  218. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  219. package/dist/react/primitives/message/MessageGroupedParts.js +3 -2
  220. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  221. package/dist/react/primitives/message/MessageParts.d.ts +10 -10
  222. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  223. package/dist/react/primitives/message/MessageQuote.d.ts +2 -3
  224. package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
  225. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +2 -3
  226. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
  227. package/dist/react/primitives/part/PartMessages.d.ts +4 -4
  228. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  229. package/dist/react/primitives/part/PartMessages.js +1 -0
  230. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  231. package/dist/react/primitives/thread/ThreadMessages.d.ts +7 -8
  232. package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
  233. package/dist/react/primitives/thread/ThreadMessages.js +6 -5
  234. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  235. package/dist/react/primitives/thread/ThreadSuggestions.d.ts +5 -6
  236. package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
  237. package/dist/react/primitives/threadList/ThreadListItems.d.ts +4 -5
  238. package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  239. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +2 -3
  240. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
  241. package/dist/react/providers/AttachmentByIndexProvider.d.ts +2 -3
  242. package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
  243. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +1 -2
  244. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
  245. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +1 -2
  246. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
  247. package/dist/react/providers/MessageByIdProvider.d.ts +1 -2
  248. package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
  249. package/dist/react/providers/MessageByIndexProvider.d.ts +1 -2
  250. package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
  251. package/dist/react/providers/PartByIndexProvider.d.ts +1 -2
  252. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
  253. package/dist/react/providers/QueueItemByIndexProvider.d.ts +2 -3
  254. package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
  255. package/dist/react/providers/ReadonlyThreadProvider.d.ts +2 -3
  256. package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
  257. package/dist/react/providers/SuggestionByIndexProvider.d.ts +2 -3
  258. package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
  259. package/dist/react/providers/TextMessagePartProvider.d.ts +1 -2
  260. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  261. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +1 -2
  262. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
  263. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +1 -2
  264. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
  265. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +3 -2
  266. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  267. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +17 -7
  268. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  269. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +1 -2
  270. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  271. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +2 -1
  272. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  273. package/dist/react/runtimes/RemoteThreadResource.d.ts +4 -5
  274. package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
  275. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +3 -3
  276. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
  277. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +2 -3
  278. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
  279. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +3 -4
  280. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
  281. package/dist/react/runtimes/assistant-transport/runManager.d.ts +2 -3
  282. package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
  283. package/dist/react/runtimes/assistant-transport/types.d.ts +17 -18
  284. package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
  285. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +4 -5
  286. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
  287. package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +1 -2
  288. package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
  289. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +1 -2
  290. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
  291. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +3 -26
  292. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  293. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +152 -378
  294. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  295. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +2 -2
  296. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
  297. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +22 -2
  298. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  299. package/dist/react/runtimes/cloud/auiV0.d.ts +51 -18
  300. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  301. package/dist/react/runtimes/cloud/auiV0.js +125 -17
  302. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  303. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +6 -6
  304. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
  305. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js +4 -0
  306. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js.map +1 -1
  307. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +1 -2
  308. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
  309. package/dist/react/runtimes/cloud/sdkIdentity.d.ts +5 -0
  310. package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -0
  311. package/dist/react/runtimes/cloud/sdkIdentity.js +9 -0
  312. package/dist/react/runtimes/cloud/sdkIdentity.js.map +1 -0
  313. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +1 -2
  314. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  315. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +1 -2
  316. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  317. package/dist/react/runtimes/createMessageConverter.d.ts +1 -2
  318. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  319. package/dist/react/runtimes/createRuntimeExtras.d.ts +3 -4
  320. package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
  321. package/dist/react/runtimes/external-message-converter.d.ts +14 -4
  322. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  323. package/dist/react/runtimes/external-message-converter.js +26 -61
  324. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  325. package/dist/react/runtimes/useExternalStoreRuntime.d.ts +1 -2
  326. package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
  327. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +1 -2
  328. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
  329. package/dist/react/runtimes/useLocalRuntime.d.ts +3 -4
  330. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  331. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +1 -2
  332. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
  333. package/dist/react/runtimes/useRemoteThreadListRuntime.js +3 -3
  334. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  335. package/dist/react/runtimes/useRuntimeAdapters.d.ts +4 -4
  336. package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
  337. package/dist/react/runtimes/useStreamingTiming.d.ts +2 -2
  338. package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
  339. package/dist/react/types/MessagePartComponentTypes.d.ts +26 -27
  340. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
  341. package/dist/react/types/scopes/dataRenderers.d.ts +3 -4
  342. package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
  343. package/dist/react/types/scopes/interactables.d.ts +10 -11
  344. package/dist/react/types/scopes/interactables.d.ts.map +1 -1
  345. package/dist/react/types/scopes/tools.d.ts +4 -5
  346. package/dist/react/types/scopes/tools.d.ts.map +1 -1
  347. package/dist/react/utils/getMessageQuote.d.ts +1 -2
  348. package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
  349. package/dist/react/utils/groupParts.d.ts +13 -9
  350. package/dist/react/utils/groupParts.d.ts.map +1 -1
  351. package/dist/react/utils/groupParts.js +6 -0
  352. package/dist/react/utils/groupParts.js.map +1 -1
  353. package/dist/react/utils/useJSONEqual.d.ts +3 -2
  354. package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
  355. package/dist/react/utils/useJSONEqual.js +6 -1
  356. package/dist/react/utils/useJSONEqual.js.map +1 -1
  357. package/dist/react/utils/useJSONSchemaDependency.d.ts +6 -0
  358. package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -0
  359. package/dist/react/utils/useJSONSchemaDependency.js +20 -0
  360. package/dist/react/utils/useJSONSchemaDependency.js.map +1 -0
  361. package/dist/runtime/api/assistant-runtime.d.ts +2 -3
  362. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  363. package/dist/runtime/api/attachment-runtime.d.ts +6 -7
  364. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  365. package/dist/runtime/api/bindings.d.ts +5 -6
  366. package/dist/runtime/api/bindings.d.ts.map +1 -1
  367. package/dist/runtime/api/composer-runtime.d.ts +10 -10
  368. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  369. package/dist/runtime/api/message-part-runtime.d.ts +3 -4
  370. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  371. package/dist/runtime/api/message-part-runtime.js +3 -2
  372. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  373. package/dist/runtime/api/message-runtime.d.ts +8 -6
  374. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  375. package/dist/runtime/api/message-runtime.js +3 -2
  376. package/dist/runtime/api/message-runtime.js.map +1 -1
  377. package/dist/runtime/api/paths.d.ts +6 -7
  378. package/dist/runtime/api/paths.d.ts.map +1 -1
  379. package/dist/runtime/api/thread-list-item-runtime.d.ts +8 -8
  380. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  381. package/dist/runtime/api/thread-list-runtime.d.ts +4 -5
  382. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  383. package/dist/runtime/api/thread-runtime.d.ts +10 -11
  384. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  385. package/dist/runtime/api/thread-runtime.js +2 -5
  386. package/dist/runtime/api/thread-runtime.js.map +1 -1
  387. package/dist/runtime/base/base-assistant-runtime-core.d.ts +1 -2
  388. package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
  389. package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -2
  390. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  391. package/dist/runtime/base/base-composer-runtime-core.js +46 -10
  392. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  393. package/dist/runtime/base/base-thread-runtime-core.d.ts +10 -3
  394. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  395. package/dist/runtime/base/base-thread-runtime-core.js +212 -77
  396. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  397. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +1 -2
  398. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  399. package/dist/runtime/base/default-edit-composer-runtime-core.js +12 -2
  400. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  401. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -2
  402. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  403. package/dist/runtime/base/default-thread-composer-runtime-core.js +7 -1
  404. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  405. package/dist/runtime/branch/external-thread-branch-adapter.d.ts +1 -2
  406. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
  407. package/dist/runtime/interfaces/assistant-runtime-core.d.ts +1 -2
  408. package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
  409. package/dist/runtime/interfaces/composer-runtime-core.d.ts +10 -11
  410. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  411. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +4 -5
  412. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  413. package/dist/runtime/interfaces/thread-runtime-core.d.ts +23 -16
  414. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  415. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +2 -3
  416. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
  417. package/dist/runtime/queue/message-queue.d.ts +10 -4
  418. package/dist/runtime/queue/message-queue.d.ts.map +1 -1
  419. package/dist/runtime/queue/message-queue.js +70 -7
  420. package/dist/runtime/queue/message-queue.js.map +1 -1
  421. package/dist/runtime/queue/queue-item.d.ts +2 -3
  422. package/dist/runtime/queue/queue-item.d.ts.map +1 -1
  423. package/dist/runtime/utils/abortable-thread-load.d.ts +2 -3
  424. package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
  425. package/dist/runtime/utils/attachment-add-operations.d.ts +3 -4
  426. package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
  427. package/dist/runtime/utils/auto-status.d.ts +9 -6
  428. package/dist/runtime/utils/auto-status.d.ts.map +1 -1
  429. package/dist/runtime/utils/auto-status.js +12 -4
  430. package/dist/runtime/utils/auto-status.js.map +1 -1
  431. package/dist/runtime/utils/chat-model-adapter.d.ts +5 -6
  432. package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
  433. package/dist/runtime/utils/external-message-conversion.d.ts +26 -15
  434. package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
  435. package/dist/runtime/utils/external-message-conversion.js +51 -14
  436. package/dist/runtime/utils/external-message-conversion.js.map +1 -1
  437. package/dist/runtime/utils/external-store-message.d.ts +4 -5
  438. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  439. package/dist/runtime/utils/message-repository-session.d.ts +3 -4
  440. package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
  441. package/dist/runtime/utils/message-repository.d.ts +4 -5
  442. package/dist/runtime/utils/message-repository.d.ts.map +1 -1
  443. package/dist/runtime/utils/message-repository.js +3 -3
  444. package/dist/runtime/utils/message-repository.js.map +1 -1
  445. package/dist/runtime/utils/pending-tool-calls.d.ts +2 -3
  446. package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
  447. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +1 -2
  448. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
  449. package/dist/runtime/utils/runtime-extras-brand.d.ts +2 -3
  450. package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
  451. package/dist/runtime/utils/stored-message-parts.d.ts +21 -0
  452. package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -0
  453. package/dist/runtime/utils/stored-message-parts.js +83 -0
  454. package/dist/runtime/utils/stored-message-parts.js.map +1 -0
  455. package/dist/runtime/utils/streaming-timing.d.ts +4 -5
  456. package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
  457. package/dist/runtime/utils/thread-message-like.d.ts +7 -6
  458. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  459. package/dist/runtime/utils/thread-message-like.js +4 -2
  460. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  461. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +3 -4
  462. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
  463. package/dist/runtime/utils/tool-call-tree.d.ts +4 -5
  464. package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
  465. package/dist/runtimes/assistant-transport/utils.d.ts +1 -2
  466. package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
  467. package/dist/runtimes/external-store/external-store-adapter.d.ts +9 -6
  468. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  469. package/dist/runtimes/external-store/external-store-runtime-core.d.ts +1 -2
  470. package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
  471. package/dist/runtimes/external-store/external-store-shared-options.d.ts +2 -3
  472. package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
  473. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +2 -3
  474. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  475. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +4 -3
  476. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  477. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +36 -6
  478. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  479. package/dist/runtimes/external-store/thread-message-converter.d.ts +2 -3
  480. package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
  481. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +2 -3
  482. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
  483. package/dist/runtimes/internal.d.ts +1 -1
  484. package/dist/runtimes/local/local-runtime-core.d.ts +1 -2
  485. package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
  486. package/dist/runtimes/local/local-runtime-options.d.ts +1 -2
  487. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  488. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +2 -3
  489. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
  490. package/dist/runtimes/local/local-thread-runtime-core.d.ts +10 -5
  491. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  492. package/dist/runtimes/local/local-thread-runtime-core.js +57 -10
  493. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  494. package/dist/runtimes/local/should-continue.d.ts +1 -2
  495. package/dist/runtimes/local/should-continue.d.ts.map +1 -1
  496. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -2
  497. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  498. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -2
  499. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  500. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +1 -2
  501. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
  502. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +1 -2
  503. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  504. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +1 -2
  505. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
  506. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +16 -17
  507. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  508. package/dist/runtimes/remote-thread-list/title-generation.d.ts +7 -8
  509. package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
  510. package/dist/runtimes/remote-thread-list/title.d.ts +2 -3
  511. package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
  512. package/dist/runtimes/remote-thread-list/types.d.ts +8 -9
  513. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  514. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +4 -5
  515. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
  516. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +2 -1
  517. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  518. package/dist/store/clients/chain-of-thought-client.d.ts +1 -2
  519. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  520. package/dist/store/clients/external-thread.d.ts +3 -4
  521. package/dist/store/clients/external-thread.d.ts.map +1 -1
  522. package/dist/store/clients/external-thread.js +256 -211
  523. package/dist/store/clients/external-thread.js.map +1 -1
  524. package/dist/store/clients/model-context-client.d.ts +1 -2
  525. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  526. package/dist/store/clients/no-op-composer-client.d.ts +1 -2
  527. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  528. package/dist/store/clients/runtime-adapter.d.ts +1 -2
  529. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  530. package/dist/store/clients/single-thread-list.d.ts +1 -2
  531. package/dist/store/clients/single-thread-list.d.ts.map +1 -1
  532. package/dist/store/clients/suggestions.d.ts +3 -4
  533. package/dist/store/clients/suggestions.d.ts.map +1 -1
  534. package/dist/store/clients/thread-message-client.d.ts +2 -3
  535. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  536. package/dist/store/clients/thread-selection-events.d.ts +1 -2
  537. package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
  538. package/dist/store/clients/thread-tasks.d.ts +12 -0
  539. package/dist/store/clients/thread-tasks.d.ts.map +1 -0
  540. package/dist/store/clients/thread-tasks.js +69 -0
  541. package/dist/store/clients/thread-tasks.js.map +1 -0
  542. package/dist/store/env.d.ts +1 -2
  543. package/dist/store/env.d.ts.map +1 -1
  544. package/dist/store/index.d.ts +3 -2
  545. package/dist/store/index.js +3 -3
  546. package/dist/store/primitive-predicates.d.ts +11 -12
  547. package/dist/store/primitive-predicates.d.ts.map +1 -1
  548. package/dist/store/primitive-predicates.js +4 -4
  549. package/dist/store/primitive-predicates.js.map +1 -1
  550. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +1 -2
  551. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  552. package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -2
  553. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  554. package/dist/store/runtime-clients/handle-runtime-action.d.ts +1 -2
  555. package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
  556. package/dist/store/runtime-clients/handle-thread-list-action.d.ts +1 -2
  557. package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
  558. package/dist/store/runtime-clients/liveRef.d.ts +1 -2
  559. package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
  560. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +1 -2
  561. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  562. package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -2
  563. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  564. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +1 -2
  565. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  566. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +1 -2
  567. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  568. package/dist/store/runtime-clients/thread-runtime-client.d.ts +1 -2
  569. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  570. package/dist/store/runtime-clients/thread-runtime-client.js +176 -128
  571. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  572. package/dist/store/runtime-clients/useSubscribable.d.ts +1 -2
  573. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
  574. package/dist/store/scope-registration.d.ts +2 -0
  575. package/dist/store/scope-registration.d.ts.map +1 -1
  576. package/dist/store/scopes/attachment.d.ts +4 -5
  577. package/dist/store/scopes/attachment.d.ts.map +1 -1
  578. package/dist/store/scopes/chain-of-thought.d.ts +5 -6
  579. package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
  580. package/dist/store/scopes/composer.d.ts +6 -7
  581. package/dist/store/scopes/composer.d.ts.map +1 -1
  582. package/dist/store/scopes/message.d.ts +6 -6
  583. package/dist/store/scopes/message.d.ts.map +1 -1
  584. package/dist/store/scopes/model-context.d.ts +3 -4
  585. package/dist/store/scopes/model-context.d.ts.map +1 -1
  586. package/dist/store/scopes/part.d.ts +4 -5
  587. package/dist/store/scopes/part.d.ts.map +1 -1
  588. package/dist/store/scopes/queue-item.d.ts +4 -4
  589. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  590. package/dist/store/scopes/suggestion.d.ts +4 -5
  591. package/dist/store/scopes/suggestion.d.ts.map +1 -1
  592. package/dist/store/scopes/suggestions.d.ts +5 -6
  593. package/dist/store/scopes/suggestions.d.ts.map +1 -1
  594. package/dist/store/scopes/task.d.ts +35 -0
  595. package/dist/store/scopes/task.d.ts.map +1 -0
  596. package/dist/store/scopes/task.js +0 -0
  597. package/dist/store/scopes/thread-list-item.d.ts +5 -6
  598. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  599. package/dist/store/scopes/thread.d.ts +25 -6
  600. package/dist/store/scopes/thread.d.ts.map +1 -1
  601. package/dist/store/scopes/threads.d.ts +4 -5
  602. package/dist/store/scopes/threads.d.ts.map +1 -1
  603. package/dist/subscribable/subscribable.d.ts +15 -15
  604. package/dist/subscribable/subscribable.d.ts.map +1 -1
  605. package/dist/subscribable/subscribable.js +23 -15
  606. package/dist/subscribable/subscribable.js.map +1 -1
  607. package/dist/tests/remote-thread-list-test-helpers.d.ts +5 -6
  608. package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
  609. package/dist/types/attachment.d.ts +9 -10
  610. package/dist/types/attachment.d.ts.map +1 -1
  611. package/dist/types/augmentations.d.ts +3 -4
  612. package/dist/types/augmentations.d.ts.map +1 -1
  613. package/dist/types/directive.d.ts +2 -3
  614. package/dist/types/directive.d.ts.map +1 -1
  615. package/dist/types/error.d.ts +8 -9
  616. package/dist/types/error.d.ts.map +1 -1
  617. package/dist/types/index.d.ts +2 -2
  618. package/dist/types/message.d.ts +53 -44
  619. package/dist/types/message.d.ts.map +1 -1
  620. package/dist/types/message.js.map +1 -1
  621. package/dist/types/quote.d.ts +1 -2
  622. package/dist/types/quote.d.ts.map +1 -1
  623. package/dist/types/trigger.d.ts +2 -3
  624. package/dist/types/trigger.d.ts.map +1 -1
  625. package/dist/types/unsubscribe.d.ts +1 -2
  626. package/dist/types/unsubscribe.d.ts.map +1 -1
  627. package/dist/utils/abortable-iterable.d.ts +2 -3
  628. package/dist/utils/abortable-iterable.d.ts.map +1 -1
  629. package/dist/utils/abortable-iterable.js +30 -14
  630. package/dist/utils/abortable-iterable.js.map +1 -1
  631. package/dist/utils/composite-context-provider.d.ts +1 -2
  632. package/dist/utils/composite-context-provider.d.ts.map +1 -1
  633. package/dist/utils/data-url.d.ts +6 -7
  634. package/dist/utils/data-url.d.ts.map +1 -1
  635. package/dist/utils/getGroupStatus.d.ts +17 -2
  636. package/dist/utils/getGroupStatus.d.ts.map +1 -1
  637. package/dist/utils/getGroupStatus.js +32 -7
  638. package/dist/utils/getGroupStatus.js.map +1 -1
  639. package/dist/utils/id.d.ts +3 -4
  640. package/dist/utils/id.d.ts.map +1 -1
  641. package/dist/utils/image-media-type.d.ts +1 -2
  642. package/dist/utils/image-media-type.d.ts.map +1 -1
  643. package/dist/utils/invoke-user-callback.d.ts +1 -2
  644. package/dist/utils/invoke-user-callback.d.ts.map +1 -1
  645. package/dist/utils/json/is-json-equal.d.ts +1 -2
  646. package/dist/utils/json/is-json-equal.d.ts.map +1 -1
  647. package/dist/utils/json/is-json.d.ts +4 -5
  648. package/dist/utils/json/is-json.d.ts.map +1 -1
  649. package/dist/utils/json/stable-stringify-tool-args.d.ts +2 -3
  650. package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
  651. package/dist/utils/normalizePartStatus.d.ts +4 -5
  652. package/dist/utils/normalizePartStatus.d.ts.map +1 -1
  653. package/dist/utils/notify-event-listeners.d.ts +1 -2
  654. package/dist/utils/notify-event-listeners.d.ts.map +1 -1
  655. package/dist/utils/record.d.ts +1 -2
  656. package/dist/utils/record.d.ts.map +1 -1
  657. package/dist/utils/silent-runtime-action.d.ts +2 -3
  658. package/dist/utils/silent-runtime-action.d.ts.map +1 -1
  659. package/dist/utils/text.d.ts +1 -2
  660. package/dist/utils/text.d.ts.map +1 -1
  661. package/dist/utils/wire-media.d.ts +3 -4
  662. package/dist/utils/wire-media.d.ts.map +1 -1
  663. package/dist/utils/wire-media.js +2 -2
  664. package/dist/utils/wire-media.js.map +1 -1
  665. package/package.json +15 -14
  666. package/src/adapters/attachment.ts +8 -1
  667. package/src/adapters/feedback.ts +1 -0
  668. package/src/adapters/speech.test.ts +236 -0
  669. package/src/adapters/speech.ts +17 -10
  670. package/src/adapters/thread-history.ts +3 -0
  671. package/src/index.ts +1 -0
  672. package/src/model-context/frame/host.test.ts +113 -1
  673. package/src/model-context/frame/host.ts +39 -12
  674. package/src/model-context/frame/provider.test.ts +45 -20
  675. package/src/model-context/interactable-composer-metadata.test.ts +30 -0
  676. package/src/model-context/interactable-composer-metadata.ts +10 -10
  677. package/src/react/RuntimeAdapter.test.ts +4 -1
  678. package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +361 -0
  679. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +69 -19
  680. package/src/react/client/DataRenderers.test.tsx +45 -0
  681. package/src/react/client/DataRenderers.ts +13 -9
  682. package/src/react/client/Interactables.test.ts +52 -4
  683. package/src/react/client/Interactables.ts +7 -1
  684. package/src/react/client/RemoteThreadList.concurrent.test.tsx +9 -3
  685. package/src/react/client/RemoteThreadList.test.ts +46 -7
  686. package/src/react/client/RemoteThreadList.ts +15 -2
  687. package/src/react/client/interactable-model-context.test.ts +44 -0
  688. package/src/react/client/interactable-model-context.ts +3 -2
  689. package/src/react/index.ts +5 -1
  690. package/src/react/interactables-legacy/Interactables.test.ts +9 -3
  691. package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +150 -0
  692. package/src/react/interactables-legacy/useAssistantInteractable.ts +10 -1
  693. package/src/react/model-context/useInteractable.test.tsx +204 -0
  694. package/src/react/model-context/useInteractable.ts +3 -0
  695. package/src/react/primitive-hooks/useActionBarCopy.test.ts +5 -6
  696. package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +0 -1
  697. package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +54 -0
  698. package/src/react/primitives/generativeUI/GenerativeUI.tsx +13 -18
  699. package/src/react/primitives/message/MessageGroupedParts.test.tsx +99 -0
  700. package/src/react/primitives/message/MessageGroupedParts.tsx +15 -4
  701. package/src/react/primitives/part/PartMessages.test.tsx +104 -1
  702. package/src/react/primitives/part/PartMessages.tsx +1 -0
  703. package/src/react/primitives/thread/ThreadMessages.test.tsx +160 -0
  704. package/src/react/primitives/thread/ThreadMessages.tsx +8 -5
  705. package/src/react/providers/ReadonlyThreadProvider.test.tsx +56 -0
  706. package/src/react/runtimes/RemoteThreadListHookInstanceManager.layout.test.tsx +62 -0
  707. package/src/react/runtimes/RemoteThreadListHookInstanceManager.retry.test.tsx +2 -2
  708. package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +23 -20
  709. package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +24 -17
  710. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +39 -24
  711. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +7 -1
  712. package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +73 -46
  713. package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +66 -1
  714. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +20 -14
  715. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +323 -1
  716. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +190 -523
  717. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +81 -0
  718. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +27 -1
  719. package/src/react/runtimes/cloud/auiV0.ts +281 -26
  720. package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +522 -0
  721. package/src/react/runtimes/cloud/createCloudThreadListAdapter.test.ts +21 -0
  722. package/src/react/runtimes/cloud/createCloudThreadListAdapter.ts +7 -1
  723. package/src/react/runtimes/cloud/sdkIdentity.ts +9 -0
  724. package/src/react/runtimes/cloud/useCloudThreadListAdapter.test.tsx +18 -4
  725. package/src/react/runtimes/external-message-converter.test.ts +143 -4
  726. package/src/react/runtimes/external-message-converter.ts +39 -93
  727. package/src/react/runtimes/remote-thread-hook-on-tap.test.ts +2 -1
  728. package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +8 -2
  729. package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +6 -2
  730. package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +84 -4
  731. package/src/react/runtimes/useRemoteThreadListRuntime.ts +6 -2
  732. package/src/react/utils/groupParts.ts +12 -1
  733. package/src/react/utils/useJSONEqual.ts +9 -0
  734. package/src/react/utils/useJSONSchemaDependency.ts +22 -0
  735. package/src/runtime/api/message-part-runtime.ts +4 -1
  736. package/src/runtime/api/message-runtime.ts +15 -2
  737. package/src/runtime/api/thread-runtime.test.ts +58 -0
  738. package/src/runtime/api/thread-runtime.ts +2 -4
  739. package/src/runtime/base/base-composer-runtime-core.ts +69 -16
  740. package/src/runtime/base/base-thread-runtime-core.test.ts +1799 -49
  741. package/src/runtime/base/base-thread-runtime-core.ts +296 -94
  742. package/src/runtime/base/default-edit-composer-runtime-core.ts +12 -2
  743. package/src/runtime/base/default-thread-composer-runtime-core.ts +12 -1
  744. package/src/runtime/interfaces/thread-runtime-core.ts +8 -0
  745. package/src/runtime/queue/message-queue.ts +79 -7
  746. package/src/runtime/utils/auto-status.test.ts +112 -1
  747. package/src/runtime/utils/auto-status.ts +31 -5
  748. package/src/runtime/utils/external-message-conversion.test.ts +177 -0
  749. package/src/runtime/utils/external-message-conversion.ts +128 -33
  750. package/src/runtime/utils/message-repository.test.ts +49 -0
  751. package/src/runtime/utils/message-repository.ts +3 -3
  752. package/src/runtime/utils/stored-message-parts.ts +174 -0
  753. package/src/runtime/utils/thread-message-like.test.ts +52 -0
  754. package/src/runtime/utils/thread-message-like.ts +11 -2
  755. package/src/runtimes/external-store/external-store-adapter.ts +4 -0
  756. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +74 -9
  757. package/src/runtimes/local/local-thread-runtime-core.test.ts +189 -12
  758. package/src/runtimes/local/local-thread-runtime-core.ts +91 -10
  759. package/src/runtimes/tool-invocations/EDGE_CASES.md +2 -6
  760. package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +133 -0
  761. package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +10 -6
  762. package/src/store/clients/external-thread.ts +53 -14
  763. package/src/store/clients/thread-tasks.test.ts +274 -0
  764. package/src/store/clients/thread-tasks.ts +138 -0
  765. package/src/store/index.ts +8 -0
  766. package/src/store/primitive-predicates.test.ts +64 -5
  767. package/src/store/primitive-predicates.ts +10 -2
  768. package/src/store/runtime-clients/thread-runtime-client.test.tsx +110 -0
  769. package/src/store/runtime-clients/thread-runtime-client.ts +31 -1
  770. package/src/store/scope-registration.ts +2 -0
  771. package/src/store/scopes/message.ts +4 -1
  772. package/src/store/scopes/task.ts +34 -0
  773. package/src/store/scopes/thread.ts +16 -0
  774. package/src/store/thread-tasks.test.tsx +209 -0
  775. package/src/subscribable/subscribable.test.ts +161 -1
  776. package/src/subscribable/subscribable.ts +25 -15
  777. package/src/tests/MessageRepository.test.ts +1 -5
  778. package/src/tests/attachment-adapters.test.ts +16 -1
  779. package/src/tests/auiV0Encode.test.ts +304 -0
  780. package/src/tests/base-composer-runtime-core-addAttachment.test.ts +6 -6
  781. package/src/tests/base-composer-runtime-core-send.test.ts +51 -0
  782. package/src/tests/base-composer-runtime-core.test.ts +329 -6
  783. package/src/tests/composer-can-cancel.test.ts +35 -6
  784. package/src/tests/composer-can-send.test.ts +22 -0
  785. package/src/tests/default-edit-composer-runtime-core.test.ts +47 -0
  786. package/src/tests/external-store-thread-runtime-core-adapter.test.ts +369 -16
  787. package/src/tests/external-store-thread-runtime-core.test.ts +31 -0
  788. package/src/tests/external-thread-attachments.test.tsx +91 -23
  789. package/src/tests/external-thread-feedback.test.tsx +20 -7
  790. package/src/tests/external-thread-parity.test.tsx +35 -1
  791. package/src/tests/groupParts.test.ts +71 -0
  792. package/src/tests/message-queue.test.ts +290 -2
  793. package/src/tests/remote-thread-list-reactive-threadId.test.ts +51 -0
  794. package/src/tests/thread-switch-events.test.tsx +11 -7
  795. package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +45 -1
  796. package/src/types/index.ts +1 -0
  797. package/src/types/message.test.ts +19 -0
  798. package/src/types/message.ts +23 -7
  799. package/src/utils/abortable-iterable.test.ts +115 -0
  800. package/src/utils/abortable-iterable.ts +34 -23
  801. package/src/utils/getGroupStatus.test.ts +70 -4
  802. package/src/utils/getGroupStatus.ts +35 -12
  803. package/src/utils/wire-media.test.ts +10 -0
  804. package/src/utils/wire-media.ts +6 -2
@@ -103,7 +103,7 @@ var BaseComposerRuntimeCore = class extends BaseSubscribable {
103
103
  const adapter = this.getAttachmentAdapter();
104
104
  if (adapter) {
105
105
  const pending = this._attachments.filter((a) => !isAttachmentComplete(a));
106
- await Promise.all(pending.map((a) => adapter.remove(a)));
106
+ await Promise.all(pending.map(async (a) => adapter.remove(a)));
107
107
  }
108
108
  }
109
109
  async reset() {
@@ -121,14 +121,18 @@ var BaseComposerRuntimeCore = class extends BaseSubscribable {
121
121
  }
122
122
  async clearAttachments() {
123
123
  this._cancelAllAttachmentAdds();
124
+ if (this._isSending) for (const attachment of this._attachments) this._removedDuringSend.add(attachment.id);
124
125
  const task = this._onClearAttachments();
125
126
  this.setAttachments([]);
126
127
  await task;
127
128
  }
128
129
  async send(options) {
129
130
  if (!this.canSend || this._isSending) return;
130
- if (this._dictationSession) {
131
+ if (this._dictationSession) try {
131
132
  this._dictationSession.cancel();
133
+ } catch (error) {
134
+ console.error("[assistant-ui] Dictation session cancel threw", error);
135
+ } finally {
132
136
  this._cleanupDictation();
133
137
  }
134
138
  const adapter = this.getAttachmentAdapter();
@@ -386,16 +390,26 @@ var BaseComposerRuntimeCore = class extends BaseSubscribable {
386
390
  startDictation() {
387
391
  const adapter = this.getDictationAdapter();
388
392
  if (!adapter) throw new Error("Dictation adapter not configured");
393
+ const isReplacing = this._dictationSession !== void 0;
389
394
  if (this._dictationSession) {
390
- for (const unsub of this._dictationUnsubscribes) unsub();
391
- this._dictationUnsubscribes = [];
392
- this._dictationSession.stop().catch(() => {});
393
- this._dictationSession = void 0;
395
+ const oldSession = this._dictationSession;
396
+ this._cleanupDictation({ notify: false });
397
+ this._stopDictationSession(oldSession);
394
398
  }
395
399
  const inputDisabled = adapter.disableInputDuringDictation ?? false;
396
400
  this._dictationBaseText = this._text;
397
401
  this._currentInterimText = "";
398
- const session = adapter.listen();
402
+ let session;
403
+ try {
404
+ session = adapter.listen();
405
+ } catch (error) {
406
+ if (isReplacing) try {
407
+ this._notifySubscribers();
408
+ } catch (notifyError) {
409
+ console.error("[assistant-ui] Dictation replacement rollback notification threw", notifyError);
410
+ }
411
+ throw error;
412
+ }
399
413
  this._dictationSession = session;
400
414
  const sessionId = ++this._dictationSessionIdCounter;
401
415
  this._activeDictationSessionId = sessionId;
@@ -453,20 +467,42 @@ var BaseComposerRuntimeCore = class extends BaseSubscribable {
453
467
  const session = this._dictationSession;
454
468
  const sessionId = this._activeDictationSessionId;
455
469
  const cleanup = () => this._cleanupDictation({ sessionId });
456
- session.stop().then(cleanup, cleanup);
470
+ this._stopDictationSession(session, cleanup);
471
+ }
472
+ _stopDictationSession(session, onSettled = () => {}) {
473
+ let task;
474
+ try {
475
+ task = session.stop();
476
+ } catch (error) {
477
+ console.error("[assistant-ui] Dictation session stop threw", error);
478
+ onSettled();
479
+ return;
480
+ }
481
+ task.then(onSettled, (error) => {
482
+ console.error("[assistant-ui] Dictation session stop rejected", error);
483
+ onSettled();
484
+ });
457
485
  }
458
486
  _cleanupDictation(options) {
459
487
  if (options?.sessionId !== void 0 && options.sessionId !== this._activeDictationSessionId || this._isCleaningDictation) return;
460
488
  this._isCleaningDictation = true;
489
+ const runCleanup = (cleanup) => {
490
+ try {
491
+ cleanup();
492
+ } catch (error) {
493
+ console.error("[assistant-ui] Dictation cleanup threw", error);
494
+ }
495
+ };
461
496
  try {
462
- for (const unsub of this._dictationUnsubscribes) unsub();
497
+ const unsubscribes = this._dictationUnsubscribes;
463
498
  this._dictationUnsubscribes = [];
464
499
  this._dictationSession = void 0;
465
500
  this._activeDictationSessionId = void 0;
466
501
  this._dictation = void 0;
467
502
  this._dictationBaseText = "";
468
503
  this._currentInterimText = "";
469
- this._notifySubscribers();
504
+ for (const unsubscribe of unsubscribes) runCleanup(unsubscribe);
505
+ if (options?.notify !== false) runCleanup(() => this._notifySubscribers());
470
506
  } finally {
471
507
  this._isCleaningDictation = false;
472
508
  }
@@ -1 +1 @@
1
- {"version":3,"file":"base-composer-runtime-core.js","names":["isAttachmentComplete","isCreateAttachment","Attachment","CompleteAttachment","CreateAttachment","PendingAttachment","MessageRole","AppendMessage","isMessageNotSentError","QuoteInfo","Unsubscribe","RunConfig","BaseSubscribable","AttachmentAdapter","fileMatchesAccept","AttachmentAddErrorReason","ComposerRuntimeCore","ComposerRuntimeEventCallback","ComposerRuntimeEventPayload","ComposerRuntimeEventType","DictationState","SendOptions","DictationAdapter","QueuePlacement","EMPTY_QUEUE_ITEMS","QueueItemState","generateId","notifyEventListeners","AttachmentAddOperations","drainAttachmentAdd","BaseComposerRuntimeCore","isEditing","getAttachmentAdapter","getDictationAdapter","enrichWithComposerMetadata","metadata","custom","Record","message","T","composerMetadata","attachmentAccept","accept","_attachments","attachments","setAttachments","value","_notifySubscribers","canCancel","canSend","isEmpty","text","trim","length","_text","_role","role","_runConfig","runConfig","_quote","undefined","quote","setQuote","setText","_rebaseDictation","_dictation","_dictationBaseText","_currentInterimText","status","inputDisabled","setRole","setRunConfig","_isSending","_removedDuringSend","Set","_sendGeneration","_attachmentAddOperations","_cancelAttachmentAdd","attachmentId","cancel","_cancelAllAttachmentAdds","cancelAll","_emptyTextAndAttachments","_onClearAttachments","adapter","pending","filter","a","Promise","all","map","remove","reset","clear","Object","keys","task","clearAttachments","send","options","_dictationSession","_cleanupDictation","attachmentTasks","Error","result","originalAttachments","generation","resolvedAttachments","e","allSettled","then","sentIds","id","has","finalAttachments","Omit","createdAt","Date","content","type","draft","sendTask","handleSend","error","_restoreUnsentDraft","catch","_notifyEventSubscribers","chars","restoreDraft","retractDraft","attachmentsUntouched","handleCancel","queue","moveQueueItem","_queueItemId","_placement","removeQueueItem","addAttachment","fileOrAttachment","File","name","contentType","err","_safeEmitAttachmentAddError","operation","start","upsertAttachment","idx","findIndex","attachment","slice","lastAttachment","add","file","isCancelled","reason","String","finish","subscriberError","console","removeAttachment","index","candidate","Session","_dictationUnsubscribes","_dictationSessionIdCounter","_activeDictationSessionId","_isCleaningDictation","dictation","_isActiveSession","sessionId","session","startDictation","unsub","oldSession","stop","disableInputDuringDictation","listen","unsubSpeech","onSpeech","isFinal","needsSeparator","endsWith","transcript","separator","_","rest","push","unsubStart","onSpeechStart","unsubEnd","onSpeechEnd","statusInterval","setInterval","clearInterval","stopDictation","cleanup","isStaleSession","_eventSubscribers","Map","payload","event","E","subscribers","get","unstable_on","callback","wrapped","set","delete"],"sources":["../../../src/runtime/base/base-composer-runtime-core.ts"],"sourcesContent":["import {\n isAttachmentComplete,\n isCreateAttachment,\n type Attachment,\n type CompleteAttachment,\n type CreateAttachment,\n type PendingAttachment,\n} from \"../../types/attachment\";\nimport type { MessageRole, AppendMessage } from \"../../types/message\";\nimport { isMessageNotSentError } from \"../../types/error\";\nimport type { QuoteInfo } from \"../../types/quote\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { RunConfig } from \"../../types/message\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\nimport {\n type AttachmentAdapter,\n fileMatchesAccept,\n} from \"../../adapters/attachment\";\nimport type {\n AttachmentAddErrorReason,\n ComposerRuntimeCore,\n ComposerRuntimeEventCallback,\n ComposerRuntimeEventPayload,\n ComposerRuntimeEventType,\n DictationState,\n SendOptions,\n} from \"../interfaces/composer-runtime-core\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type { QueuePlacement } from \"../queue/external-thread-queue-adapter\";\nimport { EMPTY_QUEUE_ITEMS, type QueueItemState } from \"../queue/queue-item\";\nimport { generateId } from \"../../utils/id\";\nimport { notifyEventListeners } from \"../../utils/notify-event-listeners\";\nimport {\n AttachmentAddOperations,\n drainAttachmentAdd,\n} from \"../utils/attachment-add-operations\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n protected abstract getDictationAdapter(): DictationAdapter | undefined;\n\n protected enrichWithComposerMetadata<\n T extends { metadata?: { custom?: Record<string, unknown> } },\n >(message: T, composerMetadata: Record<string, unknown> | undefined): T {\n if (!composerMetadata) return message;\n return {\n ...message,\n metadata: {\n ...message.metadata,\n custom: { ...message.metadata?.custom, ...composerMetadata },\n },\n } as T;\n }\n\n public get attachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n public abstract get canSend(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n private _quote: QuoteInfo | undefined = undefined;\n\n get quote() {\n return this._quote;\n }\n\n public setQuote(quote: QuoteInfo | undefined) {\n if (this._quote === quote) return;\n\n this._quote = quote;\n this._notifySubscribers();\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._rebaseDictation(value);\n this._notifySubscribers();\n }\n\n // A live dictation session appends to the text it last saw, so any write\n // that bypasses `setText` has to move that baseline or the next transcript\n // overwrites what was just written.\n private _rebaseDictation(value: string) {\n if (!this._dictation) return;\n\n this._dictationBaseText = value;\n this._currentInterimText = \"\";\n const { status, inputDisabled } = this._dictation;\n this._dictation = inputDisabled ? { status, inputDisabled } : { status };\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n protected _isSending = false;\n private _removedDuringSend = new Set<string>();\n private _sendGeneration = 0;\n private _attachmentAddOperations = new AttachmentAddOperations();\n\n private _cancelAttachmentAdd(attachmentId: string) {\n this._attachmentAddOperations.cancel(attachmentId);\n }\n\n private _cancelAllAttachmentAdds() {\n this._attachmentAddOperations.cancelAll();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._rebaseDictation(\"\");\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n const pending = this._attachments.filter((a) => !isAttachmentComplete(a));\n await Promise.all(pending.map((a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n this._cancelAllAttachmentAdds();\n\n // A send whose adapter never settles must not brick the composer; reset is\n // the escape hatch that releases the in-flight lock. Bumping the generation\n // invalidates that send entirely so a late-settling upload can neither\n // append the discarded draft nor touch a newer send's lock.\n this._sendGeneration++;\n this._isSending = false;\n this._removedDuringSend.clear();\n\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0 &&\n this._quote === undefined\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n this._quote = undefined;\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n this._cancelAllAttachmentAdds();\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send(options?: SendOptions) {\n if (!this.canSend || this._isSending) return;\n\n if (this._dictationSession) {\n this._dictationSession.cancel();\n this._cleanupDictation();\n }\n\n const adapter = this.getAttachmentAdapter();\n const attachmentTasks = this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n if (!adapter) throw new Error(\"Attachments are not supported\");\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n });\n\n const originalAttachments = this.attachments;\n const text = this.text;\n const quote = this._quote;\n const role = this.role;\n const runConfig = this.runConfig;\n this._quote = undefined;\n this._text = \"\";\n this._isSending = true;\n const generation = ++this._sendGeneration;\n this._notifySubscribers();\n\n let resolvedAttachments: CompleteAttachment[];\n try {\n resolvedAttachments = await Promise.all(attachmentTasks);\n } catch (e) {\n if (generation === this._sendGeneration) {\n if (!this.text.trim() && this._quote === undefined) {\n this._text = text;\n this._rebaseDictation(text);\n this._quote = quote;\n this._notifySubscribers();\n }\n // Promise.all rejects on the first failure, but sibling uploads from\n // this batch keep running; the send rejects immediately while the\n // retry lock is held until they settle, or a retry could re-send\n // attachments that are still in flight.\n void Promise.allSettled(attachmentTasks).then(() => {\n if (generation !== this._sendGeneration) return;\n this._removedDuringSend.clear();\n this._isSending = false;\n this._notifySubscribers();\n });\n }\n throw e;\n }\n\n // A reset during the upload discarded this send's draft; the settled\n // uploads must not append it or touch the lock a newer send may own.\n if (generation !== this._sendGeneration) return;\n\n // Drop by id, not wholesale: the user may have added or removed chips while\n // the upload was in flight.\n const sentIds = new Set(originalAttachments.map((a) => a.id));\n this._attachments = this._attachments.filter((a) => !sentIds.has(a.id));\n this._isSending = false;\n this._notifySubscribers();\n\n // An attachment removed mid-upload can't be cancelled, but it can still be\n // dropped from the outgoing message instead of silently being sent anyway.\n const finalAttachments = resolvedAttachments.filter(\n (a) => !this._removedDuringSend.has(a.id),\n );\n this._removedDuringSend.clear();\n\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n createdAt: new Date(),\n role,\n content: text ? [{ type: \"text\", text }] : [],\n attachments: finalAttachments,\n runConfig,\n metadata: { custom: { ...(quote ? { quote } : {}) } },\n };\n\n const draft = { text, quote, attachments: finalAttachments };\n let sendTask: void | Promise<void>;\n try {\n sendTask = this.handleSend(message, options);\n } catch (error) {\n this._restoreUnsentDraft(error, generation, draft);\n throw error;\n }\n if (sendTask)\n void sendTask.catch((error) => {\n this._restoreUnsentDraft(error, generation, draft);\n });\n this._notifyEventSubscribers(\"send\", {\n chars: text.length,\n attachments: finalAttachments.length,\n });\n }\n\n /**\n * Take a message back into the composer when it has nowhere else to live:\n * a send the runtime never dispatched, or a message a cancelled run is\n * removing from the thread. Reports whether the composer accepted it, so a\n * caller that is also removing the message can keep it instead of dropping\n * it. Refused, and left untouched, while the composer holds anything of its\n * own.\n */\n public restoreDraft(draft: {\n text: string;\n quote?: QuoteInfo | undefined;\n attachments?: readonly Attachment[] | undefined;\n }): boolean {\n if (\n this._text.trim() ||\n this._quote !== undefined ||\n this._attachments.length > 0\n )\n return false;\n\n this._text = draft.text;\n this._rebaseDictation(draft.text);\n this._quote = draft.quote;\n this._attachments = draft.attachments ?? [];\n this._notifySubscribers();\n return true;\n }\n\n /**\n * Inverse of `restoreDraft`: clears the composer while it still holds\n * exactly the given draft. A draft the user has edited since is left\n * untouched.\n */\n public retractDraft(draft: {\n text: string;\n quote?: QuoteInfo | undefined;\n attachments?: readonly Attachment[] | undefined;\n }): void {\n const attachmentsUntouched =\n draft.attachments !== undefined\n ? this._attachments === draft.attachments\n : this._attachments.length === 0;\n if (\n this._text !== draft.text ||\n this._quote !== draft.quote ||\n !attachmentsUntouched\n )\n return;\n\n this._text = \"\";\n this._rebaseDictation(\"\");\n this._quote = undefined;\n this._attachments = [];\n this._notifySubscribers();\n }\n\n // The generation check is what a reset and a later send use to invalidate a\n // draft, so of several queued drafts only the most recent one is still\n // restorable.\n private _restoreUnsentDraft(\n error: unknown,\n generation: number,\n draft: {\n text: string;\n quote: QuoteInfo | undefined;\n attachments: readonly CompleteAttachment[];\n },\n ) {\n if (!isMessageNotSentError(error)) return;\n if (generation !== this._sendGeneration) return;\n this.restoreDraft(draft);\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n public get queue(): readonly QueueItemState[] {\n return EMPTY_QUEUE_ITEMS;\n }\n\n public moveQueueItem(\n _queueItemId: string,\n _placement: QueuePlacement,\n ): void {}\n public removeQueueItem(_queueItemId: string): void {}\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n options?: SendOptions,\n ): void | Promise<void>;\n protected abstract handleCancel(): void;\n\n async addAttachment(fileOrAttachment: File | CreateAttachment) {\n if (isCreateAttachment(fileOrAttachment)) {\n const adapter = this.getAttachmentAdapter();\n if (\n adapter &&\n !fileMatchesAccept(\n {\n name: fileOrAttachment.name,\n type: fileOrAttachment.contentType ?? \"\",\n },\n adapter.accept,\n )\n ) {\n const message = `File type ${fileOrAttachment.contentType || \"unknown\"} is not accepted. Accepted types: ${adapter.accept}`;\n const err = new Error(message);\n this._safeEmitAttachmentAddError(\n \"not-accepted\",\n message,\n undefined,\n err,\n fileOrAttachment.contentType,\n );\n throw err;\n }\n\n const a: CompleteAttachment = {\n id: fileOrAttachment.id ?? generateId(),\n type: fileOrAttachment.type ?? \"document\",\n name: fileOrAttachment.name,\n contentType: fileOrAttachment.contentType,\n content: fileOrAttachment.content,\n status: { type: \"complete\" },\n };\n this._attachments = [...this._attachments, a];\n this._notifySubscribers();\n this._notifyEventSubscribers(\"attachmentAdd\", {\n ...(a.contentType ? { contentType: a.contentType } : undefined),\n });\n return;\n }\n\n const adapter = this.getAttachmentAdapter();\n if (!adapter) {\n const message = \"Attachments are not supported\";\n const err = new Error(message);\n this._safeEmitAttachmentAddError(\n \"no-adapter\",\n message,\n undefined,\n err,\n fileOrAttachment.type,\n );\n throw err;\n }\n\n if (\n !fileMatchesAccept(\n { name: fileOrAttachment.name, type: fileOrAttachment.type },\n adapter.accept,\n )\n ) {\n const message = `File type ${fileOrAttachment.type || \"unknown\"} is not accepted. Accepted types: ${adapter.accept}`;\n const err = new Error(message);\n this._safeEmitAttachmentAddError(\n \"not-accepted\",\n message,\n undefined,\n err,\n fileOrAttachment.type,\n );\n throw err;\n }\n\n const operation = this._attachmentAddOperations.start();\n const upsertAttachment = (a: PendingAttachment) => {\n if (!this._attachmentAddOperations.accept(operation, a.id)) return false;\n\n const idx = this._attachments.findIndex(\n (attachment) => attachment.id === a.id,\n );\n if (idx !== -1)\n this._attachments = [\n ...this._attachments.slice(0, idx),\n a,\n ...this._attachments.slice(idx + 1),\n ];\n else {\n this._attachments = [...this._attachments, a];\n }\n\n this._notifySubscribers();\n return true;\n };\n let lastAttachment: PendingAttachment | undefined;\n try {\n await drainAttachmentAdd(\n adapter.add({ file: fileOrAttachment }),\n (attachment) => {\n lastAttachment = attachment;\n return upsertAttachment(attachment);\n },\n );\n } catch (e) {\n if (this._attachmentAddOperations.isCancelled(operation)) return;\n if (lastAttachment) {\n upsertAttachment({\n ...lastAttachment,\n status: {\n type: \"incomplete\",\n reason: \"error\",\n message: e instanceof Error ? e.message : String(e),\n },\n });\n }\n this._safeEmitAttachmentAddError(\n \"adapter-error\",\n e instanceof Error ? e.message : String(e),\n lastAttachment?.id,\n e instanceof Error ? e : undefined,\n lastAttachment?.contentType || fileOrAttachment.type,\n );\n throw e;\n } finally {\n this._attachmentAddOperations.finish(operation);\n }\n\n if (this._attachmentAddOperations.isCancelled(operation)) return;\n if (\n lastAttachment?.status.type === \"incomplete\" &&\n lastAttachment.status.reason === \"error\"\n ) {\n this._safeEmitAttachmentAddError(\n \"adapter-error\",\n lastAttachment.status.message ??\n \"Attachment upload did not complete successfully.\",\n lastAttachment.id,\n undefined,\n lastAttachment.contentType || fileOrAttachment.type,\n );\n } else {\n this._notifyEventSubscribers(\"attachmentAdd\", {\n ...(lastAttachment?.contentType\n ? { contentType: lastAttachment.contentType }\n : fileOrAttachment.type\n ? { contentType: fileOrAttachment.type }\n : undefined),\n });\n }\n }\n\n private _safeEmitAttachmentAddError(\n reason: AttachmentAddErrorReason,\n message: string,\n attachmentId?: string,\n error?: Error,\n contentType?: string,\n ) {\n try {\n this._notifyEventSubscribers(\"attachmentAddError\", {\n reason,\n message,\n ...(attachmentId !== undefined && { attachmentId }),\n ...(error !== undefined && { error }),\n ...(contentType ? { contentType } : undefined),\n });\n } catch (subscriberError) {\n console.error(\n \"[assistant-ui] attachmentAddError subscriber threw:\",\n subscriberError,\n );\n }\n }\n\n async removeAttachment(attachmentId: string) {\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n this._cancelAttachmentAdd(attachmentId);\n\n // A send in flight may already be uploading this attachment; the upload\n // can't be cancelled, so mark it to be dropped from the outgoing message\n // before any await gives the upload a chance to settle first.\n if (this._isSending) this._removedDuringSend.add(attachmentId);\n\n if (!isAttachmentComplete(attachment)) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n try {\n await adapter.remove(attachment);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n this._attachments = this._attachments.map((candidate) =>\n candidate.id === attachmentId && !isAttachmentComplete(candidate)\n ? {\n ...candidate,\n status: { type: \"incomplete\", reason: \"error\", message },\n }\n : candidate,\n );\n this._notifySubscribers();\n throw error;\n }\n }\n this._attachments = this._attachments.filter((a) => a.id !== attachmentId);\n this._notifySubscribers();\n }\n\n private _dictation: DictationState | undefined;\n private _dictationSession: DictationAdapter.Session | undefined;\n private _dictationUnsubscribes: Unsubscribe[] = [];\n private _dictationBaseText = \"\";\n private _currentInterimText = \"\";\n private _dictationSessionIdCounter = 0;\n private _activeDictationSessionId: number | undefined;\n private _isCleaningDictation = false;\n\n public get dictation(): DictationState | undefined {\n return this._dictation;\n }\n\n private _isActiveSession(\n sessionId: number,\n session: DictationAdapter.Session,\n ): boolean {\n return (\n this._activeDictationSessionId === sessionId &&\n this._dictationSession === session\n );\n }\n\n public startDictation(): void {\n const adapter = this.getDictationAdapter();\n if (!adapter) {\n throw new Error(\"Dictation adapter not configured\");\n }\n\n if (this._dictationSession) {\n for (const unsub of this._dictationUnsubscribes) {\n unsub();\n }\n this._dictationUnsubscribes = [];\n const oldSession = this._dictationSession;\n oldSession.stop().catch(() => {});\n this._dictationSession = undefined;\n }\n\n const inputDisabled = adapter.disableInputDuringDictation ?? false;\n\n this._dictationBaseText = this._text;\n this._currentInterimText = \"\";\n\n const session = adapter.listen();\n this._dictationSession = session;\n const sessionId = ++this._dictationSessionIdCounter;\n this._activeDictationSessionId = sessionId;\n this._dictation = { status: session.status, inputDisabled };\n this._notifySubscribers();\n\n const unsubSpeech = session.onSpeech((result) => {\n if (!this._isActiveSession(sessionId, session)) return;\n const isFinal = result.isFinal !== false;\n\n const needsSeparator =\n this._dictationBaseText &&\n !this._dictationBaseText.endsWith(\" \") &&\n result.transcript;\n const separator = needsSeparator ? \" \" : \"\";\n\n if (isFinal) {\n this._dictationBaseText =\n this._dictationBaseText + separator + result.transcript;\n this._currentInterimText = \"\";\n this._text = this._dictationBaseText;\n\n if (this._dictation) {\n const { transcript: _, ...rest } = this._dictation;\n this._dictation = rest;\n }\n this._notifySubscribers();\n } else {\n this._currentInterimText = separator + result.transcript;\n this._text = this._dictationBaseText + this._currentInterimText;\n\n if (this._dictation) {\n this._dictation = {\n ...this._dictation,\n transcript: result.transcript,\n };\n }\n this._notifySubscribers();\n }\n });\n this._dictationUnsubscribes.push(unsubSpeech);\n\n const unsubStart = session.onSpeechStart(() => {\n if (!this._isActiveSession(sessionId, session)) return;\n\n this._dictation = {\n status: { type: \"running\" },\n inputDisabled,\n ...(this._dictation?.transcript && {\n transcript: this._dictation.transcript,\n }),\n };\n this._notifySubscribers();\n });\n this._dictationUnsubscribes.push(unsubStart);\n\n const unsubEnd = session.onSpeechEnd(() => {\n this._cleanupDictation({ sessionId });\n });\n this._dictationUnsubscribes.push(unsubEnd);\n\n const statusInterval = setInterval(() => {\n if (!this._isActiveSession(sessionId, session)) return;\n\n if (session.status.type === \"ended\") {\n this._cleanupDictation({ sessionId });\n }\n }, 100);\n this._dictationUnsubscribes.push(() => clearInterval(statusInterval));\n }\n\n public stopDictation(): void {\n if (!this._dictationSession) return;\n\n const session = this._dictationSession;\n const sessionId = this._activeDictationSessionId;\n const cleanup = () => this._cleanupDictation({ sessionId });\n void session.stop().then(cleanup, cleanup);\n }\n\n private _cleanupDictation(options?: { sessionId: number | undefined }): void {\n const isStaleSession =\n options?.sessionId !== undefined &&\n options.sessionId !== this._activeDictationSessionId;\n if (isStaleSession || this._isCleaningDictation) return;\n\n this._isCleaningDictation = true;\n try {\n for (const unsub of this._dictationUnsubscribes) {\n unsub();\n }\n this._dictationUnsubscribes = [];\n this._dictationSession = undefined;\n this._activeDictationSessionId = undefined;\n this._dictation = undefined;\n this._dictationBaseText = \"\";\n this._currentInterimText = \"\";\n this._notifySubscribers();\n } finally {\n this._isCleaningDictation = false;\n }\n }\n\n private _eventSubscribers = new Map<\n ComposerRuntimeEventType,\n Set<(payload?: unknown) => void>\n >();\n\n protected _notifyEventSubscribers<E extends ComposerRuntimeEventType>(\n event: E,\n payload: ComposerRuntimeEventPayload[E],\n ) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n notifyEventListeners(subscribers, payload, `Composer runtime \"${event}\"`);\n }\n\n public unstable_on<E extends ComposerRuntimeEventType>(\n event: E,\n callback: ComposerRuntimeEventCallback<E>,\n ) {\n const wrapped = callback as (payload?: unknown) => void;\n let subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n subscribers = new Set();\n this._eventSubscribers.set(event, subscribers);\n }\n subscribers.add(wrapped);\n\n return () => {\n this._eventSubscribers.get(event)?.delete(wrapped);\n };\n }\n}\n"],"mappings":";;;;;;;;;AAqCA,IAAsB8B,0BAAtB,cACUlB,iBAEV;CACE,YAA4B;CAK5B,2BAEE0B,SAAYE,kBAA0D;EACtE,IAAI,CAACA,kBAAkB,OAAOF;EAC9B,OAAO;GACL,GAAGA;GACHH,UAAU;IACR,GAAGG,QAAQH;IACXC,QAAQ;KAAE,GAAGE,QAAQH,UAAUC;KAAQ,GAAGI;IAAiB;GAC7D;EACF;CACF;CAEA,IAAWC,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SAAS,KAAKT,wBACvBS,MAAM;GAER,KAAKT,yBAAyB,CAAA;GAC9B,KAAKhE,oBAAoBxC,KAAAA;GACzB,KAAK0G,4BAA4B1G,KAAAA;GACjC,KAAKK,aAAaL,KAAAA;GAClB,KAAKM,qBAAqB;GAC1B,KAAKC,sBAAsB;GAC3B,KAAKpB,mBAAmB;EAC1B,UAAU;GACR,KAAKwH,uBAAuB;EAC9B;CACF;CAEA,oCAA4B,IAAIgC,IAG9B;CAEF,wBACEE,OACAD,SACA;EACA,MAAMG,cAAc,KAAKL,kBAAkBM,IAAIH,KAAK;EACpD,IAAI,CAACE,aAAa;EAElBhL,qBAAqBgL,aAAaH,SAAS,qBAAqBC,MAAK,EAAG;CAC1E;CAEA,YACEA,OACAK,UACA;EACA,MAAMC,UAAUD;EAChB,IAAIH,cAAc,KAAKL,kBAAkBM,IAAIH,KAAK;EAClD,IAAI,CAACE,aAAa;GAChBA,8BAAc,IAAIjI,IAAI;GACtB,KAAK4H,kBAAkBU,IAAIP,OAAOE,WAAW;EAC/C;EACAA,YAAYnD,IAAIuD,OAAO;EAEvB,aAAa;GACX,KAAKT,kBAAkBM,IAAIH,KAAK,CAAC,EAAEQ,OAAOF,OAAO;EACnD;CACF;AACF"}
1
+ {"version":3,"file":"base-composer-runtime-core.js","names":["isAttachmentComplete","isCreateAttachment","Attachment","CompleteAttachment","CreateAttachment","PendingAttachment","MessageRole","AppendMessage","isMessageNotSentError","QuoteInfo","Unsubscribe","RunConfig","BaseSubscribable","AttachmentAdapter","fileMatchesAccept","AttachmentAddErrorReason","ComposerRuntimeCore","ComposerRuntimeEventCallback","ComposerRuntimeEventPayload","ComposerRuntimeEventType","DictationState","SendOptions","DictationAdapter","QueuePlacement","EMPTY_QUEUE_ITEMS","QueueItemState","generateId","notifyEventListeners","AttachmentAddOperations","drainAttachmentAdd","BaseComposerRuntimeCore","isEditing","getAttachmentAdapter","getDictationAdapter","enrichWithComposerMetadata","metadata","custom","Record","message","T","composerMetadata","attachmentAccept","accept","_attachments","attachments","setAttachments","value","_notifySubscribers","canCancel","canSend","isEmpty","text","trim","length","_text","_role","role","_runConfig","runConfig","_quote","undefined","quote","setQuote","setText","_rebaseDictation","_dictation","_dictationBaseText","_currentInterimText","status","inputDisabled","setRole","setRunConfig","_isSending","_removedDuringSend","Set","_sendGeneration","_attachmentAddOperations","_cancelAttachmentAdd","attachmentId","cancel","_cancelAllAttachmentAdds","cancelAll","_emptyTextAndAttachments","_onClearAttachments","adapter","pending","filter","a","Promise","all","map","remove","reset","clear","Object","keys","task","clearAttachments","attachment","add","id","send","options","_dictationSession","error","console","_cleanupDictation","attachmentTasks","Error","result","originalAttachments","generation","resolvedAttachments","e","allSettled","then","sentIds","has","finalAttachments","Omit","createdAt","Date","content","type","draft","sendTask","handleSend","_restoreUnsentDraft","catch","_notifyEventSubscribers","chars","restoreDraft","retractDraft","attachmentsUntouched","handleCancel","queue","moveQueueItem","_queueItemId","_placement","removeQueueItem","addAttachment","fileOrAttachment","File","name","contentType","err","_safeEmitAttachmentAddError","operation","start","upsertAttachment","idx","findIndex","slice","lastAttachment","file","isCancelled","reason","String","finish","subscriberError","removeAttachment","index","candidate","Session","_dictationUnsubscribes","_dictationSessionIdCounter","_activeDictationSessionId","_isCleaningDictation","dictation","_isActiveSession","sessionId","session","startDictation","isReplacing","oldSession","notify","_stopDictationSession","disableInputDuringDictation","listen","notifyError","unsubSpeech","onSpeech","isFinal","needsSeparator","endsWith","transcript","separator","_","rest","push","unsubStart","onSpeechStart","unsubEnd","onSpeechEnd","statusInterval","setInterval","clearInterval","stopDictation","cleanup","onSettled","stop","isStaleSession","runCleanup","unsubscribes","unsubscribe","_eventSubscribers","Map","payload","event","E","subscribers","get","unstable_on","callback","wrapped","set","delete"],"sources":["../../../src/runtime/base/base-composer-runtime-core.ts"],"sourcesContent":["import {\n isAttachmentComplete,\n isCreateAttachment,\n type Attachment,\n type CompleteAttachment,\n type CreateAttachment,\n type PendingAttachment,\n} from \"../../types/attachment\";\nimport type { MessageRole, AppendMessage } from \"../../types/message\";\nimport { isMessageNotSentError } from \"../../types/error\";\nimport type { QuoteInfo } from \"../../types/quote\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { RunConfig } from \"../../types/message\";\nimport { BaseSubscribable } from \"../../subscribable/subscribable\";\nimport {\n type AttachmentAdapter,\n fileMatchesAccept,\n} from \"../../adapters/attachment\";\nimport type {\n AttachmentAddErrorReason,\n ComposerRuntimeCore,\n ComposerRuntimeEventCallback,\n ComposerRuntimeEventPayload,\n ComposerRuntimeEventType,\n DictationState,\n SendOptions,\n} from \"../interfaces/composer-runtime-core\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type { QueuePlacement } from \"../queue/external-thread-queue-adapter\";\nimport { EMPTY_QUEUE_ITEMS, type QueueItemState } from \"../queue/queue-item\";\nimport { generateId } from \"../../utils/id\";\nimport { notifyEventListeners } from \"../../utils/notify-event-listeners\";\nimport {\n AttachmentAddOperations,\n drainAttachmentAdd,\n} from \"../utils/attachment-add-operations\";\n\nexport abstract class BaseComposerRuntimeCore\n extends BaseSubscribable\n implements ComposerRuntimeCore\n{\n public readonly isEditing = true;\n\n protected abstract getAttachmentAdapter(): AttachmentAdapter | undefined;\n protected abstract getDictationAdapter(): DictationAdapter | undefined;\n\n protected enrichWithComposerMetadata<\n T extends { metadata?: { custom?: Record<string, unknown> } },\n >(message: T, composerMetadata: Record<string, unknown> | undefined): T {\n if (!composerMetadata) return message;\n return {\n ...message,\n metadata: {\n ...message.metadata,\n custom: { ...message.metadata?.custom, ...composerMetadata },\n },\n } as T;\n }\n\n public get attachmentAccept(): string {\n return this.getAttachmentAdapter()?.accept ?? \"*\";\n }\n\n private _attachments: readonly Attachment[] = [];\n public get attachments() {\n return this._attachments;\n }\n\n protected setAttachments(value: readonly Attachment[]) {\n this._attachments = value;\n this._notifySubscribers();\n }\n\n public abstract get canCancel(): boolean;\n public abstract get canSend(): boolean;\n\n public get isEmpty() {\n return !this.text.trim() && !this.attachments.length;\n }\n\n private _text = \"\";\n\n get text() {\n return this._text;\n }\n\n private _role: MessageRole = \"user\";\n\n get role() {\n return this._role;\n }\n\n private _runConfig: RunConfig = {};\n\n get runConfig() {\n return this._runConfig;\n }\n\n private _quote: QuoteInfo | undefined = undefined;\n\n get quote() {\n return this._quote;\n }\n\n public setQuote(quote: QuoteInfo | undefined) {\n if (this._quote === quote) return;\n\n this._quote = quote;\n this._notifySubscribers();\n }\n\n public setText(value: string) {\n if (this._text === value) return;\n\n this._text = value;\n this._rebaseDictation(value);\n this._notifySubscribers();\n }\n\n // A live dictation session appends to the text it last saw, so any write\n // that bypasses `setText` has to move that baseline or the next transcript\n // overwrites what was just written.\n private _rebaseDictation(value: string) {\n if (!this._dictation) return;\n\n this._dictationBaseText = value;\n this._currentInterimText = \"\";\n const { status, inputDisabled } = this._dictation;\n this._dictation = inputDisabled ? { status, inputDisabled } : { status };\n }\n\n public setRole(role: MessageRole) {\n if (this._role === role) return;\n\n this._role = role;\n this._notifySubscribers();\n }\n\n public setRunConfig(runConfig: RunConfig) {\n if (this._runConfig === runConfig) return;\n\n this._runConfig = runConfig;\n this._notifySubscribers();\n }\n\n protected _isSending = false;\n private _removedDuringSend = new Set<string>();\n private _sendGeneration = 0;\n private _attachmentAddOperations = new AttachmentAddOperations();\n\n private _cancelAttachmentAdd(attachmentId: string) {\n this._attachmentAddOperations.cancel(attachmentId);\n }\n\n private _cancelAllAttachmentAdds() {\n this._attachmentAddOperations.cancelAll();\n }\n\n private _emptyTextAndAttachments() {\n this._attachments = [];\n this._text = \"\";\n this._rebaseDictation(\"\");\n this._notifySubscribers();\n }\n\n private async _onClearAttachments() {\n const adapter = this.getAttachmentAdapter();\n if (adapter) {\n const pending = this._attachments.filter((a) => !isAttachmentComplete(a));\n await Promise.all(pending.map(async (a) => adapter.remove(a)));\n }\n }\n\n public async reset() {\n this._cancelAllAttachmentAdds();\n\n // A send whose adapter never settles must not brick the composer; reset is\n // the escape hatch that releases the in-flight lock. Bumping the generation\n // invalidates that send entirely so a late-settling upload can neither\n // append the discarded draft nor touch a newer send's lock.\n this._sendGeneration++;\n this._isSending = false;\n this._removedDuringSend.clear();\n\n if (\n this._attachments.length === 0 &&\n this._text === \"\" &&\n this._role === \"user\" &&\n Object.keys(this._runConfig).length === 0 &&\n this._quote === undefined\n ) {\n return;\n }\n\n this._role = \"user\";\n this._runConfig = {};\n this._quote = undefined;\n\n const task = this._onClearAttachments();\n this._emptyTextAndAttachments();\n await task;\n }\n\n public async clearAttachments() {\n this._cancelAllAttachmentAdds();\n if (this._isSending) {\n for (const attachment of this._attachments)\n this._removedDuringSend.add(attachment.id);\n }\n const task = this._onClearAttachments();\n this.setAttachments([]);\n\n await task;\n }\n\n public async send(options?: SendOptions) {\n if (!this.canSend || this._isSending) return;\n\n if (this._dictationSession) {\n try {\n this._dictationSession.cancel();\n } catch (error) {\n console.error(\"[assistant-ui] Dictation session cancel threw\", error);\n } finally {\n this._cleanupDictation();\n }\n }\n\n const adapter = this.getAttachmentAdapter();\n const attachmentTasks = this.attachments.map(async (a) => {\n if (isAttachmentComplete(a)) return a;\n if (!adapter) throw new Error(\"Attachments are not supported\");\n const result = await adapter.send(a);\n return result as CompleteAttachment;\n });\n\n const originalAttachments = this.attachments;\n const text = this.text;\n const quote = this._quote;\n const role = this.role;\n const runConfig = this.runConfig;\n this._quote = undefined;\n this._text = \"\";\n this._isSending = true;\n const generation = ++this._sendGeneration;\n this._notifySubscribers();\n\n let resolvedAttachments: CompleteAttachment[];\n try {\n resolvedAttachments = await Promise.all(attachmentTasks);\n } catch (e) {\n if (generation === this._sendGeneration) {\n if (!this.text.trim() && this._quote === undefined) {\n this._text = text;\n this._rebaseDictation(text);\n this._quote = quote;\n this._notifySubscribers();\n }\n // Promise.all rejects on the first failure, but sibling uploads from\n // this batch keep running; the send rejects immediately while the\n // retry lock is held until they settle, or a retry could re-send\n // attachments that are still in flight.\n void Promise.allSettled(attachmentTasks).then(() => {\n if (generation !== this._sendGeneration) return;\n this._removedDuringSend.clear();\n this._isSending = false;\n this._notifySubscribers();\n });\n }\n throw e;\n }\n\n // A reset during the upload discarded this send's draft; the settled\n // uploads must not append it or touch the lock a newer send may own.\n if (generation !== this._sendGeneration) return;\n\n // Drop by id, not wholesale: the user may have added or removed chips while\n // the upload was in flight.\n const sentIds = new Set(originalAttachments.map((a) => a.id));\n this._attachments = this._attachments.filter((a) => !sentIds.has(a.id));\n this._isSending = false;\n this._notifySubscribers();\n\n // An attachment removed mid-upload can't be cancelled, but it can still be\n // dropped from the outgoing message instead of silently being sent anyway.\n const finalAttachments = resolvedAttachments.filter(\n (a) => !this._removedDuringSend.has(a.id),\n );\n this._removedDuringSend.clear();\n\n const message: Omit<AppendMessage, \"parentId\" | \"sourceId\"> = {\n createdAt: new Date(),\n role,\n content: text ? [{ type: \"text\", text }] : [],\n attachments: finalAttachments,\n runConfig,\n metadata: { custom: { ...(quote ? { quote } : {}) } },\n };\n\n const draft = { text, quote, attachments: finalAttachments };\n let sendTask: void | Promise<void>;\n try {\n sendTask = this.handleSend(message, options);\n } catch (error) {\n this._restoreUnsentDraft(error, generation, draft);\n throw error;\n }\n if (sendTask)\n void sendTask.catch((error) => {\n this._restoreUnsentDraft(error, generation, draft);\n });\n this._notifyEventSubscribers(\"send\", {\n chars: text.length,\n attachments: finalAttachments.length,\n });\n }\n\n /**\n * Take a message back into the composer when it has nowhere else to live:\n * a send the runtime never dispatched, or a message a cancelled run is\n * removing from the thread. Reports whether the composer accepted it, so a\n * caller that is also removing the message can keep it instead of dropping\n * it. Refused, and left untouched, while the composer holds anything of its\n * own.\n */\n public restoreDraft(draft: {\n text: string;\n quote?: QuoteInfo | undefined;\n attachments?: readonly Attachment[] | undefined;\n }): boolean {\n if (\n this._text.trim() ||\n this._quote !== undefined ||\n this._attachments.length > 0\n )\n return false;\n\n this._text = draft.text;\n this._rebaseDictation(draft.text);\n this._quote = draft.quote;\n this._attachments = draft.attachments ?? [];\n this._notifySubscribers();\n return true;\n }\n\n /**\n * Inverse of `restoreDraft`: clears the composer while it still holds\n * exactly the given draft. A draft the user has edited since is left\n * untouched.\n */\n public retractDraft(draft: {\n text: string;\n quote?: QuoteInfo | undefined;\n attachments?: readonly Attachment[] | undefined;\n }): void {\n const attachmentsUntouched =\n draft.attachments !== undefined\n ? this._attachments === draft.attachments\n : this._attachments.length === 0;\n if (\n this._text !== draft.text ||\n this._quote !== draft.quote ||\n !attachmentsUntouched\n )\n return;\n\n this._text = \"\";\n this._rebaseDictation(\"\");\n this._quote = undefined;\n this._attachments = [];\n this._notifySubscribers();\n }\n\n // The generation check is what a reset and a later send use to invalidate a\n // draft, so of several queued drafts only the most recent one is still\n // restorable.\n private _restoreUnsentDraft(\n error: unknown,\n generation: number,\n draft: {\n text: string;\n quote: QuoteInfo | undefined;\n attachments: readonly CompleteAttachment[];\n },\n ) {\n if (!isMessageNotSentError(error)) return;\n if (generation !== this._sendGeneration) return;\n this.restoreDraft(draft);\n }\n\n public cancel() {\n this.handleCancel();\n }\n\n public get queue(): readonly QueueItemState[] {\n return EMPTY_QUEUE_ITEMS;\n }\n\n public moveQueueItem(\n _queueItemId: string,\n _placement: QueuePlacement,\n ): void {}\n public removeQueueItem(_queueItemId: string): void {}\n\n protected abstract handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n options?: SendOptions,\n ): void | Promise<void>;\n protected abstract handleCancel(): void;\n\n async addAttachment(fileOrAttachment: File | CreateAttachment) {\n if (isCreateAttachment(fileOrAttachment)) {\n const adapter = this.getAttachmentAdapter();\n if (\n adapter &&\n !fileMatchesAccept(\n {\n name: fileOrAttachment.name,\n type: fileOrAttachment.contentType ?? \"\",\n },\n adapter.accept,\n )\n ) {\n const message = `File type ${fileOrAttachment.contentType || \"unknown\"} is not accepted. Accepted types: ${adapter.accept}`;\n const err = new Error(message);\n this._safeEmitAttachmentAddError(\n \"not-accepted\",\n message,\n undefined,\n err,\n fileOrAttachment.contentType,\n );\n throw err;\n }\n\n const a: CompleteAttachment = {\n id: fileOrAttachment.id ?? generateId(),\n type: fileOrAttachment.type ?? \"document\",\n name: fileOrAttachment.name,\n contentType: fileOrAttachment.contentType,\n content: fileOrAttachment.content,\n status: { type: \"complete\" },\n };\n this._attachments = [...this._attachments, a];\n this._notifySubscribers();\n this._notifyEventSubscribers(\"attachmentAdd\", {\n ...(a.contentType ? { contentType: a.contentType } : undefined),\n });\n return;\n }\n\n const adapter = this.getAttachmentAdapter();\n if (!adapter) {\n const message = \"Attachments are not supported\";\n const err = new Error(message);\n this._safeEmitAttachmentAddError(\n \"no-adapter\",\n message,\n undefined,\n err,\n fileOrAttachment.type,\n );\n throw err;\n }\n\n if (\n !fileMatchesAccept(\n { name: fileOrAttachment.name, type: fileOrAttachment.type },\n adapter.accept,\n )\n ) {\n const message = `File type ${fileOrAttachment.type || \"unknown\"} is not accepted. Accepted types: ${adapter.accept}`;\n const err = new Error(message);\n this._safeEmitAttachmentAddError(\n \"not-accepted\",\n message,\n undefined,\n err,\n fileOrAttachment.type,\n );\n throw err;\n }\n\n const operation = this._attachmentAddOperations.start();\n const upsertAttachment = (a: PendingAttachment) => {\n if (!this._attachmentAddOperations.accept(operation, a.id)) return false;\n\n const idx = this._attachments.findIndex(\n (attachment) => attachment.id === a.id,\n );\n if (idx !== -1)\n this._attachments = [\n ...this._attachments.slice(0, idx),\n a,\n ...this._attachments.slice(idx + 1),\n ];\n else {\n this._attachments = [...this._attachments, a];\n }\n\n this._notifySubscribers();\n return true;\n };\n let lastAttachment: PendingAttachment | undefined;\n try {\n await drainAttachmentAdd(\n adapter.add({ file: fileOrAttachment }),\n (attachment) => {\n lastAttachment = attachment;\n return upsertAttachment(attachment);\n },\n );\n } catch (e) {\n if (this._attachmentAddOperations.isCancelled(operation)) return;\n if (lastAttachment) {\n upsertAttachment({\n ...lastAttachment,\n status: {\n type: \"incomplete\",\n reason: \"error\",\n message: e instanceof Error ? e.message : String(e),\n },\n });\n }\n this._safeEmitAttachmentAddError(\n \"adapter-error\",\n e instanceof Error ? e.message : String(e),\n lastAttachment?.id,\n e instanceof Error ? e : undefined,\n lastAttachment?.contentType || fileOrAttachment.type,\n );\n throw e;\n } finally {\n this._attachmentAddOperations.finish(operation);\n }\n\n if (this._attachmentAddOperations.isCancelled(operation)) return;\n if (\n lastAttachment?.status.type === \"incomplete\" &&\n lastAttachment.status.reason === \"error\"\n ) {\n this._safeEmitAttachmentAddError(\n \"adapter-error\",\n lastAttachment.status.message ??\n \"Attachment upload did not complete successfully.\",\n lastAttachment.id,\n undefined,\n lastAttachment.contentType || fileOrAttachment.type,\n );\n } else {\n this._notifyEventSubscribers(\"attachmentAdd\", {\n ...(lastAttachment?.contentType\n ? { contentType: lastAttachment.contentType }\n : fileOrAttachment.type\n ? { contentType: fileOrAttachment.type }\n : undefined),\n });\n }\n }\n\n private _safeEmitAttachmentAddError(\n reason: AttachmentAddErrorReason,\n message: string,\n attachmentId?: string,\n error?: Error,\n contentType?: string,\n ) {\n try {\n this._notifyEventSubscribers(\"attachmentAddError\", {\n reason,\n message,\n ...(attachmentId !== undefined && { attachmentId }),\n ...(error !== undefined && { error }),\n ...(contentType ? { contentType } : undefined),\n });\n } catch (subscriberError) {\n console.error(\n \"[assistant-ui] attachmentAddError subscriber threw:\",\n subscriberError,\n );\n }\n }\n\n async removeAttachment(attachmentId: string) {\n const index = this._attachments.findIndex((a) => a.id === attachmentId);\n if (index === -1) throw new Error(\"Attachment not found\");\n const attachment = this._attachments[index]!;\n\n this._cancelAttachmentAdd(attachmentId);\n\n // A send in flight may already be uploading this attachment; the upload\n // can't be cancelled, so mark it to be dropped from the outgoing message\n // before any await gives the upload a chance to settle first.\n if (this._isSending) this._removedDuringSend.add(attachmentId);\n\n if (!isAttachmentComplete(attachment)) {\n const adapter = this.getAttachmentAdapter();\n if (!adapter) throw new Error(\"Attachments are not supported\");\n try {\n await adapter.remove(attachment);\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n this._attachments = this._attachments.map((candidate) =>\n candidate.id === attachmentId && !isAttachmentComplete(candidate)\n ? {\n ...candidate,\n status: { type: \"incomplete\", reason: \"error\", message },\n }\n : candidate,\n );\n this._notifySubscribers();\n throw error;\n }\n }\n this._attachments = this._attachments.filter((a) => a.id !== attachmentId);\n this._notifySubscribers();\n }\n\n private _dictation: DictationState | undefined;\n private _dictationSession: DictationAdapter.Session | undefined;\n private _dictationUnsubscribes: Unsubscribe[] = [];\n private _dictationBaseText = \"\";\n private _currentInterimText = \"\";\n private _dictationSessionIdCounter = 0;\n private _activeDictationSessionId: number | undefined;\n private _isCleaningDictation = false;\n\n public get dictation(): DictationState | undefined {\n return this._dictation;\n }\n\n private _isActiveSession(\n sessionId: number,\n session: DictationAdapter.Session,\n ): boolean {\n return (\n this._activeDictationSessionId === sessionId &&\n this._dictationSession === session\n );\n }\n\n public startDictation(): void {\n const adapter = this.getDictationAdapter();\n if (!adapter) {\n throw new Error(\"Dictation adapter not configured\");\n }\n\n const isReplacing = this._dictationSession !== undefined;\n if (this._dictationSession) {\n const oldSession = this._dictationSession;\n this._cleanupDictation({ notify: false });\n this._stopDictationSession(oldSession);\n }\n\n const inputDisabled = adapter.disableInputDuringDictation ?? false;\n\n this._dictationBaseText = this._text;\n this._currentInterimText = \"\";\n\n let session: DictationAdapter.Session;\n try {\n session = adapter.listen();\n } catch (error) {\n if (isReplacing) {\n try {\n this._notifySubscribers();\n } catch (notifyError) {\n console.error(\n \"[assistant-ui] Dictation replacement rollback notification threw\",\n notifyError,\n );\n }\n }\n throw error;\n }\n this._dictationSession = session;\n const sessionId = ++this._dictationSessionIdCounter;\n this._activeDictationSessionId = sessionId;\n this._dictation = { status: session.status, inputDisabled };\n this._notifySubscribers();\n\n const unsubSpeech = session.onSpeech((result) => {\n if (!this._isActiveSession(sessionId, session)) return;\n const isFinal = result.isFinal !== false;\n\n const needsSeparator =\n this._dictationBaseText &&\n !this._dictationBaseText.endsWith(\" \") &&\n result.transcript;\n const separator = needsSeparator ? \" \" : \"\";\n\n if (isFinal) {\n this._dictationBaseText =\n this._dictationBaseText + separator + result.transcript;\n this._currentInterimText = \"\";\n this._text = this._dictationBaseText;\n\n if (this._dictation) {\n const { transcript: _, ...rest } = this._dictation;\n this._dictation = rest;\n }\n this._notifySubscribers();\n } else {\n this._currentInterimText = separator + result.transcript;\n this._text = this._dictationBaseText + this._currentInterimText;\n\n if (this._dictation) {\n this._dictation = {\n ...this._dictation,\n transcript: result.transcript,\n };\n }\n this._notifySubscribers();\n }\n });\n this._dictationUnsubscribes.push(unsubSpeech);\n\n const unsubStart = session.onSpeechStart(() => {\n if (!this._isActiveSession(sessionId, session)) return;\n\n this._dictation = {\n status: { type: \"running\" },\n inputDisabled,\n ...(this._dictation?.transcript && {\n transcript: this._dictation.transcript,\n }),\n };\n this._notifySubscribers();\n });\n this._dictationUnsubscribes.push(unsubStart);\n\n const unsubEnd = session.onSpeechEnd(() => {\n this._cleanupDictation({ sessionId });\n });\n this._dictationUnsubscribes.push(unsubEnd);\n\n const statusInterval = setInterval(() => {\n if (!this._isActiveSession(sessionId, session)) return;\n\n if (session.status.type === \"ended\") {\n this._cleanupDictation({ sessionId });\n }\n }, 100);\n this._dictationUnsubscribes.push(() => clearInterval(statusInterval));\n }\n\n public stopDictation(): void {\n if (!this._dictationSession) return;\n\n const session = this._dictationSession;\n const sessionId = this._activeDictationSessionId;\n const cleanup = () => this._cleanupDictation({ sessionId });\n this._stopDictationSession(session, cleanup);\n }\n\n private _stopDictationSession(\n session: DictationAdapter.Session,\n onSettled: () => void = () => {},\n ): void {\n let task: Promise<void>;\n try {\n task = session.stop();\n } catch (error) {\n console.error(\"[assistant-ui] Dictation session stop threw\", error);\n onSettled();\n return;\n }\n\n void task.then(onSettled, (error) => {\n console.error(\"[assistant-ui] Dictation session stop rejected\", error);\n onSettled();\n });\n }\n\n private _cleanupDictation(options?: {\n sessionId?: number | undefined;\n notify?: boolean | undefined;\n }): void {\n const isStaleSession =\n options?.sessionId !== undefined &&\n options.sessionId !== this._activeDictationSessionId;\n if (isStaleSession || this._isCleaningDictation) return;\n\n this._isCleaningDictation = true;\n const runCleanup = (cleanup: () => void) => {\n try {\n cleanup();\n } catch (error) {\n console.error(\"[assistant-ui] Dictation cleanup threw\", error);\n }\n };\n\n try {\n const unsubscribes = this._dictationUnsubscribes;\n this._dictationUnsubscribes = [];\n this._dictationSession = undefined;\n this._activeDictationSessionId = undefined;\n this._dictation = undefined;\n this._dictationBaseText = \"\";\n this._currentInterimText = \"\";\n\n for (const unsubscribe of unsubscribes) runCleanup(unsubscribe);\n if (options?.notify !== false) {\n runCleanup(() => this._notifySubscribers());\n }\n } finally {\n this._isCleaningDictation = false;\n }\n }\n\n private _eventSubscribers = new Map<\n ComposerRuntimeEventType,\n Set<(payload?: unknown) => void>\n >();\n\n protected _notifyEventSubscribers<E extends ComposerRuntimeEventType>(\n event: E,\n payload: ComposerRuntimeEventPayload[E],\n ) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n notifyEventListeners(subscribers, payload, `Composer runtime \"${event}\"`);\n }\n\n public unstable_on<E extends ComposerRuntimeEventType>(\n event: E,\n callback: ComposerRuntimeEventCallback<E>,\n ) {\n const wrapped = callback as (payload?: unknown) => void;\n let subscribers = this._eventSubscribers.get(event);\n if (!subscribers) {\n subscribers = new Set();\n this._eventSubscribers.set(event, subscribers);\n }\n subscribers.add(wrapped);\n\n return () => {\n this._eventSubscribers.get(event)?.delete(wrapped);\n };\n }\n}\n"],"mappings":";;;;;;;;;AAqCA,IAAsB8B,0BAAtB,cACUlB,iBAEV;CACE,YAA4B;CAK5B,2BAEE0B,SAAYE,kBAA0D;EACtE,IAAI,CAACA,kBAAkB,OAAOF;EAC9B,OAAO;GACL,GAAGA;GACHH,UAAU;IACR,GAAGG,QAAQH;IACXC,QAAQ;KAAE,GAAGE,QAAQH,UAAUC;KAAQ,GAAGI;IAAiB;GAC7D;EACF;CACF;CAEA,IAAWC,mBAA2B;EACpC,OAAO,KAAKT,qBAAqB,CAAC,EAAE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AIH,cAAc,KAAKL,kBAAkBM,IAAIH,KAAK;EAClD,IAAI,CAACE,aAAa;GAChBA,8BAAc,IAAIxI,IAAI;GACtB,KAAKmI,kBAAkBU,IAAIP,OAAOE,WAAW;EAC/C;EACAA,YAAY/G,IAAImH,OAAO;EAEvB,aAAa;GACX,KAAKT,kBAAkBM,IAAIH,KAAK,CAAC,EAAEQ,OAAOF,OAAO;EACnD;CACF;AACF"}
@@ -19,7 +19,7 @@ type BaseThreadAdapters = {
19
19
  attachments?: AttachmentAdapter | undefined;
20
20
  voice?: RealtimeVoiceAdapter | undefined;
21
21
  };
22
- declare abstract class BaseThreadRuntimeCore extends BaseSubscribable implements ThreadRuntimeCore {
22
+ export declare abstract class BaseThreadRuntimeCore extends BaseSubscribable implements ThreadRuntimeCore {
23
23
  private _isInitialized;
24
24
  protected repository: MessageRepository;
25
25
  abstract get adapters(): BaseThreadAdapters | undefined;
@@ -47,6 +47,7 @@ declare abstract class BaseThreadRuntimeCore extends BaseSubscribable implements
47
47
  private _cachedMergedBase;
48
48
  protected _markVoiceMessagesDirty(): void;
49
49
  protected _getBaseMessages(): readonly ThreadMessage[];
50
+ protected _commitVoiceMessage(_message: ThreadMessage): void;
50
51
  get messages(): readonly ThreadMessage[];
51
52
  get state(): string | number | boolean | import("assistant-stream/utils").ReadonlyJSONObject | import("assistant-stream/utils").ReadonlyJSONArray | null;
52
53
  readonly composer: DefaultThreadComposerRuntimeCore;
@@ -69,6 +70,8 @@ declare abstract class BaseThreadRuntimeCore extends BaseSubscribable implements
69
70
  protected enrichAppendMetadata(message: AppendMessage, anchorId?: string | null): AppendMessage;
70
71
  private _editComposers;
71
72
  getEditComposer(messageId: string): DefaultEditComposerRuntimeCore | undefined;
73
+ protected _isVoiceMessage(messageId: string | null): boolean;
74
+ protected _resolveAppendParent(parentId: string | null): string | null;
72
75
  beginEdit(messageId: string): void;
73
76
  getMessageById(messageId: string): {
74
77
  parentId: string | null;
@@ -78,7 +81,8 @@ declare abstract class BaseThreadRuntimeCore extends BaseSubscribable implements
78
81
  getBranches(messageId: string): string[];
79
82
  switchToBranch(branchId: string): void;
80
83
  _notifyEventSubscribers<E extends ThreadRuntimeEventType>(event: E, payload: ThreadRuntimeEventPayload[E]): void;
81
- submitFeedback({ messageId, type }: SubmitFeedbackOptions): void;
84
+ protected _notifyToolApprovalAnswered(messageId: string, toolCallId: string, toolName: string, approved: boolean): void;
85
+ submitFeedback({ messageId, type, comment }: SubmitFeedbackOptions): void;
82
86
  private _stopSpeaking;
83
87
  speech: SpeechState | undefined;
84
88
  speak(messageId: string): void;
@@ -90,11 +94,15 @@ declare abstract class BaseThreadRuntimeCore extends BaseSubscribable implements
90
94
  private _voiceVolumeSubscribers;
91
95
  getVoiceVolume: () => number;
92
96
  subscribeVoiceVolume: (callback: () => void) => Unsubscribe;
97
+ protected _onVoiceConnected(): void;
98
+ protected _onVoiceDisconnected(): void;
99
+ protected _isRunActive(): boolean;
93
100
  connectVoice(): void;
94
101
  private _currentAssistantMsg;
95
102
  private _handleVoiceTranscript;
96
103
  private _finishVoiceAssistantMessage;
97
104
  disconnectVoice(): void;
105
+ private _disconnectVoice;
98
106
  muteVoice(): void;
99
107
  unmuteVoice(): void;
100
108
  protected ensureInitialized(): void;
@@ -105,5 +113,4 @@ declare abstract class BaseThreadRuntimeCore extends BaseSubscribable implements
105
113
  unstable_on<E extends ThreadRuntimeEventType>(event: E, callback: ThreadRuntimeEventCallback<E>): Unsubscribe;
106
114
  }
107
115
  //#endregion
108
- export { BaseThreadRuntimeCore };
109
116
  //# sourceMappingURL=base-thread-runtime-core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"base-thread-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/base-thread-runtime-core.ts"],"mappings":";;;;;;;;;;;;;;;KAwCK;EACH,SAAS;EACT,WAAW;EACX,cAAc;EACd,QAAQ;;uBAGY,8BACZ,4BACG;UAEH;YAEE,YAAU;eACA,YAAY;eACZ;eACA;eACA;eACA,wBAAwB;eACxB;eAEA,gBAAgB;WACpB,OAAO,SAAS;WAChB,cAAc,2BAA2B;WACzC,SAAS,QAAQ;WACjB,UAAU,QAAQ;WAClB,cAAc,SAAS;WACvB,eAAe,SAAS;WACxB,sBACd,SAAS,+BACR;WACa;WACA;WACA,oBAAoB;WACpB;YAEN,gBAAgB;YAChB;UACF;UACA;UACA;YAEE;YAKA,6BAA6B;MAI5B,qBAAqB;MAgBrB,sEAAK,sDAAA;WAWA,UAAQ;mBAEP;EAEL,YAAA,kBAAkB;EAKvB,mBALuB;;;;;;;;;;;;;;YAsBpB,qBACR,SAAS,eACT,2BACC;UAmBK;EACD,gBAAgB,oBAAiB;EAGjC,UAAU;EAeV,eAAe;;;;;EAsBf,YAAY;EAOZ,eAAe;EAKf,wBAAwB,UAAU,wBACvC,OAAO,GACP,SAAS,0BAA0B;EAQ9B,iBAAiB,WAAW,QAAQ;UAqBnC;EACD,QAAQ;EAER,MAAM;EA8BN;UAMC;UACA;EACD,OAAO;UAEN;UACA;EAED;EAEA,uBAAwB,yBAAuB;EAK/C;UAmEC;UAEA;UAgEA;EAaD;EAmBA;EAUA;YAUG;EAOH,UAAM;EAIN,OAAO,MAAM;EAOb,MAAM,2BAA2B;UAIhC;EAKD,YAAY,UAAU,wBAC3B,OAAO,GACP,UAAU,2BAA2B,KAAE"}
1
+ {"version":3,"file":"base-thread-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/base-thread-runtime-core.ts"],"mappings":";;;;;;;;;;;;;;;KA2CK;EACH,SAAS;EACT,WAAW;EACX,cAAc;EACd,QAAQ;;8BAGY,8BACZ,4BACG;UAEH;YAEE,YAAU;eACA,YAAY;eACZ;eACA;eACA;eACA,wBAAwB;eACxB;eAEA,gBAAgB;WACpB,OAAO,SAAS;WAChB,cAAc,2BAA2B;WACzC,SAAS,QAAQ;WACjB,UAAU,QAAQ;WAClB,cAAc,SAAS;WACvB,eAAe,SAAS;WACxB,sBACd,SAAS,+BACR;WACa;WACA;WACA,oBAAoB;WACpB;YAEN,gBAAgB;YAChB;UACF;UACA;UACA;YAEE;YAKA,6BAA6B;YAI7B,oBAAoB,UAAU;MAE7B,qBAAqB;MAsBrB,sEAAK,sDAAA;WAWA,UAAQ;mBAEP;EAEL,YAAA,kBAAkB;EAKvB,mBALuB;;;;;;;;;;;;;;YAsBpB,qBACR,SAAS,eACT,2BACC;UAmBK;EACD,gBAAgB,oBAAiB;YAG9B,gBAAgB;YAMhB,qBAAqB;EAMxB,UAAU;EAsBV,eAAe;;;;;EAsBf,YAAY;EAOZ,eAAe;EAKf,wBAAwB,UAAU,wBACvC,OAAO,GACP,SAAS,0BAA0B;YAQ3B,4BACR,mBACA,oBACA,kBACA;EAUK,iBAAiB,WAAW,MAAM,WAAW;UAkC5C;EACD,QAAQ;EAER,MAAM;EA2EN;UAKC;UACA;EACD,OAAO;UAEN;UACA;EAED;EAEA,uBAAwB,yBAAuB;YAK5C;YAEA;YAEA;EAUH;UA+HC;UAEA;UAoEA;EAeD;UAIC;EAoCD;EAUA;YAUG;EAOH,UAAM;EAIN,OAAO,MAAM;EAOb,MAAM,2BAA2B;UAIhC;EAKD,YAAY,UAAU,wBAC3B,OAAO,GACP,UAAU,2BAA2B,KAAE"}