@assistant-ui/core 0.2.9 → 0.2.11

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 (437) hide show
  1. package/dist/adapters/attachment.d.ts.map +1 -1
  2. package/dist/adapters/attachment.js +22 -12
  3. package/dist/adapters/attachment.js.map +1 -1
  4. package/dist/adapters/directive-formatter.js.map +1 -1
  5. package/dist/adapters/speech.js.map +1 -1
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.js +2 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal.js +1 -1
  10. package/dist/model-context/frame/host.js.map +1 -1
  11. package/dist/model-context/frame/provider.js.map +1 -1
  12. package/dist/model-context/registry.js.map +1 -1
  13. package/dist/model-context/tool.d.ts +1 -1
  14. package/dist/model-context/tool.js +1 -1
  15. package/dist/model-context/tool.js.map +1 -1
  16. package/dist/model-context/types.js +17 -2
  17. package/dist/model-context/types.js.map +1 -1
  18. package/dist/react/AssistantProvider.js +1 -1
  19. package/dist/react/AssistantRuntimeProvider.d.ts +1 -1
  20. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  21. package/dist/react/AssistantRuntimeProvider.js +1 -1
  22. package/dist/react/RuntimeAdapter.js +4 -2
  23. package/dist/react/RuntimeAdapter.js.map +1 -1
  24. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  25. package/dist/react/adapters/LocalStorageThreadListAdapter.js +13 -3
  26. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  27. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  28. package/dist/react/client/DataRenderers.js +6 -5
  29. package/dist/react/client/DataRenderers.js.map +1 -1
  30. package/dist/react/client/Interactables.d.ts.map +1 -1
  31. package/dist/react/client/Interactables.js +30 -29
  32. package/dist/react/client/Interactables.js.map +1 -1
  33. package/dist/react/client/Tools.d.ts.map +1 -1
  34. package/dist/react/client/Tools.js +19 -12
  35. package/dist/react/client/Tools.js.map +1 -1
  36. package/dist/react/index.d.ts +10 -5
  37. package/dist/react/index.js +7 -2
  38. package/dist/react/model-context/define-mcp-toolkit.d.ts +12 -0
  39. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -0
  40. package/dist/react/model-context/define-mcp-toolkit.js +14 -0
  41. package/dist/react/model-context/define-mcp-toolkit.js.map +1 -0
  42. package/dist/react/model-context/define-toolkit.d.ts +10 -12
  43. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  44. package/dist/react/model-context/define-toolkit.js +2 -15
  45. package/dist/react/model-context/define-toolkit.js.map +1 -1
  46. package/dist/react/model-context/external-tool.d.ts +14 -0
  47. package/dist/react/model-context/external-tool.d.ts.map +1 -0
  48. package/dist/react/model-context/external-tool.js +17 -0
  49. package/dist/react/model-context/external-tool.js.map +1 -0
  50. package/dist/react/model-context/human-tool.d.ts +27 -0
  51. package/dist/react/model-context/human-tool.d.ts.map +1 -0
  52. package/dist/react/model-context/human-tool.js +30 -0
  53. package/dist/react/model-context/human-tool.js.map +1 -0
  54. package/dist/react/model-context/makeAssistantTool.d.ts +8 -0
  55. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  56. package/dist/react/model-context/makeAssistantTool.js +4 -0
  57. package/dist/react/model-context/makeAssistantTool.js.map +1 -1
  58. package/dist/react/model-context/makeAssistantToolUI.d.ts +8 -0
  59. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  60. package/dist/react/model-context/makeAssistantToolUI.js +4 -0
  61. package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
  62. package/dist/react/model-context/provider-tool.d.ts +15 -0
  63. package/dist/react/model-context/provider-tool.d.ts.map +1 -0
  64. package/dist/react/model-context/provider-tool.js +12 -0
  65. package/dist/react/model-context/provider-tool.js.map +1 -0
  66. package/dist/react/model-context/stub-tool.d.ts +12 -0
  67. package/dist/react/model-context/stub-tool.d.ts.map +1 -0
  68. package/dist/react/model-context/stub-tool.js +15 -0
  69. package/dist/react/model-context/stub-tool.js.map +1 -0
  70. package/dist/react/model-context/toolbox.d.ts +64 -17
  71. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  72. package/dist/react/model-context/toolbox.js +19 -1
  73. package/dist/react/model-context/toolbox.js.map +1 -1
  74. package/dist/react/model-context/useAssistantContext.js +1 -1
  75. package/dist/react/model-context/useAssistantContext.js.map +1 -1
  76. package/dist/react/model-context/useAssistantDataUI.js +1 -1
  77. package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
  78. package/dist/react/model-context/useAssistantInstructions.js +1 -1
  79. package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
  80. package/dist/react/model-context/useAssistantInteractable.js +1 -1
  81. package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
  82. package/dist/react/model-context/useAssistantTool.d.ts +11 -1
  83. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  84. package/dist/react/model-context/useAssistantTool.js +12 -6
  85. package/dist/react/model-context/useAssistantTool.js.map +1 -1
  86. package/dist/react/model-context/useAssistantToolUI.d.ts +13 -4
  87. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  88. package/dist/react/model-context/useAssistantToolUI.js +7 -4
  89. package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
  90. package/dist/react/model-context/useAuiToolOverrides.d.ts +22 -0
  91. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -0
  92. package/dist/react/model-context/useAuiToolOverrides.js +31 -0
  93. package/dist/react/model-context/useAuiToolOverrides.js.map +1 -0
  94. package/dist/react/model-context/useInlineRender.js +1 -1
  95. package/dist/react/model-context/useInlineRender.js.map +1 -1
  96. package/dist/react/model-context/useInteractableState.js +1 -1
  97. package/dist/react/model-context/useInteractableState.js.map +1 -1
  98. package/dist/react/model-context/useToolArgsStatus.js +1 -1
  99. package/dist/react/primitive-hooks/useActionBarCopy.js +1 -1
  100. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  101. package/dist/react/primitive-hooks/useActionBarEdit.js +1 -1
  102. package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
  103. package/dist/react/primitive-hooks/useActionBarFeedback.js +1 -1
  104. package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
  105. package/dist/react/primitive-hooks/useActionBarReload.js +1 -1
  106. package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
  107. package/dist/react/primitive-hooks/useActionBarSpeak.js +1 -1
  108. package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
  109. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +1 -1
  110. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
  111. package/dist/react/primitive-hooks/useBranchPickerNext.js +1 -1
  112. package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
  113. package/dist/react/primitive-hooks/useBranchPickerPrevious.js +1 -1
  114. package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
  115. package/dist/react/primitive-hooks/useComposerAddAttachment.js +1 -1
  116. package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
  117. package/dist/react/primitive-hooks/useComposerCancel.js +1 -1
  118. package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
  119. package/dist/react/primitive-hooks/useComposerDictate.js +1 -1
  120. package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
  121. package/dist/react/primitive-hooks/useComposerSend.js +1 -1
  122. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  123. package/dist/react/primitive-hooks/useEditComposerCancel.js +1 -1
  124. package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
  125. package/dist/react/primitive-hooks/useEditComposerSend.js +1 -1
  126. package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
  127. package/dist/react/primitive-hooks/useMessageBranching.js +1 -1
  128. package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
  129. package/dist/react/primitive-hooks/useMessageReload.js +1 -1
  130. package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
  131. package/dist/react/primitive-hooks/useSuggestionTrigger.js +1 -1
  132. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  133. package/dist/react/primitive-hooks/useThreadListItemArchive.js +1 -1
  134. package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
  135. package/dist/react/primitive-hooks/useThreadListItemDelete.js +1 -1
  136. package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
  137. package/dist/react/primitive-hooks/useThreadListItemTrigger.js +1 -1
  138. package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
  139. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +1 -1
  140. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
  141. package/dist/react/primitive-hooks/useThreadListLoadMore.js +1 -1
  142. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
  143. package/dist/react/primitive-hooks/useThreadListNew.js +1 -1
  144. package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
  145. package/dist/react/primitive-hooks/useVoice.js +1 -1
  146. package/dist/react/primitive-hooks/useVoice.js.map +1 -1
  147. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +1 -1
  148. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
  149. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
  150. package/dist/react/primitives/composer/ComposerAttachments.js +1 -1
  151. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
  152. package/dist/react/primitives/composer/ComposerQueue.js +1 -1
  153. package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
  154. package/dist/react/primitives/generativeUI/GenerativeUI.js +1 -1
  155. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  156. package/dist/react/primitives/message/MessageAttachments.js +1 -1
  157. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  158. package/dist/react/primitives/message/MessageGroupedParts.js +1 -1
  159. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  160. package/dist/react/primitives/message/MessageParts.d.ts +1 -1
  161. package/dist/react/primitives/message/MessageParts.js +1 -1
  162. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  163. package/dist/react/primitives/message/MessageQuote.js +1 -1
  164. package/dist/react/primitives/part/PartMessages.d.ts +12 -10
  165. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  166. package/dist/react/primitives/part/PartMessages.js +13 -11
  167. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  168. package/dist/react/primitives/thread/ThreadMessages.js +1 -1
  169. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  170. package/dist/react/primitives/thread/ThreadSuggestions.js +1 -1
  171. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  172. package/dist/react/primitives/threadList/ThreadListItems.js +1 -1
  173. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
  174. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
  175. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
  176. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  177. package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
  178. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  179. package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
  180. package/dist/react/providers/ReadonlyThreadProvider.js +1 -1
  181. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  182. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
  183. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  184. package/dist/react/providers/TextMessagePartProvider.js +4 -3
  185. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  186. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
  187. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +7 -0
  188. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  189. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +1 -1
  190. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  191. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +8 -0
  192. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  193. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +29 -1
  194. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  195. package/dist/react/runtimes/RuntimeAdapterProvider.js +1 -1
  196. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +1 -1
  197. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  198. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  199. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +10 -3
  200. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  201. package/dist/react/runtimes/createMessageConverter.d.ts +2 -2
  202. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  203. package/dist/react/runtimes/createMessageConverter.js.map +1 -1
  204. package/dist/react/runtimes/external-message-converter.d.ts +4 -3
  205. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  206. package/dist/react/runtimes/external-message-converter.js +1 -1
  207. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  208. package/dist/react/runtimes/useExternalStoreRuntime.js +1 -1
  209. package/dist/react/runtimes/useExternalStoreSharedOptions.js +1 -1
  210. package/dist/react/runtimes/useLocalRuntime.d.ts +2 -1
  211. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  212. package/dist/react/runtimes/useLocalRuntime.js +4 -3
  213. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  214. package/dist/react/runtimes/useRemoteThreadListRuntime.js +1 -1
  215. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  216. package/dist/react/utils/groupParts.d.ts +1 -1
  217. package/dist/react/utils/groupParts.js.map +1 -1
  218. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  219. package/dist/runtime/api/composer-runtime.d.ts +8 -2
  220. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  221. package/dist/runtime/api/composer-runtime.js +14 -0
  222. package/dist/runtime/api/composer-runtime.js.map +1 -1
  223. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  224. package/dist/runtime/api/message-runtime.js +1 -1
  225. package/dist/runtime/api/message-runtime.js.map +1 -1
  226. package/dist/runtime/api/thread-list-item-runtime.d.ts +2 -0
  227. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  228. package/dist/runtime/api/thread-list-item-runtime.js +6 -0
  229. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  230. package/dist/runtime/api/thread-runtime.d.ts +7 -0
  231. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  232. package/dist/runtime/api/thread-runtime.js.map +1 -1
  233. package/dist/runtime/base/base-composer-runtime-core.d.ts +4 -0
  234. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  235. package/dist/runtime/base/base-composer-runtime-core.js +7 -1
  236. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  237. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  238. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +4 -0
  239. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  240. package/dist/runtime/base/default-thread-composer-runtime-core.js +17 -1
  241. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  242. package/dist/runtime/interfaces/composer-runtime-core.d.ts +6 -1
  243. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  244. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
  245. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  246. package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -0
  247. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  248. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +20 -0
  249. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -0
  250. package/dist/runtime/queue/external-thread-queue-adapter.js +0 -0
  251. package/dist/runtime/queue/message-queue.d.ts +20 -0
  252. package/dist/runtime/queue/message-queue.d.ts.map +1 -0
  253. package/dist/runtime/queue/message-queue.js +97 -0
  254. package/dist/runtime/queue/message-queue.js.map +1 -0
  255. package/dist/runtime/utils/message-repository.js.map +1 -1
  256. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  257. package/dist/runtimes/external-store/external-store-adapter.d.ts +5 -1
  258. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  259. package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
  260. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -0
  261. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  262. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +5 -0
  263. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  264. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +4 -0
  265. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  266. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +20 -2
  267. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  268. package/dist/runtimes/local/local-runtime-core.js.map +1 -1
  269. package/dist/runtimes/local/local-runtime-options.d.ts +5 -0
  270. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  271. package/dist/runtimes/local/local-thread-runtime-core.d.ts +7 -0
  272. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  273. package/dist/runtimes/local/local-thread-runtime-core.js +45 -0
  274. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  275. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +3 -0
  276. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  277. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +3 -0
  278. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  279. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -0
  280. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  281. package/dist/runtimes/remote-thread-list/adapter/in-memory.js +3 -0
  282. package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
  283. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  284. package/dist/runtimes/remote-thread-list/empty-thread-core.js +3 -0
  285. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  286. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  287. package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
  288. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  289. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  290. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  291. package/dist/store/clients/chain-of-thought-client.js +6 -5
  292. package/dist/store/clients/chain-of-thought-client.js.map +1 -1
  293. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  294. package/dist/store/clients/model-context-client.js +6 -5
  295. package/dist/store/clients/model-context-client.js.map +1 -1
  296. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  297. package/dist/store/clients/no-op-composer-client.js +4 -3
  298. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  299. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  300. package/dist/store/clients/runtime-adapter.js +7 -6
  301. package/dist/store/clients/runtime-adapter.js.map +1 -1
  302. package/dist/store/clients/suggestions.d.ts.map +1 -1
  303. package/dist/store/clients/suggestions.js +7 -6
  304. package/dist/store/clients/suggestions.js.map +1 -1
  305. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  306. package/dist/store/clients/thread-message-client.js +13 -12
  307. package/dist/store/clients/thread-message-client.js.map +1 -1
  308. package/dist/store/index.d.ts +1 -1
  309. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  310. package/dist/store/runtime-clients/attachment-runtime-client.js +3 -3
  311. package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
  312. package/dist/store/runtime-clients/composer-runtime-client.d.ts +12 -5
  313. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  314. package/dist/store/runtime-clients/composer-runtime-client.js +32 -16
  315. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  316. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  317. package/dist/store/runtime-clients/message-part-runtime-client.js +3 -3
  318. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  319. package/dist/store/runtime-clients/message-runtime-client.d.ts +6 -3
  320. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  321. package/dist/store/runtime-clients/message-runtime-client.js +17 -16
  322. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  323. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  324. package/dist/store/runtime-clients/thread-list-item-runtime-client.js +9 -7
  325. package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
  326. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  327. package/dist/store/runtime-clients/thread-list-runtime-client.js +11 -10
  328. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  329. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  330. package/dist/store/runtime-clients/thread-runtime-client.js +15 -14
  331. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  332. package/dist/store/runtime-clients/useSubscribable.d.ts +7 -0
  333. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -0
  334. package/dist/store/runtime-clients/useSubscribable.js +16 -0
  335. package/dist/store/runtime-clients/useSubscribable.js.map +1 -0
  336. package/dist/store/scope-registration.d.ts +1 -1
  337. package/dist/store/scopes/composer.d.ts +1 -1
  338. package/dist/store/scopes/queue-item.d.ts +2 -1
  339. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  340. package/dist/store/scopes/queue-item.js +6 -0
  341. package/dist/store/scopes/queue-item.js.map +1 -0
  342. package/dist/store/scopes/thread-list-item.d.ts +1 -0
  343. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  344. package/dist/store/scopes/thread.d.ts +1 -1
  345. package/dist/store/scopes/threads.d.ts +1 -1
  346. package/dist/types/message.d.ts +2 -1
  347. package/dist/types/message.d.ts.map +1 -1
  348. package/dist/types/message.js.map +1 -1
  349. package/dist/utils/composite-context-provider.d.ts +1 -1
  350. package/dist/utils/composite-context-provider.js +3 -1
  351. package/dist/utils/composite-context-provider.js.map +1 -1
  352. package/dist/utils/json/is-json.js.map +1 -1
  353. package/dist/utils/text.js.map +1 -1
  354. package/package.json +15 -11
  355. package/src/adapters/attachment.ts +24 -4
  356. package/src/index.ts +8 -0
  357. package/src/model-context/tool.ts +1 -1
  358. package/src/model-context/types.ts +21 -3
  359. package/src/react/RuntimeAdapter.ts +6 -4
  360. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +15 -2
  361. package/src/react/client/DataRenderers.ts +48 -42
  362. package/src/react/client/Interactables.ts +263 -267
  363. package/src/react/client/Tools.ts +123 -115
  364. package/src/react/index.ts +16 -3
  365. package/src/react/model-context/define-mcp-toolkit.ts +16 -0
  366. package/src/react/model-context/define-toolkit.test.ts +101 -6
  367. package/src/react/model-context/define-toolkit.ts +35 -18
  368. package/src/react/model-context/external-tool.ts +16 -0
  369. package/src/react/model-context/human-tool.ts +32 -0
  370. package/src/react/model-context/makeAssistantTool.ts +8 -0
  371. package/src/react/model-context/makeAssistantToolUI.ts +8 -0
  372. package/src/react/model-context/provider-tool.ts +30 -0
  373. package/src/react/model-context/stub-tool.ts +14 -0
  374. package/src/react/model-context/toolbox.test.ts +182 -0
  375. package/src/react/model-context/toolbox.ts +191 -23
  376. package/src/react/model-context/useAssistantTool.ts +28 -8
  377. package/src/react/model-context/useAssistantToolUI.ts +13 -4
  378. package/src/react/model-context/useAuiToolOverrides.ts +38 -0
  379. package/src/react/primitives/message/MessageGroupedParts.tsx +1 -1
  380. package/src/react/primitives/part/PartMessages.tsx +12 -10
  381. package/src/react/providers/TextMessagePartProvider.tsx +31 -32
  382. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +43 -0
  383. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +9 -0
  384. package/src/react/runtimes/createMessageConverter.ts +2 -1
  385. package/src/react/runtimes/external-message-converter.ts +5 -3
  386. package/src/react/runtimes/useLocalRuntime.ts +2 -0
  387. package/src/runtime/api/composer-runtime.ts +26 -0
  388. package/src/runtime/api/thread-list-item-runtime.ts +15 -0
  389. package/src/runtime/base/base-composer-runtime-core.ts +11 -0
  390. package/src/runtime/base/default-thread-composer-runtime-core.ts +22 -0
  391. package/src/runtime/interfaces/composer-runtime-core.ts +7 -0
  392. package/src/runtime/interfaces/thread-list-runtime-core.ts +4 -0
  393. package/src/runtime/interfaces/thread-runtime-core.ts +5 -0
  394. package/src/runtime/queue/external-thread-queue-adapter.ts +14 -0
  395. package/src/runtime/queue/message-queue.ts +128 -0
  396. package/src/runtimes/external-store/external-store-adapter.ts +10 -0
  397. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +13 -0
  398. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +31 -2
  399. package/src/runtimes/local/local-runtime-options.ts +6 -0
  400. package/src/runtimes/local/local-thread-runtime-core.ts +70 -0
  401. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +4 -0
  402. package/src/runtimes/remote-thread-list/adapter/in-memory.ts +4 -0
  403. package/src/runtimes/remote-thread-list/empty-thread-core.ts +4 -0
  404. package/src/runtimes/remote-thread-list/types.ts +4 -0
  405. package/src/store/clients/chain-of-thought-client.ts +24 -25
  406. package/src/store/clients/model-context-client.test.ts +87 -2
  407. package/src/store/clients/model-context-client.ts +22 -19
  408. package/src/store/clients/no-op-composer-client.ts +69 -66
  409. package/src/store/clients/runtime-adapter.ts +9 -6
  410. package/src/store/clients/suggestions.ts +41 -40
  411. package/src/store/clients/thread-message-client.ts +127 -132
  412. package/src/store/runtime-clients/attachment-runtime-client.ts +7 -3
  413. package/src/store/runtime-clients/composer-runtime-client.ts +142 -113
  414. package/src/store/runtime-clients/message-part-runtime-client.ts +16 -14
  415. package/src/store/runtime-clients/message-runtime-client.ts +124 -122
  416. package/src/store/runtime-clients/thread-list-item-runtime-client.ts +44 -44
  417. package/src/store/runtime-clients/thread-list-runtime-client.ts +83 -80
  418. package/src/store/runtime-clients/thread-runtime-client.ts +113 -119
  419. package/src/store/runtime-clients/{tap-subscribable.ts → useSubscribable.ts} +4 -4
  420. package/src/store/scopes/queue-item.ts +2 -0
  421. package/src/store/scopes/thread-list-item.ts +1 -0
  422. package/src/tests/RemoteThreadListThreadListRuntimeCore-custom-metadata.test.ts +69 -1
  423. package/src/tests/attachment-adapters.test.ts +86 -0
  424. package/src/tests/external-store-thread-runtime-core.test.ts +125 -0
  425. package/src/tests/message-queue.test.ts +168 -0
  426. package/src/tests/thread-list-runtime-getLoadThreadsPromise.test.ts +1 -0
  427. package/src/types/message.ts +2 -0
  428. package/src/utils/composite-context-provider.ts +3 -1
  429. package/dist/react/model-context/hitl.d.ts +0 -19
  430. package/dist/react/model-context/hitl.d.ts.map +0 -1
  431. package/dist/react/model-context/hitl.js +0 -22
  432. package/dist/react/model-context/hitl.js.map +0 -1
  433. package/dist/store/runtime-clients/tap-subscribable.d.ts +0 -7
  434. package/dist/store/runtime-clients/tap-subscribable.d.ts.map +0 -1
  435. package/dist/store/runtime-clients/tap-subscribable.js +0 -16
  436. package/dist/store/runtime-clients/tap-subscribable.js.map +0 -1
  437. package/src/react/model-context/hitl.ts +0 -22
