@assistant-ui/core 0.3.19 → 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 (934) hide show
  1. package/dist/adapters/attachment.d.ts +50 -43
  2. package/dist/adapters/attachment.d.ts.map +1 -1
  3. package/dist/adapters/attachment.js +52 -21
  4. package/dist/adapters/attachment.js.map +1 -1
  5. package/dist/adapters/directive-formatter.d.ts +2 -5
  6. package/dist/adapters/directive-formatter.d.ts.map +1 -1
  7. package/dist/adapters/feedback.d.ts +7 -8
  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 +63 -65
  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 +19 -22
  17. package/dist/adapters/suggestion.d.ts.map +1 -1
  18. package/dist/adapters/thread-history.d.ts +60 -58
  19. package/dist/adapters/thread-history.d.ts.map +1 -1
  20. package/dist/adapters/trigger.d.ts +8 -11
  21. package/dist/adapters/trigger.d.ts.map +1 -1
  22. package/dist/adapters/voice.d.ts +50 -45
  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 +1 -4
  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 +20 -23
  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 +28 -30
  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 +24 -27
  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 +51 -39
  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 +9 -12
  54. package/dist/model-context/registry-handles.d.ts.map +1 -1
  55. package/dist/model-context/registry.d.ts +15 -18
  56. package/dist/model-context/registry.d.ts.map +1 -1
  57. package/dist/model-context/tool-call-text.d.ts +15 -17
  58. package/dist/model-context/tool-call-text.d.ts.map +1 -1
  59. package/dist/model-context/tool.d.ts +12 -14
  60. package/dist/model-context/tool.d.ts.map +1 -1
  61. package/dist/model-context/types.d.ts +40 -43
  62. package/dist/model-context/types.d.ts.map +1 -1
  63. package/dist/react/AssistantProvider.d.ts +9 -12
  64. package/dist/react/AssistantProvider.d.ts.map +1 -1
  65. package/dist/react/AssistantRuntimeProvider.d.ts +23 -26
  66. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  67. package/dist/react/RuntimeAdapter.d.ts +4 -8
  68. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  69. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +28 -23
  70. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  71. package/dist/react/adapters/LocalStorageThreadListAdapter.js +77 -58
  72. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  73. package/dist/react/adapters/TitleGenerationAdapter.d.ts +4 -7
  74. package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
  75. package/dist/react/client/AdaptedRemoteThread.d.ts +6 -9
  76. package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
  77. package/dist/react/client/DataRenderers.d.ts +2 -5
  78. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  79. package/dist/react/client/InMemoryThreadList.d.ts +9 -12
  80. package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
  81. package/dist/react/client/Interactables.d.ts +3 -6
  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 +34 -37
  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 +10 -12
  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 -11
  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 +2 -5
  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 -9
  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 +42 -46
  109. package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
  110. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +8 -11
  111. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
  112. package/dist/react/interactables-legacy/useInteractableState.d.ts +7 -9
  113. package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
  114. package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +23 -14
  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 +15 -18
  119. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
  120. package/dist/react/model-context/define-toolkit.d.ts +13 -6
  121. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  122. package/dist/react/model-context/external-tool.d.ts +1 -4
  123. package/dist/react/model-context/external-tool.d.ts.map +1 -1
  124. package/dist/react/model-context/human-tool.d.ts +3 -6
  125. package/dist/react/model-context/human-tool.d.ts.map +1 -1
  126. package/dist/react/model-context/interactableTool.d.ts +26 -29
  127. package/dist/react/model-context/interactableTool.d.ts.map +1 -1
  128. package/dist/react/model-context/makeAssistantDataUI.d.ts +6 -9
  129. package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
  130. package/dist/react/model-context/makeAssistantTool.d.ts +6 -9
  131. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  132. package/dist/react/model-context/makeAssistantToolUI.d.ts +6 -9
  133. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  134. package/dist/react/model-context/provider-tool.d.ts +5 -7
  135. package/dist/react/model-context/provider-tool.d.ts.map +1 -1
  136. package/dist/react/model-context/stub-tool.d.ts +1 -4
  137. package/dist/react/model-context/stub-tool.d.ts.map +1 -1
  138. package/dist/react/model-context/toolbox.d.ts +44 -32
  139. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  140. package/dist/react/model-context/useAssistantContext.d.ts +3 -6
  141. package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
  142. package/dist/react/model-context/useAssistantDataUI.d.ts +7 -10
  143. package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
  144. package/dist/react/model-context/useAssistantInstructions.d.ts +3 -6
  145. package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
  146. package/dist/react/model-context/useAssistantTool.d.ts +9 -13
  147. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  148. package/dist/react/model-context/useAssistantToolUI.d.ts +13 -16
  149. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  150. package/dist/react/model-context/useAuiToolOverrides.d.ts +3 -5
  151. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
  152. package/dist/react/model-context/useInlineRender.d.ts +3 -6
  153. package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
  154. package/dist/react/model-context/useInteractable.d.ts +40 -40
  155. package/dist/react/model-context/useInteractable.d.ts.map +1 -1
  156. package/dist/react/model-context/useInteractableState.d.ts +10 -9
  157. package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
  158. package/dist/react/model-context/useInteractableVersions.d.ts +4 -7
  159. package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
  160. package/dist/react/model-context/useToolArgsStatus.d.ts +7 -9
  161. package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
  162. package/dist/react/primitive-hooks/useActionBarCopy.d.ts +7 -10
  163. package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
  164. package/dist/react/primitive-hooks/useActionBarEdit.d.ts +3 -6
  165. package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
  166. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +6 -9
  167. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
  168. package/dist/react/primitive-hooks/useActionBarReload.d.ts +3 -6
  169. package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
  170. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +3 -6
  171. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
  172. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +3 -6
  173. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
  174. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +3 -6
  175. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
  176. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +3 -6
  177. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
  178. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +4 -7
  179. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
  180. package/dist/react/primitive-hooks/useComposerCancel.d.ts +3 -6
  181. package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
  182. package/dist/react/primitive-hooks/useComposerDictate.d.ts +3 -6
  183. package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
  184. package/dist/react/primitive-hooks/useComposerSend.d.ts +4 -7
  185. package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
  186. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +2 -5
  187. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
  188. package/dist/react/primitive-hooks/useEditComposerSend.d.ts +3 -6
  189. package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
  190. package/dist/react/primitive-hooks/useMessageBranching.d.ts +5 -8
  191. package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
  192. package/dist/react/primitive-hooks/useMessageError.d.ts +1 -4
  193. package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
  194. package/dist/react/primitive-hooks/useMessageReload.d.ts +3 -6
  195. package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
  196. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +7 -10
  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 +1 -4
  201. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
  202. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +1 -4
  203. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
  204. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +2 -5
  205. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
  206. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +2 -5
  207. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
  208. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +2 -5
  209. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
  210. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +2 -5
  211. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
  212. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +3 -6
  213. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
  214. package/dist/react/primitive-hooks/useThreadListNew.d.ts +2 -5
  215. package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
  216. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +1 -4
  217. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
  218. package/dist/react/primitive-hooks/useThreadMessages.d.ts +2 -5
  219. package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
  220. package/dist/react/primitive-hooks/useVoice.d.ts +8 -11
  221. package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
  222. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +27 -29
  223. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
  224. package/dist/react/primitives/composer/ComposerAttachments.d.ts +26 -28
  225. package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
  226. package/dist/react/primitives/composer/ComposerIf.d.ts +13 -13
  227. package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
  228. package/dist/react/primitives/composer/ComposerQueue.d.ts +13 -17
  229. package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
  230. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +30 -33
  231. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
  232. package/dist/react/primitives/generativeUI/GenerativeUI.js +42 -33
  233. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  234. package/dist/react/primitives/message/MessageAttachments.d.ts +30 -28
  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 +122 -120
  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 +208 -194
  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 +8 -11
  247. package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
  248. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +4 -7
  249. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
  250. package/dist/react/primitives/part/PartMessages.d.ts +16 -19
  251. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  252. package/dist/react/primitives/thread/ThreadMessages.d.ts +61 -64
  253. package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
  254. package/dist/react/primitives/thread/ThreadSuggestions.d.ts +25 -27
  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 +26 -28
  259. package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  260. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +6 -9
  261. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
  262. package/dist/react/providers/AttachmentByIndexProvider.d.ts +5 -8
  263. package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
  264. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +4 -7
  265. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
  266. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +3 -6
  267. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
  268. package/dist/react/providers/MessageByIdProvider.d.ts +3 -6
  269. package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
  270. package/dist/react/providers/MessageByIndexProvider.d.ts +3 -6
  271. package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
  272. package/dist/react/providers/PartByIndexProvider.d.ts +3 -6
  273. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
  274. package/dist/react/providers/QueueItemByIndexProvider.d.ts +4 -7
  275. package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
  276. package/dist/react/providers/ReadonlyThreadProvider.d.ts +7 -10
  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 +4 -7
  280. package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
  281. package/dist/react/providers/TextMessagePartProvider.d.ts +4 -7
  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 +4 -7
  286. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
  287. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +4 -8
  288. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
  289. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +210 -219
  290. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  291. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +70 -46
  292. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  293. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +186 -198
  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 +17 -23
  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 +10 -11
  302. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
  303. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +11 -14
  304. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
  305. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +6 -8
  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 +9 -12
  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 +123 -118
  314. package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
  315. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +7 -10
  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 +3 -6
  320. package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
  321. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +2 -5
  322. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
  323. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +7 -10
  324. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  325. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +426 -216
  326. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  327. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +15 -18
  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 +146 -125
  332. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  333. package/dist/react/runtimes/cloud/auiV0.js +120 -8
  334. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  335. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +13 -15
  336. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
  337. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +5 -7
  338. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
  339. package/dist/react/runtimes/cloud/sdkIdentity.d.ts +2 -5
  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 +3 -6
  343. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  344. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +9 -11
  345. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  346. package/dist/react/runtimes/createMessageConverter.d.ts +15 -19
  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 +14 -17
  350. package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
  351. package/dist/react/runtimes/external-message-converter.d.ts +17 -21
  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 +3 -6
  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 +2 -5
  362. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
  363. package/dist/react/runtimes/useLocalRuntime.d.ts +29 -41
  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 +3 -6
  368. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
  369. package/dist/react/runtimes/useRemoteThreadListRuntime.js +2 -2
  370. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  371. package/dist/react/runtimes/useRuntimeAdapters.d.ts +5 -7
  372. package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
  373. package/dist/react/runtimes/useStreamingTiming.d.ts +4 -6
  374. package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
  375. package/dist/react/types/MessagePartComponentTypes.d.ts +72 -70
  376. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
  377. package/dist/react/types/scopes/dataRenderers.d.ts +11 -15
  378. package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
  379. package/dist/react/types/scopes/interactables.d.ts +60 -60
  380. package/dist/react/types/scopes/interactables.d.ts.map +1 -1
  381. package/dist/react/types/scopes/tools.d.ts +21 -24
  382. package/dist/react/types/scopes/tools.d.ts.map +1 -1
  383. package/dist/react/types/store-augmentation.d.ts +10 -11
  384. package/dist/react/types/store-augmentation.d.ts.map +1 -1
  385. package/dist/react/utils/getMessageQuote.d.ts +6 -8
  386. package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
  387. package/dist/react/utils/groupParts.d.ts +35 -37
  388. package/dist/react/utils/groupParts.d.ts.map +1 -1
  389. package/dist/react/utils/useJSONEqual.d.ts +3 -6
  390. package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
  391. package/dist/react/utils/useJSONSchemaDependency.d.ts +3 -6
  392. package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -1
  393. package/dist/runtime/api/assistant-runtime.d.ts +28 -31
  394. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  395. package/dist/runtime/api/attachment-runtime.d.ts +51 -49
  396. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  397. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  398. package/dist/runtime/api/bindings.d.ts +35 -35
  399. package/dist/runtime/api/bindings.d.ts.map +1 -1
  400. package/dist/runtime/api/composer-runtime.d.ts +215 -201
  401. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  402. package/dist/runtime/api/composer-runtime.js +4 -0
  403. package/dist/runtime/api/composer-runtime.js.map +1 -1
  404. package/dist/runtime/api/message-part-runtime.d.ts +31 -30
  405. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  406. package/dist/runtime/api/message-part-runtime.js +25 -2
  407. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  408. package/dist/runtime/api/message-runtime.d.ts +87 -82
  409. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  410. package/dist/runtime/api/message-runtime.js +4 -3
  411. package/dist/runtime/api/message-runtime.js.map +1 -1
  412. package/dist/runtime/api/paths.d.ts +54 -57
  413. package/dist/runtime/api/paths.d.ts.map +1 -1
  414. package/dist/runtime/api/thread-list-item-runtime.d.ts +70 -72
  415. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  416. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  417. package/dist/runtime/api/thread-list-runtime.d.ts +77 -81
  418. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  419. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  420. package/dist/runtime/api/thread-runtime.d.ts +306 -308
  421. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  422. package/dist/runtime/api/thread-runtime.js +2 -1
  423. package/dist/runtime/api/thread-runtime.js.map +1 -1
  424. package/dist/runtime/base/base-assistant-runtime-core.d.ts +9 -12
  425. package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
  426. package/dist/runtime/base/base-composer-runtime-core.d.ts +150 -101
  427. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  428. package/dist/runtime/base/base-composer-runtime-core.js +400 -122
  429. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  430. package/dist/runtime/base/base-thread-runtime-core.d.ts +121 -104
  431. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  432. package/dist/runtime/base/base-thread-runtime-core.js +174 -62
  433. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  434. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +30 -31
  435. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  436. package/dist/runtime/base/default-edit-composer-runtime-core.js +21 -2
  437. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  438. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +28 -31
  439. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  440. package/dist/runtime/base/default-thread-composer-runtime-core.js +23 -2
  441. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  442. package/dist/runtime/branch/external-thread-branch-adapter.d.ts +15 -18
  443. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
  444. package/dist/runtime/interfaces/assistant-runtime-core.d.ts +8 -11
  445. package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
  446. package/dist/runtime/interfaces/composer-runtime-core.d.ts +98 -83
  447. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  448. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +67 -70
  449. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  450. package/dist/runtime/interfaces/thread-runtime-core.d.ts +225 -211
  451. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  452. package/dist/runtime/internal.d.ts +25 -20
  453. package/dist/runtime/internal.d.ts.map +1 -0
  454. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +37 -40
  455. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
  456. package/dist/runtime/queue/message-queue.d.ts +32 -33
  457. package/dist/runtime/queue/message-queue.d.ts.map +1 -1
  458. package/dist/runtime/queue/message-queue.js +10 -2
  459. package/dist/runtime/queue/message-queue.js.map +1 -1
  460. package/dist/runtime/queue/queue-item.d.ts +7 -10
  461. package/dist/runtime/queue/queue-item.d.ts.map +1 -1
  462. package/dist/runtime/utils/abortable-thread-load.d.ts +9 -11
  463. package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
  464. package/dist/runtime/utils/attachment-add-operations.d.ts +16 -15
  465. package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
  466. package/dist/runtime/utils/attachment-add-operations.js +24 -2
  467. package/dist/runtime/utils/attachment-add-operations.js.map +1 -1
  468. package/dist/runtime/utils/attachment-send-operations.d.ts +12 -0
  469. package/dist/runtime/utils/attachment-send-operations.d.ts.map +1 -0
  470. package/dist/runtime/utils/attachment-send-operations.js +34 -0
  471. package/dist/runtime/utils/attachment-send-operations.js.map +1 -0
  472. package/dist/runtime/utils/auto-status.d.ts +11 -13
  473. package/dist/runtime/utils/auto-status.d.ts.map +1 -1
  474. package/dist/runtime/utils/auto-status.js +3 -5
  475. package/dist/runtime/utils/auto-status.js.map +1 -1
  476. package/dist/runtime/utils/chat-model-adapter.d.ts +31 -33
  477. package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
  478. package/dist/runtime/utils/external-message-conversion.d.ts +47 -48
  479. package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
  480. package/dist/runtime/utils/external-message-conversion.js +6 -5
  481. package/dist/runtime/utils/external-message-conversion.js.map +1 -1
  482. package/dist/runtime/utils/external-store-message.d.ts +6 -9
  483. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  484. package/dist/runtime/utils/message-repository-session.d.ts +24 -27
  485. package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
  486. package/dist/runtime/utils/message-repository.d.ts +52 -54
  487. package/dist/runtime/utils/message-repository.d.ts.map +1 -1
  488. package/dist/runtime/utils/message-repository.js +8 -7
  489. package/dist/runtime/utils/message-repository.js.map +1 -1
  490. package/dist/runtime/utils/pending-tool-calls.d.ts +12 -14
  491. package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
  492. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +7 -10
  493. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
  494. package/dist/runtime/utils/runtime-extras-brand.d.ts +6 -9
  495. package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
  496. package/dist/runtime/utils/stored-message-parts.d.ts +21 -0
  497. package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -0
  498. package/dist/runtime/utils/stored-message-parts.js +103 -0
  499. package/dist/runtime/utils/stored-message-parts.js.map +1 -0
  500. package/dist/runtime/utils/streaming-timing.d.ts +23 -26
  501. package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
  502. package/dist/runtime/utils/thread-message-like.d.ts +38 -34
  503. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  504. package/dist/runtime/utils/thread-message-like.js +16 -6
  505. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  506. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +5 -7
  507. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
  508. package/dist/runtime/utils/thread-runtime-lifecycle.js +31 -4
  509. package/dist/runtime/utils/thread-runtime-lifecycle.js.map +1 -1
  510. package/dist/runtime/utils/tool-call-tree.d.ts +10 -13
  511. package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
  512. package/dist/runtime/utils/tool-interactions.d.ts +10 -0
  513. package/dist/runtime/utils/tool-interactions.d.ts.map +1 -0
  514. package/dist/runtime/utils/tool-interactions.js +92 -0
  515. package/dist/runtime/utils/tool-interactions.js.map +1 -0
  516. package/dist/runtimes/assistant-transport/utils.d.ts +1 -4
  517. package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
  518. package/dist/runtimes/external-store/external-store-adapter.d.ts +220 -200
  519. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  520. package/dist/runtimes/external-store/external-store-runtime-core.d.ts +6 -8
  521. package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
  522. package/dist/runtimes/external-store/external-store-runtime-core.js +4 -1
  523. package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
  524. package/dist/runtimes/external-store/external-store-shared-options.d.ts +3 -6
  525. package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
  526. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +40 -43
  527. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  528. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +2 -2
  529. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  530. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +119 -125
  531. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  532. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +71 -18
  533. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  534. package/dist/runtimes/external-store/thread-message-converter.d.ts +5 -8
  535. package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
  536. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +96 -98
  537. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
  538. package/dist/runtimes/inert/InertThreadRuntimeCore.js +3 -0
  539. package/dist/runtimes/inert/InertThreadRuntimeCore.js.map +1 -1
  540. package/dist/runtimes/internal.d.ts +20 -16
  541. package/dist/runtimes/internal.d.ts.map +1 -0
  542. package/dist/runtimes/local/local-runtime-core.d.ts +7 -10
  543. package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
  544. package/dist/runtimes/local/local-runtime-options.d.ts +41 -44
  545. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  546. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +42 -45
  547. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
  548. package/dist/runtimes/local/local-thread-runtime-core.d.ts +94 -93
  549. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  550. package/dist/runtimes/local/local-thread-runtime-core.js +220 -29
  551. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  552. package/dist/runtimes/local/should-continue.d.ts +2 -5
  553. package/dist/runtimes/local/should-continue.d.ts.map +1 -1
  554. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +77 -55
  555. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  556. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +28 -1
  557. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  558. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +12 -15
  559. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  560. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +3 -6
  561. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
  562. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +2 -5
  563. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  564. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +34 -31
  565. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
  566. package/dist/runtimes/remote-thread-list/optimistic-state.js +8 -3
  567. package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
  568. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +60 -63
  569. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  570. package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -1
  571. package/dist/runtimes/remote-thread-list/title-generation.d.ts +31 -33
  572. package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
  573. package/dist/runtimes/remote-thread-list/title.d.ts +5 -8
  574. package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
  575. package/dist/runtimes/remote-thread-list/types.d.ts +119 -121
  576. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  577. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +147 -149
  578. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
  579. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +22 -7
  580. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  581. package/dist/store/clients/chain-of-thought-client.d.ts +8 -11
  582. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  583. package/dist/store/clients/external-thread.d.ts +56 -58
  584. package/dist/store/clients/external-thread.d.ts.map +1 -1
  585. package/dist/store/clients/external-thread.js +1270 -741
  586. package/dist/store/clients/external-thread.js.map +1 -1
  587. package/dist/store/clients/model-context-client.d.ts +2 -5
  588. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  589. package/dist/store/clients/no-op-composer-client.d.ts +3 -6
  590. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  591. package/dist/store/clients/no-op-composer-client.js +3 -1
  592. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  593. package/dist/store/clients/runtime-adapter.d.ts +2 -5
  594. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  595. package/dist/store/clients/single-thread-list.d.ts +4 -6
  596. package/dist/store/clients/single-thread-list.d.ts.map +1 -1
  597. package/dist/store/clients/submission-message.d.ts +8 -0
  598. package/dist/store/clients/submission-message.d.ts.map +1 -0
  599. package/dist/store/clients/submission-message.js +22 -0
  600. package/dist/store/clients/submission-message.js.map +1 -0
  601. package/dist/store/clients/suggestions.d.ts +8 -11
  602. package/dist/store/clients/suggestions.d.ts.map +1 -1
  603. package/dist/store/clients/thread-message-client.d.ts +12 -12
  604. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  605. package/dist/store/clients/thread-message-client.js +81 -82
  606. package/dist/store/clients/thread-message-client.js.map +1 -1
  607. package/dist/store/clients/thread-selection-events.d.ts +1 -4
  608. package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
  609. package/dist/store/clients/thread-tasks.d.ts +7 -10
  610. package/dist/store/clients/thread-tasks.d.ts.map +1 -1
  611. package/dist/store/env.d.ts +1 -4
  612. package/dist/store/env.d.ts.map +1 -1
  613. package/dist/store/index.d.ts +33 -36
  614. package/dist/store/index.d.ts.map +1 -0
  615. package/dist/store/index.js +5 -5
  616. package/dist/store/internal.d.ts +12 -12
  617. package/dist/store/internal.d.ts.map +1 -0
  618. package/dist/store/internal.js +2 -2
  619. package/dist/store/primitive-predicates.d.ts +14 -16
  620. package/dist/store/primitive-predicates.d.ts.map +1 -1
  621. package/dist/store/primitive-predicates.js +10 -5
  622. package/dist/store/primitive-predicates.js.map +1 -1
  623. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +4 -7
  624. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  625. package/dist/store/runtime-clients/composer-runtime-client.d.ts +11 -14
  626. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  627. package/dist/store/runtime-clients/composer-runtime-client.js +65 -62
  628. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  629. package/dist/store/runtime-clients/handle-runtime-action.d.ts +1 -4
  630. package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
  631. package/dist/store/runtime-clients/handle-thread-list-action.d.ts +1 -4
  632. package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
  633. package/dist/store/runtime-clients/liveRef.d.ts +2 -5
  634. package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
  635. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +4 -7
  636. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  637. package/dist/store/runtime-clients/message-part-runtime-client.js +26 -16
  638. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  639. package/dist/store/runtime-clients/message-runtime-client.d.ts +10 -11
  640. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  641. package/dist/store/runtime-clients/message-runtime-client.js +121 -113
  642. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  643. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +5 -8
  644. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  645. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +6 -9
  646. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  647. package/dist/store/runtime-clients/thread-runtime-client.d.ts +4 -7
  648. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  649. package/dist/store/runtime-clients/thread-runtime-client.js +221 -158
  650. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  651. package/dist/store/runtime-clients/useSubscribable.d.ts +3 -6
  652. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
  653. package/dist/store/scope-registration.d.ts +28 -29
  654. package/dist/store/scope-registration.d.ts.map +1 -1
  655. package/dist/store/scopes/attachment.d.ts +19 -22
  656. package/dist/store/scopes/attachment.d.ts.map +1 -1
  657. package/dist/store/scopes/chain-of-thought.d.ts +33 -35
  658. package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
  659. package/dist/store/scopes/composer.d.ts +147 -135
  660. package/dist/store/scopes/composer.d.ts.map +1 -1
  661. package/dist/store/scopes/message.d.ts +119 -112
  662. package/dist/store/scopes/message.d.ts.map +1 -1
  663. package/dist/store/scopes/model-context.d.ts +10 -13
  664. package/dist/store/scopes/model-context.d.ts.map +1 -1
  665. package/dist/store/scopes/part.d.ts +53 -50
  666. package/dist/store/scopes/part.d.ts.map +1 -1
  667. package/dist/store/scopes/queue-item.d.ts +21 -23
  668. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  669. package/dist/store/scopes/suggestion.d.ts +14 -17
  670. package/dist/store/scopes/suggestion.d.ts.map +1 -1
  671. package/dist/store/scopes/suggestions.d.ts +18 -21
  672. package/dist/store/scopes/suggestions.d.ts.map +1 -1
  673. package/dist/store/scopes/task.d.ts +27 -30
  674. package/dist/store/scopes/task.d.ts.map +1 -1
  675. package/dist/store/scopes/thread-list-item.d.ts +68 -71
  676. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  677. package/dist/store/scopes/thread.d.ts +197 -200
  678. package/dist/store/scopes/thread.d.ts.map +1 -1
  679. package/dist/store/scopes/threads.d.ts +49 -52
  680. package/dist/store/scopes/threads.d.ts.map +1 -1
  681. package/dist/subscribable/subscribable.d.ts +73 -69
  682. package/dist/subscribable/subscribable.d.ts.map +1 -1
  683. package/dist/subscribable/subscribable.js +35 -7
  684. package/dist/subscribable/subscribable.js.map +1 -1
  685. package/dist/types/attachment.d.ts +35 -37
  686. package/dist/types/attachment.d.ts.map +1 -1
  687. package/dist/types/augmentations.d.ts +7 -8
  688. package/dist/types/augmentations.d.ts.map +1 -1
  689. package/dist/types/directive.d.ts +13 -16
  690. package/dist/types/directive.d.ts.map +1 -1
  691. package/dist/types/error.d.ts +15 -17
  692. package/dist/types/error.d.ts.map +1 -1
  693. package/dist/types/index.d.ts +7 -7
  694. package/dist/types/index.d.ts.map +1 -0
  695. package/dist/types/message.d.ts +358 -318
  696. package/dist/types/message.d.ts.map +1 -1
  697. package/dist/types/message.js.map +1 -1
  698. package/dist/types/quote.d.ts +3 -6
  699. package/dist/types/quote.d.ts.map +1 -1
  700. package/dist/types/trigger.d.ts +10 -13
  701. package/dist/types/trigger.d.ts.map +1 -1
  702. package/dist/types/unsubscribe.d.ts +1 -4
  703. package/dist/types/unsubscribe.d.ts.map +1 -1
  704. package/dist/utils/abortable-iterable.d.ts +2 -5
  705. package/dist/utils/abortable-iterable.d.ts.map +1 -1
  706. package/dist/utils/composite-context-provider.d.ts +9 -13
  707. package/dist/utils/composite-context-provider.d.ts.map +1 -1
  708. package/dist/utils/data-url.d.ts +16 -19
  709. package/dist/utils/data-url.d.ts.map +1 -1
  710. package/dist/utils/getGroupStatus.d.ts +19 -21
  711. package/dist/utils/getGroupStatus.d.ts.map +1 -1
  712. package/dist/utils/id.d.ts +3 -6
  713. package/dist/utils/id.d.ts.map +1 -1
  714. package/dist/utils/image-media-type.d.ts +1 -4
  715. package/dist/utils/image-media-type.d.ts.map +1 -1
  716. package/dist/utils/invoke-user-callback.d.ts +1 -4
  717. package/dist/utils/invoke-user-callback.d.ts.map +1 -1
  718. package/dist/utils/json/is-json-equal.d.ts +1 -4
  719. package/dist/utils/json/is-json-equal.d.ts.map +1 -1
  720. package/dist/utils/json/is-json.d.ts +5 -8
  721. package/dist/utils/json/is-json.d.ts.map +1 -1
  722. package/dist/utils/json/stable-stringify-tool-args.d.ts +3 -6
  723. package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
  724. package/dist/utils/normalizePartStatus.d.ts +6 -8
  725. package/dist/utils/normalizePartStatus.d.ts.map +1 -1
  726. package/dist/utils/normalizePartStatus.js +3 -2
  727. package/dist/utils/normalizePartStatus.js.map +1 -1
  728. package/dist/utils/notify-event-listeners.d.ts +2 -4
  729. package/dist/utils/notify-event-listeners.d.ts.map +1 -1
  730. package/dist/utils/record.d.ts +1 -4
  731. package/dist/utils/record.d.ts.map +1 -1
  732. package/dist/utils/silent-runtime-action.d.ts +2 -5
  733. package/dist/utils/silent-runtime-action.d.ts.map +1 -1
  734. package/dist/utils/text.d.ts +2 -5
  735. package/dist/utils/text.d.ts.map +1 -1
  736. package/dist/utils/wire-media.d.ts +3 -6
  737. package/dist/utils/wire-media.d.ts.map +1 -1
  738. package/package.json +15 -13
  739. package/src/adapters/attachment.test.ts +98 -1
  740. package/src/adapters/attachment.ts +77 -20
  741. package/src/adapters/feedback.ts +1 -0
  742. package/src/adapters/speech.test.ts +94 -0
  743. package/src/adapters/speech.ts +16 -2
  744. package/src/adapters/thread-history.ts +16 -5
  745. package/src/adapters/voice.test.ts +169 -0
  746. package/src/adapters/voice.ts +25 -4
  747. package/src/index.ts +14 -2
  748. package/src/internal.ts +7 -0
  749. package/src/model-context/frame/host.test.ts +51 -1
  750. package/src/model-context/frame/host.ts +3 -1
  751. package/src/model-context/frame/provider.test.ts +106 -20
  752. package/src/model-context/frame/provider.ts +8 -1
  753. package/src/model-context/frame/validate.ts +57 -0
  754. package/src/model-context/interactable-composer-metadata.test.ts +82 -0
  755. package/src/model-context/interactable-composer-metadata.ts +45 -2
  756. package/src/react/RuntimeAdapter.test.ts +4 -1
  757. package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +711 -0
  758. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +125 -109
  759. package/src/react/client/Interactables.test.ts +865 -8
  760. package/src/react/client/Interactables.ts +325 -45
  761. package/src/react/client/RemoteThreadList.concurrent.test.tsx +9 -3
  762. package/src/react/client/RemoteThreadList.initialize-failure.test.ts +124 -0
  763. package/src/react/client/RemoteThreadList.test.ts +5 -6
  764. package/src/react/client/RemoteThreadList.ts +6 -0
  765. package/src/react/client/Tools.ts +2 -3
  766. package/src/react/client/interactable-model-context.test.ts +56 -13
  767. package/src/react/client/interactable-model-context.ts +48 -23
  768. package/src/react/index.ts +2 -2
  769. package/src/react/interactables-legacy/Interactables.test.ts +221 -4
  770. package/src/react/interactables-legacy/Interactables.ts +25 -14
  771. package/src/react/interactables-legacy/interactable-model-context.ts +26 -24
  772. package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +40 -22
  773. package/src/react/interactables-shared/useInteractablePersistenceQueue.test.tsx +22 -2
  774. package/src/react/interactables-shared/useInteractablePersistenceQueue.ts +63 -11
  775. package/src/react/model-context/useInteractable.test.tsx +56 -29
  776. package/src/react/primitive-hooks/useActionBarCopy.test.ts +5 -5
  777. package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +33 -0
  778. package/src/react/primitive-hooks/useSuggestionTrigger.ts +7 -4
  779. package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +170 -0
  780. package/src/react/primitives/generativeUI/GenerativeUI.tsx +43 -28
  781. package/src/react/primitives/message/MessageAttachments.test.tsx +2 -6
  782. package/src/react/primitives/message/MessageAttachments.tsx +14 -8
  783. package/src/react/primitives/message/MessageGroupedParts.test.tsx +155 -8
  784. package/src/react/primitives/message/MessageGroupedParts.tsx +19 -6
  785. package/src/react/primitives/message/MessageParts.test.tsx +84 -0
  786. package/src/react/primitives/message/MessageParts.tool-interaction.test.tsx +69 -0
  787. package/src/react/primitives/message/MessageParts.tsx +29 -8
  788. package/src/react/primitives/thread/ThreadMessages.test.tsx +25 -7
  789. package/src/react/primitives/thread/ThreadSuggestions.test.tsx +97 -0
  790. package/src/react/primitives/thread/ThreadSuggestions.tsx +29 -6
  791. package/src/react/providers/ReadonlyThreadProvider.tsx +2 -2
  792. package/src/react/providers/TextMessagePartProvider.tsx +3 -0
  793. package/src/react/runtimes/RemoteThreadListHookInstanceManager.layout.test.tsx +62 -0
  794. package/src/react/runtimes/RemoteThreadListHookInstanceManager.retry.test.tsx +2 -2
  795. package/src/react/runtimes/RemoteThreadListHookInstanceManager.running.test.tsx +93 -0
  796. package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +181 -21
  797. package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +62 -17
  798. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +112 -77
  799. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +19 -3
  800. package/src/react/runtimes/RemoteThreadResource.ts +5 -2
  801. package/src/react/runtimes/assistant-transport/replayBoundaryStream.test.ts +3 -1
  802. package/src/react/runtimes/assistant-transport/replayBoundaryStream.ts +10 -2
  803. package/src/react/runtimes/assistant-transport/runManager.ts +3 -0
  804. package/src/react/runtimes/assistant-transport/transport-parentid.test.tsx +57 -0
  805. package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +73 -46
  806. package/src/react/runtimes/assistant-transport/transport-thread-id.test.tsx +571 -0
  807. package/src/react/runtimes/assistant-transport/types.ts +9 -1
  808. package/src/react/runtimes/assistant-transport/useAssistantTransport.spec.md +10 -0
  809. package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +108 -1
  810. package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.ts +33 -9
  811. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.integration.test.tsx +289 -0
  812. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.copy.test.tsx +471 -0
  813. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.engagement.test.tsx +330 -0
  814. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +78 -2
  815. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +463 -2
  816. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +595 -227
  817. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +33 -4
  818. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +7 -3
  819. package/src/react/runtimes/cloud/auiV0.ts +275 -6
  820. package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +873 -0
  821. package/src/react/runtimes/createMessageConverter.ts +9 -3
  822. package/src/react/runtimes/external-message-converter.test.ts +7 -3
  823. package/src/react/runtimes/external-store-history-copy.ts +223 -0
  824. package/src/react/runtimes/remote-thread-hook-on-tap.test.ts +2 -1
  825. package/src/react/runtimes/useExternalStoreRuntime.history-copy.test.tsx +483 -0
  826. package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +84 -3
  827. package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +6 -2
  828. package/src/react/runtimes/useExternalStoreRuntime.ts +25 -5
  829. package/src/react/runtimes/useLocalRuntime.test.tsx +145 -1
  830. package/src/react/runtimes/useLocalRuntime.ts +8 -5
  831. package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +84 -4
  832. package/src/react/runtimes/useRemoteThreadListRuntime.ts +5 -1
  833. package/src/react/types/MessagePartComponentTypes.ts +10 -0
  834. package/src/react/types/scopes/interactables.ts +3 -0
  835. package/src/runtime/api/attachment-runtime.ts +10 -5
  836. package/src/runtime/api/bindings.ts +6 -1
  837. package/src/runtime/api/composer-runtime.ts +29 -6
  838. package/src/runtime/api/message-part-runtime.test.ts +215 -0
  839. package/src/runtime/api/message-part-runtime.ts +44 -1
  840. package/src/runtime/api/message-runtime.test.ts +112 -2
  841. package/src/runtime/api/message-runtime.ts +25 -7
  842. package/src/runtime/api/thread-list-item-runtime.ts +5 -5
  843. package/src/runtime/api/thread-list-runtime.ts +3 -3
  844. package/src/runtime/api/thread-runtime.test.ts +59 -0
  845. package/src/runtime/api/thread-runtime.ts +21 -11
  846. package/src/runtime/base/base-composer-runtime-core.ts +548 -153
  847. package/src/runtime/base/base-thread-runtime-core.test.ts +1614 -136
  848. package/src/runtime/base/base-thread-runtime-core.ts +236 -46
  849. package/src/runtime/base/default-edit-composer-runtime-core.ts +24 -2
  850. package/src/runtime/base/default-thread-composer-runtime-core.ts +33 -3
  851. package/src/runtime/interfaces/composer-runtime-core.ts +19 -0
  852. package/src/runtime/interfaces/thread-runtime-core.ts +24 -1
  853. package/src/runtime/queue/message-queue.ts +11 -1
  854. package/src/runtime/utils/attachment-add-operations.ts +45 -2
  855. package/src/runtime/utils/attachment-send-operations.ts +54 -0
  856. package/src/runtime/utils/auto-status.test.ts +54 -0
  857. package/src/runtime/utils/auto-status.ts +3 -10
  858. package/src/runtime/utils/external-message-conversion.test.ts +91 -0
  859. package/src/runtime/utils/external-message-conversion.ts +9 -6
  860. package/src/runtime/utils/message-repository.test.ts +69 -1
  861. package/src/runtime/utils/message-repository.ts +14 -7
  862. package/src/runtime/utils/stored-message-parts.ts +216 -0
  863. package/src/runtime/utils/thread-message-like.test.ts +58 -0
  864. package/src/runtime/utils/thread-message-like.ts +79 -48
  865. package/src/runtime/utils/thread-runtime-lifecycle.test.ts +67 -0
  866. package/src/runtime/utils/thread-runtime-lifecycle.ts +42 -8
  867. package/src/runtime/utils/tool-interactions.test.ts +193 -0
  868. package/src/runtime/utils/tool-interactions.ts +147 -0
  869. package/src/runtimes/external-store/external-store-adapter.ts +25 -0
  870. package/src/runtimes/external-store/external-store-runtime-core.ts +10 -2
  871. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +2 -2
  872. package/src/runtimes/external-store/external-store-thread-runtime-core.test.ts +49 -0
  873. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +114 -32
  874. package/src/runtimes/inert/InertThreadRuntimeCore.test.ts +127 -56
  875. package/src/runtimes/inert/InertThreadRuntimeCore.ts +10 -1
  876. package/src/runtimes/local/local-thread-runtime-core.edit-cancellation.test.ts +70 -0
  877. package/src/runtimes/local/local-thread-runtime-core.test.ts +1866 -169
  878. package/src/runtimes/local/local-thread-runtime-core.ts +365 -40
  879. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +53 -1
  880. package/src/runtimes/remote-thread-list/optimistic-state.ts +8 -3
  881. package/src/runtimes/tool-invocations/EDGE_CASES.md +19 -4
  882. package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +392 -39
  883. package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +31 -8
  884. package/src/store/clients/external-thread.test.ts +145 -0
  885. package/src/store/clients/external-thread.ts +669 -144
  886. package/src/store/clients/model-context-client.test.ts +8 -8
  887. package/src/store/clients/no-op-composer-client.ts +2 -0
  888. package/src/store/clients/submission-message.ts +27 -0
  889. package/src/store/clients/thread-message-client.test.ts +39 -0
  890. package/src/store/clients/thread-message-client.ts +13 -6
  891. package/src/store/index.ts +2 -2
  892. package/src/store/internal.ts +1 -0
  893. package/src/store/primitive-predicates.test.ts +119 -0
  894. package/src/store/primitive-predicates.ts +19 -4
  895. package/src/store/runtime-clients/composer-runtime-client.ts +4 -3
  896. package/src/store/runtime-clients/message-part-runtime-client.test.ts +42 -0
  897. package/src/store/runtime-clients/message-part-runtime-client.ts +4 -0
  898. package/src/store/runtime-clients/message-runtime-client.ts +5 -0
  899. package/src/store/runtime-clients/thread-runtime-client.test.tsx +243 -0
  900. package/src/store/runtime-clients/thread-runtime-client.ts +46 -9
  901. package/src/store/scopes/composer.ts +22 -4
  902. package/src/store/scopes/message.ts +12 -1
  903. package/src/store/scopes/part.ts +8 -0
  904. package/src/subscribable/subscribable.test.ts +205 -3
  905. package/src/subscribable/subscribable.ts +49 -7
  906. package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +95 -1
  907. package/src/tests/attachment-adapters.test.ts +16 -1
  908. package/src/tests/auiV0Encode.test.ts +412 -1
  909. package/src/tests/base-composer-runtime-core-addAttachment.test.ts +6 -6
  910. package/src/tests/base-composer-runtime-core-send.test.ts +722 -29
  911. package/src/tests/base-composer-runtime-core.test.ts +212 -5
  912. package/src/tests/composer-can-cancel.test.ts +35 -6
  913. package/src/tests/composer-can-send.test.ts +120 -1
  914. package/src/tests/composer-submission.test.tsx +796 -0
  915. package/src/tests/default-edit-composer-runtime-core.test.ts +149 -2
  916. package/src/tests/external-store-thread-list-runtime-core.test.ts +111 -0
  917. package/src/tests/external-store-thread-runtime-core-adapter.test.ts +810 -28
  918. package/src/tests/external-store-thread-runtime-core.test.ts +217 -0
  919. package/src/tests/external-thread-attachments.test.tsx +763 -26
  920. package/src/tests/external-thread-feedback.test.tsx +20 -7
  921. package/src/tests/external-thread-isLast.test.tsx +69 -0
  922. package/src/tests/external-thread-parity.test.tsx +1 -1
  923. package/src/tests/get-thread-state-isRunning.test.ts +2 -2
  924. package/src/tests/message-queue.test.ts +45 -10
  925. package/src/tests/remote-thread-list-adapter-switch.test.ts +45 -1
  926. package/src/tests/thread-switch-events.test.tsx +11 -7
  927. package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +2 -1
  928. package/src/types/message.test.ts +19 -0
  929. package/src/types/message.ts +65 -10
  930. package/src/utils/normalizePartStatus.ts +14 -1
  931. package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -16
  932. package/dist/tests/remote-thread-list-test-helpers.d.ts.map +0 -1
  933. package/dist/tests/remote-thread-list-test-helpers.js +0 -59
  934. package/dist/tests/remote-thread-list-test-helpers.js.map +0 -1
