@assistant-ui/core 0.3.20 → 0.3.21

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 (905) hide show
  1. package/dist/adapters/attachment.d.ts +42 -34
  2. package/dist/adapters/attachment.d.ts.map +1 -1
  3. package/dist/adapters/attachment.js +51 -21
  4. package/dist/adapters/attachment.js.map +1 -1
  5. package/dist/adapters/directive-formatter.d.ts +1 -3
  6. package/dist/adapters/directive-formatter.d.ts.map +1 -1
  7. package/dist/adapters/feedback.d.ts +6 -7
  8. package/dist/adapters/feedback.d.ts.map +1 -1
  9. package/dist/adapters/index.d.ts +14 -9
  10. package/dist/adapters/index.d.ts.map +1 -0
  11. package/dist/adapters/index.js +1 -1
  12. package/dist/adapters/speech.d.ts +57 -58
  13. package/dist/adapters/speech.d.ts.map +1 -1
  14. package/dist/adapters/speech.js +16 -2
  15. package/dist/adapters/speech.js.map +1 -1
  16. package/dist/adapters/suggestion.d.ts +14 -16
  17. package/dist/adapters/suggestion.d.ts.map +1 -1
  18. package/dist/adapters/thread-history.d.ts +54 -51
  19. package/dist/adapters/thread-history.d.ts.map +1 -1
  20. package/dist/adapters/trigger.d.ts +7 -9
  21. package/dist/adapters/trigger.d.ts.map +1 -1
  22. package/dist/adapters/voice.d.ts +46 -40
  23. package/dist/adapters/voice.d.ts.map +1 -1
  24. package/dist/adapters/voice.js +17 -3
  25. package/dist/adapters/voice.js.map +1 -1
  26. package/dist/index.d.ts +70 -56
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +6 -6
  29. package/dist/index.js.map +1 -1
  30. package/dist/internal/duplicate-detection.d.ts +0 -2
  31. package/dist/internal/duplicate-detection.d.ts.map +1 -1
  32. package/dist/internal.d.ts +27 -58
  33. package/dist/internal.d.ts.map +1 -0
  34. package/dist/internal.js +8 -6
  35. package/dist/model-context/frame/host.d.ts +19 -21
  36. package/dist/model-context/frame/host.d.ts.map +1 -1
  37. package/dist/model-context/frame/host.js +3 -1
  38. package/dist/model-context/frame/host.js.map +1 -1
  39. package/dist/model-context/frame/provider.d.ts +27 -28
  40. package/dist/model-context/frame/provider.d.ts.map +1 -1
  41. package/dist/model-context/frame/provider.js +6 -0
  42. package/dist/model-context/frame/provider.js.map +1 -1
  43. package/dist/model-context/frame/types.d.ts +19 -21
  44. package/dist/model-context/frame/types.d.ts.map +1 -1
  45. package/dist/model-context/frame/validate.d.ts +3 -0
  46. package/dist/model-context/frame/validate.d.ts.map +1 -0
  47. package/dist/model-context/frame/validate.js +26 -0
  48. package/dist/model-context/frame/validate.js.map +1 -0
  49. package/dist/model-context/interactable-composer-metadata.d.ts +42 -29
  50. package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
  51. package/dist/model-context/interactable-composer-metadata.js +30 -6
  52. package/dist/model-context/interactable-composer-metadata.js.map +1 -1
  53. package/dist/model-context/registry-handles.d.ts +6 -8
  54. package/dist/model-context/registry-handles.d.ts.map +1 -1
  55. package/dist/model-context/registry.d.ts +14 -16
  56. package/dist/model-context/registry.d.ts.map +1 -1
  57. package/dist/model-context/tool-call-text.d.ts +13 -14
  58. package/dist/model-context/tool-call-text.d.ts.map +1 -1
  59. package/dist/model-context/tool.d.ts +10 -11
  60. package/dist/model-context/tool.d.ts.map +1 -1
  61. package/dist/model-context/types.d.ts +32 -34
  62. package/dist/model-context/types.d.ts.map +1 -1
  63. package/dist/react/AssistantProvider.d.ts +6 -8
  64. package/dist/react/AssistantProvider.d.ts.map +1 -1
  65. package/dist/react/AssistantRuntimeProvider.d.ts +23 -25
  66. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  67. package/dist/react/RuntimeAdapter.d.ts +2 -5
  68. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  69. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +24 -18
  70. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  71. package/dist/react/adapters/LocalStorageThreadListAdapter.js +58 -25
  72. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  73. package/dist/react/adapters/TitleGenerationAdapter.d.ts +2 -4
  74. package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
  75. package/dist/react/client/AdaptedRemoteThread.d.ts +5 -7
  76. package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
  77. package/dist/react/client/DataRenderers.d.ts +1 -3
  78. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  79. package/dist/react/client/InMemoryThreadList.d.ts +6 -8
  80. package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
  81. package/dist/react/client/Interactables.d.ts +2 -4
  82. package/dist/react/client/Interactables.d.ts.map +1 -1
  83. package/dist/react/client/Interactables.js +306 -101
  84. package/dist/react/client/Interactables.js.map +1 -1
  85. package/dist/react/client/RemoteThreadList.d.ts +32 -34
  86. package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
  87. package/dist/react/client/RemoteThreadList.js +2 -1
  88. package/dist/react/client/RemoteThreadList.js.map +1 -1
  89. package/dist/react/client/Tools.d.ts +9 -11
  90. package/dist/react/client/Tools.d.ts.map +1 -1
  91. package/dist/react/client/Tools.js +4 -8
  92. package/dist/react/client/Tools.js.map +1 -1
  93. package/dist/react/client/interactable-model-context.d.ts +9 -10
  94. package/dist/react/client/interactable-model-context.d.ts.map +1 -1
  95. package/dist/react/client/interactable-model-context.js +32 -22
  96. package/dist/react/client/interactable-model-context.js.map +1 -1
  97. package/dist/react/index.d.ts +160 -122
  98. package/dist/react/index.d.ts.map +1 -0
  99. package/dist/react/index.js +5 -5
  100. package/dist/react/interactables-legacy/Interactables.d.ts +1 -3
  101. package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
  102. package/dist/react/interactables-legacy/Interactables.js +15 -8
  103. package/dist/react/interactables-legacy/Interactables.js.map +1 -1
  104. package/dist/react/interactables-legacy/interactable-model-context.d.ts +6 -8
  105. package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
  106. package/dist/react/interactables-legacy/interactable-model-context.js +13 -14
  107. package/dist/react/interactables-legacy/interactable-model-context.js.map +1 -1
  108. package/dist/react/interactables-legacy/scopes.d.ts +33 -36
  109. package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
  110. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +6 -8
  111. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
  112. package/dist/react/interactables-legacy/useInteractableState.d.ts +6 -7
  113. package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
  114. package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +23 -13
  115. package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
  116. package/dist/react/interactables-shared/useInteractablePersistenceQueue.js +54 -25
  117. package/dist/react/interactables-shared/useInteractablePersistenceQueue.js.map +1 -1
  118. package/dist/react/model-context/define-mcp-toolkit.d.ts +11 -13
  119. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
  120. package/dist/react/model-context/define-toolkit.d.ts +12 -4
  121. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  122. package/dist/react/model-context/external-tool.d.ts +0 -2
  123. package/dist/react/model-context/external-tool.d.ts.map +1 -1
  124. package/dist/react/model-context/human-tool.d.ts +0 -2
  125. package/dist/react/model-context/human-tool.d.ts.map +1 -1
  126. package/dist/react/model-context/interactableTool.d.ts +23 -25
  127. package/dist/react/model-context/interactableTool.d.ts.map +1 -1
  128. package/dist/react/model-context/makeAssistantDataUI.d.ts +4 -6
  129. package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
  130. package/dist/react/model-context/makeAssistantTool.d.ts +4 -6
  131. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  132. package/dist/react/model-context/makeAssistantToolUI.d.ts +4 -6
  133. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  134. package/dist/react/model-context/provider-tool.d.ts +3 -4
  135. package/dist/react/model-context/provider-tool.d.ts.map +1 -1
  136. package/dist/react/model-context/stub-tool.d.ts +0 -2
  137. package/dist/react/model-context/stub-tool.d.ts.map +1 -1
  138. package/dist/react/model-context/toolbox.d.ts +37 -24
  139. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  140. package/dist/react/model-context/useAssistantContext.d.ts +2 -5
  141. package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
  142. package/dist/react/model-context/useAssistantDataUI.d.ts +5 -7
  143. package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
  144. package/dist/react/model-context/useAssistantInstructions.d.ts +2 -5
  145. package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
  146. package/dist/react/model-context/useAssistantTool.d.ts +8 -11
  147. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  148. package/dist/react/model-context/useAssistantToolUI.d.ts +11 -13
  149. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  150. package/dist/react/model-context/useAuiToolOverrides.d.ts +2 -3
  151. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
  152. package/dist/react/model-context/useInlineRender.d.ts +2 -4
  153. package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
  154. package/dist/react/model-context/useInteractable.d.ts +37 -36
  155. package/dist/react/model-context/useInteractable.d.ts.map +1 -1
  156. package/dist/react/model-context/useInteractableState.d.ts +10 -8
  157. package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
  158. package/dist/react/model-context/useInteractableVersions.d.ts +3 -5
  159. package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
  160. package/dist/react/model-context/useToolArgsStatus.d.ts +5 -6
  161. package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
  162. package/dist/react/primitive-hooks/useActionBarCopy.d.ts +6 -8
  163. package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
  164. package/dist/react/primitive-hooks/useActionBarEdit.d.ts +2 -4
  165. package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
  166. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +4 -6
  167. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
  168. package/dist/react/primitive-hooks/useActionBarReload.d.ts +2 -4
  169. package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
  170. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +2 -4
  171. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
  172. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +2 -4
  173. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
  174. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +2 -4
  175. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
  176. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +2 -4
  177. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
  178. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +3 -5
  179. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
  180. package/dist/react/primitive-hooks/useComposerCancel.d.ts +2 -4
  181. package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
  182. package/dist/react/primitive-hooks/useComposerDictate.d.ts +2 -4
  183. package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
  184. package/dist/react/primitive-hooks/useComposerSend.d.ts +3 -5
  185. package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
  186. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +1 -3
  187. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
  188. package/dist/react/primitive-hooks/useEditComposerSend.d.ts +2 -4
  189. package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
  190. package/dist/react/primitive-hooks/useMessageBranching.d.ts +4 -6
  191. package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
  192. package/dist/react/primitive-hooks/useMessageError.d.ts +0 -2
  193. package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
  194. package/dist/react/primitive-hooks/useMessageReload.d.ts +2 -4
  195. package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
  196. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +6 -8
  197. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
  198. package/dist/react/primitive-hooks/useSuggestionTrigger.js +4 -4
  199. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  200. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +0 -2
  201. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
  202. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +0 -2
  203. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
  204. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +1 -3
  205. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
  206. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +1 -3
  207. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
  208. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +1 -3
  209. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
  210. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +1 -3
  211. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
  212. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +2 -4
  213. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
  214. package/dist/react/primitive-hooks/useThreadListNew.d.ts +1 -3
  215. package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
  216. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +0 -2
  217. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
  218. package/dist/react/primitive-hooks/useThreadMessages.d.ts +1 -3
  219. package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
  220. package/dist/react/primitive-hooks/useVoice.d.ts +5 -7
  221. package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
  222. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +25 -26
  223. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
  224. package/dist/react/primitives/composer/ComposerAttachments.d.ts +22 -23
  225. package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
  226. package/dist/react/primitives/composer/ComposerIf.d.ts +10 -9
  227. package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
  228. package/dist/react/primitives/composer/ComposerQueue.d.ts +11 -14
  229. package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
  230. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +26 -28
  231. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
  232. package/dist/react/primitives/generativeUI/GenerativeUI.js +16 -6
  233. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  234. package/dist/react/primitives/message/MessageAttachments.d.ts +26 -23
  235. package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
  236. package/dist/react/primitives/message/MessageAttachments.js +14 -15
  237. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  238. package/dist/react/primitives/message/MessageGroupedParts.d.ts +120 -117
  239. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  240. package/dist/react/primitives/message/MessageGroupedParts.js +3 -3
  241. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  242. package/dist/react/primitives/message/MessageParts.d.ts +199 -185
  243. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  244. package/dist/react/primitives/message/MessageParts.js +124 -82
  245. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  246. package/dist/react/primitives/message/MessageQuote.d.ts +6 -8
  247. package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
  248. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +2 -4
  249. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
  250. package/dist/react/primitives/part/PartMessages.d.ts +13 -15
  251. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  252. package/dist/react/primitives/thread/ThreadMessages.d.ts +54 -56
  253. package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
  254. package/dist/react/primitives/thread/ThreadSuggestions.d.ts +20 -21
  255. package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
  256. package/dist/react/primitives/thread/ThreadSuggestions.js +24 -5
  257. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  258. package/dist/react/primitives/threadList/ThreadListItems.d.ts +22 -23
  259. package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  260. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +4 -6
  261. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
  262. package/dist/react/providers/AttachmentByIndexProvider.d.ts +3 -5
  263. package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
  264. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +3 -5
  265. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
  266. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +2 -4
  267. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
  268. package/dist/react/providers/MessageByIdProvider.d.ts +2 -4
  269. package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
  270. package/dist/react/providers/MessageByIndexProvider.d.ts +2 -4
  271. package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
  272. package/dist/react/providers/PartByIndexProvider.d.ts +2 -4
  273. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
  274. package/dist/react/providers/QueueItemByIndexProvider.d.ts +2 -4
  275. package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
  276. package/dist/react/providers/ReadonlyThreadProvider.d.ts +5 -7
  277. package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
  278. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  279. package/dist/react/providers/SuggestionByIndexProvider.d.ts +2 -4
  280. package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
  281. package/dist/react/providers/TextMessagePartProvider.d.ts +3 -5
  282. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  283. package/dist/react/providers/TextMessagePartProvider.js +5 -1
  284. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  285. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +3 -5
  286. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
  287. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +3 -6
  288. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
  289. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +209 -219
  290. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  291. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +53 -39
  292. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  293. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +185 -196
  294. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  295. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +13 -4
  296. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  297. package/dist/react/runtimes/RemoteThreadResource.d.ts +14 -19
  298. package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
  299. package/dist/react/runtimes/RemoteThreadResource.js +3 -1
  300. package/dist/react/runtimes/RemoteThreadResource.js.map +1 -1
  301. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +8 -9
  302. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
  303. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +9 -11
  304. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
  305. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +4 -5
  306. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
  307. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js +9 -2
  308. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.js.map +1 -1
  309. package/dist/react/runtimes/assistant-transport/runManager.d.ts +7 -9
  310. package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
  311. package/dist/react/runtimes/assistant-transport/runManager.js +4 -1
  312. package/dist/react/runtimes/assistant-transport/runManager.js.map +1 -1
  313. package/dist/react/runtimes/assistant-transport/types.d.ts +106 -100
  314. package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
  315. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +3 -5
  316. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
  317. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js +17 -6
  318. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.js.map +1 -1
  319. package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +2 -4
  320. package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
  321. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +1 -3
  322. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
  323. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +5 -7
  324. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  325. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +410 -213
  326. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  327. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +14 -16
  328. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
  329. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +8 -4
  330. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  331. package/dist/react/runtimes/cloud/auiV0.d.ts +136 -123
  332. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  333. package/dist/react/runtimes/cloud/auiV0.js +60 -9
  334. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  335. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +9 -10
  336. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
  337. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +4 -5
  338. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
  339. package/dist/react/runtimes/cloud/sdkIdentity.d.ts +1 -3
  340. package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -1
  341. package/dist/react/runtimes/cloud/sdkIdentity.js +1 -1
  342. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +2 -4
  343. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  344. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +8 -9
  345. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  346. package/dist/react/runtimes/createMessageConverter.d.ts +14 -17
  347. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  348. package/dist/react/runtimes/createMessageConverter.js.map +1 -1
  349. package/dist/react/runtimes/createRuntimeExtras.d.ts +11 -13
  350. package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
  351. package/dist/react/runtimes/external-message-converter.d.ts +14 -18
  352. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  353. package/dist/react/runtimes/external-store-history-copy.d.ts +25 -0
  354. package/dist/react/runtimes/external-store-history-copy.d.ts.map +1 -0
  355. package/dist/react/runtimes/external-store-history-copy.js +148 -0
  356. package/dist/react/runtimes/external-store-history-copy.js.map +1 -0
  357. package/dist/react/runtimes/useExternalStoreRuntime.d.ts +2 -4
  358. package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
  359. package/dist/react/runtimes/useExternalStoreRuntime.js +72 -35
  360. package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
  361. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +1 -3
  362. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
  363. package/dist/react/runtimes/useLocalRuntime.d.ts +26 -37
  364. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  365. package/dist/react/runtimes/useLocalRuntime.js +142 -34
  366. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  367. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +2 -4
  368. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
  369. package/dist/react/runtimes/useRuntimeAdapters.d.ts +1 -3
  370. package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
  371. package/dist/react/runtimes/useStreamingTiming.d.ts +3 -5
  372. package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
  373. package/dist/react/types/MessagePartComponentTypes.d.ts +46 -43
  374. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
  375. package/dist/react/types/scopes/dataRenderers.d.ts +8 -11
  376. package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
  377. package/dist/react/types/scopes/interactables.d.ts +50 -49
  378. package/dist/react/types/scopes/interactables.d.ts.map +1 -1
  379. package/dist/react/types/scopes/tools.d.ts +17 -19
  380. package/dist/react/types/scopes/tools.d.ts.map +1 -1
  381. package/dist/react/types/store-augmentation.d.ts +10 -11
  382. package/dist/react/types/store-augmentation.d.ts.map +1 -1
  383. package/dist/react/utils/getMessageQuote.d.ts +5 -6
  384. package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
  385. package/dist/react/utils/groupParts.d.ts +28 -29
  386. package/dist/react/utils/groupParts.d.ts.map +1 -1
  387. package/dist/react/utils/useJSONEqual.d.ts +1 -3
  388. package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
  389. package/dist/react/utils/useJSONSchemaDependency.d.ts +2 -4
  390. package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -1
  391. package/dist/runtime/api/assistant-runtime.d.ts +26 -28
  392. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  393. package/dist/runtime/api/attachment-runtime.d.ts +46 -43
  394. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  395. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  396. package/dist/runtime/api/bindings.d.ts +31 -30
  397. package/dist/runtime/api/bindings.d.ts.map +1 -1
  398. package/dist/runtime/api/composer-runtime.d.ts +207 -193
  399. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  400. package/dist/runtime/api/composer-runtime.js +4 -0
  401. package/dist/runtime/api/composer-runtime.js.map +1 -1
  402. package/dist/runtime/api/message-part-runtime.d.ts +28 -26
  403. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  404. package/dist/runtime/api/message-part-runtime.js +22 -0
  405. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  406. package/dist/runtime/api/message-runtime.d.ts +87 -84
  407. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  408. package/dist/runtime/api/message-runtime.js +1 -1
  409. package/dist/runtime/api/message-runtime.js.map +1 -1
  410. package/dist/runtime/api/paths.d.ts +48 -50
  411. package/dist/runtime/api/paths.d.ts.map +1 -1
  412. package/dist/runtime/api/thread-list-item-runtime.d.ts +64 -66
  413. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  414. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  415. package/dist/runtime/api/thread-list-runtime.d.ts +73 -76
  416. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  417. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  418. package/dist/runtime/api/thread-runtime.d.ts +299 -300
  419. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  420. package/dist/runtime/api/thread-runtime.js +2 -1
  421. package/dist/runtime/api/thread-runtime.js.map +1 -1
  422. package/dist/runtime/base/base-assistant-runtime-core.d.ts +8 -10
  423. package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
  424. package/dist/runtime/base/base-composer-runtime-core.d.ts +149 -99
  425. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  426. package/dist/runtime/base/base-composer-runtime-core.js +400 -122
  427. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  428. package/dist/runtime/base/base-thread-runtime-core.d.ts +120 -108
  429. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  430. package/dist/runtime/base/base-thread-runtime-core.js +109 -41
  431. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  432. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +29 -29
  433. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  434. package/dist/runtime/base/default-edit-composer-runtime-core.js +10 -1
  435. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  436. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +27 -29
  437. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  438. package/dist/runtime/base/default-thread-composer-runtime-core.js +21 -6
  439. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  440. package/dist/runtime/branch/external-thread-branch-adapter.d.ts +14 -16
  441. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
  442. package/dist/runtime/interfaces/assistant-runtime-core.d.ts +7 -9
  443. package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
  444. package/dist/runtime/interfaces/composer-runtime-core.d.ts +88 -72
  445. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  446. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +63 -65
  447. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  448. package/dist/runtime/interfaces/thread-runtime-core.d.ts +210 -197
  449. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  450. package/dist/runtime/internal.d.ts +25 -20
  451. package/dist/runtime/internal.d.ts.map +1 -0
  452. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +35 -37
  453. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
  454. package/dist/runtime/queue/message-queue.d.ts +29 -31
  455. package/dist/runtime/queue/message-queue.d.ts.map +1 -1
  456. package/dist/runtime/queue/message-queue.js +1 -1
  457. package/dist/runtime/queue/queue-item.d.ts +5 -7
  458. package/dist/runtime/queue/queue-item.d.ts.map +1 -1
  459. package/dist/runtime/utils/abortable-thread-load.d.ts +7 -8
  460. package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
  461. package/dist/runtime/utils/attachment-add-operations.d.ts +13 -11
  462. package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
  463. package/dist/runtime/utils/attachment-add-operations.js +24 -2
  464. package/dist/runtime/utils/attachment-add-operations.js.map +1 -1
  465. package/dist/runtime/utils/attachment-send-operations.d.ts +12 -0
  466. package/dist/runtime/utils/attachment-send-operations.d.ts.map +1 -0
  467. package/dist/runtime/utils/attachment-send-operations.js +34 -0
  468. package/dist/runtime/utils/attachment-send-operations.js.map +1 -0
  469. package/dist/runtime/utils/auto-status.d.ts +4 -5
  470. package/dist/runtime/utils/auto-status.d.ts.map +1 -1
  471. package/dist/runtime/utils/auto-status.js +3 -5
  472. package/dist/runtime/utils/auto-status.js.map +1 -1
  473. package/dist/runtime/utils/chat-model-adapter.d.ts +26 -27
  474. package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
  475. package/dist/runtime/utils/external-message-conversion.d.ts +32 -32
  476. package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
  477. package/dist/runtime/utils/external-message-conversion.js +3 -3
  478. package/dist/runtime/utils/external-message-conversion.js.map +1 -1
  479. package/dist/runtime/utils/external-store-message.d.ts +2 -4
  480. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  481. package/dist/runtime/utils/message-repository-session.d.ts +21 -23
  482. package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
  483. package/dist/runtime/utils/message-repository.d.ts +50 -51
  484. package/dist/runtime/utils/message-repository.d.ts.map +1 -1
  485. package/dist/runtime/utils/message-repository.js +8 -7
  486. package/dist/runtime/utils/message-repository.js.map +1 -1
  487. package/dist/runtime/utils/pending-tool-calls.d.ts +10 -11
  488. package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
  489. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +6 -8
  490. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
  491. package/dist/runtime/utils/runtime-extras-brand.d.ts +4 -6
  492. package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
  493. package/dist/runtime/utils/stored-message-parts.d.ts +5 -5
  494. package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -1
  495. package/dist/runtime/utils/stored-message-parts.js +22 -2
  496. package/dist/runtime/utils/stored-message-parts.js.map +1 -1
  497. package/dist/runtime/utils/streaming-timing.d.ts +19 -21
  498. package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
  499. package/dist/runtime/utils/thread-message-like.d.ts +36 -32
  500. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  501. package/dist/runtime/utils/thread-message-like.js +16 -6
  502. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  503. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +4 -5
  504. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
  505. package/dist/runtime/utils/thread-runtime-lifecycle.js +31 -4
  506. package/dist/runtime/utils/thread-runtime-lifecycle.js.map +1 -1
  507. package/dist/runtime/utils/tool-call-tree.d.ts +6 -8
  508. package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
  509. package/dist/runtime/utils/tool-interactions.d.ts +10 -0
  510. package/dist/runtime/utils/tool-interactions.d.ts.map +1 -0
  511. package/dist/runtime/utils/tool-interactions.js +92 -0
  512. package/dist/runtime/utils/tool-interactions.js.map +1 -0
  513. package/dist/runtimes/assistant-transport/utils.d.ts +0 -2
  514. package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
  515. package/dist/runtimes/external-store/external-store-adapter.d.ts +215 -198
  516. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  517. package/dist/runtimes/external-store/external-store-runtime-core.d.ts +5 -6
  518. package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
  519. package/dist/runtimes/external-store/external-store-runtime-core.js +4 -1
  520. package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
  521. package/dist/runtimes/external-store/external-store-shared-options.d.ts +1 -3
  522. package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
  523. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +38 -40
  524. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  525. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +2 -2
  526. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  527. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +117 -124
  528. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  529. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +44 -14
  530. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  531. package/dist/runtimes/external-store/thread-message-converter.d.ts +3 -5
  532. package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
  533. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +94 -95
  534. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
  535. package/dist/runtimes/inert/InertThreadRuntimeCore.js +3 -0
  536. package/dist/runtimes/inert/InertThreadRuntimeCore.js.map +1 -1
  537. package/dist/runtimes/internal.d.ts +20 -16
  538. package/dist/runtimes/internal.d.ts.map +1 -0
  539. package/dist/runtimes/local/local-runtime-core.d.ts +6 -8
  540. package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
  541. package/dist/runtimes/local/local-runtime-options.d.ts +40 -42
  542. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  543. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +40 -42
  544. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
  545. package/dist/runtimes/local/local-thread-runtime-core.d.ts +93 -97
  546. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  547. package/dist/runtimes/local/local-thread-runtime-core.js +178 -31
  548. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  549. package/dist/runtimes/local/should-continue.d.ts +1 -3
  550. package/dist/runtimes/local/should-continue.d.ts.map +1 -1
  551. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +76 -53
  552. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  553. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +28 -1
  554. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  555. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +11 -13
  556. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  557. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +2 -4
  558. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
  559. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +1 -3
  560. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  561. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +33 -29
  562. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
  563. package/dist/runtimes/remote-thread-list/optimistic-state.js +8 -3
  564. package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
  565. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +44 -46
  566. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  567. package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -1
  568. package/dist/runtimes/remote-thread-list/title-generation.d.ts +25 -26
  569. package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
  570. package/dist/runtimes/remote-thread-list/title.d.ts +3 -5
  571. package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
  572. package/dist/runtimes/remote-thread-list/types.d.ts +111 -112
  573. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  574. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +144 -145
  575. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
  576. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +22 -7
  577. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  578. package/dist/store/clients/chain-of-thought-client.d.ts +7 -9
  579. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  580. package/dist/store/clients/external-thread.d.ts +53 -54
  581. package/dist/store/clients/external-thread.d.ts.map +1 -1
  582. package/dist/store/clients/external-thread.js +1256 -731
  583. package/dist/store/clients/external-thread.js.map +1 -1
  584. package/dist/store/clients/model-context-client.d.ts +1 -3
  585. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  586. package/dist/store/clients/no-op-composer-client.d.ts +2 -4
  587. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  588. package/dist/store/clients/no-op-composer-client.js +3 -1
  589. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  590. package/dist/store/clients/runtime-adapter.d.ts +1 -3
  591. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  592. package/dist/store/clients/single-thread-list.d.ts +3 -4
  593. package/dist/store/clients/single-thread-list.d.ts.map +1 -1
  594. package/dist/store/clients/submission-message.d.ts +8 -0
  595. package/dist/store/clients/submission-message.d.ts.map +1 -0
  596. package/dist/store/clients/submission-message.js +22 -0
  597. package/dist/store/clients/submission-message.js.map +1 -0
  598. package/dist/store/clients/suggestions.d.ts +5 -7
  599. package/dist/store/clients/suggestions.d.ts.map +1 -1
  600. package/dist/store/clients/thread-message-client.d.ts +10 -9
  601. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  602. package/dist/store/clients/thread-message-client.js +81 -82
  603. package/dist/store/clients/thread-message-client.js.map +1 -1
  604. package/dist/store/clients/thread-selection-events.d.ts +0 -2
  605. package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
  606. package/dist/store/clients/thread-tasks.d.ts +4 -6
  607. package/dist/store/clients/thread-tasks.d.ts.map +1 -1
  608. package/dist/store/env.d.ts +0 -2
  609. package/dist/store/env.d.ts.map +1 -1
  610. package/dist/store/index.d.ts +33 -36
  611. package/dist/store/index.d.ts.map +1 -0
  612. package/dist/store/index.js +5 -5
  613. package/dist/store/internal.d.ts +12 -12
  614. package/dist/store/internal.d.ts.map +1 -0
  615. package/dist/store/internal.js +2 -2
  616. package/dist/store/primitive-predicates.d.ts +3 -4
  617. package/dist/store/primitive-predicates.d.ts.map +1 -1
  618. package/dist/store/primitive-predicates.js +9 -4
  619. package/dist/store/primitive-predicates.js.map +1 -1
  620. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +3 -5
  621. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  622. package/dist/store/runtime-clients/composer-runtime-client.d.ts +10 -12
  623. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  624. package/dist/store/runtime-clients/composer-runtime-client.js +65 -62
  625. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  626. package/dist/store/runtime-clients/handle-runtime-action.d.ts +0 -2
  627. package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
  628. package/dist/store/runtime-clients/handle-thread-list-action.d.ts +0 -2
  629. package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
  630. package/dist/store/runtime-clients/liveRef.d.ts +1 -3
  631. package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
  632. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +3 -5
  633. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  634. package/dist/store/runtime-clients/message-part-runtime-client.js +26 -16
  635. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  636. package/dist/store/runtime-clients/message-runtime-client.d.ts +9 -9
  637. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  638. package/dist/store/runtime-clients/message-runtime-client.js +121 -113
  639. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  640. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +4 -6
  641. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  642. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +5 -7
  643. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  644. package/dist/store/runtime-clients/thread-runtime-client.d.ts +3 -5
  645. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  646. package/dist/store/runtime-clients/thread-runtime-client.js +221 -158
  647. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  648. package/dist/store/runtime-clients/useSubscribable.d.ts +2 -4
  649. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
  650. package/dist/store/scope-registration.d.ts +28 -29
  651. package/dist/store/scope-registration.d.ts.map +1 -1
  652. package/dist/store/scopes/attachment.d.ts +15 -17
  653. package/dist/store/scopes/attachment.d.ts.map +1 -1
  654. package/dist/store/scopes/chain-of-thought.d.ts +28 -29
  655. package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
  656. package/dist/store/scopes/composer.d.ts +141 -128
  657. package/dist/store/scopes/composer.d.ts.map +1 -1
  658. package/dist/store/scopes/message.d.ts +114 -107
  659. package/dist/store/scopes/message.d.ts.map +1 -1
  660. package/dist/store/scopes/model-context.d.ts +7 -9
  661. package/dist/store/scopes/model-context.d.ts.map +1 -1
  662. package/dist/store/scopes/part.d.ts +49 -45
  663. package/dist/store/scopes/part.d.ts.map +1 -1
  664. package/dist/store/scopes/queue-item.d.ts +18 -20
  665. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  666. package/dist/store/scopes/suggestion.d.ts +10 -12
  667. package/dist/store/scopes/suggestion.d.ts.map +1 -1
  668. package/dist/store/scopes/suggestions.d.ts +13 -15
  669. package/dist/store/scopes/suggestions.d.ts.map +1 -1
  670. package/dist/store/scopes/task.d.ts +23 -25
  671. package/dist/store/scopes/task.d.ts.map +1 -1
  672. package/dist/store/scopes/thread-list-item.d.ts +63 -65
  673. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  674. package/dist/store/scopes/thread.d.ts +192 -194
  675. package/dist/store/scopes/thread.d.ts.map +1 -1
  676. package/dist/store/scopes/threads.d.ts +45 -47
  677. package/dist/store/scopes/threads.d.ts.map +1 -1
  678. package/dist/subscribable/subscribable.d.ts +58 -53
  679. package/dist/subscribable/subscribable.d.ts.map +1 -1
  680. package/dist/subscribable/subscribable.js +35 -7
  681. package/dist/subscribable/subscribable.js.map +1 -1
  682. package/dist/types/attachment.d.ts +26 -27
  683. package/dist/types/attachment.d.ts.map +1 -1
  684. package/dist/types/augmentations.d.ts +4 -4
  685. package/dist/types/augmentations.d.ts.map +1 -1
  686. package/dist/types/directive.d.ts +11 -13
  687. package/dist/types/directive.d.ts.map +1 -1
  688. package/dist/types/error.d.ts +7 -8
  689. package/dist/types/error.d.ts.map +1 -1
  690. package/dist/types/index.d.ts +7 -7
  691. package/dist/types/index.d.ts.map +1 -0
  692. package/dist/types/message.d.ts +322 -284
  693. package/dist/types/message.d.ts.map +1 -1
  694. package/dist/types/message.js.map +1 -1
  695. package/dist/types/quote.d.ts +2 -4
  696. package/dist/types/quote.d.ts.map +1 -1
  697. package/dist/types/trigger.d.ts +8 -10
  698. package/dist/types/trigger.d.ts.map +1 -1
  699. package/dist/types/unsubscribe.d.ts +0 -2
  700. package/dist/types/unsubscribe.d.ts.map +1 -1
  701. package/dist/utils/abortable-iterable.d.ts +0 -2
  702. package/dist/utils/abortable-iterable.d.ts.map +1 -1
  703. package/dist/utils/composite-context-provider.d.ts +8 -11
  704. package/dist/utils/composite-context-provider.d.ts.map +1 -1
  705. package/dist/utils/data-url.d.ts +10 -12
  706. package/dist/utils/data-url.d.ts.map +1 -1
  707. package/dist/utils/getGroupStatus.d.ts +17 -18
  708. package/dist/utils/getGroupStatus.d.ts.map +1 -1
  709. package/dist/utils/id.d.ts +0 -2
  710. package/dist/utils/id.d.ts.map +1 -1
  711. package/dist/utils/image-media-type.d.ts +0 -2
  712. package/dist/utils/image-media-type.d.ts.map +1 -1
  713. package/dist/utils/invoke-user-callback.d.ts +0 -2
  714. package/dist/utils/invoke-user-callback.d.ts.map +1 -1
  715. package/dist/utils/json/is-json-equal.d.ts +0 -2
  716. package/dist/utils/json/is-json-equal.d.ts.map +1 -1
  717. package/dist/utils/json/is-json.d.ts +1 -3
  718. package/dist/utils/json/is-json.d.ts.map +1 -1
  719. package/dist/utils/json/stable-stringify-tool-args.d.ts +1 -3
  720. package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
  721. package/dist/utils/normalizePartStatus.d.ts +2 -3
  722. package/dist/utils/normalizePartStatus.d.ts.map +1 -1
  723. package/dist/utils/normalizePartStatus.js +3 -2
  724. package/dist/utils/normalizePartStatus.js.map +1 -1
  725. package/dist/utils/notify-event-listeners.d.ts +1 -2
  726. package/dist/utils/notify-event-listeners.d.ts.map +1 -1
  727. package/dist/utils/record.d.ts +0 -2
  728. package/dist/utils/record.d.ts.map +1 -1
  729. package/dist/utils/silent-runtime-action.d.ts +0 -2
  730. package/dist/utils/silent-runtime-action.d.ts.map +1 -1
  731. package/dist/utils/text.d.ts +1 -3
  732. package/dist/utils/text.d.ts.map +1 -1
  733. package/dist/utils/wire-media.d.ts +0 -2
  734. package/dist/utils/wire-media.d.ts.map +1 -1
  735. package/package.json +11 -10
  736. package/src/adapters/attachment.test.ts +98 -1
  737. package/src/adapters/attachment.ts +70 -20
  738. package/src/adapters/speech.test.ts +94 -0
  739. package/src/adapters/speech.ts +16 -2
  740. package/src/adapters/thread-history.ts +16 -5
  741. package/src/adapters/voice.test.ts +169 -0
  742. package/src/adapters/voice.ts +25 -4
  743. package/src/index.ts +14 -2
  744. package/src/internal.ts +7 -0
  745. package/src/model-context/frame/host.test.ts +51 -1
  746. package/src/model-context/frame/host.ts +3 -1
  747. package/src/model-context/frame/provider.test.ts +61 -0
  748. package/src/model-context/frame/provider.ts +8 -1
  749. package/src/model-context/frame/validate.ts +57 -0
  750. package/src/model-context/interactable-composer-metadata.test.ts +82 -0
  751. package/src/model-context/interactable-composer-metadata.ts +45 -2
  752. package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +594 -0
  753. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +98 -35
  754. package/src/react/client/Interactables.test.ts +853 -1
  755. package/src/react/client/Interactables.ts +325 -45
  756. package/src/react/client/RemoteThreadList.initialize-failure.test.ts +124 -0
  757. package/src/react/client/RemoteThreadList.ts +6 -0
  758. package/src/react/client/Tools.ts +2 -3
  759. package/src/react/client/interactable-model-context.test.ts +56 -13
  760. package/src/react/client/interactable-model-context.ts +48 -23
  761. package/src/react/index.ts +2 -2
  762. package/src/react/interactables-legacy/Interactables.test.ts +212 -1
  763. package/src/react/interactables-legacy/Interactables.ts +25 -14
  764. package/src/react/interactables-legacy/interactable-model-context.ts +26 -24
  765. package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +22 -2
  766. package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +63 -11
  767. package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +33 -0
  768. package/src/react/primitive-hooks/useSuggestionTrigger.ts +7 -4
  769. package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +124 -8
  770. package/src/react/primitives/generativeUI/GenerativeUI.tsx +35 -15
  771. package/src/react/primitives/message/MessageAttachments.test.tsx +2 -6
  772. package/src/react/primitives/message/MessageAttachments.tsx +14 -8
  773. package/src/react/primitives/message/MessageGroupedParts.test.tsx +151 -7
  774. package/src/react/primitives/message/MessageGroupedParts.tsx +19 -6
  775. package/src/react/primitives/message/MessageParts.test.tsx +84 -0
  776. package/src/react/primitives/message/MessageParts.tool-interaction.test.tsx +69 -0
  777. package/src/react/primitives/message/MessageParts.tsx +29 -8
  778. package/src/react/primitives/thread/ThreadSuggestions.test.tsx +97 -0
  779. package/src/react/primitives/thread/ThreadSuggestions.tsx +29 -6
  780. package/src/react/providers/ReadonlyThreadProvider.tsx +2 -2
  781. package/src/react/providers/TextMessagePartProvider.tsx +3 -0
  782. package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +93 -0
  783. package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +160 -3
  784. package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +38 -0
  785. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +73 -53
  786. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +19 -3
  787. package/src/react/runtimes/RemoteThreadResource.ts +5 -2
  788. package/src/react/runtimes/assistant-transport/replayBoundaryStream.test.ts +3 -1
  789. package/src/react/runtimes/assistant-transport/replayBoundaryStream.ts +10 -2
  790. package/src/react/runtimes/assistant-transport/runManager.ts +3 -0
  791. package/src/react/runtimes/assistant-transport/transport-parentid.test.tsx +57 -0
  792. package/src/react/runtimes/assistant-transport/transport-thread-id.test.tsx +571 -0
  793. package/src/react/runtimes/assistant-transport/types.ts +9 -1
  794. package/src/react/runtimes/assistant-transport/useAssistantTransport.spec.md +10 -0
  795. package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +42 -0
  796. package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +33 -9
  797. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.integration.test.tsx +289 -0
  798. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.test.tsx +471 -0
  799. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.engagement.test.tsx +330 -0
  800. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +78 -2
  801. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +361 -2
  802. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +571 -216
  803. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +25 -0
  804. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +7 -3
  805. package/src/react/runtimes/cloud/auiV0.ts +158 -9
  806. package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +352 -1
  807. package/src/react/runtimes/createMessageConverter.ts +9 -3
  808. package/src/react/runtimes/external-store-history-copy.ts +223 -0
  809. package/src/react/runtimes/useExternalStoreRuntime.history-copy.test.tsx +483 -0
  810. package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +76 -1
  811. package/src/react/runtimes/useExternalStoreRuntime.ts +25 -5
  812. package/src/react/runtimes/useLocalRuntime.test.tsx +145 -1
  813. package/src/react/runtimes/useLocalRuntime.ts +8 -5
  814. package/src/react/types/MessagePartComponentTypes.ts +10 -0
  815. package/src/react/types/scopes/interactables.ts +3 -0
  816. package/src/runtime/api/attachment-runtime.ts +10 -5
  817. package/src/runtime/api/bindings.ts +6 -1
  818. package/src/runtime/api/composer-runtime.ts +29 -6
  819. package/src/runtime/api/message-part-runtime.test.ts +215 -0
  820. package/src/runtime/api/message-part-runtime.ts +40 -0
  821. package/src/runtime/api/message-runtime.test.ts +112 -2
  822. package/src/runtime/api/message-runtime.ts +10 -5
  823. package/src/runtime/api/thread-list-item-runtime.ts +5 -5
  824. package/src/runtime/api/thread-list-runtime.ts +3 -3
  825. package/src/runtime/api/thread-runtime.test.ts +59 -0
  826. package/src/runtime/api/thread-runtime.ts +21 -11
  827. package/src/runtime/base/base-composer-runtime-core.ts +548 -153
  828. package/src/runtime/base/base-thread-runtime-core.test.ts +744 -9
  829. package/src/runtime/base/base-thread-runtime-core.ts +154 -27
  830. package/src/runtime/base/default-edit-composer-runtime-core.ts +13 -1
  831. package/src/runtime/base/default-thread-composer-runtime-core.ts +29 -10
  832. package/src/runtime/interfaces/composer-runtime-core.ts +19 -0
  833. package/src/runtime/interfaces/thread-runtime-core.ts +22 -1
  834. package/src/runtime/utils/attachment-add-operations.ts +45 -2
  835. package/src/runtime/utils/attachment-send-operations.ts +54 -0
  836. package/src/runtime/utils/auto-status.test.ts +54 -0
  837. package/src/runtime/utils/auto-status.ts +3 -10
  838. package/src/runtime/utils/external-message-conversion.test.ts +48 -0
  839. package/src/runtime/utils/external-message-conversion.ts +3 -4
  840. package/src/runtime/utils/message-repository.test.ts +69 -1
  841. package/src/runtime/utils/message-repository.ts +14 -7
  842. package/src/runtime/utils/stored-message-parts.ts +43 -1
  843. package/src/runtime/utils/thread-message-like.test.ts +58 -0
  844. package/src/runtime/utils/thread-message-like.ts +72 -46
  845. package/src/runtime/utils/thread-runtime-lifecycle.test.ts +67 -0
  846. package/src/runtime/utils/thread-runtime-lifecycle.ts +42 -8
  847. package/src/runtime/utils/tool-interactions.test.ts +193 -0
  848. package/src/runtime/utils/tool-interactions.ts +147 -0
  849. package/src/runtimes/external-store/external-store-adapter.ts +22 -1
  850. package/src/runtimes/external-store/external-store-runtime-core.ts +10 -2
  851. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +2 -2
  852. package/src/runtimes/external-store/external-store-thread-runtime-core.test.ts +49 -0
  853. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +76 -29
  854. package/src/runtimes/inert/InertThreadRuntimeCore.test.ts +127 -56
  855. package/src/runtimes/inert/InertThreadRuntimeCore.ts +10 -1
  856. package/src/runtimes/local/local-thread-runtime-core.edit-cancellation.test.ts +70 -0
  857. package/src/runtimes/local/local-thread-runtime-core.test.ts +1649 -108
  858. package/src/runtimes/local/local-thread-runtime-core.ts +301 -47
  859. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +53 -1
  860. package/src/runtimes/remote-thread-list/optimistic-state.ts +8 -3
  861. package/src/runtimes/tool-invocations/EDGE_CASES.md +19 -4
  862. package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +392 -39
  863. package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +31 -8
  864. package/src/store/clients/external-thread.test.ts +145 -0
  865. package/src/store/clients/external-thread.ts +635 -131
  866. package/src/store/clients/model-context-client.test.ts +8 -8
  867. package/src/store/clients/no-op-composer-client.ts +2 -0
  868. package/src/store/clients/submission-message.ts +27 -0
  869. package/src/store/clients/thread-message-client.test.ts +39 -0
  870. package/src/store/clients/thread-message-client.ts +13 -6
  871. package/src/store/index.ts +2 -2
  872. package/src/store/internal.ts +1 -0
  873. package/src/store/primitive-predicates.test.ts +103 -0
  874. package/src/store/primitive-predicates.ts +15 -3
  875. package/src/store/runtime-clients/composer-runtime-client.ts +4 -3
  876. package/src/store/runtime-clients/message-part-runtime-client.test.ts +42 -0
  877. package/src/store/runtime-clients/message-part-runtime-client.ts +4 -0
  878. package/src/store/runtime-clients/message-runtime-client.ts +5 -0
  879. package/src/store/runtime-clients/thread-runtime-client.test.tsx +138 -5
  880. package/src/store/runtime-clients/thread-runtime-client.ts +46 -9
  881. package/src/store/scopes/composer.ts +22 -4
  882. package/src/store/scopes/message.ts +8 -0
  883. package/src/store/scopes/part.ts +8 -0
  884. package/src/subscribable/subscribable.test.ts +198 -1
  885. package/src/subscribable/subscribable.ts +49 -7
  886. package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +95 -1
  887. package/src/tests/auiV0Encode.test.ts +408 -1
  888. package/src/tests/base-composer-runtime-core-send.test.ts +722 -29
  889. package/src/tests/base-composer-runtime-core.test.ts +196 -0
  890. package/src/tests/composer-can-send.test.ts +98 -1
  891. package/src/tests/composer-submission.test.tsx +796 -0
  892. package/src/tests/default-edit-composer-runtime-core.test.ts +102 -2
  893. package/src/tests/external-store-thread-list-runtime-core.test.ts +111 -0
  894. package/src/tests/external-store-thread-runtime-core-adapter.test.ts +581 -1
  895. package/src/tests/external-store-thread-runtime-core.test.ts +186 -0
  896. package/src/tests/external-thread-attachments.test.tsx +741 -3
  897. package/src/tests/external-thread-isLast.test.tsx +69 -0
  898. package/src/tests/get-thread-state-isRunning.test.ts +2 -2
  899. package/src/tests/remote-thread-list-adapter-switch.test.ts +45 -1
  900. package/src/types/message.ts +49 -2
  901. package/src/utils/normalizePartStatus.ts +14 -1
  902. package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -15
  903. package/dist/tests/remote-thread-list-test-helpers.d.ts.map +0 -1
  904. package/dist/tests/remote-thread-list-test-helpers.js +0 -59
  905. package/dist/tests/remote-thread-list-test-helpers.js.map +0 -1
