@assistant-ui/core 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (437) hide show
  1. package/dist/adapters/attachment.d.ts.map +1 -1
  2. package/dist/adapters/attachment.js +22 -12
  3. package/dist/adapters/attachment.js.map +1 -1
  4. package/dist/adapters/directive-formatter.js.map +1 -1
  5. package/dist/adapters/speech.js.map +1 -1
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.js +2 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal.js +1 -1
  10. package/dist/model-context/frame/host.js.map +1 -1
  11. package/dist/model-context/frame/provider.js.map +1 -1
  12. package/dist/model-context/registry.js.map +1 -1
  13. package/dist/model-context/tool.d.ts +1 -1
  14. package/dist/model-context/tool.js +1 -1
  15. package/dist/model-context/tool.js.map +1 -1
  16. package/dist/model-context/types.js +17 -2
  17. package/dist/model-context/types.js.map +1 -1
  18. package/dist/react/AssistantProvider.js +1 -1
  19. package/dist/react/AssistantRuntimeProvider.d.ts +1 -1
  20. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  21. package/dist/react/AssistantRuntimeProvider.js +1 -1
  22. package/dist/react/RuntimeAdapter.js +4 -2
  23. package/dist/react/RuntimeAdapter.js.map +1 -1
  24. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  25. package/dist/react/adapters/LocalStorageThreadListAdapter.js +13 -3
  26. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  27. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  28. package/dist/react/client/DataRenderers.js +6 -5
  29. package/dist/react/client/DataRenderers.js.map +1 -1
  30. package/dist/react/client/Interactables.d.ts.map +1 -1
  31. package/dist/react/client/Interactables.js +30 -29
  32. package/dist/react/client/Interactables.js.map +1 -1
  33. package/dist/react/client/Tools.d.ts.map +1 -1
  34. package/dist/react/client/Tools.js +19 -12
  35. package/dist/react/client/Tools.js.map +1 -1
  36. package/dist/react/index.d.ts +10 -5
  37. package/dist/react/index.js +7 -2
  38. package/dist/react/model-context/define-mcp-toolkit.d.ts +12 -0
  39. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -0
  40. package/dist/react/model-context/define-mcp-toolkit.js +14 -0
  41. package/dist/react/model-context/define-mcp-toolkit.js.map +1 -0
  42. package/dist/react/model-context/define-toolkit.d.ts +10 -12
  43. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  44. package/dist/react/model-context/define-toolkit.js +2 -15
  45. package/dist/react/model-context/define-toolkit.js.map +1 -1
  46. package/dist/react/model-context/external-tool.d.ts +14 -0
  47. package/dist/react/model-context/external-tool.d.ts.map +1 -0
  48. package/dist/react/model-context/external-tool.js +17 -0
  49. package/dist/react/model-context/external-tool.js.map +1 -0
  50. package/dist/react/model-context/human-tool.d.ts +27 -0
  51. package/dist/react/model-context/human-tool.d.ts.map +1 -0
  52. package/dist/react/model-context/human-tool.js +30 -0
  53. package/dist/react/model-context/human-tool.js.map +1 -0
  54. package/dist/react/model-context/makeAssistantTool.d.ts +8 -0
  55. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  56. package/dist/react/model-context/makeAssistantTool.js +4 -0
  57. package/dist/react/model-context/makeAssistantTool.js.map +1 -1
  58. package/dist/react/model-context/makeAssistantToolUI.d.ts +8 -0
  59. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  60. package/dist/react/model-context/makeAssistantToolUI.js +4 -0
  61. package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
  62. package/dist/react/model-context/provider-tool.d.ts +15 -0
  63. package/dist/react/model-context/provider-tool.d.ts.map +1 -0
  64. package/dist/react/model-context/provider-tool.js +12 -0
  65. package/dist/react/model-context/provider-tool.js.map +1 -0
  66. package/dist/react/model-context/stub-tool.d.ts +12 -0
  67. package/dist/react/model-context/stub-tool.d.ts.map +1 -0
  68. package/dist/react/model-context/stub-tool.js +15 -0
  69. package/dist/react/model-context/stub-tool.js.map +1 -0
  70. package/dist/react/model-context/toolbox.d.ts +64 -17
  71. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  72. package/dist/react/model-context/toolbox.js +19 -1
  73. package/dist/react/model-context/toolbox.js.map +1 -1
  74. package/dist/react/model-context/useAssistantContext.js +1 -1
  75. package/dist/react/model-context/useAssistantContext.js.map +1 -1
  76. package/dist/react/model-context/useAssistantDataUI.js +1 -1
  77. package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
  78. package/dist/react/model-context/useAssistantInstructions.js +1 -1
  79. package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
  80. package/dist/react/model-context/useAssistantInteractable.js +1 -1
  81. package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
  82. package/dist/react/model-context/useAssistantTool.d.ts +11 -1
  83. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  84. package/dist/react/model-context/useAssistantTool.js +12 -6
  85. package/dist/react/model-context/useAssistantTool.js.map +1 -1
  86. package/dist/react/model-context/useAssistantToolUI.d.ts +13 -4
  87. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  88. package/dist/react/model-context/useAssistantToolUI.js +7 -4
  89. package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
  90. package/dist/react/model-context/useAuiToolOverrides.d.ts +22 -0
  91. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -0
  92. package/dist/react/model-context/useAuiToolOverrides.js +31 -0
  93. package/dist/react/model-context/useAuiToolOverrides.js.map +1 -0
  94. package/dist/react/model-context/useInlineRender.js +1 -1
  95. package/dist/react/model-context/useInlineRender.js.map +1 -1
  96. package/dist/react/model-context/useInteractableState.js +1 -1
  97. package/dist/react/model-context/useInteractableState.js.map +1 -1
  98. package/dist/react/model-context/useToolArgsStatus.js +1 -1
  99. package/dist/react/primitive-hooks/useActionBarCopy.js +1 -1
  100. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  101. package/dist/react/primitive-hooks/useActionBarEdit.js +1 -1
  102. package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
  103. package/dist/react/primitive-hooks/useActionBarFeedback.js +1 -1
  104. package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
  105. package/dist/react/primitive-hooks/useActionBarReload.js +1 -1
  106. package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
  107. package/dist/react/primitive-hooks/useActionBarSpeak.js +1 -1
  108. package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
  109. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +1 -1
  110. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
  111. package/dist/react/primitive-hooks/useBranchPickerNext.js +1 -1
  112. package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
  113. package/dist/react/primitive-hooks/useBranchPickerPrevious.js +1 -1
  114. package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
  115. package/dist/react/primitive-hooks/useComposerAddAttachment.js +1 -1
  116. package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
  117. package/dist/react/primitive-hooks/useComposerCancel.js +1 -1
  118. package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
  119. package/dist/react/primitive-hooks/useComposerDictate.js +1 -1
  120. package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
  121. package/dist/react/primitive-hooks/useComposerSend.js +1 -1
  122. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  123. package/dist/react/primitive-hooks/useEditComposerCancel.js +1 -1
  124. package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
  125. package/dist/react/primitive-hooks/useEditComposerSend.js +1 -1
  126. package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
  127. package/dist/react/primitive-hooks/useMessageBranching.js +1 -1
  128. package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
  129. package/dist/react/primitive-hooks/useMessageReload.js +1 -1
  130. package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
  131. package/dist/react/primitive-hooks/useSuggestionTrigger.js +1 -1
  132. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  133. package/dist/react/primitive-hooks/useThreadListItemArchive.js +1 -1
  134. package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
  135. package/dist/react/primitive-hooks/useThreadListItemDelete.js +1 -1
  136. package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
  137. package/dist/react/primitive-hooks/useThreadListItemTrigger.js +1 -1
  138. package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
  139. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +1 -1
  140. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
  141. package/dist/react/primitive-hooks/useThreadListLoadMore.js +1 -1
  142. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
  143. package/dist/react/primitive-hooks/useThreadListNew.js +1 -1
  144. package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
  145. package/dist/react/primitive-hooks/useVoice.js +1 -1
  146. package/dist/react/primitive-hooks/useVoice.js.map +1 -1
  147. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +1 -1
  148. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
  149. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
  150. package/dist/react/primitives/composer/ComposerAttachments.js +1 -1
  151. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
  152. package/dist/react/primitives/composer/ComposerQueue.js +1 -1
  153. package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
  154. package/dist/react/primitives/generativeUI/GenerativeUI.js +1 -1
  155. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  156. package/dist/react/primitives/message/MessageAttachments.js +1 -1
  157. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  158. package/dist/react/primitives/message/MessageGroupedParts.js +1 -1
  159. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  160. package/dist/react/primitives/message/MessageParts.d.ts +1 -1
  161. package/dist/react/primitives/message/MessageParts.js +1 -1
  162. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  163. package/dist/react/primitives/message/MessageQuote.js +1 -1
  164. package/dist/react/primitives/part/PartMessages.d.ts +12 -10
  165. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  166. package/dist/react/primitives/part/PartMessages.js +13 -11
  167. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  168. package/dist/react/primitives/thread/ThreadMessages.js +1 -1
  169. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  170. package/dist/react/primitives/thread/ThreadSuggestions.js +1 -1
  171. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  172. package/dist/react/primitives/threadList/ThreadListItems.js +1 -1
  173. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
  174. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
  175. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
  176. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  177. package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
  178. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  179. package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
  180. package/dist/react/providers/ReadonlyThreadProvider.js +1 -1
  181. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  182. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
  183. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  184. package/dist/react/providers/TextMessagePartProvider.js +4 -3
  185. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  186. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
  187. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +7 -0
  188. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  189. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +1 -1
  190. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  191. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +8 -0
  192. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  193. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +29 -1
  194. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  195. package/dist/react/runtimes/RuntimeAdapterProvider.js +1 -1
  196. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +1 -1
  197. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  198. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  199. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +10 -3
  200. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  201. package/dist/react/runtimes/createMessageConverter.d.ts +2 -2
  202. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  203. package/dist/react/runtimes/createMessageConverter.js.map +1 -1
  204. package/dist/react/runtimes/external-message-converter.d.ts +4 -3
  205. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  206. package/dist/react/runtimes/external-message-converter.js +1 -1
  207. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  208. package/dist/react/runtimes/useExternalStoreRuntime.js +1 -1
  209. package/dist/react/runtimes/useExternalStoreSharedOptions.js +1 -1
  210. package/dist/react/runtimes/useLocalRuntime.d.ts +2 -1
  211. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  212. package/dist/react/runtimes/useLocalRuntime.js +4 -3
  213. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  214. package/dist/react/runtimes/useRemoteThreadListRuntime.js +1 -1
  215. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  216. package/dist/react/utils/groupParts.d.ts +1 -1
  217. package/dist/react/utils/groupParts.js.map +1 -1
  218. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  219. package/dist/runtime/api/composer-runtime.d.ts +8 -2
  220. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  221. package/dist/runtime/api/composer-runtime.js +14 -0
  222. package/dist/runtime/api/composer-runtime.js.map +1 -1
  223. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  224. package/dist/runtime/api/message-runtime.js +1 -1
  225. package/dist/runtime/api/message-runtime.js.map +1 -1
  226. package/dist/runtime/api/thread-list-item-runtime.d.ts +2 -0
  227. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  228. package/dist/runtime/api/thread-list-item-runtime.js +6 -0
  229. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  230. package/dist/runtime/api/thread-runtime.d.ts +7 -0
  231. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  232. package/dist/runtime/api/thread-runtime.js.map +1 -1
  233. package/dist/runtime/base/base-composer-runtime-core.d.ts +4 -0
  234. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  235. package/dist/runtime/base/base-composer-runtime-core.js +7 -1
  236. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  237. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  238. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +4 -0
  239. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  240. package/dist/runtime/base/default-thread-composer-runtime-core.js +17 -1
  241. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  242. package/dist/runtime/interfaces/composer-runtime-core.d.ts +6 -1
  243. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  244. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
  245. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  246. package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -0
  247. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  248. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +20 -0
  249. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -0
  250. package/dist/runtime/queue/external-thread-queue-adapter.js +0 -0
  251. package/dist/runtime/queue/message-queue.d.ts +20 -0
  252. package/dist/runtime/queue/message-queue.d.ts.map +1 -0
  253. package/dist/runtime/queue/message-queue.js +97 -0
  254. package/dist/runtime/queue/message-queue.js.map +1 -0
  255. package/dist/runtime/utils/message-repository.js.map +1 -1
  256. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  257. package/dist/runtimes/external-store/external-store-adapter.d.ts +5 -1
  258. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  259. package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
  260. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -0
  261. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  262. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +5 -0
  263. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  264. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +4 -0
  265. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  266. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +20 -2
  267. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  268. package/dist/runtimes/local/local-runtime-core.js.map +1 -1
  269. package/dist/runtimes/local/local-runtime-options.d.ts +5 -0
  270. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  271. package/dist/runtimes/local/local-thread-runtime-core.d.ts +7 -0
  272. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  273. package/dist/runtimes/local/local-thread-runtime-core.js +45 -0
  274. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  275. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +3 -0
  276. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  277. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +3 -0
  278. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  279. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -0
  280. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  281. package/dist/runtimes/remote-thread-list/adapter/in-memory.js +3 -0
  282. package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
  283. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  284. package/dist/runtimes/remote-thread-list/empty-thread-core.js +3 -0
  285. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  286. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  287. package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
  288. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  289. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  290. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  291. package/dist/store/clients/chain-of-thought-client.js +6 -5
  292. package/dist/store/clients/chain-of-thought-client.js.map +1 -1
  293. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  294. package/dist/store/clients/model-context-client.js +6 -5
  295. package/dist/store/clients/model-context-client.js.map +1 -1
  296. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  297. package/dist/store/clients/no-op-composer-client.js +4 -3
  298. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  299. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  300. package/dist/store/clients/runtime-adapter.js +7 -6
  301. package/dist/store/clients/runtime-adapter.js.map +1 -1
  302. package/dist/store/clients/suggestions.d.ts.map +1 -1
  303. package/dist/store/clients/suggestions.js +7 -6
  304. package/dist/store/clients/suggestions.js.map +1 -1
  305. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  306. package/dist/store/clients/thread-message-client.js +13 -12
  307. package/dist/store/clients/thread-message-client.js.map +1 -1
  308. package/dist/store/index.d.ts +1 -1
  309. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  310. package/dist/store/runtime-clients/attachment-runtime-client.js +3 -3
  311. package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
  312. package/dist/store/runtime-clients/composer-runtime-client.d.ts +12 -5
  313. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  314. package/dist/store/runtime-clients/composer-runtime-client.js +32 -16
  315. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  316. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  317. package/dist/store/runtime-clients/message-part-runtime-client.js +3 -3
  318. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  319. package/dist/store/runtime-clients/message-runtime-client.d.ts +6 -3
  320. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  321. package/dist/store/runtime-clients/message-runtime-client.js +17 -16
  322. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  323. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  324. package/dist/store/runtime-clients/thread-list-item-runtime-client.js +9 -7
  325. package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
  326. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  327. package/dist/store/runtime-clients/thread-list-runtime-client.js +11 -10
  328. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  329. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  330. package/dist/store/runtime-clients/thread-runtime-client.js +15 -14
  331. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  332. package/dist/store/runtime-clients/useSubscribable.d.ts +7 -0
  333. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -0
  334. package/dist/store/runtime-clients/useSubscribable.js +16 -0
  335. package/dist/store/runtime-clients/useSubscribable.js.map +1 -0
  336. package/dist/store/scope-registration.d.ts +1 -1
  337. package/dist/store/scopes/composer.d.ts +1 -1
  338. package/dist/store/scopes/queue-item.d.ts +2 -1
  339. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  340. package/dist/store/scopes/queue-item.js +6 -0
  341. package/dist/store/scopes/queue-item.js.map +1 -0
  342. package/dist/store/scopes/thread-list-item.d.ts +1 -0
  343. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  344. package/dist/store/scopes/thread.d.ts +1 -1
  345. package/dist/store/scopes/threads.d.ts +1 -1
  346. package/dist/types/message.d.ts +2 -1
  347. package/dist/types/message.d.ts.map +1 -1
  348. package/dist/types/message.js.map +1 -1
  349. package/dist/utils/composite-context-provider.d.ts +1 -1
  350. package/dist/utils/composite-context-provider.js +3 -1
  351. package/dist/utils/composite-context-provider.js.map +1 -1
  352. package/dist/utils/json/is-json.js.map +1 -1
  353. package/dist/utils/text.js.map +1 -1
  354. package/package.json +15 -11
  355. package/src/adapters/attachment.ts +24 -4
  356. package/src/index.ts +8 -0
  357. package/src/model-context/tool.ts +1 -1
  358. package/src/model-context/types.ts +21 -3
  359. package/src/react/RuntimeAdapter.ts +6 -4
  360. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +15 -2
  361. package/src/react/client/DataRenderers.ts +48 -42
  362. package/src/react/client/Interactables.ts +263 -267
  363. package/src/react/client/Tools.ts +123 -115
  364. package/src/react/index.ts +16 -3
  365. package/src/react/model-context/define-mcp-toolkit.ts +16 -0
  366. package/src/react/model-context/define-toolkit.test.ts +101 -6
  367. package/src/react/model-context/define-toolkit.ts +35 -18
  368. package/src/react/model-context/external-tool.ts +16 -0
  369. package/src/react/model-context/human-tool.ts +32 -0
  370. package/src/react/model-context/makeAssistantTool.ts +8 -0
  371. package/src/react/model-context/makeAssistantToolUI.ts +8 -0
  372. package/src/react/model-context/provider-tool.ts +30 -0
  373. package/src/react/model-context/stub-tool.ts +14 -0
  374. package/src/react/model-context/toolbox.test.ts +182 -0
  375. package/src/react/model-context/toolbox.ts +191 -23
  376. package/src/react/model-context/useAssistantTool.ts +28 -8
  377. package/src/react/model-context/useAssistantToolUI.ts +13 -4
  378. package/src/react/model-context/useAuiToolOverrides.ts +38 -0
  379. package/src/react/primitives/message/MessageGroupedParts.tsx +1 -1
  380. package/src/react/primitives/part/PartMessages.tsx +12 -10
  381. package/src/react/providers/TextMessagePartProvider.tsx +31 -32
  382. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +43 -0
  383. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +9 -0
  384. package/src/react/runtimes/createMessageConverter.ts +2 -1
  385. package/src/react/runtimes/external-message-converter.ts +5 -3
  386. package/src/react/runtimes/useLocalRuntime.ts +2 -0
  387. package/src/runtime/api/composer-runtime.ts +26 -0
  388. package/src/runtime/api/thread-list-item-runtime.ts +15 -0
  389. package/src/runtime/base/base-composer-runtime-core.ts +11 -0
  390. package/src/runtime/base/default-thread-composer-runtime-core.ts +22 -0
  391. package/src/runtime/interfaces/composer-runtime-core.ts +7 -0
  392. package/src/runtime/interfaces/thread-list-runtime-core.ts +4 -0
  393. package/src/runtime/interfaces/thread-runtime-core.ts +5 -0
  394. package/src/runtime/queue/external-thread-queue-adapter.ts +14 -0
  395. package/src/runtime/queue/message-queue.ts +128 -0
  396. package/src/runtimes/external-store/external-store-adapter.ts +10 -0
  397. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +13 -0
  398. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +31 -2
  399. package/src/runtimes/local/local-runtime-options.ts +6 -0
  400. package/src/runtimes/local/local-thread-runtime-core.ts +70 -0
  401. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +4 -0
  402. package/src/runtimes/remote-thread-list/adapter/in-memory.ts +4 -0
  403. package/src/runtimes/remote-thread-list/empty-thread-core.ts +4 -0
  404. package/src/runtimes/remote-thread-list/types.ts +4 -0
  405. package/src/store/clients/chain-of-thought-client.ts +24 -25
  406. package/src/store/clients/model-context-client.test.ts +87 -2
  407. package/src/store/clients/model-context-client.ts +22 -19
  408. package/src/store/clients/no-op-composer-client.ts +69 -66
  409. package/src/store/clients/runtime-adapter.ts +9 -6
  410. package/src/store/clients/suggestions.ts +41 -40
  411. package/src/store/clients/thread-message-client.ts +127 -132
  412. package/src/store/runtime-clients/attachment-runtime-client.ts +7 -3
  413. package/src/store/runtime-clients/composer-runtime-client.ts +142 -113
  414. package/src/store/runtime-clients/message-part-runtime-client.ts +16 -14
  415. package/src/store/runtime-clients/message-runtime-client.ts +124 -122
  416. package/src/store/runtime-clients/thread-list-item-runtime-client.ts +44 -44
  417. package/src/store/runtime-clients/thread-list-runtime-client.ts +83 -80
  418. package/src/store/runtime-clients/thread-runtime-client.ts +113 -119
  419. package/src/store/runtime-clients/{tap-subscribable.ts → useSubscribable.ts} +4 -4
  420. package/src/store/scopes/queue-item.ts +2 -0
  421. package/src/store/scopes/thread-list-item.ts +1 -0
  422. package/src/tests/RemoteThreadListThreadListRuntimeCore-custom-metadata.test.ts +69 -1
  423. package/src/tests/attachment-adapters.test.ts +86 -0
  424. package/src/tests/external-store-thread-runtime-core.test.ts +125 -0
  425. package/src/tests/message-queue.test.ts +168 -0
  426. package/src/tests/thread-list-runtime-getLoadThreadsPromise.test.ts +1 -0
  427. package/src/types/message.ts +2 -0
  428. package/src/utils/composite-context-provider.ts +3 -1
  429. package/dist/react/model-context/hitl.d.ts +0 -19
  430. package/dist/react/model-context/hitl.d.ts.map +0 -1
  431. package/dist/react/model-context/hitl.js +0 -22
  432. package/dist/react/model-context/hitl.js.map +0 -1
  433. package/dist/store/runtime-clients/tap-subscribable.d.ts +0 -7
  434. package/dist/store/runtime-clients/tap-subscribable.d.ts.map +0 -1
  435. package/dist/store/runtime-clients/tap-subscribable.js +0 -16
  436. package/dist/store/runtime-clients/tap-subscribable.js.map +0 -1
  437. package/src/react/model-context/hitl.ts +0 -22
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui, useAuiState } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useMessageBranching.ts
4
4
  const useMessageBranching = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useMessageBranching.js","names":[],"sources":["../../../src/react/primitive-hooks/useMessageBranching.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport const useMessageBranching = () => {\n const aui = useAui();\n const branchNumber = useAuiState((s) => s.message.branchNumber);\n const branchCount = useAuiState((s) => s.message.branchCount);\n\n const goToPrev = useCallback(() => {\n aui.message().switchToBranch({ position: \"previous\" });\n }, [aui]);\n\n const goToNext = useCallback(() => {\n aui.message().switchToBranch({ position: \"next\" });\n }, [aui]);\n\n return { branchNumber, branchCount, goToPrev, goToNext };\n};\n"],"mappings":";;;AAGA,MAAa,4BAA4B;CACvC,MAAM,MAAM,OAAO;CAYnB,OAAO;EAAE,cAXY,aAAa,MAAM,EAAE,QAAQ,YAW9B;EAAG,aAVH,aAAa,MAAM,EAAE,QAAQ,WAUhB;EAAG,UARnB,kBAAkB;GACjC,IAAI,QAAQ,EAAE,eAAe,EAAE,UAAU,WAAW,CAAC;EACvD,GAAG,CAAC,GAAG,CAMoC;EAAG,UAJ7B,kBAAkB;GACjC,IAAI,QAAQ,EAAE,eAAe,EAAE,UAAU,OAAO,CAAC;EACnD,GAAG,CAAC,GAAG,CAE8C;CAAE;AACzD"}
1
+ {"version":3,"file":"useMessageBranching.js","names":[],"sources":["../../../src/react/primitive-hooks/useMessageBranching.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport const useMessageBranching = () => {\n const aui = useAui();\n const branchNumber = useAuiState((s) => s.message.branchNumber);\n const branchCount = useAuiState((s) => s.message.branchCount);\n\n const goToPrev = useCallback(() => {\n aui.message().switchToBranch({ position: \"previous\" });\n }, [aui]);\n\n const goToNext = useCallback(() => {\n aui.message().switchToBranch({ position: \"next\" });\n }, [aui]);\n\n return { branchNumber, branchCount, goToPrev, goToNext };\n};\n"],"mappings":";;;AAGA,MAAa,4BAA4B;CACvC,MAAM,MAAM,OAAO;CAYnB,OAAO;EAAE,cAXY,aAAa,MAAM,EAAE,QAAQ,YAW9B;EAAG,aAVH,aAAa,MAAM,EAAE,QAAQ,WAUhB;EAAG,UARnB,kBAAkB;GACjC,IAAI,QAAQ,CAAC,CAAC,eAAe,EAAE,UAAU,WAAW,CAAC;EACvD,GAAG,CAAC,GAAG,CAMoC;EAAG,UAJ7B,kBAAkB;GACjC,IAAI,QAAQ,CAAC,CAAC,eAAe,EAAE,UAAU,OAAO,CAAC;EACnD,GAAG,CAAC,GAAG,CAE8C;CAAE;AACzD"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui, useAuiState } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useMessageReload.ts
4
4
  const useMessageReload = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useMessageReload.js","names":[],"sources":["../../../src/react/primitive-hooks/useMessageReload.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport const useMessageReload = () => {\n const aui = useAui();\n const canReload = useAuiState((s) => s.message.role === \"assistant\");\n\n const reload = useCallback(() => {\n aui.message().reload();\n }, [aui]);\n\n return { reload, canReload };\n};\n"],"mappings":";;;AAGA,MAAa,yBAAyB;CACpC,MAAM,MAAM,OAAO;CACnB,MAAM,YAAY,aAAa,MAAM,EAAE,QAAQ,SAAS,WAAW;CAMnE,OAAO;EAAE,QAJM,kBAAkB;GAC/B,IAAI,QAAQ,EAAE,OAAO;EACvB,GAAG,CAAC,GAAG,CAEO;EAAG;CAAU;AAC7B"}
1
+ {"version":3,"file":"useMessageReload.js","names":[],"sources":["../../../src/react/primitive-hooks/useMessageReload.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport const useMessageReload = () => {\n const aui = useAui();\n const canReload = useAuiState((s) => s.message.role === \"assistant\");\n\n const reload = useCallback(() => {\n aui.message().reload();\n }, [aui]);\n\n return { reload, canReload };\n};\n"],"mappings":";;;AAGA,MAAa,yBAAyB;CACpC,MAAM,MAAM,OAAO;CACnB,MAAM,YAAY,aAAa,MAAM,EAAE,QAAQ,SAAS,WAAW;CAMnE,OAAO;EAAE,QAJM,kBAAkB;GAC/B,IAAI,QAAQ,CAAC,CAAC,OAAO;EACvB,GAAG,CAAC,GAAG,CAEO;EAAG;CAAU;AAC7B"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui, useAuiState } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useSuggestionTrigger.ts
4
4
  const useSuggestionTrigger = ({ prompt, send, clearComposer = true }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useSuggestionTrigger.js","names":[],"sources":["../../../src/react/primitive-hooks/useSuggestionTrigger.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport type UseSuggestionTriggerOptions = {\n prompt: string;\n send?: boolean | undefined;\n clearComposer?: boolean | undefined;\n};\n\nexport const useSuggestionTrigger = ({\n prompt,\n send,\n clearComposer = true,\n}: UseSuggestionTriggerOptions) => {\n const aui = useAui();\n const disabled = useAuiState((s) => s.thread.isDisabled);\n const resolvedSend = send ?? false;\n\n const trigger = useCallback(() => {\n const isRunning = aui.thread().getState().isRunning;\n\n if (resolvedSend && !isRunning) {\n aui.thread().append({\n content: [{ type: \"text\", text: prompt }],\n runConfig: aui.composer().getState().runConfig,\n });\n if (clearComposer) {\n aui.composer().setText(\"\");\n }\n } else {\n if (clearComposer) {\n aui.composer().setText(prompt);\n } else {\n const currentText = aui.composer().getState().text;\n aui\n .composer()\n .setText(currentText.trim() ? `${currentText} ${prompt}` : prompt);\n }\n }\n }, [aui, resolvedSend, clearComposer, prompt]);\n\n return { trigger, disabled };\n};\n"],"mappings":";;;AASA,MAAa,wBAAwB,EACnC,QACA,MACA,gBAAgB,WACiB;CACjC,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,aAAa,MAAM,EAAE,OAAO,UAAU;CACvD,MAAM,eAAe,QAAQ;CAyB7B,OAAO;EAAE,SAvBO,kBAAkB;GAChC,MAAM,YAAY,IAAI,OAAO,EAAE,SAAS,EAAE;GAE1C,IAAI,gBAAgB,CAAC,WAAW;IAC9B,IAAI,OAAO,EAAE,OAAO;KAClB,SAAS,CAAC;MAAE,MAAM;MAAQ,MAAM;KAAO,CAAC;KACxC,WAAW,IAAI,SAAS,EAAE,SAAS,EAAE;IACvC,CAAC;IACD,IAAI,eACF,IAAI,SAAS,EAAE,QAAQ,EAAE;GAE7B,OACE,IAAI,eACF,IAAI,SAAS,EAAE,QAAQ,MAAM;QACxB;IACL,MAAM,cAAc,IAAI,SAAS,EAAE,SAAS,EAAE;IAC9C,IACG,SAAS,EACT,QAAQ,YAAY,KAAK,IAAI,GAAG,YAAY,GAAG,WAAW,MAAM;GACrE;EAEJ,GAAG;GAAC;GAAK;GAAc;GAAe;EAAM,CAE7B;EAAG;CAAS;AAC7B"}
1
+ {"version":3,"file":"useSuggestionTrigger.js","names":[],"sources":["../../../src/react/primitive-hooks/useSuggestionTrigger.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport type UseSuggestionTriggerOptions = {\n prompt: string;\n send?: boolean | undefined;\n clearComposer?: boolean | undefined;\n};\n\nexport const useSuggestionTrigger = ({\n prompt,\n send,\n clearComposer = true,\n}: UseSuggestionTriggerOptions) => {\n const aui = useAui();\n const disabled = useAuiState((s) => s.thread.isDisabled);\n const resolvedSend = send ?? false;\n\n const trigger = useCallback(() => {\n const isRunning = aui.thread().getState().isRunning;\n\n if (resolvedSend && !isRunning) {\n aui.thread().append({\n content: [{ type: \"text\", text: prompt }],\n runConfig: aui.composer().getState().runConfig,\n });\n if (clearComposer) {\n aui.composer().setText(\"\");\n }\n } else {\n if (clearComposer) {\n aui.composer().setText(prompt);\n } else {\n const currentText = aui.composer().getState().text;\n aui\n .composer()\n .setText(currentText.trim() ? `${currentText} ${prompt}` : prompt);\n }\n }\n }, [aui, resolvedSend, clearComposer, prompt]);\n\n return { trigger, disabled };\n};\n"],"mappings":";;;AASA,MAAa,wBAAwB,EACnC,QACA,MACA,gBAAgB,WACiB;CACjC,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,aAAa,MAAM,EAAE,OAAO,UAAU;CACvD,MAAM,eAAe,QAAQ;CAyB7B,OAAO;EAAE,SAvBO,kBAAkB;GAChC,MAAM,YAAY,IAAI,OAAO,CAAC,CAAC,SAAS,CAAC,CAAC;GAE1C,IAAI,gBAAgB,CAAC,WAAW;IAC9B,IAAI,OAAO,CAAC,CAAC,OAAO;KAClB,SAAS,CAAC;MAAE,MAAM;MAAQ,MAAM;KAAO,CAAC;KACxC,WAAW,IAAI,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,eACF,IAAI,SAAS,CAAC,CAAC,QAAQ,EAAE;GAE7B,OACE,IAAI,eACF,IAAI,SAAS,CAAC,CAAC,QAAQ,MAAM;QACxB;IACL,MAAM,cAAc,IAAI,SAAS,CAAC,CAAC,SAAS,CAAC,CAAC;IAC9C,IACG,SAAS,CAAC,CACV,QAAQ,YAAY,KAAK,IAAI,GAAG,YAAY,GAAG,WAAW,MAAM;GACrE;EAEJ,GAAG;GAAC;GAAK;GAAc;GAAe;EAAM,CAE7B;EAAG;CAAS;AAC7B"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useThreadListItemArchive.ts
4
4
  const useThreadListItemArchive = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadListItemArchive.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemArchive.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemArchive = () => {\n const aui = useAui();\n\n const archive = useCallback(() => {\n aui.threadListItem().archive();\n }, [aui]);\n\n return { archive };\n};\n"],"mappings":";;;AAGA,MAAa,iCAAiC;CAC5C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,SAJO,kBAAkB;EAChC,IAAI,eAAe,EAAE,QAAQ;CAC/B,GAAG,CAAC,GAAG,CAEQ,EAAE;AACnB"}
1
+ {"version":3,"file":"useThreadListItemArchive.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemArchive.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemArchive = () => {\n const aui = useAui();\n\n const archive = useCallback(() => {\n aui.threadListItem().archive();\n }, [aui]);\n\n return { archive };\n};\n"],"mappings":";;;AAGA,MAAa,iCAAiC;CAC5C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,SAJO,kBAAkB;EAChC,IAAI,eAAe,CAAC,CAAC,QAAQ;CAC/B,GAAG,CAAC,GAAG,CAEQ,EAAE;AACnB"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useThreadListItemDelete.ts
4
4
  const useThreadListItemDelete = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadListItemDelete.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemDelete.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemDelete = () => {\n const aui = useAui();\n\n const deleteThread = useCallback(() => {\n aui.threadListItem().delete();\n }, [aui]);\n\n return { delete: deleteThread };\n};\n"],"mappings":";;;AAGA,MAAa,gCAAgC;CAC3C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,QAJY,kBAAkB;EACrC,IAAI,eAAe,EAAE,OAAO;CAC9B,GAAG,CAAC,GAAG,CAEqB,EAAE;AAChC"}
1
+ {"version":3,"file":"useThreadListItemDelete.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemDelete.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemDelete = () => {\n const aui = useAui();\n\n const deleteThread = useCallback(() => {\n aui.threadListItem().delete();\n }, [aui]);\n\n return { delete: deleteThread };\n};\n"],"mappings":";;;AAGA,MAAa,gCAAgC;CAC3C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,QAJY,kBAAkB;EACrC,IAAI,eAAe,CAAC,CAAC,OAAO;CAC9B,GAAG,CAAC,GAAG,CAEqB,EAAE;AAChC"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useThreadListItemTrigger.ts
4
4
  const useThreadListItemTrigger = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadListItemTrigger.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemTrigger.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemTrigger = () => {\n const aui = useAui();\n\n const switchTo = useCallback(() => {\n aui.threadListItem().switchTo();\n }, [aui]);\n\n return { switchTo };\n};\n"],"mappings":";;;AAGA,MAAa,iCAAiC;CAC5C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,UAJQ,kBAAkB;EACjC,IAAI,eAAe,EAAE,SAAS;CAChC,GAAG,CAAC,GAAG,CAES,EAAE;AACpB"}
1
+ {"version":3,"file":"useThreadListItemTrigger.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemTrigger.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemTrigger = () => {\n const aui = useAui();\n\n const switchTo = useCallback(() => {\n aui.threadListItem().switchTo();\n }, [aui]);\n\n return { switchTo };\n};\n"],"mappings":";;;AAGA,MAAa,iCAAiC;CAC5C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,UAJQ,kBAAkB;EACjC,IAAI,eAAe,CAAC,CAAC,SAAS;CAChC,GAAG,CAAC,GAAG,CAES,EAAE;AACpB"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useThreadListItemUnarchive.ts
4
4
  const useThreadListItemUnarchive = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadListItemUnarchive.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemUnarchive.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemUnarchive = () => {\n const aui = useAui();\n\n const unarchive = useCallback(() => {\n aui.threadListItem().unarchive();\n }, [aui]);\n\n return { unarchive };\n};\n"],"mappings":";;;AAGA,MAAa,mCAAmC;CAC9C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,WAJS,kBAAkB;EAClC,IAAI,eAAe,EAAE,UAAU;CACjC,GAAG,CAAC,GAAG,CAEU,EAAE;AACrB"}
1
+ {"version":3,"file":"useThreadListItemUnarchive.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListItemUnarchive.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListItemUnarchive = () => {\n const aui = useAui();\n\n const unarchive = useCallback(() => {\n aui.threadListItem().unarchive();\n }, [aui]);\n\n return { unarchive };\n};\n"],"mappings":";;;AAGA,MAAa,mCAAmC;CAC9C,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,WAJS,kBAAkB;EAClC,IAAI,eAAe,CAAC,CAAC,UAAU;CACjC,GAAG,CAAC,GAAG,CAEU,EAAE;AACrB"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui, useAuiState } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useThreadListLoadMore.ts
4
4
  const useThreadListLoadMore = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadListLoadMore.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListLoadMore.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport const useThreadListLoadMore = () => {\n const aui = useAui();\n const disabled = useAuiState(\n (s) => !s.threads.hasMore || s.threads.isLoading || s.threads.isLoadingMore,\n );\n\n const loadMore = useCallback(() => {\n aui.threads().loadMore();\n }, [aui]);\n\n return { loadMore, disabled };\n};\n"],"mappings":";;;AAGA,MAAa,8BAA8B;CACzC,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,aACd,MAAM,CAAC,EAAE,QAAQ,WAAW,EAAE,QAAQ,aAAa,EAAE,QAAQ,aAChE;CAMA,OAAO;EAAE,UAJQ,kBAAkB;GACjC,IAAI,QAAQ,EAAE,SAAS;EACzB,GAAG,CAAC,GAAG,CAES;EAAG;CAAS;AAC9B"}
1
+ {"version":3,"file":"useThreadListLoadMore.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListLoadMore.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\n\nexport const useThreadListLoadMore = () => {\n const aui = useAui();\n const disabled = useAuiState(\n (s) => !s.threads.hasMore || s.threads.isLoading || s.threads.isLoadingMore,\n );\n\n const loadMore = useCallback(() => {\n aui.threads().loadMore();\n }, [aui]);\n\n return { loadMore, disabled };\n};\n"],"mappings":";;;AAGA,MAAa,8BAA8B;CACzC,MAAM,MAAM,OAAO;CACnB,MAAM,WAAW,aACd,MAAM,CAAC,EAAE,QAAQ,WAAW,EAAE,QAAQ,aAAa,EAAE,QAAQ,aAChE;CAMA,OAAO;EAAE,UAJQ,kBAAkB;GACjC,IAAI,QAAQ,CAAC,CAAC,SAAS;EACzB,GAAG,CAAC,GAAG,CAES;EAAG;CAAS;AAC9B"}
@@ -1,4 +1,4 @@
1
- import { useCallback } from "react";
1
+ import { useCallback } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useThreadListNew.ts
4
4
  const useThreadListNew = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useThreadListNew.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListNew.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListNew = () => {\n const aui = useAui();\n\n const switchToNewThread = useCallback(() => {\n aui.threads().switchToNewThread();\n }, [aui]);\n\n return { switchToNewThread };\n};\n"],"mappings":";;;AAGA,MAAa,yBAAyB;CACpC,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,mBAJiB,kBAAkB;EAC1C,IAAI,QAAQ,EAAE,kBAAkB;CAClC,GAAG,CAAC,GAAG,CAEkB,EAAE;AAC7B"}
1
+ {"version":3,"file":"useThreadListNew.js","names":[],"sources":["../../../src/react/primitive-hooks/useThreadListNew.ts"],"sourcesContent":["import { useCallback } from \"react\";\nimport { useAui } from \"@assistant-ui/store\";\n\nexport const useThreadListNew = () => {\n const aui = useAui();\n\n const switchToNewThread = useCallback(() => {\n aui.threads().switchToNewThread();\n }, [aui]);\n\n return { switchToNewThread };\n};\n"],"mappings":";;;AAGA,MAAa,yBAAyB;CACpC,MAAM,MAAM,OAAO;CAMnB,OAAO,EAAE,mBAJiB,kBAAkB;EAC1C,IAAI,QAAQ,CAAC,CAAC,kBAAkB;CAClC,GAAG,CAAC,GAAG,CAEkB,EAAE;AAC7B"}
@@ -1,4 +1,4 @@
1
- import { useCallback, useSyncExternalStore } from "react";
1
+ import { useCallback, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
2
2
  import { useAui, useAuiState } from "@assistant-ui/store";
3
3
  //#region src/react/primitive-hooks/useVoice.ts
4
4
  const useVoiceState = () => {
@@ -1 +1 @@
1
- {"version":3,"file":"useVoice.js","names":[],"sources":["../../../src/react/primitive-hooks/useVoice.ts"],"sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { VoiceSessionState } from \"../../runtime/interfaces/thread-runtime-core\";\n\nexport const useVoiceState = (): VoiceSessionState | undefined => {\n return useAuiState((s) => s.thread.voice);\n};\n\nconst getServerVolume = () => 0;\n\nexport const useVoiceVolume = (): number => {\n const aui = useAui();\n const thread = aui.thread();\n return useSyncExternalStore(\n thread.subscribeVoiceVolume,\n thread.getVoiceVolume,\n getServerVolume,\n );\n};\n\nexport const useVoiceControls = () => {\n const aui = useAui();\n\n const connect = useCallback(() => {\n aui.thread().connectVoice();\n }, [aui]);\n\n const disconnect = useCallback(() => {\n aui.thread().disconnectVoice();\n }, [aui]);\n\n const mute = useCallback(() => {\n aui.thread().muteVoice();\n }, [aui]);\n\n const unmute = useCallback(() => {\n aui.thread().unmuteVoice();\n }, [aui]);\n\n return { connect, disconnect, mute, unmute };\n};\n"],"mappings":";;;AAIA,MAAa,sBAAqD;CAChE,OAAO,aAAa,MAAM,EAAE,OAAO,KAAK;AAC1C;AAEA,MAAM,wBAAwB;AAE9B,MAAa,uBAA+B;CAE1C,MAAM,SADM,OACK,EAAE,OAAO;CAC1B,OAAO,qBACL,OAAO,sBACP,OAAO,gBACP,eACF;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,MAAM,OAAO;CAkBnB,OAAO;EAAE,SAhBO,kBAAkB;GAChC,IAAI,OAAO,EAAE,aAAa;EAC5B,GAAG,CAAC,GAAG,CAcQ;EAAG,YAZC,kBAAkB;GACnC,IAAI,OAAO,EAAE,gBAAgB;EAC/B,GAAG,CAAC,GAAG,CAUoB;EAAG,MARjB,kBAAkB;GAC7B,IAAI,OAAO,EAAE,UAAU;EACzB,GAAG,CAAC,GAAG,CAM0B;EAAG,QAJrB,kBAAkB;GAC/B,IAAI,OAAO,EAAE,YAAY;EAC3B,GAAG,CAAC,GAAG,CAEkC;CAAE;AAC7C"}
1
+ {"version":3,"file":"useVoice.js","names":[],"sources":["../../../src/react/primitive-hooks/useVoice.ts"],"sourcesContent":["import { useCallback, useSyncExternalStore } from \"react\";\nimport { useAui, useAuiState } from \"@assistant-ui/store\";\nimport type { VoiceSessionState } from \"../../runtime/interfaces/thread-runtime-core\";\n\nexport const useVoiceState = (): VoiceSessionState | undefined => {\n return useAuiState((s) => s.thread.voice);\n};\n\nconst getServerVolume = () => 0;\n\nexport const useVoiceVolume = (): number => {\n const aui = useAui();\n const thread = aui.thread();\n return useSyncExternalStore(\n thread.subscribeVoiceVolume,\n thread.getVoiceVolume,\n getServerVolume,\n );\n};\n\nexport const useVoiceControls = () => {\n const aui = useAui();\n\n const connect = useCallback(() => {\n aui.thread().connectVoice();\n }, [aui]);\n\n const disconnect = useCallback(() => {\n aui.thread().disconnectVoice();\n }, [aui]);\n\n const mute = useCallback(() => {\n aui.thread().muteVoice();\n }, [aui]);\n\n const unmute = useCallback(() => {\n aui.thread().unmuteVoice();\n }, [aui]);\n\n return { connect, disconnect, mute, unmute };\n};\n"],"mappings":";;;AAIA,MAAa,sBAAqD;CAChE,OAAO,aAAa,MAAM,EAAE,OAAO,KAAK;AAC1C;AAEA,MAAM,wBAAwB;AAE9B,MAAa,uBAA+B;CAE1C,MAAM,SADM,OACK,CAAC,CAAC,OAAO;CAC1B,OAAO,qBACL,OAAO,sBACP,OAAO,gBACP,eACF;AACF;AAEA,MAAa,yBAAyB;CACpC,MAAM,MAAM,OAAO;CAkBnB,OAAO;EAAE,SAhBO,kBAAkB;GAChC,IAAI,OAAO,CAAC,CAAC,aAAa;EAC5B,GAAG,CAAC,GAAG,CAcQ;EAAG,YAZC,kBAAkB;GACnC,IAAI,OAAO,CAAC,CAAC,gBAAgB;EAC/B,GAAG,CAAC,GAAG,CAUoB;EAAG,MARjB,kBAAkB;GAC7B,IAAI,OAAO,CAAC,CAAC,UAAU;EACzB,GAAG,CAAC,GAAG,CAM0B;EAAG,QAJrB,kBAAkB;GAC/B,IAAI,OAAO,CAAC,CAAC,YAAY;EAC3B,GAAG,CAAC,GAAG,CAEkC;CAAE;AAC7C"}
@@ -1,5 +1,5 @@
1
- import { ReasoningMessagePartComponent, ToolCallMessagePartComponent } from "../../types/MessagePartComponentTypes.js";
2
1
  import { PartState } from "../../../store/scopes/part.js";
2
+ import { ReasoningMessagePartComponent, ToolCallMessagePartComponent } from "../../types/MessagePartComponentTypes.js";
3
3
  import { ComponentType, FC, PropsWithChildren, ReactNode } from "react";
4
4
 
5
5
  //#region src/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts
@@ -1,6 +1,6 @@
1
1
  import { ChainOfThoughtPartByIndexProvider } from "../../providers/ChainOfThoughtPartByIndexProvider.js";
2
2
  import { MessagePartComponent } from "../message/MessageParts.js";
3
- import { useMemo } from "react";
3
+ import { useMemo } from "@assistant-ui/tap/react-shim";
4
4
  import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
5
5
  import { jsx } from "react/jsx-runtime";
6
6
  //#region src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx
@@ -1 +1 @@
1
- {"version":3,"file":"ChainOfThoughtParts.js","names":[],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { ChainOfThoughtPartByIndexProvider } from \"../../providers/ChainOfThoughtPartByIndexProvider\";\nimport { MessagePartComponent } from \"../message/MessageParts\";\nimport type {\n ReasoningMessagePartComponent,\n ToolCallMessagePartComponent,\n} from \"../../types/MessagePartComponentTypes\";\n\ntype ChainOfThoughtPartsComponentConfig = {\n /** Component for rendering reasoning parts */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Fallback component for tool-call parts */\n tools?: {\n Fallback?: ToolCallMessagePartComponent | undefined;\n };\n /** Layout component to wrap the rendered parts when expanded */\n Layout?: ComponentType<PropsWithChildren> | undefined;\n};\n\nexport namespace ChainOfThoughtPrimitiveParts {\n export type Props =\n | {\n /**\n * @deprecated Use the children render function instead.\n */\n components?: ChainOfThoughtPartsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the part. */\n children: (value: { part: PartState }) => ReactNode;\n components?: never;\n };\n}\n\nconst ChainOfThoughtPrimitivePartsInner: FC<{\n children: (value: { part: PartState }) => ReactNode;\n}> = ({ children }) => {\n const partsLength = useAuiState((s) => s.chainOfThought.parts.length);\n\n return useMemo(\n () =>\n Array.from({ length: partsLength }, (_, index) => (\n <ChainOfThoughtPartByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.chainOfThought().part({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get part() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ChainOfThoughtPartByIndexProvider>\n )),\n [partsLength, children],\n );\n};\n\n/**\n * Renders the parts within a chain of thought, with support for collapsed/expanded states.\n *\n * When collapsed, no parts are shown. When expanded, all parts are rendered\n * using the provided component configuration through the part scope mechanism.\n */\nexport const ChainOfThoughtPrimitiveParts: FC<\n ChainOfThoughtPrimitiveParts.Props\n> = ({ components, children }) => {\n if (children) {\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {children}\n </ChainOfThoughtPrimitivePartsInner>\n );\n }\n\n // oxlint-disable-next-line react-hooks/rules-of-hooks -- intentional conditional hook below the early return above\n const messageComponents = useMemo(\n () => ({\n Reasoning: components?.Reasoning,\n tools: {\n Fallback: components?.tools?.Fallback,\n },\n }),\n [components?.Reasoning, components?.tools?.Fallback],\n );\n\n const Layout = components?.Layout;\n\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {() =>\n Layout ? (\n <Layout>\n <MessagePartComponent components={messageComponents} />\n </Layout>\n ) : (\n <MessagePartComponent components={messageComponents} />\n )\n }\n </ChainOfThoughtPrimitivePartsInner>\n );\n};\n\nChainOfThoughtPrimitiveParts.displayName = \"ChainOfThoughtPrimitive.Parts\";\n"],"mappings":";;;;;;AA2CA,MAAM,qCAEA,EAAE,eAAe;CACrB,MAAM,cAAc,aAAa,MAAM,EAAE,eAAe,MAAM,MAAM;CAEpE,OAAO,cAEH,MAAM,KAAK,EAAE,QAAQ,YAAY,IAAI,GAAG,UACtC,oBAAC,mCAAD;EAAsD;YACpD,oBAAC,4BAAD;GACE,eAAe,QACb,IAAI,eAAe,EAAE,KAAK,EAAE,MAAM,CAAC,EAAE,SAAS;cAG9C,YACA,SAAS,EACP,IAAI,OAAO;IACT,OAAO,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACK,GAdK,KAcL,CACpC,GACH,CAAC,aAAa,QAAQ,CACxB;AACF;;;;;;;AAQA,MAAa,gCAER,EAAE,YAAY,eAAe;CAChC,IAAI,UACF,OACE,oBAAC,mCAAD,EACG,SACgC,CAAA;CAKvC,MAAM,oBAAoB,eACjB;EACL,WAAW,YAAY;EACvB,OAAO,EACL,UAAU,YAAY,OAAO,SAC/B;CACF,IACA,CAAC,YAAY,WAAW,YAAY,OAAO,QAAQ,CACrD;CAEA,MAAM,SAAS,YAAY;CAE3B,OACE,oBAAC,mCAAD,EAAA,gBAEI,SACE,oBAAC,QAAD,EAAA,UACE,oBAAC,sBAAD,EAAsB,YAAY,kBAAoB,CAAA,EAChD,CAAA,IAER,oBAAC,sBAAD,EAAsB,YAAY,kBAAoB,CAAA,EAGzB,CAAA;AAEvC;AAEA,6BAA6B,cAAc"}
1
+ {"version":3,"file":"ChainOfThoughtParts.js","names":[],"sources":["../../../../src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx"],"sourcesContent":["import {\n type ComponentType,\n type FC,\n type PropsWithChildren,\n type ReactNode,\n useMemo,\n} from \"react\";\nimport { RenderChildrenWithAccessor, useAuiState } from \"@assistant-ui/store\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport { ChainOfThoughtPartByIndexProvider } from \"../../providers/ChainOfThoughtPartByIndexProvider\";\nimport { MessagePartComponent } from \"../message/MessageParts\";\nimport type {\n ReasoningMessagePartComponent,\n ToolCallMessagePartComponent,\n} from \"../../types/MessagePartComponentTypes\";\n\ntype ChainOfThoughtPartsComponentConfig = {\n /** Component for rendering reasoning parts */\n Reasoning?: ReasoningMessagePartComponent | undefined;\n /** Fallback component for tool-call parts */\n tools?: {\n Fallback?: ToolCallMessagePartComponent | undefined;\n };\n /** Layout component to wrap the rendered parts when expanded */\n Layout?: ComponentType<PropsWithChildren> | undefined;\n};\n\nexport namespace ChainOfThoughtPrimitiveParts {\n export type Props =\n | {\n /**\n * @deprecated Use the children render function instead.\n */\n components?: ChainOfThoughtPartsComponentConfig;\n children?: never;\n }\n | {\n /** Render function called for each part. Receives the part. */\n children: (value: { part: PartState }) => ReactNode;\n components?: never;\n };\n}\n\nconst ChainOfThoughtPrimitivePartsInner: FC<{\n children: (value: { part: PartState }) => ReactNode;\n}> = ({ children }) => {\n const partsLength = useAuiState((s) => s.chainOfThought.parts.length);\n\n return useMemo(\n () =>\n Array.from({ length: partsLength }, (_, index) => (\n <ChainOfThoughtPartByIndexProvider key={index} index={index}>\n <RenderChildrenWithAccessor\n getItemState={(aui) =>\n aui.chainOfThought().part({ index }).getState()\n }\n >\n {(getItem) =>\n children({\n get part() {\n return getItem();\n },\n })\n }\n </RenderChildrenWithAccessor>\n </ChainOfThoughtPartByIndexProvider>\n )),\n [partsLength, children],\n );\n};\n\n/**\n * Renders the parts within a chain of thought, with support for collapsed/expanded states.\n *\n * When collapsed, no parts are shown. When expanded, all parts are rendered\n * using the provided component configuration through the part scope mechanism.\n */\nexport const ChainOfThoughtPrimitiveParts: FC<\n ChainOfThoughtPrimitiveParts.Props\n> = ({ components, children }) => {\n if (children) {\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {children}\n </ChainOfThoughtPrimitivePartsInner>\n );\n }\n\n // oxlint-disable-next-line react-hooks/rules-of-hooks -- intentional conditional hook below the early return above\n const messageComponents = useMemo(\n () => ({\n Reasoning: components?.Reasoning,\n tools: {\n Fallback: components?.tools?.Fallback,\n },\n }),\n [components?.Reasoning, components?.tools?.Fallback],\n );\n\n const Layout = components?.Layout;\n\n return (\n <ChainOfThoughtPrimitivePartsInner>\n {() =>\n Layout ? (\n <Layout>\n <MessagePartComponent components={messageComponents} />\n </Layout>\n ) : (\n <MessagePartComponent components={messageComponents} />\n )\n }\n </ChainOfThoughtPrimitivePartsInner>\n );\n};\n\nChainOfThoughtPrimitiveParts.displayName = \"ChainOfThoughtPrimitive.Parts\";\n"],"mappings":";;;;;;AA2CA,MAAM,qCAEA,EAAE,eAAe;CACrB,MAAM,cAAc,aAAa,MAAM,EAAE,eAAe,MAAM,MAAM;CAEpE,OAAO,cAEH,MAAM,KAAK,EAAE,QAAQ,YAAY,IAAI,GAAG,UACtC,oBAAC,mCAAD;EAAsD;YACpD,oBAAC,4BAAD;GACE,eAAe,QACb,IAAI,eAAe,CAAC,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,SAAS;cAG9C,YACA,SAAS,EACP,IAAI,OAAO;IACT,OAAO,QAAQ;GACjB,EACF,CAAC;EAEuB,CAAA;CACK,GAdK,KAcL,CACpC,GACH,CAAC,aAAa,QAAQ,CACxB;AACF;;;;;;;AAQA,MAAa,gCAER,EAAE,YAAY,eAAe;CAChC,IAAI,UACF,OACE,oBAAC,mCAAD,EACG,SACgC,CAAA;CAKvC,MAAM,oBAAoB,eACjB;EACL,WAAW,YAAY;EACvB,OAAO,EACL,UAAU,YAAY,OAAO,SAC/B;CACF,IACA,CAAC,YAAY,WAAW,YAAY,OAAO,QAAQ,CACrD;CAEA,MAAM,SAAS,YAAY;CAE3B,OACE,oBAAC,mCAAD,EAAA,gBAEI,SACE,oBAAC,QAAD,EAAA,UACE,oBAAC,sBAAD,EAAsB,YAAY,kBAAoB,CAAA,EAChD,CAAA,IAER,oBAAC,sBAAD,EAAsB,YAAY,kBAAoB,CAAA,EAGzB,CAAA;AAEvC;AAEA,6BAA6B,cAAc"}
@@ -1,5 +1,5 @@
1
1
  import { ComposerAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider.js";
2
- import { memo, useMemo } from "react";
2
+ import { memo, useMemo } from "@assistant-ui/tap/react-shim";
3
3
  import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/react/primitives/composer/ComposerAttachments.tsx
@@ -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,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,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":[],"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,5 +1,5 @@
1
1
  import { QueueItemByIndexProvider } from "../../providers/QueueItemByIndexProvider.js";
2
- import { memo, useMemo } from "react";
2
+ import { memo, useMemo } from "@assistant-ui/tap/react-shim";
3
3
  import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/react/primitives/composer/ComposerQueue.tsx
@@ -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,EAAE,UAAU,EAAE,MAAM,CAAC,EAAE,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":[],"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,5 +1,5 @@
1
1
  "use client";
2
- import { createElement, useMemo } from "react";
2
+ import { createElement, useMemo } from "@assistant-ui/tap/react-shim";
3
3
  import { useAuiState } from "@assistant-ui/store";
4
4
  import { Fragment as Fragment$1, jsx } from "react/jsx-runtime";
5
5
  //#region src/react/primitives/generativeUI/GenerativeUI.tsx
@@ -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,EAAE,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":[],"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,5 +1,5 @@
1
1
  import { MessageAttachmentByIndexProvider } from "../../providers/AttachmentByIndexProvider.js";
2
- import { memo, useMemo } from "react";
2
+ import { memo, useMemo } from "@assistant-ui/tap/react-shim";
3
3
  import { RenderChildrenWithAccessor, useAuiState } from "@assistant-ui/store";
4
4
  import { jsx } from "react/jsx-runtime";
5
5
  //#region src/react/primitives/message/MessageAttachments.tsx
@@ -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,GAAG;CACvC,CAAC;CAED,OAAO,cAEH,MAAM,KAAK,EAAE,QAAQ,iBAAiB,IAAI,GAAG,UAC3C,oBAAC,kCAAD;EAAqD;YACnD,oBAAC,4BAAD;GACE,eAAe,QACb,IAAI,QAAQ,EAAE,WAAW,EAAE,MAAM,CAAC,EAAE,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":[],"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,7 +1,7 @@
1
1
  "use client";
2
2
  import { MessagePartChildren } from "./MessageParts.js";
3
3
  import { GROUPBY_MEMO_KEY, buildGroupTree } from "../../utils/groupParts.js";
4
- import { Fragment, useMemo } from "react";
4
+ import { Fragment, useMemo } from "@assistant-ui/tap/react-shim";
5
5
  import { useAuiState } from "@assistant-ui/store";
6
6
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
7
7
  import { useShallow } from "zustand/shallow";
@@ -1 +1 @@
1
- {"version":3,"file":"MessageGroupedParts.js","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupByContext,\n type GroupNode,\n} from \"../../utils/groupParts\";\nimport { MessagePartChildren, type EnrichedPartState } from \"./MessageParts\";\n\nexport namespace MessagePrimitiveGroupedParts {\n /**\n * A coalesced group of adjacent parts. Surfaced through the same\n * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers\n * dispatch on a single `switch (part.type)`. `type` is the group key\n * (always `\"group-…\"`); `status` mirrors the last contained part.\n */\n export type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {\n readonly type: TKey;\n readonly status: MessagePartStatus | ToolCallMessagePartStatus;\n readonly indices: readonly number[];\n };\n\n /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the last part isn't `text`/`reasoning`\n * (e.g. it ended on a tool call, so the assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\n\n export type RenderInfo<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Either a coalesced group ({@link GroupPart}, identified by a\n * `group-…` `type`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\n /**\n * For group nodes: the recursively-rendered subtree (subgroups +\n * leaf parts). For leaf parts: a sentinel that throws when rendered\n * — accidental fall-through (`default: return children;`) errors\n * loudly instead of silently rendering nothing.\n */\n readonly children: ReactNode;\n };\n\n export type Props<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Maps each part to a group-key path. Adjacent parts that share a\n * prefix coalesce into the same group. Return `[]` (or `null`) to\n * leave a part ungrouped.\n *\n * Group keys must start with `\"group-\"` so the renderer's\n * `switch (part.type)` can tell groups apart from real part types.\n *\n * **Prefer {@link groupPartByType}** for the common case of mapping by\n * `part.type` — it ships a stable memo fingerprint so the tree\n * survives unrelated re-renders. Use an inline function only when\n * the helper isn't expressive enough (e.g. branching on\n * `part.toolName` or part metadata).\n *\n * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\n *\n * @example\n * ```tsx\n * import { groupPartByType } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * ```\n */\n readonly groupBy: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\n *\n * Leaf parts receive the same {@link EnrichedPartState} that\n * `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,\n * `resume`, `respondToApproval`, `dataRendererUI`).\n */\n readonly children: (info: RenderInfo<TKey>) => ReactNode;\n };\n}\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\n\nconst shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last !== undefined && last.type !== \"text\" && last.type !== \"reasoning\"\n );\n }\n }\n};\n\n/**\n * `children` placeholder passed for leaf-part renders. Leaf parts have no\n * inner subtree; rendering this sentinel signals the consumer wrote\n * `default: return children;` and accidentally fell through for a part —\n * surface the bug loudly instead of silently rendering nothing.\n */\nconst PartChildrenSentinel: FC = () => {\n throw new Error(\n \"MessagePrimitive.GroupedParts: rendered `children` under a leaf \" +\n \"part. `children` is only meaningful for `group-…` cases — add a \" +\n \"matching case for the part type or return `null` to skip it.\",\n );\n};\n\nconst renderNode = <TKey extends `group-${string}`>(\n node: GroupNode,\n parts: readonly PartState[],\n render: (info: MessagePrimitiveGroupedParts.RenderInfo<TKey>) => ReactNode,\n): ReactNode => {\n if (node.type === \"part\") {\n // Key by absolute part index, not structural nodeKey — prevents zombie fiber subscriptions when parts reshape (#4051).\n return (\n <MessagePartChildren key={`part-${node.index}`} index={node.index}>\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = parts[node.indices.at(-1)!]?.status ?? COMPLETE_STATUS;\n const groupPart: MessagePrimitiveGroupedParts.GroupPart<TKey> = {\n type: node.key as TKey,\n status,\n indices: node.indices,\n };\n\n return (\n <Fragment key={node.nodeKey}>\n {render({\n part: groupPart,\n children: (\n <>{node.children.map((child) => renderNode(child, parts, render))}</>\n ),\n })}\n </Fragment>\n );\n};\n\n/**\n * Groups adjacent message parts into a tree of coalesced runs and\n * renders each node — group or part — through a single `children`\n * function.\n *\n * The render function receives `{ part, children }` where `part.type`\n * is either a `\"group-…\"` literal (for a group, `children` is the\n * recursively-rendered subtree) or a real part type (`\"text\"`,\n * `\"tool-call\"`, …) for a leaf (`children` is a sentinel that throws\n * if rendered — use `part.type` to distinguish).\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * {({ part, children }) => {\n * switch (part.type) {\n * case \"group-thought\": return <Thought>{children}</Thought>;\n * case \"group-reasoning\": return <Reasoning>{children}</Reasoning>;\n * case \"group-tool\": return <ToolStack>{children}</ToolStack>;\n * case \"text\": return <MarkdownText />;\n * case \"tool-call\": return part.toolUI ?? <ToolFallback {...part} />;\n * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\n\n // Helpers like `groupPartByType` tag the function with `GROUPBY_MEMO_KEY`\n // (a stable string fingerprint of the helper config). When present,\n // memo on `[parts, memoKey]` so the tree survives unrelated renders.\n // For inline `groupBy`, fall back to recomputing each render — O(n)\n // and cheap.\n const memoKey = (groupBy as { [GROUPBY_MEMO_KEY]?: string })[\n GROUPBY_MEMO_KEY\n ];\n const memoDep = memoKey ?? groupBy;\n const tree = useMemo(() => {\n const context: GroupByContext = { toolUIs };\n return buildGroupTree(parts.map((part) => groupBy(part, context) ?? []));\n // oxlint-disable-next-line tap-hooks/exhaustive-deps -- groupBy is captured via memoDep (either its identity or the helper's memoKey fingerprint); listing it directly would defeat the helper-tagged memo path\n }, [parts, memoDep, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;AAsIA,MAAM,kBAAqC,OAAO,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7E,MAAM,uBACJ,MACA,OACA,cACY;CAGZ,IAAI,CAAC,WAAW,OAAO;CAEvB,QAAQ,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAO,MAAM,WAAW;EAC1B,KAAK,WAAW;GACd,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,OACE,SAAS,KAAA,KAAa,KAAK,SAAS,UAAU,KAAK,SAAS;EAEhE;CACF;AACF;;;;;;;AAQA,MAAM,6BAAiC;CACrC,MAAM,IAAI,MACR,8LAGF;AACF;AAEA,MAAM,cACJ,MACA,OACA,WACc;CACd,IAAI,KAAK,SAAS,QAEhB,OACE,oBAAC,qBAAD;EAAgD,OAAO,KAAK;aACxD,EAAE,WAAW,OAAO;GAAE;GAAM,UAAU,oBAAC,sBAAD,CAAuB,CAAA;EAAE,CAAC;CAC/C,GAFK,QAAQ,KAAK,OAElB;CAIzB,MAAM,SAAS,MAAM,KAAK,QAAQ,GAAG,EAAE,IAAK,UAAU;CAOtD,OACE,oBAAC,UAAD,EAAA,UACG,OAAO;EACN,MAAM;GARV,MAAM,KAAK;GACX;GACA,SAAS,KAAK;EAMI;EACd,UACE,oBAAA,YAAA,EAAA,UAAG,KAAK,SAAS,KAAK,UAAU,WAAW,OAAO,OAAO,MAAM,CAAC,EAAI,CAAA;CAExE,CAAC,EACO,GAPK,KAAK,OAOV;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,gCAAgE,EAC3E,SACA,YAAY,WACZ,eACyD;CACzD,MAAM,QAAQ,YAAY,YAAY,MAAM,EAAE,QAAQ,KAAK,CAAC;CAE5D,MAAM,UAAU,aAAa,MAAM,EAAE,MAAM,OAAO;CAGlD,MAAM,YAAY,aAAa,MAC7B,cAAc,UAAU,QAAQ,EAAE,QAAQ,QAAQ,SAAS,SAC7D;CAiBA,OACE,qBAAA,YAAA,EAAA,UAAA,CAPW,cAAc;EACzB,MAAM,UAA0B,EAAE,QAAQ;EAC1C,OAAO,eAAe,MAAM,KAAK,SAAS,QAAQ,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;CAEzE,GAAG;EAAC;EARa,QACf,qBAEyB;EAKP;CAAO,CAInB,EAAE,KAAK,SAAS,WAAW,MAAM,OAAO,QAAQ,CAAC,GACpD,oBAAoB,WAAW,OAAO,SAAS,KAC9C,SAAS;EACP,MAAM,EAAE,MAAM,YAAY;EAC1B,UAAU,oBAAC,sBAAD,CAAuB,CAAA;CACnC,CAAC,CACH,EAAA,CAAA;AAEN;AAEA,6BAA6B,cAAc"}
1
+ {"version":3,"file":"MessageGroupedParts.js","names":[],"sources":["../../../../src/react/primitives/message/MessageGroupedParts.tsx"],"sourcesContent":["\"use client\";\n\nimport { Fragment, type FC, type ReactNode, useMemo } from \"react\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useShallow } from \"zustand/shallow\";\nimport type { PartState } from \"../../../store/scopes/part\";\nimport type {\n MessagePartStatus,\n ToolCallMessagePartStatus,\n} from \"../../../types/message\";\nimport {\n buildGroupTree,\n GROUPBY_MEMO_KEY,\n type GroupByContext,\n type GroupNode,\n} from \"../../utils/groupParts\";\nimport { MessagePartChildren, type EnrichedPartState } from \"./MessageParts\";\n\nexport namespace MessagePrimitiveGroupedParts {\n /**\n * A coalesced group of adjacent parts. Surfaced through the same\n * `{ part }` channel as a leaf {@link EnrichedPartState} so consumers\n * dispatch on a single `switch (part.type)`. `type` is the group key\n * (always `\"group-…\"`); `status` mirrors the last contained part.\n */\n export type GroupPart<TKey extends `group-${string}` = `group-${string}`> = {\n readonly type: TKey;\n readonly status: MessagePartStatus | ToolCallMessagePartStatus;\n readonly indices: readonly number[];\n };\n\n /**\n * Synthetic trailing slot for a streaming/loading affordance (a\n * \"thinking…\" dot, etc.). Surfaced through the same `{ part }` channel\n * as groups and leaf parts so a single `switch (part.type)` renders it\n * via `case \"indicator\"`.\n *\n * It is only ever emitted while the message is running, so its presence\n * alone means \"render your loading UI here\" — there's no `status` to\n * branch on.\n */\n export type IndicatorPart = {\n readonly type: \"indicator\";\n };\n\n /**\n * When to emit the synthetic {@link IndicatorPart}. It is **only** emitted\n * while the message is running (streaming); the mode further restricts\n * which running states qualify:\n * - `\"never\"` — never.\n * - `\"empty\"` — only when the message has no parts yet.\n * - `\"no-text\"` (default) — when the last part isn't `text`/`reasoning`\n * (e.g. it ended on a tool call, so the assistant likely isn't done).\n * - `\"always\"` — whenever the message is running, regardless of parts.\n */\n export type IndicatorMode = \"never\" | \"empty\" | \"no-text\" | \"always\";\n\n export type RenderInfo<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Either a coalesced group ({@link GroupPart}, identified by a\n * `group-…` `type`), a single enriched leaf part, or the synthetic\n * {@link IndicatorPart} (`type: \"indicator\"`). Use one switch over\n * `part.type` to handle all three.\n */\n readonly part: GroupPart<TKey> | EnrichedPartState | IndicatorPart;\n /**\n * For group nodes: the recursively-rendered subtree (subgroups +\n * leaf parts). For leaf parts: a sentinel that throws when rendered\n * — accidental fall-through (`default: return children;`) errors\n * loudly instead of silently rendering nothing.\n */\n readonly children: ReactNode;\n };\n\n export type Props<TKey extends `group-${string}` = `group-${string}`> = {\n /**\n * Maps each part to a group-key path. Adjacent parts that share a\n * prefix coalesce into the same group. Return `[]` (or `null`) to\n * leave a part ungrouped.\n *\n * Group keys must start with `\"group-\"` so the renderer's\n * `switch (part.type)` can tell groups apart from real part types.\n *\n * **Prefer {@link groupPartByType}** for the common case of mapping by\n * `part.type` — it ships a stable memo fingerprint so the tree\n * survives unrelated re-renders. Use an inline function only when\n * the helper isn't expressive enough (e.g. branching on\n * `part.toolName` or part metadata).\n *\n * The second argument is a {@link GroupByContext} carrying the tool-UI\n * registry, for grouping that depends on it (e.g. standalone tool calls).\n *\n * @example\n * ```tsx\n * import { groupPartByType } from \"@assistant-ui/react\";\n *\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * ```\n */\n readonly groupBy: (\n part: PartState,\n context: GroupByContext,\n ) => readonly TKey[] | null;\n\n /**\n * Controls emission of the synthetic {@link IndicatorPart} — a\n * trailing `{ part: { type: \"indicator\", status } }` render call you\n * handle with `case \"indicator\"` to show loading/status UI.\n *\n * @default \"no-text\"\n * @see IndicatorMode\n */\n readonly indicator?: IndicatorMode;\n\n /**\n * Render function called once per group node, once per leaf part, and\n * (when the `indicator` condition is met) once for the trailing\n * {@link IndicatorPart}. Switch on `part.type`: `\"group-…\"` cases wrap\n * `children`; real part types (`\"text\"`, `\"tool-call\"`, …) render the\n * part directly; `\"indicator\"` renders status/loading UI.\n *\n * Leaf parts receive the same {@link EnrichedPartState} that\n * `<MessagePrimitive.Parts>` would produce (`toolUI`, `addResult`,\n * `resume`, `respondToApproval`, `dataRendererUI`).\n */\n readonly children: (info: RenderInfo<TKey>) => ReactNode;\n };\n}\n\nconst COMPLETE_STATUS: MessagePartStatus = Object.freeze({ type: \"complete\" });\n\nconst shouldShowIndicator = (\n mode: MessagePrimitiveGroupedParts.IndicatorMode,\n parts: readonly PartState[],\n isRunning: boolean,\n): boolean => {\n // The indicator is a streaming affordance — never show it on a settled\n // message, whatever the mode.\n if (!isRunning) return false;\n\n switch (mode) {\n case \"never\":\n return false;\n case \"always\":\n return true;\n case \"empty\":\n return parts.length === 0;\n case \"no-text\": {\n const last = parts[parts.length - 1];\n return (\n last !== undefined && last.type !== \"text\" && last.type !== \"reasoning\"\n );\n }\n }\n};\n\n/**\n * `children` placeholder passed for leaf-part renders. Leaf parts have no\n * inner subtree; rendering this sentinel signals the consumer wrote\n * `default: return children;` and accidentally fell through for a part —\n * surface the bug loudly instead of silently rendering nothing.\n */\nconst PartChildrenSentinel: FC = () => {\n throw new Error(\n \"MessagePrimitive.GroupedParts: rendered `children` under a leaf \" +\n \"part. `children` is only meaningful for `group-…` cases — add a \" +\n \"matching case for the part type or return `null` to skip it.\",\n );\n};\n\nconst renderNode = <TKey extends `group-${string}`>(\n node: GroupNode,\n parts: readonly PartState[],\n render: (info: MessagePrimitiveGroupedParts.RenderInfo<TKey>) => ReactNode,\n): ReactNode => {\n if (node.type === \"part\") {\n // Key by absolute part index, not structural nodeKey — prevents zombie fiber subscriptions when parts reshape (#4051).\n return (\n <MessagePartChildren key={`part-${node.index}`} index={node.index}>\n {({ part }) => render({ part, children: <PartChildrenSentinel /> })}\n </MessagePartChildren>\n );\n }\n\n const status = parts[node.indices.at(-1)!]?.status ?? COMPLETE_STATUS;\n const groupPart: MessagePrimitiveGroupedParts.GroupPart<TKey> = {\n type: node.key as TKey,\n status,\n indices: node.indices,\n };\n\n return (\n <Fragment key={node.nodeKey}>\n {render({\n part: groupPart,\n children: (\n <>{node.children.map((child) => renderNode(child, parts, render))}</>\n ),\n })}\n </Fragment>\n );\n};\n\n/**\n * Groups adjacent message parts into a tree of coalesced runs and\n * renders each node — group or part — through a single `children`\n * function.\n *\n * The render function receives `{ part, children }` where `part.type`\n * is either a `\"group-…\"` literal (for a group, `children` is the\n * recursively-rendered subtree) or a real part type (`\"text\"`,\n * `\"tool-call\"`, …) for a leaf (`children` is a sentinel that throws\n * if rendered — use `part.type` to distinguish).\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * })}\n * >\n * {({ part, children }) => {\n * switch (part.type) {\n * case \"group-thought\": return <Thought>{children}</Thought>;\n * case \"group-reasoning\": return <Reasoning>{children}</Reasoning>;\n * case \"group-tool\": return <ToolStack>{children}</ToolStack>;\n * case \"text\": return <MarkdownText />;\n * case \"tool-call\": return part.toolUI ?? <ToolFallback {...part} />;\n * case \"indicator\": return <LoadingDots />;\n * default: return null;\n * }\n * }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const MessagePrimitiveGroupedParts = <TKey extends `group-${string}`>({\n groupBy,\n indicator = \"no-text\",\n children,\n}: MessagePrimitiveGroupedParts.Props<TKey>): ReactNode => {\n const parts = useAuiState(useShallow((s) => s.message.parts));\n // Handed to `groupBy` as its `context` argument (see GroupByContext).\n const toolUIs = useAuiState((s) => s.tools.toolUIs);\n // Subscribe to a boolean, not the status object: the tree only needs to\n // re-render when running-ness flips, and `\"never\"` opts out entirely.\n const isRunning = useAuiState((s) =>\n indicator === \"never\" ? false : s.message.status?.type === \"running\",\n );\n\n // Helpers like `groupPartByType` tag the function with `GROUPBY_MEMO_KEY`\n // (a stable string fingerprint of the helper config). When present,\n // memo on `[parts, memoKey]` so the tree survives unrelated renders.\n // For inline `groupBy`, fall back to recomputing each render — O(n)\n // and cheap.\n const memoKey = (groupBy as { [GROUPBY_MEMO_KEY]?: string })[\n GROUPBY_MEMO_KEY\n ];\n const memoDep = memoKey ?? groupBy;\n const tree = useMemo(() => {\n const context: GroupByContext = { toolUIs };\n return buildGroupTree(parts.map((part) => groupBy(part, context) ?? []));\n // oxlint-disable-next-line react/exhaustive-deps -- groupBy is captured via memoDep (either its identity or the helper's memoKey fingerprint); listing it directly would defeat the helper-tagged memo path\n }, [parts, memoDep, toolUIs]);\n\n return (\n <>\n {tree.map((node) => renderNode(node, parts, children))}\n {shouldShowIndicator(indicator, parts, isRunning) &&\n children({\n part: { type: \"indicator\" },\n children: <PartChildrenSentinel />,\n })}\n </>\n );\n};\n\nMessagePrimitiveGroupedParts.displayName = \"MessagePrimitive.GroupedParts\";\n"],"mappings":";;;;;;;;AAsIA,MAAM,kBAAqC,OAAO,OAAO,EAAE,MAAM,WAAW,CAAC;AAE7E,MAAM,uBACJ,MACA,OACA,cACY;CAGZ,IAAI,CAAC,WAAW,OAAO;CAEvB,QAAQ,MAAR;EACE,KAAK,SACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,SACH,OAAO,MAAM,WAAW;EAC1B,KAAK,WAAW;GACd,MAAM,OAAO,MAAM,MAAM,SAAS;GAClC,OACE,SAAS,KAAA,KAAa,KAAK,SAAS,UAAU,KAAK,SAAS;EAEhE;CACF;AACF;;;;;;;AAQA,MAAM,6BAAiC;CACrC,MAAM,IAAI,MACR,8LAGF;AACF;AAEA,MAAM,cACJ,MACA,OACA,WACc;CACd,IAAI,KAAK,SAAS,QAEhB,OACE,oBAAC,qBAAD;EAAgD,OAAO,KAAK;aACxD,EAAE,WAAW,OAAO;GAAE;GAAM,UAAU,oBAAC,sBAAD,CAAuB,CAAA;EAAE,CAAC;CAC/C,GAFK,QAAQ,KAAK,OAElB;CAIzB,MAAM,SAAS,MAAM,KAAK,QAAQ,GAAG,EAAE,EAAG,EAAE,UAAU;CAOtD,OACE,oBAAC,UAAD,EAAA,UACG,OAAO;EACN,MAAM;GARV,MAAM,KAAK;GACX;GACA,SAAS,KAAK;EAMI;EACd,UACE,oBAAA,YAAA,EAAA,UAAG,KAAK,SAAS,KAAK,UAAU,WAAW,OAAO,OAAO,MAAM,CAAC,EAAI,CAAA;CAExE,CAAC,EACO,GAPK,KAAK,OAOV;AAEd;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,gCAAgE,EAC3E,SACA,YAAY,WACZ,eACyD;CACzD,MAAM,QAAQ,YAAY,YAAY,MAAM,EAAE,QAAQ,KAAK,CAAC;CAE5D,MAAM,UAAU,aAAa,MAAM,EAAE,MAAM,OAAO;CAGlD,MAAM,YAAY,aAAa,MAC7B,cAAc,UAAU,QAAQ,EAAE,QAAQ,QAAQ,SAAS,SAC7D;CAiBA,OACE,qBAAA,YAAA,EAAA,UAAA,CAPW,cAAc;EACzB,MAAM,UAA0B,EAAE,QAAQ;EAC1C,OAAO,eAAe,MAAM,KAAK,SAAS,QAAQ,MAAM,OAAO,KAAK,CAAC,CAAC,CAAC;CAEzE,GAAG;EAAC;EARa,QACf,qBAEyB;EAKP;CAAO,CAInB,CAAC,CAAC,KAAK,SAAS,WAAW,MAAM,OAAO,QAAQ,CAAC,GACpD,oBAAoB,WAAW,OAAO,SAAS,KAC9C,SAAS;EACP,MAAM,EAAE,MAAM,YAAY;EAC1B,UAAU,oBAAC,sBAAD,CAAuB,CAAA;CACnC,CAAC,CACH,EAAA,CAAA;AAEN;AAEA,6BAA6B,cAAc"}
@@ -1,5 +1,5 @@
1
- import { DataMessagePartComponent, EmptyMessagePartComponent, FileMessagePartComponent, GenerativeUIComponentRegistry, ImageMessagePartComponent, QuoteMessagePartComponent, ReasoningGroupComponent, ReasoningMessagePartComponent, SourceMessagePartComponent, TextMessagePartComponent, ToolCallMessagePartComponent, ToolCallMessagePartProps, Unstable_AudioMessagePartComponent } from "../../types/MessagePartComponentTypes.js";
2
1
  import { PartState } from "../../../store/scopes/part.js";
2
+ import { DataMessagePartComponent, EmptyMessagePartComponent, FileMessagePartComponent, GenerativeUIComponentRegistry, ImageMessagePartComponent, QuoteMessagePartComponent, ReasoningGroupComponent, ReasoningMessagePartComponent, SourceMessagePartComponent, TextMessagePartComponent, ToolCallMessagePartComponent, ToolCallMessagePartProps, Unstable_AudioMessagePartComponent } from "../../types/MessagePartComponentTypes.js";
3
3
  import { ComponentType, FC, PropsWithChildren, ReactNode } from "react";
4
4
 
5
5
  //#region src/react/primitives/message/MessageParts.d.ts
@@ -4,7 +4,7 @@ import { TextMessagePartProvider } from "../../providers/TextMessagePartProvider
4
4
  import { ChainOfThoughtByIndicesProvider } from "../../providers/ChainOfThoughtByIndicesProvider.js";
5
5
  import { getMessageQuote } from "../../utils/getMessageQuote.js";
6
6
  import { GenerativeUIRender } from "../generativeUI/GenerativeUI.js";
7
- import { memo, useMemo } from "react";
7
+ import { memo, useMemo } from "@assistant-ui/tap/react-shim";
8
8
  import { RenderChildrenWithAccessor, useAui, useAuiState } from "@assistant-ui/store";
9
9
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { useShallow } from "zustand/shallow";