@assistant-ui/core 0.2.12 → 0.2.15

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 (445) hide show
  1. package/dist/adapters/attachment.js.map +1 -1
  2. package/dist/adapters/directive-formatter.js.map +1 -1
  3. package/dist/adapters/speech.js.map +1 -1
  4. package/dist/adapters/thread-history.d.ts +3 -1
  5. package/dist/adapters/thread-history.d.ts.map +1 -1
  6. package/dist/adapters/voice.js.map +1 -1
  7. package/dist/index.d.ts +3 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/duplicate-detection.js.map +1 -1
  10. package/dist/internal.d.ts +2 -1
  11. package/dist/internal.js +2 -1
  12. package/dist/model-context/frame/host.js.map +1 -1
  13. package/dist/model-context/frame/provider.js.map +1 -1
  14. package/dist/model-context/frame/types.js.map +1 -1
  15. package/dist/model-context/registry.js.map +1 -1
  16. package/dist/model-context/tool.js.map +1 -1
  17. package/dist/model-context/types.d.ts +1 -0
  18. package/dist/model-context/types.d.ts.map +1 -1
  19. package/dist/model-context/types.js.map +1 -1
  20. package/dist/react/AssistantProvider.js +7 -1
  21. package/dist/react/AssistantProvider.js.map +1 -1
  22. package/dist/react/AssistantRuntimeProvider.js +18 -6
  23. package/dist/react/AssistantRuntimeProvider.js.map +1 -1
  24. package/dist/react/RuntimeAdapter.d.ts +1 -1
  25. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  26. package/dist/react/RuntimeAdapter.js +35 -6
  27. package/dist/react/RuntimeAdapter.js.map +1 -1
  28. package/dist/react/adapters/LocalStorageThreadListAdapter.js +29 -7
  29. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  30. package/dist/react/adapters/TitleGenerationAdapter.js.map +1 -1
  31. package/dist/react/client/DataRenderers.d.ts +1 -8
  32. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  33. package/dist/react/client/DataRenderers.js +56 -36
  34. package/dist/react/client/DataRenderers.js.map +1 -1
  35. package/dist/react/client/Interactables.d.ts +1 -1
  36. package/dist/react/client/Interactables.d.ts.map +1 -1
  37. package/dist/react/client/Interactables.js +71 -70
  38. package/dist/react/client/Interactables.js.map +1 -1
  39. package/dist/react/client/Tools.d.ts +2 -13
  40. package/dist/react/client/Tools.d.ts.map +1 -1
  41. package/dist/react/client/Tools.js +121 -57
  42. package/dist/react/client/Tools.js.map +1 -1
  43. package/dist/react/client/interactable-model-context.js.map +1 -1
  44. package/dist/react/model-context/define-mcp-toolkit.js.map +1 -1
  45. package/dist/react/model-context/define-toolkit.js.map +1 -1
  46. package/dist/react/model-context/external-tool.js.map +1 -1
  47. package/dist/react/model-context/human-tool.js.map +1 -1
  48. package/dist/react/model-context/makeAssistantDataUI.js.map +1 -1
  49. package/dist/react/model-context/makeAssistantTool.js.map +1 -1
  50. package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
  51. package/dist/react/model-context/provider-tool.js.map +1 -1
  52. package/dist/react/model-context/stub-tool.js.map +1 -1
  53. package/dist/react/model-context/toolbox.js.map +1 -1
  54. package/dist/react/model-context/useAssistantContext.js.map +1 -1
  55. package/dist/react/model-context/useAssistantDataUI.js +27 -8
  56. package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
  57. package/dist/react/model-context/useAssistantInstructions.js +33 -10
  58. package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
  59. package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
  60. package/dist/react/model-context/useAssistantTool.js +59 -17
  61. package/dist/react/model-context/useAssistantTool.js.map +1 -1
  62. package/dist/react/model-context/useAssistantToolUI.js +30 -9
  63. package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
  64. package/dist/react/model-context/useAuiToolOverrides.js.map +1 -1
  65. package/dist/react/model-context/useInlineRender.js +35 -8
  66. package/dist/react/model-context/useInlineRender.js.map +1 -1
  67. package/dist/react/model-context/useInteractableState.js +65 -19
  68. package/dist/react/model-context/useInteractableState.js.map +1 -1
  69. package/dist/react/model-context/useToolArgsStatus.js +42 -14
  70. package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
  71. package/dist/react/primitive-hooks/useActionBarCopy.js +59 -22
  72. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  73. package/dist/react/primitive-hooks/useActionBarEdit.js +25 -7
  74. package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
  75. package/dist/react/primitive-hooks/useActionBarFeedback.js +49 -13
  76. package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
  77. package/dist/react/primitive-hooks/useActionBarReload.js +25 -7
  78. package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
  79. package/dist/react/primitive-hooks/useActionBarSpeak.js +28 -9
  80. package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
  81. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +25 -7
  82. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
  83. package/dist/react/primitive-hooks/useBranchPickerNext.js +27 -11
  84. package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
  85. package/dist/react/primitive-hooks/useBranchPickerPrevious.js +27 -11
  86. package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
  87. package/dist/react/primitive-hooks/useComposerAddAttachment.js +24 -8
  88. package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
  89. package/dist/react/primitive-hooks/useComposerCancel.js +25 -7
  90. package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
  91. package/dist/react/primitive-hooks/useComposerDictate.js +25 -7
  92. package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
  93. package/dist/react/primitive-hooks/useComposerSend.js +25 -7
  94. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  95. package/dist/react/primitive-hooks/useEditComposerCancel.js +18 -4
  96. package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
  97. package/dist/react/primitive-hooks/useEditComposerSend.js +25 -7
  98. package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
  99. package/dist/react/primitive-hooks/useMessageBranching.js +41 -9
  100. package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
  101. package/dist/react/primitive-hooks/useMessageError.js +4 -1
  102. package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
  103. package/dist/react/primitive-hooks/useMessageReload.js +25 -7
  104. package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
  105. package/dist/react/primitive-hooks/useSuggestionTrigger.js +31 -13
  106. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  107. package/dist/react/primitive-hooks/useThreadIsEmpty.js +4 -1
  108. package/dist/react/primitive-hooks/useThreadIsEmpty.js.map +1 -1
  109. package/dist/react/primitive-hooks/useThreadIsRunning.js +4 -1
  110. package/dist/react/primitive-hooks/useThreadIsRunning.js.map +1 -1
  111. package/dist/react/primitive-hooks/useThreadListItemArchive.js +18 -4
  112. package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
  113. package/dist/react/primitive-hooks/useThreadListItemDelete.js +18 -4
  114. package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
  115. package/dist/react/primitive-hooks/useThreadListItemTrigger.js +18 -4
  116. package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
  117. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +18 -4
  118. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
  119. package/dist/react/primitive-hooks/useThreadListLoadMore.js +25 -7
  120. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
  121. package/dist/react/primitive-hooks/useThreadListNew.js +18 -4
  122. package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
  123. package/dist/react/primitive-hooks/useThreadMessages.js +4 -1
  124. package/dist/react/primitive-hooks/useThreadMessages.js.map +1 -1
  125. package/dist/react/primitive-hooks/useVoice.js +63 -13
  126. package/dist/react/primitive-hooks/useVoice.js.map +1 -1
  127. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +42 -7
  128. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
  129. package/dist/react/primitives/composer/ComposerAttachments.js +67 -16
  130. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
  131. package/dist/react/primitives/composer/ComposerIf.js +30 -9
  132. package/dist/react/primitives/composer/ComposerIf.js.map +1 -1
  133. package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
  134. package/dist/react/primitives/generativeUI/GenerativeUI.js +55 -13
  135. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  136. package/dist/react/primitives/message/MessageAttachments.js +68 -16
  137. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  138. package/dist/react/primitives/message/MessageGroupedParts.d.ts +3 -2
  139. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  140. package/dist/react/primitives/message/MessageGroupedParts.js +6 -6
  141. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  142. package/dist/react/primitives/message/MessageParts.d.ts +28 -1
  143. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  144. package/dist/react/primitives/message/MessageParts.js +665 -163
  145. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  146. package/dist/react/primitives/message/MessageQuote.js +18 -2
  147. package/dist/react/primitives/message/MessageQuote.js.map +1 -1
  148. package/dist/react/primitives/messagePart/MessagePartInProgress.js +6 -2
  149. package/dist/react/primitives/messagePart/MessagePartInProgress.js.map +1 -1
  150. package/dist/react/primitives/part/PartMessages.js +46 -14
  151. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  152. package/dist/react/primitives/thread/ThreadMessages.js +67 -10
  153. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  154. package/dist/react/primitives/thread/ThreadSuggestions.js +50 -10
  155. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  156. package/dist/react/primitives/threadList/ThreadListItems.js +55 -14
  157. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
  158. package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +15 -2
  159. package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
  160. package/dist/react/providers/AttachmentByIndexProvider.js +57 -12
  161. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
  162. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +33 -11
  163. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
  164. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +29 -6
  165. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  166. package/dist/react/providers/MessageByIndexProvider.js +49 -19
  167. package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
  168. package/dist/react/providers/PartByIndexProvider.js +29 -6
  169. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  170. package/dist/react/providers/QueueItemByIndexProvider.js +29 -6
  171. package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
  172. package/dist/react/providers/ReadonlyThreadProvider.js +83 -28
  173. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  174. package/dist/react/providers/SuggestionByIndexProvider.js +29 -6
  175. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
  176. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  177. package/dist/react/providers/TextMessagePartProvider.js +75 -26
  178. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  179. package/dist/react/providers/ThreadListItemByIndexProvider.js +30 -6
  180. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
  181. package/dist/react/providers/ThreadListItemRuntimeProvider.js +28 -5
  182. package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -1
  183. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -0
  184. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  185. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +19 -4
  186. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  187. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
  188. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  189. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -0
  190. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  191. package/dist/react/runtimes/RuntimeAdapterProvider.js +27 -10
  192. package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -1
  193. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  194. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +16 -1
  195. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  196. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  197. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  198. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  199. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +19 -17
  200. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  201. package/dist/react/runtimes/createMessageConverter.js.map +1 -1
  202. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  203. package/dist/react/runtimes/external-message-converter.js +67 -30
  204. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  205. package/dist/react/runtimes/useExternalStoreRuntime.js +44 -10
  206. package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
  207. package/dist/react/runtimes/useExternalStoreSharedOptions.js +17 -12
  208. package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
  209. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  210. package/dist/react/runtimes/useRemoteThreadListRuntime.js +34 -6
  211. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  212. package/dist/react/types/MessagePartComponentTypes.d.ts +5 -6
  213. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
  214. package/dist/react/utils/getMessageQuote.js.map +1 -1
  215. package/dist/react/utils/groupParts.d.ts +13 -1
  216. package/dist/react/utils/groupParts.d.ts.map +1 -1
  217. package/dist/react/utils/groupParts.js +17 -5
  218. package/dist/react/utils/groupParts.js.map +1 -1
  219. package/dist/runtime/api/assistant-runtime.js.map +1 -1
  220. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  221. package/dist/runtime/api/bindings.d.ts +1 -0
  222. package/dist/runtime/api/bindings.d.ts.map +1 -1
  223. package/dist/runtime/api/composer-runtime.js.map +1 -1
  224. package/dist/runtime/api/message-part-runtime.d.ts +3 -9
  225. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  226. package/dist/runtime/api/message-part-runtime.js +3 -6
  227. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  228. package/dist/runtime/api/message-runtime.d.ts +2 -0
  229. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  230. package/dist/runtime/api/message-runtime.js +5 -0
  231. package/dist/runtime/api/message-runtime.js.map +1 -1
  232. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  233. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  234. package/dist/runtime/api/thread-list-runtime.js +1 -0
  235. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  236. package/dist/runtime/api/thread-runtime.d.ts +3 -0
  237. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  238. package/dist/runtime/api/thread-runtime.js +4 -0
  239. package/dist/runtime/api/thread-runtime.js.map +1 -1
  240. package/dist/runtime/base/base-assistant-runtime-core.js.map +1 -1
  241. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  242. package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -0
  243. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  244. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  245. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  246. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  247. package/dist/runtime/branch/external-thread-branch-adapter.d.ts +30 -0
  248. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -0
  249. package/dist/runtime/branch/external-thread-branch-adapter.js +0 -0
  250. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
  251. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  252. package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -1
  253. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  254. package/dist/runtime/queue/message-queue.js.map +1 -1
  255. package/dist/runtime/utils/auto-status.js.map +1 -1
  256. package/dist/runtime/utils/external-store-message.js.map +1 -1
  257. package/dist/runtime/utils/message-repository.js.map +1 -1
  258. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +15 -0
  259. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -0
  260. package/dist/runtime/utils/resolveToolApprovalResponse.js +35 -0
  261. package/dist/runtime/utils/resolveToolApprovalResponse.js.map +1 -0
  262. package/dist/runtime/utils/thread-message-like.d.ts +5 -1
  263. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  264. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  265. package/dist/runtimes/assistant-transport/utils.js.map +1 -1
  266. package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -0
  267. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  268. package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
  269. package/dist/runtimes/external-store/external-store-shared-options.js.map +1 -1
  270. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  271. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +1 -0
  272. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  273. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +13 -0
  274. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  275. package/dist/runtimes/external-store/thread-message-converter.js.map +1 -1
  276. package/dist/runtimes/local/local-runtime-core.js.map +1 -1
  277. package/dist/runtimes/local/local-runtime-options.d.ts +1 -1
  278. package/dist/runtimes/local/local-thread-list-runtime-core.js.map +1 -1
  279. package/dist/runtimes/local/local-thread-runtime-core.d.ts +9 -1
  280. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  281. package/dist/runtimes/local/local-thread-runtime-core.js +65 -5
  282. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  283. package/dist/runtimes/local/should-continue.js +4 -2
  284. package/dist/runtimes/local/should-continue.js.map +1 -1
  285. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +2 -0
  286. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  287. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +4 -0
  288. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  289. package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
  290. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  291. package/dist/runtimes/remote-thread-list/empty-thread-core.js +4 -0
  292. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  293. package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
  294. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +1 -0
  295. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  296. package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -0
  297. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  298. package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
  299. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  300. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  301. package/dist/store/clients/chain-of-thought-client.d.ts +2 -7
  302. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  303. package/dist/store/clients/chain-of-thought-client.js +39 -20
  304. package/dist/store/clients/chain-of-thought-client.js.map +1 -1
  305. package/dist/store/clients/model-context-client.d.ts +1 -1
  306. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  307. package/dist/store/clients/model-context-client.js +67 -16
  308. package/dist/store/clients/model-context-client.js.map +1 -1
  309. package/dist/store/clients/no-op-composer-client.d.ts +2 -4
  310. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  311. package/dist/store/clients/no-op-composer-client.js +96 -54
  312. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  313. package/dist/store/clients/runtime-adapter.d.ts +1 -3
  314. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  315. package/dist/store/clients/runtime-adapter.js +2 -15
  316. package/dist/store/clients/runtime-adapter.js.map +1 -1
  317. package/dist/store/clients/suggestions.d.ts +1 -4
  318. package/dist/store/clients/suggestions.d.ts.map +1 -1
  319. package/dist/store/clients/suggestions.js +63 -23
  320. package/dist/store/clients/suggestions.js.map +1 -1
  321. package/dist/store/clients/thread-message-client.d.ts +1 -1
  322. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  323. package/dist/store/clients/thread-message-client.js +184 -73
  324. package/dist/store/clients/thread-message-client.js.map +1 -1
  325. package/dist/store/internal.d.ts +2 -2
  326. package/dist/store/internal.js +2 -2
  327. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +2 -4
  328. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  329. package/dist/store/runtime-clients/attachment-runtime-client.js +31 -7
  330. package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
  331. package/dist/store/runtime-clients/composer-runtime-client.d.ts +2 -10
  332. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  333. package/dist/store/runtime-clients/composer-runtime-client.js +195 -72
  334. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  335. package/dist/store/runtime-clients/liveRef.d.ts +7 -0
  336. package/dist/store/runtime-clients/liveRef.d.ts.map +1 -0
  337. package/dist/store/runtime-clients/liveRef.js +8 -0
  338. package/dist/store/runtime-clients/liveRef.js.map +1 -0
  339. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +2 -4
  340. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  341. package/dist/store/runtime-clients/message-part-runtime-client.js +49 -9
  342. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  343. package/dist/store/runtime-clients/message-runtime-client.d.ts +2 -7
  344. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  345. package/dist/store/runtime-clients/message-runtime-client.js +220 -54
  346. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  347. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +2 -4
  348. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  349. package/dist/store/runtime-clients/thread-list-item-runtime-client.js +71 -26
  350. package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
  351. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +2 -5
  352. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  353. package/dist/store/runtime-clients/thread-list-runtime-client.js +141 -36
  354. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  355. package/dist/store/runtime-clients/thread-runtime-client.d.ts +2 -4
  356. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  357. package/dist/store/runtime-clients/thread-runtime-client.js +196 -72
  358. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  359. package/dist/store/runtime-clients/useSubscribable.js +2 -9
  360. package/dist/store/runtime-clients/useSubscribable.js.map +1 -1
  361. package/dist/store/scopes/message.d.ts +1 -0
  362. package/dist/store/scopes/message.d.ts.map +1 -1
  363. package/dist/store/scopes/part.d.ts +5 -6
  364. package/dist/store/scopes/part.d.ts.map +1 -1
  365. package/dist/store/scopes/queue-item.js.map +1 -1
  366. package/dist/store/scopes/thread-list-item.d.ts +1 -0
  367. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  368. package/dist/store/scopes/thread.d.ts +1 -0
  369. package/dist/store/scopes/thread.d.ts.map +1 -1
  370. package/dist/subscribable/subscribable.js.map +1 -1
  371. package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
  372. package/dist/types/message.d.ts +38 -5
  373. package/dist/types/message.d.ts.map +1 -1
  374. package/dist/types/message.js.map +1 -1
  375. package/dist/utils/composite-context-provider.js.map +1 -1
  376. package/dist/utils/id.js.map +1 -1
  377. package/dist/utils/json/is-json-equal.js.map +1 -1
  378. package/dist/utils/json/is-json.js.map +1 -1
  379. package/dist/utils/text.js.map +1 -1
  380. package/package.json +6 -6
  381. package/src/adapters/thread-history.ts +2 -0
  382. package/src/index.ts +5 -0
  383. package/src/internal.ts +1 -0
  384. package/src/model-context/types.ts +1 -0
  385. package/src/react/AssistantProvider.tsx +10 -1
  386. package/src/react/RuntimeAdapter.ts +25 -8
  387. package/src/react/client/DataRenderers.ts +42 -45
  388. package/src/react/client/Interactables.ts +261 -261
  389. package/src/react/client/Tools.ts +9 -9
  390. package/src/react/primitives/message/MessageGroupedParts.tsx +19 -7
  391. package/src/react/primitives/message/MessageParts.tsx +64 -13
  392. package/src/react/providers/TextMessagePartProvider.tsx +5 -3
  393. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -0
  394. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +11 -0
  395. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +6 -0
  396. package/src/react/runtimes/external-message-converter.ts +3 -1
  397. package/src/react/types/MessagePartComponentTypes.ts +5 -5
  398. package/src/react/utils/groupParts.ts +27 -0
  399. package/src/runtime/api/bindings.ts +1 -0
  400. package/src/runtime/api/message-part-runtime.ts +14 -11
  401. package/src/runtime/api/message-runtime.ts +7 -0
  402. package/src/runtime/api/thread-list-runtime.ts +1 -0
  403. package/src/runtime/api/thread-runtime.ts +7 -0
  404. package/src/runtime/base/base-thread-runtime-core.ts +1 -0
  405. package/src/runtime/branch/external-thread-branch-adapter.ts +26 -0
  406. package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -0
  407. package/src/runtime/interfaces/thread-runtime-core.ts +4 -0
  408. package/src/runtime/utils/resolveToolApprovalResponse.test.ts +91 -0
  409. package/src/runtime/utils/resolveToolApprovalResponse.ts +55 -0
  410. package/src/runtime/utils/thread-message-like.ts +10 -1
  411. package/src/runtimes/external-store/external-store-adapter.ts +1 -0
  412. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +24 -0
  413. package/src/runtimes/local/local-runtime-options.ts +1 -1
  414. package/src/runtimes/local/local-thread-runtime-core.test.ts +370 -0
  415. package/src/runtimes/local/local-thread-runtime-core.ts +113 -7
  416. package/src/runtimes/local/should-continue.ts +24 -13
  417. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +5 -0
  418. package/src/runtimes/remote-thread-list/empty-thread-core.ts +5 -0
  419. package/src/runtimes/remote-thread-list/remote-thread-state.ts +2 -0
  420. package/src/runtimes/remote-thread-list/types.ts +1 -0
  421. package/src/store/clients/chain-of-thought-client.ts +5 -3
  422. package/src/store/clients/model-context-client.test.ts +5 -4
  423. package/src/store/clients/model-context-client.ts +21 -21
  424. package/src/store/clients/no-op-composer-client.ts +5 -3
  425. package/src/store/clients/runtime-adapter.ts +0 -24
  426. package/src/store/clients/suggestions.ts +12 -23
  427. package/src/store/clients/thread-message-client.ts +42 -40
  428. package/src/store/internal.ts +1 -4
  429. package/src/store/runtime-clients/attachment-runtime-client.ts +14 -14
  430. package/src/store/runtime-clients/composer-runtime-client.ts +48 -45
  431. package/src/store/runtime-clients/liveRef.ts +5 -0
  432. package/src/store/runtime-clients/message-part-runtime-client.ts +5 -3
  433. package/src/store/runtime-clients/message-runtime-client.ts +42 -40
  434. package/src/store/runtime-clients/thread-list-item-runtime-client.ts +5 -3
  435. package/src/store/runtime-clients/thread-list-runtime-client.ts +13 -11
  436. package/src/store/runtime-clients/thread-runtime-client.ts +20 -16
  437. package/src/store/runtime-clients/useSubscribable.ts +2 -10
  438. package/src/store/scopes/message.ts +1 -0
  439. package/src/store/scopes/part.ts +5 -2
  440. package/src/store/scopes/thread-list-item.ts +1 -0
  441. package/src/store/scopes/thread.ts +1 -0
  442. package/src/tests/external-store-thread-runtime-core.test.ts +57 -0
  443. package/src/tests/groupMessageParts.test.ts +84 -0
  444. package/src/tests/groupParts.test.ts +55 -0
  445. package/src/types/message.ts +45 -3