@@ -1,10 +1,14 @@
1
1
  import { generateId } from "../../utils/id.js";
2
2
  import { fileMatchesAccept } from "../../adapters/attachment.js";
3
3
  import { getThreadMessageText } from "../../utils/text.js";
4
+ import { createToolInteraction } from "../../runtime/utils/tool-interactions.js";
4
5
  import { toMessagePartStatus } from "../../utils/normalizePartStatus.js";
5
6
  import { resolveToolApprovalResponse } from "../../runtime/utils/resolveToolApprovalResponse.js";
6
7
  import { isAttachmentComplete, isCreateAttachment } from "../../types/attachment.js";
7
8
  import { AttachmentAddOperations, drainAttachmentAdd } from "../../runtime/utils/attachment-add-operations.js";
9
+ import { AttachmentSendOperations } from "../../runtime/utils/attachment-send-operations.js";
10
+ import { ThreadMessageClient } from "./thread-message-client.js";
11
+ import { submissionThreadMessage } from "./submission-message.js";
8
12
  import { ThreadSuggestions } from "./suggestions.js";
9
13
  import { TaskClient, createTaskDeriver, getTaskKey } from "./thread-tasks.js";
10
14
  import { ModelContext } from "./model-context-client.js";
@@ -16,6 +20,7 @@ import { ToolResponse } from "assistant-stream";
16
20
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
17
21
  import { useEffect, useRef, useState } from "@assistant-ui/tap/react-shim";