@@ -1,9 +1,11 @@
1
- import { gateInteractableComposerMetadata } from "../../model-context/interactable-composer-metadata.js";
2
- import { notifyEventListeners } from "../../utils/notify-event-listeners.js";
3
- import { BaseSubscribable, notifySubscribers } from "../../subscribable/subscribable.js";
4
1
  import { generateId } from "../../utils/id.js";
2
+ import { notifyEventListeners } from "../../utils/notify-event-listeners.js";
5
3
  import { getThreadMessageText } from "../../utils/text.js";
4
+ import { gateInteractableComposerMetadata } from "../../model-context/interactable-composer-metadata.js";
5
+ import { BaseSubscribable, notifySubscribers } from "../../subscribable/subscribable.js";
6
+ import { MessageNotSentError } from "../../types/error.js";
6
7
  import { ExportedMessageRepository, MessageRepository } from "../utils/message-repository.js";
8
+ import { captureThreadRuntimeGeneration } from "../utils/thread-runtime-lifecycle.js";
7
9
  import { DefaultThreadComposerRuntimeCore } from "./default-thread-composer-runtime-core.js";
8
10
  import { DefaultEditComposerRuntimeCore } from "./default-edit-composer-runtime-core.js";
9
11
  //#region src/runtime/base/base-thread-runtime-core.ts