@@ -1,6 +1,7 @@
1
1
  import { ComposerAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider.js";
2
2
  import { memo, useMemo } from "@assistant-ui/tap/react-shim";
3
3
  import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
4
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  //#region src/react/primitives/composer/ComposerAttachments.tsx
6
7
  const getComponent = (components, attachment) => {
@@ -11,21 +12,51 @@ const getComponent = (components, attachment) => {
11
12
  default: return components?.Attachment;
12
13
  }
13
14
  };
14
- const AttachmentComponent = ({ components }) => {
15
- const attachment = useAuiState((s) => s.attachment);
15
+ const AttachmentComponent = (t0) => {
16
+ const $ = c(5);
17
+ const { components } = t0;
18
+ const attachment = useAuiState(_temp);
16
19
  if (!attachment) return null;
17
- const Component = getComponent(components, attachment);
20
+ let t1;
21
+ if ($[0] !== attachment || $[1] !== components) {
22
+ t1 = getComponent(components, attachment);
23
+ $[0] = attachment;
24
+ $[1] = components;
25
+ $[2] = t1;
26
+ } else t1 = $[2];
27
+ const Component = t1;
18
28
  if (!Component) return null;
19
- return /* @__PURE__ */ jsx(Component, {});
29
+ let t2;
30
+ if ($[3] !== Component) {
31
+ t2 = /* @__PURE__ */ jsx(Component, {});
32
+ $[3] = Component;
33
+ $[4] = t2;
34
+ } else t2 = $[4];
35
+ return t2;
20
36
  };
21
37
  /**
22
38
  * Renders a single attachment at the specified index within the composer.
23
39
  */
24
- const ComposerPrimitiveAttachmentByIndex = memo(({ index, components }) => {
25
- return /* @__PURE__ */ jsx(ComposerAttachmentByIndexProvider, {
26
- index,
27
- children: /* @__PURE__ */ jsx(AttachmentComponent, { components })
28
- });
40
+ const ComposerPrimitiveAttachmentByIndex = memo((t0) => {
41
+ const $ = c(5);
42
+ const { index, components } = t0;
43
+ let t1;
44
+ if ($[0] !== components) {
45
+ t1 = /* @__PURE__ */ jsx(AttachmentComponent, { components });
46
+ $[0] = components;
47
+ $[1] = t1;
48
+ } else t1 = $[1];
49
+ let t2;
50
+ if ($[2] !== index || $[3] !== t1) {
51
+ t2 = /* @__PURE__ */ jsx(ComposerAttachmentByIndexProvider, {
52
+ index,
53
+ children: t1
54
+ });
55
+ $[2] = index;
56
+ $[3] = t1;
57
+ $[4] = t2;
58
+ } else t2 = $[4];
59
+ return t2;
29
60
  }, (prev, next) => prev.index === next.index && prev.components?.Image === next.components?.Image && prev.components?.Document === next.components?.Document && prev.components?.File === next.components?.File && prev.components?.Attachment === next.components?.Attachment);
30
61
  ComposerPrimitiveAttachmentByIndex.displayName = "ComposerPrimitive.AttachmentByIndex";
31
62
  const ComposerPrimitiveAttachmentsInner = ({ children }) => {
@@ -40,15 +71,35 @@ const ComposerPrimitiveAttachmentsInner = ({ children }) => {
40
71
  })
41
72
  }, index)), [attachmentsCount, children]);