18
22
  import { resource, withKey } from "@assistant-ui/tap";
23
+ import { useAssistantClientDestroySignal } from "@assistant-ui/store/internal";
19
24
  //#region src/store/clients/external-thread.ts
20
25
  const EMPTY_QUEUE_ITEMS = [];
21
26
  const EMPTY_BRANCH_IDS = [];
@@ -26,17 +31,18 @@ const derivePartStatus = (message, partIndex, part) => {
26
31
  return toMessagePartStatus(message, partIndex, part);
27
32
  };
28
33
  const useMessageClient = (t0) => {
29
- const $ = c(71);
30
- const { message, index, parentId, onEdit, onReload, queue, branches, onRespondToToolApproval, onAddToolResult, onResumeToolCall, attachmentAdapter, submittedFeedback, onSubmitFeedback, speech, onSpeak, onStopSpeaking } = t0;
34
+ const $ = c(73);
35
+ const { message, index, isLast, parentId, onEdit, onReload, queue, branches, onRespondToToolApproval, unstable_onRecordToolInteraction, onAddToolResult, onResumeToolCall, attachmentAdapter, submittedFeedback, onSubmitFeedback, speech, onSpeak, onStopSpeaking } = t0;
31
36
  const [isCopied, setIsCopied] = useState(false);
32
37
  const [isHovering, setIsHovering] = useState(false);
33
38
  let t1;
34
- if ($[0] !== message || $[1] !== onAddToolResult || $[2] !== onRespondToToolApproval || $[3] !== onResumeToolCall) {
39
+ if ($[0] !== message || $[1] !== onAddToolResult || $[2] !== onRespondToToolApproval || $[3] !== onResumeToolCall || $[4] !== unstable_onRecordToolInteraction) {
35
40
  t1 = message.content.map((part, idx) => withKey(idx, PartResource({
36
41
  part,
37
42
  status: derivePartStatus(message, idx, part),
38
43
  messageId: message.id,
39
44
  onRespondToToolApproval,
45
+ unstable_onRecordToolInteraction,
40
46
  onAddToolResult,
41
47
  onResumeToolCall
42
48
  })));
@@ -44,33 +50,34 @@ const useMessageClient = (t0) => {
44
50
  $[1] = onAddToolResult;
45
51
  $[2] = onRespondToToolApproval;
46
52
  $[3] = onResumeToolCall;
47
- $[4] = t1;
48
- } else t1 = $[4];
53
+ $[4] = unstable_onRecordToolInteraction;
54
+ $[5] = t1;
55
+ } else t1 = $[5];
49
56
  const partClients = useClientLookup(t1);
50
57
  let t2;
51
- if ($[5] !== message.attachments) {
58
+ if ($[6] !== message.attachments) {
52
59
  t2 = message.attachments ?? [];
53
- $[5] = message.attachments;
54
- $[6] = t2;
55
- } else t2 = $[6];
60
+ $[6] = message.attachments;
61
+ $[7] = t2;
62
+ } else t2 = $[7];
56
63
  let t3;
57
- if ($[7] !== t2) {
64
+ if ($[8] !== t2) {
58
65
  t3 = t2.map(_temp2);
59
- $[7] = t2;
60
- $[8] = t3;
61
- } else t3 = $[8];
66
+ $[8] = t2;
67
+ $[9] = t3;
68
+ } else t3 = $[9];
62
69
  const attachmentClients = useClientLookup(t3);
63
70
  let t4;
64
- if ($[9] !== onEdit) {
71
+ if ($[10] !== onEdit) {
65
72
  t4 = () => {
66
73
  if (!onEdit) throw new Error("Runtime does not support editing.");
67
74
  };
68
- $[9] = onEdit;
69
- $[10] = t4;
70
- } else t4 = $[10];
75
+ $[10] = onEdit;
76
+ $[11] = t4;
77
+ } else t4 = $[11];
71
78
  const handleBeginEdit = t4;
72
79
  let t5;
73
- if ($[11] !== message.id || $[12] !== onEdit || $[13] !== parentId) {
80
+ if ($[12] !== message.id || $[13] !== onEdit || $[14] !== parentId) {
74
81
  t5 = (msg) => {
75
82
  if (!onEdit) throw new Error("Runtime does not support editing.");
76
83
  onEdit({
@@ -79,14 +86,14 @@ const useMessageClient = (t0) => {
79
86
  sourceId: message.id
80
87
  });
81
88
  };
82
- $[11] = message.id;
83
- $[12] = onEdit;
84
- $[13] = parentId;
85
- $[14] = t5;
86
- } else t5 = $[14];
89
+ $[12] = message.id;
90
+ $[13] = onEdit;
91
+ $[14] = parentId;
92
+ $[15] = t5;
93
+ } else t5 = $[15];
87
94
  const handleSendEdit = t5;
88
95
  let t6;
89
- if ($[15] !== attachmentAdapter || $[16] !== handleBeginEdit || $[17] !== handleSendEdit || $[18] !== message || $[19] !== queue) {
96
+ if ($[16] !== attachmentAdapter || $[17] !== handleBeginEdit || $[18] !== handleSendEdit || $[19] !== message || $[20] !== queue) {
90
97
  t6 = ComposerClientResource({
91
98
  type: "edit",
92
99
  canCancel: true,
@@ -96,57 +103,57 @@ const useMessageClient = (t0) => {
96
103
  queue,
97
104
  attachmentAdapter
98
105
  });
99
- $[15] = attachmentAdapter;
100
- $[16] = handleBeginEdit;
101
- $[17] = handleSendEdit;
102
- $[18] = message;
103
- $[19] = queue;
104
- $[20] = t6;
105
- } else t6 = $[20];
106
+ $[16] = attachmentAdapter;
107
+ $[17] = handleBeginEdit;
108
+ $[18] = handleSendEdit;
109
+ $[19] = message;
110
+ $[20] = queue;
111
+ $[21] = t6;
112
+ } else t6 = $[21];
106
113
  const composerClient = useClientResource(t6);
107
114
  let branchIds;
108
115
  let t7;
109
- if ($[21] !== branches || $[22] !== message.id) {
116
+ if ($[22] !== branches || $[23] !== message.id) {
110
117
  branchIds = branches?.getBranches(message.id) ?? EMPTY_BRANCH_IDS;
111
118
  t7 = branchIds.indexOf(message.id);
112
- $[21] = branches;
113
- $[22] = message.id;
114
- $[23] = branchIds;
115
- $[24] = t7;
119
+ $[22] = branches;
120
+ $[23] = message.id;
121
+ $[24] = branchIds;
122
+ $[25] = t7;
116
123
  } else {
117
- branchIds = $[23];
118
- t7 = $[24];
124
+ branchIds = $[24];
125
+ t7 = $[25];
119
126
  }
120
127
  const branchIndex = t7;
121
128
  const branchNumber = branchIndex === -1 ? 1 : branchIndex + 1;
122
129
  const branchCount = branchIndex === -1 ? 1 : branchIds.length;
123
130
  let t8;
124
- if ($[25] !== message || $[26] !== submittedFeedback) {
131
+ if ($[26] !== message || $[27] !== submittedFeedback) {
125
132
  t8 = submittedFeedback && message.role === "assistant" ? {
126
133
  ...message,
127
134
  metadata: {
128
135
  ...message.metadata,
129
- submittedFeedback: { type: submittedFeedback }
136
+ submittedFeedback
130
137
  }
131
138
  } : message;
132
- $[25] = message;
133
- $[26] = submittedFeedback;
134
- $[27] = t8;
135
- } else t8 = $[27];
139
+ $[26] = message;
140
+ $[27] = submittedFeedback;
141
+ $[28] = t8;
142
+ } else t8 = $[28];
136
143
  const messageWithFeedback = t8;
137
144
  let t9;
138
- if ($[28] !== message.attachments) {
145
+ if ($[29] !== message.attachments) {
139
146
  t9 = message.attachments ?? [];
140
- $[28] = message.attachments;
141
- $[29] = t9;
142
- } else t9 = $[29];
147
+ $[29] = message.attachments;
148
+ $[30] = t9;
149
+ } else t9 = $[30];
143
150
  let t10;
144
- if ($[30] !== branchCount || $[31] !== branchNumber || $[32] !== composerClient.state || $[33] !== index || $[34] !== isCopied || $[35] !== isHovering || $[36] !== messageWithFeedback || $[37] !== parentId || $[38] !== partClients.state || $[39] !== speech || $[40] !== t9) {
151
+ if ($[31] !== branchCount || $[32] !== branchNumber || $[33] !== composerClient.state || $[34] !== index || $[35] !== isCopied || $[36] !== isHovering || $[37] !== isLast || $[38] !== messageWithFeedback || $[39] !== parentId || $[40] !== partClients.state || $[41] !== speech || $[42] !== t9) {
145
152
  t10 = {
146
153
  ...messageWithFeedback,
147
154
  attachments: t9,
148
155
  parentId,
149
- isLast: false,
156
+ isLast,
150
157
  branchNumber,
151
158
  branchCount,
152
159
  speech,
@@ -156,82 +163,83 @@ const useMessageClient = (t0) => {
156
163
  index,
157
164
  composer: composerClient.state
158
165
  };
159
- $[30] = branchCount;
160
- $[31] = branchNumber;
161
- $[32] = composerClient.state;
162
- $[33] = index;
163
- $[34] = isCopied;
164
- $[35] = isHovering;
165
- $[36] = messageWithFeedback;
166
- $[37] = parentId;
167
- $[38] = partClients.state;
168
- $[39] = speech;
169
- $[40] = t9;
170
- $[41] = t10;
171
- } else t10 = $[41];
166
+ $[31] = branchCount;
167
+ $[32] = branchNumber;
168
+ $[33] = composerClient.state;
169
+ $[34] = index;
170
+ $[35] = isCopied;
171
+ $[36] = isHovering;
172
+ $[37] = isLast;
173
+ $[38] = messageWithFeedback;
174
+ $[39] = parentId;
175
+ $[40] = partClients.state;
176
+ $[41] = speech;
177
+ $[42] = t9;
178
+ $[43] = t10;
179
+ } else t10 = $[43];
172
180
  const state = t10;
173
181
  let t11;
174
- if ($[42] !== state) {
182
+ if ($[44] !== state) {
175
183
  t11 = () => state;
176
- $[42] = state;
177
- $[43] = t11;
178
- } else t11 = $[43];
184
+ $[44] = state;
185
+ $[45] = t11;
186
+ } else t11 = $[45];
179
187
  let t12;
180
- if ($[44] !== composerClient.methods) {
188
+ if ($[46] !== composerClient.methods) {
181
189
  t12 = () => composerClient.methods;
182
- $[44] = composerClient.methods;
183
- $[45] = t12;
184
- } else t12 = $[45];
190
+ $[46] = composerClient.methods;
191
+ $[47] = t12;
192
+ } else t12 = $[47];
185
193
  let t13;
186
- if ($[46] !== onReload) {
194
+ if ($[48] !== onReload) {
187
195
  t13 = () => {
188
196
  onReload?.();
189
197
  };
190
- $[46] = onReload;
191
- $[47] = t13;
192
- } else t13 = $[47];
198
+ $[48] = onReload;
199
+ $[49] = t13;
200
+ } else t13 = $[49];
193
201
  let t14;
194
- if ($[48] !== branchIds || $[49] !== branchIndex || $[50] !== branches || $[51] !== message.id) {
202
+ if ($[50] !== branchIds || $[51] !== branchIndex || $[52] !== branches || $[53] !== message.id) {
195
203
  t14 = (t15) => {
196
204
  const { position, branchId } = t15;
197
205
  if (!branches) return;
198
206
  const target = branchId ?? (branchIndex === -1 ? void 0 : position === "previous" ? branchIds[branchIndex - 1] : position === "next" ? branchIds[branchIndex + 1] : void 0);
199
207
  if (target !== void 0 && target !== message.id) branches.switchToBranch(target);
200
208
  };
201
- $[48] = branchIds;
202
- $[49] = branchIndex;
203
- $[50] = branches;
204
- $[51] = message.id;
205
- $[52] = t14;
206
- } else t14 = $[52];
209
+ $[50] = branchIds;
210
+ $[51] = branchIndex;
211
+ $[52] = branches;
212
+ $[53] = message.id;
213
+ $[54] = t14;
214
+ } else t14 = $[54];
207
215
  let t15;
208
- if ($[53] !== message) {
216
+ if ($[55] !== message) {
209
217
  t15 = () => getThreadMessageText(message);
210
- $[53] = message;
211
- $[54] = t15;
212
- } else t15 = $[54];
218
+ $[55] = message;
219
+ $[56] = t15;
220
+ } else t15 = $[56];
213
221
  let t16;
214
- if ($[55] !== partClients || $[56] !== state) {
222
+ if ($[57] !== partClients || $[58] !== state) {
215
223
  t16 = (selector) => {
216
224
  if ("index" in selector) return partClients.get(selector);
217
225
  const partIndex = state.parts.findIndex((p) => p.type === "tool-call" && p.toolCallId === selector.toolCallId);
218
226
  return partClients.get({ index: partIndex });
219
227
  };
220
- $[55] = partClients;
221
- $[56] = state;
222
- $[57] = t16;
223
- } else t16 = $[57];
228
+ $[57] = partClients;
229
+ $[58] = state;
230
+ $[59] = t16;
231
+ } else t16 = $[59];
224
232
  let t17;
225
- if ($[58] !== attachmentClients) {
233
+ if ($[60] !== attachmentClients) {
226
234
  t17 = (selector_0) => {
227
235
  if ("id" in selector_0) return attachmentClients.get({ key: selector_0.id });
228
236
  return attachmentClients.get(selector_0);
229
237
  };
230
- $[58] = attachmentClients;
231
- $[59] = t17;
232
- } else t17 = $[59];
238
+ $[60] = attachmentClients;
239
+ $[61] = t17;
240
+ } else t17 = $[61];
233
241
  let t18;
234
- if ($[60] !== onSpeak || $[61] !== onStopSpeaking || $[62] !== onSubmitFeedback || $[63] !== t11 || $[64] !== t12 || $[65] !== t13 || $[66] !== t14 || $[67] !== t15 || $[68] !== t16 || $[69] !== t17) {
242
+ if ($[62] !== onSpeak || $[63] !== onStopSpeaking || $[64] !== onSubmitFeedback || $[65] !== t11 || $[66] !== t12 || $[67] !== t13 || $[68] !== t14 || $[69] !== t15 || $[70] !== t16 || $[71] !== t17) {
235
243
  t18 = {
236
244
  getState: t11,
237
245
  composer: t12,
@@ -247,24 +255,24 @@ const useMessageClient = (t0) => {
247
255
  setIsCopied,
248
256
  setIsHovering
249
257
  };
250
- $[60] = onSpeak;
251
- $[61] = onStopSpeaking;
252
- $[62] = onSubmitFeedback;
253
- $[63] = t11;
254
- $[64] = t12;
255
- $[65] = t13;
256
- $[66] = t14;
257
- $[67] = t15;
258
- $[68] = t16;
259
- $[69] = t17;
260
- $[70] = t18;
261
- } else t18 = $[70];
258
+ $[62] = onSpeak;
259
+ $[63] = onStopSpeaking;
260
+ $[64] = onSubmitFeedback;
261
+ $[65] = t11;
262
+ $[66] = t12;
263
+ $[67] = t13;
264
+ $[68] = t14;
265
+ $[69] = t15;
266
+ $[70] = t16;
267
+ $[71] = t17;
268
+ $[72] = t18;
269
+ } else t18 = $[72];
262
270
  return t18;
263
271
  };
264
272
  const MessageClient = resource(useMessageClient);
265
273
  const usePartResource = (t0) => {
266
- const $ = c(20);
267
- const { part, status, messageId, onRespondToToolApproval, onAddToolResult, onResumeToolCall } = t0;
274
+ const $ = c(27);
275
+ const { part, status, messageId, onRespondToToolApproval, unstable_onRecordToolInteraction, onAddToolResult, onResumeToolCall } = t0;
268
276
  const t1 = status;
269
277
  let t2;
270
278
  if ($[0] !== part || $[1] !== t1) {
@@ -305,7 +313,7 @@ const usePartResource = (t0) => {
305
313
  $[8] = t4;
306
314
  } else t4 = $[8];
307
315
  let t5;
308
- if ($[9] !== onResumeToolCall || $[10] !== part) {
316
+ if ($[9] !== messageId || $[10] !== onResumeToolCall || $[11] !== part || $[12] !== unstable_onRecordToolInteraction) {
309
317
  t5 = (payload) => {
310
318
  if (!onResumeToolCall) throw new Error("Runtime does not support resuming tool calls (onResumeToolCall is not set).");
311
319
  if (part.type !== "tool-call") throw new Error("Tried to resume tool call on non-tool message part");
@@ -313,13 +321,23 @@ const usePartResource = (t0) => {
313
321
  toolCallId: part.toolCallId,
314
322
  payload
315
323
  });
324
+ Promise.resolve().then(() => unstable_onRecordToolInteraction?.({
325
+ messageId,
326
+ toolCallId: part.toolCallId,
327
+ interaction: createToolInteraction({
328
+ type: "human-response",
329
+ payload
330
+ })
331
+ })).catch(_temp4);
316
332
  };
317
- $[9] = onResumeToolCall;
318
- $[10] = part;
319
- $[11] = t5;
320
- } else t5 = $[11];
333
+ $[9] = messageId;
334
+ $[10] = onResumeToolCall;
335
+ $[11] = part;
336
+ $[12] = unstable_onRecordToolInteraction;
337
+ $[13] = t5;
338
+ } else t5 = $[13];
321
339
  let t6;
322
- if ($[12] !== onRespondToToolApproval || $[13] !== part) {
340
+ if ($[14] !== onRespondToToolApproval || $[15] !== part) {
323
341
  t6 = (response_0) => {
324
342
  if (!onRespondToToolApproval) throw new Error("Runtime does not support tool approvals.");
325
343
  if (part.type !== "tool-call") throw new Error("Tried to respond to tool approval on non-tool message part");
@@ -332,25 +350,43 @@ const usePartResource = (t0) => {
332
350
  return Promise.reject(error);
333
351
  }
334
352
  };
335
- $[12] = onRespondToToolApproval;
336
- $[13] = part;
337
- $[14] = t6;
338
- } else t6 = $[14];
353
+ $[14] = onRespondToToolApproval;
354
+ $[15] = part;
355
+ $[16] = t6;
356
+ } else t6 = $[16];
339
357
  let t7;
340
- if ($[15] !== t3 || $[16] !== t4 || $[17] !== t5 || $[18] !== t6) {
341
- t7 = {
358
+ if ($[17] !== messageId || $[18] !== part || $[19] !== unstable_onRecordToolInteraction) {
359
+ t7 = async (input) => {
360
+ if (!unstable_onRecordToolInteraction) throw new Error("Runtime does not support recording tool interactions.");
361
+ if (part.type !== "tool-call") throw new Error("Tried to record interaction on non-tool message part");
362
+ await unstable_onRecordToolInteraction({
363
+ messageId,
364
+ toolCallId: part.toolCallId,
365
+ interaction: createToolInteraction(input)
366
+ });
367
+ };
368
+ $[17] = messageId;
369
+ $[18] = part;
370
+ $[19] = unstable_onRecordToolInteraction;
371
+ $[20] = t7;
372
+ } else t7 = $[20];
373
+ let t8;
374
+ if ($[21] !== t3 || $[22] !== t4 || $[23] !== t5 || $[24] !== t6 || $[25] !== t7) {
375
+ t8 = {
342
376
  getState: t3,
343
377
  addToolResult: t4,
344
378
  resumeToolCall: t5,
345
- respondToToolApproval: t6
379
+ respondToToolApproval: t6,
380
+ unstable_recordInteraction: t7
346
381
  };
347
- $[15] = t3;
348
- $[16] = t4;
349
- $[17] = t5;
350
- $[18] = t6;
351
- $[19] = t7;
352
- } else t7 = $[19];
353
- return t7;
382
+ $[21] = t3;
383
+ $[22] = t4;
384
+ $[23] = t5;
385
+ $[24] = t6;
386
+ $[25] = t7;
387
+ $[26] = t8;
388
+ } else t8 = $[26];
389
+ return t8;
354
390
  };
355
391
  const PartResource = resource(usePartResource);
356
392
  const useAttachmentResource = ({ attachment, onRemove }) => {
@@ -362,6 +398,7 @@ const useAttachmentResource = ({ attachment, onRemove }) => {
362
398
  };
363
399
  };
364
400
  const AttachmentResource = resource(useAttachmentResource);
401
+ const EMPTY_MESSAGE_KEYS = Object.freeze([]);
365
402
  const useQueueItemClient = ({ item, onMove, onRemove }) => {
366
403
  return {
367
404
  getState: () => item,
@@ -399,144 +436,327 @@ const useLiveState = (initial) => {
399
436
  } else t1 = $[2];
400
437
  return t1;
401
438
  };
402
- const removeAttachmentThroughAdapter = async (attachment, attachmentAdapter, setAttachments) => {
439
+ const removeAttachmentThroughAdapter = async (attachment, attachmentAdapter, onError) => {
403
440
  try {
404
441
  await attachmentAdapter?.remove(attachment);
405
442
  } catch (error) {
406
- const message = error instanceof Error ? error.message : String(error);
407
- setAttachments((prev) => prev.map((candidate) => candidate.id === attachment.id && !isAttachmentComplete(candidate) ? {
408
- ...candidate,
409
- status: {
410
- type: "incomplete",
411
- reason: "error",
412
- message
413
- }
414
- } : candidate));
443
+ onError(error instanceof Error ? error.message : String(error));
415
444
  throw error;
416
445
  }
417
446
  };
447
+ const dispatchSafely = (dispatch) => {
448
+ try {
449
+ dispatch();
450
+ return;
451
+ } catch (error) {
452
+ return { error };
453
+ }
454
+ };
455
+ const abortOnDestroy = (destroySignal, controller) => {
456
+ if (!destroySignal) return () => {};
457
+ const abort = () => controller.abort(destroySignal.reason);
458
+ if (destroySignal.aborted) {
459
+ abort();
460
+ return () => {};
461
+ }
462
+ const unlink = () => {
463
+ destroySignal.removeEventListener("abort", abort);
464
+ controller.signal.removeEventListener("abort", unlink);
465
+ };
466
+ destroySignal.addEventListener("abort", abort, { once: true });
467
+ controller.signal.addEventListener("abort", unlink, { once: true });
468
+ return unlink;
469
+ };
470
+ const EMPTY_IN_TRANSIT = Object.freeze([]);
418
471
  const useComposerClientResource = (t0) => {
419
- const $ = c(108);
420
- const { type, canCancel, isRunning: t1, isSendDisabled: t2, onCancel, onBeginEdit, onSend, message, queue, attachmentAdapter } = t0;
472
+ const $ = c(190);
473
+ const { type, canCancel, isRunning: t1, isSendDisabled: t2, onCancel, onBeginEdit, onSend, message, queue, attachmentAdapter, messageKeys: t3 } = t0;
421
474
  const isRunning = t1 === void 0 ? false : t1;
422
475
  const isSendDisabled = t2 === void 0 ? false : t2;
476
+ const messageKeys = t3 === void 0 ? EMPTY_MESSAGE_KEYS : t3;
423
477
  const [isEditing, setIsEditing, isEditingRef] = useLiveState(type === "thread");
424
478
  const [text, setText, textRef] = useLiveState("");
425
479
  const [role, setRole, roleRef] = useLiveState("user");
426
- let t3;
427
- if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
428
- t3 = {};
429
- $[0] = t3;
430
- } else t3 = $[0];
431
- const [runConfig, setRunConfig, runConfigRef] = useLiveState(t3);
432
480
  let t4;
481
+ if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
482
+ t4 = {};
483
+ $[0] = t4;
484
+ } else t4 = $[0];
485
+ const [runConfig, setRunConfig, runConfigRef] = useLiveState(t4);
486
+ let t5;
433
487
  if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
434
- t4 = [];
435
- $[1] = t4;
436
- } else t4 = $[1];
437
- const [attachments, setAttachments, attachmentsRef] = useLiveState(t4);
488
+ t5 = [];
489
+ $[1] = t5;
490
+ } else t5 = $[1];
491
+ const [attachments, setAttachments, attachmentsRef] = useLiveState(t5);
438
492
  const [quote, setQuote, quoteRef] = useLiveState(void 0);
439
- let t5;
440
- if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
441
- t5 = new AttachmentAddOperations();
442
- $[2] = t5;
443
- } else t5 = $[2];
444
- const attachmentAddOperations = t5;
445
493
  let t6;
446
- if ($[3] !== message || $[4] !== setAttachments || $[5] !== setRole || $[6] !== setText) {
447
- t6 = () => {
494
+ if ($[2] === Symbol.for("react.memo_cache_sentinel")) {
495
+ t6 = new AttachmentAddOperations();
496
+ $[2] = t6;
497
+ } else t6 = $[2];
498
+ const attachmentAddOperations = t6;
499
+ let t7;
500
+ if ($[3] === Symbol.for("react.memo_cache_sentinel")) {
501
+ t7 = new AttachmentSendOperations();
502
+ $[3] = t7;
503
+ } else t7 = $[3];
504
+ const attachmentSends = t7;
505
+ const destroySignal = useAssistantClientDestroySignal();
506
+ const [submission, setSubmission, submissionRef] = useLiveState(void 0);
507
+ const submissionSend = useRef(void 0);
508
+ const [inTransit, setInTransit] = useLiveState(EMPTY_IN_TRANSIT);
509
+ const messageKeysRef = useRef(messageKeys);
510
+ const sendGeneration = useRef(0);
511
+ let claimed;
512
+ let landed;
513
+ if ($[4] !== inTransit || $[5] !== messageKeys) {
514
+ claimed = /* @__PURE__ */ new Set();
515
+ landed = /* @__PURE__ */ new Set();
516
+ for (const entry of inTransit) {
517
+ const key = messageKeys.find((candidate) => !entry.known.has(candidate) && !claimed.has(candidate) && candidate.endsWith(`|${entry.submission.role}`));
518
+ if (key === void 0) continue;
519
+ claimed.add(key);
520
+ landed.add(entry);
521
+ }
522
+ $[4] = inTransit;
523
+ $[5] = messageKeys;
524
+ $[6] = claimed;
525
+ $[7] = landed;
526
+ } else {
527
+ claimed = $[6];
528
+ landed = $[7];
529
+ }
530
+ let t8;
531
+ if ($[8] !== claimed || $[9] !== landed) {
532
+ t8 = {
533
+ landed,
534
+ claimed
535
+ };
536
+ $[8] = claimed;
537
+ $[9] = landed;
538
+ $[10] = t8;
539
+ } else t8 = $[10];
540
+ const shown = t8;
541
+ let t9;
542
+ if ($[11] !== inTransit || $[12] !== shown.landed) {
543
+ let t10;
544
+ if ($[14] !== shown.landed) {
545
+ t10 = (entry_0) => !shown.landed.has(entry_0);
546
+ $[14] = shown.landed;
547
+ $[15] = t10;
548
+ } else t10 = $[15];
549
+ t9 = inTransit.filter(t10).map(_temp5);
550
+ $[11] = inTransit;
551
+ $[12] = shown.landed;
552
+ $[13] = t9;
553
+ } else t9 = $[13];
554
+ const inTransitSubmissions = t9;
555
+ let t10;
556
+ if ($[16] !== messageKeys || $[17] !== setInTransit || $[18] !== shown.claimed || $[19] !== shown.landed) {
557
+ t10 = () => {
558
+ messageKeysRef.current = messageKeys;
559
+ if (shown.landed.size === 0) return;
560
+ setInTransit((prev) => prev.filter((entry_2) => !shown.landed.has(entry_2)).map((entry_3) => ({
561
+ ...entry_3,
562
+ known: /* @__PURE__ */ new Set([...entry_3.known, ...shown.claimed])
563
+ })));
564
+ };
565
+ $[16] = messageKeys;
566
+ $[17] = setInTransit;
567
+ $[18] = shown.claimed;
568
+ $[19] = shown.landed;
569
+ $[20] = t10;
570
+ } else t10 = $[20];
571
+ let t11;
572
+ if ($[21] !== messageKeys || $[22] !== setInTransit || $[23] !== shown) {
573
+ t11 = [
574
+ messageKeys,
575
+ shown,
576
+ setInTransit
577
+ ];
578
+ $[21] = messageKeys;
579
+ $[22] = setInTransit;
580
+ $[23] = shown;
581
+ $[24] = t11;
582
+ } else t11 = $[24];
583
+ useEffect(t10, t11);
584
+ let t12;
585
+ if ($[25] !== message || $[26] !== setAttachments || $[27] !== setRole || $[28] !== setText) {
586
+ t12 = () => {
448
587
  if (!message) return;
449
- const messageText = message.content.filter(_temp4).map(_temp5).join("\n\n");
588
+ const messageText = message.content.filter(_temp6).map(_temp7).join("\n\n");
450
589
  setText(messageText);
451
590
  setRole(message.role);
452
- setAttachments(message.attachments ?? []);
591
+ const restored = message.attachments ?? [];
592
+ for (const attachment of restored) attachmentSends.unmarkRemoved(attachment);
593
+ setAttachments(restored);
453
594
  };
454
- $[3] = message;
455
- $[4] = setAttachments;
456
- $[5] = setRole;
457
- $[6] = setText;
458
- $[7] = t6;
459
- } else t6 = $[7];
460
- const updateFromMessage = t6;
461
- let t7;
462
- if ($[8] !== attachmentAdapter || $[9] !== attachments || $[10] !== setAttachments) {
463
- let t8;
464
- if ($[12] !== attachmentAdapter || $[13] !== setAttachments) {
465
- t8 = (attachment) => withKey(attachment.id, AttachmentResource({
466
- attachment,
467
- onRemove: async () => {
468
- attachmentAddOperations.cancel(attachment.id);
469
- if (!isAttachmentComplete(attachment)) await removeAttachmentThroughAdapter(attachment, attachmentAdapter, setAttachments);
470
- setAttachments((prev) => prev.filter((a) => a.id !== attachment.id));
595
+ $[25] = message;
596
+ $[26] = setAttachments;
597
+ $[27] = setRole;
598
+ $[28] = setText;
599
+ $[29] = t12;
600
+ } else t12 = $[29];
601
+ const updateFromMessage = t12;
602
+ let t13;
603
+ if ($[30] !== attachmentAdapter || $[31] !== setAttachments) {
604
+ t13 = async (attachment_0) => {
605
+ attachmentAddOperations.cancel(attachment_0.id);
606
+ attachmentSends.markRemoved(attachment_0);
607
+ if (!isAttachmentComplete(attachment_0)) await removeAttachmentThroughAdapter(attachment_0, attachmentAdapter, (message_0) => setAttachments((prev_0) => prev_0.map((candidate_0) => candidate_0.id === attachment_0.id && !isAttachmentComplete(candidate_0) ? attachmentSends.transfer(candidate_0, {
608
+ ...candidate_0,
609
+ status: {
610
+ type: "incomplete",
611
+ reason: "error",
612
+ message: message_0
471
613
  }
614
+ }) : candidate_0)));
615
+ setAttachments((prev_1) => prev_1.filter((a) => a.id !== attachment_0.id));
616
+ };
617
+ $[30] = attachmentAdapter;
618
+ $[31] = setAttachments;
619
+ $[32] = t13;
620
+ } else t13 = $[32];
621
+ const handleRemoveAttachment = t13;
622
+ let t14;
623
+ if ($[33] !== attachmentAdapter || $[34] !== setSubmission) {
624
+ t14 = async (attachment_1) => {
625
+ attachmentAddOperations.cancel(attachment_1.id);
626
+ attachmentSends.markRemoved(attachment_1);
627
+ if (!isAttachmentComplete(attachment_1)) await removeAttachmentThroughAdapter(attachment_1, attachmentAdapter, (message_1) => setSubmission((prev_2) => prev_2 ? {
628
+ ...prev_2,
629
+ attachments: prev_2.attachments.map((candidate_1) => {
630
+ if (candidate_1.id !== attachment_1.id || isAttachmentComplete(candidate_1)) return candidate_1;
631
+ const failed = attachmentSends.transfer(candidate_1, {
632
+ ...candidate_1,
633
+ status: {
634
+ type: "incomplete",
635
+ reason: "error",
636
+ message: message_1
637
+ }
638
+ });
639
+ attachmentSends.markRemoved(failed);
640
+ return failed;
641
+ })
642
+ } : prev_2));
643
+ setSubmission((prev_3) => prev_3 ? {
644
+ ...prev_3,
645
+ attachments: prev_3.attachments.filter((a_0) => a_0.id !== attachment_1.id)
646
+ } : prev_3);
647
+ };
648
+ $[33] = attachmentAdapter;
649
+ $[34] = setSubmission;
650
+ $[35] = t14;
651
+ } else t14 = $[35];
652
+ const handleRemoveSubmittedAttachment = t14;
653
+ let t15;
654
+ if ($[36] !== attachments || $[37] !== handleRemoveAttachment) {
655
+ let t16;
656
+ if ($[39] !== handleRemoveAttachment) {
657
+ t16 = (attachment_2) => withKey(attachment_2.id, AttachmentResource({
658
+ attachment: attachment_2,
659
+ onRemove: () => handleRemoveAttachment(attachment_2)
472
660
  }));
473
- $[12] = attachmentAdapter;
474
- $[13] = setAttachments;
475
- $[14] = t8;
476
- } else t8 = $[14];
477
- t7 = attachments.map(t8);
478
- $[8] = attachmentAdapter;
479
- $[9] = attachments;
480
- $[10] = setAttachments;
481
- $[11] = t7;
482
- } else t7 = $[11];
483
- const attachmentClients = useClientLookup(t7);
484
- let t8;
485
- if ($[15] !== attachmentAdapter) {
486
- t8 = async (removed) => {
661
+ $[39] = handleRemoveAttachment;
662
+ $[40] = t16;
663
+ } else t16 = $[40];
664
+ t15 = attachments.map(t16);
665
+ $[36] = attachments;
666
+ $[37] = handleRemoveAttachment;
667
+ $[38] = t15;
668
+ } else t15 = $[38];
669
+ const attachmentClients = useClientLookup(t15);
670
+ let t16;
671
+ if ($[41] !== attachments || $[42] !== handleRemoveSubmittedAttachment || $[43] !== submission?.attachments) {
672
+ let t17;
673
+ if ($[45] !== attachments) {
674
+ t17 = (attachment_3) => !attachments.some((a_1) => a_1.id === attachment_3.id);
675
+ $[45] = attachments;
676
+ $[46] = t17;
677
+ } else t17 = $[46];
678
+ let t18;
679
+ if ($[47] !== handleRemoveSubmittedAttachment) {
680
+ t18 = (attachment_4) => withKey(attachment_4.id, AttachmentResource({
681
+ attachment: attachment_4,
682
+ onRemove: () => handleRemoveSubmittedAttachment(attachment_4)
683
+ }));
684
+ $[47] = handleRemoveSubmittedAttachment;
685
+ $[48] = t18;
686
+ } else t18 = $[48];
687
+ t16 = (submission?.attachments ?? []).filter(t17).map(t18);
688
+ $[41] = attachments;
689
+ $[42] = handleRemoveSubmittedAttachment;
690
+ $[43] = submission?.attachments;
691
+ $[44] = t16;
692
+ } else t16 = $[44];
693
+ const submittedAttachmentClients = useClientLookup(t16);
694
+ let t17;
695
+ if ($[49] !== attachmentAdapter) {
696
+ t17 = async (removed) => {
487
697
  if (!attachmentAdapter) return;
488
- await Promise.all(removed.filter(_temp6).map(async (a_1) => attachmentAdapter.remove(a_1)));
698
+ await Promise.all(removed.filter(_temp8).map(async (a_3) => attachmentAdapter.remove(a_3)));
489
699
  };
490
- $[15] = attachmentAdapter;
491
- $[16] = t8;
492
- } else t8 = $[16];
493
- const removePendingAttachments = t8;
494
- let t9;
495
- if ($[17] !== setAttachments) {
496
- t9 = (attachment_0) => {
497
- setAttachments((prev_0) => {
498
- const idx = prev_0.findIndex((a_2) => a_2.id === attachment_0.id);
499
- if (idx === -1) return [...prev_0, attachment_0];
500
- const next = [...prev_0];
501
- next[idx] = attachment_0;
700
+ $[49] = attachmentAdapter;
701
+ $[50] = t17;
702
+ } else t17 = $[50];
703
+ const removePendingAttachments = t17;
704
+ let t18;
705
+ if ($[51] !== setAttachments || $[52] !== setSubmission || $[53] !== submissionRef) {
706
+ t18 = (attachment_5) => {
707
+ const current = submissionRef.current;
708
+ if (current?.attachments.some((a_5) => a_5.id === attachment_5.id)) {
709
+ setSubmission({
710
+ ...current,
711
+ attachments: current.attachments.map((a_4) => a_4.id === attachment_5.id ? attachmentSends.transfer(a_4, attachment_5) : a_4)
712
+ });
713
+ return;
714
+ }
715
+ setAttachments((prev_4) => {
716
+ const idx = prev_4.findIndex((a_6) => a_6.id === attachment_5.id);
717
+ if (idx === -1) return [...prev_4, attachment_5];
718
+ const next = [...prev_4];
719
+ next[idx] = attachment_5;
502
720
  return next;
503
721
  });
504
722
  };
505
- $[17] = setAttachments;
506
- $[18] = t9;
507
- } else t9 = $[18];
508
- const upsertAttachment = t9;
723
+ $[51] = setAttachments;
724
+ $[52] = setSubmission;
725
+ $[53] = submissionRef;
726
+ $[54] = t18;
727
+ } else t18 = $[54];
728
+ const upsertAttachment = t18;
509
729
  const steerItems = queue?.steerItems ?? EMPTY_QUEUE_ITEMS;
510
730
  const laneItems = queue?.items ?? EMPTY_QUEUE_ITEMS;
511
- let t10;
512
- if ($[19] !== laneItems || $[20] !== steerItems) {
513
- t10 = steerItems.length === 0 ? laneItems : laneItems.length === 0 ? steerItems : [...steerItems, ...laneItems];
514
- $[19] = laneItems;
515
- $[20] = steerItems;
516
- $[21] = t10;
517
- } else t10 = $[21];
518
- const queueItems = t10;
519
- let t11;
520
- if ($[22] !== queue || $[23] !== queueItems) {
521
- let t12;
522
- if ($[25] !== queue) {
523
- t12 = (item) => withKey(item.id, QueueItemClient({
731
+ let t19;
732
+ if ($[55] !== laneItems || $[56] !== steerItems) {
733
+ t19 = steerItems.length === 0 ? laneItems : laneItems.length === 0 ? steerItems : [...steerItems, ...laneItems];
734
+ $[55] = laneItems;
735
+ $[56] = steerItems;
736
+ $[57] = t19;
737
+ } else t19 = $[57];
738
+ const queueItems = t19;
739
+ let t20;
740
+ if ($[58] !== queue || $[59] !== queueItems) {
741
+ let t21;
742
+ if ($[61] !== queue) {
743
+ t21 = (item) => withKey(item.id, QueueItemClient({
524
744
  item,
525
745
  onMove: (placement) => queue?.move(item.id, placement),
526
746
  onRemove: () => queue?.remove(item.id)
527
747
  }));
528
- $[25] = queue;
529
- $[26] = t12;
530
- } else t12 = $[26];
531
- t11 = queueItems.map(t12);
532
- $[22] = queue;
533
- $[23] = queueItems;
534
- $[24] = t11;
535
- } else t11 = $[24];
536
- const queueItemClients = useClientLookup(t11);
537
- let t12;
538
- if ($[27] !== attachmentAdapter?.accept || $[28] !== attachmentClients.state || $[29] !== attachments.length || $[30] !== canCancel || $[31] !== isEditing || $[32] !== isSendDisabled || $[33] !== queueItems || $[34] !== quote || $[35] !== role || $[36] !== runConfig || $[37] !== text || $[38] !== type) {
539
- t12 = () => {
748
+ $[61] = queue;
749
+ $[62] = t21;
750
+ } else t21 = $[62];
751
+ t20 = queueItems.map(t21);
752
+ $[58] = queue;
753
+ $[59] = queueItems;
754
+ $[60] = t20;
755
+ } else t20 = $[60];
756
+ const queueItemClients = useClientLookup(t20);
757
+ let t21;
758
+ if ($[63] !== attachmentAdapter?.accept || $[64] !== attachmentClients.state || $[65] !== attachments.length || $[66] !== canCancel || $[67] !== inTransitSubmissions || $[68] !== isEditing || $[69] !== isSendDisabled || $[70] !== queueItems || $[71] !== quote || $[72] !== role || $[73] !== runConfig || $[74] !== submission || $[75] !== text || $[76] !== type) {
759
+ t21 = () => {
540
760
  const isEmpty = !text.trim() && !attachments.length;
541
761
  return {
542
762
  text,
@@ -544,47 +764,248 @@ const useComposerClientResource = (t0) => {
544
764
  attachments: attachmentClients.state,
545
765
  runConfig,
546
766
  isEditing,
547
- canCancel,
548
- canSend: isEditing && !isEmpty && !isSendDisabled,
767
+ canCancel: canCancel || submission !== void 0,
768
+ canSend: isEditing && !isEmpty && !isSendDisabled && submission === void 0,
549
769
  attachmentAccept: attachmentAdapter?.accept ?? "*",
550
770
  isEmpty,
551
771
  type,
552
772
  dictation: void 0,
553
773
  quote,
554
- queue: queueItems
774
+ queue: queueItems,
775
+ submission,
776
+ inTransit: inTransitSubmissions
555
777
  };
556
778
  };
557
- $[27] = attachmentAdapter?.accept;
558
- $[28] = attachmentClients.state;
559
- $[29] = attachments.length;
560
- $[30] = canCancel;
561
- $[31] = isEditing;
562
- $[32] = isSendDisabled;
563
- $[33] = queueItems;
564
- $[34] = quote;
565
- $[35] = role;
566
- $[36] = runConfig;
567
- $[37] = text;
568
- $[38] = type;
569
- $[39] = t12;
570
- } else t12 = $[39];
779
+ $[63] = attachmentAdapter?.accept;
780
+ $[64] = attachmentClients.state;
781
+ $[65] = attachments.length;
782
+ $[66] = canCancel;
783
+ $[67] = inTransitSubmissions;
784
+ $[68] = isEditing;
785
+ $[69] = isSendDisabled;
786
+ $[70] = queueItems;
787
+ $[71] = quote;
788
+ $[72] = role;
789
+ $[73] = runConfig;
790
+ $[74] = submission;
791
+ $[75] = text;
792
+ $[76] = type;
793
+ $[77] = t21;
794
+ } else t21 = $[77];
571
795
  attachmentAdapter?.accept;
572
- let t13;
573
- if ($[40] !== t12) {
574
- t13 = t12();
575
- $[40] = t12;
576
- $[41] = t13;
577
- } else t13 = $[41];
578
- const state = t13;
579
- let t14;
580
- if ($[42] !== state) {
581
- t14 = () => state;
582
- $[42] = state;
583
- $[43] = t14;
584
- } else t14 = $[43];
585
- let t15;
586
- if ($[44] !== attachmentAdapter || $[45] !== setAttachments || $[46] !== upsertAttachment) {
587
- t15 = async (fileOrAttachment) => {
796
+ let t22;
797
+ if ($[78] !== t21) {
798
+ t22 = t21();
799
+ $[78] = t21;
800
+ $[79] = t22;
801
+ } else t22 = $[79];
802
+ const state = t22;
803
+ let t23;
804
+ if ($[80] !== setSubmission) {
805
+ t23 = () => {
806
+ sendGeneration.current = sendGeneration.current + 1;
807
+ submissionSend.current = void 0;
808
+ setSubmission(void 0);
809
+ };
810
+ $[80] = setSubmission;
811
+ $[81] = t23;
812
+ } else t23 = $[81];
813
+ const endSubmission = t23;
814
+ let t24;
815
+ if ($[82] !== setAttachments || $[83] !== setQuote || $[84] !== setText || $[85] !== type) {
816
+ t24 = (content) => {
817
+ if (type !== "thread") {
818
+ const returned = new Map(content.attachments.map(_temp9));
819
+ setAttachments((prev_5) => prev_5.map((attachment_7) => returned.get(attachment_7.id) ?? attachment_7));
820
+ return;
821
+ }
822
+ const kept = content.attachments.filter((attachment_8) => !attachmentSends.isRemoved(attachment_8));
823
+ setAttachments((prev_6) => [...kept, ...prev_6]);
824
+ setText((prev_7) => [content.text, prev_7].filter(Boolean).join("\n"));
825
+ setQuote((prev_8) => prev_8 ?? content.quote);
826
+ };
827
+ $[82] = setAttachments;
828
+ $[83] = setQuote;
829
+ $[84] = setText;
830
+ $[85] = type;
831
+ $[86] = t24;
832
+ } else t24 = $[86];
833
+ const returnToDraft = t24;
834
+ let t25;
835
+ if ($[87] !== endSubmission || $[88] !== returnToDraft || $[89] !== submissionRef) {
836
+ t25 = () => {
837
+ const current_0 = submissionRef.current;
838
+ if (!current_0) return;
839
+ submissionSend.current?.controller.abort();
840
+ endSubmission();
841
+ returnToDraft(current_0);
842
+ };
843
+ $[87] = endSubmission;
844
+ $[88] = returnToDraft;
845
+ $[89] = submissionRef;
846
+ $[90] = t25;
847
+ } else t25 = $[90];
848
+ const cancelSubmission = t25;
849
+ let t26;
850
+ if ($[91] !== attachmentsRef || $[92] !== endSubmission || $[93] !== removePendingAttachments || $[94] !== submissionRef) {
851
+ t26 = async () => {
852
+ const current_1 = submissionRef.current;
853
+ if (!current_1) return;
854
+ submissionSend.current?.controller.abort();
855
+ endSubmission();
856
+ const drafted = new Set(attachmentsRef.current.map(_temp0));
857
+ await removePendingAttachments(current_1.attachments.filter((attachment_9) => !drafted.has(attachment_9.id)));
858
+ };
859
+ $[91] = attachmentsRef;
860
+ $[92] = endSubmission;
861
+ $[93] = removePendingAttachments;
862
+ $[94] = submissionRef;
863
+ $[95] = t26;
864
+ } else t26 = $[95];
865
+ const discardSubmission = t26;
866
+ let t27;
867
+ if ($[96] !== endSubmission || $[97] !== returnToDraft || $[98] !== submissionRef) {
868
+ t27 = (sent, settled, reason) => {
869
+ const current_2 = submissionRef.current;
870
+ if (!current_2) return;
871
+ const failures = /* @__PURE__ */ new Map();
872
+ settled.forEach((result, index) => {
873
+ if (result.status === "rejected") failures.set(sent[index].id, result.reason);
874
+ });
875
+ const attachments_0 = current_2.attachments.map((attachment_10) => {
876
+ if (!failures.has(attachment_10.id) || isAttachmentComplete(attachment_10)) return attachment_10;
877
+ const failure = failures.get(attachment_10.id);
878
+ return attachmentSends.transfer(attachment_10, {
879
+ ...attachment_10,
880
+ status: {
881
+ type: "incomplete",
882
+ reason: "error",
883
+ message: failure instanceof Error ? failure.message : String(failure)
884
+ }
885
+ });
886
+ });
887
+ endSubmission();
888
+ returnToDraft({
889
+ ...current_2,
890
+ attachments: attachments_0
891
+ });
892
+ console.error("Failed to send attachments", reason);
893
+ };
894
+ $[96] = endSubmission;
895
+ $[97] = returnToDraft;
896
+ $[98] = submissionRef;
897
+ $[99] = t27;
898
+ } else t27 = $[99];
899
+ const returnSubmissionToDraft = t27;
900
+ let t28;
901
+ if ($[100] !== isRunning || $[101] !== onSend || $[102] !== queue || $[103] !== returnToDraft || $[104] !== setAttachments || $[105] !== setInTransit || $[106] !== setIsEditing || $[107] !== setSubmission || $[108] !== type) {
902
+ t28 = (current_3, attachments_1, context, isSubmission) => {
903
+ const composedMessage = {
904
+ role: current_3.role,
905
+ content: current_3.text ? [{
906
+ type: "text",
907
+ text: current_3.text
908
+ }] : [],
909
+ attachments: attachments_1,
910
+ createdAt: /* @__PURE__ */ new Date(),
911
+ parentId: null,
912
+ sourceId: null,
913
+ runConfig: context.runConfig,
914
+ startRun: context.options?.startRun,
915
+ metadata: { custom: { ...current_3.quote ? { quote: current_3.quote } : {} } }
916
+ };
917
+ const sent_0 = {
918
+ ...current_3,
919
+ attachments: attachments_1
920
+ };
921
+ const queued = queue && type === "thread";
922
+ if (isSubmission) {
923
+ submissionSend.current = void 0;
924
+ setSubmission(void 0);
925
+ }
926
+ if (isSubmission && type !== "thread") {
927
+ const delivered = new Map(attachments_1.map(_temp1));
928
+ setAttachments((prev_9) => prev_9.map((attachment_12) => delivered.get(attachment_12.id) ?? attachment_12));
929
+ }
930
+ const entry_4 = isSubmission && type === "thread" && !queued ? {
931
+ submission: sent_0,
932
+ known: new Set(messageKeysRef.current)
933
+ } : void 0;
934
+ if (entry_4) setInTransit((prev_10) => [...prev_10, entry_4]);
935
+ const failure_0 = dispatchSafely(() => {
936
+ if (queued) {
937
+ if (context.options?.steer ?? isRunning) queue.steer(composedMessage);
938
+ else queue.enqueue(composedMessage);
939
+ } else onSend?.(composedMessage);
940
+ });
941
+ if (failure_0) {
942
+ console.error("[assistant-ui] Failed to send the message", failure_0.error);
943
+ if (entry_4) setInTransit((prev_11) => prev_11.filter((candidate_2) => candidate_2 !== entry_4));
944
+ returnToDraft(sent_0);
945
+ return;
946
+ }
947
+ if (type === "edit") {
948
+ attachmentAddOperations.cancelAll();
949
+ setIsEditing(false);
950
+ }
951
+ };
952
+ $[100] = isRunning;
953
+ $[101] = onSend;
954
+ $[102] = queue;
955
+ $[103] = returnToDraft;
956
+ $[104] = setAttachments;
957
+ $[105] = setInTransit;
958
+ $[106] = setIsEditing;
959
+ $[107] = setSubmission;
960
+ $[108] = type;
961
+ $[109] = t28;
962
+ } else t28 = $[109];
963
+ const dispatchMessage = t28;
964
+ let t29;
965
+ if ($[110] !== attachmentAdapter || $[111] !== dispatchMessage || $[112] !== returnSubmissionToDraft || $[113] !== submissionRef) {
966
+ t29 = async (generation) => {
967
+ const context_0 = submissionSend.current;
968
+ if (!context_0) return;
969
+ const { signal } = context_0.controller;
970
+ if (signal.aborted) return;
971
+ const uploads = (submissionRef.current?.attachments ?? []).flatMap((attachment_13) => {
972
+ const upload = attachmentAddOperations.whenSendable(attachment_13.id);
973
+ return upload ? [upload] : [];
974
+ });
975
+ if (uploads.length > 0) {
976
+ await Promise.all(uploads);
977
+ if (generation !== sendGeneration.current || signal.aborted) return;
978
+ }
979
+ const current_4 = submissionRef.current;
980
+ if (!current_4) return;
981
+ const sent_1 = current_4.attachments.filter((attachment_14) => !attachmentSends.isRemoved(attachment_14));
982
+ for (const attachment_15 of sent_1) attachmentAddOperations.cancel(attachment_15.id);
983
+ const settled_0 = await Promise.allSettled(sent_1.map((attachment_16) => attachmentSends.send(attachment_16, attachmentAdapter, signal)));
984
+ if (generation !== sendGeneration.current || signal.aborted) return;
985
+ const rejection = settled_0.find(_temp10);
986
+ if (rejection) {
987
+ returnSubmissionToDraft(sent_1, settled_0, rejection.reason);
988
+ return;
989
+ }
990
+ const finalAttachments = settled_0.flatMap((result_1, index_0) => attachmentSends.isRemoved(sent_1[index_0]) || result_1.status === "rejected" ? [] : [result_1.value]);
991
+ dispatchMessage(submissionRef.current ?? current_4, finalAttachments, context_0, true);
992
+ };
993
+ $[110] = attachmentAdapter;
994
+ $[111] = dispatchMessage;
995
+ $[112] = returnSubmissionToDraft;
996
+ $[113] = submissionRef;
997
+ $[114] = t29;
998
+ } else t29 = $[114];
999
+ const prepareSubmission = t29;
1000
+ let t30;
1001
+ if ($[115] !== state) {
1002
+ t30 = () => state;
1003
+ $[115] = state;
1004
+ $[116] = t30;
1005
+ } else t30 = $[116];
1006
+ let t31;
1007
+ if ($[117] !== attachmentAdapter || $[118] !== setAttachments || $[119] !== upsertAttachment) {
1008
+ t31 = async (fileOrAttachment) => {
588
1009
  if (attachmentAdapter) {
589
1010
  const file = isCreateAttachment(fileOrAttachment) ? {
590
1011
  name: fileOrAttachment.name,
@@ -598,14 +1019,14 @@ const useComposerClientResource = (t0) => {
598
1019
  if (!isCreateAttachment(fileOrAttachment) && attachmentAdapter) {
599
1020
  const operation = attachmentAddOperations.start();
600
1021
  try {
601
- await drainAttachmentAdd(attachmentAdapter.add({ file: fileOrAttachment }), (attachment_1) => {
602
- if (!attachmentAddOperations.accept(operation, attachment_1.id)) return false;
603
- upsertAttachment(attachment_1);
1022
+ await drainAttachmentAdd(attachmentAdapter.add({ file: fileOrAttachment }), (attachment_17) => {
1023
+ if (!attachmentAddOperations.accept(operation, attachment_17)) return false;
1024
+ upsertAttachment(attachment_17);
604
1025
  return true;
605
1026
  });
606
1027
  attachmentAddOperations.finish(operation);
607
- } catch (t16) {
608
- const error = t16;
1028
+ } catch (t32) {
1029
+ const error = t32;
609
1030
  attachmentAddOperations.finish(operation);
610
1031
  if (!attachmentAddOperations.isCancelled(operation)) throw error;
611
1032
  }
@@ -619,7 +1040,7 @@ const useComposerClientResource = (t0) => {
619
1040
  status: { type: "complete" },
620
1041
  content: []
621
1042
  };
622
- setAttachments((prev_1) => [...prev_1, newAttachment]);
1043
+ setAttachments((prev_12) => [...prev_12, newAttachment]);
623
1044
  } else {
624
1045
  const newAttachment_0 = {
625
1046
  id: fileOrAttachment.id ?? generateId(),
@@ -629,199 +1050,220 @@ const useComposerClientResource = (t0) => {
629
1050
  content: fileOrAttachment.content,
630
1051
  status: { type: "complete" }
631
1052
  };
632
- setAttachments((prev_2) => [...prev_2, newAttachment_0]);
1053
+ setAttachments((prev_13) => [...prev_13, newAttachment_0]);
633
1054
  }
634
1055
  };
635
- $[44] = attachmentAdapter;
636
- $[45] = setAttachments;
637
- $[46] = upsertAttachment;
638
- $[47] = t15;
639
- } else t15 = $[47];
640
- let t16;
641
- if ($[48] !== attachmentsRef || $[49] !== removePendingAttachments || $[50] !== setAttachments) {
642
- t16 = async () => {
1056
+ $[117] = attachmentAdapter;
1057
+ $[118] = setAttachments;
1058
+ $[119] = upsertAttachment;
1059
+ $[120] = t31;
1060
+ } else t31 = $[120];
1061
+ let t32;
1062
+ if ($[121] !== attachmentsRef || $[122] !== removePendingAttachments || $[123] !== setAttachments || $[124] !== submissionRef) {
1063
+ t32 = async () => {
643
1064
  attachmentAddOperations.cancelAll();
644
1065
  const removed_0 = attachmentsRef.current;
1066
+ if (submissionRef.current) for (const attachment_18 of removed_0) attachmentSends.markRemoved(attachment_18);
645
1067
  setAttachments([]);
646
1068
  await removePendingAttachments(removed_0);
647
1069
  };
648
- $[48] = attachmentsRef;
649
- $[49] = removePendingAttachments;
650
- $[50] = setAttachments;
651
- $[51] = t16;
652
- } else t16 = $[51];
653
- let t17;
654
- if ($[52] !== attachmentClients) {
655
- t17 = (selector) => {
656
- if ("id" in selector) return attachmentClients.get({ key: selector.id });
1070
+ $[121] = attachmentsRef;
1071
+ $[122] = removePendingAttachments;
1072
+ $[123] = setAttachments;
1073
+ $[124] = submissionRef;
1074
+ $[125] = t32;
1075
+ } else t32 = $[125];
1076
+ let t33;
1077
+ if ($[126] !== attachmentClients || $[127] !== attachments || $[128] !== submission?.attachments || $[129] !== submittedAttachmentClients) {
1078
+ t33 = (selector) => {
1079
+ if ("id" in selector) {
1080
+ const submitted = submission?.attachments.some((attachment_19) => attachment_19.id === selector.id);
1081
+ const inDraft = attachments.some((attachment_20) => attachment_20.id === selector.id);
1082
+ if (submitted && !inDraft) return submittedAttachmentClients.get({ key: selector.id });
1083
+ return attachmentClients.get({ key: selector.id });
1084
+ }
657
1085
  return attachmentClients.get(selector);
658
1086
  };
659
- $[52] = attachmentClients;
660
- $[53] = t17;
661
- } else t17 = $[53];
662
- let t18;
663
- if ($[54] !== attachmentsRef || $[55] !== removePendingAttachments || $[56] !== setAttachments || $[57] !== setQuote || $[58] !== setRole || $[59] !== setRunConfig || $[60] !== setText) {
664
- t18 = async () => {
1087
+ $[126] = attachmentClients;
1088
+ $[127] = attachments;
1089
+ $[128] = submission?.attachments;
1090
+ $[129] = submittedAttachmentClients;
1091
+ $[130] = t33;
1092
+ } else t33 = $[130];
1093
+ let t34;
1094
+ if ($[131] !== attachmentsRef || $[132] !== discardSubmission || $[133] !== removePendingAttachments || $[134] !== setAttachments || $[135] !== setQuote || $[136] !== setRole || $[137] !== setRunConfig || $[138] !== setText) {
1095
+ t34 = async () => {
665
1096
  attachmentAddOperations.cancelAll();
1097
+ sendGeneration.current = sendGeneration.current + 1;
1098
+ const discarded = discardSubmission();
666
1099
  const removed_1 = attachmentsRef.current;
667
1100
  setText("");
668
1101
  setRole("user");
669
1102
  setRunConfig({});
670
1103
  setAttachments([]);
671
1104
  setQuote(void 0);
672
- await removePendingAttachments(removed_1);
1105
+ await Promise.all([removePendingAttachments(removed_1), discarded]);
673
1106
  };
674
- $[54] = attachmentsRef;
675
- $[55] = removePendingAttachments;
676
- $[56] = setAttachments;
677
- $[57] = setQuote;
678
- $[58] = setRole;
679
- $[59] = setRunConfig;
680
- $[60] = setText;
681
- $[61] = t18;
682
- } else t18 = $[61];
683
- let t19;
684
- if ($[62] !== attachmentAdapter || $[63] !== attachmentsRef || $[64] !== isEditingRef || $[65] !== isRunning || $[66] !== isSendDisabled || $[67] !== onSend || $[68] !== queue || $[69] !== quoteRef || $[70] !== roleRef || $[71] !== runConfigRef || $[72] !== setAttachments || $[73] !== setIsEditing || $[74] !== setQuote || $[75] !== setText || $[76] !== textRef || $[77] !== type) {
685
- t19 = (opts) => {
686
- const currentQuote = quoteRef.current;
687
- const currentText = textRef.current;
688
- const currentRole = roleRef.current;
689
- const currentRunConfig = runConfigRef.current;
690
- const currentAttachments = attachmentsRef.current;
691
- const isEmpty_0 = !currentText.trim() && !currentAttachments.length;
1107
+ $[131] = attachmentsRef;
1108
+ $[132] = discardSubmission;
1109
+ $[133] = removePendingAttachments;
1110
+ $[134] = setAttachments;
1111
+ $[135] = setQuote;
1112
+ $[136] = setRole;
1113
+ $[137] = setRunConfig;
1114
+ $[138] = setText;
1115
+ $[139] = t34;
1116
+ } else t34 = $[139];
1117
+ let t35;
1118
+ if ($[140] !== attachmentsRef || $[141] !== destroySignal || $[142] !== dispatchMessage || $[143] !== isEditingRef || $[144] !== isSendDisabled || $[145] !== prepareSubmission || $[146] !== quoteRef || $[147] !== roleRef || $[148] !== runConfigRef || $[149] !== setAttachments || $[150] !== setQuote || $[151] !== setSubmission || $[152] !== setText || $[153] !== submissionRef || $[154] !== textRef || $[155] !== type) {
1119
+ t35 = (opts) => {
1120
+ const currentAttachments = attachmentsRef.current.filter((attachment_21) => !attachmentSends.isRemoved(attachment_21));
1121
+ const isEmpty_0 = !textRef.current.trim() && !currentAttachments.length;
692
1122
  if (!isEditingRef.current) throw new Error("Composer is not available");
693
- if (isEmpty_0 || isSendDisabled) return;
694
- attachmentAddOperations.cancelAll();
695
- setText("");
696
- setAttachments([]);
697
- setQuote(void 0);
698
- const dispatch = (sendAttachments) => {
699
- const composedMessage = {
700
- role: currentRole,
701
- content: currentText ? [{
702
- type: "text",
703
- text: currentText
704
- }] : [],
705
- attachments: sendAttachments,
706
- createdAt: /* @__PURE__ */ new Date(),
707
- parentId: null,
708
- sourceId: null,
709
- runConfig: currentRunConfig,
710
- startRun: opts?.startRun,
711
- metadata: { custom: { ...currentQuote ? { quote: currentQuote } : {} } }
712
- };
713
- if (queue && type === "thread") {
714
- if (opts?.steer ?? isRunning) queue.steer(composedMessage);
715
- else queue.enqueue(composedMessage);
716
- } else onSend?.(composedMessage);
717
- if (type === "edit") setIsEditing(false);
1123
+ if (isEmpty_0 || isSendDisabled || submissionRef.current) return;
1124
+ const submitted_0 = {
1125
+ id: generateId(),
1126
+ role: roleRef.current,
1127
+ text: textRef.current,
1128
+ quote: quoteRef.current,
1129
+ attachments: currentAttachments
718
1130
  };
719
- if (attachmentAdapter && currentAttachments.length > 0) Promise.all(currentAttachments.map((attachment_2) => attachment_2.status.type === "complete" ? attachment_2 : attachmentAdapter.send(attachment_2))).then(dispatch, (error_0) => {
720
- setText((prev_3) => currentText && prev_3 ? currentText + "\n" + prev_3 : currentText || prev_3);
721
- setQuote((prev_4) => prev_4 ?? currentQuote);
722
- setAttachments((prev_5) => [...currentAttachments, ...prev_5]);
723
- console.error("Failed to send attachments", error_0);
724
- });
725
- else dispatch(currentAttachments);
1131
+ const context_1 = {
1132
+ options: opts,
1133
+ runConfig: runConfigRef.current
1134
+ };
1135
+ const complete = currentAttachments.filter(isAttachmentComplete);
1136
+ const controller = complete.length === currentAttachments.length ? void 0 : new AbortController();
1137
+ if (controller) {
1138
+ submissionSend.current = {
1139
+ ...context_1,
1140
+ controller
1141
+ };
1142
+ setSubmission(submitted_0);
1143
+ }
1144
+ if (type === "thread") {
1145
+ const detached = new Set(currentAttachments);
1146
+ setAttachments((prev_14) => prev_14.filter((attachment_22) => !detached.has(attachment_22)));
1147
+ setText("");
1148
+ setQuote(void 0);
1149
+ }
1150
+ const generation_0 = sendGeneration.current = sendGeneration.current + 1;
1151
+ if (!controller) {
1152
+ dispatchMessage(submitted_0, complete, context_1, false);
1153
+ return;
1154
+ }
1155
+ const release = abortOnDestroy(destroySignal, controller);
1156
+ prepareSubmission(generation_0).finally(release);
726
1157
  };
727
- $[62] = attachmentAdapter;
728
- $[63] = attachmentsRef;
729
- $[64] = isEditingRef;
730
- $[65] = isRunning;
731
- $[66] = isSendDisabled;
732
- $[67] = onSend;
733
- $[68] = queue;
734
- $[69] = quoteRef;
735
- $[70] = roleRef;
736
- $[71] = runConfigRef;
737
- $[72] = setAttachments;
738
- $[73] = setIsEditing;
739
- $[74] = setQuote;
740
- $[75] = setText;
741
- $[76] = textRef;
742
- $[77] = type;
743
- $[78] = t19;
744
- } else t19 = $[78];
745
- let t20;
746
- if ($[79] !== attachmentsRef || $[80] !== onCancel || $[81] !== removePendingAttachments || $[82] !== setAttachments || $[83] !== setIsEditing || $[84] !== type) {
747
- t20 = () => {
1158
+ $[140] = attachmentsRef;
1159
+ $[141] = destroySignal;
1160
+ $[142] = dispatchMessage;
1161
+ $[143] = isEditingRef;
1162
+ $[144] = isSendDisabled;
1163
+ $[145] = prepareSubmission;
1164
+ $[146] = quoteRef;
1165
+ $[147] = roleRef;
1166
+ $[148] = runConfigRef;
1167
+ $[149] = setAttachments;
1168
+ $[150] = setQuote;
1169
+ $[151] = setSubmission;
1170
+ $[152] = setText;
1171
+ $[153] = submissionRef;
1172
+ $[154] = textRef;
1173
+ $[155] = type;
1174
+ $[156] = t35;
1175
+ } else t35 = $[156];
1176
+ let t36;
1177
+ if ($[157] !== attachmentsRef || $[158] !== canCancel || $[159] !== cancelSubmission || $[160] !== discardSubmission || $[161] !== onCancel || $[162] !== removePendingAttachments || $[163] !== setAttachments || $[164] !== setIsEditing || $[165] !== submissionRef || $[166] !== type) {
1178
+ t36 = () => {
1179
+ if (type === "thread" && submissionRef.current) {
1180
+ cancelSubmission();
1181
+ if (canCancel) onCancel?.();
1182
+ return;
1183
+ }
748
1184
  if (type === "edit") {
749
1185
  attachmentAddOperations.cancelAll();
1186
+ sendGeneration.current = sendGeneration.current + 1;
1187
+ discardSubmission();
750
1188
  const removed_2 = attachmentsRef.current;
751
1189
  setAttachments([]);
752
- removePendingAttachments(removed_2).catch(_temp7);
1190
+ removePendingAttachments(removed_2).catch(_temp11);
753
1191
  }
754
1192
  onCancel?.();
755
1193
  if (type === "edit") setIsEditing(false);
756
1194
  };
757
- $[79] = attachmentsRef;
758
- $[80] = onCancel;
759
- $[81] = removePendingAttachments;
760
- $[82] = setAttachments;
761
- $[83] = setIsEditing;
762
- $[84] = type;
763
- $[85] = t20;
764
- } else t20 = $[85];
765
- let t21;
766
- if ($[86] !== isEditingRef || $[87] !== onBeginEdit || $[88] !== setIsEditing || $[89] !== type || $[90] !== updateFromMessage) {
767
- t21 = () => {
1195
+ $[157] = attachmentsRef;
1196
+ $[158] = canCancel;
1197
+ $[159] = cancelSubmission;
1198
+ $[160] = discardSubmission;
1199
+ $[161] = onCancel;
1200
+ $[162] = removePendingAttachments;
1201
+ $[163] = setAttachments;
1202
+ $[164] = setIsEditing;
1203
+ $[165] = submissionRef;
1204
+ $[166] = type;
1205
+ $[167] = t36;
1206
+ } else t36 = $[167];
1207
+ let t37;
1208
+ if ($[168] !== isEditingRef || $[169] !== onBeginEdit || $[170] !== setIsEditing || $[171] !== type || $[172] !== updateFromMessage) {
1209
+ t37 = () => {
768
1210
  onBeginEdit?.();
769
1211
  if (type === "thread") return;
770
1212
  if (isEditingRef.current) throw new Error("Edit already in progress");
771
1213
  setIsEditing(true);
772
1214
  updateFromMessage();
773
1215
  };
774
- $[86] = isEditingRef;
775
- $[87] = onBeginEdit;
776
- $[88] = setIsEditing;
777
- $[89] = type;
778
- $[90] = updateFromMessage;
779
- $[91] = t21;
780
- } else t21 = $[91];
781
- let t22;
782
- if ($[92] !== queueItemClients) {
783
- t22 = (selector_0) => {
1216
+ $[168] = isEditingRef;
1217
+ $[169] = onBeginEdit;
1218
+ $[170] = setIsEditing;
1219
+ $[171] = type;
1220
+ $[172] = updateFromMessage;
1221
+ $[173] = t37;
1222
+ } else t37 = $[173];
1223
+ let t38;
1224
+ if ($[174] !== queueItemClients) {
1225
+ t38 = (selector_0) => {
784
1226
  if ("id" in selector_0) return queueItemClients.get({ key: selector_0.id });
785
1227
  return queueItemClients.get(selector_0);
786
1228
  };
787
- $[92] = queueItemClients;
788
- $[93] = t22;
789
- } else t22 = $[93];
790
- let t23;
791
- if ($[94] !== setQuote || $[95] !== setRole || $[96] !== setRunConfig || $[97] !== setText || $[98] !== t14 || $[99] !== t15 || $[100] !== t16 || $[101] !== t17 || $[102] !== t18 || $[103] !== t19 || $[104] !== t20 || $[105] !== t21 || $[106] !== t22) {
792
- t23 = {
793
- getState: t14,
1229
+ $[174] = queueItemClients;
1230
+ $[175] = t38;
1231
+ } else t38 = $[175];
1232
+ let t39;
1233
+ if ($[176] !== setQuote || $[177] !== setRole || $[178] !== setRunConfig || $[179] !== setText || $[180] !== t30 || $[181] !== t31 || $[182] !== t32 || $[183] !== t33 || $[184] !== t34 || $[185] !== t35 || $[186] !== t36 || $[187] !== t37 || $[188] !== t38) {
1234
+ t39 = {
1235
+ getState: t30,
794
1236
  setText,
795
1237
  setRole,
796
1238
  setRunConfig,
797
- addAttachment: t15,
798
- clearAttachments: t16,
799
- attachment: t17,
800
- reset: t18,
801
- send: t19,
802
- cancel: t20,
803
- beginEdit: t21,
804
- startDictation: _temp8,
805
- stopDictation: _temp9,
1239
+ addAttachment: t31,
1240
+ clearAttachments: t32,
1241
+ attachment: t33,
1242
+ reset: t34,
1243
+ send: t35,
1244
+ cancel: t36,
1245
+ beginEdit: t37,
1246
+ startDictation: _temp12,
1247
+ stopDictation: _temp13,
806
1248
  setQuote,
807
- queueItem: t22
1249
+ queueItem: t38
808
1250
  };
809
- $[94] = setQuote;
810
- $[95] = setRole;
811
- $[96] = setRunConfig;
812
- $[97] = setText;
813
- $[98] = t14;
814
- $[99] = t15;
815
- $[100] = t16;
816
- $[101] = t17;
817
- $[102] = t18;
818
- $[103] = t19;
819
- $[104] = t20;
820
- $[105] = t21;
821
- $[106] = t22;
822
- $[107] = t23;
823
- } else t23 = $[107];
824
- return t23;
1251
+ $[176] = setQuote;
1252
+ $[177] = setRole;
1253
+ $[178] = setRunConfig;
1254
+ $[179] = setText;
1255
+ $[180] = t30;
1256
+ $[181] = t31;
1257
+ $[182] = t32;
1258
+ $[183] = t33;
1259
+ $[184] = t34;
1260
+ $[185] = t35;
1261
+ $[186] = t36;
1262
+ $[187] = t37;
1263
+ $[188] = t38;
1264
+ $[189] = t39;
1265
+ } else t39 = $[189];
1266
+ return t39;
825
1267
  };
826
1268
  const ComposerClientResource = resource(useComposerClientResource);
827
1269
  const createSpeechController = (notify) => {
@@ -890,8 +1332,8 @@ const dedupeMessagesById = (messages) => {
890
1332
  return deduped.length === messages.length ? messages : deduped.reverse();
891
1333
  };
892
1334
  const useExternalThread = (t0) => {
893
- const $ = c(125);
894
- const { messages: messagesProp, isRunning: t1, isLoading: t2, state: threadState, extras, isSendDisabled: t3, onNew, onEdit, onReload, onStartRun, onCancel, onResume, onRefetchThread, onAddToolResult, onResumeToolCall, onLoadExternalState, attachmentAdapter, feedbackAdapter, speechAdapter, queue, branches, onRespondToToolApproval } = t0;
1335
+ const $ = c(146);
1336
+ const { messages: messagesProp, isRunning: t1, isLoading: t2, state: threadState, extras, isSendDisabled: t3, onNew, onEdit, onReload, onStartRun, onCancel, onResume, onRefetchThread, onAddToolResult, onResumeToolCall, unstable_onRecordToolInteraction, onLoadExternalState, attachmentAdapter, feedbackAdapter, speechAdapter, queue, branches, onRespondToToolApproval } = t0;
895
1337
  const isRunning = t1 === void 0 ? false : t1;
896
1338
  const isLoading = t2 === void 0 ? false : t2;
897
1339
  const isSendDisabled = t3 === void 0 ? false : t3;
@@ -912,7 +1354,8 @@ const useExternalThread = (t0) => {
912
1354
  if ($[3] !== submittedFeedback) {
913
1355
  t6 = (msg) => {
914
1356
  const entry = submittedFeedback[msg.id];
915
- return entry && msg.metadata.submittedFeedback?.type === entry.external ? entry.type : void 0;
1357
+ const external = msg.metadata.submittedFeedback;
1358
+ return entry && external?.type === entry.external?.type && external?.comment === entry.external?.comment ? entry.feedback : void 0;
916
1359
  };
917
1360
  $[3] = submittedFeedback;
918
1361
  $[4] = t6;
@@ -926,7 +1369,7 @@ const useExternalThread = (t0) => {
926
1369
  const live = Object.entries(prev).filter((t9) => {
927
1370
  const [id, entry_0] = t9;
928
1371
  const msg_0 = messages.find((m) => m.id === id);
929
- return !!msg_0 && msg_0.metadata.submittedFeedback?.type === entry_0.external;
1372
+ return !!msg_0 && msg_0.metadata.submittedFeedback?.type === entry_0.external?.type && msg_0.metadata.submittedFeedback?.comment === entry_0.external?.comment;
930
1373
  });
931
1374
  return live.length === Object.keys(prev).length ? prev : Object.fromEntries(live);
932
1375
  });
@@ -942,18 +1385,21 @@ const useExternalThread = (t0) => {
942
1385
  useEffect(t7, t8);
943
1386
  let t9;
944
1387
  if ($[8] !== feedbackAdapter) {
945
- t9 = (message, t10) => {
946
- const { type } = t10;
947
- if (!feedbackAdapter) throw new Error("Feedback adapter not configured");
948
- feedbackAdapter.submit({
1388
+ t9 = (message, feedback) => {
1389
+ const comment = feedback.comment?.trim();
1390
+ const submittedFeedback_0 = {
1391
+ type: feedback.type,
1392
+ ...comment ? { comment } : void 0
1393
+ };
1394
+ feedbackAdapter?.submit({
949
1395
  message,
950
- type
1396
+ ...submittedFeedback_0
951
1397
  });
952
1398
  if (message.role === "assistant") setSubmittedFeedback((prev_0) => ({
953
1399
  ...prev_0,
954
1400
  [message.id]: {
955
- type,
956
- external: message.metadata.submittedFeedback?.type
1401
+ feedback: submittedFeedback_0,
1402
+ external: message.metadata.submittedFeedback
957
1403
  }
958
1404
  }));
959
1405
  };
@@ -1024,146 +1470,209 @@ const useExternalThread = (t0) => {
1024
1470
  } else t16 = $[23];
1025
1471
  const handleReload = t16;
1026
1472
  let t17;
1027
- if ($[24] !== attachmentAdapter || $[25] !== branches || $[26] !== feedbackFor || $[27] !== handleReload || $[28] !== handleSpeak || $[29] !== handleSubmitFeedback || $[30] !== messages || $[31] !== onAddToolResult || $[32] !== onEdit || $[33] !== onRespondToToolApproval || $[34] !== onResumeToolCall || $[35] !== queue || $[36] !== speech || $[37] !== speechController) {
1028
- t17 = messages.map((msg_1, index) => {
1029
- const props = {
1030
- message: msg_1,
1031
- index,
1032
- parentId: index > 0 ? messages[index - 1].id : null,
1033
- onReload: () => handleReload(msg_1.id),
1034
- queue,
1035
- branches,
1036
- onRespondToToolApproval,
1037
- onAddToolResult,
1038
- onResumeToolCall,
1039
- attachmentAdapter,
1040
- submittedFeedback: feedbackFor(msg_1),
1041
- onSubmitFeedback: (feedback) => handleSubmitFeedback(msg_1, feedback),
1042
- speech: speech?.messageId === msg_1.id ? speech : void 0,
1043
- onSpeak: () => handleSpeak(msg_1),
1044
- onStopSpeaking: () => speechController.stopMessage(msg_1.id)
1045
- };
1046
- if (onEdit) props.onEdit = onEdit;
1047
- return withKey(msg_1.id, MessageClient(props));
1048
- });
1049
- $[24] = attachmentAdapter;
1050
- $[25] = branches;
1051
- $[26] = feedbackFor;
1052
- $[27] = handleReload;
1053
- $[28] = handleSpeak;
1054
- $[29] = handleSubmitFeedback;
1055
- $[30] = messages;
1056
- $[31] = onAddToolResult;
1057
- $[32] = onEdit;
1058
- $[33] = onRespondToToolApproval;
1059
- $[34] = onResumeToolCall;
1060
- $[35] = queue;
1061
- $[36] = speech;
1062
- $[37] = speechController;
1063
- $[38] = t17;
1064
- } else t17 = $[38];
1065
- const messageClients = useClientLookup(t17);
1473
+ if ($[24] !== messages) {
1474
+ t17 = messages.map(_temp14);
1475
+ $[24] = messages;
1476
+ $[25] = t17;
1477
+ } else t17 = $[25];
1478
+ const messageKeys = t17;
1066
1479
  let t18;
1067
- if ($[39] === Symbol.for("react.memo_cache_sentinel")) {
1068
- t18 = createTaskDeriver();
1069
- $[39] = t18;
1070
- } else t18 = $[39];
1071
- const taskDeriver = t18;
1072
- let t19;
1073
- if ($[40] !== messages) {
1074
- t19 = taskDeriver(messages);
1075
- $[40] = messages;
1076
- $[41] = t19;
1077
- } else t19 = $[41];
1078
- const tasks = t19;
1079
- let t20;
1080
- if ($[42] !== tasks) {
1081
- t20 = tasks.map(_temp0);
1082
- $[42] = tasks;
1083
- $[43] = t20;
1084
- } else t20 = $[43];
1085
- const taskClients = useClientLookup(t20);
1086
- let t21;
1087
- if ($[44] !== onCancel || $[45] !== queue) {
1088
- t21 = () => {
1480
+ if ($[26] !== onCancel || $[27] !== queue) {
1481
+ t18 = () => {
1089
1482
  if (!onCancel) return;
1090
1483
  queue?.__internal_notifyCancelled?.();
1091
1484
  onCancel();
1092
1485
  };
1093
- $[44] = onCancel;
1094
- $[45] = queue;
1095
- $[46] = t21;
1096
- } else t21 = $[46];
1097
- const handleCancelRun = t21;
1098
- let t22;
1099
- if ($[47] !== messages || $[48] !== onNew) {
1100
- t22 = (message_1) => {
1486
+ $[26] = onCancel;
1487
+ $[27] = queue;
1488
+ $[28] = t18;
1489
+ } else t18 = $[28];
1490
+ const handleCancelRun = t18;
1491
+ let t19;
1492
+ if ($[29] !== messages || $[30] !== onNew) {
1493
+ t19 = (message_2) => {
1101
1494
  onNew?.({
1102
- ...message_1,
1495
+ ...message_2,
1103
1496
  parentId: messages.at(-1)?.id ?? null
1104
1497
  });
1105
1498
  };
1106
- $[47] = messages;
1107
- $[48] = onNew;
1108
- $[49] = t22;
1109
- } else t22 = $[49];
1110
- const handleSendNew = t22;
1111
- let t23;
1112
- if ($[50] !== messages) {
1113
- t23 = messages.at(-1)?.id ?? null;
1114
- $[50] = messages;
1115
- $[51] = t23;
1116
- } else t23 = $[51];
1117
- const headId = t23;
1499
+ $[29] = messages;
1500
+ $[30] = onNew;
1501
+ $[31] = t19;
1502
+ } else t19 = $[31];
1503
+ const handleSendNew = t19;
1504
+ let t20;
1505
+ if ($[32] !== messages) {
1506
+ t20 = messages.at(-1)?.id ?? null;
1507
+ $[32] = messages;
1508
+ $[33] = t20;
1509
+ } else t20 = $[33];
1510
+ const headId = t20;
1118
1511
  const hasCancel = !!onCancel;
1119
1512
  const hasRefetchThread = !!onRefetchThread;
1120
- let t24;
1121
- if ($[52] !== headId || $[53] !== queue) {
1122
- t24 = queue && {
1513
+ let t21;
1514
+ if ($[34] !== headId || $[35] !== queue) {
1515
+ t21 = queue && {
1123
1516
  ...queue,
1124
- enqueue: (message_2) => queue.enqueue({
1125
- ...message_2,
1126
- parentId: message_2.parentId ?? headId
1127
- }),
1128
- steer: (message_3) => queue.steer({
1517
+ enqueue: (message_3) => queue.enqueue({
1129
1518
  ...message_3,
1130
1519
  parentId: message_3.parentId ?? headId
1520
+ }),
1521
+ steer: (message_4) => queue.steer({
1522
+ ...message_4,
1523
+ parentId: message_4.parentId ?? headId
1131
1524
  })
1132
1525
  };
1133
- $[52] = headId;
1134
- $[53] = queue;
1135
- $[54] = t24;
1136
- } else t24 = $[54];
1137
- const composerQueue = t24;
1138
- const t25 = isRunning && hasCancel;
1139
- let t26;
1140
- if ($[55] !== attachmentAdapter || $[56] !== composerQueue || $[57] !== handleCancelRun || $[58] !== handleSendNew || $[59] !== isRunning || $[60] !== isSendDisabled || $[61] !== t25) {
1141
- t26 = ComposerClientResource({
1526
+ $[34] = headId;
1527
+ $[35] = queue;
1528
+ $[36] = t21;
1529
+ } else t21 = $[36];
1530
+ const composerQueue = t21;
1531
+ const t22 = isRunning && hasCancel;
1532
+ let t23;
1533
+ if ($[37] !== attachmentAdapter || $[38] !== composerQueue || $[39] !== handleCancelRun || $[40] !== handleSendNew || $[41] !== isRunning || $[42] !== isSendDisabled || $[43] !== messageKeys || $[44] !== t22) {
1534
+ t23 = ComposerClientResource({
1142
1535
  type: "thread",
1143
- canCancel: t25,
1536
+ canCancel: t22,
1144
1537
  isRunning,
1145
1538
  isSendDisabled,
1146
1539
  onCancel: handleCancelRun,
1147
1540
  onSend: handleSendNew,
1148
1541
  queue: composerQueue,
1149
- attachmentAdapter
1542
+ attachmentAdapter,
1543
+ messageKeys
1150
1544
  });
1151
- $[55] = attachmentAdapter;
1152
- $[56] = composerQueue;
1153
- $[57] = handleCancelRun;
1154
- $[58] = handleSendNew;
1155
- $[59] = isRunning;
1156
- $[60] = isSendDisabled;
1157
- $[61] = t25;
1158
- $[62] = t26;
1159
- } else t26 = $[62];
1160
- const composerClient = useClientResource(t26);
1545
+ $[37] = attachmentAdapter;
1546
+ $[38] = composerQueue;
1547
+ $[39] = handleCancelRun;
1548
+ $[40] = handleSendNew;
1549
+ $[41] = isRunning;
1550
+ $[42] = isSendDisabled;
1551
+ $[43] = messageKeys;
1552
+ $[44] = t22;
1553
+ $[45] = t23;
1554
+ } else t23 = $[45];
1555
+ const composerClient = useClientResource(t23);
1556
+ const submission = composerClient.state.submission;
1557
+ const inTransit = composerClient.state.inTransit;
1558
+ let t24;
1559
+ if ($[46] !== inTransit) {
1560
+ t24 = inTransit ?? [];
1561
+ $[46] = inTransit;
1562
+ $[47] = t24;
1563
+ } else t24 = $[47];
1564
+ let t25;
1565
+ if ($[48] !== submission) {
1566
+ t25 = submission ? [submission] : [];
1567
+ $[48] = submission;
1568
+ $[49] = t25;
1569
+ } else t25 = $[49];
1570
+ let t26;
1571
+ if ($[50] !== t24 || $[51] !== t25) {
1572
+ t26 = [...t24, ...t25];
1573
+ $[50] = t24;
1574
+ $[51] = t25;
1575
+ $[52] = t26;
1576
+ } else t26 = $[52];
1577
+ const pending = t26;
1578
+ const hasPending = pending.length > 0;
1161
1579
  let t27;
1162
- if ($[63] === Symbol.for("react.memo_cache_sentinel")) {
1163
- t27 = ThreadSuggestions(EMPTY_SUGGESTIONS);
1164
- $[63] = t27;
1165
- } else t27 = $[63];
1166
- const suggestionsClient = useClientResource(t27);
1580
+ if ($[53] !== attachmentAdapter || $[54] !== branches || $[55] !== feedbackFor || $[56] !== handleReload || $[57] !== handleSpeak || $[58] !== handleSubmitFeedback || $[59] !== hasPending || $[60] !== messages || $[61] !== onAddToolResult || $[62] !== onEdit || $[63] !== onRespondToToolApproval || $[64] !== onResumeToolCall || $[65] !== queue || $[66] !== speech || $[67] !== speechController || $[68] !== unstable_onRecordToolInteraction) {
1581
+ t27 = messages.map((msg_1, index) => {
1582
+ const props = {
1583
+ message: msg_1,
1584
+ index,
1585
+ isLast: index === messages.length - 1 && !hasPending,
1586
+ parentId: index > 0 ? messages[index - 1].id : null,
1587
+ onReload: () => handleReload(msg_1.id),
1588
+ queue,
1589
+ branches,
1590
+ onRespondToToolApproval,
1591
+ unstable_onRecordToolInteraction,
1592
+ onAddToolResult,
1593
+ onResumeToolCall,
1594
+ attachmentAdapter,
1595
+ submittedFeedback: feedbackFor(msg_1),
1596
+ onSubmitFeedback: (feedback_0) => handleSubmitFeedback(msg_1, feedback_0),
1597
+ speech: speech?.messageId === msg_1.id ? speech : void 0,
1598
+ onSpeak: () => handleSpeak(msg_1),
1599
+ onStopSpeaking: () => speechController.stopMessage(msg_1.id)
1600
+ };
1601
+ if (onEdit) props.onEdit = onEdit;
1602
+ return withKey(msg_1.id, MessageClient(props));
1603
+ });
1604
+ $[53] = attachmentAdapter;
1605
+ $[54] = branches;
1606
+ $[55] = feedbackFor;
1607
+ $[56] = handleReload;
1608
+ $[57] = handleSpeak;
1609
+ $[58] = handleSubmitFeedback;
1610
+ $[59] = hasPending;
1611
+ $[60] = messages;
1612
+ $[61] = onAddToolResult;
1613
+ $[62] = onEdit;
1614
+ $[63] = onRespondToToolApproval;
1615
+ $[64] = onResumeToolCall;
1616
+ $[65] = queue;
1617
+ $[66] = speech;
1618
+ $[67] = speechController;
1619
+ $[68] = unstable_onRecordToolInteraction;
1620
+ $[69] = t27;
1621
+ } else t27 = $[69];
1622
+ const messageClients = useClientLookup(t27);
1623
+ let t28;
1624
+ if ($[70] !== pending) {
1625
+ t28 = pending.map(submissionThreadMessage);
1626
+ $[70] = pending;
1627
+ $[71] = t28;
1628
+ } else t28 = $[71];
1629
+ const pendingMessages = t28;
1630
+ let t29;
1631
+ if ($[72] !== messages.length || $[73] !== pending || $[74] !== pendingMessages) {
1632
+ t29 = pending.map((row, index_0) => withKey(row.id, ThreadMessageClient({
1633
+ message: pendingMessages[index_0],
1634
+ submission: row,
1635
+ index: messages.length + index_0,
1636
+ isLast: index_0 === pending.length - 1
1637
+ }), [
1638
+ pendingMessages[index_0],
1639
+ row,
1640
+ messages.length,
1641
+ index_0,
1642
+ pending.length
1643
+ ]));
1644
+ $[72] = messages.length;
1645
+ $[73] = pending;
1646
+ $[74] = pendingMessages;
1647
+ $[75] = t29;
1648
+ } else t29 = $[75];
1649
+ const pendingClients = useClientLookup(t29);
1650
+ let t30;
1651
+ if ($[76] === Symbol.for("react.memo_cache_sentinel")) {
1652
+ t30 = createTaskDeriver();
1653
+ $[76] = t30;
1654
+ } else t30 = $[76];
1655
+ const taskDeriver = t30;
1656
+ let t31;
1657
+ if ($[77] !== messages) {
1658
+ t31 = taskDeriver(messages);
1659
+ $[77] = messages;
1660
+ $[78] = t31;
1661
+ } else t31 = $[78];
1662
+ const tasks = t31;
1663
+ let t32;
1664
+ if ($[79] !== tasks) {
1665
+ t32 = tasks.map(_temp15);
1666
+ $[79] = tasks;
1667
+ $[80] = t32;
1668
+ } else t32 = $[80];
1669
+ const taskClients = useClientLookup(t32);
1670
+ let t33;
1671
+ if ($[81] === Symbol.for("react.memo_cache_sentinel")) {
1672
+ t33 = ThreadSuggestions(EMPTY_SUGGESTIONS);
1673
+ $[81] = t33;
1674
+ } else t33 = $[81];
1675
+ const suggestionsClient = useClientResource(t33);
1167
1676
  const hasQueue = !!queue;
1168
1677
  const hasBranches = !!branches;
1169
1678
  const hasEdit = !!onEdit;
@@ -1171,17 +1680,18 @@ const useExternalThread = (t0) => {
1171
1680
  const hasAttachments = !!attachmentAdapter;
1172
1681
  const hasFeedback = !!feedbackAdapter;
1173
1682
  const hasSpeech = !!speechAdapter;
1174
- let t28;
1175
- if ($[64] !== messageClients.state) {
1176
- t28 = messageClients.state.map(_temp1);
1177
- $[64] = messageClients.state;
1178
- $[65] = t28;
1179
- } else t28 = $[65];
1180
- const messageStates = t28;
1181
- const t29 = messages.length === 0 && !isLoading;
1182
- let t30;
1183
- if ($[66] !== hasAttachments || $[67] !== hasBranches || $[68] !== hasCancel || $[69] !== hasEdit || $[70] !== hasFeedback || $[71] !== hasQueue || $[72] !== hasRefetchThread || $[73] !== hasReload || $[74] !== hasSpeech) {
1184
- t30 = {
1683
+ let t34;
1684
+ if ($[82] !== messageClients.state || $[83] !== pendingClients.state) {
1685
+ t34 = pendingClients.state.length === 0 ? messageClients.state : [...messageClients.state, ...pendingClients.state];
1686
+ $[82] = messageClients.state;
1687
+ $[83] = pendingClients.state;
1688
+ $[84] = t34;
1689
+ } else t34 = $[84];
1690
+ const messageStates = t34;
1691
+ const t35 = messageStates.length === 0 && !isLoading;
1692
+ let t36;
1693
+ if ($[85] !== hasAttachments || $[86] !== hasBranches || $[87] !== hasCancel || $[88] !== hasEdit || $[89] !== hasFeedback || $[90] !== hasQueue || $[91] !== hasRefetchThread || $[92] !== hasReload || $[93] !== hasSpeech) {
1694
+ t36 = {
1185
1695
  edit: hasEdit,
1186
1696
  delete: false,
1187
1697
  reload: hasReload,
@@ -1197,88 +1707,88 @@ const useExternalThread = (t0) => {
1197
1707
  dictation: false,
1198
1708
  queue: hasQueue
1199
1709
  };
1200
- $[66] = hasAttachments;
1201
- $[67] = hasBranches;
1202
- $[68] = hasCancel;
1203
- $[69] = hasEdit;
1204
- $[70] = hasFeedback;
1205
- $[71] = hasQueue;
1206
- $[72] = hasRefetchThread;
1207
- $[73] = hasReload;
1208
- $[74] = hasSpeech;
1209
- $[75] = t30;
1210
- } else t30 = $[75];
1211
- let t31;
1212
- if ($[76] !== threadState) {
1213
- t31 = threadState ?? {};
1214
- $[76] = threadState;
1215
- $[77] = t31;
1216
- } else t31 = $[77];
1217
- let t32;
1218
- if ($[78] !== composerClient.state || $[79] !== extras || $[80] !== isLoading || $[81] !== isRunning || $[82] !== messageStates || $[83] !== speech || $[84] !== t29 || $[85] !== t30 || $[86] !== t31 || $[87] !== tasks) {
1219
- t32 = {
1220
- isEmpty: t29,
1710
+ $[85] = hasAttachments;
1711
+ $[86] = hasBranches;
1712
+ $[87] = hasCancel;
1713
+ $[88] = hasEdit;
1714
+ $[89] = hasFeedback;
1715
+ $[90] = hasQueue;
1716
+ $[91] = hasRefetchThread;
1717
+ $[92] = hasReload;
1718
+ $[93] = hasSpeech;
1719
+ $[94] = t36;
1720
+ } else t36 = $[94];
1721
+ let t37;
1722
+ if ($[95] !== threadState) {
1723
+ t37 = threadState ?? {};
1724
+ $[95] = threadState;
1725
+ $[96] = t37;
1726
+ } else t37 = $[96];
1727
+ let t38;
1728
+ if ($[97] !== composerClient.state || $[98] !== extras || $[99] !== isLoading || $[100] !== isRunning || $[101] !== messageStates || $[102] !== speech || $[103] !== t35 || $[104] !== t36 || $[105] !== t37 || $[106] !== tasks) {
1729
+ t38 = {
1730
+ isEmpty: t35,
1221
1731
  isDisabled: false,
1222
1732
  isLoading,
1223
1733
  isRunning,
1224
- capabilities: t30,
1734
+ capabilities: t36,
1225
1735
  messages: messageStates,
1226
1736
  tasks,
1227
- state: t31,
1737
+ state: t37,
1228
1738
  suggestions: EMPTY_SUGGESTIONS,
1229
1739
  extras,
1230
1740
  speech,
1231
1741
  voice: void 0,
1232
1742
  composer: composerClient.state
1233
1743
  };
1234
- $[78] = composerClient.state;
1235
- $[79] = extras;
1236
- $[80] = isLoading;
1237
- $[81] = isRunning;
1238
- $[82] = messageStates;
1239
- $[83] = speech;
1240
- $[84] = t29;
1241
- $[85] = t30;
1242
- $[86] = t31;
1243
- $[87] = tasks;
1244
- $[88] = t32;
1245
- } else t32 = $[88];
1246
- const state = t32;
1247
- let t33;
1248
- if ($[89] !== state) {
1249
- t33 = () => state;
1250
- $[89] = state;
1251
- $[90] = t33;
1252
- } else t33 = $[90];
1253
- let t34;
1254
- if ($[91] !== composerClient.methods) {
1255
- t34 = () => composerClient.methods;
1256
- $[91] = composerClient.methods;
1257
- $[92] = t34;
1258
- } else t34 = $[92];
1259
- let t35;
1260
- if ($[93] !== suggestionsClient) {
1261
- t35 = () => suggestionsClient.methods;
1262
- $[93] = suggestionsClient;
1263
- $[94] = t35;
1264
- } else t35 = $[94];
1265
- let t36;
1266
- if ($[95] !== taskClients || $[96] !== tasks) {
1267
- t36 = (selector) => {
1744
+ $[97] = composerClient.state;
1745
+ $[98] = extras;
1746
+ $[99] = isLoading;
1747
+ $[100] = isRunning;
1748
+ $[101] = messageStates;
1749
+ $[102] = speech;
1750
+ $[103] = t35;
1751
+ $[104] = t36;
1752
+ $[105] = t37;
1753
+ $[106] = tasks;
1754
+ $[107] = t38;
1755
+ } else t38 = $[107];
1756
+ const state = t38;
1757
+ let t39;
1758
+ if ($[108] !== state) {
1759
+ t39 = () => state;
1760
+ $[108] = state;
1761
+ $[109] = t39;
1762
+ } else t39 = $[109];
1763
+ let t40;
1764
+ if ($[110] !== composerClient.methods) {
1765
+ t40 = () => composerClient.methods;
1766
+ $[110] = composerClient.methods;
1767
+ $[111] = t40;
1768
+ } else t40 = $[111];
1769
+ let t41;
1770
+ if ($[112] !== suggestionsClient) {
1771
+ t41 = () => suggestionsClient.methods;
1772
+ $[112] = suggestionsClient;
1773
+ $[113] = t41;
1774
+ } else t41 = $[113];
1775
+ let t42;
1776
+ if ($[114] !== taskClients || $[115] !== tasks) {
1777
+ t42 = (selector) => {
1268
1778
  if ("id" in selector) {
1269
1779
  const task_0 = tasks.find((candidate) => candidate.id === selector.id);
1270
1780
  return taskClients.get({ key: task_0 ? getTaskKey(task_0) : selector.id });
1271
1781
  }
1272
1782
  return taskClients.get(selector);
1273
1783
  };
1274
- $[95] = taskClients;
1275
- $[96] = tasks;
1276
- $[97] = t36;
1277
- } else t36 = $[97];
1278
- let t37;
1279
- if ($[98] !== messages || $[99] !== onNew || $[100] !== queue) {
1280
- t37 = (message_4) => {
1281
- const appendMessage = typeof message_4 === "string" ? {
1784
+ $[114] = taskClients;
1785
+ $[115] = tasks;
1786
+ $[116] = t42;
1787
+ } else t42 = $[116];
1788
+ let t43;
1789
+ if ($[117] !== messages || $[118] !== onNew || $[119] !== queue) {
1790
+ t43 = (message_5) => {
1791
+ const appendMessage = typeof message_5 === "string" ? {
1282
1792
  createdAt: /* @__PURE__ */ new Date(),
1283
1793
  parentId: messages.at(-1)?.id ?? null,
1284
1794
  sourceId: null,
@@ -1286,112 +1796,118 @@ const useExternalThread = (t0) => {
1286
1796
  role: "user",
1287
1797
  content: [{
1288
1798
  type: "text",
1289
- text: message_4
1799
+ text: message_5
1290
1800
  }],
1291
1801
  attachments: [],
1292
1802
  metadata: { custom: {} }
1293
1803
  } : {
1294
- createdAt: message_4.createdAt ?? /* @__PURE__ */ new Date(),
1295
- parentId: message_4.parentId === void 0 ? messages.at(-1)?.id ?? null : message_4.parentId,
1296
- sourceId: message_4.sourceId ?? null,
1297
- role: message_4.role ?? "user",
1298
- content: message_4.content,
1299
- attachments: message_4.attachments ?? [],
1300
- metadata: message_4.metadata ?? { custom: {} },
1301
- runConfig: message_4.runConfig ?? {},
1302
- startRun: message_4.startRun
1804
+ createdAt: message_5.createdAt ?? /* @__PURE__ */ new Date(),
1805
+ parentId: message_5.parentId === void 0 ? messages.at(-1)?.id ?? null : message_5.parentId,
1806
+ sourceId: message_5.sourceId ?? null,
1807
+ role: message_5.role ?? "user",
1808
+ content: message_5.content,
1809
+ attachments: message_5.attachments ?? [],
1810
+ metadata: message_5.metadata ?? { custom: {} },
1811
+ runConfig: message_5.runConfig ?? {},
1812
+ startRun: message_5.startRun
1303
1813
  };
1304
1814
  if (queue) queue.enqueue(appendMessage);
1305
1815
  else onNew?.(appendMessage);
1306
1816
  };
1307
- $[98] = messages;
1308
- $[99] = onNew;
1309
- $[100] = queue;
1310
- $[101] = t37;
1311
- } else t37 = $[101];
1312
- let t38;
1313
- if ($[102] !== onStartRun) {
1314
- t38 = () => {
1817
+ $[117] = messages;
1818
+ $[118] = onNew;
1819
+ $[119] = queue;
1820
+ $[120] = t43;
1821
+ } else t43 = $[120];
1822
+ let t44;
1823
+ if ($[121] !== onStartRun) {
1824
+ t44 = () => {
1315
1825
  onStartRun?.();
1316
1826
  };
1317
- $[102] = onStartRun;
1318
- $[103] = t38;
1319
- } else t38 = $[103];
1320
- let t39;
1321
- if ($[104] !== onResume) {
1322
- t39 = () => {
1827
+ $[121] = onStartRun;
1828
+ $[122] = t44;
1829
+ } else t44 = $[122];
1830
+ let t45;
1831
+ if ($[123] !== onResume) {
1832
+ t45 = () => {
1323
1833
  if (!onResume) throw new Error("Runtime does not support resuming runs (onResume is not set).");
1324
1834
  onResume();
1325
1835
  };
1326
- $[104] = onResume;
1327
- $[105] = t39;
1328
- } else t39 = $[105];
1329
- let t40;
1330
- if ($[106] !== onRefetchThread) {
1331
- t40 = onRefetchThread && { unstable_refetchThread: onRefetchThread };
1332
- $[106] = onRefetchThread;
1333
- $[107] = t40;
1334
- } else t40 = $[107];
1335
- let t41;
1336
- if ($[108] !== onLoadExternalState) {
1337
- t41 = (state_0) => {
1836
+ $[123] = onResume;
1837
+ $[124] = t45;
1838
+ } else t45 = $[124];
1839
+ let t46;
1840
+ if ($[125] !== onRefetchThread) {
1841
+ t46 = onRefetchThread && { unstable_refetchThread: onRefetchThread };
1842
+ $[125] = onRefetchThread;
1843
+ $[126] = t46;
1844
+ } else t46 = $[126];
1845
+ let t47;
1846
+ if ($[127] !== onLoadExternalState) {
1847
+ t47 = (state_0) => {
1338
1848
  if (!onLoadExternalState) throw new Error("Runtime does not support importing external states (onLoadExternalState is not set).");
1339
1849
  onLoadExternalState(state_0);
1340
1850
  };
1341
- $[108] = onLoadExternalState;
1342
- $[109] = t41;
1343
- } else t41 = $[109];
1344
- let t42;
1345
- if ($[110] !== messageClients) {
1346
- t42 = (selector_0) => {
1347
- if ("id" in selector_0) return messageClients.get({ key: selector_0.id });
1851
+ $[127] = onLoadExternalState;
1852
+ $[128] = t47;
1853
+ } else t47 = $[128];
1854
+ let t48;
1855
+ if ($[129] !== messageClients || $[130] !== pending || $[131] !== pendingClients) {
1856
+ t48 = (selector_0) => {
1857
+ if ("id" in selector_0) {
1858
+ if (pending.some((row_0) => row_0.id === selector_0.id)) return pendingClients.get({ key: selector_0.id });
1859
+ return messageClients.get({ key: selector_0.id });
1860
+ }
1861
+ if (selector_0.index >= messageClients.state.length) return pendingClients.get({ index: selector_0.index - messageClients.state.length });
1348
1862
  return messageClients.get(selector_0);
1349
1863
  };
1350
- $[110] = messageClients;
1351
- $[111] = t42;
1352
- } else t42 = $[111];
1353
- let t43;
1354
- if ($[112] !== handleCancelRun || $[113] !== speechController.stop || $[114] !== t33 || $[115] !== t34 || $[116] !== t35 || $[117] !== t36 || $[118] !== t37 || $[119] !== t38 || $[120] !== t39 || $[121] !== t40 || $[122] !== t41 || $[123] !== t42) {
1355
- t43 = {
1356
- getState: t33,
1357
- composer: t34,
1358
- suggestions: t35,
1359
- task: t36,
1360
- append: t37,
1361
- deleteMessage: _temp10,
1362
- startRun: t38,
1363
- resumeRun: t39,
1864
+ $[129] = messageClients;
1865
+ $[130] = pending;
1866
+ $[131] = pendingClients;
1867
+ $[132] = t48;
1868
+ } else t48 = $[132];
1869
+ let t49;
1870
+ if ($[133] !== handleCancelRun || $[134] !== speechController.stop || $[135] !== t39 || $[136] !== t40 || $[137] !== t41 || $[138] !== t42 || $[139] !== t43 || $[140] !== t44 || $[141] !== t45 || $[142] !== t46 || $[143] !== t47 || $[144] !== t48) {
1871
+ t49 = {
1872
+ getState: t39,
1873
+ composer: t40,
1874
+ suggestions: t41,
1875
+ task: t42,
1876
+ append: t43,
1877
+ deleteMessage: _temp16,
1878
+ startRun: t44,
1879
+ resumeRun: t45,
1364
1880
  cancelRun: handleCancelRun,
1365
- ...t40,
1366
- importExternalState: t41,
1367
- getModelContext: _temp11,
1368
- export: _temp12,
1369
- import: _temp13,
1370
- reset: _temp14,
1371
- message: t42,
1881
+ ...t46,
1882
+ importExternalState: t47,
1883
+ getModelContext: _temp17,
1884
+ export: _temp18,
1885
+ import: _temp19,
1886
+ reset: _temp20,
1887
+ message: t48,
1372
1888
  stopSpeaking: speechController.stop,
1373
- connectVoice: _temp15,
1374
- disconnectVoice: _temp16,
1375
- getVoiceVolume: _temp17,
1376
- subscribeVoiceVolume: _temp19,
1377
- muteVoice: _temp20,
1378
- unmuteVoice: _temp21
1889
+ connectVoice: _temp21,
1890
+ disconnectVoice: _temp22,
1891
+ getVoiceVolume: _temp23,
1892
+ subscribeVoiceVolume: _temp25,
1893
+ muteVoice: _temp26,
1894
+ unmuteVoice: _temp27
1379
1895
  };
1380
- $[112] = handleCancelRun;
1381
- $[113] = speechController.stop;
1382
- $[114] = t33;
1383
- $[115] = t34;
1384
- $[116] = t35;
1385
- $[117] = t36;
1386
- $[118] = t37;
1387
- $[119] = t38;
1388
- $[120] = t39;
1389
- $[121] = t40;
1390
- $[122] = t41;
1391
- $[123] = t42;
1392
- $[124] = t43;
1393
- } else t43 = $[124];
1394
- return t43;
1896
+ $[133] = handleCancelRun;
1897
+ $[134] = speechController.stop;
1898
+ $[135] = t39;
1899
+ $[136] = t40;
1900
+ $[137] = t41;
1901
+ $[138] = t42;
1902
+ $[139] = t43;
1903
+ $[140] = t44;
1904
+ $[141] = t45;
1905
+ $[142] = t46;
1906
+ $[143] = t47;
1907
+ $[144] = t48;
1908
+ $[145] = t49;
1909
+ } else t49 = $[145];
1910
+ return t49;
1395
1911
  };
1396
1912
  const ExternalThread = resource(useExternalThread);
1397
1913
  attachTransformScopes(useExternalThread, (scopes, parent) => {
@@ -1432,52 +1948,65 @@ function _temp2(attachment) {
1432
1948
  }));
1433
1949
  }
1434
1950
  function _temp3() {}
1435
- function _temp4(part) {
1951
+ function _temp4() {}
1952
+ function _temp5(entry_1) {
1953
+ return entry_1.submission;
1954
+ }
1955
+ function _temp6(part) {
1436
1956
  return part.type === "text";
1437
1957
  }
1438
- function _temp5(part_0) {
1958
+ function _temp7(part_0) {
1439
1959
  return part_0.text;
1440
1960
  }
1441
- function _temp6(a_0) {
1442
- return a_0.status.type !== "complete";
1961
+ function _temp8(a_2) {
1962
+ return a_2.status.type !== "complete";
1443
1963
  }
1444
- function _temp7(error_1) {
1445
- console.error("Failed to remove cancelled edit attachments", error_1);
1964
+ function _temp9(attachment_6) {
1965
+ return [attachment_6.id, attachment_6];
1446
1966
  }
1447
- function _temp8() {}
1448
- function _temp9() {}
1449
- function _temp0(task) {
1450
- return withKey(getTaskKey(task), TaskClient({ task }), [task]);
1967
+ function _temp0(a_7) {
1968
+ return a_7.id;
1451
1969
  }
1452
- function _temp1(s, idx, arr) {
1453
- return {
1454
- ...s,
1455
- isLast: idx === arr.length - 1
1456
- };
1970
+ function _temp1(attachment_11) {
1971
+ return [attachment_11.id, attachment_11];
1972
+ }
1973
+ function _temp10(result_0) {
1974
+ return result_0.status === "rejected";
1975
+ }
1976
+ function _temp11(error_0) {
1977
+ console.error("Failed to remove cancelled edit attachments", error_0);
1978
+ }
1979
+ function _temp12() {}
1980
+ function _temp13() {}
1981
+ function _temp14(message_1) {
1982
+ return `${message_1.id}|${message_1.role}`;
1983
+ }
1984
+ function _temp15(task) {
1985
+ return withKey(getTaskKey(task), TaskClient({ task }), [task]);
1457
1986
  }
1458
- function _temp10() {}
1459
- function _temp11() {
1987
+ function _temp16() {}
1988
+ function _temp17() {
1460
1989
  return {
1461
1990
  tools: {},
1462
1991
  config: {}
1463
1992
  };
1464
1993
  }
1465
- function _temp12() {
1994
+ function _temp18() {
1466
1995
  return { messages: [] };
1467
1996
  }
1468
- function _temp13() {}
1469
- function _temp14() {}
1470
- function _temp15() {}
1471
- function _temp16() {}
1472
- function _temp17() {
1997
+ function _temp19() {}
1998
+ function _temp20() {}
1999
+ function _temp21() {}
2000
+ function _temp22() {}
2001
+ function _temp23() {
1473
2002
  return 0;
1474
2003
  }
1475
- function _temp18() {}
1476
- function _temp19() {
1477
- return _temp18;
2004
+ function _temp24() {}
2005
+ function _temp25() {
2006
+ return _temp24;
1478
2007
  }
1479
- function _temp20() {}
1480
- function _temp21() {}
2008
+ function _temp26() {}
2009
+ function _temp27() {}
1481
2010
  //#endregion
1482
2011
  export { ExternalThread };
1483
2012