@@ -23,6 +25,14 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
23
25
  return this.repository.getMessages();
24
26
  }
25
27
  _commitVoiceMessage(_message) {}
28
+ _onMessageMetadataChanged(_previousMessage, _message) {}
29
+ _dropVoiceMessage(messageId, notify) {
30
+ const index = this._voiceMessages.findIndex((voiceMessage) => voiceMessage.id === messageId);
31
+ if (index === -1) return;
32
+ this._voiceMessages.splice(index, 1);
33
+ this._markVoiceMessagesDirty();
34
+ if (notify) this._notifySubscribers();
35
+ }
26
36
  get messages() {
27
37
  if (this._voiceMessages.length === 0) return this._getBaseMessages();
28
38
  const base = this._getBaseMessages();
@@ -153,8 +163,10 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
153
163
  }
154
164
  };
155
165
  const voiceIdx = this._voiceMessages.findIndex((voiceMessage) => voiceMessage.id === messageId);
156
- if (voiceIdx === -1) this.repository.addOrUpdateMessage(parentId, updatedMessage);
157
- else {
166
+ if (voiceIdx === -1) {
167
+ this.repository.addOrUpdateMessage(parentId, updatedMessage);
168
+ this._onMessageMetadataChanged(message, updatedMessage);
169
+ } else {
158
170
  this._voiceMessages[voiceIdx] = updatedMessage;
159
171
  if (this._currentAssistantMsg === message) this._currentAssistantMsg = updatedMessage;
160
172
  this._markVoiceMessagesDirty();
@@ -243,11 +255,41 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
243
255
  };
244
256
  _onVoiceConnected() {}
245
257
  _onVoiceDisconnected() {}
258
+ _toVoiceSessionState(session, status, mode) {
259
+ return {
260
+ status,
261
+ isMuted: session.isMuted,
262
+ mode,
263
+ canSendText: status.type === "running" && session.sendText !== void 0
264
+ };
265
+ }
246
266
  _isRunActive() {
247
267
  if (this.isRunning) return true;
248
268
  const last = this._getBaseMessages().at(-1);
249
269
  return last?.role === "assistant" && (last.status.type === "running" || last.status.type === "requires-action");
250
270
  }
271
+ /**
272
+ * Waits for a pending history import before a voice message is committed.
273
+ * The import may begin before or after the voice session connects, so the
274
+ * loading state must be rechecked when the commit is ready to run. The wait
275
+ * also ends when the runtime is invalidated, since a superseded runtime may
276
+ * never learn that loading ended.
277
+ */
278
+ _getVoiceCommitBarrier() {
279
+ if (!this.isLoading) return void 0;
280
+ const generation = captureThreadRuntimeGeneration(this);
281
+ return (async () => {
282
+ while (this.isLoading && !generation.aborted) await new Promise((resolve) => {
283
+ const wake = () => {
284
+ unsubscribe();
285
+ generation.removeEventListener("abort", wake);
286
+ resolve();
287
+ };
288
+ const unsubscribe = this.subscribe(wake);
289
+ generation.addEventListener("abort", wake);
290
+ });
291
+ })();
292
+ }
251
293
  connectVoice() {
252
294
  const adapter = this.adapters?.voice;
253
295
  if (!adapter) throw new Error("Voice adapter not configured");
@@ -279,11 +321,7 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
279
321
  };
280
322
  try {
281
323
  let currentMode = "listening";
282
- this.voice = {
283
- status: session.status,
284
- isMuted: session.isMuted,
285
- mode: currentMode
286
- };
324
+ this.voice = this._toVoiceSessionState(session, session.status, currentMode);
287
325
  this._voiceVolume = 0;
288
326
  this._notifySubscribers();
289
327
  if (finishDetachedSetup()) return;
@@ -294,15 +332,12 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
294
332
  this._voiceSession = void 0;
295
333
  this.voice = void 0;
296
334
  this._onVoiceDisconnected();
297
- } else this.voice = {
298
- status,
299
- isMuted: session.isMuted,
300
- mode: currentMode
301
- };
335
+ } else this.voice = this._toVoiceSessionState(session, status, currentMode);
302
336
  this._notifySubscribers();