42
73
  };
43
- const ComposerPrimitiveAttachments = ({ components, children }) => {
44
- if (components) return /* @__PURE__ */ jsx(ComposerPrimitiveAttachmentsInner, { children: ({ attachment }) => {
45
- const Component = getComponent(components, attachment);
46
- if (!Component) return null;
47
- return /* @__PURE__ */ jsx(Component, {});
48
- } });
49
- return /* @__PURE__ */ jsx(ComposerPrimitiveAttachmentsInner, { children });
74
+ const ComposerPrimitiveAttachments = (t0) => {
75
+ const $ = c(4);
76
+ const { components, children } = t0;
77
+ if (components) {
78
+ let t1;
79
+ if ($[0] !== components) {
80
+ t1 = /* @__PURE__ */ jsx(ComposerPrimitiveAttachmentsInner, { children: (t2) => {
81
+ const { attachment } = t2;
82
+ const Component = getComponent(components, attachment);
83
+ if (!Component) return null;
84
+ return /* @__PURE__ */ jsx(Component, {});
85
+ } });
86
+ $[0] = components;
87
+ $[1] = t1;
88
+ } else t1 = $[1];
89
+ return t1;
90
+ }
91
+ let t1;
92
+ if ($[2] !== children) {
93
+ t1 = /* @__PURE__ */ jsx(ComposerPrimitiveAttachmentsInner, { children });
94
+ $[2] = children;
95
+ $[3] = t1;
96
+ } else t1 = $[3];
97
+ return t1;
50
98
  };
51
99
  ComposerPrimitiveAttachments.displayName = "ComposerPrimitive.Attachments";
100
+ function _temp(s) {
101
+ return s.attachment;
102
+ }
52
103
  //#endregion
53
104
  export { ComposerPrimitiveAttachmentByIndex, ComposerPrimitiveAttachments };
54
105
 
@@ -1 +1 @@
1
- {"version":3,"file":"ComposerAttachments.js","names":[],"sources":["../../../../src/react/primitives/composer/ComposerAttachments.tsx"],"sourcesContent":["import type { Attachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { ComposerAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype ComposerAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace ComposerPrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: ComposerAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: Attachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: ComposerAttachmentsComponentConfig | undefined,\n attachment: Attachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: ComposerAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace ComposerPrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: ComposerAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the composer.\n */\nexport const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <ComposerAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </ComposerAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nComposerPrimitiveAttachmentByIndex.displayName =\n \"ComposerPrimitive.AttachmentByIndex\";\n\nconst ComposerPrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: Attachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => s.composer.attachments.length);\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <ComposerAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ComposerAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const ComposerPrimitiveAttachments: FC<\n ComposerPrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <ComposerPrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </ComposerPrimitiveAttachmentsInner>\n );\n }\n return (\n <ComposerPrimitiveAttachmentsInner>\n {children}\n </ComposerPrimitiveAttachmentsInner>\n );\n};\n\nComposerPrimitiveAttachments.displayName = \"ComposerPrimitive.Attachments\";\n"],"mappings":";;;;;AAgCA,MAAM,gBACJ,YACA,eACG;CAEH,QADa,WAAW,MACxB;EACE,KAAK,SACH,OAAO,YAAY,SAAS,YAAY;EAC1C,KAAK,YACH,OAAO,YAAY,YAAY,YAAY;EAC7C,KAAK,QACH,OAAO,YAAY,QAAQ,YAAY;EACzC,SACE,OAAO,YAAY;CACvB;AACF;AAEA,MAAM,uBAEA,EAAE,iBAAiB;CACvB,MAAM,aAAa,aAAa,MAAM,EAAE,UAAU;CAClD,IAAI,CAAC,YAAY,OAAO;CAExB,MAAM,YAAY,aAAa,YAAY,UAAU;CACrD,IAAI,CAAC,WAAW,OAAO;CACvB,OAAO,oBAAC,WAAD,CAAY,CAAA;AACrB;;;;AAYA,MAAa,qCACX,MACG,EAAE,OAAO,iBAAiB;CACzB,OACE,oBAAC,mCAAD;EAA0C;YACxC,oBAAC,qBAAD,EAAiC,WAAa,CAAA;CACb,CAAA;AAEvC,IACC,MAAM,SACL,KAAK,UAAU,KAAK,SACpB,KAAK,YAAY,UAAU,KAAK,YAAY,SAC5C,KAAK,YAAY,aAAa,KAAK,YAAY,YAC/C,KAAK,YAAY,SAAS,KAAK,YAAY,QAC3C,KAAK,YAAY,eAAe,KAAK,YAAY,UACrD;AAEF,mCAAmC,cACjC;AAEF,MAAM,qCAEA,EAAE,eAAe;CACrB,MAAM,mBAAmB,aAAa,MAAM,EAAE,SAAS,YAAY,MAAM;CAEzE,OAAO,cAEH,MAAM,KAAK,EAAE,QAAQ,iBAAiB,IAAI,GAAG,UAC3C,oBAAC,mCAAD;EAAsD;YACpD,oBAAC,4BAAD;GACE,eAAe,QACb,IAAI,SAAS,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS;cAG9C,YACA,SAAS,EACP,IAAI,aAAa;IACf,OAAO,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACK,GAdK,KAcL,CACpC,GACH,CAAC,kBAAkB,QAAQ,CAC7B;AACF;AAEA,MAAa,gCAER,EAAE,YAAY,eAAe;CAChC,IAAI,YACF,OACE,oBAAC,mCAAD,EAAA,WACI,EAAE,iBAAiB;EACnB,MAAM,YAAY,aAAa,YAAY,UAAU;EACrD,IAAI,CAAC,WAAW,OAAO;EACvB,OAAO,oBAAC,WAAD,CAAY,CAAA;CACrB,EACiC,CAAA;CAGvC,OACE,oBAAC,mCAAD,EACG,SACgC,CAAA;AAEvC;AAEA,6BAA6B,cAAc"}
1
+ {"version":3,"file":"ComposerAttachments.js","names":["Attachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","ComposerAttachmentByIndexProvider","ComposerAttachmentsComponentConfig","Image","Document","File","ComposerPrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","Component","t2","ComposerPrimitiveAttachmentByIndex","index","prev","next","displayName","ComposerPrimitiveAttachmentsInner","attachmentsCount","s","composer","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/composer/ComposerAttachments.tsx"],"sourcesContent":["import type { Attachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { ComposerAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype ComposerAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace ComposerPrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: ComposerAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: Attachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: ComposerAttachmentsComponentConfig | undefined,\n attachment: Attachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: ComposerAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace ComposerPrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: ComposerAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the composer.\n */\nexport const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <ComposerAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </ComposerAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nComposerPrimitiveAttachmentByIndex.displayName =\n \"ComposerPrimitive.AttachmentByIndex\";\n\nconst ComposerPrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: Attachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => s.composer.attachments.length);\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <ComposerAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ComposerAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const ComposerPrimitiveAttachments: FC<\n ComposerPrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <ComposerPrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </ComposerPrimitiveAttachmentsInner>\n );\n }\n return (\n <ComposerPrimitiveAttachmentsInner>\n {children}\n </ComposerPrimitiveAttachmentsInner>\n );\n};\n\nComposerPrimitiveAttachments.displayName = \"ComposerPrimitive.Attachments\";\n"],"mappings":"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"}
@@ -1,19 +1,40 @@
1
1
  import { useAuiState } from "@assistant-ui/store";
2
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
2
3
  //#region src/react/primitives/composer/ComposerIf.tsx
3
4
  const useComposerIf = (props) => {
4
- return useAuiState((s) => {
5
- if (props.editing === true && !s.composer.isEditing) return false;
6
- if (props.editing === false && s.composer.isEditing) return false;
7
- const isDictating = s.composer.dictation != null;
8
- if (props.dictation === true && !isDictating) return false;
9
- if (props.dictation === false && isDictating) return false;
10
- return true;
11
- });
5
+ const $ = c(3);
6
+ let t0;
7
+ if ($[0] !== props.dictation || $[1] !== props.editing) {
8
+ t0 = (s) => {
9
+ if (props.editing === true && !s.composer.isEditing) return false;
10
+ if (props.editing === false && s.composer.isEditing) return false;
11
+ const isDictating = s.composer.dictation != null;
12
+ if (props.dictation === true && !isDictating) return false;
13
+ if (props.dictation === false && isDictating) return false;
14
+ return true;
15
+ };
16
+ $[0] = props.dictation;
17
+ $[1] = props.editing;
18
+ $[2] = t0;
19
+ } else t0 = $[2];
20
+ return useAuiState(t0);
12
21
  };
13
22
  /**
14
23
  * @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.
15
24
  */
16
- const ComposerPrimitiveIf = ({ children, ...query }) => {
25
+ const ComposerPrimitiveIf = (t0) => {
26
+ const $ = c(3);
27
+ let children;
28
+ let query;
29
+ if ($[0] !== t0) {
30
+ ({children, ...query} = t0);
31
+ $[0] = t0;
32
+ $[1] = children;
33
+ $[2] = query;
34
+ } else {
35
+ children = $[1];
36
+ query = $[2];
37
+ }
17
38
  return useComposerIf(query) ? children : null;
18
39
  };
19
40
  ComposerPrimitiveIf.displayName = "ComposerPrimitive.If";
@@ -1 +1 @@
1
- {"version":3,"file":"ComposerIf.js","names":[],"sources":["../../../../src/react/primitives/composer/ComposerIf.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\ntype ComposerIfFilters = {\n /** Whether the composer is in editing mode */\n editing: boolean | undefined;\n /** Whether dictation is currently active */\n dictation: boolean | undefined;\n};\n\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;\n\nconst useComposerIf = (props: UseComposerIfProps) => {\n return useAuiState((s) => {\n if (props.editing === true && !s.composer.isEditing) return false;\n if (props.editing === false && s.composer.isEditing) return false;\n\n const isDictating = s.composer.dictation != null;\n if (props.dictation === true && !isDictating) return false;\n if (props.dictation === false && isDictating) return false;\n\n return true;\n });\n};\n\nexport namespace ComposerPrimitiveIf {\n export type Props = PropsWithChildren<UseComposerIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.\n */\nexport const ComposerPrimitiveIf: FC<ComposerPrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useComposerIf(query);\n return result ? children : null;\n};\n\nComposerPrimitiveIf.displayName = \"ComposerPrimitive.If\";\n"],"mappings":";;AAoBA,MAAM,iBAAiB,UAA8B;CACnD,OAAO,aAAa,MAAM;EACxB,IAAI,MAAM,YAAY,QAAQ,CAAC,EAAE,SAAS,WAAW,OAAO;EAC5D,IAAI,MAAM,YAAY,SAAS,EAAE,SAAS,WAAW,OAAO;EAE5D,MAAM,cAAc,EAAE,SAAS,aAAa;EAC5C,IAAI,MAAM,cAAc,QAAQ,CAAC,aAAa,OAAO;EACrD,IAAI,MAAM,cAAc,SAAS,aAAa,OAAO;EAErD,OAAO;CACT,CAAC;AACH;;;;AASA,MAAa,uBAAsD,EACjE,UACA,GAAG,YACC;CAEJ,OADe,cAAc,KACjB,IAAI,WAAW;AAC7B;AAEA,oBAAoB,cAAc"}
1
+ {"version":3,"file":"ComposerIf.js","names":["FC","PropsWithChildren","useAuiState","ComposerIfFilters","editing","dictation","RequireAtLeastOne","T","Pick","Exclude","Keys","Required","K","Partial","UseComposerIfProps","useComposerIf","props","$","_c","t0","s","composer","isEditing","isDictating","ComposerPrimitiveIf","Props","children","query","result","displayName"],"sources":["../../../../src/react/primitives/composer/ComposerIf.tsx"],"sourcesContent":["import type { FC, PropsWithChildren } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\n\ntype ComposerIfFilters = {\n /** Whether the composer is in editing mode */\n editing: boolean | undefined;\n /** Whether dictation is currently active */\n dictation: boolean | undefined;\n};\n\nexport type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<\n T,\n Exclude<keyof T, Keys>\n> &\n {\n [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;\n }[Keys];\n\nexport type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;\n\nconst useComposerIf = (props: UseComposerIfProps) => {\n return useAuiState((s) => {\n if (props.editing === true && !s.composer.isEditing) return false;\n if (props.editing === false && s.composer.isEditing) return false;\n\n const isDictating = s.composer.dictation != null;\n if (props.dictation === true && !isDictating) return false;\n if (props.dictation === false && isDictating) return false;\n\n return true;\n });\n};\n\nexport namespace ComposerPrimitiveIf {\n export type Props = PropsWithChildren<UseComposerIfProps>;\n}\n\n/**\n * @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.\n */\nexport const ComposerPrimitiveIf: FC<ComposerPrimitiveIf.Props> = ({\n children,\n ...query\n}) => {\n const result = useComposerIf(query);\n return result ? children : null;\n};\n\nComposerPrimitiveIf.displayName = \"ComposerPrimitive.If\";\n"],"mappings":";;;AAoBA,MAAMe,iBAAgBC,UAAA;CAAA,MAAAC,IAAAC,EAAA,CAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAD,MAAAX,aAAAY,EAAA,OAAAD,MAAAZ,SAAA;EACDe,MAAAC,MAAA;GACjB,IAAIJ,MAAKZ,YAAa,QAAlB,CAA2BgB,EAACC,SAASC,WAAU,OAAS;GAC5D,IAAIN,MAAKZ,YAAa,SAASgB,EAACC,SAASC,WAAU,OAAS;GAE5D,MAAAC,cAAoBH,EAACC,SAAShB,aAAc;GAC5C,IAAIW,MAAKX,cAAe,QAApB,CAA6BkB,aAAW,OAAS;GACrD,IAAIP,MAAKX,cAAe,SAApBkB,aAAwC,OAAS;GAAM,OAEpD;EAAI;EACZN,EAAA,KAAAD,MAAAX;EAAAY,EAAA,KAAAD,MAAAZ;EAAAa,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAA,OATMf,YAAYiB,EASlB;AAAC;;;;AAUJ,MAAaK,uBAAqDL,OAAA;CAAA,MAAAF,IAAAC,EAAA,CAAA;CAAA,IAAAQ;CAAA,IAAAC;CAAA,IAAAV,EAAA,OAAAE,IAAA;EAAC,CAAA,CAAAO,aAAAC,SAAAR;EAGlEF,EAAA,KAAAE;EAAAF,EAAA,KAAAS;EAAAT,EAAA,KAAAU;CAAA,OAAA;EAAAD,WAAAT,EAAA;EAAAU,QAAAV,EAAA;CAAA;CACqC,OAArBF,cAAcY,KACtBC,IAAAF,WAAA;AAAwB;AAGjCF,oBAAoBK,cAAc"}
@@ -1 +1 @@
1
- {"version":3,"file":"ComposerQueue.js","names":[],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo, useMemo } from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { QueueItemState } from \"../../../store/scopes/queue-item\";\nimport { QueueItemByIndexProvider } from \"../../providers/QueueItemByIndexProvider\";\n\nexport namespace ComposerPrimitiveQueue {\n export type Props = {\n /** Render function called for each queue item. Receives the queue item state. */\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n };\n}\n\nconst ComposerPrimitiveQueueInner: FC<{\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n}> = ({ children }) => {\n const queue = useAuiState((s) => s.composer.queue.length);\n\n return useMemo(\n () =>\n Array.from({ length: queue }, (_, index) => (\n <QueueItemByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().queueItem({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get queueItem() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </QueueItemByIndexProvider>\n )),\n [queue, children],\n );\n};\n\n/**\n * Renders all queue items in the composer.\n *\n * @example\n * ```tsx\n * <ComposerPrimitive.Queue>\n * {({ queueItem }) => (\n * <div>\n * <QueueItemPrimitive.Text />\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * </div>\n * )}\n * </ComposerPrimitive.Queue>\n * ```\n */\nexport const ComposerPrimitiveQueue = memo(ComposerPrimitiveQueueInner);\n\nComposerPrimitiveQueue.displayName = \"ComposerPrimitive.Queue\";\n"],"mappings":";;;;;AAYA,MAAM,+BAEA,EAAE,eAAe;CACrB,MAAM,QAAQ,aAAa,MAAM,EAAE,SAAS,MAAM,MAAM;CAExD,OAAO,cAEH,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UAChC,oBAAC,0BAAD;EAA6C;YAC3C,oBAAC,4BAAD;GACE,eAAe,QACb,IAAI,SAAS,CAAC,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS;cAG7C,YACA,SAAS,EACP,IAAI,YAAY;IACd,OAAO,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACJ,GAdK,KAcL,CAC3B,GACH,CAAC,OAAO,QAAQ,CAClB;AACF;;;;;;;;;;;;;;;;AAiBA,MAAa,yBAAyB,KAAK,2BAA2B;AAEtE,uBAAuB,cAAc"}
1
+ {"version":3,"file":"ComposerQueue.js","names":["FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","QueueItemState","QueueItemByIndexProvider","ComposerPrimitiveQueue","Props","children","value","queueItem","ComposerPrimitiveQueueInner","queue","s","composer","length","Array","from","_","index","aui","getState","getItem","displayName"],"sources":["../../../../src/react/primitives/composer/ComposerQueue.tsx"],"sourcesContent":["import { type FC, type ReactNode, memo, useMemo } from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { QueueItemState } from \"../../../store/scopes/queue-item\";\nimport { QueueItemByIndexProvider } from \"../../providers/QueueItemByIndexProvider\";\n\nexport namespace ComposerPrimitiveQueue {\n export type Props = {\n /** Render function called for each queue item. Receives the queue item state. */\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n };\n}\n\nconst ComposerPrimitiveQueueInner: FC<{\n children: (value: { queueItem: QueueItemState }) => ReactNode;\n}> = ({ children }) => {\n const queue = useAuiState((s) => s.composer.queue.length);\n\n return useMemo(\n () =>\n Array.from({ length: queue }, (_, index) => (\n <QueueItemByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.composer().queueItem({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get queueItem() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </QueueItemByIndexProvider>\n )),\n [queue, children],\n );\n};\n\n/**\n * Renders all queue items in the composer.\n *\n * @example\n * ```tsx\n * <ComposerPrimitive.Queue>\n * {({ queueItem }) => (\n * <div>\n * <QueueItemPrimitive.Text />\n * <QueueItemPrimitive.Steer>Run Now</QueueItemPrimitive.Steer>\n * </div>\n * )}\n * </ComposerPrimitive.Queue>\n * ```\n */\nexport const ComposerPrimitiveQueue = memo(ComposerPrimitiveQueueInner);\n\nComposerPrimitiveQueue.displayName = \"ComposerPrimitive.Queue\";\n"],"mappings":";;;;;AAYA,MAAMa,+BAEA,EAAEH,eAAe;CACrB,MAAMI,QAAQT,aAAaU,MAAMA,EAAEC,SAASF,MAAMG,MAAM;CAExD,OAAOd,cAEHe,MAAMC,KAAK,EAAEF,QAAQH,MAAM,IAAIM,GAAGC,UAChC,oBAAC,0BAAD;EAA6CA;YAC3C,oBAAC,4BAAD;GACE,eAAeC,QACbA,IAAIN,SAAS,CAAC,CAACJ,UAAU,EAAES,MAAM,CAAC,CAAC,CAACE,SAAS;cAG7CC,YACAd,SAAS,EACP,IAAIE,YAAY;IACd,OAAOY,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACJ,GAdKH,KAcL,CAC3B,GACH,CAACP,OAAOJ,QAAQ,CAClB;AACF;;;;;;;;;;;;;;;;AAiBA,MAAaF,yBAAyBN,KAAKW,2BAA2B;AAEtEL,uBAAuBiB,cAAc"}
@@ -1,6 +1,7 @@
1
1
  "use client";
