@assistant-ui/core 0.2.21 → 0.2.23

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 (345) hide show
  1. package/dist/adapters/attachment.d.ts.map +1 -1
  2. package/dist/adapters/speech.d.ts.map +1 -1
  3. package/dist/adapters/speech.js +9 -2
  4. package/dist/adapters/speech.js.map +1 -1
  5. package/dist/adapters/thread-history.d.ts +8 -0
  6. package/dist/adapters/thread-history.d.ts.map +1 -1
  7. package/dist/adapters/voice.d.ts.map +1 -1
  8. package/dist/adapters/voice.js +13 -5
  9. package/dist/adapters/voice.js.map +1 -1
  10. package/dist/internal.d.ts +5 -2
  11. package/dist/internal.js +5 -2
  12. package/dist/model-context/frame/host.d.ts +1 -0
  13. package/dist/model-context/frame/host.d.ts.map +1 -1
  14. package/dist/model-context/frame/host.js +41 -21
  15. package/dist/model-context/frame/host.js.map +1 -1
  16. package/dist/model-context/frame/provider.d.ts.map +1 -1
  17. package/dist/model-context/frame/provider.js +1 -0
  18. package/dist/model-context/frame/provider.js.map +1 -1
  19. package/dist/model-context/interactable-composer-metadata.js.map +1 -1
  20. package/dist/model-context/types.d.ts.map +1 -1
  21. package/dist/model-context/types.js +13 -4
  22. package/dist/model-context/types.js.map +1 -1
  23. package/dist/react/AssistantProvider.js.map +1 -1
  24. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  25. package/dist/react/adapters/LocalStorageThreadListAdapter.js +78 -50
  26. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  27. package/dist/react/client/Interactables.js.map +1 -1
  28. package/dist/react/client/Tools.d.ts.map +1 -1
  29. package/dist/react/client/interactable-model-context.d.ts.map +1 -1
  30. package/dist/react/client/interactable-model-context.js +1 -0
  31. package/dist/react/client/interactable-model-context.js.map +1 -1
  32. package/dist/react/interactables-legacy/useInteractableState.js +1 -0
  33. package/dist/react/interactables-legacy/useInteractableState.js.map +1 -1
  34. package/dist/react/model-context/useInteractable.js.map +1 -1
  35. package/dist/react/model-context/useInteractableState.js +1 -0
  36. package/dist/react/model-context/useInteractableState.js.map +1 -1
  37. package/dist/react/model-context/useInteractableVersions.js +1 -0
  38. package/dist/react/model-context/useInteractableVersions.js.map +1 -1
  39. package/dist/react/model-context/useToolArgsStatus.js +1 -0
  40. package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
  41. package/dist/react/primitive-hooks/useActionBarCopy.js +14 -13
  42. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  43. package/dist/react/primitive-hooks/useActionBarEdit.js +1 -0
  44. package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
  45. package/dist/react/primitive-hooks/useActionBarFeedback.js +1 -0
  46. package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
  47. package/dist/react/primitive-hooks/useActionBarReload.js +1 -0
  48. package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
  49. package/dist/react/primitive-hooks/useActionBarSpeak.js +1 -0
  50. package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
  51. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +1 -0
  52. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
  53. package/dist/react/primitive-hooks/useBranchPickerNext.js +1 -0
  54. package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
  55. package/dist/react/primitive-hooks/useBranchPickerPrevious.js +1 -0
  56. package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
  57. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
  58. package/dist/react/primitive-hooks/useComposerAddAttachment.js +1 -0
  59. package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
  60. package/dist/react/primitive-hooks/useComposerCancel.js +1 -0
  61. package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
  62. package/dist/react/primitive-hooks/useComposerDictate.js +1 -0
  63. package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
  64. package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
  65. package/dist/react/primitive-hooks/useComposerSend.js +1 -0
  66. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  67. package/dist/react/primitive-hooks/useEditComposerCancel.js +1 -0
  68. package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
  69. package/dist/react/primitive-hooks/useEditComposerSend.js +1 -0
  70. package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
  71. package/dist/react/primitive-hooks/useMessageBranching.js +1 -0
  72. package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
  73. package/dist/react/primitive-hooks/useMessageReload.js +1 -0
  74. package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
  75. package/dist/react/primitive-hooks/useSuggestionTrigger.js +1 -0
  76. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  77. package/dist/react/primitive-hooks/useThreadListItemArchive.js +1 -0
  78. package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
  79. package/dist/react/primitive-hooks/useThreadListItemDelete.js +1 -0
  80. package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
  81. package/dist/react/primitive-hooks/useThreadListItemTrigger.js +1 -0
  82. package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
  83. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +1 -0
  84. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
  85. package/dist/react/primitive-hooks/useThreadListLoadMore.js +1 -0
  86. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
  87. package/dist/react/primitive-hooks/useThreadListNew.js +1 -0
  88. package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
  89. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
  90. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
  91. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
  92. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
  93. package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
  94. package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
  95. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
  96. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  97. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  98. package/dist/react/primitives/message/MessageParts.d.ts +2 -1
  99. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  100. package/dist/react/primitives/message/MessageParts.js +46 -36
  101. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  102. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  103. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  104. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  105. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
  106. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
  107. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +18 -30
  108. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  109. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
  110. package/dist/react/providers/PartByIndexProvider.js +18 -30
  111. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  112. package/dist/react/providers/TextMessagePartProvider.js +1 -0
  113. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  114. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  115. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +1 -0
  116. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  117. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +9 -2
  118. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  119. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +55 -12
  120. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  121. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +31 -1
  122. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  123. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +12 -2
  124. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  125. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -1
  126. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
  127. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +3 -2
  128. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  129. package/dist/react/runtimes/cloud/auiV0.d.ts +12 -1
  130. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  131. package/dist/react/runtimes/cloud/auiV0.js +2 -1
  132. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  133. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +75 -73
  134. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  135. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  136. package/dist/react/runtimes/external-message-converter.js +2 -2
  137. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  138. package/dist/react/runtimes/useExternalStoreSharedOptions.js +1 -0
  139. package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
  140. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  141. package/dist/react/runtimes/useLocalRuntime.js +9 -1
  142. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  143. package/dist/runtime/api/assistant-runtime.d.ts +1 -1
  144. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  145. package/dist/runtime/api/assistant-runtime.js +1 -1
  146. package/dist/runtime/api/assistant-runtime.js.map +1 -1
  147. package/dist/runtime/api/attachment-runtime.d.ts +1 -1
  148. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  149. package/dist/runtime/api/attachment-runtime.js +1 -1
  150. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  151. package/dist/runtime/api/composer-runtime.d.ts +2 -2
  152. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  153. package/dist/runtime/api/composer-runtime.js +2 -2
  154. package/dist/runtime/api/composer-runtime.js.map +1 -1
  155. package/dist/runtime/api/message-part-runtime.d.ts +4 -4
  156. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  157. package/dist/runtime/api/message-part-runtime.js +3 -3
  158. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  159. package/dist/runtime/api/message-runtime.d.ts +1 -1
  160. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  161. package/dist/runtime/api/message-runtime.js +6 -6
  162. package/dist/runtime/api/message-runtime.js.map +1 -1
  163. package/dist/runtime/api/thread-list-item-runtime.d.ts +1 -1
  164. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  165. package/dist/runtime/api/thread-list-item-runtime.js +4 -3
  166. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  167. package/dist/runtime/api/thread-list-runtime.d.ts +1 -1
  168. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  169. package/dist/runtime/api/thread-list-runtime.js +1 -1
  170. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  171. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  172. package/dist/runtime/base/base-composer-runtime-core.d.ts +4 -1
  173. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  174. package/dist/runtime/base/base-composer-runtime-core.js +41 -14
  175. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  176. package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -1
  177. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  178. package/dist/runtime/base/base-thread-runtime-core.js +3 -2
  179. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  180. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +2 -2
  181. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  182. package/dist/runtime/base/default-edit-composer-runtime-core.js +6 -4
  183. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  184. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -1
  185. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  186. package/dist/runtime/base/default-thread-composer-runtime-core.js +3 -3
  187. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  188. package/dist/runtime/utils/message-repository.d.ts.map +1 -1
  189. package/dist/runtime/utils/message-repository.js +4 -2
  190. package/dist/runtime/utils/message-repository.js.map +1 -1
  191. package/dist/runtime/utils/thread-message-like.js +4 -1
  192. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  193. package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
  194. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -1
  195. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  196. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +1 -1
  197. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  198. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  199. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +12 -0
  200. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  201. package/dist/runtimes/internal.d.ts +2 -1
  202. package/dist/runtimes/internal.js +2 -1
  203. package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
  204. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
  205. package/dist/runtimes/local/local-thread-runtime-core.d.ts +3 -0
  206. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  207. package/dist/runtimes/local/local-thread-runtime-core.js +49 -15
  208. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  209. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  210. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +4 -4
  211. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
  212. package/dist/runtimes/remote-thread-list/optimistic-state.js +22 -9
  213. package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
  214. package/dist/runtimes/remote-thread-list/types.d.ts +1 -1
  215. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +32 -27
  216. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
  217. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +3 -2
  218. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  219. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  220. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  221. package/dist/store/clients/no-op-composer-client.js +1 -0
  222. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  223. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  224. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  225. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  226. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  227. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  228. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  229. package/dist/store/runtime-clients/thread-list-runtime-client.js +1 -0
  230. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  231. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  232. package/dist/store/runtime-clients/thread-runtime-client.js +17 -15
  233. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  234. package/dist/store/scopes/thread.d.ts +1 -0
  235. package/dist/store/scopes/thread.d.ts.map +1 -1
  236. package/dist/subscribable/subscribable.d.ts +4 -4
  237. package/dist/subscribable/subscribable.d.ts.map +1 -1
  238. package/dist/subscribable/subscribable.js +14 -6
  239. package/dist/subscribable/subscribable.js.map +1 -1
  240. package/dist/tests/remote-thread-list-test-helpers.d.ts +2 -1
  241. package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
  242. package/dist/tests/remote-thread-list-test-helpers.js +5 -2
  243. package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
  244. package/dist/types/attachment.d.ts +2 -1
  245. package/dist/types/attachment.d.ts.map +1 -1
  246. package/dist/types/attachment.js +6 -0
  247. package/dist/types/attachment.js.map +1 -0
  248. package/dist/types/message.d.ts +1 -0
  249. package/dist/types/message.d.ts.map +1 -1
  250. package/dist/types/message.js.map +1 -1
  251. package/dist/utils/data-url.d.ts +9 -0
  252. package/dist/utils/data-url.d.ts.map +1 -0
  253. package/dist/utils/data-url.js +14 -0
  254. package/dist/utils/data-url.js.map +1 -0
  255. package/dist/utils/notify-event-listeners.d.ts +6 -0
  256. package/dist/utils/notify-event-listeners.d.ts.map +1 -0
  257. package/dist/utils/notify-event-listeners.js +16 -0
  258. package/dist/utils/notify-event-listeners.js.map +1 -0
  259. package/package.json +10 -9
  260. package/src/adapters/speech.test.ts +88 -0
  261. package/src/adapters/speech.ts +17 -2
  262. package/src/adapters/thread-history.ts +8 -0
  263. package/src/adapters/voice.test.ts +130 -0
  264. package/src/adapters/voice.ts +26 -6
  265. package/src/internal.ts +6 -1
  266. package/src/model-context/frame/host.test.ts +147 -0
  267. package/src/model-context/frame/host.ts +56 -19
  268. package/src/model-context/frame/provider.test.ts +83 -0
  269. package/src/model-context/frame/provider.ts +1 -0
  270. package/src/model-context/types.ts +16 -6
  271. package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +82 -0
  272. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +108 -58
  273. package/src/react/primitive-hooks/useActionBarCopy.test.ts +79 -0
  274. package/src/react/primitive-hooks/useActionBarCopy.ts +4 -3
  275. package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -3
  276. package/src/react/primitives/message/MessageParts.tsx +48 -35
  277. package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +19 -2
  278. package/src/react/providers/PartByIndexProvider.tsx +16 -2
  279. package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +18 -0
  280. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +1 -0
  281. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +68 -13
  282. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +34 -0
  283. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +69 -0
  284. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +27 -6
  285. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +16 -0
  286. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +7 -2
  287. package/src/react/runtimes/cloud/auiV0.ts +14 -0
  288. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +90 -88
  289. package/src/react/runtimes/external-message-converter.test.ts +346 -0
  290. package/src/react/runtimes/external-message-converter.test.tsx +21 -0
  291. package/src/react/runtimes/external-message-converter.ts +2 -2
  292. package/src/react/runtimes/useLocalRuntime.test.tsx +99 -0
  293. package/src/react/runtimes/useLocalRuntime.ts +13 -1
  294. package/src/runtime/api/assistant-runtime.ts +4 -1
  295. package/src/runtime/api/attachment-runtime.ts +8 -2
  296. package/src/runtime/api/composer-runtime.ts +9 -5
  297. package/src/runtime/api/message-part-runtime.ts +10 -3
  298. package/src/runtime/api/message-runtime.test.ts +81 -0
  299. package/src/runtime/api/message-runtime.ts +11 -8
  300. package/src/runtime/api/thread-list-item-runtime.ts +13 -3
  301. package/src/runtime/api/thread-list-runtime.ts +10 -2
  302. package/src/runtime/base/base-composer-runtime-core.ts +77 -31
  303. package/src/runtime/base/base-thread-runtime-core.ts +7 -2
  304. package/src/runtime/base/default-edit-composer-runtime-core.ts +18 -4
  305. package/src/runtime/base/default-thread-composer-runtime-core.ts +13 -3
  306. package/src/runtime/utils/message-repository.ts +19 -13
  307. package/src/runtime/utils/thread-message-like.ts +1 -0
  308. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +4 -1
  309. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +15 -0
  310. package/src/runtimes/internal.ts +3 -0
  311. package/src/runtimes/local/local-thread-runtime-core.test.ts +746 -1
  312. package/src/runtimes/local/local-thread-runtime-core.ts +89 -23
  313. package/src/runtimes/local/should-continue.test.ts +122 -0
  314. package/src/runtimes/remote-thread-list/optimistic-state.test.ts +63 -0
  315. package/src/runtimes/remote-thread-list/optimistic-state.ts +49 -17
  316. package/src/runtimes/remote-thread-list/types.ts +1 -1
  317. package/src/runtimes/tool-invocations/EDGE_CASES.md +13 -19
  318. package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +128 -8
  319. package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +42 -34
  320. package/src/store/clients/model-context-client.test.ts +21 -1
  321. package/src/store/runtime-clients/thread-runtime-client.ts +2 -1
  322. package/src/store/scopes/thread.ts +1 -0
  323. package/src/subscribable/subscribable.test.ts +58 -0
  324. package/src/subscribable/subscribable.ts +29 -11
  325. package/src/tests/MessageRepository.test.ts +12 -0
  326. package/src/tests/OptimisticState-list-race.test.ts +33 -0
  327. package/src/tests/RemoteThreadListThreadListRuntimeCore-switchToThread-order.test.ts +223 -0
  328. package/src/tests/RemoteThreadListThreadListRuntimeCore-switchToThread-position.test.ts +121 -0
  329. package/src/tests/auiV0Encode.test.ts +74 -0
  330. package/src/tests/base-composer-runtime-core-addAttachment.test.ts +44 -0
  331. package/src/tests/base-composer-runtime-core-send.test.ts +433 -5
  332. package/src/tests/base-composer-runtime-core.test.ts +422 -0
  333. package/src/tests/default-edit-composer-runtime-core.test.ts +43 -5
  334. package/src/tests/event-subscription-listener-errors.test.ts +205 -0
  335. package/src/tests/external-store-thread-list-runtime-core.test.ts +6 -6
  336. package/src/tests/external-store-thread-runtime-core-adapter.test.ts +575 -0
  337. package/src/tests/external-store-thread-runtime-core.test.ts +55 -1
  338. package/src/tests/remote-thread-list-test-helpers.ts +14 -7
  339. package/src/tests/thread-message-like.test.ts +57 -0
  340. package/src/types/attachment.ts +5 -0
  341. package/src/types/message.ts +1 -0
  342. package/src/utils/data-url.test.ts +50 -0
  343. package/src/utils/data-url.ts +9 -0
  344. package/src/utils/notify-event-listeners.ts +30 -0
  345. package/src/tests/OptimisticState-delete-crash.test.ts +0 -208