303
337
  }));
304
338
  if (finishDetachedSetup()) return;
305
339
  unsubs.push(session.onModeChange((mode) => {
340
+ if (this._voiceSession !== session) return;
306
341
  currentMode = mode;
307
342
  if (this.voice) {
308
343
  this.voice = {
@@ -314,11 +349,13 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
314
349
  }));
315
350
  if (finishDetachedSetup()) return;
316
351
  unsubs.push(session.onVolumeChange((volume) => {
352
+ if (this._voiceSession !== session) return;
317
353
  this._voiceVolume = volume;
318
354
  notifyEventListeners(this._voiceVolumeSubscribers, void 0, "Voice volume");
319
355
  }));
320
356
  if (finishDetachedSetup()) return;
321
357
  unsubs.push(session.onTranscript((transcript) => {
358
+ if (this._voiceSession !== session) return;
322
359
  this._handleVoiceTranscript(transcript);
323
360
  }));
324
361
  if (!finishDetachedSetup()) this._onVoiceConnected();
@@ -335,35 +372,30 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
335
372
  }
336
373
  }
337
374
  _currentAssistantMsg = null;
375
+ _observeVoiceCommit(commit) {
376
+ Promise.resolve(commit).catch((error) => {
377
+ console.error("[assistant-ui] Voice message commit failed", error);
378
+ });
379
+ }
338
380
  _handleVoiceTranscript(transcript) {
339
381
  this.ensureInitialized();
340
382
  if (transcript.role === "user") {
341
383
  this._finishVoiceAssistantMessage();
342
384
  this._currentAssistantMsg = null;
343
- if (transcript.isFinal) {
344
- const message = {
345
- id: generateId(),
346
- role: "user",
347
- content: [{
348
- type: "text",
349
- text: transcript.text
350
- }],
351
- metadata: {
352
- modality: "voice",
353
- custom: {}
354
- },
355
- createdAt: /* @__PURE__ */ new Date(),
356
- status: {
357
- type: "complete",
358
- reason: "unknown"
359
- },
360
- attachments: []
361
- };
362
- this._voiceMessages.push(message);
363
- this._commitVoiceMessage(message);
364
- this._markVoiceMessagesDirty();
365
- this._notifySubscribers();
366
- }
385
+ if (transcript.isFinal) this._observeVoiceCommit(this._commitVoiceUserMessage({
386
+ id: generateId(),
387
+ role: "user",
388
+ content: [{
389
+ type: "text",
390
+ text: transcript.text
391
+ }],
392
+ metadata: {
393
+ modality: "voice",
394
+ custom: {}
395
+ },
396
+ createdAt: /* @__PURE__ */ new Date(),
397
+ attachments: []
398
+ }));
367
399
  } else {
368
400
  const status = transcript.isFinal ? {
369
401
  type: "complete",
@@ -404,13 +436,49 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
404
436
  this._currentAssistantMsg = updated;
405
437
  }
406
438
  if (transcript.isFinal) {
407
- this._commitVoiceMessage(this._currentAssistantMsg);
439
+ this._observeVoiceCommit(this._commitVoiceMessage(this._currentAssistantMsg));
408
440
  this._currentAssistantMsg = null;
409
441
  }
410
442
  this._markVoiceMessagesDirty();
411
443
  this._notifySubscribers();
412
444
  }
413
445
  }