2
- import { createElement, useMemo } from "@assistant-ui/tap/react-shim";
2
+ import { createElement } from "@assistant-ui/tap/react-shim";
3
3
  import { useAuiState } from "@assistant-ui/store";
4
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
5
  import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
5
6
  //#region src/react/primitives/generativeUI/GenerativeUI.tsx
6
7
  /**
@@ -50,8 +51,38 @@ const normalizeRoot = (spec) => {
50
51
  * allowlist. Used by `MessagePrimitive.GenerativeUI` and by
51
52
  * `MessagePrimitive.Parts` when handling a `generative-ui` part.
52
53
  */
53
- const GenerativeUIRender = ({ spec, components, Fallback }) => {
54
- return /* @__PURE__ */ jsx(Fragment$1, { children: useMemo(() => normalizeRoot(spec), [spec]).map((node, i) => renderNode(node, components, Fallback, `${i}`)) });
54
+ const GenerativeUIRender = (t0) => {
55
+ const $ = c(11);
56
+ const { spec, components, Fallback } = t0;
57
+ let t1;
58
+ if ($[0] !== spec) {
59
+ t1 = normalizeRoot(spec);
60
+ $[0] = spec;
61
+ $[1] = t1;
62
+ } else t1 = $[1];
63
+ const nodes = t1;
64
+ let t2;
65
+ if ($[2] !== Fallback || $[3] !== components || $[4] !== nodes) {
66
+ let t3;
67
+ if ($[6] !== Fallback || $[7] !== components) {
68
+ t3 = (node, i) => renderNode(node, components, Fallback, `${i}`);
69
+ $[6] = Fallback;
70
+ $[7] = components;
71
+ $[8] = t3;
72
+ } else t3 = $[8];
73
+ t2 = nodes.map(t3);
74
+ $[2] = Fallback;
75
+ $[3] = components;
76
+ $[4] = nodes;
77
+ $[5] = t2;
78
+ } else t2 = $[5];
79
+ let t3;
80
+ if ($[9] !== t2) {
81
+ t3 = /* @__PURE__ */ jsx(Fragment$1, { children: t2 });
82
+ $[9] = t2;
83
+ $[10] = t3;
84
+ } else t3 = $[10];
85
+ return t3;
55
86
  };
56
87
  GenerativeUIRender.displayName = "GenerativeUIRender";
57
88
  /**
@@ -71,20 +102,31 @@ GenerativeUIRender.displayName = "GenerativeUIRender";
71
102
  * />
72
103
  * ```
73
104
  */
74
- const MessagePrimitiveGenerativeUI = ({ components, spec, Fallback }) => {
75
- const storeSpec = useAuiState((s) => {
76
- const part = s.part;
77
- return part?.type === "generative-ui" ? part.spec : void 0;
78
- });
105
+ const MessagePrimitiveGenerativeUI = (t0) => {
106
+ const $ = c(4);
107
+ const { components, spec, Fallback } = t0;
108
+ const storeSpec = useAuiState(_temp);
79
109
  const partSpec = spec ?? storeSpec;
80
110
  if (!partSpec) return null;
81
- return /* @__PURE__ */ jsx(GenerativeUIRender, {
82
- spec: partSpec,
83
- components,
84
- Fallback
85
- });
111
+ let t1;
112
+ if ($[0] !== Fallback || $[1] !== components || $[2] !== partSpec) {
113
+ t1 = /* @__PURE__ */ jsx(GenerativeUIRender, {
114
+ spec: partSpec,
115
+ components,
116
+ Fallback
117
+ });
118
+ $[0] = Fallback;
119
+ $[1] = components;
120
+ $[2] = partSpec;
121
+ $[3] = t1;
122
+ } else t1 = $[3];
123
+ return t1;
86
124
  };
87
125
  MessagePrimitiveGenerativeUI.displayName = "MessagePrimitive.GenerativeUI";
126
+ function _temp(s) {
127
+ const part = s.part;
128
+ return part?.type === "generative-ui" ? part.spec : void 0;
129
+ }
88
130
  //#endregion
89
131
  export { GenerativeUIRender, GenerativeUIRenderError, MessagePrimitiveGenerativeUI };
90
132
 
@@ -1 +1 @@
1
- {"version":3,"file":"GenerativeUI.js","names":[],"sources":["../../../../src/react/primitives/generativeUI/GenerativeUI.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n createElement,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type {\n GenerativeUINode,\n GenerativeUISpec,\n} from \"../../../types/message\";\nimport type {\n GenerativeUIComponentRegistry,\n GenerativeUIRenderProps,\n} from \"../../types/MessagePartComponentTypes\";\n\n/**\n * Thrown when a generative-ui spec references a component name that is not\n * present in the consumer-provided allowlist. The allowlist is the security\n * boundary in the same-realm rendering path — there is no fallback by\n * default. Pass `Fallback` to opt into a soft-fail UX.\n */\nexport class GenerativeUIRenderError extends Error {\n public readonly componentName: string;\n\n constructor(\n componentName: string,\n message = `Component \"${componentName}\" is not in the generative-ui allowlist.`,\n ) {\n super(message);\n this.name = \"GenerativeUIRenderError\";\n this.componentName = componentName;\n }\n}\n\nconst isObjectNode = (\n node: GenerativeUINode,\n): node is Exclude<GenerativeUINode, string> =>\n typeof node === \"object\" && node !== null;\n\nconst renderNode = (\n node: GenerativeUINode | undefined,\n components: GenerativeUIComponentRegistry,\n Fallback: GenerativeUIRenderProps[\"Fallback\"],\n path: string,\n): ReactNode => {\n if (node === undefined || node === null) return null;\n\n if (typeof node === \"string\") return node;\n\n if (!isObjectNode(node) || !(\"component\" in node)) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(`[generative-ui] Skipping malformed node at ${path}:`, node);\n }\n return null;\n }\n\n const { component, props, children, key } = node;\n\n const Resolved = components[component];\n if (!Resolved) {\n if (Fallback) {\n return <Fallback key={key ?? path} component={component} props={props} />;\n }\n throw new GenerativeUIRenderError(component);\n }\n\n const renderedChildren = children?.length\n ? children.map((child, i) =>\n renderNode(child, components, Fallback, `${path}/${i}`),\n )\n : undefined;\n\n return createElement(\n Resolved,\n { ...(props ?? {}), key: key ?? path },\n ...(renderedChildren ?? []),\n );\n};\n\nconst normalizeRoot = (\n spec: GenerativeUISpec | undefined,\n): readonly GenerativeUINode[] => {\n if (!spec || spec.root === undefined || spec.root === null) return [];\n const root = spec.root;\n return Array.isArray(root)\n ? (root as readonly GenerativeUINode[])\n : [root as GenerativeUINode];\n};\n\n/**\n * Internal renderer. Resolves a {@link GenerativeUISpec} against the consumer\n * allowlist. Used by `MessagePrimitive.GenerativeUI` and by\n * `MessagePrimitive.Parts` when handling a `generative-ui` part.\n */\nexport const GenerativeUIRender: FC<GenerativeUIRenderProps> = ({\n spec,\n components,\n Fallback,\n}) => {\n const nodes = useMemo(() => normalizeRoot(spec), [spec]);\n\n return (\n <>\n {nodes.map((node, i) => renderNode(node, components, Fallback, `${i}`))}\n </>\n );\n};\n\nGenerativeUIRender.displayName = \"GenerativeUIRender\";\n\nexport namespace MessagePrimitiveGenerativeUI {\n export type Props = {\n /**\n * The component allowlist. Keys are the names referenced in the spec\n * (e.g. `\"Card\"`, `\"Button\"`), values are the React components.\n *\n * This is the security boundary — any name not in the allowlist is\n * rejected with {@link GenerativeUIRenderError}.\n */\n components: GenerativeUIComponentRegistry;\n /**\n * Optional override spec. If omitted, the primitive reads the\n * `generative-ui` part from the surrounding `MessagePartProvider` /\n * `PartByIndexProvider` context.\n */\n spec?: GenerativeUISpec | undefined;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n };\n}\n\n/**\n * Renders a generative-ui message part using a consumer-provided allowlist.\n *\n * The agent emits a `generative-ui` message part containing a JSON spec\n * (see {@link GenerativeUISpec}). This primitive walks the spec and resolves\n * each `component` name against the allowlist. Names not in the allowlist\n * throw {@link GenerativeUIRenderError} unless a `Fallback` is provided.\n *\n * Stream-friendly: a partial spec renders progressively as it is filled in.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GenerativeUI\n * components={{ Card: MyCard, Button: MyButton }}\n * />\n * ```\n */\nexport const MessagePrimitiveGenerativeUI: FC<\n MessagePrimitiveGenerativeUI.Props\n> = ({ components, spec, Fallback }) => {\n // Selector reads store state only — combining with the `spec` prop inside\n // the selector closes over a value that may change identity per render and\n // would trigger spurious tearing-detection re-renders in\n // `useSyncExternalStore`.\n const storeSpec = useAuiState((s) => {\n const part = s.part as { type?: string; spec?: GenerativeUISpec };\n return part?.type === \"generative-ui\" ? part.spec : undefined;\n });\n const partSpec = spec ?? storeSpec;\n\n if (!partSpec) return null;\n\n return (\n <GenerativeUIRender\n spec={partSpec}\n components={components}\n Fallback={Fallback}\n />\n );\n};\n\nMessagePrimitiveGenerativeUI.displayName = \"MessagePrimitive.GenerativeUI\";\n"],"mappings":";;;;;;;;;;;AAyBA,IAAa,0BAAb,cAA6C,MAAM;CACjD;CAEA,YACE,eACA,UAAU,cAAc,cAAc,2CACtC;EACA,MAAM,OAAO;EACb,KAAK,OAAO;EACZ,KAAK,gBAAgB;CACvB;AACF;AAEA,MAAM,gBACJ,SAEA,OAAO,SAAS,YAAY,SAAS;AAEvC,MAAM,cACJ,MACA,YACA,UACA,SACc;CACd,IAAI,SAAS,KAAA,KAAa,SAAS,MAAM,OAAO;CAEhD,IAAI,OAAO,SAAS,UAAU,OAAO;CAErC,IAAI,CAAC,aAAa,IAAI,KAAK,EAAE,eAAe,OAAO;EACjD,IACE,OAAO,YAAY,eACnB,QAAQ,KAAK,aAAa,cAE1B,QAAQ,KAAK,8CAA8C,KAAK,IAAI,IAAI;EAE1E,OAAO;CACT;CAEA,MAAM,EAAE,WAAW,OAAO,UAAU,QAAQ;CAE5C,MAAM,WAAW,WAAW;CAC5B,IAAI,CAAC,UAAU;EACb,IAAI,UACF,OAAO,oBAAC,UAAD;GAAuC;GAAkB;EAAQ,GAAlD,OAAO,IAA2C;EAE1E,MAAM,IAAI,wBAAwB,SAAS;CAC7C;CAEA,MAAM,mBAAmB,UAAU,SAC/B,SAAS,KAAK,OAAO,MACnB,WAAW,OAAO,YAAY,UAAU,GAAG,KAAK,GAAG,GAAG,CACxD,IACA,KAAA;CAEJ,OAAO,cACL,UACA;EAAE,GAAI,SAAS,CAAC;EAAI,KAAK,OAAO;CAAK,GACrC,GAAI,oBAAoB,CAAC,CAC3B;AACF;AAEA,MAAM,iBACJ,SACgC;CAChC,IAAI,CAAC,QAAQ,KAAK,SAAS,KAAA,KAAa,KAAK,SAAS,MAAM,OAAO,CAAC;CACpE,MAAM,OAAO,KAAK;CAClB,OAAO,MAAM,QAAQ,IAAI,IACpB,OACD,CAAC,IAAwB;AAC/B;;;;;;AAOA,MAAa,sBAAmD,EAC9D,MACA,YACA,eACI;CAGJ,OACE,oBAAA,YAAA,EAAA,UAHY,cAAc,cAAc,IAAI,GAAG,CAAC,IAAI,CAI7C,CAAC,CAAC,KAAK,MAAM,MAAM,WAAW,MAAM,YAAY,UAAU,GAAG,GAAG,CAAC,EACtE,CAAA;AAEN;AAEA,mBAAmB,cAAc;;;;;;;;;;;;;;;;;;AA0CjC,MAAa,gCAER,EAAE,YAAY,MAAM,eAAe;CAKtC,MAAM,YAAY,aAAa,MAAM;EACnC,MAAM,OAAO,EAAE;EACf,OAAO,MAAM,SAAS,kBAAkB,KAAK,OAAO,KAAA;CACtD,CAAC;CACD,MAAM,WAAW,QAAQ;CAEzB,IAAI,CAAC,UAAU,OAAO;CAEtB,OACE,oBAAC,oBAAD;EACE,MAAM;EACM;EACF;CACX,CAAA;AAEL;AAEA,6BAA6B,cAAc"}
1
+ {"version":3,"file":"GenerativeUI.js","names":["c","_c","ComponentType","FC","ReactNode","createElement","useMemo","useAuiState","GenerativeUINode","GenerativeUISpec","GenerativeUIComponentRegistry","GenerativeUIRenderProps","GenerativeUIRenderError","Error","componentName","constructor","message","name","isObjectNode","node","Exclude","renderNode","components","Fallback","path","undefined","process","env","NODE_ENV","console","warn","component","props","children","key","Resolved","renderedChildren","length","map","child","i","normalizeRoot","spec","root","Array","isArray","GenerativeUIRender","t0","$","t1","nodes","t2","t3","displayName","MessagePrimitiveGenerativeUI","Props","storeSpec","_temp","partSpec","s","part","type"],"sources":["../../../../src/react/primitives/generativeUI/GenerativeUI.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n createElement,\n useMemo,\n} from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type {\n GenerativeUINode,\n GenerativeUISpec,\n} from \"../../../types/message\";\nimport type {\n GenerativeUIComponentRegistry,\n GenerativeUIRenderProps,\n} from \"../../types/MessagePartComponentTypes\";\n\n/**\n * Thrown when a generative-ui spec references a component name that is not\n * present in the consumer-provided allowlist. The allowlist is the security\n * boundary in the same-realm rendering path — there is no fallback by\n * default. Pass `Fallback` to opt into a soft-fail UX.\n */\nexport class GenerativeUIRenderError extends Error {\n public readonly componentName: string;\n\n constructor(\n componentName: string,\n message = `Component \"${componentName}\" is not in the generative-ui allowlist.`,\n ) {\n super(message);\n this.name = \"GenerativeUIRenderError\";\n this.componentName = componentName;\n }\n}\n\nconst isObjectNode = (\n node: GenerativeUINode,\n): node is Exclude<GenerativeUINode, string> =>\n typeof node === \"object\" && node !== null;\n\nconst renderNode = (\n node: GenerativeUINode | undefined,\n components: GenerativeUIComponentRegistry,\n Fallback: GenerativeUIRenderProps[\"Fallback\"],\n path: string,\n): ReactNode => {\n if (node === undefined || node === null) return null;\n\n if (typeof node === \"string\") return node;\n\n if (!isObjectNode(node) || !(\"component\" in node)) {\n if (\n typeof process !== \"undefined\" &&\n process.env?.NODE_ENV !== \"production\"\n ) {\n console.warn(`[generative-ui] Skipping malformed node at ${path}:`, node);\n }\n return null;\n }\n\n const { component, props, children, key } = node;\n\n const Resolved = components[component];\n if (!Resolved) {\n if (Fallback) {\n return <Fallback key={key ?? path} component={component} props={props} />;\n }\n throw new GenerativeUIRenderError(component);\n }\n\n const renderedChildren = children?.length\n ? children.map((child, i) =>\n renderNode(child, components, Fallback, `${path}/${i}`),\n )\n : undefined;\n\n return createElement(\n Resolved,\n { ...(props ?? {}), key: key ?? path },\n ...(renderedChildren ?? []),\n );\n};\n\nconst normalizeRoot = (\n spec: GenerativeUISpec | undefined,\n): readonly GenerativeUINode[] => {\n if (!spec || spec.root === undefined || spec.root === null) return [];\n const root = spec.root;\n return Array.isArray(root)\n ? (root as readonly GenerativeUINode[])\n : [root as GenerativeUINode];\n};\n\n/**\n * Internal renderer. Resolves a {@link GenerativeUISpec} against the consumer\n * allowlist. Used by `MessagePrimitive.GenerativeUI` and by\n * `MessagePrimitive.Parts` when handling a `generative-ui` part.\n */\nexport const GenerativeUIRender: FC<GenerativeUIRenderProps> = ({\n spec,\n components,\n Fallback,\n}) => {\n const nodes = useMemo(() => normalizeRoot(spec), [spec]);\n\n return (\n <>\n {nodes.map((node, i) => renderNode(node, components, Fallback, `${i}`))}\n </>\n );\n};\n\nGenerativeUIRender.displayName = \"GenerativeUIRender\";\n\nexport namespace MessagePrimitiveGenerativeUI {\n export type Props = {\n /**\n * The component allowlist. Keys are the names referenced in the spec\n * (e.g. `\"Card\"`, `\"Button\"`), values are the React components.\n *\n * This is the security boundary — any name not in the allowlist is\n * rejected with {@link GenerativeUIRenderError}.\n */\n components: GenerativeUIComponentRegistry;\n /**\n * Optional override spec. If omitted, the primitive reads the\n * `generative-ui` part from the surrounding `MessagePartProvider` /\n * `PartByIndexProvider` context.\n */\n spec?: GenerativeUISpec | undefined;\n /** Optional fallback for unknown component names. */\n Fallback?:\n | ComponentType<{ component: string; props?: unknown }>\n | undefined;\n };\n}\n\n/**\n * Renders a generative-ui message part using a consumer-provided allowlist.\n *\n * The agent emits a `generative-ui` message part containing a JSON spec\n * (see {@link GenerativeUISpec}). This primitive walks the spec and resolves\n * each `component` name against the allowlist. Names not in the allowlist\n * throw {@link GenerativeUIRenderError} unless a `Fallback` is provided.\n *\n * Stream-friendly: a partial spec renders progressively as it is filled in.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GenerativeUI\n * components={{ Card: MyCard, Button: MyButton }}\n * />\n * ```\n */\nexport const MessagePrimitiveGenerativeUI: FC<\n MessagePrimitiveGenerativeUI.Props\n> = ({ components, spec, Fallback }) => {\n // Selector reads store state only — combining with the `spec` prop inside\n // the selector closes over a value that may change identity per render and\n // would trigger spurious tearing-detection re-renders in\n // `useSyncExternalStore`.\n const storeSpec = useAuiState((s) => {\n const part = s.part as { type?: string; spec?: GenerativeUISpec };\n return part?.type === \"generative-ui\" ? part.spec : undefined;\n });\n const partSpec = spec ?? storeSpec;\n\n if (!partSpec) return null;\n\n return (\n <GenerativeUIRender\n spec={partSpec}\n components={components}\n Fallback={Fallback}\n />\n );\n};\n\nMessagePrimitiveGenerativeUI.displayName = \"MessagePrimitive.GenerativeUI\";\n"],"mappings":"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"}
@@ -1,6 +1,7 @@
1
1
  import { MessageAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider.js";
2
2
  import { memo, useMemo } from "@assistant-ui/tap/react-shim";
3
3
  import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
4
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
4
5
  import { jsx } from "react/jsx-runtime";
5
6
  //#region src/react/primitives/message/MessageAttachments.tsx
6
7
  const getComponent = (components, attachment) => {
@@ -11,21 +12,52 @@ const getComponent = (components, attachment) => {
11
12
  default: return components?.Attachment;
12
13
  }
13
14
  };
14
- const AttachmentComponent = ({ components }) => {
15
- const attachment = useAuiState((s) => s.attachment);
15
+ const AttachmentComponent = (t0) => {
16
+ const $ = c(5);
17
+ const { components } = t0;
18
+ const attachment = useAuiState(_temp);
16
19
  if (!attachment) return null;
17
- const Component = getComponent(components, attachment);
20
+ const t1 = attachment;
21
+ let t2;
22
+ if ($[0] !== components || $[1] !== t1) {
23
+ t2 = getComponent(components, t1);
24
+ $[0] = components;
25
+ $[1] = t1;
26
+ $[2] = t2;
27
+ } else t2 = $[2];
28
+ const Component = t2;
18
29
  if (!Component) return null;
19
- return /* @__PURE__ */ jsx(Component, {});
30
+ let t3;
31
+ if ($[3] !== Component) {
32
+ t3 = /* @__PURE__ */ jsx(Component, {});
33
+ $[3] = Component;
34
+ $[4] = t3;
35
+ } else t3 = $[4];
36
+ return t3;
20
37
  };
21
38
  /**
22
39
  * Renders a single attachment at the specified index within the current message.
23
40
  */
24
- const MessagePrimitiveAttachmentByIndex = memo(({ index, components }) => {
25
- return /* @__PURE__ */ jsx(MessageAttachmentByIndexProvider, {
26
- index,
27
- children: /* @__PURE__ */ jsx(AttachmentComponent, { components })
28
- });
41
+ const MessagePrimitiveAttachmentByIndex = memo((t0) => {
42
+ const $ = c(5);
43
+ const { index, components } = t0;
44
+ let t1;
45
+ if ($[0] !== components) {
46
+ t1 = /* @__PURE__ */ jsx(AttachmentComponent, { components });
47
+ $[0] = components;
48
+ $[1] = t1;
49
+ } else t1 = $[1];
50
+ let t2;
51
+ if ($[2] !== index || $[3] !== t1) {
52
+ t2 = /* @__PURE__ */ jsx(MessageAttachmentByIndexProvider, {
53
+ index,
54
+ children: t1
55
+ });
56
+ $[2] = index;
57
+ $[3] = t1;
58
+ $[4] = t2;
59
+ } else t2 = $[4];
60
+ return t2;
29
61
  }, (prev, next) => prev.index === next.index && prev.components?.Image === next.components?.Image && prev.components?.Document === next.components?.Document && prev.components?.File === next.components?.File && prev.components?.Attachment === next.components?.Attachment);
30
62
  MessagePrimitiveAttachmentByIndex.displayName = "MessagePrimitive.AttachmentByIndex";
31
63
  const MessagePrimitiveAttachmentsInner = ({ children }) => {
@@ -43,15 +75,35 @@ const MessagePrimitiveAttachmentsInner = ({ children }) => {
43
75
  })
44
76
  }, index)), [attachmentsCount, children]);
45
77
  };
46
- const MessagePrimitiveAttachments = ({ components, children }) => {
47
- if (components) return /* @__PURE__ */ jsx(MessagePrimitiveAttachmentsInner, { children: ({ attachment }) => {
48
- const Component = getComponent(components, attachment);
49
- if (!Component) return null;
50
- return /* @__PURE__ */ jsx(Component, {});
51
- } });
52
- return /* @__PURE__ */ jsx(MessagePrimitiveAttachmentsInner, { children });
78
+ const MessagePrimitiveAttachments = (t0) => {
79
+ const $ = c(4);
80
+ const { components, children } = t0;
81
+ if (components) {
82
+ let t1;
83
+ if ($[0] !== components) {
84
+ t1 = /* @__PURE__ */ jsx(MessagePrimitiveAttachmentsInner, { children: (t2) => {
85
+ const { attachment } = t2;
86
+ const Component = getComponent(components, attachment);
87
+ if (!Component) return null;
88
+ return /* @__PURE__ */ jsx(Component, {});
89
+ } });
90
+ $[0] = components;
91
+ $[1] = t1;
92
+ } else t1 = $[1];
93
+ return t1;
94
+ }
95
+ let t1;
96
+ if ($[2] !== children) {
97
+ t1 = /* @__PURE__ */ jsx(MessagePrimitiveAttachmentsInner, { children });
98
+ $[2] = children;
99
+ $[3] = t1;
100
+ } else t1 = $[3];
101
+ return t1;
53
102
  };
54
103
  MessagePrimitiveAttachments.displayName = "MessagePrimitive.Attachments";
104
+ function _temp(s) {
105
+ return s.attachment;
106
+ }
55
107
  //#endregion
56
108
  export { MessagePrimitiveAttachmentByIndex, MessagePrimitiveAttachments };
57
109
 
@@ -1 +1 @@
1
- {"version":3,"file":"MessageAttachments.js","names":[],"sources":["../../../../src/react/primitives/message/MessageAttachments.tsx"],"sourcesContent":["import type { CompleteAttachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype MessageAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace MessagePrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: MessageAttachmentsComponentConfig | undefined,\n attachment: CompleteAttachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: MessageAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment as CompleteAttachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace MessagePrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: MessageAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the current message.\n */\nexport const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </MessageAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nMessagePrimitiveAttachmentByIndex.displayName =\n \"MessagePrimitive.AttachmentByIndex\";\n\nconst MessagePrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => {\n if (s.message.role !== \"user\") return 0;\n return (s.message.attachments ?? []).length;\n });\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <MessageAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.message().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem() as CompleteAttachment;\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const MessagePrimitiveAttachments: FC<\n MessagePrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <MessagePrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </MessagePrimitiveAttachmentsInner>\n );\n }\n return (\n <MessagePrimitiveAttachmentsInner>\n {children}\n </MessagePrimitiveAttachmentsInner>\n );\n};\n\nMessagePrimitiveAttachments.displayName = \"MessagePrimitive.Attachments\";\n"],"mappings":";;;;;AAgCA,MAAM,gBACJ,YACA,eACG;CAEH,QADa,WAAW,MACxB;EACE,KAAK,SACH,OAAO,YAAY,SAAS,YAAY;EAC1C,KAAK,YACH,OAAO,YAAY,YAAY,YAAY;EAC7C,KAAK,QACH,OAAO,YAAY,QAAQ,YAAY;EACzC,SACE,OAAO,YAAY;CACvB;AACF;AAEA,MAAM,uBAEA,EAAE,iBAAiB;CACvB,MAAM,aAAa,aAAa,MAAM,EAAE,UAAU;CAClD,IAAI,CAAC,YAAY,OAAO;CAExB,MAAM,YAAY,aAAa,YAAY,UAAgC;CAC3E,IAAI,CAAC,WAAW,OAAO;CACvB,OAAO,oBAAC,WAAD,CAAY,CAAA;AACrB;;;;AAYA,MAAa,oCACX,MACG,EAAE,OAAO,iBAAiB;CACzB,OACE,oBAAC,kCAAD;EAAyC;YACvC,oBAAC,qBAAD,EAAiC,WAAa,CAAA;CACd,CAAA;AAEtC,IACC,MAAM,SACL,KAAK,UAAU,KAAK,SACpB,KAAK,YAAY,UAAU,KAAK,YAAY,SAC5C,KAAK,YAAY,aAAa,KAAK,YAAY,YAC/C,KAAK,YAAY,SAAS,KAAK,YAAY,QAC3C,KAAK,YAAY,eAAe,KAAK,YAAY,UACrD;AAEF,kCAAkC,cAChC;AAEF,MAAM,oCAEA,EAAE,eAAe;CACrB,MAAM,mBAAmB,aAAa,MAAM;EAC1C,IAAI,EAAE,QAAQ,SAAS,QAAQ,OAAO;EACtC,QAAQ,EAAE,QAAQ,eAAe,CAAC,EAAA,CAAG;CACvC,CAAC;CAED,OAAO,cAEH,MAAM,KAAK,EAAE,QAAQ,iBAAiB,IAAI,GAAG,UAC3C,oBAAC,kCAAD;EAAqD;YACnD,oBAAC,4BAAD;GACE,eAAe,QACb,IAAI,QAAQ,CAAC,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS;cAG7C,YACA,SAAS,EACP,IAAI,aAAa;IACf,OAAO,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACI,GAdK,KAcL,CACnC,GACH,CAAC,kBAAkB,QAAQ,CAC7B;AACF;AAEA,MAAa,+BAER,EAAE,YAAY,eAAe;CAChC,IAAI,YACF,OACE,oBAAC,kCAAD,EAAA,WACI,EAAE,iBAAiB;EACnB,MAAM,YAAY,aAAa,YAAY,UAAU;EACrD,IAAI,CAAC,WAAW,OAAO;EACvB,OAAO,oBAAC,WAAD,CAAY,CAAA;CACrB,EACgC,CAAA;CAGtC,OACE,oBAAC,kCAAD,EACG,SAC+B,CAAA;AAEtC;AAEA,4BAA4B,cAAc"}
1
+ {"version":3,"file":"MessageAttachments.js","names":["CompleteAttachment","ComponentType","FC","ReactNode","memo","useMemo","RenderChildrenWithAccessor","useAuiState","MessageAttachmentByIndexProvider","MessageAttachmentsComponentConfig","Image","Document","File","Attachment","MessagePrimitiveAttachments","Props","components","children","value","attachment","getComponent","type","AttachmentComponent","t0","$","_c","_temp","t1","t2","Component","t3","MessagePrimitiveAttachmentByIndex","index","prev","next","displayName","MessagePrimitiveAttachmentsInner","attachmentsCount","s","message","role","attachments","length","Array","from","_","aui","getState","getItem"],"sources":["../../../../src/react/primitives/message/MessageAttachments.tsx"],"sourcesContent":["import type { CompleteAttachment } from \"../../../types/attachment\";\nimport {\n type ComponentType,\n type FC,\n type ReactNode,\n memo,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport { MessageAttachmentByIndexProvider } from \"../../providers/AttachmentByIndexProvider\";\n\ntype MessageAttachmentsComponentConfig = {\n Image?: ComponentType | undefined;\n Document?: ComponentType | undefined;\n File?: ComponentType | undefined;\n Attachment?: ComponentType | undefined;\n};\n\nexport namespace MessagePrimitiveAttachments {\n export type Props =\n | {\n /** @deprecated Use the children render function instead. */\n components: MessageAttachmentsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each attachment. Receives the attachment. */\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n components?: never;\n };\n}\n\nconst getComponent = (\n components: MessageAttachmentsComponentConfig | undefined,\n attachment: CompleteAttachment,\n) => {\n const type = attachment.type;\n switch (type) {\n case \"image\":\n return components?.Image ?? components?.Attachment;\n case \"document\":\n return components?.Document ?? components?.Attachment;\n case \"file\":\n return components?.File ?? components?.Attachment;\n default:\n return components?.Attachment;\n }\n};\n\nconst AttachmentComponent: FC<{\n components: MessageAttachmentsComponentConfig | undefined;\n}> = ({ components }) => {\n const attachment = useAuiState((s) => s.attachment);\n if (!attachment) return null;\n\n const Component = getComponent(components, attachment as CompleteAttachment);\n if (!Component) return null;\n return <Component />;\n};\n\nexport namespace MessagePrimitiveAttachmentByIndex {\n export type Props = {\n index: number;\n components?: MessageAttachmentsComponentConfig;\n };\n}\n\n/**\n * Renders a single attachment at the specified index within the current message.\n */\nexport const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =\n memo(\n ({ index, components }) => {\n return (\n <MessageAttachmentByIndexProvider index={index}>\n <AttachmentComponent components={components} />\n </MessageAttachmentByIndexProvider>\n );\n },\n (prev, next) =>\n prev.index === next.index &&\n prev.components?.Image === next.components?.Image &&\n prev.components?.Document === next.components?.Document &&\n prev.components?.File === next.components?.File &&\n prev.components?.Attachment === next.components?.Attachment,\n );\n\nMessagePrimitiveAttachmentByIndex.displayName =\n \"MessagePrimitive.AttachmentByIndex\";\n\nconst MessagePrimitiveAttachmentsInner: FC<{\n children: (value: { attachment: CompleteAttachment }) => ReactNode;\n}> = ({ children }) => {\n const attachmentsCount = useAuiState((s) => {\n if (s.message.role !== \"user\") return 0;\n return (s.message.attachments ?? []).length;\n });\n\n return useMemo(\n () =>\n Array.from({ length: attachmentsCount }, (_, index) => (\n <MessageAttachmentByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.message().attachment({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get attachment() {\n return getItem() as CompleteAttachment;\n },\n })\n }\n </RenderChildrenWithAccessor>\n </MessageAttachmentByIndexProvider>\n )),\n [attachmentsCount, children],\n );\n};\n\nexport const MessagePrimitiveAttachments: FC<\n MessagePrimitiveAttachments.Props\n> = ({ components, children }) => {\n if (components) {\n return (\n <MessagePrimitiveAttachmentsInner>\n {({ attachment }) => {\n const Component = getComponent(components, attachment);\n if (!Component) return null;\n return <Component />;\n }}\n </MessagePrimitiveAttachmentsInner>\n );\n }\n return (\n <MessagePrimitiveAttachmentsInner>\n {children}\n </MessagePrimitiveAttachmentsInner>\n );\n};\n\nMessagePrimitiveAttachments.displayName = \"MessagePrimitive.Attachments\";\n"],"mappings":"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"}
@@ -36,8 +36,9 @@ declare namespace MessagePrimitiveGroupedParts {
36
36
  * which running states qualify:
37
37
  * - `"never"` — never.
38
38
  * - `"empty"` — only when the message has no parts yet.
39
- * - `"no-text"` (default) — when the last part isn't `text`/`reasoning`
40
- * (e.g. it ended on a tool call, so the assistant likely isn't done).
39
+ * - `"no-text"` (default) — when the message has no parts yet or the last
40
+ * part isn't `text`/`reasoning` (e.g. it ended on a tool call, so the
41
+ * assistant likely isn't done).
41
42
  * - `"always"` — whenever the message is running, regardless of parts.
42
43
  */
43
44
  type IndicatorMode = "never" | "empty" | "no-text" | "always";
@@ -1 +1 @@
1
- {"version":3,"file":"MessageGroupedParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"mappings":";;;;;;;kBAkBiB,4BAAA;;AAAjB;;;;;OAOc,SAAA;IAAA,SACD,IAAA,EAAM,IAAA;IAAA,SACN,MAAA,EAAQ,iBAAA,GAAoB,yBAAA;IAAA,SAC5B,OAAA;EAAA;EA2CU;;;;;;;;;;EAAA,KA9BT,aAAA;IAAA,SACD,IAAA;EAAA;EAhBM;;;;;;;;;;EAAA,KA6BL,aAAA;EAAA,KAEA,UAAA;IAOe;;;;;;IAAA,SAAhB,IAAA,EAAM,SAAA,CAAU,IAAA,IAAQ,iBAAA,GAAoB,aAAA;IAwC5C;;;;;;IAAA,SAjCA,QAAA,EAAU,SAAA;EAAA;EAAA,KAGT,KAAA;IAwDgB;;;;;AAA8B;AA+G5D;;;;;;;;;;;;;;;;;;;;;;;IA/G8B,SA1BjB,OAAA,GACP,IAAA,EAAM,SAAA,EACN,OAAA,EAAS,cAAA,cACG,IAAA;;;;;;;;;aAUL,SAAA,GAAY,aAAA;;;;;;;;;;;;aAaZ,QAAA,GAAW,IAAA,EAAM,UAAA,CAAW,IAAA,MAAU,SAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cA+GtC,4BAAA;EAAA;IAA8D,OAAA;IAAA,SAAA;IAAA;EAAA,GAIxE,4BAAA,CAA6B,KAAA,CAAM,IAAA,IAAQ,SAAA"}
1
+ {"version":3,"file":"MessageGroupedParts.d.ts","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"mappings":";;;;;;;kBAkBiB,4BAAA;;AAAjB;;;;;OAOc,SAAA;IAAA,SACD,IAAA,EAAM,IAAA;IAAA,SACN,MAAA,EAAQ,iBAAA,GAAoB,yBAAA;IAAA,SAC5B,OAAA;EAAA;EA4CU;;;;;;;;;;EAAA,KA/BT,aAAA;IAAA,SACD,IAAA;EAAA;EAhBM;;;;;;;;;;;EAAA,KA8BL,aAAA;EAAA,KAEA,UAAA;IAOuB;;;;;;IAAA,SAAxB,IAAA,EAAM,SAAA,CAAU,IAAA,IAAQ,iBAAA,GAAoB,aAAA;IAyC7C;;;;;;IAAA,SAlCC,QAAA,EAAU,SAAA;EAAA;EAAA,KAGT,KAAA;IAwD2B;;;;AAAmB;AAqH5D;;;;;;;;;;;;;;;;;;;;;;;;IArHyC,SA1B5B,OAAA,GACP,IAAA,EAAM,SAAA,EACN,OAAA,EAAS,cAAA,cACG,IAAA;;;;;;;;;aAUL,SAAA,GAAY,aAAA;;;;;;;;;;;;aAaZ,QAAA,GAAW,IAAA,EAAM,UAAA,CAAW,IAAA,MAAU,SAAA;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAqHtC,4BAAA;EAAA;IAA8D,OAAA;IAAA,SAAA;IAAA;EAAA,GAIxE,4BAAA,CAA6B,KAAA,CAAM,IAAA,IAAQ,SAAA"}
@@ -15,7 +15,7 @@ const shouldShowIndicator = (mode, parts, isRunning) => {
15
15
  case "empty": return parts.length === 0;
16
16
  case "no-text": {
17
17
  const last = parts[parts.length - 1];
18
- return last !== void 0 && last.type !== "text" && last.type !== "reasoning";
18
+ return last === void 0 || last.type !== "text" && last.type !== "reasoning";
19
19
  }
20
20
  }
21
21
  };
@@ -35,7 +35,7 @@ const renderNode = (node, parts, render) => {
35
35
  part,
36
36
  children: /* @__PURE__ */ jsx(PartChildrenSentinel, {})
37
37
  })
38
- }, `part-${node.index}`);
38
+ }, node.idKey ? `part-${node.idKey}` : `part-${node.index}`);
39
39
  const status = parts[node.indices.at(-1)]?.status ?? COMPLETE_STATUS;