@@ -1 +1 @@
1
- {"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","COMPLETE_STATUS","Object","freeze","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","at","groupPart","key","nodeKey","map","child","s","message","toolUIs","tools","memoKey","memoDep","tree","toolCallId","displayName"],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupByContext,\n type GroupNode,\n} from \"../../utils/groupParts\";\nimport { MessagePartChildren, type EnrichedPartState } from \"./MessageParts\";\n\nexport namespace MessagePrimitiveGroupedParts {\n /**\n * A coalesced group of adjacent parts. Surfaced through the same\n * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers\n * dispatch on a single `switch (part.type)`. `type` is the group key\n * (always `\"group-…\"`); `status` mirrors the last contained part.\n */\n export type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {\n readonly type: TKey;\n readonly status: MessagePartStatus | ToolCallMessagePartStatus;\n readonly indices: readonly number[];\n };\n\n /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the message has no parts yet or the last\n * part isn't `text`/`reasoning` (e.g. it ended on a tool call, so the\n * assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\n\n export type RenderInfo<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Either a coalesced group ({@link GroupPart}, identified by a\n * `group-…` `type`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\n /**\n * For group nodes: the recursively-rendered subtree (subgroups +\n * leaf parts). For leaf parts: a sentinel that throws when rendered\n * — accidental fall-through (`default: return children;`) errors\n * loudly instead of silently rendering nothing.\n */\n readonly children: ReactNode;\n };\n\n export type Props<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Maps each part to a group-key path. Adjacent parts that share a\n * prefix coalesce into the same group. Return `[]` (or `null`) to\n * leave a part ungrouped.\n *\n * Group keys must start with `\"group-\"` so the renderer's\n * `switch (part.type)` can tell groups apart from real part types.\n *\n * **Prefer {@link groupPartByType}** for the common case of mapping by\n * `part.type` — it ships a stable memo fingerprint so the tree\n * survives unrelated re-renders. Use an inline function only when\n * the helper isn't expressive enough (e.g. branching on\n * `part.toolName` or part metadata).\n *\n * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\n *\n * @example\n * ```tsx\n * import { groupPartByType } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * ```\n */\n readonly groupBy: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\n *\n * Leaf parts receive the same {@link EnrichedPartState} that\n * `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,\n * `resume`, `respondToApproval`, `dataRendererUI`).\n */\n readonly children: (info: RenderInfo<TKey>) => ReactNode;\n };\n}\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\n\nconst shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last === undefined ||\n (last.type !== \"text\" && last.type !== \"reasoning\")\n );\n }\n }\n};\n\n/**\n * `children` placeholder passed for leaf-part renders. Leaf parts have no\n * inner subtree; rendering this sentinel signals the consumer wrote\n * `default: return children;` and accidentally fell through for a part —\n * surface the bug loudly instead of silently rendering nothing.\n */\nconst PartChildrenSentinel: FC = () => {\n throw new Error(\n \"MessagePrimitive.GroupedParts: rendered `children` under a leaf \" +\n \"part. `children` is only meaningful for `group-…` cases — add a \" +\n \"matching case for the part type or return `null` to skip it.\",\n );\n};\n\nconst renderNode = <TKey extends `group-${string}`>(\n node: GroupNode,\n parts: readonly PartState[],\n render: (info: MessagePrimitiveGroupedParts.RenderInfo<TKey>) => ReactNode,\n): ReactNode => {\n if (node.type === \"part\") {\n // Key by part identity when available, else absolute part index — never\n // the structural nodeKey, which leaves zombie fiber subscriptions when\n // parts reshape (#4051).\n return (\n <MessagePartChildren\n key={node.idKey ? `part-${node.idKey}` : `part-${node.index}`}\n index={node.index}\n >\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = parts[node.indices.at(-1)!]?.status ?? COMPLETE_STATUS;\n const groupPart: MessagePrimitiveGroupedParts.GroupPart<TKey> = {\n type: node.key as TKey,\n status,\n indices: node.indices,\n };\n\n return (\n <Fragment key={node.idKey ?? node.nodeKey}>\n {render({\n part: groupPart,\n children: (\n <>{node.children.map((child) => renderNode(child, parts, render))}</>\n ),\n })}\n </Fragment>\n );\n};\n\n/**\n * Groups adjacent message parts into a tree of coalesced runs and\n * renders each node — group or part — through a single `children`\n * function.\n *\n * The render function receives `{ part, children }` where `part.type`\n * is either a `\"group-…\"` literal (for a group, `children` is the\n * recursively-rendered subtree) or a real part type (`\"text\"`,\n * `\"tool-call\"`, …) for a leaf (`children` is a sentinel that throws\n * if rendered — use `part.type` to distinguish).\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 * })}\n * >\n * {({ part, children }) => {\n * switch (part.type) {\n * case \"group-thought\": return <Thought>{children}</Thought>;\n * case \"group-reasoning\": return <Reasoning>{children}</Reasoning>;\n * case \"group-tool\": return <ToolStack>{children}</ToolStack>;\n * case \"text\": return <MarkdownText />;\n * case \"tool-call\": return part.toolUI ?? <ToolFallback {...part} />;\n * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\n\n // Helpers like `groupPartByType` tag the function with `GROUPBY_MEMO_KEY`\n // (a stable string fingerprint of the helper config). When present,\n // memo on `[parts, memoKey]` so the tree survives unrelated renders.\n // For inline `groupBy`, fall back to recomputing each render — O(n)\n // and cheap.\n const memoKey = (groupBy as { [GROUPBY_MEMO_KEY]?: string })[\n GROUPBY_MEMO_KEY\n ];\n const memoDep = memoKey ?? groupBy;\n const tree = useMemo(() => {\n const context: GroupByContext = { toolUIs };\n return buildGroupTree(\n parts.map((part) => groupBy(part, context) ?? []),\n parts.map((part) =>\n part.type === \"tool-call\" ? part.toolCallId : undefined,\n ),\n );\n // oxlint-disable-next-line react/exhaustive-deps -- groupBy is captured via memoDep (either its identity or the helper's memoKey fingerprint); listing it directly would defeat the helper-tagged memo path\n }, [parts, memoDep, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;AAuIA,MAAM+B,kBAAqCC,OAAOC,OAAO,EAAEhB,MAAM,WAAW,CAAC;AAE7E,MAAMiB,uBACJC,MACAC,OACAC,cACY;CAGZ,IAAI,CAACA,WAAW,OAAO;CAEvB,QAAQF,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAOC,MAAME,WAAW;EAC1B,KAAK,WAAW;GACd,MAAMC,OAAOH,MAAMA,MAAME,SAAS;GAClC,OACEC,SAASC,KAAAA,KACRD,KAAKtB,SAAS,UAAUsB,KAAKtB,SAAS;EAE3C;CACF;AACF;;;;;;;AAQA,MAAMwB,6BAAiC;CACrC,MAAM,IAAIC,MACR,8LAGF;AACF;AAEA,MAAMC,cACJC,MACAR,OACAS,WACc;CACd,IAAID,KAAK3B,SAAS,QAIhB,OACE,oBAAC,qBAAD;EAEE,OAAO2B,KAAKG;aAEV,EAAEvB,WAAWqB,OAAO;GAAErB;GAAMC,UAAU,oBAAC,sBAAD,CAAqB,CAAA;EAAI,CAAC;CAC/C,GAJdmB,KAAKE,QAAQ,QAAQF,KAAKE,UAAU,QAAQF,KAAKG,OAInC;CAIzB,MAAM5B,SAASiB,MAAMQ,KAAKxB,QAAQ4B,GAAG,EAAE,EAAG,EAAE7B,UAAUY;CAOtD,OACE,oBAAC,UAAD,EAAA,UACGc,OAAO;EACNrB,MAAMyB;GARVhC,MAAM2B,KAAKM;GACX/B;GACAC,SAASwB,KAAKxB;EAMJ6B;EACNxB,UACE,oBAAA,YAAA,EAAA,UAAGmB,KAAKnB,SAAS2B,KAAKC,UAAUV,WAAWU,OAAOjB,OAAOS,MAAM,CAAC,EAAE,CAAA;CAEtE,CAAC,EACO,GAPKD,KAAKE,SAASF,KAAKO,OAOxB;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAapC,gCAAgE,EAC3EY,SACAE,YAAY,WACZJ,eACyD;CACzD,MAAMW,QAAQhC,YAAYC,YAAYiD,MAAMA,EAAEC,QAAQnB,KAAK,CAAC;CAE5D,MAAMoB,UAAUpD,aAAakD,QAAMA,IAAEG,MAAMD,OAAO;CAGlD,MAAMnB,YAAYjC,aAAakD,QAC7BzB,cAAc,UAAU,QAAQyB,IAAEC,QAAQpC,QAAQF,SAAS,SAC7D;CAsBA,OACE,qBAAA,YAAA,EAAA,UAAA,CAZWd,cAAc;EACzB,MAAMyB,UAA0B,EAAE4B,QAAQ;EAC1C,OAAO/C,eACL2B,MAAMgB,KAAK5B,SAASG,QAAQH,MAAMI,OAAO,KAAK,CAAA,CAAE,GAChDQ,MAAMgB,KAAK5B,WACTA,OAAKP,SAAS,cAAcO,OAAKqC,aAAarB,KAAAA,CAChD,CACF;CAEF,GAAG;EAACJ;EAbaT,QACfjB,qBAEyBiB;EAUP6B;CAAO,CAItBI,CAAI,CAACR,KAAKR,SAASD,WAAWC,MAAMR,OAAOX,QAAQ,CAAC,GACpDS,oBAAoBL,WAAWO,OAAOC,SAAS,KAC9CZ,SAAS;EACPD,MAAM,EAAEP,MAAM,YAAY;EAC1BQ,UAAU,oBAAC,sBAAD,CAAqB,CAAA;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B+C,cAAc"}
1
+ {"version":3,"file":"MessageGroupedParts.js","names":["Fragment","FC","ReactNode","useMemo","useAuiState","useShallow","PartState","MessagePartStatus","ToolCallMessagePartStatus","buildGroupTree","GROUPBY_MEMO_KEY","GroupByContext","GroupNode","MessagePartChildren","EnrichedPartState","MessagePrimitiveGroupedParts","GroupPart","type","TKey","status","indices","IndicatorPart","IndicatorMode","RenderInfo","part","children","Props","groupBy","context","indicator","info","COMPLETE_STATUS","Object","freeze","shouldShowIndicator","mode","parts","isRunning","length","last","undefined","PartChildrenSentinel","Error","renderNode","node","render","idKey","index","at","groupPart","key","nodeKey","map","child","s","message","toolUIs","tools","memoKey","memoDep","tree","toolCallId","displayName"],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupByContext,\n type GroupNode,\n} from \"../../utils/groupParts\";\nimport { MessagePartChildren, type EnrichedPartState } from \"./MessageParts\";\n\nexport namespace MessagePrimitiveGroupedParts {\n /**\n * A coalesced group of adjacent parts. Surfaced through the same\n * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers\n * dispatch on a single `switch (part.type)`. `type` is the group key\n * (always `\"group-…\"`); `status` mirrors the last contained part.\n */\n export type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {\n readonly type: TKey;\n readonly status: MessagePartStatus | ToolCallMessagePartStatus;\n readonly indices: readonly number[];\n };\n\n /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the message has no parts yet or the last\n * part isn't `text`/`reasoning` (e.g. it ended on a tool call, so the\n * assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\n\n export type RenderInfo<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Either a coalesced group ({@link GroupPart}, identified by a\n * `group-…` `type`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\n /**\n * For group nodes: the recursively-rendered subtree (subgroups +\n * leaf parts). For leaf parts: a sentinel that throws when rendered\n * — accidental fall-through (`default: return children;`) errors\n * loudly instead of silently rendering nothing.\n */\n readonly children: ReactNode;\n };\n\n export type Props<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Maps each part to a group-key path. Adjacent parts that share a\n * prefix coalesce into the same group. Return `[]` (or `null`) to\n * leave a part ungrouped.\n *\n * Group keys must start with `\"group-\"` so the renderer's\n * `switch (part.type)` can tell groups apart from real part types.\n *\n * **Prefer {@link groupPartByType}** for the common case of mapping by\n * `part.type` — it ships a stable memo fingerprint so the tree\n * survives unrelated re-renders. Use an inline function only when\n * the helper isn't expressive enough (e.g. branching on\n * `part.toolName` or part metadata).\n *\n * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\n *\n * @example\n * ```tsx\n * import { groupPartByType } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * ```\n */\n readonly groupBy: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\n *\n * Leaf parts receive the same {@link EnrichedPartState} that\n * `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,\n * `resume`, `respondToApproval`, `dataRendererUI`).\n */\n readonly children: (info: RenderInfo<TKey>) => ReactNode;\n };\n}\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\n\nconst shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last === undefined ||\n (last.type !== \"text\" && last.type !== \"reasoning\")\n );\n }\n }\n};\n\n/**\n * `children` placeholder passed for leaf-part renders. Leaf parts have no\n * inner subtree; rendering this sentinel signals the consumer wrote\n * `default: return children;` and accidentally fell through for a part —\n * surface the bug loudly instead of silently rendering nothing.\n */\nconst PartChildrenSentinel: FC = () => {\n throw new Error(\n \"MessagePrimitive.GroupedParts: rendered `children` under a leaf \" +\n \"part. `children` is only meaningful for `group-…` cases — add a \" +\n \"matching case for the part type or return `null` to skip it.\",\n );\n};\n\nconst renderNode = <TKey extends `group-${string}`>(\n node: GroupNode,\n parts: readonly PartState[],\n render: (info: MessagePrimitiveGroupedParts.RenderInfo<TKey>) => ReactNode,\n): ReactNode => {\n if (node.type === \"part\") {\n // Key by part identity when available, else absolute part index — never\n // the structural nodeKey, which leaves zombie fiber subscriptions when\n // parts reshape (#4051).\n return (\n <MessagePartChildren\n key={node.idKey ? `part-${node.idKey}` : `part-${node.index}`}\n index={node.index}\n >\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = parts[node.indices.at(-1)!]?.status ?? COMPLETE_STATUS;\n const groupPart: MessagePrimitiveGroupedParts.GroupPart<TKey> = {\n type: node.key as TKey,\n status,\n indices: node.indices,\n };\n\n return (\n <Fragment key={node.idKey ?? node.nodeKey}>\n {render({\n part: groupPart,\n children: (\n <>{node.children.map((child) => renderNode(child, parts, render))}</>\n ),\n })}\n </Fragment>\n );\n};\n\n/**\n * Groups adjacent message parts into a tree of coalesced runs and\n * renders each node — group or part — through a single `children`\n * function.\n *\n * The render function receives `{ part, children }` where `part.type`\n * is either a `\"group-…\"` literal (for a group, `children` is the\n * recursively-rendered subtree) or a real part type (`\"text\"`,\n * `\"tool-call\"`, …) for a leaf (`children` is a sentinel that throws\n * if rendered — use `part.type` to distinguish).\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 * })}\n * >\n * {({ part, children }) => {\n * switch (part.type) {\n * case \"group-thought\": return <Thought>{children}</Thought>;\n * case \"group-reasoning\": return <Reasoning>{children}</Reasoning>;\n * case \"group-tool\": return <ToolStack>{children}</ToolStack>;\n * case \"text\": return <MarkdownText />;\n * case \"tool-call\": return part.toolUI ?? <ToolFallback {...part} />;\n * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\n\n // Helpers like `groupPartByType` tag the function with `GROUPBY_MEMO_KEY`\n // (a stable string fingerprint of the helper config). When present,\n // memo on `[parts, memoKey]` so the tree survives unrelated renders.\n // For inline `groupBy`, fall back to recomputing each render — O(n)\n // and cheap.\n const memoKey = (groupBy as { [GROUPBY_MEMO_KEY]?: string })[\n GROUPBY_MEMO_KEY\n ];\n const memoDep = memoKey ?? groupBy;\n const tree = useMemo(() => {\n const context: GroupByContext = { toolUIs };\n return buildGroupTree(\n parts.map((part) => groupBy(part, context) ?? []),\n parts.map((part) =>\n part.type === \"tool-call\" ? part.toolCallId : undefined,\n ),\n );\n // oxlint-disable-next-line react/exhaustive-deps -- groupBy is captured via memoDep (either its identity or the helper's memoKey fingerprint); listing it directly would defeat the helper-tagged memo path\n }, [parts, memoDep, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;AAuIA,MAAM+B,kBAAqCC,OAAOC,OAAO,EAAEhB,MAAM,WAAW,CAAC;AAE7E,MAAMiB,uBACJC,MACAC,OACAC,cACY;CAGZ,IAAI,CAACA,WAAW,OAAO;CAEvB,QAAQF,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAOC,MAAME,WAAW;EAC1B,KAAK,WAAW;GACd,MAAMC,OAAOH,MAAMA,MAAME,SAAS;GAClC,OACEC,SAASC,KAAAA,K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,SAASG,QAAQH,MAAMI,OAAO,KAAK,CAAA,CAAE,GAChDQ,MAAMgB,KAAK5B,WACTA,OAAKP,SAAS,cAAcO,OAAKqC,aAAarB,KAAAA,CAChD,CACF;CAEF,GAAG;EAACJ;EAbaT,QACfjB,qBAEyBiB;EAUP6B;CAAO,CAItBI,CAAI,CAACR,KAAKR,SAASD,WAAWC,MAAMR,OAAOX,QAAQ,CAAC,GACpDS,oBAAoBL,WAAWO,OAAOC,SAAS,KAC9CZ,SAAS;EACPD,MAAM,EAAEP,MAAM,YAAY;EAC1BQ,UAAU,oBAAC,sBAAD,CAAqB,CAAA;CACjC,CAAC,CACL,EAAA,CAAA;AAEJ;AAEAV,6BAA6B+C,cAAc"}
@@ -224,6 +224,7 @@ type EnrichedPartState = (Extract<PartState, {
224
224
  } | {
225
225
  type: "data";
226
226
  }>;
227
+ declare const MessagePartChildren: FC<MessagePartChildrenProps>;
227
228
  /**
228
229
  * Renders the parts of a message with support for multiple content types.
229
230
  *
@@ -232,5 +233,5 @@ type EnrichedPartState = (Extract<PartState, {
232
233
  */
233
234
  declare const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props>;
234
235
  //#endregion
235
- export { EnrichedPartState, MessagePartComponent, MessagePrimitivePartByIndex, MessagePrimitiveParts, type PartState, defaultComponents, groupMessageParts };
236
+ export { EnrichedPartState, MessagePartChildren, MessagePartComponent, MessagePrimitivePartByIndex, MessagePrimitiveParts, type PartState, defaultComponents, groupMessageParts };
236
237
  //# sourceMappingURL=MessageParts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MessageParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"mappings":";;;;KA4CK;EACC;EAAgB;;EAEhB;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;EAGA;EACA;EACA;EACA;;;;;;;;;cAiDO,oBACX,iCACA,4BACA,8CACC;kBAkFc;OACV;;IAEH,UAAU,eAAe;;IAEzB,WAAW;;OAGR;;IAEH,QA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OAAO;;IAEP,iBAAiB;;IAEjB,OAAO;;IAEP,QAAQ;;;;;;;;;IASR;;MAGM,YAAY;;MAEZ,WACI;QAAgB;QAAmB;;;;OAM1C;;IAGC,UACI,eAAe;;IAGnB,WAAW,cAAc;;;IAIzB,UAAU,cAAc;;;;;;;;OASzB,qBAAqB;;IAExB,YAAY;;IAEZ,QAAQ;;;;;;;;;;IAWR,YAAY,cACV;MAAoB;MAAoB;;;;;;;;;;;IAY1C,iBAAiB;IAEjB;;;;;;;;;OAUG,2BAA2B;;;;;;IAM9B,gBAAgB;IAEhB;IACA;IACA;IACA;;cAGU;;;;;;;;IASN,aAAa,qBAAqB;;;;;;;;IAQlC;IACA;;;IAIA,WAAW;MAAS,MAAM;UAAwB;IAClD;IACA;;;;;;;;cA4CK;;;;;;;EAOe,cAAA,YAAA,sBAAiB;EACZ,mBAAA,YAAA,sBAAiB;;KAG7C;EACH,YAAY,sBAAsB;;cAGvB,sBAAsB,GAAG;kBAkGrB;OACH;IACV;IACA,YAAY,sBAAsB;;;;;;cAOzB,6BAA6B,GAAG,4BAA4B;;;;;;;;;;;;;KA+L7D,qBACP,QAAQ;EAAa;;;WAEX,QAAQ;;EAEjB,WAAW;;EAEX,QAAQ;;EAER,mBAAmB;MAEpB,QAAQ;EAAa;;;WAEX,gBAAgB;KAE3B,QAAQ;EAAa;;EAAwB;;cAmEpC,qBAAqB,GAAG;;;;;;;cA8CxB,uBAAuB,GAAG,sBAAsB"}
@@ -649,46 +649,56 @@ const EMPTY_RUNNING_TEXT_PART = Object.freeze({
649
649
  text: "",
650
650
  status: RUNNING_STATUS
651
651
  });
652
- /**
653
- * @internal
654
- * Renders a single part by index, calling `children` with the
655
- * {@link EnrichedPartState} (tool/data UI enrichments + addResult/resume
656
- * for tool calls). Shared between `<MessagePrimitive.Parts>` and
657
- * `<MessagePrimitive.GroupedParts>`. Returns whatever `children`
658
- * returns — callers decide how to handle a `null` return.
659
- */
660
- const MessagePartChildren = ({ index, children }) => {
652
+ const MessagePartChildrenInner = ({ children }) => {
661
653
  const aui = useAui();
662
654
  const dataRenderers = useAuiState((s) => s.dataRenderers);
663
- return /* @__PURE__ */ jsx(PartByIndexProvider, {
664
- index,
665
- children: /* @__PURE__ */ jsx(RenderChildrenWithAccessor, {
666
- getItemState: (aui_0) => aui_0.message().part({ index }).getState(),
667
- children: (getItem) => children({ get part() {
668
- const state = getItem();
669
- if (state.type === "tool-call") {
670
- const hasUI = resolveToolRender(aui.tools().getState(), state) !== null;
671
- const partMethods = aui.message().part({ index });
672
- return {
673
- ...state,
674
- toolUI: hasUI ? /* @__PURE__ */ jsx(RegisteredToolUI, {}) : null,
675
- addResult: partMethods.addToolResult,
676
- resume: partMethods.resumeToolCall,
677
- respondToApproval: partMethods.respondToToolApproval
678
- };
679
- }
680
- if (state.type === "data") {
681
- const hasUI = getDataRenderer(dataRenderers, state.name, void 0) !== void 0;
682
- return {
683
- ...state,
684
- dataRendererUI: hasUI ? /* @__PURE__ */ jsx(RegisteredDataRendererUI, {}) : null
685
- };
686
- }
687
- return state;
688
- } })
689
- })
655
+ return /* @__PURE__ */ jsx(RenderChildrenWithAccessor, {
656
+ getItemState: (client) => client.part().getState(),
657
+ children: (getItem) => children({ get part() {
658
+ const state = getItem();
659
+ if (state.type === "tool-call") {
660
+ const hasUI = resolveToolRender(aui.tools().getState(), state) !== null;
661
+ const partMethods = aui.part();
662
+ return {
663
+ ...state,
664
+ toolUI: hasUI ? /* @__PURE__ */ jsx(RegisteredToolUI, {}) : null,
665
+ addResult: partMethods.addToolResult,
666
+ resume: partMethods.resumeToolCall,
667
+ respondToApproval: partMethods.respondToToolApproval
668
+ };
669
+ }
670
+ if (state.type === "data") {
671
+ const hasUI = getDataRenderer(dataRenderers, state.name, void 0) !== void 0;
672
+ return {
673
+ ...state,
674
+ dataRendererUI: hasUI ? /* @__PURE__ */ jsx(RegisteredDataRendererUI, {}) : null
675
+ };
676
+ }
677
+ return state;
678
+ } })
690
679
  });
691
680
  };
681
+ const MessagePartChildren = (t0) => {
682
+ const $ = c(5);
683
+ const { index, children } = t0;
684
+ let t1;
685
+ if ($[0] !== children) {
686
+ t1 = /* @__PURE__ */ jsx(MessagePartChildrenInner, { children });
687
+ $[0] = children;
688
+ $[1] = t1;
689
+ } else t1 = $[1];
690
+ let t2;
691
+ if ($[2] !== index || $[3] !== t1) {
692
+ t2 = /* @__PURE__ */ jsx(PartByIndexProvider, {
693
+ index,
694
+ children: t1
695
+ });
696
+ $[2] = index;
697
+ $[3] = t1;
698
+ $[4] = t2;
699
+ } else t2 = $[4];
700
+ return t2;
701
+ };
692
702
  const MessagePrimitivePartsInner = (t0) => {
693
703
  const $ = c(9);
694
704
  const { children } = t0;
@@ -1 +1 @@
1
- {"version":3,"file":"MessageParts.js","names":["ComponentType","FC","ReactNode","memo","PropsWithChildren","useMemo","RenderChildrenWithAccessor","useAuiState","useAui","PartState","PartByIndexProvider","TextMessagePartProvider","ChainOfThoughtByIndicesProvider","getMessageQuote","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","ReasoningGroupComponent","QuoteMessagePartComponent","GenerativeUIComponentRegistry","GenerativeUIRender","isMcpAppUri","MessagePartStatus","GenerativeUIMessagePart","DataRenderersState","ToolsState","useShallow","MessagePartRange","type","index","startIndex","endIndex","idKey","createGroupState","groupType","T","start","startGroup","endGroup","ranges","push","finalize","groupMessageParts","messageTypes","useChainOfThought","partIds","chainOfThoughtGroup","i","length","toolGroup","reasoningGroup","claimed","Set","range","id","undefined","has","add","useMessagePartsGroups","$","_c","_temp2","_temp4","t0","bb0","t1","Symbol","for","t2","MessagePrimitiveParts","DataConfig","by_name","Record","Fallback","BaseComponents","Empty","Text","Source","Image","File","Unstable_Audio","data","Quote","generativeUI","components","component","props","ToolsConfig","Override","StandardComponents","Reasoning","tools","ToolGroup","ReasoningGroup","ChainOfThought","ChainOfThoughtComponents","Props","unstable_showEmptyOnNonTextEnd","children","value","part","EnrichedPartState","ToolUIDisplay","toolName","s","toolUIs","render","Render","getDataRenderer","dataRenderers","name","inlineFallback","named","renderers","fallbacks","DataUIDisplay","defaultComponents","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp5","t11","addResult","addToolResult","t12","resume","resumeToolCall","t13","respondToApproval","respondToToolApproval","t14","Tool","status","Error","Data","process","env","NODE_ENV","console","warn","spec","MessagePrimitivePartByIndex","prev","next","displayName","EmptyPartFallback","Component","COMPLETE_STATUS","Object","freeze","RUNNING_STATUS","EmptyPartsImpl","_temp6","EmptyParts","ConditionalEmptyImpl","enabled","message","parts","lastPart","shouldShowEmpty","ConditionalEmpty","QuoteRendererImpl","quoteInfo","messageId","text","QuoteRenderer","resolveToolRender","toolsState","Extract","mcp","app","resourceUri","mcpApp","RegisteredToolUI","_temp7","_temp8","RegisteredDataRendererUI","_temp9","_temp0","DefaultPartFallback","partType","_temp1","toolUI","dataRendererUI","Exclude","EMPTY_RUNNING_TEXT_PART","MessagePartChildren","getState","getItem","state","hasUI","partMethods","MessagePrimitivePartsInner","contentLength","_temp10","isRunning","_temp11","isEmptyRunning","_","Array","from","MessagePrimitivePartsCompat","_temp12","messageRanges","toolLeafKey","partIndex","map","ChainOfThoughtComponent","ToolGroupComponent","partIndex_0","__0","i_0","partIndex_1","partsElements","_temp","c","_temp3","c_0","toolCallId","s_0"],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport {\n RenderChildrenWithAccessor,\n useAuiState,\n useAui,\n} from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { PartByIndexProvider } from \"../../providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../providers/TextMessagePartProvider\";\nimport { ChainOfThoughtByIndicesProvider } from \"../../providers/ChainOfThoughtByIndicesProvider\";\nimport { getMessageQuote } from \"../../utils/getMessageQuote\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n ReasoningGroupComponent,\n QuoteMessagePartComponent,\n GenerativeUIComponentRegistry,\n} from \"../../types/MessagePartComponentTypes\";\nimport { GenerativeUIRender } from \"../generativeUI/GenerativeUI\";\nimport {\n isMcpAppUri,\n type MessagePartStatus,\n type GenerativeUIMessagePart,\n} from \"../../../types/message\";\nimport type { DataRenderersState } from \"../../types/scopes/dataRenderers\";\nimport type { ToolsState } from \"../../types/scopes/tools\";\nimport { useShallow } from \"zustand/shallow\";\n\ntype MessagePartRange =\n | { type: \"single\"; index: number }\n | {\n type: \"toolGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"reasoningGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"chainOfThoughtGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n };\n\n/**\n * Creates a group state manager for a specific part type.\n * Returns functions to start, end, and finalize groups.\n */\nconst createGroupState = <\n T extends \"toolGroup\" | \"reasoningGroup\" | \"chainOfThoughtGroup\",\n>(\n groupType: T,\n) => {\n let start = -1;\n\n return {\n startGroup: (index: number) => {\n if (start === -1) {\n start = index;\n }\n },\n endGroup: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n start = -1;\n }\n },\n finalize: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n }\n },\n };\n};\n\n/**\n * Groups consecutive tool-call and reasoning message parts into ranges.\n * Always groups tool calls and reasoning parts, even if there's only one.\n * When useChainOfThought is true, groups tool-call and reasoning parts together.\n * `partIds[i]` optionally carries a stable identity for part `i`; group\n * ranges derive an `idKey` from their first part's id (first claim wins).\n */\nexport const groupMessageParts = (\n messageTypes: readonly string[],\n useChainOfThought: boolean,\n partIds?: readonly (string | undefined)[],\n): MessagePartRange[] => {\n const ranges: MessagePartRange[] = [];\n\n if (useChainOfThought) {\n const chainOfThoughtGroup = createGroupState(\"chainOfThoughtGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\" || type === \"reasoning\") {\n chainOfThoughtGroup.startGroup(i);\n } else {\n chainOfThoughtGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n chainOfThoughtGroup.finalize(messageTypes.length - 1, ranges);\n } else {\n const toolGroup = createGroupState(\"toolGroup\");\n const reasoningGroup = createGroupState(\"reasoningGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\") {\n reasoningGroup.endGroup(i - 1, ranges);\n toolGroup.startGroup(i);\n } else if (type === \"reasoning\") {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.startGroup(i);\n } else {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n toolGroup.finalize(messageTypes.length - 1, ranges);\n reasoningGroup.finalize(messageTypes.length - 1, ranges);\n }\n\n if (partIds) {\n const claimed = new Set<string>();\n for (const range of ranges) {\n if (range.type === \"single\") continue;\n const id = partIds[range.startIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n range.idKey = `id:${id}`;\n }\n }\n }\n\n return ranges;\n};\n\nconst useMessagePartsGroups = (\n useChainOfThought: boolean,\n): { ranges: MessagePartRange[]; partIds: (string | undefined)[] } => {\n const messageTypes = useAuiState(\n useShallow((s) => s.message.parts.map((c: any) => c.type)),\n );\n const partIds = useAuiState(\n useShallow((s) =>\n s.message.parts.map((c: any) =>\n c.type === \"tool-call\" ? c.toolCallId : undefined,\n ),\n ),\n );\n\n return useMemo(() => {\n if (messageTypes.length === 0) {\n return { ranges: [], partIds };\n }\n return {\n ranges: groupMessageParts(messageTypes, useChainOfThought, partIds),\n partIds,\n };\n }, [messageTypes, partIds, useChainOfThought]);\n};\n\nexport namespace MessagePrimitiveParts {\n type DataConfig = {\n /** Map data event names to specific components */\n by_name?: Record<string, DataMessagePartComponent | undefined> | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n };\n\n type BaseComponents = {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /** Component for rendering audio content (experimental) */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?: DataConfig | undefined;\n /** Component for rendering a quoted message reference (from metadata, not parts) */\n Quote?: QuoteMessagePartComponent | undefined;\n /**\n * Configuration for generative-ui part rendering.\n *\n * `components` is the consumer-provided allowlist of React components\n * the agent's JSON spec is permitted to render. Any name not present in\n * the registry is rejected with a typed `GenerativeUIRenderError` —\n * this is the security boundary in the same-realm rendering path.\n */\n generativeUI?:\n | {\n /** The component allowlist (the security boundary). */\n components: GenerativeUIComponentRegistry;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n }\n | undefined;\n };\n\n type ToolsConfig =\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n };\n\n /**\n * Standard component configuration for rendering reasoning and tool-call parts\n * individually (with optional grouping).\n *\n * Cannot be combined with `ChainOfThought`.\n */\n type StandardComponents = BaseComponents & {\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Configuration for tool call rendering */\n tools?: ToolsConfig | undefined;\n\n /**\n * Component for rendering grouped consecutive tool calls.\n *\n * @param startIndex - Index of the first tool call in the group\n * @param endIndex - Index of the last tool call in the group\n * @param children - Rendered tool call components to display within the group\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ToolGroup?: ComponentType<\n PropsWithChildren<{ startIndex: number; endIndex: number }>\n >;\n\n /**\n * Component for rendering grouped reasoning parts.\n *\n * @param startIndex - Index of the first reasoning part in the group\n * @param endIndex - Index of the last reasoning part in the group\n * @param children - Rendered reasoning part components\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ReasoningGroup?: ReasoningGroupComponent;\n\n ChainOfThought?: never;\n };\n\n /**\n * Chain of thought component configuration.\n *\n * When `ChainOfThought` is set, it takes control of rendering ALL reasoning and\n * tool-call parts in the message. The `Reasoning`, `tools`, `ReasoningGroup`, and\n * `ToolGroup` components cannot be used alongside it.\n */\n type ChainOfThoughtComponents = BaseComponents & {\n /**\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a `groupBy`\n * that returns `[\"group-thought\", ...]` for reasoning and tool-call\n * parts. See `@assistant-ui/ui` for a worked example.\n */\n ChainOfThought: ComponentType;\n\n Reasoning?: never;\n tools?: never;\n ToolGroup?: never;\n ReasoningGroup?: never;\n };\n\n export type Props =\n | {\n /**\n * Component configuration for rendering different types of message content.\n *\n * Use either `Reasoning`/`tools`/`ToolGroup`/`ReasoningGroup` for standard rendering,\n * or `ChainOfThought` to group all reasoning and tool-call parts into a single\n * collapsible component. These two modes are mutually exclusive.\n */\n components?: StandardComponents | ChainOfThoughtComponents | undefined;\n /**\n * When enabled, shows the Empty component if the last part in the message\n * is anything other than Text or Reasoning.\n *\n * @experimental This API is experimental and may change in future versions.\n * @default true\n */\n unstable_showEmptyOnNonTextEnd?: boolean | undefined;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the enriched part state. */\n children: (value: { part: EnrichedPartState }) => ReactNode;\n components?: never;\n unstable_showEmptyOnNonTextEnd?: never;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState(\n (s) => s.tools.toolUIs[props.toolName]?.[0]?.render ?? Fallback,\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst getDataRenderer = (\n dataRenderers: DataRenderersState,\n name: string,\n inlineFallback: DataMessagePartComponent | undefined,\n): DataMessagePartComponent | undefined => {\n const named = dataRenderers.renderers[name]?.[0];\n if (named) return named;\n return dataRenderers.fallbacks[0] ?? inlineFallback;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) =>\n getDataRenderer(s.dataRenderers, props.name, Fallback),\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\n/**\n * Platform-agnostic no-op default components.\n * Each platform (web, RN) wraps MessagePrimitiveParts with its own defaults.\n */\nexport const defaultComponents = {\n Text: () => null,\n Reasoning: () => null,\n Source: () => null,\n Image: () => null,\n File: () => null,\n Unstable_Audio: () => null,\n ToolGroup: ({ children }: PropsWithChildren) => children,\n ReasoningGroup: ({ children }: PropsWithChildren) => children,\n} satisfies MessagePrimitiveParts.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveParts.Props[\"components\"];\n};\n\nexport const MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n generativeUI,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part().addToolResult;\n const resume = aui.part().resumeToolCall;\n const respondToApproval = aui.part().respondToToolApproval;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data = data?.by_name?.[part.name] ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n case \"generative-ui\": {\n if (!generativeUI?.components) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(\n \"MessagePrimitive.Parts received a generative-ui part but no \" +\n \"`components.generativeUI.components` allowlist was provided. \" +\n \"Pass an allowlist or render with <MessagePrimitive.GenerativeUI />.\",\n );\n }\n return null;\n }\n return (\n <GenerativeUIRender\n spec={(part as GenerativeUIMessagePart).spec}\n components={generativeUI.components}\n Fallback={generativeUI.Fallback}\n />\n );\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\nexport namespace MessagePrimitivePartByIndex {\n export type Props = {\n index: number;\n components: MessagePrimitiveParts.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single message part at the specified index.\n */\nexport const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.generativeUI === next.components?.generativeUI &&\n prev.components?.ToolGroup === next.components?.ToolGroup &&\n prev.components?.ReasoningGroup === next.components?.ReasoningGroup,\n );\n\nMessagePrimitivePartByIndex.displayName = \"MessagePrimitive.PartByIndex\";\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst RUNNING_STATUS: MessagePartStatus = Object.freeze({\n type: \"running\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n if (status.type !== \"running\") return null;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst ConditionalEmptyImpl: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n enabled: boolean;\n}> = ({ components, enabled }) => {\n const shouldShowEmpty = useAuiState((s) => {\n if (!enabled) return false;\n if (s.message.parts.length === 0) return false;\n\n const lastPart = s.message.parts[s.message.parts.length - 1];\n return lastPart?.type !== \"text\" && lastPart?.type !== \"reasoning\";\n });\n\n if (!shouldShowEmpty) return null;\n return <EmptyParts components={components} />;\n};\n\nconst ConditionalEmpty = memo(\n ConditionalEmptyImpl,\n (prev, next) =>\n prev.enabled === next.enabled &&\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst QuoteRendererImpl: FC<{ Quote: QuoteMessagePartComponent }> = ({\n Quote,\n}) => {\n const quoteInfo = useAuiState(getMessageQuote);\n if (!quoteInfo) return null;\n return <Quote text={quoteInfo.text} messageId={quoteInfo.messageId} />;\n};\n\nconst QuoteRenderer = memo(QuoteRendererImpl);\n\nfunction resolveToolRender(\n toolsState: ToolsState,\n part: Extract<PartState, { type: \"tool-call\" }>,\n): ToolCallMessagePartComponent | null {\n const named = toolsState.toolUIs[part.toolName]?.[0]?.render ?? null;\n if (named) return named;\n if (isMcpAppUri(part.mcp?.app?.resourceUri) && toolsState.mcpApp) {\n return toolsState.mcpApp.render;\n }\n return null;\n}\n\n/**\n * Stable propless component that renders the registered tool UI for the\n * current part context. Reads tool registry and part state from context.\n */\nconst RegisteredToolUI: FC = () => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"tool-call\" ? resolveToolRender(s.tools, s.part) : null,\n );\n\n if (!Render || part.type !== \"tool-call\") return null;\n\n return (\n <Render\n {...part}\n addResult={aui.part().addToolResult}\n resume={aui.part().resumeToolCall}\n respondToApproval={aui.part().respondToToolApproval}\n />\n );\n};\n\n/**\n * Stable propless component that renders the registered data renderer UI\n * for the current part context.\n */\nconst RegisteredDataRendererUI: FC = () => {\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"data\"\n ? (getDataRenderer(s.dataRenderers, s.part.name, undefined) ?? null)\n : null,\n );\n\n if (!Render || part.type !== \"data\") return null;\n\n return <Render {...(part as DataMessagePartProps)} />;\n};\n\n/**\n * Fallback component rendered when the children render function returns null.\n * Renders registered tool/data UIs via context.\n * For all other part types, renders nothing.\n *\n * This allows users to write:\n * {({ part }) => {\n * if (part.type === \"text\") return <MyText />;\n * return null; // tool UIs and data UIs still render via registry\n * }}\n *\n * To explicitly render nothing (suppressing registered UIs), return <></>.\n */\nconst DefaultPartFallback: FC = () => {\n const partType = useAuiState((s) => s.part.type);\n\n if (partType === \"tool-call\") return <RegisteredToolUI />;\n if (partType === \"data\") return <RegisteredDataRendererUI />;\n\n return null;\n};\n\nexport type { PartState };\n\n/**\n * Enriched part state passed to children render functions.\n *\n * For tool-call parts, adds `toolUI`, `addResult`, and `resume`.\n * For data parts, adds `dataRendererUI`.\n *\n * The render function is also invoked once with a synthetic empty text part\n * (`{ type: \"text\", text: \"\", status: { type: \"running\" } }`) when the\n * assistant message has no parts yet but is in the running state, so a\n * loading indicator can render. Differentiate this from a real empty text\n * via `part.status?.type === \"running\" && part.text === \"\"`.\n */\nexport type EnrichedPartState =\n | (Extract<PartState, { type: \"tool-call\" }> & {\n /** The registered tool UI element, or null if none registered. */\n readonly toolUI: ReactNode;\n /** Add a tool result to this tool call. */\n addResult: ToolCallMessagePartProps[\"addResult\"];\n /** Resume a tool call waiting for human input. */\n resume: ToolCallMessagePartProps[\"resume\"];\n /** Respond to a server-side tool approval gate. */\n respondToApproval: ToolCallMessagePartProps[\"respondToApproval\"];\n })\n | (Extract<PartState, { type: \"data\" }> & {\n /** The registered data renderer UI element, or null if none registered. */\n readonly dataRendererUI: ReactNode;\n })\n | Exclude<PartState, { type: \"tool-call\" } | { type: \"data\" }>;\n\nconst EMPTY_RUNNING_TEXT_PART: Extract<EnrichedPartState, { type: \"text\" }> =\n Object.freeze({\n type: \"text\",\n text: \"\",\n status: RUNNING_STATUS,\n });\n\n/**\n * @internal\n * Renders a single part by index, calling `children` with the\n * {@link EnrichedPartState} (tool/data UI enrichments + addResult/resume\n * for tool calls). Shared between `<MessagePrimitive.Parts>` and\n * `<MessagePrimitive.GroupedParts>`. Returns whatever `children`\n * returns — callers decide how to handle a `null` return.\n */\nexport const MessagePartChildren: FC<{\n index: number;\n children: (value: { part: EnrichedPartState }) => ReactNode;\n}> = ({ index, children }) => {\n const aui = useAui();\n // Subscribed (not snapshotted like `tools`) so fallbacks registered\n // after the first render trigger a re-render and `hasUI` re-evaluates.\n const dataRenderers = useAuiState((s) => s.dataRenderers);\n\n return (\n <PartByIndexProvider index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) => aui.message().part({ index }).getState()}\n >\n {(getItem) =>\n children({\n get part() {\n const state = getItem();\n if (state.type === \"tool-call\") {\n const toolsState = aui.tools().getState();\n const hasUI = resolveToolRender(toolsState, state) !== null;\n const partMethods = aui.message().part({ index });\n return {\n ...state,\n toolUI: hasUI ? <RegisteredToolUI /> : null,\n addResult: partMethods.addToolResult,\n resume: partMethods.resumeToolCall,\n respondToApproval: partMethods.respondToToolApproval,\n };\n }\n if (state.type === \"data\") {\n const hasUI =\n getDataRenderer(dataRenderers, state.name, undefined) !==\n undefined;\n return {\n ...state,\n dataRendererUI: hasUI ? <RegisteredDataRendererUI /> : null,\n };\n }\n return state;\n },\n })\n }\n </RenderChildrenWithAccessor>\n </PartByIndexProvider>\n );\n};\n\nconst MessagePrimitivePartsInner: FC<{\n children: (value: { part: EnrichedPartState }) => ReactNode;\n}> = ({ children }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const isRunning = useAuiState(\n (s) => (s.message.status?.type ?? \"complete\") === \"running\",\n );\n const isEmptyRunning = contentLength === 0 && isRunning;\n\n if (contentLength === 0) {\n if (!isEmptyRunning) return null;\n return (\n <TextMessagePartProvider text=\"\" isRunning>\n {children({ part: EMPTY_RUNNING_TEXT_PART })}\n </TextMessagePartProvider>\n );\n }\n\n return (\n <>\n {Array.from({ length: contentLength }, (_, index) => (\n <MessagePartChildren key={index} index={index}>\n {(value) => children(value) ?? <DefaultPartFallback />}\n </MessagePartChildren>\n ))}\n </>\n );\n};\n\n/**\n * Renders the parts of a message with support for multiple content types.\n *\n * This is the platform-agnostic base. Each platform wraps this with its own\n * default components (web uses `<p>`, `<span>`; RN would use `<Text>`, etc.).\n */\nexport const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({\n components,\n unstable_showEmptyOnNonTextEnd = true,\n children,\n}) => {\n if (children) {\n return <MessagePrimitivePartsInner>{children}</MessagePrimitivePartsInner>;\n }\n return (\n <MessagePrimitivePartsCompat\n components={components}\n unstable_showEmptyOnNonTextEnd={unstable_showEmptyOnNonTextEnd}\n />\n );\n};\n\nMessagePrimitiveParts.displayName = \"MessagePrimitive.Parts\";\n\nconst MessagePrimitivePartsCompat: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n unstable_showEmptyOnNonTextEnd: boolean;\n}> = ({ components, unstable_showEmptyOnNonTextEnd }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const useChainOfThought = !!components?.ChainOfThought;\n const { ranges: messageRanges, partIds } =\n useMessagePartsGroups(useChainOfThought);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n const claimed = new Set<string>();\n const toolLeafKey = (partIndex: number) => {\n const id = partIds[partIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n return `part-id:${id}`;\n }\n return `part-${partIndex}`;\n };\n\n return messageRanges.map((range) => {\n if (range.type === \"single\") {\n return (\n <MessagePrimitivePartByIndex\n key={range.index}\n index={range.index}\n components={components}\n />\n );\n } else if (range.type === \"chainOfThoughtGroup\") {\n const ChainOfThoughtComponent = components?.ChainOfThought;\n if (!ChainOfThoughtComponent) return null;\n return (\n <ChainOfThoughtByIndicesProvider\n key={`chainOfThought-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n <ChainOfThoughtComponent />\n </ChainOfThoughtByIndicesProvider>\n );\n } else if (range.type === \"toolGroup\") {\n const ToolGroupComponent =\n components?.ToolGroup ?? defaultComponents.ToolGroup;\n return (\n <ToolGroupComponent\n key={`tool-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={toolLeafKey(partIndex)}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ToolGroupComponent>\n );\n } else {\n // reasoningGroup\n const ReasoningGroupComponent =\n components?.ReasoningGroup ?? defaultComponents.ReasoningGroup;\n return (\n <ReasoningGroupComponent\n key={`reasoning-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={`part-${partIndex}`}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ReasoningGroupComponent>\n );\n }\n });\n }, [messageRanges, partIds, components, contentLength]);\n\n return (\n <>\n {components?.Quote && <QuoteRenderer Quote={components.Quote} />}\n {partsElements}\n <ConditionalEmpty\n components={components}\n enabled={unstable_showEmptyOnNonTextEnd}\n />\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqEA,MAAMyC,oBAGJC,cACG;CACH,IAAIE,QAAQ;CAEZ,OAAO;EACLC,aAAaR,UAAkB;GAC7B,IAAIO,UAAU,IACZA,QAAQP;EAEZ;EACAS,WAAWP,UAAkBQ,WAA+B;GAC1D,IAAIH,UAAU,IAAI;IAChBG,OAAOC,KAAK;KACVZ,MAAMM;KACNJ,YAAYM;KACZL;IAC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AKxE;AAAK;AAwG5C,SAAA+K,QAAAnG,GAAA;CAAA,OACsCA,EAAC6D,QAAQC,MAAMtH;AAAO;AAD5D,SAAA6J,QAAAuB,KAAA;CAAA,QAGO5H,IAAC6D,QAAQxB,QAAajH,QAAtB,gBAA0C;AAAS;AAmD1D,SAAAuL,QAAA3G,GAAA;CAAA,OACsCA,EAAC6D,QAAQC,MAAMtH;AAAO"}
1
+ {"version":3,"file":"MessageParts.js","names":["ComponentType","FC","ReactNode","memo","PropsWithChildren","useMemo","RenderChildrenWithAccessor","useAuiState","useAui","PartState","PartByIndexProvider","TextMessagePartProvider","ChainOfThoughtByIndicesProvider","getMessageQuote","Unstable_AudioMessagePartComponent","DataMessagePartComponent","DataMessagePartProps","EmptyMessagePartComponent","TextMessagePartComponent","ImageMessagePartComponent","SourceMessagePartComponent","ToolCallMessagePartComponent","ToolCallMessagePartProps","FileMessagePartComponent","ReasoningMessagePartComponent","ReasoningGroupComponent","QuoteMessagePartComponent","GenerativeUIComponentRegistry","GenerativeUIRender","isMcpAppUri","MessagePartStatus","GenerativeUIMessagePart","DataRenderersState","ToolsState","useShallow","MessagePartRange","type","index","startIndex","endIndex","idKey","createGroupState","groupType","T","start","startGroup","endGroup","ranges","push","finalize","groupMessageParts","messageTypes","useChainOfThought","partIds","chainOfThoughtGroup","i","length","toolGroup","reasoningGroup","claimed","Set","range","id","undefined","has","add","useMessagePartsGroups","$","_c","_temp2","_temp4","t0","bb0","t1","Symbol","for","t2","MessagePrimitiveParts","DataConfig","by_name","Record","Fallback","BaseComponents","Empty","Text","Source","Image","File","Unstable_Audio","data","Quote","generativeUI","components","component","props","ToolsConfig","Override","StandardComponents","Reasoning","tools","ToolGroup","ReasoningGroup","ChainOfThought","ChainOfThoughtComponents","Props","unstable_showEmptyOnNonTextEnd","children","value","part","EnrichedPartState","ToolUIDisplay","toolName","s","toolUIs","render","Render","getDataRenderer","dataRenderers","name","inlineFallback","named","renderers","fallbacks","DataUIDisplay","defaultComponents","MessagePartComponentProps","MessagePartComponent","t3","t4","t5","t6","t7","t8","t9","Audio","t10","aui","_temp5","t11","addResult","addToolResult","t12","resume","resumeToolCall","t13","respondToApproval","respondToToolApproval","t14","Tool","status","Error","Data","process","env","NODE_ENV","console","warn","spec","MessagePrimitivePartByIndex","prev","next","displayName","EmptyPartFallback","Component","COMPLETE_STATUS","Object","freeze","RUNNING_STATUS","EmptyPartsImpl","_temp6","EmptyParts","ConditionalEmptyImpl","enabled","message","parts","lastPart","shouldShowEmpty","ConditionalEmpty","QuoteRendererImpl","quoteInfo","messageId","text","QuoteRenderer","resolveToolRender","toolsState","Extract","mcp","app","resourceUri","mcpApp","RegisteredToolUI","_temp7","_temp8","RegisteredDataRendererUI","_temp9","_temp0","DefaultPartFallback","partType","_temp1","toolUI","dataRendererUI","Exclude","EMPTY_RUNNING_TEXT_PART","MessagePartChildrenProps","MessagePartChildrenInner","Pick","client","getState","getItem","state","hasUI","partMethods","MessagePartChildren","MessagePrimitivePartsInner","contentLength","_temp10","isRunning","_temp11","isEmptyRunning","_","Array","from","MessagePrimitivePartsCompat","_temp12","messageRanges","toolLeafKey","partIndex","map","ChainOfThoughtComponent","ToolGroupComponent","partIndex_0","__0","i_0","partIndex_1","partsElements","_temp","c","_temp3","c_0","toolCallId","s_0"],"sources":["../../../../src/react/primitives/message/MessageParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n type PropsWithChildren,\n useMemo,\n} from \"react\";\nimport {\n RenderChildrenWithAccessor,\n useAuiState,\n useAui,\n} from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { PartByIndexProvider } from \"../../providers/PartByIndexProvider\";\nimport { TextMessagePartProvider } from \"../../providers/TextMessagePartProvider\";\nimport { ChainOfThoughtByIndicesProvider } from \"../../providers/ChainOfThoughtByIndicesProvider\";\nimport { getMessageQuote } from \"../../utils/getMessageQuote\";\nimport type {\n Unstable_AudioMessagePartComponent,\n DataMessagePartComponent,\n DataMessagePartProps,\n EmptyMessagePartComponent,\n TextMessagePartComponent,\n ImageMessagePartComponent,\n SourceMessagePartComponent,\n ToolCallMessagePartComponent,\n ToolCallMessagePartProps,\n FileMessagePartComponent,\n ReasoningMessagePartComponent,\n ReasoningGroupComponent,\n QuoteMessagePartComponent,\n GenerativeUIComponentRegistry,\n} from \"../../types/MessagePartComponentTypes\";\nimport { GenerativeUIRender } from \"../generativeUI/GenerativeUI\";\nimport {\n isMcpAppUri,\n type MessagePartStatus,\n type GenerativeUIMessagePart,\n} from \"../../../types/message\";\nimport type { DataRenderersState } from \"../../types/scopes/dataRenderers\";\nimport type { ToolsState } from \"../../types/scopes/tools\";\nimport { useShallow } from \"zustand/shallow\";\n\ntype MessagePartRange =\n | { type: \"single\"; index: number }\n | {\n type: \"toolGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"reasoningGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n }\n | {\n type: \"chainOfThoughtGroup\";\n startIndex: number;\n endIndex: number;\n idKey?: string | undefined;\n };\n\n/**\n * Creates a group state manager for a specific part type.\n * Returns functions to start, end, and finalize groups.\n */\nconst createGroupState = <\n T extends \"toolGroup\" | \"reasoningGroup\" | \"chainOfThoughtGroup\",\n>(\n groupType: T,\n) => {\n let start = -1;\n\n return {\n startGroup: (index: number) => {\n if (start === -1) {\n start = index;\n }\n },\n endGroup: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n start = -1;\n }\n },\n finalize: (endIndex: number, ranges: MessagePartRange[]) => {\n if (start !== -1) {\n ranges.push({\n type: groupType,\n startIndex: start,\n endIndex,\n } as MessagePartRange);\n }\n },\n };\n};\n\n/**\n * Groups consecutive tool-call and reasoning message parts into ranges.\n * Always groups tool calls and reasoning parts, even if there's only one.\n * When useChainOfThought is true, groups tool-call and reasoning parts together.\n * `partIds[i]` optionally carries a stable identity for part `i`; group\n * ranges derive an `idKey` from their first part's id (first claim wins).\n */\nexport const groupMessageParts = (\n messageTypes: readonly string[],\n useChainOfThought: boolean,\n partIds?: readonly (string | undefined)[],\n): MessagePartRange[] => {\n const ranges: MessagePartRange[] = [];\n\n if (useChainOfThought) {\n const chainOfThoughtGroup = createGroupState(\"chainOfThoughtGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\" || type === \"reasoning\") {\n chainOfThoughtGroup.startGroup(i);\n } else {\n chainOfThoughtGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n chainOfThoughtGroup.finalize(messageTypes.length - 1, ranges);\n } else {\n const toolGroup = createGroupState(\"toolGroup\");\n const reasoningGroup = createGroupState(\"reasoningGroup\");\n\n for (let i = 0; i < messageTypes.length; i++) {\n const type = messageTypes[i];\n\n if (type === \"tool-call\") {\n reasoningGroup.endGroup(i - 1, ranges);\n toolGroup.startGroup(i);\n } else if (type === \"reasoning\") {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.startGroup(i);\n } else {\n toolGroup.endGroup(i - 1, ranges);\n reasoningGroup.endGroup(i - 1, ranges);\n ranges.push({ type: \"single\", index: i });\n }\n }\n\n toolGroup.finalize(messageTypes.length - 1, ranges);\n reasoningGroup.finalize(messageTypes.length - 1, ranges);\n }\n\n if (partIds) {\n const claimed = new Set<string>();\n for (const range of ranges) {\n if (range.type === \"single\") continue;\n const id = partIds[range.startIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n range.idKey = `id:${id}`;\n }\n }\n }\n\n return ranges;\n};\n\nconst useMessagePartsGroups = (\n useChainOfThought: boolean,\n): { ranges: MessagePartRange[]; partIds: (string | undefined)[] } => {\n const messageTypes = useAuiState(\n useShallow((s) => s.message.parts.map((c: any) => c.type)),\n );\n const partIds = useAuiState(\n useShallow((s) =>\n s.message.parts.map((c: any) =>\n c.type === \"tool-call\" ? c.toolCallId : undefined,\n ),\n ),\n );\n\n return useMemo(() => {\n if (messageTypes.length === 0) {\n return { ranges: [], partIds };\n }\n return {\n ranges: groupMessageParts(messageTypes, useChainOfThought, partIds),\n partIds,\n };\n }, [messageTypes, partIds, useChainOfThought]);\n};\n\nexport namespace MessagePrimitiveParts {\n type DataConfig = {\n /** Map data event names to specific components */\n by_name?: Record<string, DataMessagePartComponent | undefined> | undefined;\n /** Fallback component for unmatched data events */\n Fallback?: DataMessagePartComponent | undefined;\n };\n\n type BaseComponents = {\n /** Component for rendering empty messages */\n Empty?: EmptyMessagePartComponent | undefined;\n /** Component for rendering text content */\n Text?: TextMessagePartComponent | undefined;\n /** Component for rendering source content */\n Source?: SourceMessagePartComponent | undefined;\n /** Component for rendering image content */\n Image?: ImageMessagePartComponent | undefined;\n /** Component for rendering file content */\n File?: FileMessagePartComponent | undefined;\n /** Component for rendering audio content (experimental) */\n Unstable_Audio?: Unstable_AudioMessagePartComponent | undefined;\n /** Configuration for data part rendering */\n data?: DataConfig | undefined;\n /** Component for rendering a quoted message reference (from metadata, not parts) */\n Quote?: QuoteMessagePartComponent | undefined;\n /**\n * Configuration for generative-ui part rendering.\n *\n * `components` is the consumer-provided allowlist of React components\n * the agent's JSON spec is permitted to render. Any name not present in\n * the registry is rejected with a typed `GenerativeUIRenderError` —\n * this is the security boundary in the same-realm rendering path.\n */\n generativeUI?:\n | {\n /** The component allowlist (the security boundary). */\n components: GenerativeUIComponentRegistry;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n }\n | undefined;\n };\n\n type ToolsConfig =\n | {\n /** Map of tool names to their specific components */\n by_name?:\n | Record<string, ToolCallMessagePartComponent | undefined>\n | undefined;\n /** Fallback component for unregistered tools */\n Fallback?: ComponentType<ToolCallMessagePartProps> | undefined;\n }\n | {\n /** Override component that handles all tool calls */\n Override: ComponentType<ToolCallMessagePartProps>;\n };\n\n /**\n * Standard component configuration for rendering reasoning and tool-call parts\n * individually (with optional grouping).\n *\n * Cannot be combined with `ChainOfThought`.\n */\n type StandardComponents = BaseComponents & {\n /** Component for rendering reasoning content (typically hidden) */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Configuration for tool call rendering */\n tools?: ToolsConfig | undefined;\n\n /**\n * Component for rendering grouped consecutive tool calls.\n *\n * @param startIndex - Index of the first tool call in the group\n * @param endIndex - Index of the last tool call in the group\n * @param children - Rendered tool call components to display within the group\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ToolGroup?: ComponentType<\n PropsWithChildren<{ startIndex: number; endIndex: number }>\n >;\n\n /**\n * Component for rendering grouped reasoning parts.\n *\n * @param startIndex - Index of the first reasoning part in the group\n * @param endIndex - Index of the last reasoning part in the group\n * @param children - Rendered reasoning part components\n *\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a custom `groupBy` instead.\n */\n ReasoningGroup?: ReasoningGroupComponent;\n\n ChainOfThought?: never;\n };\n\n /**\n * Chain of thought component configuration.\n *\n * When `ChainOfThought` is set, it takes control of rendering ALL reasoning and\n * tool-call parts in the message. The `Reasoning`, `tools`, `ReasoningGroup`, and\n * `ToolGroup` components cannot be used alongside it.\n */\n type ChainOfThoughtComponents = BaseComponents & {\n /**\n * @deprecated Use `<MessagePrimitive.GroupedParts>` with a `groupBy`\n * that returns `[\"group-thought\", ...]` for reasoning and tool-call\n * parts. See `@assistant-ui/ui` for a worked example.\n */\n ChainOfThought: ComponentType;\n\n Reasoning?: never;\n tools?: never;\n ToolGroup?: never;\n ReasoningGroup?: never;\n };\n\n export type Props =\n | {\n /**\n * Component configuration for rendering different types of message content.\n *\n * Use either `Reasoning`/`tools`/`ToolGroup`/`ReasoningGroup` for standard rendering,\n * or `ChainOfThought` to group all reasoning and tool-call parts into a single\n * collapsible component. These two modes are mutually exclusive.\n */\n components?: StandardComponents | ChainOfThoughtComponents | undefined;\n /**\n * When enabled, shows the Empty component if the last part in the message\n * is anything other than Text or Reasoning.\n *\n * @experimental This API is experimental and may change in future versions.\n * @default true\n */\n unstable_showEmptyOnNonTextEnd?: boolean | undefined;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the enriched part state. */\n children: (value: { part: EnrichedPartState }) => ReactNode;\n components?: never;\n unstable_showEmptyOnNonTextEnd?: never;\n };\n}\n\nconst ToolUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: ToolCallMessagePartComponent | undefined;\n} & ToolCallMessagePartProps) => {\n const Render = useAuiState(\n (s) => s.tools.toolUIs[props.toolName]?.[0]?.render ?? Fallback,\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\nconst getDataRenderer = (\n dataRenderers: DataRenderersState,\n name: string,\n inlineFallback: DataMessagePartComponent | undefined,\n): DataMessagePartComponent | undefined => {\n const named = dataRenderers.renderers[name]?.[0];\n if (named) return named;\n return dataRenderers.fallbacks[0] ?? inlineFallback;\n};\n\nconst DataUIDisplay = ({\n Fallback,\n ...props\n}: {\n Fallback: DataMessagePartComponent | undefined;\n} & DataMessagePartProps) => {\n const Render = useAuiState((s) =>\n getDataRenderer(s.dataRenderers, props.name, Fallback),\n );\n if (!Render) return null;\n return <Render {...props} />;\n};\n\n/**\n * Platform-agnostic no-op default components.\n * Each platform (web, RN) wraps MessagePrimitiveParts with its own defaults.\n */\nexport const defaultComponents = {\n Text: () => null,\n Reasoning: () => null,\n Source: () => null,\n Image: () => null,\n File: () => null,\n Unstable_Audio: () => null,\n ToolGroup: ({ children }: PropsWithChildren) => children,\n ReasoningGroup: ({ children }: PropsWithChildren) => children,\n} satisfies MessagePrimitiveParts.Props[\"components\"];\n\ntype MessagePartComponentProps = {\n components: MessagePrimitiveParts.Props[\"components\"];\n};\n\nexport const MessagePartComponent: FC<MessagePartComponentProps> = ({\n components: {\n Text = defaultComponents.Text,\n Reasoning = defaultComponents.Reasoning,\n Image = defaultComponents.Image,\n Source = defaultComponents.Source,\n File = defaultComponents.File,\n Unstable_Audio: Audio = defaultComponents.Unstable_Audio,\n tools = {},\n data,\n generativeUI,\n } = {},\n}) => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n\n const type = part.type;\n if (type === \"tool-call\") {\n const addResult = aui.part().addToolResult;\n const resume = aui.part().resumeToolCall;\n const respondToApproval = aui.part().respondToToolApproval;\n if (\"Override\" in tools)\n return (\n <tools.Override\n {...part}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n const Tool = tools.by_name?.[part.toolName] ?? tools.Fallback;\n return (\n <ToolUIDisplay\n {...part}\n Fallback={Tool}\n addResult={addResult}\n resume={resume}\n respondToApproval={respondToApproval}\n />\n );\n }\n\n if (part.status?.type === \"requires-action\")\n throw new Error(\"Encountered unexpected requires-action status\");\n\n switch (type) {\n case \"text\":\n return <Text {...part} />;\n\n case \"reasoning\":\n return <Reasoning {...part} />;\n\n case \"source\":\n return <Source {...part} />;\n\n case \"image\":\n return <Image {...part} />;\n\n case \"file\":\n return <File {...part} />;\n\n case \"audio\":\n return <Audio {...part} />;\n\n case \"data\": {\n const Data = data?.by_name?.[part.name] ?? data?.Fallback;\n return <DataUIDisplay {...part} Fallback={Data} />;\n }\n\n case \"generative-ui\": {\n if (!generativeUI?.components) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(\n \"MessagePrimitive.Parts received a generative-ui part but no \" +\n \"`components.generativeUI.components` allowlist was provided. \" +\n \"Pass an allowlist or render with <MessagePrimitive.GenerativeUI />.\",\n );\n }\n return null;\n }\n return (\n <GenerativeUIRender\n spec={(part as GenerativeUIMessagePart).spec}\n components={generativeUI.components}\n Fallback={generativeUI.Fallback}\n />\n );\n }\n\n default:\n console.warn(`Unknown message part type: ${type}`);\n return null;\n }\n};\n\nexport namespace MessagePrimitivePartByIndex {\n export type Props = {\n index: number;\n components: MessagePrimitiveParts.Props[\"components\"];\n };\n}\n\n/**\n * Renders a single message part at the specified index.\n */\nexport const MessagePrimitivePartByIndex: FC<MessagePrimitivePartByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartComponent components={components} />\n </PartByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Text === next.components?.Text &&\n prev.components?.Reasoning === next.components?.Reasoning &&\n prev.components?.Source === next.components?.Source &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.File === next.components?.File &&\n prev.components?.Unstable_Audio === next.components?.Unstable_Audio &&\n prev.components?.tools === next.components?.tools &&\n prev.components?.data === next.components?.data &&\n prev.components?.generativeUI === next.components?.generativeUI &&\n prev.components?.ToolGroup === next.components?.ToolGroup &&\n prev.components?.ReasoningGroup === next.components?.ReasoningGroup,\n );\n\nMessagePrimitivePartByIndex.displayName = \"MessagePrimitive.PartByIndex\";\n\nconst EmptyPartFallback: FC<{\n status: MessagePartStatus;\n component: TextMessagePartComponent;\n}> = ({ status, component: Component }) => {\n return (\n <TextMessagePartProvider text=\"\" isRunning={status.type === \"running\"}>\n <Component type=\"text\" text=\"\" status={status} />\n </TextMessagePartProvider>\n );\n};\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({\n type: \"complete\",\n});\n\nconst RUNNING_STATUS: MessagePartStatus = Object.freeze({\n type: \"running\",\n});\n\nconst EmptyPartsImpl: FC<MessagePartComponentProps> = ({ components }) => {\n const status = useAuiState(\n (s) => (s.message.status ?? COMPLETE_STATUS) as MessagePartStatus,\n );\n\n if (components?.Empty) return <components.Empty status={status} />;\n\n if (status.type !== \"running\") return null;\n\n return (\n <EmptyPartFallback\n status={status}\n component={components?.Text ?? defaultComponents.Text}\n />\n );\n};\n\nconst EmptyParts = memo(\n EmptyPartsImpl,\n (prev, next) =>\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst ConditionalEmptyImpl: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n enabled: boolean;\n}> = ({ components, enabled }) => {\n const shouldShowEmpty = useAuiState((s) => {\n if (!enabled) return false;\n if (s.message.parts.length === 0) return false;\n\n const lastPart = s.message.parts[s.message.parts.length - 1];\n return lastPart?.type !== \"text\" && lastPart?.type !== \"reasoning\";\n });\n\n if (!shouldShowEmpty) return null;\n return <EmptyParts components={components} />;\n};\n\nconst ConditionalEmpty = memo(\n ConditionalEmptyImpl,\n (prev, next) =>\n prev.enabled === next.enabled &&\n prev.components?.Empty === next.components?.Empty &&\n prev.components?.Text === next.components?.Text,\n);\n\nconst QuoteRendererImpl: FC<{ Quote: QuoteMessagePartComponent }> = ({\n Quote,\n}) => {\n const quoteInfo = useAuiState(getMessageQuote);\n if (!quoteInfo) return null;\n return <Quote text={quoteInfo.text} messageId={quoteInfo.messageId} />;\n};\n\nconst QuoteRenderer = memo(QuoteRendererImpl);\n\nfunction resolveToolRender(\n toolsState: ToolsState,\n part: Extract<PartState, { type: \"tool-call\" }>,\n): ToolCallMessagePartComponent | null {\n const named = toolsState.toolUIs[part.toolName]?.[0]?.render ?? null;\n if (named) return named;\n if (isMcpAppUri(part.mcp?.app?.resourceUri) && toolsState.mcpApp) {\n return toolsState.mcpApp.render;\n }\n return null;\n}\n\n/**\n * Stable propless component that renders the registered tool UI for the\n * current part context. Reads tool registry and part state from context.\n */\nconst RegisteredToolUI: FC = () => {\n const aui = useAui();\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"tool-call\" ? resolveToolRender(s.tools, s.part) : null,\n );\n\n if (!Render || part.type !== \"tool-call\") return null;\n\n return (\n <Render\n {...part}\n addResult={aui.part().addToolResult}\n resume={aui.part().resumeToolCall}\n respondToApproval={aui.part().respondToToolApproval}\n />\n );\n};\n\n/**\n * Stable propless component that renders the registered data renderer UI\n * for the current part context.\n */\nconst RegisteredDataRendererUI: FC = () => {\n const part = useAuiState((s) => s.part);\n const Render = useAuiState((s) =>\n s.part.type === \"data\"\n ? (getDataRenderer(s.dataRenderers, s.part.name, undefined) ?? null)\n : null,\n );\n\n if (!Render || part.type !== \"data\") return null;\n\n return <Render {...(part as DataMessagePartProps)} />;\n};\n\n/**\n * Fallback component rendered when the children render function returns null.\n * Renders registered tool/data UIs via context.\n * For all other part types, renders nothing.\n *\n * This allows users to write:\n * {({ part }) => {\n * if (part.type === \"text\") return <MyText />;\n * return null; // tool UIs and data UIs still render via registry\n * }}\n *\n * To explicitly render nothing (suppressing registered UIs), return <></>.\n */\nconst DefaultPartFallback: FC = () => {\n const partType = useAuiState((s) => s.part.type);\n\n if (partType === \"tool-call\") return <RegisteredToolUI />;\n if (partType === \"data\") return <RegisteredDataRendererUI />;\n\n return null;\n};\n\nexport type { PartState };\n\n/**\n * Enriched part state passed to children render functions.\n *\n * For tool-call parts, adds `toolUI`, `addResult`, and `resume`.\n * For data parts, adds `dataRendererUI`.\n *\n * The render function is also invoked once with a synthetic empty text part\n * (`{ type: \"text\", text: \"\", status: { type: \"running\" } }`) when the\n * assistant message has no parts yet but is in the running state, so a\n * loading indicator can render. Differentiate this from a real empty text\n * via `part.status?.type === \"running\" && part.text === \"\"`.\n */\nexport type EnrichedPartState =\n | (Extract<PartState, { type: \"tool-call\" }> & {\n /** The registered tool UI element, or null if none registered. */\n readonly toolUI: ReactNode;\n /** Add a tool result to this tool call. */\n addResult: ToolCallMessagePartProps[\"addResult\"];\n /** Resume a tool call waiting for human input. */\n resume: ToolCallMessagePartProps[\"resume\"];\n /** Respond to a server-side tool approval gate. */\n respondToApproval: ToolCallMessagePartProps[\"respondToApproval\"];\n })\n | (Extract<PartState, { type: \"data\" }> & {\n /** The registered data renderer UI element, or null if none registered. */\n readonly dataRendererUI: ReactNode;\n })\n | Exclude<PartState, { type: \"tool-call\" } | { type: \"data\" }>;\n\nconst EMPTY_RUNNING_TEXT_PART: Extract<EnrichedPartState, { type: \"text\" }> =\n Object.freeze({\n type: \"text\",\n text: \"\",\n status: RUNNING_STATUS,\n });\n\n/**\n * @internal\n * Renders a single part by index, calling `children` with the\n * {@link EnrichedPartState} (tool/data UI enrichments + addResult/resume\n * for tool calls). Shared between `<MessagePrimitive.Parts>` and\n * `<MessagePrimitive.GroupedParts>`. Returns whatever `children`\n * returns — callers decide how to handle a `null` return.\n */\ntype MessagePartChildrenProps = {\n index: number;\n children: (value: { part: EnrichedPartState }) => ReactNode;\n};\n\nconst MessagePartChildrenInner: FC<\n Pick<MessagePartChildrenProps, \"children\">\n> = ({ children }) => {\n const aui = useAui();\n // Subscribed (not snapshotted like `tools`) so fallbacks registered\n // after the first render trigger a re-render and `hasUI` re-evaluates.\n const dataRenderers = useAuiState((s) => s.dataRenderers);\n\n return (\n <RenderChildrenWithAccessor\n getItemState={(client) => client.part().getState()}\n >\n {(getItem) =>\n children({\n get part() {\n const state = getItem();\n if (state.type === \"tool-call\") {\n const toolsState = aui.tools().getState();\n const hasUI = resolveToolRender(toolsState, state) !== null;\n const partMethods = aui.part();\n return {\n ...state,\n toolUI: hasUI ? <RegisteredToolUI /> : null,\n addResult: partMethods.addToolResult,\n resume: partMethods.resumeToolCall,\n respondToApproval: partMethods.respondToToolApproval,\n };\n }\n if (state.type === \"data\") {\n const hasUI =\n getDataRenderer(dataRenderers, state.name, undefined) !==\n undefined;\n return {\n ...state,\n dataRendererUI: hasUI ? <RegisteredDataRendererUI /> : null,\n };\n }\n return state;\n },\n })\n }\n </RenderChildrenWithAccessor>\n );\n};\n\nexport const MessagePartChildren: FC<MessagePartChildrenProps> = ({\n index,\n children,\n}) => {\n return (\n <PartByIndexProvider index={index}>\n <MessagePartChildrenInner>{children}</MessagePartChildrenInner>\n </PartByIndexProvider>\n );\n};\n\nconst MessagePrimitivePartsInner: FC<{\n children: (value: { part: EnrichedPartState }) => ReactNode;\n}> = ({ children }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const isRunning = useAuiState(\n (s) => (s.message.status?.type ?? \"complete\") === \"running\",\n );\n const isEmptyRunning = contentLength === 0 && isRunning;\n\n if (contentLength === 0) {\n if (!isEmptyRunning) return null;\n return (\n <TextMessagePartProvider text=\"\" isRunning>\n {children({ part: EMPTY_RUNNING_TEXT_PART })}\n </TextMessagePartProvider>\n );\n }\n\n return (\n <>\n {Array.from({ length: contentLength }, (_, index) => (\n <MessagePartChildren key={index} index={index}>\n {(value) => children(value) ?? <DefaultPartFallback />}\n </MessagePartChildren>\n ))}\n </>\n );\n};\n\n/**\n * Renders the parts of a message with support for multiple content types.\n *\n * This is the platform-agnostic base. Each platform wraps this with its own\n * default components (web uses `<p>`, `<span>`; RN would use `<Text>`, etc.).\n */\nexport const MessagePrimitiveParts: FC<MessagePrimitiveParts.Props> = ({\n components,\n unstable_showEmptyOnNonTextEnd = true,\n children,\n}) => {\n if (children) {\n return <MessagePrimitivePartsInner>{children}</MessagePrimitivePartsInner>;\n }\n return (\n <MessagePrimitivePartsCompat\n components={components}\n unstable_showEmptyOnNonTextEnd={unstable_showEmptyOnNonTextEnd}\n />\n );\n};\n\nMessagePrimitiveParts.displayName = \"MessagePrimitive.Parts\";\n\nconst MessagePrimitivePartsCompat: FC<{\n components: MessagePrimitiveParts.Props[\"components\"];\n unstable_showEmptyOnNonTextEnd: boolean;\n}> = ({ components, unstable_showEmptyOnNonTextEnd }) => {\n const contentLength = useAuiState((s) => s.message.parts.length);\n const useChainOfThought = !!components?.ChainOfThought;\n const { ranges: messageRanges, partIds } =\n useMessagePartsGroups(useChainOfThought);\n\n const partsElements = useMemo(() => {\n if (contentLength === 0) {\n return <EmptyParts components={components} />;\n }\n\n const claimed = new Set<string>();\n const toolLeafKey = (partIndex: number) => {\n const id = partIds[partIndex];\n if (id !== undefined && !claimed.has(id)) {\n claimed.add(id);\n return `part-id:${id}`;\n }\n return `part-${partIndex}`;\n };\n\n return messageRanges.map((range) => {\n if (range.type === \"single\") {\n return (\n <MessagePrimitivePartByIndex\n key={range.index}\n index={range.index}\n components={components}\n />\n );\n } else if (range.type === \"chainOfThoughtGroup\") {\n const ChainOfThoughtComponent = components?.ChainOfThought;\n if (!ChainOfThoughtComponent) return null;\n return (\n <ChainOfThoughtByIndicesProvider\n key={`chainOfThought-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n <ChainOfThoughtComponent />\n </ChainOfThoughtByIndicesProvider>\n );\n } else if (range.type === \"toolGroup\") {\n const ToolGroupComponent =\n components?.ToolGroup ?? defaultComponents.ToolGroup;\n return (\n <ToolGroupComponent\n key={`tool-${range.idKey ?? range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={toolLeafKey(partIndex)}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ToolGroupComponent>\n );\n } else {\n // reasoningGroup\n const ReasoningGroupComponent =\n components?.ReasoningGroup ?? defaultComponents.ReasoningGroup;\n return (\n <ReasoningGroupComponent\n key={`reasoning-${range.startIndex}`}\n startIndex={range.startIndex}\n endIndex={range.endIndex}\n >\n {Array.from(\n { length: range.endIndex - range.startIndex + 1 },\n (_, i) => {\n const partIndex = range.startIndex + i;\n return (\n <MessagePrimitivePartByIndex\n key={`part-${partIndex}`}\n index={partIndex}\n components={components}\n />\n );\n },\n )}\n </ReasoningGroupComponent>\n );\n }\n });\n }, [messageRanges, partIds, components, contentLength]);\n\n return (\n <>\n {components?.Quote && <QuoteRenderer Quote={components.Quote} />}\n {partsElements}\n <ConditionalEmpty\n components={components}\n enabled={unstable_showEmptyOnNonTextEnd}\n />\n </>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqEA,MAAMyC,oBAGJC,cACG;CACH,IAAIE,QAAQ;CAEZ,OAAO;EACLC,aAAaR,UAAkB;GAC7B,IAAIO,UAAU,IACZA,QAAQP;EAEZ;EACAS,WAAWP,UAAkBQ,WAA+B;GAC1D,IAAIH,UAAU,IAAI;IAChBG,OAAOC,KAAK;KACVZ,MAAMM;KACNJ,YAAYM;KACZL;IACF,CAAqB;IACrBK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AA,OAEKA,EAACJ;AAAK;AAFX,SAAAoF,OAAAgD,KAAA;CAAA,OAIzBhI,IAACJ,KAAKxE,SAAU,cAAcmJ,kBAAkBvE,IAACb,OAAQa,IAACJ,IAAY,IAAtE;AAAuE;AAmBtC,SAAAsF,OAAAlF,GAAA;CAAA,OACHA,EAACJ;AAAK;AADH,SAAAuF,OAAA6C,KAAA;CAAA,OAGjChI,IAACJ,KAAKxE,SAAU,SACXgF,gBAAgBJ,IAACK,eAAgBL,IAACJ,KAAKU,MAAOvD,KAAAA,CAAiB,KAA/D,OADL;AAEQ;AAqBoB,SAAAuI,OAAAtF,GAAA;CAAA,OACMA,EAACJ,KAAKxE;AAAK;AAqH5C,SAAAmL,QAAAvG,GAAA;CAAA,OACsCA,EAAC6D,QAAQC,MAAMtH;AAAO;AAD5D,SAAAiK,QAAAuB,KAAA;CAAA,QAGOhI,IAAC6D,QAAQxB,QAAajH,QAAtB,gBAA0C;AAAS;AAmD1D,SAAA2L,QAAA/G,GAAA;CAAA,OACsCA,EAAC6D,QAAQC,MAAMtH;AAAO"}
@@ -1 +1 @@
1
- {"version":3,"file":"PartMessages.js","names":["FC","ReactNode","memo","useAuiState","ThreadMessage","ReadonlyThreadProvider","ThreadPrimitiveMessages","ThreadPrimitiveMessagesImpl","PartPrimitiveMessages","Props","components","NonNullable","children","value","message","usePartMessages","_temp","PartPrimitiveMessagesImpl","t0","$","_c","messages","length","t1","t2","displayName","s","part","type","undefined"],"sources":["../../../../src/react/primitives/part/PartMessages.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { ThreadMessage } from \"../../../types/message\";\nimport { ReadonlyThreadProvider } from \"../../providers/ReadonlyThreadProvider\";\nimport {\n type ThreadPrimitiveMessages,\n ThreadPrimitiveMessagesImpl,\n} from \"../thread/ThreadMessages\";\n\nexport namespace PartPrimitiveMessages {\n export type Props =\n | {\n components: NonNullable<ThreadPrimitiveMessages.Props[\"components\"]>;\n children?: never;\n }\n | {\n /** Render function called for each message. Receives the message. */\n children: (value: { message: ThreadMessage }) => ReactNode;\n components?: never;\n };\n}\n\nconst usePartMessages = (): readonly ThreadMessage[] | undefined => {\n return useAuiState((s) => {\n const part = s.part;\n if (part.type !== \"tool-call\") return undefined;\n return \"messages\" in part\n ? (part.messages as readonly ThreadMessage[] | undefined)\n : undefined;\n });\n};\n\n/**\n * Renders the nested messages of a tool call part (e.g. sub-agent conversation).\n *\n * This primitive reads `messages` from the current tool call part in the PartScope\n * and renders them using a readonly thread context. All existing message and part\n * primitives work inside, and parent tool UI registrations are inherited.\n *\n * @example\n * ```tsx\n * const toolkit = defineToolkit({\n * invoke_sub_agent: {\n * type: \"backend\",\n * render: () => (\n * <PartPrimitive.Messages>\n * {({ message }) => {\n * if (message.role === \"user\") return <MyUserMessage />;\n * return <MyAssistantMessage />;\n * }}\n * </PartPrimitive.Messages>\n * ),\n * },\n * });\n * ```\n */\nexport const PartPrimitiveMessagesImpl: FC<PartPrimitiveMessages.Props> = ({\n components,\n children,\n}) => {\n const messages = usePartMessages();\n\n if (!messages?.length) return null;\n\n if (components) {\n return (\n <ReadonlyThreadProvider messages={messages}>\n <ThreadPrimitiveMessagesImpl components={components} />\n </ReadonlyThreadProvider>\n );\n }\n\n return (\n <ReadonlyThreadProvider messages={messages}>\n <ThreadPrimitiveMessagesImpl>{children}</ThreadPrimitiveMessagesImpl>\n </ReadonlyThreadProvider>\n );\n};\n\nPartPrimitiveMessagesImpl.displayName = \"PartPrimitive.Messages\";\n\nexport const PartPrimitiveMessages = memo(PartPrimitiveMessagesImpl);\n"],"mappings":";;;;;;;AAsBA,MAAMe,wBAAkB;CAAA,OACfZ,YAAYa,KAMlB;AAAC;;;;;;;;;;;;;;;;;;;;;;;;;AA2BJ,MAAaC,6BAA6DC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAV,YAAAE,aAAAM;CAIzE,MAAAG,WAAiBN,gBAAgB;CAEjC,IAAI,CAACM,UAAQC,QAAQ,OAAS;CAE9B,IAAIZ,YAAU;EAAA,IAAAa;EAAA,IAAAJ,EAAA,OAAAT,YAAA;GAGRa,KAAA,oBAAC,6BAAD,EAAyCb,WAAU,CAAA;GAAIS,EAAA,KAAAT;GAAAS,EAAA,KAAAI;EAAA,OAAAA,KAAAJ,EAAA;EAAA,IAAAK;EAAA,IAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,IAAA;GADzDC,KAAA,oBAAC,wBAAD;IAAkCH;cAChCE;GADqB,CAAA;GAEEJ,EAAA,KAAAE;GAAAF,EAAA,KAAAI;GAAAJ,EAAA,KAAAK;EAAA,OAAAA,KAAAL,EAAA;EAAA,OAFzBK;CAEyB;CAE5B,IAAAD;CAAA,IAAAJ,EAAA,OAAAP,UAAA;EAIGW,KAAA,oBAAC,6BAAD,EAA8BX,SAAF,CAAA;EAAyCO,EAAA,KAAAP;EAAAO,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,IAAA;EADvEC,KAAA,oBAAC,wBAAD;GAAkCH;aAChCE;EADqB,CAAA;EAEEJ,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFzBK;AAEyB;AAI7BP,0BAA0BQ,cAAc;AAExC,MAAajB,wBAAwBN,KAAKe,yBAAyB;AA3D3C,SAAAD,MAAAU,GAAA;CAEpB,MAAAC,OAAaD,EAACC;CACd,IAAIA,KAAIC,SAAU,aAAW;CAAmB,OACzC,cAAcD,OAChBA,KAAIN,WADFQ,KAAAA;AAEM"}
1
+ {"version":3,"file":"PartMessages.js","names":["FC","ReactNode","memo","useAuiState","ThreadMessage","ReadonlyThreadProvider","ThreadPrimitiveMessages","ThreadPrimitiveMessagesImpl","PartPrimitiveMessages","Props","components","NonNullable","children","value","message","usePartMessages","_temp","PartPrimitiveMessagesImpl","t0","$","_c","messages","length","t1","t2","displayName","s","part","type","undefined"],"sources":["../../../../src/react/primitives/part/PartMessages.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { ThreadMessage } from \"../../../types/message\";\nimport { ReadonlyThreadProvider } from \"../../providers/ReadonlyThreadProvider\";\nimport {\n type ThreadPrimitiveMessages,\n ThreadPrimitiveMessagesImpl,\n} from \"../thread/ThreadMessages\";\n\nexport namespace PartPrimitiveMessages {\n export type Props =\n | {\n components: NonNullable<ThreadPrimitiveMessages.Props[\"components\"]>;\n children?: never;\n }\n | {\n /** Render function called for each message. Receives the message. */\n children: (value: { message: ThreadMessage }) => ReactNode;\n components?: never;\n };\n}\n\nconst usePartMessages = (): readonly ThreadMessage[] | undefined => {\n return useAuiState((s) => {\n const part = s.part;\n if (part.type !== \"tool-call\") return undefined;\n return \"messages\" in part\n ? (part.messages as readonly ThreadMessage[] | undefined)\n : undefined;\n });\n};\n\n/**\n * Renders the nested messages of a tool call part (e.g. sub-agent conversation).\n *\n * This primitive reads `messages` from the current tool call part in the PartScope\n * and renders them using a readonly thread context. All existing message and part\n * primitives work inside, and parent tool UI registrations are inherited.\n *\n * @example\n * ```tsx\n * const toolkit = defineToolkit({\n * invoke_sub_agent: {\n * type: \"backend\",\n * render: () => (\n * <PartPrimitive.Messages>\n * {({ message }) => {\n * if (message.role === \"user\") return <MyUserMessage />;\n * return <MyAssistantMessage />;\n * }}\n * </PartPrimitive.Messages>\n * ),\n * },\n * });\n * ```\n */\nexport const PartPrimitiveMessagesImpl: FC<PartPrimitiveMessages.Props> = ({\n components,\n children,\n}) => {\n const messages = usePartMessages();\n\n if (!messages?.length) return null;\n\n if (components) {\n return (\n <ReadonlyThreadProvider messages={messages}>\n <ThreadPrimitiveMessagesImpl components={components} />\n </ReadonlyThreadProvider>\n );\n }\n\n return (\n <ReadonlyThreadProvider messages={messages}>\n <ThreadPrimitiveMessagesImpl>{children}</ThreadPrimitiveMessagesImpl>\n </ReadonlyThreadProvider>\n );\n};\n\nPartPrimitiveMessagesImpl.displayName = \"PartPrimitive.Messages\";\n\nexport const PartPrimitiveMessages = memo(PartPrimitiveMessagesImpl);\n"],"mappings":";;;;;;;AAsBA,MAAMe,wBAAkB;CAAA,OACfZ,YAAYa,KAMlB;AAAC;;;;;;;;;;;;;;;;;;;;;;;;;AA2BJ,MAAaC,6BAA6DC,OAAA;CAAA,MAAAC,IAAAC,EAAA,EAAA;CAAC,MAAA,EAAAV,YAAAE,aAAAM;CAIzE,MAAAG,WAAiBN,gBAAgB;CAEjC,IAAI,CAACM,UAAQC,QAAQ,OAAS;CAE9B,IAAIZ,YAAU;EAAA,IAAAa;EAAA,IAAAJ,EAAA,OAAAT,YAAA;GAGRa,KAAA,oBAAC,6BAAD,EAAyCb,WAAU,CAAA;GAAIS,EAAA,KAAAT;GAAAS,EAAA,KAAAI;EAAA,OAAAA,KAAAJ,EAAA;EAAA,IAAAK;EAAA,IAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,IAAA;GADzDC,KAAA,oBAAC,wBAAD;IAAkCH;IAChCE,UAAAA;GADqB,CAAA;GAEEJ,EAAA,KAAAE;GAAAF,EAAA,KAAAI;GAAAJ,EAAA,KAAAK;EAAA,OAAAA,KAAAL,EAAA;EAAA,OAFzBK;CAEyB;CAE5B,IAAAD;CAAA,IAAAJ,EAAA,OAAAP,UAAA;EAIGW,KAAA,oBAAC,6BAAD,EAA8BX,SAAF,CAAA;EAAyCO,EAAA,KAAAP;EAAAO,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAK;CAAA,IAAAL,EAAA,OAAAE,YAAAF,EAAA,OAAAI,IAAA;EADvEC,KAAA,oBAAC,wBAAD;GAAkCH;GAChCE,UAAAA;EADqB,CAAA;EAEEJ,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OAFzBK;AAEyB;AAI7BP,0BAA0BQ,cAAc;AAExC,MAAajB,wBAAwBN,KAAKe,yBAAyB;AA3D3C,SAAAD,MAAAU,GAAA;CAEpB,MAAAC,OAAaD,EAACC;CACd,IAAIA,KAAIC,SAAU,aAAW;CAAmB,OACzC,cAAcD,OAChBA,KAAIN,WADFQ,KAAAA;AAEM"}
@@ -1 +1 @@
1
- {"version":3,"file":"ThreadMessages.js","names":["ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","MessageByIndexProvider","MessageByIdProvider","MessageState","MessagesComponentConfig","Message","EditComposer","UserEditComposer","AssistantEditComposer","SystemEditComposer","UserMessage","AssistantMessage","SystemMessage","ThreadPrimitiveMessages","Props","components","children","value","message","isComponentsSame","prev","next","DEFAULT_SYSTEM_MESSAGE","messageIdSetCache","WeakMap","ReadonlySet","hasMessageId","messages","messageId","ids","get","Set","map","m","id","set","has","getComponent","role","isEditing","_exhaustiveCheck","Error","ThreadMessageComponentProps","ThreadMessageComponent","t0","$","_c","_temp","_temp2","t1","Component","t2","ThreadPrimitiveMessageByIndex","index","displayName","ThreadPrimitiveUnstable_MessageById","s","thread","exists","t3","ThreadPrimitiveMessagesInner","messagesLength","length","Array","from","_","aui","getState","getItem","ThreadPrimitiveMessagesImpl","s_0","composer"],"sources":["../../../../src/react/primitives/thread/ThreadMessages.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageByIndexProvider } from \"../../providers/MessageByIndexProvider\";\nimport { MessageByIdProvider } from \"../../providers/MessageByIdProvider\";\nimport type { MessageState } from \"../../../store\";\n\ntype MessagesComponentConfig =\n | {\n /** Component used to render all message types */\n Message: ComponentType;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages specifically */\n UserMessage?: ComponentType | undefined;\n /** Component used to render assistant messages specifically */\n AssistantMessage?: ComponentType | undefined;\n /** Component used to render system messages specifically */\n SystemMessage?: ComponentType | undefined;\n }\n | {\n /** Component used to render all message types (fallback) */\n Message?: ComponentType | undefined;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages */\n UserMessage: ComponentType;\n /** Component used to render assistant messages */\n AssistantMessage: ComponentType;\n /** Component used to render system messages */\n SystemMessage?: ComponentType | undefined;\n };\n\nexport namespace ThreadPrimitiveMessages {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessagesComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each message. Receives the message. */\n children: (value: { message: MessageState }) => ReactNode;\n components?: never;\n };\n}\n\nconst isComponentsSame = (\n prev: MessagesComponentConfig,\n next: MessagesComponentConfig,\n) => {\n return (\n prev.Message === next.Message &&\n prev.EditComposer === next.EditComposer &&\n prev.UserEditComposer === next.UserEditComposer &&\n prev.AssistantEditComposer === next.AssistantEditComposer &&\n prev.SystemEditComposer === next.SystemEditComposer &&\n prev.UserMessage === next.UserMessage &&\n prev.AssistantMessage === next.AssistantMessage &&\n prev.SystemMessage === next.SystemMessage\n );\n};\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\n\nconst messageIdSetCache = new WeakMap<\n readonly MessageState[],\n ReadonlySet<string>\n>();\n\nconst hasMessageId = (messages: readonly MessageState[], messageId: string) => {\n let ids = messageIdSetCache.get(messages);\n if (!ids) {\n ids = new Set(messages.map((m) => m.id));\n messageIdSetCache.set(messages, ids);\n }\n return ids.has(messageId);\n};\n\nconst getComponent = (\n components: MessagesComponentConfig,\n role: MessageState[\"role\"],\n isEditing: boolean,\n) => {\n switch (role) {\n case \"user\":\n if (isEditing) {\n return (\n components.UserEditComposer ??\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.UserMessage ?? (components.Message as ComponentType);\n }\n case \"assistant\":\n if (isEditing) {\n return (\n components.AssistantEditComposer ??\n components.EditComposer ??\n components.AssistantMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.AssistantMessage ?? (components.Message as ComponentType)\n );\n }\n case \"system\":\n if (isEditing) {\n return (\n components.SystemEditComposer ??\n components.EditComposer ??\n components.SystemMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.SystemMessage ??\n (components.Message as ComponentType) ??\n DEFAULT_SYSTEM_MESSAGE\n );\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unknown message role: ${_exhaustiveCheck}`);\n }\n }\n};\n\ntype ThreadMessageComponentProps = {\n components: MessagesComponentConfig;\n};\n\nconst ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({\n components,\n}) => {\n const role = useAuiState((s) => s.message.role);\n const isEditing = useAuiState((s) => s.message.composer.isEditing);\n const Component = getComponent(components, role, isEditing);\n\n return <Component />;\n};\nexport namespace ThreadPrimitiveMessageByIndex {\n export type Props = {\n index: number;\n components: MessagesComponentConfig;\n };\n}\n\n/**\n * Renders a single message at the specified index in the current thread.\n */\nexport const ThreadPrimitiveMessageByIndex: FC<ThreadPrimitiveMessageByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageByIndexProvider index={index}>\n <ThreadMessageComponent components={components} />\n </MessageByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n isComponentsSame(prev.components, next.components),\n );\n\nThreadPrimitiveMessageByIndex.displayName = \"ThreadPrimitive.MessageByIndex\";\n\nexport namespace ThreadPrimitiveUnstable_MessageById {\n export type Props = {\n messageId: string;\n components: MessagesComponentConfig;\n };\n}\n\n/**\n * Renders the message with the given id in the current thread.\n *\n * Unlike {@link ThreadPrimitiveMessageByIndex}, this keys off the message id,\n * so it stays attached to the same message across reordering and windowing -\n * the shape needed to drive a virtualized or custom message list together with\n * `unstable_useThreadMessageIds`. A missing or removed id renders `null` rather\n * than throwing.\n *\n * @deprecated Unstable / Experimental - may change in any release.\n *\n * @example\n * ```tsx\n * const messageIds = unstable_useThreadMessageIds();\n * return messageIds.map((messageId) => (\n * <ThreadPrimitive.Unstable_MessageById\n * key={messageId}\n * messageId={messageId}\n * components={MESSAGE_COMPONENTS}\n * />\n * ));\n * ```\n */\nexport const ThreadPrimitiveUnstable_MessageById: FC<ThreadPrimitiveUnstable_MessageById.Props> =\n memo(\n ({ messageId, components }) => {\n const exists = useAuiState((s) =>\n hasMessageId(s.thread.messages, messageId),\n );\n if (!exists) return null;\n\n return (\n <MessageByIdProvider id={messageId}>\n <ThreadMessageComponent components={components} />\n </MessageByIdProvider>\n );\n },\n (prev, next) =>\n prev.messageId === next.messageId &&\n isComponentsSame(prev.components, next.components),\n );\n\nThreadPrimitiveUnstable_MessageById.displayName =\n \"ThreadPrimitive.Unstable_MessageById\";\n\nconst ThreadPrimitiveMessagesInner: FC<{\n children: (value: { message: MessageState }) => ReactNode;\n}> = ({ children }) => {\n const messagesLength = useAuiState((s) => s.thread.messages.length);\n\n return useMemo(() => {\n if (messagesLength === 0) return null;\n return Array.from({ length: messagesLength }, (_, index) => (\n <MessageByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) => aui.thread().message({ index }).getState()}\n >\n {(getItem) =>\n children({\n get message() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageByIndexProvider>\n ));\n }, [messagesLength, children]);\n};\n\n/**\n * Renders all messages in the current thread.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Messages>\n * {({ message }) => {\n * if (message.role === \"user\") return <MyUserMessage />;\n * return <MyAssistantMessage />;\n * }}\n * </ThreadPrimitive.Messages>\n * ```\n */\nexport const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({\n components,\n children,\n}) => {\n if (components) {\n return (\n <ThreadPrimitiveMessagesInner>\n {() => <ThreadMessageComponent components={components} />}\n </ThreadPrimitiveMessagesInner>\n );\n }\n return (\n <ThreadPrimitiveMessagesInner>{children}</ThreadPrimitiveMessagesInner>\n );\n};\n\nThreadPrimitiveMessagesImpl.displayName = \"ThreadPrimitive.Messages\";\n\nexport const ThreadPrimitiveMessages = memo(\n ThreadPrimitiveMessagesImpl,\n (prev, next) => {\n if (prev.children || next.children) {\n return prev.children === next.children;\n }\n return isComponentsSame(prev.components!, next.components!);\n },\n);\n"],"mappings":";;;;;;;AAgEA,MAAMyB,oBACJC,MACAC,SACG;CACH,OACED,KAAKf,YAAYgB,KAAKhB,WACtBe,KAAKd,iBAAiBe,KAAKf,gBAC3Bc,KAAKb,qBAAqBc,KAAKd,oBAC/Ba,KAAKZ,0BAA0Ba,KAAKb,yBACpCY,KAAKX,uBAAuBY,KAAKZ,sBACjCW,KAAKV,gBAAgBW,KAAKX,eAC1BU,KAAKT,qBAAqBU,KAAKV,oBAC/BS,KAAKR,kBAAkBS,KAAKT;AAEhC;AAEA,MAAMU,+BAA+B;AAErC,MAAMC,oCAAoB,IAAIC,QAG5B;AAEF,MAAME,gBAAgBC,UAAmCC,cAAsB;CAC7E,IAAIC,MAAMN,kBAAkBO,IAAIH,QAAQ;CACxC,IAAI,CAACE,KAAK;EACRA,MAAM,IAAIE,IAAIJ,SAASK,KAAKC,MAAMA,EAAEC,EAAE,CAAC;EACvCX,kBAAkBY,IAAIR,UAAUE,GAAG;CACrC;CACA,OAAOA,IAAIO,IAAIR,SAAS;AAC1B;AAEA,MAAMS,gBACJtB,YACAuB,MACAC,cACG;CACH,QAAQD,MAAR;EACE,KAAK,QACH,IAAIC,WACF,OACExB,WAAWR,oBACXQ,WAAWT,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CACd,IAAID,KAAKJ,YAAYK,KAAKL,UACxB,OAAOI,KAAKJ,aAAaK,KAAKL;CAEhC,OAAOG,iBAAiBC,KAAKL,YAAaM,KAAKN,UAAW;AAC5D,CACF;AAvJgE,SAAAgC,MAAAS,GAAA;CAAA,OAG9BA,EAACtC,QAAQoB;AAAK;AAHgB,SAAAU,OAAAsB,KAAA;CAAA,OAIzBd,IAACtC,QAAQqD,SAAShC;AAAU"}
1
+ {"version":3,"file":"ThreadMessages.js","names":["ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","MessageByIndexProvider","MessageByIdProvider","MessageState","MessagesComponentConfig","Message","EditComposer","UserEditComposer","AssistantEditComposer","SystemEditComposer","UserMessage","AssistantMessage","SystemMessage","ThreadPrimitiveMessages","Props","components","children","value","message","isComponentsSame","prev","next","DEFAULT_SYSTEM_MESSAGE","messageIdSetCache","WeakMap","ReadonlySet","hasMessageId","messages","messageId","ids","get","Set","map","m","id","set","has","getComponent","role","isEditing","_exhaustiveCheck","Error","ThreadMessageComponentProps","ThreadMessageComponent","t0","$","_c","_temp","_temp2","t1","Component","t2","ThreadPrimitiveMessageByIndex","index","displayName","ThreadPrimitiveUnstable_MessageById","s","thread","exists","t3","ThreadPrimitiveMessagesInner","messagesLength","length","Array","from","_","aui","getState","getItem","ThreadPrimitiveMessagesImpl","s_0","composer"],"sources":["../../../../src/react/primitives/thread/ThreadMessages.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageByIndexProvider } from \"../../providers/MessageByIndexProvider\";\nimport { MessageByIdProvider } from \"../../providers/MessageByIdProvider\";\nimport type { MessageState } from \"../../../store\";\n\ntype MessagesComponentConfig =\n | {\n /** Component used to render all message types */\n Message: ComponentType;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages specifically */\n UserMessage?: ComponentType | undefined;\n /** Component used to render assistant messages specifically */\n AssistantMessage?: ComponentType | undefined;\n /** Component used to render system messages specifically */\n SystemMessage?: ComponentType | undefined;\n }\n | {\n /** Component used to render all message types (fallback) */\n Message?: ComponentType | undefined;\n /** Component used when editing any message type */\n EditComposer?: ComponentType | undefined;\n /** Component used when editing user messages specifically */\n UserEditComposer?: ComponentType | undefined;\n /** Component used when editing assistant messages specifically */\n AssistantEditComposer?: ComponentType | undefined;\n /** Component used when editing system messages specifically */\n SystemEditComposer?: ComponentType | undefined;\n /** Component used to render user messages */\n UserMessage: ComponentType;\n /** Component used to render assistant messages */\n AssistantMessage: ComponentType;\n /** Component used to render system messages */\n SystemMessage?: ComponentType | undefined;\n };\n\nexport namespace ThreadPrimitiveMessages {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessagesComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each message. Receives the message. */\n children: (value: { message: MessageState }) => ReactNode;\n components?: never;\n };\n}\n\nconst isComponentsSame = (\n prev: MessagesComponentConfig,\n next: MessagesComponentConfig,\n) => {\n return (\n prev.Message === next.Message &&\n prev.EditComposer === next.EditComposer &&\n prev.UserEditComposer === next.UserEditComposer &&\n prev.AssistantEditComposer === next.AssistantEditComposer &&\n prev.SystemEditComposer === next.SystemEditComposer &&\n prev.UserMessage === next.UserMessage &&\n prev.AssistantMessage === next.AssistantMessage &&\n prev.SystemMessage === next.SystemMessage\n );\n};\n\nconst DEFAULT_SYSTEM_MESSAGE = () => null;\n\nconst messageIdSetCache = new WeakMap<\n readonly MessageState[],\n ReadonlySet<string>\n>();\n\nconst hasMessageId = (messages: readonly MessageState[], messageId: string) => {\n let ids = messageIdSetCache.get(messages);\n if (!ids) {\n ids = new Set(messages.map((m) => m.id));\n messageIdSetCache.set(messages, ids);\n }\n return ids.has(messageId);\n};\n\nconst getComponent = (\n components: MessagesComponentConfig,\n role: MessageState[\"role\"],\n isEditing: boolean,\n) => {\n switch (role) {\n case \"user\":\n if (isEditing) {\n return (\n components.UserEditComposer ??\n components.EditComposer ??\n components.UserMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return components.UserMessage ?? (components.Message as ComponentType);\n }\n case \"assistant\":\n if (isEditing) {\n return (\n components.AssistantEditComposer ??\n components.EditComposer ??\n components.AssistantMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.AssistantMessage ?? (components.Message as ComponentType)\n );\n }\n case \"system\":\n if (isEditing) {\n return (\n components.SystemEditComposer ??\n components.EditComposer ??\n components.SystemMessage ??\n (components.Message as ComponentType)\n );\n } else {\n return (\n components.SystemMessage ??\n (components.Message as ComponentType) ??\n DEFAULT_SYSTEM_MESSAGE\n );\n }\n default: {\n const _exhaustiveCheck: never = role;\n throw new Error(`Unknown message role: ${_exhaustiveCheck}`);\n }\n }\n};\n\ntype ThreadMessageComponentProps = {\n components: MessagesComponentConfig;\n};\n\nconst ThreadMessageComponent: FC<ThreadMessageComponentProps> = ({\n components,\n}) => {\n const role = useAuiState((s) => s.message.role);\n const isEditing = useAuiState((s) => s.message.composer.isEditing);\n const Component = getComponent(components, role, isEditing);\n\n return <Component />;\n};\nexport namespace ThreadPrimitiveMessageByIndex {\n export type Props = {\n index: number;\n components: MessagesComponentConfig;\n };\n}\n\n/**\n * Renders a single message at the specified index in the current thread.\n */\nexport const ThreadPrimitiveMessageByIndex: FC<ThreadPrimitiveMessageByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageByIndexProvider index={index}>\n <ThreadMessageComponent components={components} />\n </MessageByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n isComponentsSame(prev.components, next.components),\n );\n\nThreadPrimitiveMessageByIndex.displayName = \"ThreadPrimitive.MessageByIndex\";\n\nexport namespace ThreadPrimitiveUnstable_MessageById {\n export type Props = {\n messageId: string;\n components: MessagesComponentConfig;\n };\n}\n\n/**\n * Renders the message with the given id in the current thread.\n *\n * Unlike {@link ThreadPrimitiveMessageByIndex}, this keys off the message id,\n * so it stays attached to the same message across reordering and windowing -\n * the shape needed to drive a virtualized or custom message list together with\n * `unstable_useThreadMessageIds`. A missing or removed id renders `null` rather\n * than throwing.\n *\n * @deprecated Unstable / Experimental - may change in any release.\n *\n * @example\n * ```tsx\n * const messageIds = unstable_useThreadMessageIds();\n * return messageIds.map((messageId) => (\n * <ThreadPrimitive.Unstable_MessageById\n * key={messageId}\n * messageId={messageId}\n * components={MESSAGE_COMPONENTS}\n * />\n * ));\n * ```\n */\nexport const ThreadPrimitiveUnstable_MessageById: FC<ThreadPrimitiveUnstable_MessageById.Props> =\n memo(\n ({ messageId, components }) => {\n const exists = useAuiState((s) =>\n hasMessageId(s.thread.messages, messageId),\n );\n if (!exists) return null;\n\n return (\n <MessageByIdProvider id={messageId}>\n <ThreadMessageComponent components={components} />\n </MessageByIdProvider>\n );\n },\n (prev, next) =>\n prev.messageId === next.messageId &&\n isComponentsSame(prev.components, next.components),\n );\n\nThreadPrimitiveUnstable_MessageById.displayName =\n \"ThreadPrimitive.Unstable_MessageById\";\n\nconst ThreadPrimitiveMessagesInner: FC<{\n children: (value: { message: MessageState }) => ReactNode;\n}> = ({ children }) => {\n const messagesLength = useAuiState((s) => s.thread.messages.length);\n\n return useMemo(() => {\n if (messagesLength === 0) return null;\n return Array.from({ length: messagesLength }, (_, index) => (\n <MessageByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) => aui.thread().message({ index }).getState()}\n >\n {(getItem) =>\n children({\n get message() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageByIndexProvider>\n ));\n }, [messagesLength, children]);\n};\n\n/**\n * Renders all messages in the current thread.\n *\n * @example\n * ```tsx\n * <ThreadPrimitive.Messages>\n * {({ message }) => {\n * if (message.role === \"user\") return <MyUserMessage />;\n * return <MyAssistantMessage />;\n * }}\n * </ThreadPrimitive.Messages>\n * ```\n */\nexport const ThreadPrimitiveMessagesImpl: FC<ThreadPrimitiveMessages.Props> = ({\n components,\n children,\n}) => {\n if (components) {\n return (\n <ThreadPrimitiveMessagesInner>\n {() => <ThreadMessageComponent components={components} />}\n </ThreadPrimitiveMessagesInner>\n );\n }\n return (\n <ThreadPrimitiveMessagesInner>{children}</ThreadPrimitiveMessagesInner>\n );\n};\n\nThreadPrimitiveMessagesImpl.displayName = \"ThreadPrimitive.Messages\";\n\nexport const ThreadPrimitiveMessages = memo(\n ThreadPrimitiveMessagesImpl,\n (prev, next) => {\n if (prev.children || next.children) {\n return prev.children === next.children;\n }\n return isComponentsSame(prev.components!, next.components!);\n },\n);\n"],"mappings":";;;;;;;AAgEA,MAAMyB,oBACJC,MACAC,SACG;CACH,OACED,KAAKf,YAAYgB,KAAKhB,WACtBe,KAAKd,iBAAiBe,KAAKf,gBAC3Bc,KAAKb,qBAAqBc,KAAKd,oBAC/Ba,KAAKZ,0BAA0Ba,KAAKb,yBACpCY,KAAKX,uBAAuBY,KAAKZ,sBACjCW,KAAKV,gBAAgBW,KAAKX,eAC1BU,KAAKT,qBAAqBU,KAAKV,oBAC/BS,KAAKR,kBAAkBS,KAAKT;AAEhC;AAEA,MAAMU,+BAA+B;AAErC,MAAMC,oCAAoB,IAAIC,QAG5B;AAEF,MAAME,gBAAgBC,UAAmCC,cAAsB;CAC7E,IAAIC,MAAMN,kBAAkBO,IAAIH,QAAQ;CACxC,IAAI,CAACE,KAAK;EACRA,MAAM,IAAIE,IAAIJ,SAASK,KAAKC,MAAMA,EAAEC,EAAE,CAAC;EACvCX,kBAAkBY,IAAIR,UAAUE,GAAG;CACrC;CACA,OAAOA,IAAIO,IAAIR,SAAS;AAC1B;AAEA,MAAMS,gBACJtB,YACAuB,MACAC,cACG;CACH,QAAQD,MAAR;EACE,KAAK,QACH,IAAIC,WACF,OACExB,WA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