446
+ _commitVoiceUserMessage(message) {
447
+ this._voiceMessages.push(message);
448
+ const committed = this._commitVoiceMessage(message);
449
+ this._markVoiceMessagesDirty();
450
+ this._notifySubscribers();
451
+ return committed;
452
+ }
453
+ async _appendToVoiceSession(message) {
454
+ const session = this._voiceSession;
455
+ if (!this.voice?.canSendText || !session?.sendText) throw new Error("Cannot send a text message while a voice session is connected");
456
+ const content = message.content.filter((part) => part.type === "text");
457
+ if (message.role !== "user" || message.sourceId != null || message.parentId !== this._resolveAppendParent(this.messages.at(-1)?.id ?? null) || message.attachments?.length || content.length !== message.content.length || !content.some((part) => part.text.trim())) throw new Error("Only a plain text user message can be sent while a voice session is connected");
458
+ const enriched = this.enrichAppendMetadata(message);
459
+ this.ensureInitialized();
460
+ const generation = captureThreadRuntimeGeneration(this);
461
+ try {
462
+ await session.sendText(getThreadMessageText(message));
463
+ } catch (error) {
464
+ if (generation.aborted) return;
465
+ const notSent = new MessageNotSentError();
466
+ notSent.cause = error;
467
+ throw notSent;
468
+ }
469
+ if (generation.aborted) return;
470
+ if (this._voiceSession !== session) throw new MessageNotSentError("The voice session ended before the typed message was recorded");
471
+ this._finishVoiceAssistantMessage(false);
472
+ this._currentAssistantMsg = null;
473
+ await this._commitVoiceUserMessage({
474
+ id: generateId(),
475
+ role: "user",
476
+ content,
477
+ metadata: { custom: { ...enriched.metadata?.custom } },
478
+ createdAt: message.createdAt,
479
+ attachments: []
480
+ });
481
+ }
414
482
  _finishVoiceAssistantMessage(notify = true) {
415
483
  const last = this._voiceMessages.at(-1);
416
484
  if (last?.role === "assistant" && last.status.type === "running") {
@@ -422,7 +490,7 @@ var BaseThreadRuntimeCore = class extends BaseSubscribable {
422
490
  reason: "stop"
423
491
  }
424
492
  };
425
- this._commitVoiceMessage(this._voiceMessages[idx]);
493
+ this._observeVoiceCommit(this._commitVoiceMessage(this._voiceMessages[idx]));
426
494
  this._currentAssistantMsg = null;
427
495
  this._markVoiceMessagesDirty();
428
496
  if (notify) this._notifySubscribers();
@@ -1 +1 @@
1
- {"version":3,"file":"base-thread-runtime-core.js","names":["AppendMessage","ThreadAssistantMessage","ThreadMessage","Unsubscribe","ModelContextProvider","getThreadMessageText","generateId","ExportedMessageRepository","MessageRepository","DefaultThreadComposerRuntimeCore","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","ThreadSuggestion","SubmitFeedbackOptions","ThreadRuntimeCore","SpeechState","VoiceSessionState","RuntimeCapabilities","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","DefaultEditComposerRuntimeCore","SpeechSynthesisAdapter","FeedbackAdapter","AttachmentAdapter","RealtimeVoiceAdapter","ThreadMessageLike","notifyEventListeners","gateInteractableComposerMetadata","BaseSubscribable","notifySubscribers","BaseThreadAdapters","speech","feedback","attachments","voice","BaseThreadRuntimeCore","_isInitialized","repository","adapters","isDisabled","isSendDisabled","isLoading","suggestions","extras","capabilities","append","message","deleteMessage","messageId","Promise","startRun","config","resumeRun","addToolResult","options","resumeToolCall","respondToToolApproval","cancelRun","exportExternalState","importExternalState","state","unstable_notifySessionReset","_voiceMessages","_voiceGeneration","_cachedMergedMessages","_cachedVoiceGeneration","_cachedMergedBase","_markVoiceMessagesDirty","_getBaseMessages","getMessages","_commitVoiceMessage","_message","messages","length","base","baseMessageIds","Set","map","id","filter","has","mostRecentAssistantMessage","this","role","metadata","unstable_state","composer","_contextProvider","constructor","getModelContext","enrichAppendMetadata","anchorId","parentId","parentIndex","findIndex","m","composerMetadata","unstable_composerMetadata","slice","custom","_editComposers","Map","getEditComposer","get","_isVoiceMessage","some","_resolveAppendParent","at","beginEdit","Error","set","delete","getMessage","_notifySubscribers","getMessageById","baseMessages","voiceIdx","index","undefined","getBranches","switchToBranch","branchId","_notifyEventSubscribers","event","E","payload","subscribers","_eventSubscribers","_notifyToolApprovalAnswered","toolCallId","toolName","approved","submitFeedback","type","comment","adapter","entry","trimmed","trim","submit","updatedMessage","submittedFeedback","voiceMessage","addOrUpdateMessage","_currentAssistantMsg","_stopSpeaking","speak","previousStop","utterance","Utterance","error","notificationError","console","unsub","clear","cleanup","stop","cancel","update","status","subscribe","cleanupError","stopSpeaking","_voiceSession","Session","_voiceUnsubs","Array","_voiceVolume","_voiceVolumeSubscribers","getVoiceVolume","subscribeVoiceVolume","callback","add","_onVoiceConnected","_onVoiceDisconnected","_isRunActive","runtime","isRunning","last","connectVoice","replacing","_disconnectVoice","session","connect","unsubs","finishDetachedSetup","splice","currentMode","Mode","isMuted","mode","push","onStatusChange","_finishVoiceAssistantMessage","onModeChange","onVolumeChange","volume","onTranscript","transcript","_handleVoiceTranscript","TranscriptItem","ensureInitialized","isFinal","content","text","modality","createdAt","Date","reason","unstable_annotations","unstable_data","steps","idx","indexOf","updated","notify","disconnectVoice","fireHook","disconnect","muteVoice","mute","unmuteVoice","unmute","export","import","data","reset","initialMessages","fromArray","unstable_on","wrapped","queueMicrotask"],"sources":["../../../src/runtime/base/base-thread-runtime-core.ts"],"sourcesContent":["import type {\n AppendMessage,\n ThreadAssistantMessage,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { generateId } from \"../../utils/id\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/message-repository\";\nimport { DefaultThreadComposerRuntimeCore } from \"./default-thread-composer-runtime-core\";\nimport type {\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n VoiceSessionState,\n RuntimeCapabilities,\n ThreadRuntimeEventCallback,\n ThreadRuntimeEventPayload,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n} from \"../interfaces/thread-runtime-core\";\nimport { DefaultEditComposerRuntimeCore } from \"./default-edit-composer-runtime-core\";\nimport type { SpeechSynthesisAdapter } from \"../../adapters/speech\";\nimport type { FeedbackAdapter } from \"../../adapters/feedback\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { RealtimeVoiceAdapter } from \"../../adapters/voice\";\nimport type { ThreadMessageLike } from \"../utils/thread-message-like\";\nimport { notifyEventListeners } from \"../../utils/notify-event-listeners\";\nimport { gateInteractableComposerMetadata } from \"../../model-context/interactable-composer-metadata\";\nimport {\n BaseSubscribable,\n notifySubscribers,\n} from \"../../subscribable/subscribable\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n voice?: RealtimeVoiceAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore\n extends BaseSubscribable\n implements ThreadRuntimeCore\n{\n private _isInitialized = false;\n\n protected repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get isSendDisabled(): boolean;\n public abstract get isLoading(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract deleteMessage(messageId: string): void | Promise<void>;\n public abstract startRun(config: StartRunConfig): void;\n public abstract resumeRun(config: ResumeRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract resumeToolCall(options: ResumeToolCallOptions): void;\n public abstract respondToToolApproval(\n options: RespondToToolApprovalOptions,\n ): Promise<void>;\n public abstract cancelRun(): void;\n public abstract exportExternalState(): any;\n public abstract importExternalState(state: any): void;\n public abstract unstable_notifySessionReset(): void;\n\n protected _voiceMessages: ThreadMessage[] = [];\n protected _voiceGeneration = 0;\n private _cachedMergedMessages: readonly ThreadMessage[] | null = null;\n private _cachedVoiceGeneration = -1;\n private _cachedMergedBase: readonly ThreadMessage[] | null = null;\n\n protected _markVoiceMessagesDirty() {\n this._voiceGeneration++;\n this._cachedMergedMessages = null;\n }\n\n protected _getBaseMessages(): readonly ThreadMessage[] {\n return this.repository.getMessages();\n }\n\n protected _commitVoiceMessage(_message: ThreadMessage): void {}\n\n public get messages(): readonly ThreadMessage[] {\n if (this._voiceMessages.length === 0) {\n return this._getBaseMessages();\n }\n const base = this._getBaseMessages();\n if (\n this._cachedVoiceGeneration !== this._voiceGeneration ||\n this._cachedMergedBase !== base\n ) {\n const baseMessageIds = new Set(base.map((message) => message.id));\n this._cachedMergedMessages = [\n ...base,\n ...this._voiceMessages.filter(\n (message) => !baseMessageIds.has(message.id),\n ),\n ];\n this._cachedVoiceGeneration = this._voiceGeneration;\n this._cachedMergedBase = base;\n }\n return this._cachedMergedMessages!;\n }\n\n public get state() {\n let mostRecentAssistantMessage: (typeof this.messages)[number] | undefined;\n for (const message of this.messages) {\n if (message.role === \"assistant\") {\n mostRecentAssistantMessage = message;\n }\n }\n\n return mostRecentAssistantMessage?.metadata.unstable_state ?? null;\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n private readonly _contextProvider: ModelContextProvider;\n\n constructor(_contextProvider: ModelContextProvider) {\n super();\n this._contextProvider = _contextProvider;\n }\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n /**\n * Stamps provider-contributed composer metadata onto an outgoing message.\n * Called at dispatch rather than in the composer, so programmatic sends are\n * covered too, and exactly once per message: a queued send is stamped when\n * it leaves the lane, never when it enters.\n *\n * Only user messages are stamped, matching the readers: both the version\n * fold and the model injection skip every other role.\n *\n * @param anchorId Message the gated branch prefix ends at. A queued send\n * passes the current tail, having waited through a run that grew the prefix\n * past the parent it was created with.\n */\n protected enrichAppendMetadata(\n message: AppendMessage,\n anchorId: string | null = message.parentId,\n ): AppendMessage {\n if (message.role !== \"user\") return message;\n const messages = this.messages;\n const parentIndex =\n anchorId === null ? -1 : messages.findIndex((m) => m.id === anchorId);\n const composerMetadata = gateInteractableComposerMetadata(\n this.getModelContext().unstable_composerMetadata,\n messages.slice(0, parentIndex + 1),\n );\n if (!composerMetadata) return message;\n return {\n ...message,\n metadata: {\n ...message.metadata,\n custom: { ...message.metadata?.custom, ...composerMetadata },\n },\n };\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n protected _isVoiceMessage(messageId: string | null) {\n return (\n messageId !== null && this._voiceMessages.some((m) => m.id === messageId)\n );\n }\n\n protected _resolveAppendParent(parentId: string | null): string | null {\n return this._isVoiceMessage(parentId)\n ? (this._getBaseMessages().at(-1)?.id ?? null)\n : parentId;\n }\n\n public beginEdit(messageId: string) {\n if (this.voice)\n throw new Error(\n \"Cannot edit a message while a voice session is connected\",\n );\n if (this._isVoiceMessage(messageId)) {\n throw new Error(\"Voice transcript messages cannot be edited\");\n }\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n try {\n return this.repository.getMessage(messageId);\n } catch {\n // Check voice messages\n const baseMessages = this.repository.getMessages();\n const voiceIdx = this._voiceMessages.findIndex((m) => m.id === messageId);\n if (voiceIdx !== -1) {\n const parentId =\n voiceIdx > 0\n ? this._voiceMessages[voiceIdx - 1]!.id\n : (baseMessages.at(-1)?.id ?? null);\n return {\n parentId,\n message: this._voiceMessages[voiceIdx]!,\n index: baseMessages.length + voiceIdx,\n };\n }\n return undefined;\n }\n }\n\n public getBranches(messageId: string): string[] {\n if (this._voiceMessages.some((m) => m.id === messageId)) {\n return [];\n }\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n public _notifyEventSubscribers<E extends ThreadRuntimeEventType>(\n event: E,\n payload: ThreadRuntimeEventPayload[E],\n ) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n notifyEventListeners(subscribers, payload, `Thread runtime \"${event}\"`);\n }\n\n protected _notifyToolApprovalAnswered(\n messageId: string,\n toolCallId: string,\n toolName: string,\n approved: boolean,\n ) {\n this._notifyEventSubscribers(\"toolApprovalAnswered\", {\n messageId,\n toolCallId,\n toolName,\n approved,\n });\n }\n\n public submitFeedback({ messageId, type, comment }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message, parentId } = entry;\n const trimmed = comment?.trim();\n const feedback = { type, ...(trimmed ? { comment: trimmed } : undefined) };\n adapter?.submit({ message, ...feedback });\n\n if (message.role === \"assistant\") {\n const updatedMessage: ThreadMessage = {\n ...message,\n metadata: {\n ...message.metadata,\n submittedFeedback: feedback,\n },\n };\n const voiceIdx = this._voiceMessages.findIndex(\n (voiceMessage) => voiceMessage.id === messageId,\n );\n if (voiceIdx === -1) {\n this.repository.addOrUpdateMessage(parentId, updatedMessage);\n } else {\n this._voiceMessages[voiceIdx] = updatedMessage;\n if (this._currentAssistantMsg === message) {\n this._currentAssistantMsg = updatedMessage as ThreadAssistantMessage;\n }\n this._markVoiceMessagesDirty();\n }\n }\n\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message } = entry;\n\n const previousStop = this._stopSpeaking;\n let utterance: SpeechSynthesisAdapter.Utterance;\n try {\n previousStop?.();\n utterance = adapter.speak(getThreadMessageText(message));\n } catch (error) {\n if (previousStop && !this._stopSpeaking) {\n try {\n this._notifySubscribers();\n } catch (notificationError) {\n console.error(\n \"[assistant-ui] Speech rollback notification threw\",\n notificationError,\n );\n }\n }\n throw error;\n }\n let unsub: Unsubscribe | undefined;\n const clear = () => {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n const cleanup = unsub;\n unsub = undefined;\n cleanup?.();\n };\n const stop = () => {\n if (this._stopSpeaking !== stop) return;\n try {\n clear();\n } finally {\n utterance.cancel();\n }\n };\n const update = () => {\n if (this._stopSpeaking !== stop) return;\n if (utterance.status.type === \"ended\") {\n notifySubscribers([clear, () => this._notifySubscribers()]);\n } else {\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n }\n };\n\n this._stopSpeaking = stop;\n try {\n unsub = utterance.subscribe(update);\n if (this._stopSpeaking !== stop) {\n unsub();\n return;\n }\n update();\n } catch (error) {\n if (this._stopSpeaking === stop) {\n try {\n notifySubscribers([stop, () => this._notifySubscribers()]);\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Speech rollback cleanup threw\",\n cleanupError,\n );\n }\n }\n throw error;\n }\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n notifySubscribers([this._stopSpeaking, () => this._notifySubscribers()]);\n }\n\n private _voiceSession: RealtimeVoiceAdapter.Session | undefined;\n private _voiceUnsubs: Array<() => void> = [];\n public voice: VoiceSessionState | undefined;\n\n private _voiceVolume = 0;\n private _voiceVolumeSubscribers = new Set<() => void>();\n\n public getVoiceVolume = () => this._voiceVolume;\n\n public subscribeVoiceVolume = (callback: () => void): Unsubscribe => {\n this._voiceVolumeSubscribers.add(callback);\n return () => this._voiceVolumeSubscribers.delete(callback);\n };\n\n protected _onVoiceConnected(): void {}\n\n protected _onVoiceDisconnected(): void {}\n\n protected _isRunActive(): boolean {\n const runtime: ThreadRuntimeCore = this;\n if (runtime.isRunning) return true;\n const last = this._getBaseMessages().at(-1);\n return (\n last?.role === \"assistant\" &&\n (last.status.type === \"running\" || last.status.type === \"requires-action\")\n );\n }\n\n public connectVoice() {\n const adapter = this.adapters?.voice;\n if (!adapter) throw new Error(\"Voice adapter not configured\");\n if (this._isRunActive())\n throw new Error(\n \"Cannot start a voice session while a run is in progress or paused on a pending tool action\",\n );\n const replacing = this._voiceSession !== undefined;\n\n try {\n this._disconnectVoice(false);\n } catch (error) {\n console.error(\n \"[assistant-ui] Voice cleanup threw before reconnect\",\n error,\n );\n }\n\n let session: RealtimeVoiceAdapter.Session;\n try {\n session = adapter.connect({});\n } catch (error) {\n if (replacing && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n throw error;\n }\n this._voiceSession = session;\n const unsubs: Array<() => void> = [];\n this._voiceUnsubs = unsubs;\n\n // The cleanup-list identity preserves ownership after an ended status clears the session.\n const finishDetachedSetup = () => {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n return false;\n }\n\n try {\n notifySubscribers(unsubs.splice(0));\n } catch (error) {\n console.error(\n \"[assistant-ui] Detached voice setup cleanup threw\",\n error,\n );\n }\n return true;\n };\n\n try {\n let currentMode: RealtimeVoiceAdapter.Mode = \"listening\";\n\n this.voice = {\n status: session.status,\n isMuted: session.isMuted,\n mode: currentMode,\n };\n this._voiceVolume = 0;\n this._notifySubscribers();\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onStatusChange((status) => {\n if (this._voiceSession !== session) return;\n if (status.type === \"ended\") {\n this._finishVoiceAssistantMessage();\n this._voiceSession = undefined;\n this.voice = undefined;\n this._onVoiceDisconnected();\n } else {\n this.voice = {\n status,\n isMuted: session.isMuted,\n mode: currentMode,\n };\n }\n this._notifySubscribers();\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onModeChange((mode) => {\n currentMode = mode;\n if (this.voice) {\n this.voice = { ...this.voice, mode };\n this._notifySubscribers();\n }\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onVolumeChange((volume) => {\n this._voiceVolume = volume;\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n );\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onTranscript((transcript) => {\n this._handleVoiceTranscript(transcript);\n }),\n );\n if (!finishDetachedSetup()) this._onVoiceConnected();\n } catch (error) {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n try {\n this._disconnectVoice(false);\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Voice rollback cleanup threw\",\n cleanupError,\n );\n }\n if (replacing && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n } else {\n finishDetachedSetup();\n }\n throw error;\n }\n }\n\n private _currentAssistantMsg: ThreadAssistantMessage | null = null;\n\n private _handleVoiceTranscript(\n transcript: RealtimeVoiceAdapter.TranscriptItem,\n ) {\n this.ensureInitialized();\n\n if (transcript.role === \"user\") {\n this._finishVoiceAssistantMessage();\n this._currentAssistantMsg = null;\n\n if (transcript.isFinal) {\n const message: ThreadMessage = {\n id: generateId(),\n role: \"user\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: { modality: \"voice\", custom: {} },\n createdAt: new Date(),\n status: { type: \"complete\", reason: \"unknown\" },\n attachments: [],\n };\n this._voiceMessages.push(message);\n this._commitVoiceMessage(message);\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n } else {\n const status: ThreadAssistantMessage[\"status\"] = transcript.isFinal\n ? { type: \"complete\", reason: \"stop\" }\n : { type: \"running\" };\n\n if (!this._currentAssistantMsg) {\n this._currentAssistantMsg = {\n id: generateId(),\n role: \"assistant\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: {\n unstable_state: this.state,\n unstable_annotations: [],\n unstable_data: [],\n steps: [],\n modality: \"voice\",\n custom: {},\n },\n status,\n createdAt: new Date(),\n };\n this._voiceMessages.push(this._currentAssistantMsg);\n } else {\n const idx = this._voiceMessages.indexOf(this._currentAssistantMsg);\n if (idx === -1) return;\n const updated: ThreadAssistantMessage = {\n ...this._currentAssistantMsg,\n content: [{ type: \"text\", text: transcript.text }],\n status,\n };\n this._voiceMessages[idx] = updated;\n this._currentAssistantMsg = updated;\n }\n\n if (transcript.isFinal) {\n this._commitVoiceMessage(this._currentAssistantMsg);\n this._currentAssistantMsg = null;\n }\n\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n }\n\n private _finishVoiceAssistantMessage(notify = true) {\n const last = this._voiceMessages.at(-1);\n if (last?.role === \"assistant\" && last.status.type === \"running\") {\n const idx = this._voiceMessages.length - 1;\n this._voiceMessages[idx] = {\n ...(last as ThreadAssistantMessage),\n status: { type: \"complete\", reason: \"stop\" },\n };\n this._commitVoiceMessage(this._voiceMessages[idx]!);\n this._currentAssistantMsg = null;\n this._markVoiceMessagesDirty();\n if (notify) this._notifySubscribers();\n }\n }\n\n public disconnectVoice() {\n this._disconnectVoice(true);\n }\n\n private _disconnectVoice(fireHook: boolean) {\n this._finishVoiceAssistantMessage(false);\n this._currentAssistantMsg = null;\n // Drain the shared list in place so reentrant setup cannot release the same handles again.\n const unsubs = this._voiceUnsubs.splice(0);\n this._voiceUnsubs = [];\n const session = this._voiceSession;\n this._voiceSession = undefined;\n this.voice = undefined;\n this._voiceVolume = 0;\n const stopSpeaking =\n this.speech && this._isVoiceMessage(this.speech.messageId)\n ? this._stopSpeaking\n : undefined;\n this._voiceMessages = [];\n this._markVoiceMessagesDirty();\n\n try {\n notifySubscribers([\n ...unsubs,\n ...(stopSpeaking ? [stopSpeaking] : []),\n ...(session ? [() => session.disconnect()] : []),\n () =>\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n ),\n () => this._notifySubscribers(),\n ]);\n } finally {\n if (fireHook && session && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n }\n }\n\n public muteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.mute();\n this.voice = {\n ...this.voice!,\n isMuted: true,\n };\n this._notifySubscribers();\n }\n\n public unmuteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.unmute();\n this.voice = {\n ...this.voice!,\n isMuted: false,\n };\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\", {});\n }\n }\n\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n this.repository.clear();\n this.repository.import(data);\n this._notifySubscribers();\n }\n\n public reset(initialMessages?: readonly ThreadMessageLike[]) {\n this.import(ExportedMessageRepository.fromArray(initialMessages ?? []));\n }\n\n private _eventSubscribers = new Map<\n ThreadRuntimeEventType,\n Set<(payload?: unknown) => void>\n >();\n\n public unstable_on<E extends ThreadRuntimeEventType>(\n event: E,\n callback: ThreadRuntimeEventCallback<E>,\n ) {\n const wrapped = callback as (payload?: unknown) => void;\n if (event === \"modelContextUpdate\") {\n // provider.subscribe is `() => void`; pump the typed empty payload to the user callback.\n return (\n this._contextProvider.subscribe?.(() =>\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`),\n ) ?? (() => {})\n );\n }\n\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 // `initialize` latches: replay it (deferred) to subscribers that attach\n // after the thread already initialized, mirroring a BehaviorSubject.\n if (event === \"initialize\" && this._isInitialized) {\n queueMicrotask(() => {\n if (subscribers.has(wrapped)) {\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`);\n }\n });\n }\n\n return () => {\n this._eventSubscribers.get(event)?.delete(wrapped);\n };\n }\n}\n"],"mappings":";;;;;;;;;AAkDA,IAAsBuC,wBAAtB,cACUP,iBA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,mBAAmB3G,MAAK,EAAG;EAEnE,CAAC;EAGH,aAAa;GACX,KAAKI,kBAAkBxB,IAAIoB,KAAK,CAAC,EAAEZ,OAAOuH,OAAO;EACnD;CACF;AACF"}
1
+ {"version":3,"file":"base-thread-runtime-core.js","names":["AppendMessage","TextMessagePart","ThreadAssistantMessage","ThreadMessage","Unsubscribe","ModelContextProvider","getThreadMessageText","generateId","ExportedMessageRepository","MessageRepository","captureThreadRuntimeGeneration","DefaultThreadComposerRuntimeCore","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","ThreadSuggestion","SubmitFeedbackOptions","ThreadRuntimeCore","SpeechState","VoiceSessionState","RuntimeCapabilities","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","DefaultEditComposerRuntimeCore","SpeechSynthesisAdapter","FeedbackAdapter","AttachmentAdapter","RealtimeVoiceAdapter","ThreadMessageLike","notifyEventListeners","MessageNotSentError","gateInteractableComposerMetadata","BaseSubscribable","notifySubscribers","BaseThreadAdapters","speech","feedback","attachments","voice","BaseThreadRuntimeCore","_isInitialized","repository","adapters","isDisabled","isSendDisabled","isLoading","suggestions","extras","capabilities","append","message","deleteMessage","messageId","Promise","startRun","config","resumeRun","addToolResult","options","resumeToolCall","respondToToolApproval","cancelRun","exportExternalState","importExternalState","state","unstable_notifySessionReset","_voiceMessages","_voiceGeneration","_cachedMergedMessages","_cachedVoiceGeneration","_cachedMergedBase","_markVoiceMessagesDirty","_getBaseMessages","getMessages","_commitVoiceMessage","_message","_onMessageMetadataChanged","_previousMessage","_dropVoiceMessage","notify","index","findIndex","voiceMessage","id","splice","_notifySubscribers","messages","length","base","baseMessageIds","Set","map","filter","has","mostRecentAssistantMessage","this","role","metadata","unstable_state","composer","_contextProvider","constructor","getModelContext","enrichAppendMetadata","anchorId","parentId","parentIndex","m","composerMetadata","unstable_composerMetadata","slice","custom","_editComposers","Map","getEditComposer","get","_isVoiceMessage","some","_resolveAppendParent","at","beginEdit","Error","set","delete","getMessage","getMessageById","baseMessages","voiceIdx","undefined","getBranches","switchToBranch","branchId","_notifyEventSubscribers","event","E","payload","subscribers","_eventSubscribers","_notifyToolApprovalAnswered","toolCallId","toolName","approved","submitFeedback","type","comment","adapter","entry","trimmed","trim","submit","updatedMessage","submittedFeedback","addOrUpdateMessage","_currentAssistantMsg","_stopSpeaking","speak","previousStop","utterance","Utterance","error","notificationError","console","unsub","clear","cleanup","stop","cancel","update","status","subscribe","cleanupError","stopSpeaking","_voiceSession","Session","_voiceUnsubs","Array","_voiceVolume","_voiceVolumeSubscribers","getVoiceVolume","subscribeVoiceVolume","callback","add","_onVoiceConnected","_onVoiceDisconnected","_toVoiceSessionState","session","Status","mode","Mode","isMuted","canSendText","sendText","_isRunActive","runtime","isRunning","last","_getVoiceCommitBarrier","generation","aborted","resolve","wake","unsubscribe","removeEventListener","addEventListener","connectVoice","replacing","_disconnectVoice","connect","unsubs","finishDetachedSetup","currentMode","push","onStatusChange","_finishVoiceAssistantMessage","onModeChange","onVolumeChange","volume","onTranscript","transcript","_handleVoiceTranscript","_observeVoiceCommit","commit","catch","TranscriptItem","ensureInitialized","isFinal","_commitVoiceUserMessage","content","text","modality","createdAt","Date","reason","unstable_annotations","unstable_data","steps","idx","indexOf","updated","committed","_appendToVoiceSession","part","sourceId","enriched","notSent","cause","disconnectVoice","fireHook","disconnect","muteVoice","mute","unmuteVoice","unmute","export","import","data","reset","initialMessages","fromArray","unstable_on","wrapped","queueMicrotask"],"sources":["../../../src/runtime/base/base-thread-runtime-core.ts"],"sourcesContent":["import type {\n AppendMessage,\n TextMessagePart,\n ThreadAssistantMessage,\n ThreadMessage,\n} from \"../../types/message\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { generateId } from \"../../utils/id\";\nimport {\n ExportedMessageRepository,\n MessageRepository,\n} from \"../utils/message-repository\";\nimport { captureThreadRuntimeGeneration } from \"../utils/thread-runtime-lifecycle\";\nimport { DefaultThreadComposerRuntimeCore } from \"./default-thread-composer-runtime-core\";\nimport type {\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n ThreadSuggestion,\n SubmitFeedbackOptions,\n ThreadRuntimeCore,\n SpeechState,\n VoiceSessionState,\n RuntimeCapabilities,\n ThreadRuntimeEventCallback,\n ThreadRuntimeEventPayload,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n} from \"../interfaces/thread-runtime-core\";\nimport { DefaultEditComposerRuntimeCore } from \"./default-edit-composer-runtime-core\";\nimport type { SpeechSynthesisAdapter } from \"../../adapters/speech\";\nimport type { FeedbackAdapter } from \"../../adapters/feedback\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { RealtimeVoiceAdapter } from \"../../adapters/voice\";\nimport type { ThreadMessageLike } from \"../utils/thread-message-like\";\nimport { notifyEventListeners } from \"../../utils/notify-event-listeners\";\nimport { MessageNotSentError } from \"../../types/error\";\nimport { gateInteractableComposerMetadata } from \"../../model-context/interactable-composer-metadata\";\nimport {\n BaseSubscribable,\n notifySubscribers,\n} from \"../../subscribable/subscribable\";\n\ntype BaseThreadAdapters = {\n speech?: SpeechSynthesisAdapter | undefined;\n feedback?: FeedbackAdapter | undefined;\n attachments?: AttachmentAdapter | undefined;\n voice?: RealtimeVoiceAdapter | undefined;\n};\n\nexport abstract class BaseThreadRuntimeCore\n extends BaseSubscribable\n implements ThreadRuntimeCore\n{\n private _isInitialized = false;\n\n protected repository = new MessageRepository();\n public abstract get adapters(): BaseThreadAdapters | undefined;\n public abstract get isDisabled(): boolean;\n public abstract get isSendDisabled(): boolean;\n public abstract get isLoading(): boolean;\n public abstract get suggestions(): readonly ThreadSuggestion[];\n public abstract get extras(): unknown;\n\n public abstract get capabilities(): RuntimeCapabilities;\n public abstract append(message: AppendMessage): void;\n public abstract deleteMessage(messageId: string): void | Promise<void>;\n public abstract startRun(config: StartRunConfig): void;\n public abstract resumeRun(config: ResumeRunConfig): void;\n public abstract addToolResult(options: AddToolResultOptions): void;\n public abstract resumeToolCall(options: ResumeToolCallOptions): void;\n public abstract respondToToolApproval(\n options: RespondToToolApprovalOptions,\n ): Promise<void>;\n public abstract cancelRun(): void;\n public abstract exportExternalState(): any;\n public abstract importExternalState(state: any): void;\n public abstract unstable_notifySessionReset(): void;\n\n protected _voiceMessages: ThreadMessage[] = [];\n protected _voiceGeneration = 0;\n private _cachedMergedMessages: readonly ThreadMessage[] | null = null;\n private _cachedVoiceGeneration = -1;\n private _cachedMergedBase: readonly ThreadMessage[] | null = null;\n\n protected _markVoiceMessagesDirty() {\n this._voiceGeneration++;\n this._cachedMergedMessages = null;\n }\n\n protected _getBaseMessages(): readonly ThreadMessage[] {\n return this.repository.getMessages();\n }\n\n protected _commitVoiceMessage(\n _message: ThreadMessage,\n ): void | Promise<void> {}\n\n protected _onMessageMetadataChanged(\n _previousMessage: ThreadAssistantMessage,\n _message: ThreadAssistantMessage,\n ): void {}\n\n protected _dropVoiceMessage(messageId: string, notify: boolean) {\n const index = this._voiceMessages.findIndex(\n (voiceMessage) => voiceMessage.id === messageId,\n );\n if (index === -1) return;\n this._voiceMessages.splice(index, 1);\n this._markVoiceMessagesDirty();\n if (notify) this._notifySubscribers();\n }\n\n public get messages(): readonly ThreadMessage[] {\n if (this._voiceMessages.length === 0) {\n return this._getBaseMessages();\n }\n const base = this._getBaseMessages();\n if (\n this._cachedVoiceGeneration !== this._voiceGeneration ||\n this._cachedMergedBase !== base\n ) {\n const baseMessageIds = new Set(base.map((message) => message.id));\n this._cachedMergedMessages = [\n ...base,\n ...this._voiceMessages.filter(\n (message) => !baseMessageIds.has(message.id),\n ),\n ];\n this._cachedVoiceGeneration = this._voiceGeneration;\n this._cachedMergedBase = base;\n }\n return this._cachedMergedMessages!;\n }\n\n public get state() {\n let mostRecentAssistantMessage: (typeof this.messages)[number] | undefined;\n for (const message of this.messages) {\n if (message.role === \"assistant\") {\n mostRecentAssistantMessage = message;\n }\n }\n\n return mostRecentAssistantMessage?.metadata.unstable_state ?? null;\n }\n\n public readonly composer = new DefaultThreadComposerRuntimeCore(this);\n\n private readonly _contextProvider: ModelContextProvider;\n\n constructor(_contextProvider: ModelContextProvider) {\n super();\n this._contextProvider = _contextProvider;\n }\n\n public getModelContext() {\n return this._contextProvider.getModelContext();\n }\n\n /**\n * Stamps provider-contributed composer metadata onto an outgoing message.\n * Called at dispatch rather than in the composer, so programmatic sends are\n * covered too, and exactly once per message: a queued send is stamped when\n * it leaves the lane, never when it enters.\n *\n * Only user messages are stamped, matching the readers: both the version\n * fold and the model injection skip every other role.\n *\n * @param anchorId Message the gated branch prefix ends at. A queued send\n * passes the current tail, having waited through a run that grew the prefix\n * past the parent it was created with.\n */\n protected enrichAppendMetadata(\n message: AppendMessage,\n anchorId: string | null = message.parentId,\n ): AppendMessage {\n if (message.role !== \"user\") return message;\n const messages = this.messages;\n const parentIndex =\n anchorId === null ? -1 : messages.findIndex((m) => m.id === anchorId);\n const composerMetadata = gateInteractableComposerMetadata(\n this.getModelContext().unstable_composerMetadata,\n messages.slice(0, parentIndex + 1),\n );\n if (!composerMetadata) return message;\n return {\n ...message,\n metadata: {\n ...message.metadata,\n custom: { ...message.metadata?.custom, ...composerMetadata },\n },\n };\n }\n\n private _editComposers = new Map<string, DefaultEditComposerRuntimeCore>();\n public getEditComposer(messageId: string) {\n return this._editComposers.get(messageId);\n }\n protected _isVoiceMessage(messageId: string | null) {\n return (\n messageId !== null && this._voiceMessages.some((m) => m.id === messageId)\n );\n }\n\n protected _resolveAppendParent(parentId: string | null): string | null {\n return this._isVoiceMessage(parentId)\n ? (this._getBaseMessages().at(-1)?.id ?? null)\n : parentId;\n }\n\n public beginEdit(messageId: string) {\n if (this.voice)\n throw new Error(\n \"Cannot edit a message while a voice session is connected\",\n );\n if (this._isVoiceMessage(messageId)) {\n throw new Error(\"Voice transcript messages cannot be edited\");\n }\n if (this._editComposers.has(messageId))\n throw new Error(\"Edit already in progress\");\n\n this._editComposers.set(\n messageId,\n new DefaultEditComposerRuntimeCore(\n this,\n () => this._editComposers.delete(messageId),\n this.repository.getMessage(messageId),\n ),\n );\n this._notifySubscribers();\n }\n\n public getMessageById(messageId: string) {\n try {\n return this.repository.getMessage(messageId);\n } catch {\n // Check voice messages\n const baseMessages = this.repository.getMessages();\n const voiceIdx = this._voiceMessages.findIndex((m) => m.id === messageId);\n if (voiceIdx !== -1) {\n const parentId =\n voiceIdx > 0\n ? this._voiceMessages[voiceIdx - 1]!.id\n : (baseMessages.at(-1)?.id ?? null);\n return {\n parentId,\n message: this._voiceMessages[voiceIdx]!,\n index: baseMessages.length + voiceIdx,\n };\n }\n return undefined;\n }\n }\n\n public getBranches(messageId: string): string[] {\n if (this._voiceMessages.some((m) => m.id === messageId)) {\n return [];\n }\n return this.repository.getBranches(messageId);\n }\n\n public switchToBranch(branchId: string): void {\n this.repository.switchToBranch(branchId);\n this._notifySubscribers();\n }\n\n public _notifyEventSubscribers<E extends ThreadRuntimeEventType>(\n event: E,\n payload: ThreadRuntimeEventPayload[E],\n ) {\n const subscribers = this._eventSubscribers.get(event);\n if (!subscribers) return;\n\n notifyEventListeners(subscribers, payload, `Thread runtime \"${event}\"`);\n }\n\n protected _notifyToolApprovalAnswered(\n messageId: string,\n toolCallId: string,\n toolName: string,\n approved: boolean,\n ) {\n this._notifyEventSubscribers(\"toolApprovalAnswered\", {\n messageId,\n toolCallId,\n toolName,\n approved,\n });\n }\n\n public submitFeedback({ messageId, type, comment }: SubmitFeedbackOptions) {\n const adapter = this.adapters?.feedback;\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message, parentId } = entry;\n const trimmed = comment?.trim();\n const feedback = { type, ...(trimmed ? { comment: trimmed } : undefined) };\n adapter?.submit({ message, ...feedback });\n\n if (message.role === \"assistant\") {\n const updatedMessage: ThreadAssistantMessage = {\n ...message,\n metadata: {\n ...message.metadata,\n submittedFeedback: feedback,\n },\n };\n const voiceIdx = this._voiceMessages.findIndex(\n (voiceMessage) => voiceMessage.id === messageId,\n );\n if (voiceIdx === -1) {\n this.repository.addOrUpdateMessage(parentId, updatedMessage);\n this._onMessageMetadataChanged(message, updatedMessage);\n } else {\n this._voiceMessages[voiceIdx] = updatedMessage;\n if (this._currentAssistantMsg === message) {\n this._currentAssistantMsg = updatedMessage;\n }\n this._markVoiceMessagesDirty();\n }\n }\n\n this._notifySubscribers();\n }\n\n private _stopSpeaking: Unsubscribe | undefined;\n public speech: SpeechState | undefined;\n\n public speak(messageId: string) {\n const adapter = this.adapters?.speech;\n if (!adapter) throw new Error(\"Speech adapter not configured\");\n\n const entry = this.getMessageById(messageId);\n if (!entry) throw new Error(`Message not found: ${messageId}`);\n const { message } = entry;\n\n const previousStop = this._stopSpeaking;\n let utterance: SpeechSynthesisAdapter.Utterance;\n try {\n previousStop?.();\n utterance = adapter.speak(getThreadMessageText(message));\n } catch (error) {\n if (previousStop && !this._stopSpeaking) {\n try {\n this._notifySubscribers();\n } catch (notificationError) {\n console.error(\n \"[assistant-ui] Speech rollback notification threw\",\n notificationError,\n );\n }\n }\n throw error;\n }\n let unsub: Unsubscribe | undefined;\n const clear = () => {\n this._stopSpeaking = undefined;\n this.speech = undefined;\n const cleanup = unsub;\n unsub = undefined;\n cleanup?.();\n };\n const stop = () => {\n if (this._stopSpeaking !== stop) return;\n try {\n clear();\n } finally {\n utterance.cancel();\n }\n };\n const update = () => {\n if (this._stopSpeaking !== stop) return;\n if (utterance.status.type === \"ended\") {\n notifySubscribers([clear, () => this._notifySubscribers()]);\n } else {\n this.speech = { messageId, status: utterance.status };\n this._notifySubscribers();\n }\n };\n\n this._stopSpeaking = stop;\n try {\n unsub = utterance.subscribe(update);\n if (this._stopSpeaking !== stop) {\n unsub();\n return;\n }\n update();\n } catch (error) {\n if (this._stopSpeaking === stop) {\n try {\n notifySubscribers([stop, () => this._notifySubscribers()]);\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Speech rollback cleanup threw\",\n cleanupError,\n );\n }\n }\n throw error;\n }\n }\n\n public stopSpeaking() {\n if (!this._stopSpeaking) throw new Error(\"No message is being spoken\");\n notifySubscribers([this._stopSpeaking, () => this._notifySubscribers()]);\n }\n\n private _voiceSession: RealtimeVoiceAdapter.Session | undefined;\n private _voiceUnsubs: Array<() => void> = [];\n public voice: VoiceSessionState | undefined;\n\n private _voiceVolume = 0;\n private _voiceVolumeSubscribers = new Set<() => void>();\n\n public getVoiceVolume = () => this._voiceVolume;\n\n public subscribeVoiceVolume = (callback: () => void): Unsubscribe => {\n this._voiceVolumeSubscribers.add(callback);\n return () => this._voiceVolumeSubscribers.delete(callback);\n };\n\n protected _onVoiceConnected(): void {}\n\n protected _onVoiceDisconnected(): void {}\n\n private _toVoiceSessionState(\n session: RealtimeVoiceAdapter.Session,\n status: RealtimeVoiceAdapter.Status,\n mode: RealtimeVoiceAdapter.Mode,\n ): VoiceSessionState {\n return {\n status,\n isMuted: session.isMuted,\n mode,\n canSendText: status.type === \"running\" && session.sendText !== undefined,\n };\n }\n\n protected _isRunActive(): boolean {\n const runtime: ThreadRuntimeCore = this;\n if (runtime.isRunning) return true;\n const last = this._getBaseMessages().at(-1);\n return (\n last?.role === \"assistant\" &&\n (last.status.type === \"running\" || last.status.type === \"requires-action\")\n );\n }\n\n /**\n * Waits for a pending history import before a voice message is committed.\n * The import may begin before or after the voice session connects, so the\n * loading state must be rechecked when the commit is ready to run. The wait\n * also ends when the runtime is invalidated, since a superseded runtime may\n * never learn that loading ended.\n */\n protected _getVoiceCommitBarrier(): Promise<void> | undefined {\n if (!this.isLoading) return undefined;\n const generation = captureThreadRuntimeGeneration(this);\n return (async () => {\n while (this.isLoading && !generation.aborted) {\n await new Promise<void>((resolve) => {\n const wake = () => {\n unsubscribe();\n generation.removeEventListener(\"abort\", wake);\n resolve();\n };\n const unsubscribe = this.subscribe(wake);\n generation.addEventListener(\"abort\", wake);\n });\n }\n })();\n }\n\n public connectVoice() {\n const adapter = this.adapters?.voice;\n if (!adapter) throw new Error(\"Voice adapter not configured\");\n if (this._isRunActive())\n throw new Error(\n \"Cannot start a voice session while a run is in progress or paused on a pending tool action\",\n );\n const replacing = this._voiceSession !== undefined;\n\n try {\n this._disconnectVoice(false);\n } catch (error) {\n console.error(\n \"[assistant-ui] Voice cleanup threw before reconnect\",\n error,\n );\n }\n\n let session: RealtimeVoiceAdapter.Session;\n try {\n session = adapter.connect({});\n } catch (error) {\n if (replacing && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n throw error;\n }\n this._voiceSession = session;\n const unsubs: Array<() => void> = [];\n this._voiceUnsubs = unsubs;\n\n // The cleanup-list identity preserves ownership after an ended status clears the session.\n const finishDetachedSetup = () => {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n return false;\n }\n\n try {\n notifySubscribers(unsubs.splice(0));\n } catch (error) {\n console.error(\n \"[assistant-ui] Detached voice setup cleanup threw\",\n error,\n );\n }\n return true;\n };\n\n try {\n let currentMode: RealtimeVoiceAdapter.Mode = \"listening\";\n\n this.voice = this._toVoiceSessionState(\n session,\n session.status,\n currentMode,\n );\n this._voiceVolume = 0;\n this._notifySubscribers();\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onStatusChange((status) => {\n if (this._voiceSession !== session) return;\n if (status.type === \"ended\") {\n this._finishVoiceAssistantMessage();\n this._voiceSession = undefined;\n this.voice = undefined;\n this._onVoiceDisconnected();\n } else {\n this.voice = this._toVoiceSessionState(\n session,\n status,\n currentMode,\n );\n }\n this._notifySubscribers();\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onModeChange((mode) => {\n if (this._voiceSession !== session) return;\n currentMode = mode;\n if (this.voice) {\n this.voice = { ...this.voice, mode };\n this._notifySubscribers();\n }\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onVolumeChange((volume) => {\n if (this._voiceSession !== session) return;\n this._voiceVolume = volume;\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n );\n }),\n );\n if (finishDetachedSetup()) return;\n\n unsubs.push(\n session.onTranscript((transcript) => {\n if (this._voiceSession !== session) return;\n this._handleVoiceTranscript(transcript);\n }),\n );\n if (!finishDetachedSetup()) this._onVoiceConnected();\n } catch (error) {\n if (this._voiceSession === session && this._voiceUnsubs === unsubs) {\n try {\n this._disconnectVoice(false);\n } catch (cleanupError) {\n console.error(\n \"[assistant-ui] Voice rollback cleanup threw\",\n cleanupError,\n );\n }\n if (replacing && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n } else {\n finishDetachedSetup();\n }\n throw error;\n }\n }\n\n private _currentAssistantMsg: ThreadAssistantMessage | null = null;\n\n private _observeVoiceCommit(commit: void | Promise<void>) {\n void Promise.resolve(commit).catch((error) => {\n console.error(\"[assistant-ui] Voice message commit failed\", error);\n });\n }\n\n private _handleVoiceTranscript(\n transcript: RealtimeVoiceAdapter.TranscriptItem,\n ) {\n this.ensureInitialized();\n\n if (transcript.role === \"user\") {\n this._finishVoiceAssistantMessage();\n this._currentAssistantMsg = null;\n\n if (transcript.isFinal) {\n this._observeVoiceCommit(\n this._commitVoiceUserMessage({\n id: generateId(),\n role: \"user\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: { modality: \"voice\", custom: {} },\n createdAt: new Date(),\n attachments: [],\n }),\n );\n }\n } else {\n const status: ThreadAssistantMessage[\"status\"] = transcript.isFinal\n ? { type: \"complete\", reason: \"stop\" }\n : { type: \"running\" };\n\n if (!this._currentAssistantMsg) {\n this._currentAssistantMsg = {\n id: generateId(),\n role: \"assistant\",\n content: [{ type: \"text\", text: transcript.text }],\n metadata: {\n unstable_state: this.state,\n unstable_annotations: [],\n unstable_data: [],\n steps: [],\n modality: \"voice\",\n custom: {},\n },\n status,\n createdAt: new Date(),\n };\n this._voiceMessages.push(this._currentAssistantMsg);\n } else {\n const idx = this._voiceMessages.indexOf(this._currentAssistantMsg);\n if (idx === -1) return;\n const updated: ThreadAssistantMessage = {\n ...this._currentAssistantMsg,\n content: [{ type: \"text\", text: transcript.text }],\n status,\n };\n this._voiceMessages[idx] = updated;\n this._currentAssistantMsg = updated;\n }\n\n if (transcript.isFinal) {\n this._observeVoiceCommit(\n this._commitVoiceMessage(this._currentAssistantMsg),\n );\n this._currentAssistantMsg = null;\n }\n\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n }\n }\n\n private _commitVoiceUserMessage(message: ThreadMessage) {\n this._voiceMessages.push(message);\n const committed = this._commitVoiceMessage(message);\n this._markVoiceMessagesDirty();\n this._notifySubscribers();\n return committed;\n }\n\n protected async _appendToVoiceSession(message: AppendMessage) {\n const session = this._voiceSession;\n if (!this.voice?.canSendText || !session?.sendText)\n throw new Error(\n \"Cannot send a text message while a voice session is connected\",\n );\n const content = message.content.filter(\n (part): part is TextMessagePart => part.type === \"text\",\n );\n if (\n message.role !== \"user\" ||\n message.sourceId != null ||\n message.parentId !==\n this._resolveAppendParent(this.messages.at(-1)?.id ?? null) ||\n message.attachments?.length ||\n content.length !== message.content.length ||\n !content.some((part) => part.text.trim())\n )\n throw new Error(\n \"Only a plain text user message can be sent while a voice session is connected\",\n );\n\n const enriched = this.enrichAppendMetadata(message);\n this.ensureInitialized();\n const generation = captureThreadRuntimeGeneration(this);\n try {\n await session.sendText(getThreadMessageText(message));\n } catch (error) {\n if (generation.aborted) return;\n const notSent = new MessageNotSentError();\n notSent.cause = error;\n throw notSent;\n }\n if (generation.aborted) return;\n if (this._voiceSession !== session)\n throw new MessageNotSentError(\n \"The voice session ended before the typed message was recorded\",\n );\n this._finishVoiceAssistantMessage(false);\n this._currentAssistantMsg = null;\n await this._commitVoiceUserMessage({\n id: generateId(),\n role: \"user\",\n content,\n metadata: { custom: { ...enriched.metadata?.custom } },\n createdAt: message.createdAt,\n attachments: [],\n });\n }\n\n private _finishVoiceAssistantMessage(notify = true) {\n const last = this._voiceMessages.at(-1);\n if (last?.role === \"assistant\" && last.status.type === \"running\") {\n const idx = this._voiceMessages.length - 1;\n this._voiceMessages[idx] = {\n ...(last as ThreadAssistantMessage),\n status: { type: \"complete\", reason: \"stop\" },\n };\n this._observeVoiceCommit(\n this._commitVoiceMessage(this._voiceMessages[idx]!),\n );\n this._currentAssistantMsg = null;\n this._markVoiceMessagesDirty();\n if (notify) this._notifySubscribers();\n }\n }\n\n public disconnectVoice() {\n this._disconnectVoice(true);\n }\n\n private _disconnectVoice(fireHook: boolean) {\n this._finishVoiceAssistantMessage(false);\n this._currentAssistantMsg = null;\n // Drain the shared list in place so reentrant setup cannot release the same handles again.\n const unsubs = this._voiceUnsubs.splice(0);\n this._voiceUnsubs = [];\n const session = this._voiceSession;\n this._voiceSession = undefined;\n this.voice = undefined;\n this._voiceVolume = 0;\n const stopSpeaking =\n this.speech && this._isVoiceMessage(this.speech.messageId)\n ? this._stopSpeaking\n : undefined;\n this._voiceMessages = [];\n this._markVoiceMessagesDirty();\n\n try {\n notifySubscribers([\n ...unsubs,\n ...(stopSpeaking ? [stopSpeaking] : []),\n ...(session ? [() => session.disconnect()] : []),\n () =>\n notifyEventListeners(\n this._voiceVolumeSubscribers,\n undefined,\n \"Voice volume\",\n ),\n () => this._notifySubscribers(),\n ]);\n } finally {\n if (fireHook && session && this._voiceSession === undefined)\n this._onVoiceDisconnected();\n }\n }\n\n public muteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.mute();\n this.voice = {\n ...this.voice!,\n isMuted: true,\n };\n this._notifySubscribers();\n }\n\n public unmuteVoice() {\n if (!this._voiceSession) throw new Error(\"No active voice session\");\n this._voiceSession.unmute();\n this.voice = {\n ...this.voice!,\n isMuted: false,\n };\n this._notifySubscribers();\n }\n\n protected ensureInitialized() {\n if (!this._isInitialized) {\n this._isInitialized = true;\n this._notifyEventSubscribers(\"initialize\", {});\n }\n }\n\n public export() {\n return this.repository.export();\n }\n\n public import(data: ExportedMessageRepository) {\n this.ensureInitialized();\n this.repository.clear();\n this.repository.import(data);\n this._notifySubscribers();\n }\n\n public reset(initialMessages?: readonly ThreadMessageLike[]) {\n this.import(ExportedMessageRepository.fromArray(initialMessages ?? []));\n }\n\n private _eventSubscribers = new Map<\n ThreadRuntimeEventType,\n Set<(payload?: unknown) => void>\n >();\n\n public unstable_on<E extends ThreadRuntimeEventType>(\n event: E,\n callback: ThreadRuntimeEventCallback<E>,\n ) {\n const wrapped = callback as (payload?: unknown) => void;\n if (event === \"modelContextUpdate\") {\n // provider.subscribe is `() => void`; pump the typed empty payload to the user callback.\n return (\n this._contextProvider.subscribe?.(() =>\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`),\n ) ?? (() => {})\n );\n }\n\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 // `initialize` latches: replay it (deferred) to subscribers that attach\n // after the thread already initialized, mirroring a BehaviorSubject.\n if (event === \"initialize\" && this._isInitialized) {\n queueMicrotask(() => {\n if (subscribers.has(wrapped)) {\n notifyEventListeners([wrapped], {}, `Thread runtime \"${event}\"`);\n }\n });\n }\n\n return () => {\n this._eventSubscribers.get(event)?.delete(wrapped);\n };\n }\n}\n"],"mappings":";;;;;;;;;;;AAqDA,IAAsB0C,wBAAtB,cACUP,iBAEV;CACE,iBAAyB;CAEzB,aAAuB,IAAI1B,kBAAkB;CAuB7C,iBAA4C,CAAA;CAC5C,mBAA6B;CAC7B,wBAAiE;CACjE,yBAAiC;CACjC,oBAA6D;CAE7D,0BAAoC;EAClC,KAAK6D;EACL,KAAKC,wBAAwB;CAC/B;CAEA,mBAAuD;EACrD,OAAO,KAAK3B,WAAWgC,YAAY;CACrC;CAEA,oBACEE,UACsB,CAAC;CAEzB,0BACEE,kBACAF,UACM,CAAC;CAET,kBAA4BvB,WAAmB2B,QAAiB;EAC9D,MAAMC,QAAQ,KAAKd,eAAee,WAC/BC,iBAAiBA,aAAaC,OAAO/B,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,KAAK1H,WAAWqN,OAAOC,IAAI;EAC3B,KAAK1K,mBAAmB;CAC1B;CAEA,MAAa4K,iBAAgD;EAC3D,KAAKH,OAAOzP,0BAA0B6P,UAAUD,mBAAmB,CAAA,CAAE,CAAC;CACxE;CAEA,oCAA4B,IAAIhJ,IAG9B;CAEF,YACEoB,OACA+C,UACA;EACA,MAAMgF,UAAUhF;EAChB,IAAI/C,UAAU,sBAEZ,OACE,KAAKjC,iBAAiBqE,kBACpB5I,qBAAqB,CAACuO,OAAO,GAAG,CAAC,GAAG,mBAAmB/H,MAAK,EAAG,CACjE,YAAY,CAAC;EAIjB,IAAIG,cAAc,KAAKC,kBAAkBtB,IAAIkB,KAAK;EAClD,IAAI,CAACG,aAAa;GAChBA,8BAAc,IAAI9C,IAAI;GACtB,KAAK+C,kBAAkBf,IAAIW,OAAOG,WAAW;EAC/C;EACAA,YAAY6C,IAAI+E,OAAO;EAIvB,IAAI/H,UAAU,gBAAgB,KAAK7F,gBACjC6N,qBAAqB;GACnB,IAAI7H,YAAY3C,IAAIuK,OAAO,GACzBvO,qBAAqB,CAACuO,OAAO,GAAG,CAAC,GAAG,mBAAmB/H,MAAK,EAAG;EAEnE,CAAC;EAGH,aAAa;GACX,KAAKI,kBAAkBtB,IAAIkB,KAAK,CAAC,EAAEV,OAAOyI,OAAO;EACnD;CACF;AACF"}
@@ -1,33 +1,33 @@
1
- import { AppendMessage, ThreadMessage } from "../../types/message.js";
2
- import { AttachmentAdapter } from "../../adapters/attachment.js";
3
- import { DictationAdapter } from "../../adapters/speech.js";
4
- import { SendOptions } from "../interfaces/composer-runtime-core.js";
5
- import { ThreadRuntimeCore } from "../interfaces/thread-runtime-core.js";
1
+ import type { AppendMessage, ThreadMessage } from "../../types/message.js";
2
+ import type { AttachmentAdapter } from "../../adapters/attachment.js";
3
+ import type { DictationAdapter } from "../../adapters/speech.js";
4
+ import type { SendOptions } from "../interfaces/composer-runtime-core.js";
5
+ import type { ThreadRuntimeCore } from "../interfaces/thread-runtime-core.js";
6
6
  import { BaseComposerRuntimeCore } from "./base-composer-runtime-core.js";
7
- //#region src/runtime/base/default-edit-composer-runtime-core.d.ts
8
7
  export declare class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {
9
- get canCancel(): boolean;
10
- get canSend(): boolean;
11
- protected getAttachmentAdapter(): AttachmentAdapter | undefined;
12
- protected getDictationAdapter(): DictationAdapter | undefined;
13
- private _nonTextPassthrough;
14
- private _parentId;
15
- private _sourceId;
16
- private runtime;
17
- private endEditCallback;
18
- constructor(runtime: ThreadRuntimeCore & {
19
- adapters?: {
20
- attachments?: AttachmentAdapter | undefined;
21
- dictation?: DictationAdapter | undefined;
22
- } | undefined;
23
- }, endEditCallback: () => void, { parentId, message }: {
24
- parentId: string | null;
25
- message: ThreadMessage;
26
- });
27
- get parentId(): string | null;
28
- get sourceId(): string | null;
29
- handleSend(message: Omit<AppendMessage, "parentId" | "sourceId">, options?: SendOptions): Promise<void>;
30
- handleCancel(): void;
8
+ get canCancel(): boolean;
9
+ protected get detachesDraftOnSend(): boolean;
10
+ get canSend(): boolean;
11
+ protected getAttachmentAdapter(): AttachmentAdapter | undefined;
12
+ protected getDictationAdapter(): DictationAdapter | undefined;
13
+ private _nonTextPassthrough;
14
+ private _parentId;
15
+ private _sourceId;
16
+ private runtime;
17
+ private endEditCallback;
18
+ private _ended;
19
+ constructor(runtime: ThreadRuntimeCore & {
20
+ adapters?: {
21
+ attachments?: AttachmentAdapter | undefined;
22
+ dictation?: DictationAdapter | undefined;
23
+ } | undefined;
24
+ }, endEditCallback: () => void, { parentId, message }: {
25
+ parentId: string | null;
26
+ message: ThreadMessage;
27
+ });
28
+ get parentId(): string | null;
29
+ get sourceId(): string | null;
30
+ handleSend(message: Omit<AppendMessage, "parentId" | "sourceId">, options?: SendOptions): Promise<void>;
31
+ handleCancel(): void;
31
32
  }
32
- //#endregion
33
33
  //# sourceMappingURL=default-edit-composer-runtime-core.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"default-edit-composer-runtime-core.d.ts","names":[],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"mappings":";;;;;;;qBAUa,uCAAuC;MACvC;MAIA;YAID,wBAAoB;YAIpB,uBAAmB;UAIrB;UACA;UACA;UACA;UAQA;EAGN,YAAA,SAAS;IACP;MAEM,cAAc;MACd,YAAY;;KAIpB,+BACE,UAAU;IAAa;IAAyB,SAAS;;MAuClD;MAIA;EAIE,WACX,SAAS,KAAK,yCACd,UAAU,cAAW;EAqBhB"}
1
+ {"version":3,"file":"default-edit-composer-runtime-core.d.ts","sourceRoot":"","sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,+BAA4B;AAIxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,qCAAkC;AACnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,iCAA8B;AAC9D,OAAO,KAAK,EAAE,WAAW,EAAE,+CAA4C;AACvE,OAAO,KAAK,EAAE,iBAAiB,EAAE,6CAA0C;AAC3E,OAAO,EAAE,uBAAuB,EAAE,wCAAqC;AAEvE,qBAAa,8BAA+B,SAAQ,uBAAuB;IACzE,IAAW,SAAS,YAEnB;IAID,cAAuB,mBAAmB,YAEzC;IAED,IAAW,OAAO,YAEjB;IAED,SAAS,CAAC,oBAAoB;IAI9B,SAAS,CAAC,mBAAmB;IAI7B,OAAO,CAAC,mBAAmB,CAA8C;IACzE,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,OAAO,CAOb;IACF,OAAO,CAAC,eAAe,CAAa;IACpC,OAAO,CAAC,MAAM,CAAS;gBAGrB,OAAO,EAAE,iBAAiB,GAAG;QAC3B,QAAQ,CAAC,EACL;YACE,WAAW,CAAC,EAAE,iBAAiB,GAAG,SAAS,CAAC;YAC5C,SAAS,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAC;SAC1C,GACD,SAAS,CAAC;KACf,EACD,eAAe,EAAE,MAAM,IAAI,EAC3B,EAAE,QAAQ,EAAE,OAAO,EAAE,EAAE;QAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,OAAO,EAAE,aAAa,CAAA;KAAE;IAuC5E,IAAW,QAAQ,kBAElB;IAED,IAAW,QAAQ,kBAElB;IAEY,UAAU,CACrB,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,UAAU,CAAC,EACrD,OAAO,CAAC,EAAE,WAAW;IAqBhB,YAAY;CASpB"}
@@ -6,8 +6,11 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
6
6
  get canCancel() {
7
7
  return true;
8
8
  }
9
+ get detachesDraftOnSend() {
10
+ return false;
11
+ }
9
12
  get canSend() {
10
- return !this.isEmpty && !this.runtime.voice && !this._isSending;
13
+ return !this.isEmpty && !this.runtime.voice && !this.isSubmitting;
11
14
  }
12
15
  getAttachmentAdapter() {
13
16
  return this.runtime.adapters?.attachments;
@@ -20,6 +23,7 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
20
23
  _sourceId;
21
24
  runtime;
22
25
  endEditCallback;
26
+ _ended = false;
23
27
  constructor(runtime, endEditCallback, { parentId, message }) {
24
28
  super();
25
29
  this.runtime = runtime;
@@ -68,6 +72,11 @@ var DefaultEditComposerRuntimeCore = class extends BaseComposerRuntimeCore {
68
72
  return appendTask;
69
73
  }
70
74
  handleCancel() {
75
+ if (this._ended) return;
76
+ this._ended = true;
77
+ this.reset().catch((error) => {
78
+ console.error("[assistant-ui] Failed to clear cancelled edit", error);
79
+ });
71
80
  this.endEditCallback();
72
81
  this._notifySubscribers();
73
82
  }
@@ -1 +1 @@
1
- {"version":3,"file":"default-edit-composer-runtime-core.js","names":["AppendMessage","ThreadMessage","CompleteAttachment","getThreadMessageText","liftNonTextParts","AttachmentAdapter","DictationAdapter","SendOptions","ThreadRuntimeCore","BaseComposerRuntimeCore","DefaultEditComposerRuntimeCore","canCancel","canSend","isEmpty","runtime","voice","_isSending","getAttachmentAdapter","adapters","attachments","getDictationAdapter","dictation","_nonTextPassthrough","_parentId","_sourceId","endEditCallback","constructor","parentId","message","lastHasVoice","undefined","unsubscribe","subscribe","hasVoice","_notifySubscribers","id","setText","setRole","role","content","filter","p","type","setAttachments","setRunConfig","composer","runConfig","sourceId","handleSend","Omit","options","length","appendTask","append","startRun","handleCancel"],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"sourcesContent":["import type { AppendMessage, ThreadMessage } from \"../../types/message\";\nimport type { CompleteAttachment } from \"../../types/attachment\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { liftNonTextParts } from \"../../adapters/attachment\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type { SendOptions } from \"../interfaces/composer-runtime-core\";\nimport type { ThreadRuntimeCore } from \"../interfaces/thread-runtime-core\";\nimport { BaseComposerRuntimeCore } from \"./base-composer-runtime-core\";\n\nexport class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {\n public get canCancel() {\n return true;\n }\n\n public get canSend() {\n return !this.isEmpty && !this.runtime.voice && !this._isSending;\n }\n\n protected getAttachmentAdapter() {\n return this.runtime.adapters?.attachments;\n }\n\n protected getDictationAdapter() {\n return this.runtime.adapters?.dictation;\n }\n\n private _nonTextPassthrough: readonly ThreadMessage[\"content\"][number][];\n private _parentId: string | null;\n private _sourceId: string | null;\n private runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n };\n private endEditCallback: () => void;\n\n constructor(\n runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n },\n endEditCallback: () => void,\n { parentId, message }: { parentId: string | null; message: ThreadMessage },\n ) {\n super();\n this.runtime = runtime;\n let lastHasVoice = runtime.voice !== undefined;\n const unsubscribe = runtime.subscribe(() => {\n const hasVoice = runtime.voice !== undefined;\n if (hasVoice === lastHasVoice) return;\n lastHasVoice = hasVoice;\n this._notifySubscribers();\n });\n this.endEditCallback = () => {\n unsubscribe();\n endEditCallback();\n };\n this._parentId = parentId;\n this._sourceId = message.id;\n this.setText(getThreadMessageText(message));\n\n this.setRole(message.role);\n\n let attachments: readonly CompleteAttachment[];\n if (message.role === \"user\") {\n attachments = [\n ...(message.attachments ?? []),\n ...liftNonTextParts(message.content),\n ];\n this._nonTextPassthrough = [];\n } else {\n attachments = message.attachments ?? [];\n this._nonTextPassthrough = message.content.filter(\n (p) => p.type !== \"text\",\n );\n }\n this.setAttachments(attachments);\n\n this.setRunConfig({ ...runtime.composer.runConfig });\n }\n\n public get parentId() {\n return this._parentId;\n }\n\n public get sourceId() {\n return this._sourceId;\n }\n\n public async handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n options?: SendOptions,\n ) {\n const content =\n this._nonTextPassthrough.length > 0\n ? ([\n ...message.content,\n ...this._nonTextPassthrough,\n ] as AppendMessage[\"content\"])\n : message.content;\n const appendTask = this.runtime.append({\n ...message,\n content,\n parentId: this._parentId,\n sourceId: this._sourceId,\n startRun: options?.startRun,\n });\n\n this.handleCancel();\n return appendTask;\n }\n\n public handleCancel() {\n this.endEditCallback();\n this._notifySubscribers();\n }\n}\n"],"mappings":";;;;AAUA,IAAaU,iCAAb,cAAoDD,wBAAwB;CAC1E,IAAWE,YAAY;EACrB,OAAO;CACT;CAEA,IAAWC,UAAU;EACnB,OAAO,CAAC,KAAKC,WAAW,CAAC,KAAKC,QAAQC,SAAS,CAAC,KAAKC;CACvD;CAEA,uBAAiC;EAC/B,OAAO,KAAKF,QAAQI,UAAUC;CAChC;CAEA,sBAAgC;EAC9B,OAAO,KAAKL,QAAQI,UAAUG;CAChC;CAEA;CACA;CACA;CACA;CAQA;CAEAK,Y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EAClB,OAAOH;CACT;CAEA,eAAsB;EACpB,KAAK3B,gBAAgB;EACrB,KAAKS,mBAAmB;CAC1B;AACF"}
1
+ {"version":3,"file":"default-edit-composer-runtime-core.js","names":["AppendMessage","ThreadMessage","CompleteAttachment","getThreadMessageText","liftNonTextParts","AttachmentAdapter","DictationAdapter","SendOptions","ThreadRuntimeCore","BaseComposerRuntimeCore","DefaultEditComposerRuntimeCore","canCancel","detachesDraftOnSend","canSend","isEmpty","runtime","voice","isSubmitting","getAttachmentAdapter","adapters","attachments","getDictationAdapter","dictation","_nonTextPassthrough","_parentId","_sourceId","endEditCallback","_ended","constructor","parentId","message","lastHasVoice","undefined","unsubscribe","subscribe","hasVoice","_notifySubscribers","id","setText","setRole","role","content","filter","p","type","setAttachments","setRunConfig","composer","runConfig","sourceId","handleSend","Omit","options","length","appendTask","append","startRun","handleCancel","reset","catch","error","console"],"sources":["../../../src/runtime/base/default-edit-composer-runtime-core.ts"],"sourcesContent":["import type { AppendMessage, ThreadMessage } from \"../../types/message\";\nimport type { CompleteAttachment } from \"../../types/attachment\";\nimport { getThreadMessageText } from \"../../utils/text\";\nimport { liftNonTextParts } from \"../../adapters/attachment\";\nimport type { AttachmentAdapter } from \"../../adapters/attachment\";\nimport type { DictationAdapter } from \"../../adapters/speech\";\nimport type { SendOptions } from \"../interfaces/composer-runtime-core\";\nimport type { ThreadRuntimeCore } from \"../interfaces/thread-runtime-core\";\nimport { BaseComposerRuntimeCore } from \"./base-composer-runtime-core\";\n\nexport class DefaultEditComposerRuntimeCore extends BaseComposerRuntimeCore {\n public get canCancel() {\n return true;\n }\n\n // An edit composer is the message it is editing, so its draft stays in place\n // until the edit lands rather than moving into a submission row.\n protected override get detachesDraftOnSend() {\n return false;\n }\n\n public get canSend() {\n return !this.isEmpty && !this.runtime.voice && !this.isSubmitting;\n }\n\n protected getAttachmentAdapter() {\n return this.runtime.adapters?.attachments;\n }\n\n protected getDictationAdapter() {\n return this.runtime.adapters?.dictation;\n }\n\n private _nonTextPassthrough: readonly ThreadMessage[\"content\"][number][];\n private _parentId: string | null;\n private _sourceId: string | null;\n private runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n };\n private endEditCallback: () => void;\n private _ended = false;\n\n constructor(\n runtime: ThreadRuntimeCore & {\n adapters?:\n | {\n attachments?: AttachmentAdapter | undefined;\n dictation?: DictationAdapter | undefined;\n }\n | undefined;\n },\n endEditCallback: () => void,\n { parentId, message }: { parentId: string | null; message: ThreadMessage },\n ) {\n super();\n this.runtime = runtime;\n let lastHasVoice = runtime.voice !== undefined;\n const unsubscribe = runtime.subscribe(() => {\n const hasVoice = runtime.voice !== undefined;\n if (hasVoice === lastHasVoice) return;\n lastHasVoice = hasVoice;\n this._notifySubscribers();\n });\n this.endEditCallback = () => {\n unsubscribe();\n endEditCallback();\n };\n this._parentId = parentId;\n this._sourceId = message.id;\n this.setText(getThreadMessageText(message));\n\n this.setRole(message.role);\n\n let attachments: readonly CompleteAttachment[];\n if (message.role === \"user\") {\n attachments = [\n ...(message.attachments ?? []),\n ...liftNonTextParts(message.content),\n ];\n this._nonTextPassthrough = [];\n } else {\n attachments = message.attachments ?? [];\n this._nonTextPassthrough = message.content.filter(\n (p) => p.type !== \"text\",\n );\n }\n this.setAttachments(attachments);\n\n this.setRunConfig({ ...runtime.composer.runConfig });\n }\n\n public get parentId() {\n return this._parentId;\n }\n\n public get sourceId() {\n return this._sourceId;\n }\n\n public async handleSend(\n message: Omit<AppendMessage, \"parentId\" | \"sourceId\">,\n options?: SendOptions,\n ) {\n const content =\n this._nonTextPassthrough.length > 0\n ? ([\n ...message.content,\n ...this._nonTextPassthrough,\n ] as AppendMessage[\"content\"])\n : message.content;\n const appendTask = this.runtime.append({\n ...message,\n content,\n parentId: this._parentId,\n sourceId: this._sourceId,\n startRun: options?.startRun,\n });\n\n this.handleCancel();\n return appendTask;\n }\n\n public handleCancel() {\n if (this._ended) return;\n this._ended = true;\n void this.reset().catch((error: unknown) => {\n console.error(\"[assistant-ui] Failed to clear cancelled edit\", error);\n });\n this.endEditCallback();\n this._notifySubscribers();\n }\n}\n"],"mappings":";;;;AAUA,IAAaU,iCAAb,cAAoDD,wBAAwB;CAC1E,IAAWE,YAAY;EACrB,OAAO;CACT;CAIA,IAAuBC,sBAAsB;EAC3C,OAAO;CACT;CAEA,IAAWC,UAAU;EACnB,OAAO,CAAC,KAAKC,WAAW,CAAC,KAAKC,QAAQC,SAAS,CAAC,KAAKC;CACvD;CAEA,uBAAiC;EAC/B,OAAO,KAAKF,QAAQI,UAAUC;CAChC;CAEA,sBAAgC;EAC9B,OAAO,KAAKL,QAAQI,UAAUG;CAChC;CAEA;CACA;CACA;CACA;CAQA;CACA,SAAiB;CAEjBM,YACEb,SAQAW,iBACA,EAAEG,UAAUC,WACZ;EACA,MAAM;EACN,KAAKf,UAAUA;EACf,IAAIgB,eAAehB,QAAQC,UAAUgB,KAAAA;EACrC,MAAMC,cAAclB,QAAQmB,gBAAgB;GAC1C,MAAMC,WAAWpB,QAAQC,UAAUgB,KAAAA;GACnC,IAAIG,aAAaJ,cAAc;GAC/BA,eAAeI;GACf,KAAKC,mBAAmB;EAC1B,CAAC;EACD,KAAKV,wBAAwB;GAC3BO,YAAY;GACZP,gBAAgB;EAClB;EACA,KAAKF,YAAYK;EACjB,KAAKJ,YAAYK,QAAQO;EACzB,KAAKC,QAAQnC,qBAAqB2B,OAAO,CAAC;EAE1C,KAAKS,QAAQT,QAAQU,IAAI;EAEzB,IAAIpB;EACJ,IAAIU,QAAQU,SAAS,QAAQ;GAC3BpB,cAAc,CACZ,GAAIU,QAAQV,eAAe,CAAA,GAC3B,GAAGhB,iBAAiB0B,QAAQW,OAAO,CAAC;GAEtC,KAAKlB,sBAAsB,CAAA;EAC7B,OAAO;GACLH,cAAcU,QAAQV,eAAe,CAAA;GACrC,KAAKG,sBAAsBO,QAAQW,QAAQC,QACxCC,MAAMA,EA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