40
40
  return /* @__PURE__ */ jsx(Fragment, { children: render({
41
41
  part: {
@@ -44,7 +44,7 @@ const renderNode = (node, parts, render) => {
44
44
  indices: node.indices
45
45
  },
46
46
  children: /* @__PURE__ */ jsx(Fragment$1, { children: node.children.map((child) => renderNode(child, parts, render)) })
47
- }) }, node.nodeKey);
47
+ }) }, node.idKey ?? node.nodeKey);
48
48
  };
49
49
  /**
50
50
  * Groups adjacent message parts into a tree of coalesced runs and
@@ -81,11 +81,11 @@ const renderNode = (node, parts, render) => {
81
81
  */
82
82
  const MessagePrimitiveGroupedParts = ({ groupBy, indicator = "no-text", children }) => {
83
83
  const parts = useAuiState(useShallow((s) => s.message.parts));
84
- const toolUIs = useAuiState((s) => s.tools.toolUIs);
85
- const isRunning = useAuiState((s) => indicator === "never" ? false : s.message.status?.type === "running");
84
+ const toolUIs = useAuiState((s_0) => s_0.tools.toolUIs);
85
+ const isRunning = useAuiState((s_1) => indicator === "never" ? false : s_1.message.status?.type === "running");
86
86
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [useMemo(() => {
87
87
  const context = { toolUIs };
88
- return buildGroupTree(parts.map((part) => groupBy(part, context) ?? []));
88
+ return buildGroupTree(parts.map((part) => groupBy(part, context) ?? []), parts.map((part_0) => part_0.type === "tool-call" ? part_0.toolCallId : void 0));
89
89
  }, [
90
90
  parts,
91
91
  groupBy[GROUPBY_MEMO_KEY] ?? groupBy,