@@ -1 +1 @@
1
- {"version":3,"file":"useCloudThreadListAdapter.js","names":[],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"sourcesContent":["declare const process: { env: Record<string, string | undefined> };\n\nimport {\n type FC,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport type { RemoteThreadListAdapter } from \"../../../runtimes/remote-thread-list/types\";\nimport { InMemoryThreadListAdapter } from \"../../../runtimes/remote-thread-list/adapter/in-memory\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"./AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../RuntimeAdapterProvider\";\nimport { CloudFileAttachmentAdapter } from \"./CloudFileAttachmentAdapter\";\n\ntype ThreadData = {\n externalId: string | undefined;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?: (() => Promise<ThreadData>) | undefined;\n delete?: ((threadId: string) => Promise<void>) | undefined;\n};\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.NEXT_PUBLIC_ASSISTANT_BASE_URL;\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n function Provider({ children }) {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const cloudInstance = adapterRef.current.cloud ?? autoCloud!;\n const attachments = useMemo(\n () => new CloudFileAttachmentAdapter(cloudInstance),\n [cloudInstance],\n );\n\n const adapters = useMemo(\n () => ({\n history,\n attachments,\n }),\n [history, attachments],\n );\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) {\n const ref = adapterRef;\n const inMemory = new InMemoryThreadListAdapter();\n inMemory.initialize = async (threadId: string) => {\n const result = await ref.current.create?.();\n return { remoteId: threadId, externalId: result?.externalId };\n };\n return inMemory;\n }\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n // Filter messages to only include content types the title generator understands\n // (reasoning, source, etc. are not needed for title generation)\n // TODO serialize these to a more efficient format\n const filteredMessages = messages.map((msg) => ({\n ...msg,\n content: msg.content.filter(\n (part) => part.type === \"text\" || part.type === \"tool-call\",\n ),\n }));\n\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: filteredMessages,\n });\n },\n\n fetch: async (threadId: string) => {\n const thread = await cloud.threads.get(threadId);\n return {\n status: thread.is_archived ? \"archived\" : \"regular\",\n remoteId: thread.id,\n title: thread.title,\n externalId: thread.external_id ?? undefined,\n };\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";;;;;;;;AA4BA,MAAM,UACJ,OAAO,YAA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MAAM,QAAQ,OAAO;IACzD,iCAAiB,IAAI,KAAK;IAC1B;GACF,CAAC;GAED,OAAO;IAAE,YAAY;IAAuB;GAAS;EACvD;EAEA,QAAQ,OAAO,UAAU,aAAa;GACpC,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,OAAO,SAAS,CAAC;EAC3D;EACA,SAAS,OAAO,aAAa;GAC3B,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,KAAK,CAAC;EAC7D;EACA,WAAW,OAAO,aAAa;GAC7B,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,MAAM,CAAC;EAC9D;EACA,QAAQ,OAAO,aAAa;GAC1B,MAAM,QAAQ,SAAS,QAAQ;GAC/B,OAAO,MAAM,QAAQ,OAAO,QAAQ;EACtC;EAEA,eAAe,OAAO,UAAU,aAAa;GAI3C,MAAM,mBAAmB,SAAS,KAAK,SAAS;IAC9C,GAAG;IACH,SAAS,IAAI,QAAQ,QAClB,SAAS,KAAK,SAAS,UAAU,KAAK,SAAS,WAClD;GACF,EAAE;GAEF,OAAO,MAAM,KAAK,OAAO;IACvB,WAAW;IACX,cAAc;IACd,UAAU;GACZ,CAAC;EACH;EAEA,OAAO,OAAO,aAAqB;GACjC,MAAM,SAAS,MAAM,MAAM,QAAQ,IAAI,QAAQ;GAC/C,OAAO;IACL,QAAQ,OAAO,cAAc,aAAa;IAC1C,UAAU,OAAO;IACjB,OAAO,OAAO;IACd,YAAY,OAAO,eAAe,KAAA;GACpC;EACF;EAEA;CACF;AACF"}
1
+ {"version":3,"file":"useCloudThreadListAdapter.js","names":[],"sources":["../../../../src/react/runtimes/cloud/useCloudThreadListAdapter.tsx"],"sourcesContent":["declare const process: { env: Record<string, string | undefined> };\n\nimport {\n type FC,\n type PropsWithChildren,\n useCallback,\n useEffect,\n useMemo,\n useRef,\n} from \"react\";\nimport { AssistantCloud } from \"assistant-cloud\";\nimport type { RemoteThreadListAdapter } from \"../../../runtimes/remote-thread-list/types\";\nimport { InMemoryThreadListAdapter } from \"../../../runtimes/remote-thread-list/adapter/in-memory\";\nimport { useAssistantCloudThreadHistoryAdapter } from \"./AssistantCloudThreadHistoryAdapter\";\nimport { RuntimeAdapterProvider } from \"../RuntimeAdapterProvider\";\nimport { CloudFileAttachmentAdapter } from \"./CloudFileAttachmentAdapter\";\nimport { isRecord } from \"../../../utils/json/is-json\";\n\ntype ThreadData = {\n externalId: string | undefined;\n};\n\ntype CloudThreadListAdapterOptions = {\n cloud?: AssistantCloud | undefined;\n\n create?: (() => Promise<ThreadData>) | undefined;\n delete?: ((threadId: string) => Promise<void>) | undefined;\n};\n\nconst toCustom = (value: unknown): Record<string, unknown> | undefined =>\n isRecord(value) ? value : undefined;\n\nconst baseUrl =\n typeof process !== \"undefined\" &&\n process?.env?.NEXT_PUBLIC_ASSISTANT_BASE_URL;\nconst autoCloud = baseUrl\n ? new AssistantCloud({ baseUrl, anonymous: true })\n : undefined;\n\nexport const useCloudThreadListAdapter = (\n adapter: CloudThreadListAdapterOptions,\n): RemoteThreadListAdapter => {\n const adapterRef = useRef(adapter);\n useEffect(() => {\n adapterRef.current = adapter;\n }, [adapter]);\n\n const unstable_Provider = useCallback<FC<PropsWithChildren>>(\n function Provider({ children }) {\n const history = useAssistantCloudThreadHistoryAdapter({\n get current() {\n return adapterRef.current.cloud ?? autoCloud!;\n },\n });\n const cloudInstance = adapterRef.current.cloud ?? autoCloud!;\n const attachments = useMemo(\n () => new CloudFileAttachmentAdapter(cloudInstance),\n [cloudInstance],\n );\n\n const adapters = useMemo(\n () => ({\n history,\n attachments,\n }),\n [history, attachments],\n );\n\n return (\n <RuntimeAdapterProvider adapters={adapters}>\n {children}\n </RuntimeAdapterProvider>\n );\n },\n [],\n );\n\n const cloud = adapter.cloud ?? autoCloud;\n if (!cloud) {\n const ref = adapterRef;\n const inMemory = new InMemoryThreadListAdapter();\n inMemory.initialize = async (threadId: string) => {\n const result = await ref.current.create?.();\n return { remoteId: threadId, externalId: result?.externalId };\n };\n return inMemory;\n }\n\n return {\n list: async () => {\n const { threads } = await cloud.threads.list();\n return {\n threads: threads.map((t) => ({\n status: t.is_archived ? \"archived\" : \"regular\",\n remoteId: t.id,\n title: t.title,\n externalId: t.external_id ?? undefined,\n custom: toCustom(t.metadata),\n })),\n };\n },\n\n initialize: async () => {\n const createTask = adapter.create?.() ?? Promise.resolve();\n const t = await createTask;\n const external_id = t ? t.externalId : undefined;\n const { thread_id: remoteId } = await cloud.threads.create({\n last_message_at: new Date(),\n external_id,\n });\n\n return { externalId: external_id, remoteId: remoteId };\n },\n\n rename: async (threadId, newTitle) => {\n return cloud.threads.update(threadId, { title: newTitle });\n },\n updateCustom: async (threadId, custom) => {\n return cloud.threads.update(threadId, { metadata: custom ?? null });\n },\n archive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: true });\n },\n unarchive: async (threadId) => {\n return cloud.threads.update(threadId, { is_archived: false });\n },\n delete: async (threadId) => {\n await adapter.delete?.(threadId);\n return cloud.threads.delete(threadId);\n },\n\n generateTitle: async (threadId, messages) => {\n // Filter messages to only include content types the title generator understands\n // (reasoning, source, etc. are not needed for title generation)\n // TODO serialize these to a more efficient format\n const filteredMessages = messages.map((msg) => ({\n ...msg,\n content: msg.content.filter(\n (part) => part.type === \"text\" || part.type === \"tool-call\",\n ),\n }));\n\n return cloud.runs.stream({\n thread_id: threadId,\n assistant_id: \"system/thread_title\",\n messages: filteredMessages,\n });\n },\n\n fetch: async (threadId: string) => {\n const thread = await cloud.threads.get(threadId);\n return {\n status: thread.is_archived ? \"archived\" : \"regular\",\n remoteId: thread.id,\n title: thread.title,\n externalId: thread.external_id ?? undefined,\n custom: toCustom(thread.metadata),\n };\n },\n\n unstable_Provider,\n };\n};\n"],"mappings":";;;;;;;;;AA6BA,MAAM,YAAY,UAChB,SAAS,KAAK,IAAI,QAAQ,KAAA;AAE5B,MAAM,UACJ,OAAO,YAAY,eACnB,SAAS,KAAK;AAChB,MAAM,YAAY,UACd,IAAI,eAAe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AAO;IACzD,iCAAiB,IAAI,KAAK;IAC1B;GACF,CAAC;GAED,OAAO;IAAE,YAAY;IAAuB;GAAS;EACvD;EAEA,QAAQ,OAAO,UAAU,aAAa;GACpC,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,OAAO,SAAS,CAAC;EAC3D;EACA,cAAc,OAAO,UAAU,WAAW;GACxC,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,UAAU,UAAU,KAAK,CAAC;EACpE;EACA,SAAS,OAAO,aAAa;GAC3B,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,KAAK,CAAC;EAC7D;EACA,WAAW,OAAO,aAAa;GAC7B,OAAO,MAAM,QAAQ,OAAO,UAAU,EAAE,aAAa,MAAM,CAAC;EAC9D;EACA,QAAQ,OAAO,aAAa;GAC1B,MAAM,QAAQ,SAAS,QAAQ;GAC/B,OAAO,MAAM,QAAQ,OAAO,QAAQ;EACtC;EAEA,eAAe,OAAO,UAAU,aAAa;GAI3C,MAAM,mBAAmB,SAAS,KAAK,SAAS;IAC9C,GAAG;IACH,SAAS,IAAI,QAAQ,QAClB,SAAS,KAAK,SAAS,UAAU,KAAK,SAAS,WAClD;GACF,EAAE;GAEF,OAAO,MAAM,KAAK,OAAO;IACvB,WAAW;IACX,cAAc;IACd,UAAU;GACZ,CAAC;EACH;EAEA,OAAO,OAAO,aAAqB;GACjC,MAAM,SAAS,MAAM,MAAM,QAAQ,IAAI,QAAQ;GAC/C,OAAO;IACL,QAAQ,OAAO,cAAc,aAAa;IAC1C,UAAU,OAAO;IACjB,OAAO,OAAO;IACd,YAAY,OAAO,eAAe,KAAA;IAClC,QAAQ,SAAS,OAAO,QAAQ;GAClC;EACF;EAEA;CACF;AACF"}
@@ -1,6 +1,6 @@
1
1
  import { ThreadMessage } from "../../types/message.js";
2
2
  import { ThreadState } from "../../runtime/api/thread-runtime.js";
3
- import { useExternalMessageConverter } from "./external-message-converter.js";
3
+ import { JoinStrategy, useExternalMessageConverter } from "./external-message-converter.js";
4
4
 
5
5
  //#region src/react/runtimes/createMessageConverter.d.ts
6
6
  declare const createMessageConverter: <T extends object>(callback: useExternalMessageConverter.Callback<T>) => {
@@ -12,7 +12,7 @@ declare const createMessageConverter: <T extends object>(callback: useExternalMe
12
12
  }: {
13
13
  messages: T[];
14
14
  isRunning: boolean;
15
- joinStrategy?: "concat-content" | "none" | undefined;
15
+ joinStrategy?: JoinStrategy | undefined;
16
16
  metadata?: useExternalMessageConverter.Metadata;
17
17
  }) => ThreadMessage[];
18
18
  toThreadMessages: (messages: T[], isRunning?: boolean, metadata?: useExternalMessageConverter.Metadata) => ThreadMessage[];
@@ -1 +1 @@
1
- {"version":3,"file":"createMessageConverter.d.ts","names":[],"sources":["../../../src/react/runtimes/createMessageConverter.ts"],"mappings":";;;;;cAUa,sBAAA,qBACX,QAAA,EAAU,2BAAA,CAA4B,QAAA,CAAS,CAAA;;;;;;;IAS3C,QAAA,EAAU,CAAA;IACV,SAAA;IACA,YAAA;IACA,QAAA,GAAW,2BAAA,CAA4B,QAAA;EAAA,MACxC,aAAA;+BAUW,CAAA,IAAG,SAAA,YAAA,QAAA,GAEH,2BAAA,CAA4B,QAAA,KAAQ,aAAA;8BAKvC,WAAA,GAAc,aAAA,GAAgB,aAAA;6BAO9B,WAAA,GAAc,aAAA,GAAgB,aAAA"}
1
+ {"version":3,"file":"createMessageConverter.d.ts","names":[],"sources":["../../../src/react/runtimes/createMessageConverter.ts"],"mappings":";;;;;cAWa,sBAAA,qBACX,QAAA,EAAU,2BAAA,CAA4B,QAAA,CAAS,CAAA;;;;;;;IAS3C,QAAA,EAAU,CAAA;IACV,SAAA;IACA,YAAA,GAAe,YAAA;IACf,QAAA,GAAW,2BAAA,CAA4B,QAAA;EAAA,MACxC,aAAA;+BAUW,CAAA,IAAG,SAAA,YAAA,QAAA,GAEH,2BAAA,CAA4B,QAAA,KAAQ,aAAA;8BAKvC,WAAA,GAAc,aAAA,GAAgB,aAAA;6BAO9B,WAAA,GAAc,aAAA,GAAgB,aAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"createMessageConverter.js","names":[],"sources":["../../../src/react/runtimes/createMessageConverter.ts"],"sourcesContent":["\"use client\";\nimport type { ThreadMessage } from \"../../types/message\";\nimport type { ThreadState } from \"../../runtime/api/thread-runtime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport {\n useExternalMessageConverter,\n convertExternalMessages,\n} from \"./external-message-converter\";\nimport { getExternalStoreMessages } from \"../../runtime/utils/external-store-message\";\n\nexport const createMessageConverter = <T extends object>(\n callback: useExternalMessageConverter.Callback<T>,\n) => {\n const result = {\n useThreadMessages: ({\n messages,\n isRunning,\n joinStrategy,\n metadata,\n }: {\n messages: T[];\n isRunning: boolean;\n joinStrategy?: \"concat-content\" | \"none\" | undefined;\n metadata?: useExternalMessageConverter.Metadata;\n }) => {\n return useExternalMessageConverter<T>({\n callback,\n messages,\n isRunning,\n joinStrategy,\n metadata,\n });\n },\n toThreadMessages: (\n messages: T[],\n isRunning = false,\n metadata: useExternalMessageConverter.Metadata = {},\n ) => {\n return convertExternalMessages(messages, callback, isRunning, metadata);\n },\n toOriginalMessages: (\n input: ThreadState | ThreadMessage | ThreadMessage[\"content\"][number],\n ) => {\n const messages = getExternalStoreMessages(input);\n if (messages.length === 0) throw new Error(\"No original messages found\");\n return messages;\n },\n toOriginalMessage: (\n input: ThreadState | ThreadMessage | ThreadMessage[\"content\"][number],\n ) => {\n const messages = result.toOriginalMessages(input);\n return messages[0]!;\n },\n useOriginalMessage: () => {\n const messageMessages = result.useOriginalMessages();\n const first = messageMessages[0]!;\n return first;\n },\n useOriginalMessages: () => {\n const aui = useAui();\n const partMessages = useAuiState((s) => {\n if (aui.part.source) return getExternalStoreMessages(s.part);\n return undefined;\n });\n\n const messageMessages = useAuiState<T[]>((s) =>\n getExternalStoreMessages(s.message),\n );\n\n const messages = partMessages ?? messageMessages;\n if (messages.length === 0) throw new Error(\"No original messages found\");\n return messages;\n },\n };\n\n return result;\n};\n"],"mappings":";;;;;AAUA,MAAa,0BACX,aACG;CACH,MAAM,SAAS;EACb,oBAAoB,EAClB,UACA,WACA,cACA,eAMI;GACJ,OAAO,4BAA+B;IACpC;IACA;IACA;IACA;IACA;GACF,CAAC;EACH;EACA,mBACE,UACA,YAAY,OACZ,WAAiD,CAAC,MAC/C;GACH,OAAO,wBAAwB,UAAU,UAAU,WAAW,QAAQ;EACxE;EACA,qBACE,UACG;GACH,MAAM,WAAW,yBAAyB,KAAK;GAC/C,IAAI,SAAS,WAAW,GAAG,MAAM,IAAI,MAAM,4BAA4B;GACvE,OAAO;EACT;EACA,oBACE,UACG;GAEH,OADiB,OAAO,mBAAmB,KAC7B,EAAE;EAClB;EACA,0BAA0B;GAGxB,OAFwB,OAAO,oBACH,EAAE;EAEhC;EACA,2BAA2B;GACzB,MAAM,MAAM,OAAO;GACnB,MAAM,eAAe,aAAa,MAAM;IACtC,IAAI,IAAI,KAAK,QAAQ,OAAO,yBAAyB,EAAE,IAAI;GAE7D,CAAC;GAED,MAAM,kBAAkB,aAAkB,MACxC,yBAAyB,EAAE,OAAO,CACpC;GAEA,MAAM,WAAW,gBAAgB;GACjC,IAAI,SAAS,WAAW,GAAG,MAAM,IAAI,MAAM,4BAA4B;GACvE,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
1
+ {"version":3,"file":"createMessageConverter.js","names":[],"sources":["../../../src/react/runtimes/createMessageConverter.ts"],"sourcesContent":["\"use client\";\nimport type { ThreadMessage } from \"../../types/message\";\nimport type { ThreadState } from \"../../runtime/api/thread-runtime\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport {\n useExternalMessageConverter,\n convertExternalMessages,\n type JoinStrategy,\n} from \"./external-message-converter\";\nimport { getExternalStoreMessages } from \"../../runtime/utils/external-store-message\";\n\nexport const createMessageConverter = <T extends object>(\n callback: useExternalMessageConverter.Callback<T>,\n) => {\n const result = {\n useThreadMessages: ({\n messages,\n isRunning,\n joinStrategy,\n metadata,\n }: {\n messages: T[];\n isRunning: boolean;\n joinStrategy?: JoinStrategy | undefined;\n metadata?: useExternalMessageConverter.Metadata;\n }) => {\n return useExternalMessageConverter<T>({\n callback,\n messages,\n isRunning,\n joinStrategy,\n metadata,\n });\n },\n toThreadMessages: (\n messages: T[],\n isRunning = false,\n metadata: useExternalMessageConverter.Metadata = {},\n ) => {\n return convertExternalMessages(messages, callback, isRunning, metadata);\n },\n toOriginalMessages: (\n input: ThreadState | ThreadMessage | ThreadMessage[\"content\"][number],\n ) => {\n const messages = getExternalStoreMessages(input);\n if (messages.length === 0) throw new Error(\"No original messages found\");\n return messages;\n },\n toOriginalMessage: (\n input: ThreadState | ThreadMessage | ThreadMessage[\"content\"][number],\n ) => {\n const messages = result.toOriginalMessages(input);\n return messages[0]!;\n },\n useOriginalMessage: () => {\n const messageMessages = result.useOriginalMessages();\n const first = messageMessages[0]!;\n return first;\n },\n useOriginalMessages: () => {\n const aui = useAui();\n const partMessages = useAuiState((s) => {\n if (aui.part.source) return getExternalStoreMessages(s.part);\n return undefined;\n });\n\n const messageMessages = useAuiState<T[]>((s) =>\n getExternalStoreMessages(s.message),\n );\n\n const messages = partMessages ?? messageMessages;\n if (messages.length === 0) throw new Error(\"No original messages found\");\n return messages;\n },\n };\n\n return result;\n};\n"],"mappings":";;;;;AAWA,MAAa,0BACX,aACG;CACH,MAAM,SAAS;EACb,oBAAoB,EAClB,UACA,WACA,cACA,eAMI;GACJ,OAAO,4BAA+B;IACpC;IACA;IACA;IACA;IACA;GACF,CAAC;EACH;EACA,mBACE,UACA,YAAY,OACZ,WAAiD,CAAC,MAC/C;GACH,OAAO,wBAAwB,UAAU,UAAU,WAAW,QAAQ;EACxE;EACA,qBACE,UACG;GACH,MAAM,WAAW,yBAAyB,KAAK;GAC/C,IAAI,SAAS,WAAW,GAAG,MAAM,IAAI,MAAM,4BAA4B;GACvE,OAAO;EACT;EACA,oBACE,UACG;GAEH,OADiB,OAAO,mBAAmB,KAC7B,CAAC,CAAC;EAClB;EACA,0BAA0B;GAGxB,OAFwB,OAAO,oBACH,CAAC,CAAC;EAEhC;EACA,2BAA2B;GACzB,MAAM,MAAM,OAAO;GACnB,MAAM,eAAe,aAAa,MAAM;IACtC,IAAI,IAAI,KAAK,QAAQ,OAAO,yBAAyB,EAAE,IAAI;GAE7D,CAAC;GAED,MAAM,kBAAkB,aAAkB,MACxC,yBAAyB,EAAE,OAAO,CACpC;GAEA,MAAM,WAAW,gBAAgB;GACjC,IAAI,SAAS,WAAW,GAAG,MAAM,IAAI,MAAM,4BAA4B;GACvE,OAAO;EACT;CACF;CAEA,OAAO;AACT"}
@@ -4,10 +4,11 @@ import { ToolExecutionStatus } from "../../runtimes/tool-invocations/ToolInvocat
4
4
  import { ReadonlyJSONValue } from "assistant-stream/utils";
5
5
 
6
6
  //#region src/react/runtimes/external-message-converter.d.ts
7
+ type JoinStrategy = "concat-content" | "none";
7
8
  declare namespace useExternalMessageConverter {
8
9
  type Message = (ThreadMessageLike & {
9
10
  readonly convertConfig?: {
10
- readonly joinStrategy?: "concat-content" | "none";
11
+ readonly joinStrategy?: JoinStrategy;
11
12
  };
12
13
  }) | {
13
14
  role: "tool";
@@ -36,9 +37,9 @@ declare const useExternalMessageConverter: <T extends WeakKey>({
36
37
  callback: useExternalMessageConverter.Callback<T>;
37
38
  messages: T[];
38
39
  isRunning: boolean;
39
- joinStrategy?: "concat-content" | "none" | undefined;
40
+ joinStrategy?: JoinStrategy | undefined;
40
41
  metadata?: useExternalMessageConverter.Metadata | undefined;
41
42
  }) => ThreadMessage[];
42
43
  //#endregion
43
- export { convertExternalMessages, useExternalMessageConverter };
44
+ export { JoinStrategy, convertExternalMessages, useExternalMessageConverter };
44
45
  //# sourceMappingURL=external-message-converter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"external-message-converter.d.ts","names":[],"sources":["../../../src/react/runtimes/external-message-converter.ts"],"mappings":";;;;;;kBAwCiB,2BAAA;EAAA,KACH,OAAA,IACP,iBAAA;IAAA,SACU,aAAA;MAAA,SACE,YAAA;IAAA;EAAA;IAIX,IAAA;IACA,UAAA;IACA,QAAA;IACA,MAAA;IACA,QAAA;IACA,OAAA;IACA,QAAA,YAAoB,aAAA;EAAA;EAAA,KAGd,QAAA;IAAA,SACD,YAAA,GAAe,MAAA,SAAe,mBAAA;IAAA,SAC9B,KAAA,GAAQ,iBAAA;IAAA,SACR,aAAA,GAAgB,MAAA,SAAe,aAAA;EAAA;EAAA,KAG9B,QAAA,OACV,OAAA,EAAS,CAAA,EACT,QAAA,EAAU,QAAA,KACP,OAAA,GAAU,OAAA;AAAA;AAAA,cAgRJ,uBAAA,aAAqC,OAAA,EAChD,QAAA,EAAU,CAAA,IACV,QAAA,EAAU,2BAAA,CAA4B,QAAA,CAAS,CAAA,GAC/C,SAAA,WACA,QAAA,EAAU,2BAAA,CAA4B,QAAA,KAAQ,aAAA;AAAA,cA+CnC,2BAAA,aAAyC,OAAA;EAAS,QAAA;EAAA,QAAA;EAAA,SAAA;EAAA,YAAA;EAAA;AAAA;EAO7D,QAAA,EAAU,2BAAA,CAA4B,QAAA,CAAS,CAAA;EAC/C,QAAA,EAAU,CAAA;EACV,SAAA;EACA,YAAA;EACA,QAAA,GAAW,2BAAA,CAA4B,QAAA;AAAA,MACxC,aAAA"}
1
+ {"version":3,"file":"external-message-converter.d.ts","names":[],"sources":["../../../src/react/runtimes/external-message-converter.ts"],"mappings":";;;;;;KAwBY,YAAA;AAAA,kBAkBK,2BAAA;EAAA,KACH,OAAA,IACP,iBAAA;IAAA,SACU,aAAA;MAAA,SACE,YAAA,GAAe,YAAA;IAAA;EAAA;IAI1B,IAAA;IACA,UAAA;IACA,QAAA;IACA,MAAA;IACA,QAAA;IACA,OAAA;IACA,QAAA,YAAoB,aAAA;EAAA;EAAA,KAGd,QAAA;IAAA,SACD,YAAA,GAAe,MAAA,SAAe,mBAAA;IAAA,SAC9B,KAAA,GAAQ,iBAAA;IAAA,SACR,aAAA,GAAgB,MAAA,SAAe,aAAA;EAAA;EAAA,KAG9B,QAAA,OACV,OAAA,EAAS,CAAA,EACT,QAAA,EAAU,QAAA,KACP,OAAA,GAAU,OAAA;AAAA;AAAA,cAgRJ,uBAAA,aAAqC,OAAA,EAChD,QAAA,EAAU,CAAA,IACV,QAAA,EAAU,2BAAA,CAA4B,QAAA,CAAS,CAAA,GAC/C,SAAA,WACA,QAAA,EAAU,2BAAA,CAA4B,QAAA,KAAQ,aAAA;AAAA,cA+CnC,2BAAA,aAAyC,OAAA;EAAS,QAAA;EAAA,QAAA;EAAA,SAAA;EAAA,YAAA;EAAA;AAAA;EAO7D,QAAA,EAAU,2BAAA,CAA4B,QAAA,CAAS,CAAA;EAC/C,QAAA,EAAU,CAAA;EACV,SAAA;EACA,YAAA,GAAe,YAAA;EACf,QAAA,GAAW,2BAAA,CAA4B,QAAA;AAAA,MACxC,aAAA"}
@@ -4,7 +4,7 @@ import { bindExternalStoreMessage, getExternalStoreMessages, symbolInnerMessage
4
4
  import { getAutoStatus, isAutoStatus } from "../../runtime/utils/auto-status.js";
5
5
  import { fromThreadMessageLike } from "../../runtime/utils/thread-message-like.js";
6
6
  import { ThreadMessageConverter } from "../../runtimes/external-store/thread-message-converter.js";
7
- import { useMemo } from "react";
7
+ import { useMemo } from "@assistant-ui/tap/react-shim";
8
8
  //#region src/react/runtimes/external-message-converter.ts
9
9
  const isPendingToolCall = (c) => c.type === "tool-call" && c.result === void 0;
10
10
  const isInterruptedToolCall = (c) => {
@@ -1 +1 @@
1
- {"version":3,"file":"external-message-converter.js","names":["unsupportedRole"],"sources":["../../../src/react/runtimes/external-message-converter.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport { ThreadMessageConverter } from \"../../runtimes/external-store/thread-message-converter\";\nimport {\n getExternalStoreMessages,\n symbolInnerMessage,\n bindExternalStoreMessage,\n} from \"../../runtime/utils/external-store-message\";\nimport {\n fromThreadMessageLike,\n type ThreadMessageLike,\n} from \"../../runtime/utils/thread-message-like\";\nimport { getAutoStatus, isAutoStatus } from \"../../runtime/utils/auto-status\";\nimport type { ToolExecutionStatus } from \"../../runtimes/tool-invocations/ToolInvocationTracker\";\nimport type { ReadonlyJSONValue } from \"assistant-stream/utils\";\nimport { generateErrorMessageId } from \"../../utils/id\";\nimport type {\n ThreadAssistantMessage,\n ThreadMessage,\n ToolCallMessagePart,\n} from \"../../types/message\";\nimport type { MessageTiming } from \"../../types/message\";\n\ntype ThreadMessageLikeContentItem = Exclude<\n ThreadMessageLike[\"content\"],\n string\n>[number];\n\nconst isPendingToolCall = (c: ThreadMessageLikeContentItem): boolean =>\n c.type === \"tool-call\" && c.result === undefined;\n\nconst isInterruptedToolCall = (c: ThreadMessageLikeContentItem): boolean => {\n if (c.type !== \"tool-call\" || c.result !== undefined) return false;\n return (\n c.interrupt != null ||\n (c.approval != null && c.approval.approved === undefined)\n );\n};\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | (ThreadMessageLike & {\n readonly convertConfig?: {\n readonly joinStrategy?: \"concat-content\" | \"none\";\n };\n })\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n artifact?: any;\n isError?: boolean;\n messages?: readonly ThreadMessage[];\n };\n\n export type Metadata = {\n readonly toolStatuses?: Record<string, ToolExecutionStatus>;\n readonly error?: ReadonlyJSONValue;\n readonly messageTiming?: Record<string, MessageTiming>;\n };\n\n export type Callback<T> = (\n message: T,\n metadata: Metadata,\n ) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nconst mergeInnerMessages = (existing: object, incoming: object) => ({\n [symbolInnerMessage]: [\n ...((existing as any)[symbolInnerMessage] ?? []),\n ...((incoming as any)[symbolInnerMessage] ?? []),\n ],\n});\n\nconst joinExternalMessages = (\n messages: readonly useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: Mutable<Omit<ThreadMessageLike, \"metadata\">> & {\n content: Exclude<ThreadMessageLike[\"content\"][0], string>[];\n metadata?: Mutable<ThreadMessageLike[\"metadata\"]>;\n } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n // Ignore orphaned tool results so one bad tool message does not\n // prevent rendering the rest of the conversation.\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallMessagePart;\n if (output.toolName !== undefined) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n ...{\n [symbolInnerMessage]: [\n ...((toolCall as any)[symbolInnerMessage] ?? []),\n output,\n ],\n },\n result: output.result,\n artifact: output.artifact,\n isError: output.isError,\n messages: output.messages,\n };\n }\n } else {\n const role = output.role;\n const content = (\n typeof output.content === \"string\"\n ? [{ type: \"text\" as const, text: output.content }]\n : output.content\n ).map((c) => ({\n ...c,\n ...{ [symbolInnerMessage]: [output] },\n }));\n switch (role) {\n case \"system\":\n case \"user\":\n return {\n ...output,\n content,\n };\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n\n if (output.attachments) {\n assistantMessage.attachments = [\n ...(assistantMessage.attachments ?? []),\n ...output.attachments,\n ];\n }\n\n if (output.metadata) {\n assistantMessage.metadata ??= {};\n if (output.metadata.unstable_state) {\n assistantMessage.metadata.unstable_state =\n output.metadata.unstable_state;\n }\n if (output.metadata.unstable_annotations) {\n assistantMessage.metadata.unstable_annotations = [\n ...(assistantMessage.metadata.unstable_annotations ?? []),\n ...output.metadata.unstable_annotations,\n ];\n }\n if (output.metadata.unstable_data) {\n assistantMessage.metadata.unstable_data = [\n ...(assistantMessage.metadata.unstable_data ?? []),\n ...output.metadata.unstable_data,\n ];\n }\n if (output.metadata.steps) {\n assistantMessage.metadata.steps = [\n ...(assistantMessage.metadata.steps ?? []),\n ...output.metadata.steps,\n ];\n }\n if (output.metadata.custom) {\n assistantMessage.metadata.custom = {\n ...(assistantMessage.metadata.custom ?? {}),\n ...output.metadata.custom,\n };\n }\n\n if (output.metadata.timing) {\n assistantMessage.metadata.timing = output.metadata.timing;\n }\n\n if (output.metadata.submittedFeedback) {\n assistantMessage.metadata.submittedFeedback =\n output.metadata.submittedFeedback;\n }\n\n if (output.metadata.isOptimistic) {\n assistantMessage.metadata.isOptimistic = true;\n }\n }\n // TODO keep this in sync\n }\n\n // Add content parts, merging reasoning parts with same parentId\n for (const part of content) {\n if (part.type === \"tool-call\") {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"tool-call\" && c.toolCallId === part.toolCallId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n ...part,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n\n if (\n part.type === \"reasoning\" &&\n \"parentId\" in part &&\n part.parentId\n ) {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"reasoning\" &&\n \"parentId\" in c &&\n c.parentId === part.parentId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n text: `${existing.text}\\n\\n${part.text}`,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n assistantMessage.content.push(part);\n }\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T>(\n callbackResults: CallbackResult<T>[],\n joinStrategy?: \"concat-content\" | \"none\",\n) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let pendingNone = false; // true if the previous assistant message had joinStrategy \"none\"\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n isAssistant = false;\n pendingNone = false;\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (\n (pendingNone && output.role !== \"tool\") ||\n !isAssistant ||\n output.role === \"user\" ||\n output.role === \"system\"\n ) {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n\n if (\n output.role === \"assistant\" &&\n (output.convertConfig?.joinStrategy === \"none\" ||\n joinStrategy === \"none\")\n ) {\n pendingNone = true;\n }\n }\n }\n flush();\n return results;\n};\n\nfunction createErrorAssistantMessage(\n error: ReadonlyJSONValue,\n): ThreadAssistantMessage {\n const msg: ThreadAssistantMessage = {\n id: generateErrorMessageId(),\n role: \"assistant\",\n content: [],\n status: { type: \"incomplete\", reason: \"error\", error },\n createdAt: new Date(),\n metadata: {\n unstable_state: null,\n unstable_annotations: [],\n unstable_data: [],\n custom: {},\n steps: [],\n },\n };\n bindExternalStoreMessage(msg, []);\n return msg;\n}\n\nexport const convertExternalMessages = <T extends WeakKey>(\n messages: T[],\n callback: useExternalMessageConverter.Callback<T>,\n isRunning: boolean,\n metadata: useExternalMessageConverter.Metadata,\n) => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n const output = callback(message, metadata);\n const outputs = Array.isArray(output) ? output : [output];\n const result = { input: message, outputs };\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults);\n\n const result = chunks.map((message, idx) => {\n const isLast = idx === chunks.length - 1;\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? metadata.error : undefined,\n );\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n });\n\n if (metadata.error) {\n const lastMessage = result.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n result.push(createErrorAssistantMessage(metadata.error));\n }\n }\n\n return result;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n joinStrategy,\n metadata,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n joinStrategy?: \"concat-content\" | \"none\" | undefined;\n metadata?: useExternalMessageConverter.Metadata | undefined;\n}) => {\n const state = useMemo(\n () => ({\n metadata: metadata ?? {},\n callback,\n callbackCache: new WeakMap<T, CallbackResult<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }),\n [callback, metadata],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (!result) {\n const output = state.callback(message, state.metadata);\n const outputs = Array.isArray(output) ? output : [output];\n result = { input: message, outputs };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults, joinStrategy).map(\n (m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs))\n return cached;\n state.chunkCache.set(key, m);\n return m;\n },\n );\n\n const threadMessages = state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? state.metadata.error : undefined,\n );\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessages<T>(cache);\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n },\n );\n\n bindExternalStoreMessage(threadMessages, messages);\n\n if (state.metadata.error) {\n const lastMessage = threadMessages.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n threadMessages.push(createErrorAssistantMessage(state.metadata.error));\n }\n }\n\n return threadMessages;\n }, [state, messages, isRunning, joinStrategy]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":";;;;;;;;AA6BA,MAAM,qBAAqB,MACzB,EAAE,SAAS,eAAe,EAAE,WAAW,KAAA;AAEzC,MAAM,yBAAyB,MAA6C;CAC1E,IAAI,EAAE,SAAS,eAAe,EAAE,WAAW,KAAA,GAAW,OAAO;CAC7D,OACE,EAAE,aAAa,QACd,EAAE,YAAY,QAAQ,EAAE,SAAS,aAAa,KAAA;AAEnD;AA6CA,MAAM,sBAAsB,UAAkB,cAAsB,GACjE,qBAAqB,CACpB,GAAK,SAAiB,uBAAuB,CAAC,GAC9C,GAAK,SAAiB,uBAAuB,CAAC,CAChD,EACF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AA4B,MAAM,SAAS,KAAK,CAAC;EAEzE;EAEA,OAAO;CACT,GAAG;EAAC;EAAO;EAAU;EAAW;CAAY,CAAC;AAC/C;AAEA,MAAM,qBAAqB,GAAc,MAAiB;CACxD,IAAI,EAAE,WAAW,EAAE,QAAQ,OAAO;CAClC,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAC5B,IAAI,EAAE,OAAO,EAAE,IAAI,OAAO;CAE5B,OAAO;AACT"}
1
+ {"version":3,"file":"external-message-converter.js","names":["unsupportedRole"],"sources":["../../../src/react/runtimes/external-message-converter.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport { ThreadMessageConverter } from \"../../runtimes/external-store/thread-message-converter\";\nimport {\n getExternalStoreMessages,\n symbolInnerMessage,\n bindExternalStoreMessage,\n} from \"../../runtime/utils/external-store-message\";\nimport {\n fromThreadMessageLike,\n type ThreadMessageLike,\n} from \"../../runtime/utils/thread-message-like\";\nimport { getAutoStatus, isAutoStatus } from \"../../runtime/utils/auto-status\";\nimport type { ToolExecutionStatus } from \"../../runtimes/tool-invocations/ToolInvocationTracker\";\nimport type { ReadonlyJSONValue } from \"assistant-stream/utils\";\nimport { generateErrorMessageId } from \"../../utils/id\";\nimport type {\n ThreadAssistantMessage,\n ThreadMessage,\n ToolCallMessagePart,\n} from \"../../types/message\";\nimport type { MessageTiming } from \"../../types/message\";\n\nexport type JoinStrategy = \"concat-content\" | \"none\";\n\ntype ThreadMessageLikeContentItem = Exclude<\n ThreadMessageLike[\"content\"],\n string\n>[number];\n\nconst isPendingToolCall = (c: ThreadMessageLikeContentItem): boolean =>\n c.type === \"tool-call\" && c.result === undefined;\n\nconst isInterruptedToolCall = (c: ThreadMessageLikeContentItem): boolean => {\n if (c.type !== \"tool-call\" || c.result !== undefined) return false;\n return (\n c.interrupt != null ||\n (c.approval != null && c.approval.approved === undefined)\n );\n};\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | (ThreadMessageLike & {\n readonly convertConfig?: {\n readonly joinStrategy?: JoinStrategy;\n };\n })\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n artifact?: any;\n isError?: boolean;\n messages?: readonly ThreadMessage[];\n };\n\n export type Metadata = {\n readonly toolStatuses?: Record<string, ToolExecutionStatus>;\n readonly error?: ReadonlyJSONValue;\n readonly messageTiming?: Record<string, MessageTiming>;\n };\n\n export type Callback<T> = (\n message: T,\n metadata: Metadata,\n ) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nconst mergeInnerMessages = (existing: object, incoming: object) => ({\n [symbolInnerMessage]: [\n ...((existing as any)[symbolInnerMessage] ?? []),\n ...((incoming as any)[symbolInnerMessage] ?? []),\n ],\n});\n\nconst joinExternalMessages = (\n messages: readonly useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: Mutable<Omit<ThreadMessageLike, \"metadata\">> & {\n content: Exclude<ThreadMessageLike[\"content\"][0], string>[];\n metadata?: Mutable<ThreadMessageLike[\"metadata\"]>;\n } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n // Ignore orphaned tool results so one bad tool message does not\n // prevent rendering the rest of the conversation.\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallMessagePart;\n if (output.toolName !== undefined) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n ...{\n [symbolInnerMessage]: [\n ...((toolCall as any)[symbolInnerMessage] ?? []),\n output,\n ],\n },\n result: output.result,\n artifact: output.artifact,\n isError: output.isError,\n messages: output.messages,\n };\n }\n } else {\n const role = output.role;\n const content = (\n typeof output.content === \"string\"\n ? [{ type: \"text\" as const, text: output.content }]\n : output.content\n ).map((c) => ({\n ...c,\n ...{ [symbolInnerMessage]: [output] },\n }));\n switch (role) {\n case \"system\":\n case \"user\":\n return {\n ...output,\n content,\n };\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n\n if (output.attachments) {\n assistantMessage.attachments = [\n ...(assistantMessage.attachments ?? []),\n ...output.attachments,\n ];\n }\n\n if (output.metadata) {\n assistantMessage.metadata ??= {};\n if (output.metadata.unstable_state) {\n assistantMessage.metadata.unstable_state =\n output.metadata.unstable_state;\n }\n if (output.metadata.unstable_annotations) {\n assistantMessage.metadata.unstable_annotations = [\n ...(assistantMessage.metadata.unstable_annotations ?? []),\n ...output.metadata.unstable_annotations,\n ];\n }\n if (output.metadata.unstable_data) {\n assistantMessage.metadata.unstable_data = [\n ...(assistantMessage.metadata.unstable_data ?? []),\n ...output.metadata.unstable_data,\n ];\n }\n if (output.metadata.steps) {\n assistantMessage.metadata.steps = [\n ...(assistantMessage.metadata.steps ?? []),\n ...output.metadata.steps,\n ];\n }\n if (output.metadata.custom) {\n assistantMessage.metadata.custom = {\n ...(assistantMessage.metadata.custom ?? {}),\n ...output.metadata.custom,\n };\n }\n\n if (output.metadata.timing) {\n assistantMessage.metadata.timing = output.metadata.timing;\n }\n\n if (output.metadata.submittedFeedback) {\n assistantMessage.metadata.submittedFeedback =\n output.metadata.submittedFeedback;\n }\n\n if (output.metadata.isOptimistic) {\n assistantMessage.metadata.isOptimistic = true;\n }\n }\n // TODO keep this in sync\n }\n\n // Add content parts, merging reasoning parts with same parentId\n for (const part of content) {\n if (part.type === \"tool-call\") {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"tool-call\" && c.toolCallId === part.toolCallId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n ...part,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n\n if (\n part.type === \"reasoning\" &&\n \"parentId\" in part &&\n part.parentId\n ) {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"reasoning\" &&\n \"parentId\" in c &&\n c.parentId === part.parentId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n text: `${existing.text}\\n\\n${part.text}`,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n assistantMessage.content.push(part);\n }\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T>(\n callbackResults: CallbackResult<T>[],\n joinStrategy?: JoinStrategy,\n) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let pendingNone = false; // true if the previous assistant message had joinStrategy \"none\"\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n isAssistant = false;\n pendingNone = false;\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (\n (pendingNone && output.role !== \"tool\") ||\n !isAssistant ||\n output.role === \"user\" ||\n output.role === \"system\"\n ) {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n\n if (\n output.role === \"assistant\" &&\n (output.convertConfig?.joinStrategy === \"none\" ||\n joinStrategy === \"none\")\n ) {\n pendingNone = true;\n }\n }\n }\n flush();\n return results;\n};\n\nfunction createErrorAssistantMessage(\n error: ReadonlyJSONValue,\n): ThreadAssistantMessage {\n const msg: ThreadAssistantMessage = {\n id: generateErrorMessageId(),\n role: \"assistant\",\n content: [],\n status: { type: \"incomplete\", reason: \"error\", error },\n createdAt: new Date(),\n metadata: {\n unstable_state: null,\n unstable_annotations: [],\n unstable_data: [],\n custom: {},\n steps: [],\n },\n };\n bindExternalStoreMessage(msg, []);\n return msg;\n}\n\nexport const convertExternalMessages = <T extends WeakKey>(\n messages: T[],\n callback: useExternalMessageConverter.Callback<T>,\n isRunning: boolean,\n metadata: useExternalMessageConverter.Metadata,\n) => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n const output = callback(message, metadata);\n const outputs = Array.isArray(output) ? output : [output];\n const result = { input: message, outputs };\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults);\n\n const result = chunks.map((message, idx) => {\n const isLast = idx === chunks.length - 1;\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? metadata.error : undefined,\n );\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n });\n\n if (metadata.error) {\n const lastMessage = result.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n result.push(createErrorAssistantMessage(metadata.error));\n }\n }\n\n return result;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n joinStrategy,\n metadata,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n joinStrategy?: JoinStrategy | undefined;\n metadata?: useExternalMessageConverter.Metadata | undefined;\n}) => {\n const state = useMemo(\n () => ({\n metadata: metadata ?? {},\n callback,\n callbackCache: new WeakMap<T, CallbackResult<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }),\n [callback, metadata],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (!result) {\n const output = state.callback(message, state.metadata);\n const outputs = Array.isArray(output) ? output : [output];\n result = { input: message, outputs };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults, joinStrategy).map(\n (m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs))\n return cached;\n state.chunkCache.set(key, m);\n return m;\n },\n );\n\n const threadMessages = state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? state.metadata.error : undefined,\n );\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessages<T>(cache);\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n },\n );\n\n bindExternalStoreMessage(threadMessages, messages);\n\n if (state.metadata.error) {\n const lastMessage = threadMessages.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n threadMessages.push(createErrorAssistantMessage(state.metadata.error));\n }\n }\n\n return threadMessages;\n }, [state, messages, isRunning, joinStrategy]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":";;;;;;;;AA+BA,MAAM,qBAAqB,MACzB,EAAE,SAAS,eAAe,EAAE,WAAW,KAAA;AAEzC,MAAM,yBAAyB,MAA6C;CAC1E,IAAI,EAAE,SAAS,eAAe,EAAE,WAAW,KAAA,GAAW,OAAO;CAC7D,OACE,EAAE,aAAa,QACd,EAAE,YAAY,QAAQ,EAAE,SAAS,aAAa,KAAA;AAEnD;AA6CA,MAAM,sBAAsB,UAAkB,cAAsB,GACjE,qBAAqB,CACpB,GAAK,SAAiB,uBAAuB,CAAC,GAC9C,GAAK,SAAiB,uBAAuB,CAAC,CAChD,EACF;AAEA,MAAM,wBACJ,aACsB;CACtB,MAAM,mBAGF;EACF,MAAM;EACN,SAAS,CAAC;CACZ;CACA,KAAK,MAAM,UAAU,UACnB,IAAI,OAAO,SAAS,QAAQ;EAC1B,MAAM,cAAc,iBAAiB,QAAQ,WAC1C,MAAM,EAAE,SAAS,eAAe,EAAE,eAAe,OAAO,UAC3D;EAGA,IAAI,gBAAgB,IAAI;GACtB,MAAM,WAAW,iBAAiB,QAChC;GAEF,IAAI,OAAO,aAAa,KAAA;QAClB,SAAS,aAAa,OAAO,UAC/B,MAAM,IAAI,MACR,kBAAkB,OAAO,WAAW,GAAG,OAAO,SAAS,qCAAqC,SAAS,UACvG;GAAA;GAEJ,iBAAiB,QAAQ,eAAe;IACtC,GAAG;KAEA,qBAAqB,CACpB,GAAK,SAAiB,uBAAuB,CAAC,GAC9C,MACF;IAEF,QAAQ,OAAO;IACf,UAAU,OAAO;IACjB,SAAS,OAAO;IAChB,UAAU,OAAO;GACnB;EACF;CACF,OAAO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,SAAS,qBAAqB,QAAQ,OAAO;GAOnD,MAAM,aAAa,cACjB,QACA,WAPA,OAAO,OAAO,YAAY,YAC1B,OAAO,QAAQ,KAAK,qBAAqB,GAEzC,OAAO,OAAO,YAAY,YAC1B,OAAO,QAAQ,KAAK,iBAAiB,GAMrC,SAAS,MAAM,SAAS,QAAQ,KAAA,CAClC;GAEA,IACE,UACC,MAAM,SAAS,eACd,CAAC,aAAa,MAAM,MAAM,KAC1B,MAAM,WAAW;QAGf,kBADW,yBAA4B,KAChB,GAAG,QAAQ,MAAM,GAC1C,OAAO;GAAA;GAIX,MAAM,aAAa,sBACjB,QACA,IAAI,SAAS,GACb,UACF;GACA,yBAAyB,YAAY,QAAQ,MAAM;GACnD,OAAO;EACT,CACF;EAEA,yBAAyB,gBAAgB,QAAQ;EAEjD,IAAI,MAAM,SAAS,OAAO;GACxB,MAAM,cAAc,eAAe,GAAG,EAAE;GACxC,IAAI,CAAC,eAAe,YAAY,SAAS,aACvC,eAAe,KAAK,4BAA4B,MAAM,SAAS,KAAK,CAAC;EAEzE;EAEA,OAAO;CACT,GAAG;EAAC;EAAO;EAAU;EAAW;CAAY,CAAC;AAC/C;AAEA,MAAM,qBAAqB,GAAc,MAAiB;CACxD,IAAI,EAAE,WAAW,EAAE,QAAQ,OAAO;CAClC,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAC5B,IAAI,EAAE,OAAO,EAAE,IAAI,OAAO;CAE5B,OAAO;AACT"}
@@ -2,7 +2,7 @@
2
2
  import { AssistantRuntimeImpl } from "../../runtime/api/assistant-runtime.js";
3
3
  import { ExternalStoreRuntimeCore } from "../../runtimes/external-store/external-store-runtime-core.js";
4
4
  import { useRuntimeAdapters } from "./RuntimeAdapterProvider.js";
5
- import { useEffect, useMemo, useState } from "react";
5
+ import { useEffect, useMemo, useState } from "@assistant-ui/tap/react-shim";
6
6
  //#region src/react/runtimes/useExternalStoreRuntime.ts
7
7
  const useExternalStoreRuntime = (store) => {
8
8
  const [runtime] = useState(() => new ExternalStoreRuntimeCore(store));
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { useMemo } from "react";
2
+ import { useMemo } from "@assistant-ui/tap/react-shim";
3
3
  //#region src/react/runtimes/useExternalStoreSharedOptions.ts
4
4
  const useExternalStoreSharedOptions = (options) => {
5
5
  const { isDisabled, isSendDisabled, unstable_capabilities, suggestions } = options;
@@ -32,8 +32,9 @@ declare const splitLocalRuntimeOptions: <T extends LocalRuntimeOptions>(options:
32
32
  suggestion?: SuggestionAdapter | undefined;
33
33
  }, "chatModel"> | undefined;
34
34
  unstable_humanToolNames: string[] | undefined;
35
+ unstable_enableMessageQueue: boolean | undefined;
35
36
  };
36
- otherOptions: Omit<T, "adapters" | "maxSteps" | "unstable_humanToolNames" | "cloud" | "initialMessages">;
37
+ otherOptions: Omit<T, "adapters" | "maxSteps" | "unstable_humanToolNames" | "unstable_enableMessageQueue" | "cloud" | "initialMessages">;
37
38
  };
38
39
  declare const useLocalRuntime: (chatModel: ChatModelAdapter, {
39
40
  cloud,
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalRuntime.d.ts","names":[],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"mappings":";;;;;;;;;;;;;KAcY,mBAAA,GAAsB,IAAA,CAAK,uBAAA;EACrC,KAAA,GAAQ,cAAA;EACR,eAAA,YAA2B,iBAAA;EAC3B,QAAA,GAAW,IAAA,CAAK,uBAAA;AAAA;AAAA,cA+CL,wBAAA,aAAsC,mBAAA,EACjD,OAAA,EAAS,CAAA;;;;;;;;;;;;;;;;;;;cAuBE,eAAA,GACX,SAAA,EAAW,gBAAA;EACX,KAAA;EAAA,GAAA;AAAA,IAAuB,mBAAA,KACtB,gBAAA"}
1
+ {"version":3,"file":"useLocalRuntime.d.ts","names":[],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"mappings":";;;;;;;;;;;;;KAcY,mBAAA,GAAsB,IAAA,CAAK,uBAAA;EACrC,KAAA,GAAQ,cAAA;EACR,eAAA,YAA2B,iBAAA;EAC3B,QAAA,GAAW,IAAA,CAAK,uBAAA;AAAA;AAAA,cA+CL,wBAAA,aAAsC,mBAAA,EACjD,OAAA,EAAS,CAAA;;;;;;;;;;;;;;;;;;;;cAyBE,eAAA,GACX,SAAA,EAAW,gBAAA;EACX,KAAA;EAAA,GAAA;AAAA,IAAuB,mBAAA,KACtB,gBAAA"}
@@ -3,7 +3,7 @@ import { LocalRuntimeCore } from "../../runtimes/local/local-runtime-core.js";
3
3
  import { useRuntimeAdapters } from "./RuntimeAdapterProvider.js";
4
4
  import { useRemoteThreadListRuntime } from "./useRemoteThreadListRuntime.js";
5
5
  import { useCloudThreadListAdapter } from "./cloud/useCloudThreadListAdapter.js";
6
- import { useEffect, useMemo, useRef, useState } from "react";
6
+ import { useEffect, useMemo, useRef, useState } from "@assistant-ui/tap/react-shim";
7
7
  import { useAuiState } from "@assistant-ui/store";
8
8
  //#region src/react/runtimes/useLocalRuntime.ts
9
9
  const useLocalThreadRuntime = (chatModel, { initialMessages, ...options }) => {
@@ -38,14 +38,15 @@ const useLocalThreadRuntime = (chatModel, { initialMessages, ...options }) => {
38
38
  return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
39
39
  };
40
40
  const splitLocalRuntimeOptions = (options) => {
41
- const { cloud, initialMessages, maxSteps, adapters, unstable_humanToolNames, ...rest } = options;
41
+ const { cloud, initialMessages, maxSteps, adapters, unstable_humanToolNames, unstable_enableMessageQueue, ...rest } = options;
42
42
  return {
43
43
  localRuntimeOptions: {
44
44
  cloud,
45
45
  initialMessages,
46
46
  maxSteps,
47
47
  adapters,
48
- unstable_humanToolNames
48
+ unstable_humanToolNames,
49
+ unstable_enableMessageQueue
49
50
  },
50
51
  otherOptions: rest
51
52
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalRuntime.js","names":[],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n AssistantRuntime,\n ChatModelAdapter,\n ThreadMessageLike,\n} from \"../../index\";\nimport type { LocalRuntimeOptionsBase } from \"../../runtimes/local/local-runtime-options\";\nimport { AssistantRuntimeImpl, LocalRuntimeCore } from \"../../internal\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useRemoteThreadListRuntime } from \"./useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"./cloud/useCloudThreadListAdapter\";\nimport { useRuntimeAdapters } from \"./RuntimeAdapterProvider\";\nimport type { AssistantCloud } from \"assistant-cloud\";\n\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n cloud?: AssistantCloud | undefined;\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nconst useLocalThreadRuntime = (\n chatModel: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions,\n): AssistantRuntime => {\n const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};\n const opt = {\n ...options,\n adapters: {\n ...threadListAdapters,\n ...options.adapters,\n chatModel,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n const threadIdRef = useRef<string | undefined>(undefined);\n threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);\n\n useEffect(() => {\n runtime.threads\n .getMainThreadRuntimeCore()\n .__internal_setGetThreadId(() => threadIdRef.current);\n }, [runtime]);\n\n useEffect(() => {\n return () => {\n runtime.threads.getMainThreadRuntimeCore().detach();\n };\n }, [runtime]);\n\n useEffect(() => {\n runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);\n runtime.threads.getMainThreadRuntimeCore().__internal_load();\n });\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n },\n otherOptions: rest,\n };\n};\n\nexport const useLocalRuntime = (\n chatModel: ChatModelAdapter,\n { cloud, ...options }: LocalRuntimeOptions = {},\n): AssistantRuntime => {\n const cloudAdapter = useCloudThreadListAdapter({ cloud });\n return useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useLocalThreadRuntime(chatModel, options);\n },\n adapter: cloudAdapter,\n allowNesting: true,\n });\n};\n"],"mappings":";;;;;;;;AAoBA,MAAM,yBACJ,WACA,EAAE,iBAAiB,GAAG,cACD;CACrB,MAAM,EAAE,cAAc,GAAG,uBAAuB,mBAAmB,KAAK,CAAC;CACzE,MAAM,MAAM;EACV,GAAG;EACH,UAAU;GACR,GAAG;GACH,GAAG,QAAQ;GACX;EACF;CACF;CAEA,MAAM,CAAC,WAAW,eAAe,IAAI,iBAAiB,KAAK,eAAe,CAAC;CAE3E,MAAM,cAAc,OAA2B,KAAA,CAAS;CACxD,YAAY,UAAU,aAAa,MAAM,EAAE,eAAe,QAAQ;CAElE,gBAAgB;EACd,QAAQ,QACL,yBAAyB,EACzB,gCAAgC,YAAY,OAAO;CACxD,GAAG,CAAC,OAAO,CAAC;CAEZ,gBAAgB;EACd,aAAa;GACX,QAAQ,QAAQ,yBAAyB,EAAE,OAAO;EACpD;CACF,GAAG,CAAC,OAAO,CAAC;CAEZ,gBAAgB;EACd,QAAQ,QAAQ,yBAAyB,EAAE,sBAAsB,GAAG;EACpE,QAAQ,QAAQ,yBAAyB,EAAE,gBAAgB;CAC7D,CAAC;CAED,gBAAgB;EACd,IAAI,CAAC,cAAc,OAAO,KAAA;EAC1B,OAAO,QAAQ,6BAA6B,YAAY;CAC1D,GAAG,CAAC,cAAc,OAAO,CAAC;CAE1B,OAAO,cAAc,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEA,MAAa,4BACX,YACG;CACH,MAAM,EACJ,OACA,iBACA,UACA,UACA,yBACA,GAAG,SACD;CAEJ,OAAO;EACL,qBAAqB;GACnB;GACA;GACA;GACA;GACA;EACF;EACA,cAAc;CAChB;AACF;AAEA,MAAa,mBACX,WACA,EAAE,OAAO,GAAG,YAAiC,CAAC,MACzB;CAErB,OAAO,2BAA2B;EAChC,aAAa,SAAS,cAAc;GAClC,OAAO,sBAAsB,WAAW,OAAO;EACjD;EACA,SALmB,0BAA0B,EAAE,MAAM,CAKjC;EACpB,cAAc;CAChB,CAAC;AACH"}
1
+ {"version":3,"file":"useLocalRuntime.js","names":[],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n AssistantRuntime,\n ChatModelAdapter,\n ThreadMessageLike,\n} from \"../../index\";\nimport type { LocalRuntimeOptionsBase } from \"../../runtimes/local/local-runtime-options\";\nimport { AssistantRuntimeImpl, LocalRuntimeCore } from \"../../internal\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useRemoteThreadListRuntime } from \"./useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"./cloud/useCloudThreadListAdapter\";\nimport { useRuntimeAdapters } from \"./RuntimeAdapterProvider\";\nimport type { AssistantCloud } from \"assistant-cloud\";\n\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n cloud?: AssistantCloud | undefined;\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nconst useLocalThreadRuntime = (\n chatModel: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions,\n): AssistantRuntime => {\n const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};\n const opt = {\n ...options,\n adapters: {\n ...threadListAdapters,\n ...options.adapters,\n chatModel,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n const threadIdRef = useRef<string | undefined>(undefined);\n threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);\n\n useEffect(() => {\n runtime.threads\n .getMainThreadRuntimeCore()\n .__internal_setGetThreadId(() => threadIdRef.current);\n }, [runtime]);\n\n useEffect(() => {\n return () => {\n runtime.threads.getMainThreadRuntimeCore().detach();\n };\n }, [runtime]);\n\n useEffect(() => {\n runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);\n runtime.threads.getMainThreadRuntimeCore().__internal_load();\n });\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n unstable_enableMessageQueue,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n unstable_enableMessageQueue,\n },\n otherOptions: rest,\n };\n};\n\nexport const useLocalRuntime = (\n chatModel: ChatModelAdapter,\n { cloud, ...options }: LocalRuntimeOptions = {},\n): AssistantRuntime => {\n const cloudAdapter = useCloudThreadListAdapter({ cloud });\n return useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useLocalThreadRuntime(chatModel, options);\n },\n adapter: cloudAdapter,\n allowNesting: true,\n });\n};\n"],"mappings":";;;;;;;;AAoBA,MAAM,yBACJ,WACA,EAAE,iBAAiB,GAAG,cACD;CACrB,MAAM,EAAE,cAAc,GAAG,uBAAuB,mBAAmB,KAAK,CAAC;CACzE,MAAM,MAAM;EACV,GAAG;EACH,UAAU;GACR,GAAG;GACH,GAAG,QAAQ;GACX;EACF;CACF;CAEA,MAAM,CAAC,WAAW,eAAe,IAAI,iBAAiB,KAAK,eAAe,CAAC;CAE3E,MAAM,cAAc,OAA2B,KAAA,CAAS;CACxD,YAAY,UAAU,aAAa,MAAM,EAAE,eAAe,QAAQ;CAElE,gBAAgB;EACd,QAAQ,QACL,yBAAyB,CAAC,CAC1B,gCAAgC,YAAY,OAAO;CACxD,GAAG,CAAC,OAAO,CAAC;CAEZ,gBAAgB;EACd,aAAa;GACX,QAAQ,QAAQ,yBAAyB,CAAC,CAAC,OAAO;EACpD;CACF,GAAG,CAAC,OAAO,CAAC;CAEZ,gBAAgB;EACd,QAAQ,QAAQ,yBAAyB,CAAC,CAAC,sBAAsB,GAAG;EACpE,QAAQ,QAAQ,yBAAyB,CAAC,CAAC,gBAAgB;CAC7D,CAAC;CAED,gBAAgB;EACd,IAAI,CAAC,cAAc,OAAO,KAAA;EAC1B,OAAO,QAAQ,6BAA6B,YAAY;CAC1D,GAAG,CAAC,cAAc,OAAO,CAAC;CAE1B,OAAO,cAAc,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEA,MAAa,4BACX,YACG;CACH,MAAM,EACJ,OACA,iBACA,UACA,UACA,yBACA,6BACA,GAAG,SACD;CAEJ,OAAO;EACL,qBAAqB;GACnB;GACA;GACA;GACA;GACA;GACA;EACF;EACA,cAAc;CAChB;AACF;AAEA,MAAa,mBACX,WACA,EAAE,OAAO,GAAG,YAAiC,CAAC,MACzB;CAErB,OAAO,2BAA2B;EAChC,aAAa,SAAS,cAAc;GAClC,OAAO,sBAAsB,WAAW,OAAO;EACjD;EACA,SALmB,0BAA0B,EAAE,MAAM,CAKjC;EACpB,cAAc;CAChB,CAAC;AACH"}
@@ -1,7 +1,7 @@
1
1
  import { BaseAssistantRuntimeCore } from "../../runtime/base/base-assistant-runtime-core.js";
2
2
  import { AssistantRuntimeImpl } from "../../runtime/api/assistant-runtime.js";
3
3
  import { RemoteThreadListThreadListRuntimeCore } from "./RemoteThreadListThreadListRuntimeCore.js";
4
- import { useCallback, useEffect, useMemo, useRef, useState } from "react";
4
+ import { useCallback, useEffect, useMemo, useRef, useState } from "@assistant-ui/tap/react-shim";
5
5
  import { useAui } from "@assistant-ui/store";
6
6
  //#region src/react/runtimes/useRemoteThreadListRuntime.ts
7
7
  var RemoteThreadListRuntimeCore = class extends BaseAssistantRuntimeCore {
@@ -1 +1 @@
1
- {"version":3,"file":"useRemoteThreadListRuntime.js","names":[],"sources":["../../../src/react/runtimes/useRemoteThreadListRuntime.ts"],"sourcesContent":["import { useState, useEffect, useMemo, useRef, useCallback } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../../runtime/base/base-assistant-runtime-core\";\nimport { AssistantRuntimeImpl } from \"../../runtime/api/assistant-runtime\";\nimport type { RemoteThreadListOptions } from \"../../runtimes/remote-thread-list/types\";\nimport type { AssistantRuntimeCore } from \"../../runtime/interfaces/assistant-runtime-core\";\nimport type { AssistantRuntime } from \"../../runtime/api/assistant-runtime\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { useAui } from \"@assistant-ui/store\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\nconst useRemoteThreadListRuntimeImpl = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));\n useEffect(() => {\n runtime.threads.__internal_setOptions(options);\n runtime.threads.__internal_load();\n }, [runtime, options]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useRemoteThreadListRuntime = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const runtimeHookRef = useRef(options.runtimeHook);\n runtimeHookRef.current = options.runtimeHook;\n\n // threadId/initialThreadId only affect the constructor; capture once via ref\n const startThreadIdRef = useRef(options.threadId ?? options.initialThreadId);\n\n const stableRuntimeHook = useCallback(() => {\n return runtimeHookRef.current();\n }, []);\n\n const stableOptions = useMemo<RemoteThreadListOptions>(\n () => ({\n adapter: options.adapter,\n allowNesting: options.allowNesting,\n initialThreadId: startThreadIdRef.current,\n runtimeHook: stableRuntimeHook,\n }),\n [options.adapter, options.allowNesting, stableRuntimeHook],\n );\n\n const aui = useAui();\n const isNested = aui.threadListItem.source !== null;\n\n if (isNested) {\n if (!stableOptions.allowNesting) {\n throw new Error(\n \"useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. \" +\n \"Set allowNesting: true to allow nesting (the inner runtime will become a no-op).\",\n );\n }\n\n // If allowNesting is true and already inside a thread list context,\n // just call the runtimeHook directly (no-op behavior)\n return stableRuntimeHook();\n }\n\n const runtime = useRemoteThreadListRuntimeImpl(stableOptions);\n\n const prevThreadIdRef = useRef(options.threadId);\n useEffect(() => {\n if (options.threadId === prevThreadIdRef.current) return;\n prevThreadIdRef.current = options.threadId;\n if (options.threadId) {\n runtime.threads.switchToThread(options.threadId).catch(() => {});\n } else {\n runtime.threads.switchToNewThread().catch(() => {});\n }\n }, [runtime, options.threadId]);\n\n return runtime;\n};\n"],"mappings":";;;;;;AASA,IAAM,8BAAN,cACU,yBAEV;CACE;CAEA,YAAY,SAAkC;EAC5C,MAAM;EACN,KAAK,UAAU,IAAI,sCACjB,SACA,KAAK,gBACP;CACF;CAEA,IAAW,kBAAkB;EAC3B,OAAO,KAAK,QAAQ;CACtB;AACF;AAEA,MAAM,kCACJ,YACqB;CACrB,MAAM,CAAC,WAAW,eAAe,IAAI,4BAA4B,OAAO,CAAC;CACzE,gBAAgB;EACd,QAAQ,QAAQ,sBAAsB,OAAO;EAC7C,QAAQ,QAAQ,gBAAgB;CAClC,GAAG,CAAC,SAAS,OAAO,CAAC;CAErB,OAAO,cAAc,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEA,MAAa,8BACX,YACqB;CACrB,MAAM,iBAAiB,OAAO,QAAQ,WAAW;CACjD,eAAe,UAAU,QAAQ;CAGjC,MAAM,mBAAmB,OAAO,QAAQ,YAAY,QAAQ,eAAe;CAE3E,MAAM,oBAAoB,kBAAkB;EAC1C,OAAO,eAAe,QAAQ;CAChC,GAAG,CAAC,CAAC;CAEL,MAAM,gBAAgB,eACb;EACL,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,iBAAiB,iBAAiB;EAClC,aAAa;CACf,IACA;EAAC,QAAQ;EAAS,QAAQ;EAAc;CAAiB,CAC3D;CAKA,IAHY,OACO,EAAE,eAAe,WAAW,MAEjC;EACZ,IAAI,CAAC,cAAc,cACjB,MAAM,IAAI,MACR,sKAEF;EAKF,OAAO,kBAAkB;CAC3B;CAEA,MAAM,UAAU,+BAA+B,aAAa;CAE5D,MAAM,kBAAkB,OAAO,QAAQ,QAAQ;CAC/C,gBAAgB;EACd,IAAI,QAAQ,aAAa,gBAAgB,SAAS;EAClD,gBAAgB,UAAU,QAAQ;EAClC,IAAI,QAAQ,UACV,QAAQ,QAAQ,eAAe,QAAQ,QAAQ,EAAE,YAAY,CAAC,CAAC;OAE/D,QAAQ,QAAQ,kBAAkB,EAAE,YAAY,CAAC,CAAC;CAEtD,GAAG,CAAC,SAAS,QAAQ,QAAQ,CAAC;CAE9B,OAAO;AACT"}
1
+ {"version":3,"file":"useRemoteThreadListRuntime.js","names":[],"sources":["../../../src/react/runtimes/useRemoteThreadListRuntime.ts"],"sourcesContent":["import { useState, useEffect, useMemo, useRef, useCallback } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../../runtime/base/base-assistant-runtime-core\";\nimport { AssistantRuntimeImpl } from \"../../runtime/api/assistant-runtime\";\nimport type { RemoteThreadListOptions } from \"../../runtimes/remote-thread-list/types\";\nimport type { AssistantRuntimeCore } from \"../../runtime/interfaces/assistant-runtime-core\";\nimport type { AssistantRuntime } from \"../../runtime/api/assistant-runtime\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { useAui } from \"@assistant-ui/store\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\nconst useRemoteThreadListRuntimeImpl = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));\n useEffect(() => {\n runtime.threads.__internal_setOptions(options);\n runtime.threads.__internal_load();\n }, [runtime, options]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useRemoteThreadListRuntime = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const runtimeHookRef = useRef(options.runtimeHook);\n runtimeHookRef.current = options.runtimeHook;\n\n // threadId/initialThreadId only affect the constructor; capture once via ref\n const startThreadIdRef = useRef(options.threadId ?? options.initialThreadId);\n\n const stableRuntimeHook = useCallback(() => {\n return runtimeHookRef.current();\n }, []);\n\n const stableOptions = useMemo<RemoteThreadListOptions>(\n () => ({\n adapter: options.adapter,\n allowNesting: options.allowNesting,\n initialThreadId: startThreadIdRef.current,\n runtimeHook: stableRuntimeHook,\n }),\n [options.adapter, options.allowNesting, stableRuntimeHook],\n );\n\n const aui = useAui();\n const isNested = aui.threadListItem.source !== null;\n\n if (isNested) {\n if (!stableOptions.allowNesting) {\n throw new Error(\n \"useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. \" +\n \"Set allowNesting: true to allow nesting (the inner runtime will become a no-op).\",\n );\n }\n\n // If allowNesting is true and already inside a thread list context,\n // just call the runtimeHook directly (no-op behavior)\n return stableRuntimeHook();\n }\n\n const runtime = useRemoteThreadListRuntimeImpl(stableOptions);\n\n const prevThreadIdRef = useRef(options.threadId);\n useEffect(() => {\n if (options.threadId === prevThreadIdRef.current) return;\n prevThreadIdRef.current = options.threadId;\n if (options.threadId) {\n runtime.threads.switchToThread(options.threadId).catch(() => {});\n } else {\n runtime.threads.switchToNewThread().catch(() => {});\n }\n }, [runtime, options.threadId]);\n\n return runtime;\n};\n"],"mappings":";;;;;;AASA,IAAM,8BAAN,cACU,yBAEV;CACE;CAEA,YAAY,SAAkC;EAC5C,MAAM;EACN,KAAK,UAAU,IAAI,sCACjB,SACA,KAAK,gBACP;CACF;CAEA,IAAW,kBAAkB;EAC3B,OAAO,KAAK,QAAQ;CACtB;AACF;AAEA,MAAM,kCACJ,YACqB;CACrB,MAAM,CAAC,WAAW,eAAe,IAAI,4BAA4B,OAAO,CAAC;CACzE,gBAAgB;EACd,QAAQ,QAAQ,sBAAsB,OAAO;EAC7C,QAAQ,QAAQ,gBAAgB;CAClC,GAAG,CAAC,SAAS,OAAO,CAAC;CAErB,OAAO,cAAc,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEA,MAAa,8BACX,YACqB;CACrB,MAAM,iBAAiB,OAAO,QAAQ,WAAW;CACjD,eAAe,UAAU,QAAQ;CAGjC,MAAM,mBAAmB,OAAO,QAAQ,YAAY,QAAQ,eAAe;CAE3E,MAAM,oBAAoB,kBAAkB;EAC1C,OAAO,eAAe,QAAQ;CAChC,GAAG,CAAC,CAAC;CAEL,MAAM,gBAAgB,eACb;EACL,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,iBAAiB,iBAAiB;EAClC,aAAa;CACf,IACA;EAAC,QAAQ;EAAS,QAAQ;EAAc;CAAiB,CAC3D;CAKA,IAHY,OACO,CAAC,CAAC,eAAe,WAAW,MAEjC;EACZ,IAAI,CAAC,cAAc,cACjB,MAAM,IAAI,MACR,sKAEF;EAKF,OAAO,kBAAkB;CAC3B;CAEA,MAAM,UAAU,+BAA+B,aAAa;CAE5D,MAAM,kBAAkB,OAAO,QAAQ,QAAQ;CAC/C,gBAAgB;EACd,IAAI,QAAQ,aAAa,gBAAgB,SAAS;EAClD,gBAAgB,UAAU,QAAQ;EAClC,IAAI,QAAQ,UACV,QAAQ,QAAQ,eAAe,QAAQ,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;OAE/D,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,YAAY,CAAC,CAAC;CAEtD,GAAG,CAAC,SAAS,QAAQ,QAAQ,CAAC;CAE9B,OAAO;AACT"}
@@ -1,5 +1,5 @@
1
- import { ToolsState } from "../types/scopes/tools.js";
2
1
  import { PartState } from "../../store/scopes/part.js";
2
+ import { ToolsState } from "../types/scopes/tools.js";
3
3
 
4
4
  //#region src/react/utils/groupParts.d.ts
5
5
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"groupParts.js","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"sourcesContent":["import { isMcpAppUri } from \"../../types/message\";\nimport type { PartState } from \"../../store/scopes/part\";\nimport type { ToolsState } from \"../types/scopes/tools\";\n\n/**\n * Registry context passed to a `groupBy` function as its second argument by\n * `<MessagePrimitive.GroupedParts>`. Carries the live tool-UI registry so a\n * `groupBy` can resolve registry-driven grouping (e.g. standalone tool calls)\n * without the part itself having to carry that information.\n */\nexport type GroupByContext = {\n /** Tool UIs registered in the tool-UI registry, keyed by tool name. */\n readonly toolUIs?: ToolsState[\"toolUIs\"];\n};\n\n/**\n * Hierarchical adjacent-coalescing grouping for message parts.\n *\n * Given a group path per part (from `groupBy`), builds a tree of group\n * nodes wrapping individual parts. Adjacent parts sharing a path prefix\n * coalesce into the same group; ungrouped parts are direct children of\n * the root.\n *\n * Each node gets a structural `nodeKey` built from sibling indices\n * (`\"0.1.0\"`), stable under append-only streaming.\n */\n\n/**\n * Symbol attached to memoizable `groupBy` functions (e.g. those returned\n * by {@link groupPartByType}). Carries a string fingerprint of the config\n * so `MessagePrimitive.GroupedParts` can memo the tree on\n * `[parts, memoKey]` across renders — even when the helper call site\n * reconstructs the function each render.\n */\nexport const GROUPBY_MEMO_KEY: unique symbol = Symbol.for(\n \"@assistant-ui/groupBy.memoKey\",\n);\n\n/**\n * Synthetic part-type keys recognized by {@link groupPartByType}, in\n * addition to real {@link PartState} types:\n *\n * - `\"standalone-tool-call\"` — a tool-call whose UI should be presented on its\n * own, outside the chain-of-thought grouping. Matches MCP-app tool calls plus\n * any tool-call whose registered UI opts into standalone display (human\n * tools, the built-in generative-UI tool, and tools that set\n * `display: \"standalone\"`). Resolving the registry-driven cases reads the\n * {@link GroupByContext} passed to the `groupBy` function. Takes precedence\n * over the `\"tool-call\"` entry.\n * - `\"mcp-app\"` — **deprecated**, kept for back-compat. Matches only MCP-app\n * tool calls. Prefer `\"standalone-tool-call\"`, which is a superset.\n */\ntype GroupPartType = PartState[\"type\"] | \"standalone-tool-call\" | \"mcp-app\";\n\n/**\n * Build a `groupBy` from a `part.type → group-key path` lookup.\n * Parts whose type isn't in the map are left ungrouped. The returned\n * function carries a stable {@link GROUPBY_MEMO_KEY} fingerprint so\n * `<MessagePrimitive.GroupedParts>` can memoize its tree across renders.\n *\n * The synthetic `\"standalone-tool-call\"` key matches tool calls that should\n * render outside the chain-of-thought grouping. MCP-app calls are detected from\n * the part alone; the registry-driven cases (human tools, the generative-UI\n * tool, `display: \"standalone\"` opt-ins) are resolved from the\n * {@link GroupByContext} that `<MessagePrimitive.GroupedParts>` passes to the\n * `groupBy` function — the helper needs nothing threaded into it.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * \"standalone-tool-call\": [],\n * })}\n * >\n * {({ part, children }) => { ... }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const groupPartByType = <TKey extends `group-${string}`>(\n map: Partial<Readonly<Record<GroupPartType, readonly TKey[]>>>,\n): ((part: PartState, context?: GroupByContext) => readonly TKey[]) => {\n const lookup = map as Readonly<Record<string, readonly TKey[] | undefined>>;\n const fn = ((part, context) => {\n if (part.type === \"tool-call\") {\n const isMcpApp = isMcpAppUri(part.mcp?.app?.resourceUri);\n // Read the first registration's flag — the same one `resolveToolRender`\n // renders — so grouping and rendering never disagree for a tool name.\n const isStandalone =\n isMcpApp ||\n (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false);\n if (isStandalone && lookup[\"standalone-tool-call\"] !== undefined) {\n return lookup[\"standalone-tool-call\"]!;\n }\n // TODO(v0.15): drop the deprecated \"mcp-app\" key (superseded by \"standalone-tool-call\").\n if (isMcpApp && lookup[\"mcp-app\"] !== undefined) {\n return lookup[\"mcp-app\"]!;\n }\n }\n return lookup[part.type] ?? [];\n }) as ((part: PartState, context?: GroupByContext) => readonly TKey[]) & {\n [GROUPBY_MEMO_KEY]?: string;\n };\n // Sort keys so the fingerprint is insensitive to map insertion order —\n // two maps with the same key/value pairs but different declaration order\n // would otherwise hash differently and invalidate the memo unnecessarily.\n const sortedKeys = Object.keys(map).sort();\n const sortedEntries = sortedKeys.map((k) => [k, map[k as keyof typeof map]]);\n fn[GROUPBY_MEMO_KEY] = `groupPartByType:${JSON.stringify(sortedEntries)}`;\n return fn;\n};\n\nexport type GroupNode = GroupNodeGroup | GroupNodePart;\n\nexport interface GroupNodeGroup {\n readonly type: \"group\";\n /** Current-level group key (last segment of the path). */\n readonly key: string;\n /** Structural React key: sibling-index path, e.g. `\"0.1.0\"`. */\n readonly nodeKey: string;\n /** Indices of parts in this subtree, in order. */\n readonly indices: readonly number[];\n readonly children: readonly GroupNode[];\n}\n\nexport interface GroupNodePart {\n readonly type: \"part\";\n /** Index of the part in the message. */\n readonly index: number;\n /** Structural React key: sibling-index path within parent. */\n readonly nodeKey: string;\n}\n\ninterface BuildFrame {\n key: string;\n nodeKey: string;\n indices: number[];\n children: GroupNode[];\n nextChildIdx: number;\n}\n\nconst makeChildNodeKey = (parent: BuildFrame): string => {\n const idx = parent.nextChildIdx++;\n return parent.nodeKey === \"\" ? String(idx) : `${parent.nodeKey}.${idx}`;\n};\n\n/**\n * Build the group tree from an array of normalized group paths.\n * `paths[i]` is the path for part `i`. The output tree contains one\n * `part` node per part and one `group` node per coalesced run.\n */\nexport const buildGroupTree = (\n paths: readonly (readonly string[])[],\n): readonly GroupNode[] => {\n const root: BuildFrame = {\n key: \"\",\n nodeKey: \"\",\n indices: [],\n children: [],\n nextChildIdx: 0,\n };\n const stack: BuildFrame[] = [root];\n\n const closeTop = (): void => {\n const closing = stack.pop()!;\n const parent = stack[stack.length - 1]!;\n parent.children.push({\n type: \"group\",\n key: closing.key,\n nodeKey: closing.nodeKey,\n indices: closing.indices,\n children: closing.children,\n });\n };\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]!;\n\n // Find the longest prefix shared between currently-open groups\n // (excluding root) and this part's path.\n let common = 0;\n while (\n common < stack.length - 1 &&\n common < path.length &&\n stack[common + 1]!.key === path[common]\n ) {\n common++;\n }\n\n // Close groups not on this path.\n while (stack.length - 1 > common) {\n closeTop();\n }\n\n // Open new groups down to the part's depth.\n while (stack.length - 1 < path.length) {\n const parent = stack[stack.length - 1]!;\n stack.push({\n key: path[stack.length - 1]!,\n nodeKey: makeChildNodeKey(parent),\n indices: [],\n children: [],\n nextChildIdx: 0,\n });\n }\n\n // Push this part as a leaf in the deepest open group (or root).\n const top = stack[stack.length - 1]!;\n top.children.push({\n type: \"part\",\n index: i,\n nodeKey: makeChildNodeKey(top),\n });\n\n // Record the part index in every open ancestor group.\n for (let s = 1; s < stack.length; s++) {\n stack[s]!.indices.push(i);\n }\n }\n\n // Close any still-open groups.\n while (stack.length > 1) {\n closeTop();\n }\n\n return root.children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,mBAAkC,OAAO,IACpD,+BACF;;;;;;;;;;;;;;;;;;;;;;;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AS;EAIX,OAAO,MAAM,SAAS,IAAI,KAAK,QAAQ;GACrC,MAAM,SAAS,MAAM,MAAM,SAAS;GACpC,MAAM,KAAK;IACT,KAAK,KAAK,MAAM,SAAS;IACzB,SAAS,iBAAiB,MAAM;IAChC,SAAS,CAAC;IACV,UAAU,CAAC;IACX,cAAc;GAChB,CAAC;EACH;EAGA,MAAM,MAAM,MAAM,MAAM,SAAS;EACjC,IAAI,SAAS,KAAK;GAChB,MAAM;GACN,OAAO;GACP,SAAS,iBAAiB,GAAG;EAC/B,CAAC;EAGD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,MAAM,GAAI,QAAQ,KAAK,CAAC;CAE5B;CAGA,OAAO,MAAM,SAAS,GACpB,SAAS;CAGX,OAAO,KAAK;AACd"}
1
+ {"version":3,"file":"groupParts.js","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"sourcesContent":["import { isMcpAppUri } from \"../../types/message\";\nimport type { PartState } from \"../../store/scopes/part\";\nimport type { ToolsState } from \"../types/scopes/tools\";\n\n/**\n * Registry context passed to a `groupBy` function as its second argument by\n * `<MessagePrimitive.GroupedParts>`. Carries the live tool-UI registry so a\n * `groupBy` can resolve registry-driven grouping (e.g. standalone tool calls)\n * without the part itself having to carry that information.\n */\nexport type GroupByContext = {\n /** Tool UIs registered in the tool-UI registry, keyed by tool name. */\n readonly toolUIs?: ToolsState[\"toolUIs\"];\n};\n\n/**\n * Hierarchical adjacent-coalescing grouping for message parts.\n *\n * Given a group path per part (from `groupBy`), builds a tree of group\n * nodes wrapping individual parts. Adjacent parts sharing a path prefix\n * coalesce into the same group; ungrouped parts are direct children of\n * the root.\n *\n * Each node gets a structural `nodeKey` built from sibling indices\n * (`\"0.1.0\"`), stable under append-only streaming.\n */\n\n/**\n * Symbol attached to memoizable `groupBy` functions (e.g. those returned\n * by {@link groupPartByType}). Carries a string fingerprint of the config\n * so `MessagePrimitive.GroupedParts` can memo the tree on\n * `[parts, memoKey]` across renders — even when the helper call site\n * reconstructs the function each render.\n */\nexport const GROUPBY_MEMO_KEY: unique symbol = Symbol.for(\n \"@assistant-ui/groupBy.memoKey\",\n);\n\n/**\n * Synthetic part-type keys recognized by {@link groupPartByType}, in\n * addition to real {@link PartState} types:\n *\n * - `\"standalone-tool-call\"` — a tool-call whose UI should be presented on its\n * own, outside the chain-of-thought grouping. Matches MCP-app tool calls plus\n * any tool-call whose registered UI opts into standalone display (human\n * tools, the built-in generative-UI tool, and tools that set\n * `display: \"standalone\"`). Resolving the registry-driven cases reads the\n * {@link GroupByContext} passed to the `groupBy` function. Takes precedence\n * over the `\"tool-call\"` entry.\n * - `\"mcp-app\"` — **deprecated**, kept for back-compat. Matches only MCP-app\n * tool calls. Prefer `\"standalone-tool-call\"`, which is a superset.\n */\ntype GroupPartType = PartState[\"type\"] | \"standalone-tool-call\" | \"mcp-app\";\n\n/**\n * Build a `groupBy` from a `part.type → group-key path` lookup.\n * Parts whose type isn't in the map are left ungrouped. The returned\n * function carries a stable {@link GROUPBY_MEMO_KEY} fingerprint so\n * `<MessagePrimitive.GroupedParts>` can memoize its tree across renders.\n *\n * The synthetic `\"standalone-tool-call\"` key matches tool calls that should\n * render outside the chain-of-thought grouping. MCP-app calls are detected from\n * the part alone; the registry-driven cases (human tools, the generative-UI\n * tool, `display: \"standalone\"` opt-ins) are resolved from the\n * {@link GroupByContext} that `<MessagePrimitive.GroupedParts>` passes to the\n * `groupBy` function — the helper needs nothing threaded into it.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * \"standalone-tool-call\": [],\n * })}\n * >\n * {({ part, children }) => { ... }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const groupPartByType = <TKey extends `group-${string}`>(\n map: Partial<Readonly<Record<GroupPartType, readonly TKey[]>>>,\n): ((part: PartState, context?: GroupByContext) => readonly TKey[]) => {\n const lookup = map as Readonly<Record<string, readonly TKey[] | undefined>>;\n const fn = ((part, context) => {\n if (part.type === \"tool-call\") {\n const isMcpApp = isMcpAppUri(part.mcp?.app?.resourceUri);\n // Read the first registration's flag — the same one `resolveToolRender`\n // renders — so grouping and rendering never disagree for a tool name.\n const isStandalone =\n isMcpApp ||\n (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false);\n if (isStandalone && lookup[\"standalone-tool-call\"] !== undefined) {\n return lookup[\"standalone-tool-call\"]!;\n }\n // TODO(v0.15): drop the deprecated \"mcp-app\" key (superseded by \"standalone-tool-call\").\n if (isMcpApp && lookup[\"mcp-app\"] !== undefined) {\n return lookup[\"mcp-app\"]!;\n }\n }\n return lookup[part.type] ?? [];\n }) as ((part: PartState, context?: GroupByContext) => readonly TKey[]) & {\n [GROUPBY_MEMO_KEY]?: string;\n };\n // Sort keys so the fingerprint is insensitive to map insertion order —\n // two maps with the same key/value pairs but different declaration order\n // would otherwise hash differently and invalidate the memo unnecessarily.\n const sortedKeys = Object.keys(map).sort();\n const sortedEntries = sortedKeys.map((k) => [k, map[k as keyof typeof map]]);\n fn[GROUPBY_MEMO_KEY] = `groupPartByType:${JSON.stringify(sortedEntries)}`;\n return fn;\n};\n\nexport type GroupNode = GroupNodeGroup | GroupNodePart;\n\nexport interface GroupNodeGroup {\n readonly type: \"group\";\n /** Current-level group key (last segment of the path). */\n readonly key: string;\n /** Structural React key: sibling-index path, e.g. `\"0.1.0\"`. */\n readonly nodeKey: string;\n /** Indices of parts in this subtree, in order. */\n readonly indices: readonly number[];\n readonly children: readonly GroupNode[];\n}\n\nexport interface GroupNodePart {\n readonly type: \"part\";\n /** Index of the part in the message. */\n readonly index: number;\n /** Structural React key: sibling-index path within parent. */\n readonly nodeKey: string;\n}\n\ninterface BuildFrame {\n key: string;\n nodeKey: string;\n indices: number[];\n children: GroupNode[];\n nextChildIdx: number;\n}\n\nconst makeChildNodeKey = (parent: BuildFrame): string => {\n const idx = parent.nextChildIdx++;\n return parent.nodeKey === \"\" ? String(idx) : `${parent.nodeKey}.${idx}`;\n};\n\n/**\n * Build the group tree from an array of normalized group paths.\n * `paths[i]` is the path for part `i`. The output tree contains one\n * `part` node per part and one `group` node per coalesced run.\n */\nexport const buildGroupTree = (\n paths: readonly (readonly string[])[],\n): readonly GroupNode[] => {\n const root: BuildFrame = {\n key: \"\",\n nodeKey: \"\",\n indices: [],\n children: [],\n nextChildIdx: 0,\n };\n const stack: BuildFrame[] = [root];\n\n const closeTop = (): void => {\n const closing = stack.pop()!;\n const parent = stack[stack.length - 1]!;\n parent.children.push({\n type: \"group\",\n key: closing.key,\n nodeKey: closing.nodeKey,\n indices: closing.indices,\n children: closing.children,\n });\n };\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]!;\n\n // Find the longest prefix shared between currently-open groups\n // (excluding root) and this part's path.\n let common = 0;\n while (\n common < stack.length - 1 &&\n common < path.length &&\n stack[common + 1]!.key === path[common]\n ) {\n common++;\n }\n\n // Close groups not on this path.\n while (stack.length - 1 > common) {\n closeTop();\n }\n\n // Open new groups down to the part's depth.\n while (stack.length - 1 < path.length) {\n const parent = stack[stack.length - 1]!;\n stack.push({\n key: path[stack.length - 1]!,\n nodeKey: makeChildNodeKey(parent),\n indices: [],\n children: [],\n nextChildIdx: 0,\n });\n }\n\n // Push this part as a leaf in the deepest open group (or root).\n const top = stack[stack.length - 1]!;\n top.children.push({\n type: \"part\",\n index: i,\n nodeKey: makeChildNodeKey(top),\n });\n\n // Record the part index in every open ancestor group.\n for (let s = 1; s < stack.length; s++) {\n stack[s]!.indices.push(i);\n }\n }\n\n // Close any still-open groups.\n while (stack.length > 1) {\n closeTop();\n }\n\n return root.children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAa,mBAAkC,OAAO,IACpD,+BACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,mBACX,QACqE;CACrE,MAAM,SAAS;CACf,MAAM,OAAO,MAAM,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AAK,QAAQ;GACrC,MAAM,SAAS,MAAM,MAAM,SAAS;GACpC,MAAM,KAAK;IACT,KAAK,KAAK,MAAM,SAAS;IACzB,SAAS,iBAAiB,MAAM;IAChC,SAAS,CAAC;IACV,UAAU,CAAC;IACX,cAAc;GAChB,CAAC;EACH;EAGA,MAAM,MAAM,MAAM,MAAM,SAAS;EACjC,IAAI,SAAS,KAAK;GAChB,MAAM;GACN,OAAO;GACP,SAAS,iBAAiB,GAAG;EAC/B,CAAC;EAGD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,MAAM,EAAE,CAAE,QAAQ,KAAK,CAAC;CAE5B;CAGA,OAAO,MAAM,SAAS,GACpB,SAAS;CAGX,OAAO,KAAK;AACd"}
@@ -1 +1 @@
1
- {"version":3,"file":"attachment-runtime.js","names":[],"sources":["../../../src/runtime/api/attachment-runtime.ts"],"sourcesContent":["import type { Attachment, CompleteAttachment } from \"../../types/attachment\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { SubscribableWithState } from \"../../subscribable/subscribable\";\n\nimport type { ComposerRuntimeCoreBinding } from \"./bindings\";\nimport type { AttachmentRuntimePath } from \"./paths\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n readonly source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = Attachment & {\n readonly source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n readonly source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n readonly path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n constructor(private _core: AttachmentSnapshotBinding<Source>) {\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.getState = this.getState.bind(this);\n this.remove = this.remove.bind(this);\n this.subscribe = this.subscribe.bind(this);\n }\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n private _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";AA0CA,IAAsB,wBAAtB,MAE+B;CAOT;CANpB,IAAW,OAAO;EAChB,OAAO,KAAK,MAAM;CACpB;CAIA,YAAY,OAAkD;EAA1C,KAAA,QAAA;EAClB,KAAK,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAK,WAAW,KAAK,SAAS,KAAK,IAAI;EACvC,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;EACnC,KAAK,YAAY,KAAK,UAAU,KAAK,IAAI;CAC3C;CAEA,WAAwD;EACtD,OAAO,KAAK,MAAM,SAAS;CAC7B;CAIA,UAAiB,UAAsB;EACrC,OAAO,KAAK,MAAM,UAAU,QAAQ;CACtC;AACF;AAEA,IAAe,4BAAf,cAEU,sBAA8B;CAG5B;CAFV,YACE,MACA,cACA;EACA,MAAM,IAAI;EAFF,KAAA,eAAA;CAGV;CAEA,SAAgB;EACd,MAAM,OAAO,KAAK,aAAa,SAAS;EACxC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,2BAA2B;EACtD,OAAO,KAAK,iBAAiB,KAAK,SAAS,EAAE,EAAE;CACjD;AACF;AAEA,IAAa,sCAAb,cAAyD,0BAA6C;CACpG,IAAW,SAA4B;EACrC,OAAO;CACT;AACF;AAEA,IAAa,oCAAb,cAAuD,0BAA2C;CAChG,IAAW,SAA0B;EACnC,OAAO;CACT;AACF;AAEA,IAAa,+BAAb,cAAkD,sBAAiC;CACjF,IAAW,SAAoB;EAC7B,OAAO;CACT;CAEA,SAAuB;EACrB,MAAM,IAAI,MAAM,uCAAuC;CACzD;AACF"}
1
+ {"version":3,"file":"attachment-runtime.js","names":[],"sources":["../../../src/runtime/api/attachment-runtime.ts"],"sourcesContent":["import type { Attachment, CompleteAttachment } from \"../../types/attachment\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { SubscribableWithState } from \"../../subscribable/subscribable\";\n\nimport type { ComposerRuntimeCoreBinding } from \"./bindings\";\nimport type { AttachmentRuntimePath } from \"./paths\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n readonly source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = Attachment & {\n readonly source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n readonly source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n readonly path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n constructor(private _core: AttachmentSnapshotBinding<Source>) {\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.getState = this.getState.bind(this);\n this.remove = this.remove.bind(this);\n this.subscribe = this.subscribe.bind(this);\n }\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n private _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";AA0CA,IAAsB,wBAAtB,MAE+B;CAOT;CANpB,IAAW,OAAO;EAChB,OAAO,KAAK,MAAM;CACpB;CAIA,YAAY,OAAkD;EAA1C,KAAA,QAAA;EAClB,KAAK,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAK,WAAW,KAAK,SAAS,KAAK,IAAI;EACvC,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;EACnC,KAAK,YAAY,KAAK,UAAU,KAAK,IAAI;CAC3C;CAEA,WAAwD;EACtD,OAAO,KAAK,MAAM,SAAS;CAC7B;CAIA,UAAiB,UAAsB;EACrC,OAAO,KAAK,MAAM,UAAU,QAAQ;CACtC;AACF;AAEA,IAAe,4BAAf,cAEU,sBAA8B;CAG5B;CAFV,YACE,MACA,cACA;EACA,MAAM,IAAI;EAFF,KAAA,eAAA;CAGV;CAEA,SAAgB;EACd,MAAM,OAAO,KAAK,aAAa,SAAS;EACxC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,2BAA2B;EACtD,OAAO,KAAK,iBAAiB,KAAK,SAAS,CAAC,CAAC,EAAE;CACjD;AACF;AAEA,IAAa,sCAAb,cAAyD,0BAA6C;CACpG,IAAW,SAA4B;EACrC,OAAO;CACT;AACF;AAEA,IAAa,oCAAb,cAAuD,0BAA2C;CAChG,IAAW,SAA0B;EACnC,OAAO;CACT;AACF;AAEA,IAAa,+BAAb,cAAkD,sBAAiC;CACjF,IAAW,SAAoB;EAC7B,OAAO;CACT;CAEA,SAAuB;EACrB,MAAM,IAAI,MAAM,uCAAuC;CACzD;AACF"}
@@ -2,6 +2,7 @@ import { MessageRole, RunConfig } from "../../types/message.js";
2
2
  import { Attachment, CreateAttachment } from "../../types/attachment.js";
3
3
  import { Unsubscribe } from "../../types/unsubscribe.js";
4
4
  import { QuoteInfo } from "../../types/quote.js";
5
+ import { QueueItemState } from "../../store/scopes/queue-item.js";
5
6
  import { ComposerRuntimeEventCallback, ComposerRuntimeEventType, DictationState, SendOptions } from "../interfaces/composer-runtime-core.js";
6
7
  import { ComposerRuntimePath } from "./paths.js";
7
8
  import { ComposerRuntimeCoreBinding, EditComposerRuntimeCoreBinding, ThreadComposerRuntimeCoreBinding } from "./bindings.js";
@@ -27,7 +28,8 @@ type BaseComposerState = {
27
28
  * The currently quoted text, if any.
28
29
  * Undefined when no quote is set.
29
30
  */
30
- readonly quote: QuoteInfo | undefined;
31
+ readonly quote: QuoteInfo | undefined; /** Messages waiting to be processed. Empty unless the `queue` capability is set. */
32
+ readonly queue: readonly QueueItemState[];
31
33
  };
32
34
  type ThreadComposerState = BaseComposerState & {
33
35
  readonly type: "thread";
@@ -93,7 +95,9 @@ type ComposerRuntime = {
93
95
  /**
94
96
  * Cancel the current run. In edit mode, this will exit edit mode.
95
97
  */
96
- cancel(): void;
98
+ cancel(): void; /** Promote a queued message so it processes next. */
99
+ steerQueueItem(queueItemId: string): void; /** Remove a queued message. */
100
+ removeQueueItem(queueItemId: string): void;
97
101
  /**
98
102
  * Listens for changes to the composer state.
99
103
  * @param callback The callback to call when the composer state changes.
@@ -137,6 +141,8 @@ declare abstract class ComposerRuntimeImpl implements ComposerRuntime {
137
141
  clearAttachments(): Promise<void>;
138
142
  send(options?: SendOptions): void;
139
143
  cancel(): void;
144
+ steerQueueItem(queueItemId: string): void;
145
+ removeQueueItem(queueItemId: string): void;
140
146
  setRole(role: MessageRole): void;
141
147
  startDictation(): void;
142
148
  stopDictation(): void;
@@ -1 +1 @@
1
- {"version":3,"file":"composer-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/composer-runtime.ts"],"mappings":";;;;;;;;;;KAyCK,iBAAA;EAAA,SACM,SAAA;EAAA,SACA,OAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;EAAA,SAEA,IAAA;EAAA,SACA,I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  quote: runtime?.quote,
20
+ queue: runtime?.queue ?? EMPTY_ARRAY,
20
21
  value: runtime?.text ?? ""
21
22
  });
22
23
  };
@@ -34,6 +35,7 @@ const getEditComposerState = (runtime) => {
34
35
  attachmentAccept: runtime?.attachmentAccept ?? "",
35
36
  dictation: runtime?.dictation,
36
37
  quote: runtime?.quote,
38
+ queue: runtime?.queue ?? EMPTY_ARRAY,
37
39
  parentId: runtime?.parentId ?? null,
38
40
  sourceId: runtime?.sourceId ?? null,
39
41
  value: runtime?.text ?? ""
@@ -57,6 +59,8 @@ var ComposerRuntimeImpl = class {
57
59
  this.clearAttachments = this.clearAttachments.bind(this);
58
60
  this.send = this.send.bind(this);
59
61
  this.cancel = this.cancel.bind(this);
62
+ this.steerQueueItem = this.steerQueueItem.bind(this);
63
+ this.removeQueueItem = this.removeQueueItem.bind(this);
60
64
  this.setRole = this.setRole.bind(this);
61
65
  this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);
62
66
  this.startDictation = this.startDictation.bind(this);
@@ -99,6 +103,16 @@ var ComposerRuntimeImpl = class {
99
103
  if (!core) throw new Error("Composer is not available");
100
104
  core.cancel();
101
105
  }
106
+ steerQueueItem(queueItemId) {
107
+ const core = this._core.getState();
108
+ if (!core) throw new Error("Composer is not available");
109
+ core.steerQueueItem(queueItemId);
110
+ }
111
+ removeQueueItem(queueItemId) {
112
+ const core = this._core.getState();
113
+ if (!core) throw new Error("Composer is not available");
114
+ core.removeQueueItem(queueItemId);
115
+ }
102
116
  setRole(role) {
103
117
  const core = this._core.getState();
104
118
  if (!core) throw new Error("Composer is not available");