@assistant-ui/core 0.1.0 → 0.1.2

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 (417) hide show
  1. package/LICENSE +21 -0
  2. package/dist/adapters/attachment.js +1 -1
  3. package/dist/adapters/attachment.js.map +1 -1
  4. package/dist/react/AssistantProvider.d.ts +10 -0
  5. package/dist/react/AssistantProvider.d.ts.map +1 -0
  6. package/dist/react/AssistantProvider.js +13 -0
  7. package/dist/react/AssistantProvider.js.map +1 -0
  8. package/dist/react/RuntimeAdapter.d.ts +3 -0
  9. package/dist/react/RuntimeAdapter.d.ts.map +1 -0
  10. package/dist/react/RuntimeAdapter.js +16 -0
  11. package/dist/react/RuntimeAdapter.js.map +1 -0
  12. package/dist/react/client/DataRenderers.d.ts +3 -0
  13. package/dist/react/client/DataRenderers.d.ts.map +1 -0
  14. package/dist/react/client/DataRenderers.js +33 -0
  15. package/dist/react/client/DataRenderers.js.map +1 -0
  16. package/dist/react/client/Tools.d.ts +8 -0
  17. package/dist/react/client/Tools.d.ts.map +1 -0
  18. package/dist/react/client/Tools.js +68 -0
  19. package/dist/react/client/Tools.js.map +1 -0
  20. package/dist/react/client/index.d.ts +3 -0
  21. package/dist/react/client/index.d.ts.map +1 -0
  22. package/dist/react/client/index.js +3 -0
  23. package/dist/react/client/index.js.map +1 -0
  24. package/dist/react/index.d.ts +17 -0
  25. package/dist/react/index.d.ts.map +1 -0
  26. package/dist/react/index.js +19 -0
  27. package/dist/react/index.js.map +1 -0
  28. package/dist/react/model-context/index.d.ts +12 -0
  29. package/dist/react/model-context/index.d.ts.map +1 -0
  30. package/dist/react/model-context/index.js +11 -0
  31. package/dist/react/model-context/index.js.map +1 -0
  32. package/dist/react/model-context/makeAssistantDataUI.d.ts +7 -0
  33. package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -0
  34. package/dist/react/model-context/makeAssistantDataUI.js +10 -0
  35. package/dist/react/model-context/makeAssistantDataUI.js.map +1 -0
  36. package/dist/react/model-context/makeAssistantTool.d.ts +7 -0
  37. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -0
  38. package/dist/react/model-context/makeAssistantTool.js +10 -0
  39. package/dist/react/model-context/makeAssistantTool.js.map +1 -0
  40. package/dist/react/model-context/makeAssistantToolUI.d.ts +7 -0
  41. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -0
  42. package/dist/react/model-context/makeAssistantToolUI.js +10 -0
  43. package/dist/react/model-context/makeAssistantToolUI.js.map +1 -0
  44. package/dist/react/model-context/toolbox.d.ts +16 -0
  45. package/dist/react/model-context/toolbox.d.ts.map +1 -0
  46. package/dist/react/model-context/toolbox.js +2 -0
  47. package/dist/react/model-context/toolbox.js.map +1 -0
  48. package/dist/react/model-context/useAssistantDataUI.d.ts +7 -0
  49. package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -0
  50. package/dist/react/model-context/useAssistantDataUI.js +11 -0
  51. package/dist/react/model-context/useAssistantDataUI.js.map +1 -0
  52. package/dist/react/model-context/useAssistantInstructions.d.ts +4 -0
  53. package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -0
  54. package/dist/react/model-context/useAssistantInstructions.js +22 -0
  55. package/dist/react/model-context/useAssistantInstructions.js.map +1 -0
  56. package/dist/react/model-context/useAssistantTool.d.ts +7 -0
  57. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -0
  58. package/dist/react/model-context/useAssistantTool.js +22 -0
  59. package/dist/react/model-context/useAssistantTool.js.map +1 -0
  60. package/dist/react/model-context/useAssistantToolUI.d.ts +7 -0
  61. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -0
  62. package/dist/react/model-context/useAssistantToolUI.js +11 -0
  63. package/dist/react/model-context/useAssistantToolUI.js.map +1 -0
  64. package/dist/react/model-context/useInlineRender.d.ts +4 -0
  65. package/dist/react/model-context/useInlineRender.d.ts.map +1 -0
  66. package/dist/react/model-context/useInlineRender.js +15 -0
  67. package/dist/react/model-context/useInlineRender.js.map +1 -0
  68. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +27 -0
  69. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -0
  70. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +27 -0
  71. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -0
  72. package/dist/react/primitives/composer/ComposerAttachments.d.ts +23 -0
  73. package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -0
  74. package/dist/react/primitives/composer/ComposerAttachments.js +47 -0
  75. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -0
  76. package/dist/react/primitives/composer/ComposerIf.d.ts +20 -0
  77. package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -0
  78. package/dist/react/primitives/composer/ComposerIf.js +24 -0
  79. package/dist/react/primitives/composer/ComposerIf.js.map +1 -0
  80. package/dist/react/primitives/message/MessageAttachments.d.ts +23 -0
  81. package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -0
  82. package/dist/react/primitives/message/MessageAttachments.js +51 -0
  83. package/dist/react/primitives/message/MessageAttachments.js.map +1 -0
  84. package/dist/react/primitives/message/MessageParts.d.ts +139 -0
  85. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -0
  86. package/dist/react/primitives/message/MessageParts.js +251 -0
  87. package/dist/react/primitives/message/MessageParts.js.map +1 -0
  88. package/dist/react/primitives/thread/ThreadMessages.d.ts +95 -0
  89. package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -0
  90. package/dist/react/primitives/thread/ThreadMessages.js +112 -0
  91. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -0
  92. package/dist/react/primitives/thread/ThreadSuggestions.d.ts +28 -0
  93. package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -0
  94. package/dist/react/primitives/thread/ThreadSuggestions.js +32 -0
  95. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -0
  96. package/dist/react/primitives/threadList/ThreadListItems.d.ts +22 -0
  97. package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -0
  98. package/dist/react/primitives/threadList/ThreadListItems.js +23 -0
  99. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -0
  100. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +8 -0
  101. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -0
  102. package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +8 -0
  103. package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -0
  104. package/dist/react/providers/AttachmentByIndexProvider.d.ts +8 -0
  105. package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -0
  106. package/dist/react/providers/AttachmentByIndexProvider.js +23 -0
  107. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -0
  108. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +6 -0
  109. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -0
  110. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +20 -0
  111. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -0
  112. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +5 -0
  113. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -0
  114. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +13 -0
  115. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -0
  116. package/dist/react/providers/MessageByIndexProvider.d.ts +5 -0
  117. package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -0
  118. package/dist/react/providers/MessageByIndexProvider.js +18 -0
  119. package/dist/react/providers/MessageByIndexProvider.js.map +1 -0
  120. package/dist/react/providers/PartByIndexProvider.d.ts +5 -0
  121. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -0
  122. package/dist/react/providers/PartByIndexProvider.js +13 -0
  123. package/dist/react/providers/PartByIndexProvider.js.map +1 -0
  124. package/dist/react/providers/SuggestionByIndexProvider.d.ts +6 -0
  125. package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -0
  126. package/dist/react/providers/SuggestionByIndexProvider.js +13 -0
  127. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -0
  128. package/dist/react/providers/TextMessagePartProvider.d.ts +6 -0
  129. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -0
  130. package/dist/react/providers/TextMessagePartProvider.js +26 -0
  131. package/dist/react/providers/TextMessagePartProvider.js.map +1 -0
  132. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +6 -0
  133. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -0
  134. package/dist/react/providers/ThreadListItemByIndexProvider.js +13 -0
  135. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -0
  136. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +6 -0
  137. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -0
  138. package/dist/react/providers/ThreadListItemRuntimeProvider.js +10 -0
  139. package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -0
  140. package/dist/react/providers/index.d.ts +10 -0
  141. package/dist/react/providers/index.d.ts.map +1 -0
  142. package/dist/react/providers/index.js +10 -0
  143. package/dist/react/providers/index.js.map +1 -0
  144. package/dist/react/types/MessagePartComponentTypes.d.ts +33 -0
  145. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -0
  146. package/dist/react/types/MessagePartComponentTypes.js +2 -0
  147. package/dist/react/types/MessagePartComponentTypes.js.map +1 -0
  148. package/dist/react/types/index.d.ts +3 -0
  149. package/dist/react/types/index.d.ts.map +1 -0
  150. package/dist/react/types/index.js +2 -0
  151. package/dist/react/types/index.js.map +1 -0
  152. package/dist/react/types/scopes/dataRenderers.d.ts +13 -0
  153. package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -0
  154. package/dist/react/types/scopes/dataRenderers.js +2 -0
  155. package/dist/react/types/scopes/dataRenderers.js.map +1 -0
  156. package/dist/react/types/scopes/index.d.ts +3 -0
  157. package/dist/react/types/scopes/index.d.ts.map +1 -0
  158. package/dist/react/types/scopes/index.js +2 -0
  159. package/dist/react/types/scopes/index.js.map +1 -0
  160. package/dist/react/types/scopes/tools.d.ts +13 -0
  161. package/dist/react/types/scopes/tools.d.ts.map +1 -0
  162. package/dist/react/types/scopes/tools.js +2 -0
  163. package/dist/react/types/scopes/tools.js.map +1 -0
  164. package/dist/react/types/store-augmentation.d.ts +10 -0
  165. package/dist/react/types/store-augmentation.d.ts.map +1 -0
  166. package/dist/react/types/store-augmentation.js +2 -0
  167. package/dist/react/types/store-augmentation.js.map +1 -0
  168. package/dist/runtime/api/attachment-runtime.d.ts +2 -2
  169. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  170. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  171. package/dist/runtime/api/composer-runtime.d.ts +8 -6
  172. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  173. package/dist/runtime/api/composer-runtime.js +2 -2
  174. package/dist/runtime/api/composer-runtime.js.map +1 -1
  175. package/dist/runtime/api/thread-runtime.d.ts +27 -2
  176. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  177. package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -2
  178. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  179. package/dist/runtime/base/base-composer-runtime-core.js +28 -8
  180. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  181. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -2
  182. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  183. package/dist/runtime/base/default-thread-composer-runtime-core.js +0 -3
  184. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  185. package/dist/runtime/index.d.ts +1 -1
  186. package/dist/runtime/index.d.ts.map +1 -1
  187. package/dist/runtime/index.js +1 -1
  188. package/dist/runtime/index.js.map +1 -1
  189. package/dist/runtime/interfaces/composer-runtime-core.d.ts +3 -5
  190. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  191. package/dist/runtime/utils/external-store-message.d.ts +8 -0
  192. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  193. package/dist/runtime/utils/external-store-message.js +12 -0
  194. package/dist/runtime/utils/external-store-message.js.map +1 -1
  195. package/dist/runtime/utils/thread-message-like.d.ts +10 -3
  196. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  197. package/dist/runtime/utils/thread-message-like.js +20 -5
  198. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  199. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  200. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +26 -8
  201. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  202. package/dist/runtimes/remote-thread-list/empty-thread-core.js +1 -1
  203. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  204. package/dist/store/clients/chain-of-thought-client.d.ts +1 -1
  205. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  206. package/dist/store/clients/model-context-client.d.ts +1 -1
  207. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  208. package/dist/store/clients/no-op-composer-client.d.ts +1 -1
  209. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  210. package/dist/store/clients/runtime-adapter.d.ts +5 -0
  211. package/dist/store/clients/runtime-adapter.d.ts.map +1 -0
  212. package/dist/store/clients/runtime-adapter.js +46 -0
  213. package/dist/store/clients/runtime-adapter.js.map +1 -0
  214. package/dist/store/clients/suggestions.d.ts +1 -1
  215. package/dist/store/clients/suggestions.d.ts.map +1 -1
  216. package/dist/store/clients/suggestions.js +1 -1
  217. package/dist/store/clients/suggestions.js.map +1 -1
  218. package/dist/store/clients/thread-message-client.d.ts +1 -1
  219. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  220. package/dist/store/clients/thread-message-client.js +1 -1
  221. package/dist/store/clients/thread-message-client.js.map +1 -1
  222. package/dist/store/index.d.ts +1 -11
  223. package/dist/store/index.d.ts.map +1 -1
  224. package/dist/store/index.js +2 -9
  225. package/dist/store/index.js.map +1 -1
  226. package/dist/store/internal.d.ts +1 -9
  227. package/dist/store/internal.d.ts.map +1 -1
  228. package/dist/store/internal.js +1 -10
  229. package/dist/store/internal.js.map +1 -1
  230. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +1 -1
  231. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  232. package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -1
  233. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  234. package/dist/store/runtime-clients/composer-runtime-client.js +1 -1
  235. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  236. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +1 -1
  237. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  238. package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -1
  239. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  240. package/dist/store/runtime-clients/message-runtime-client.js +1 -1
  241. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  242. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +1 -1
  243. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  244. package/dist/store/runtime-clients/thread-list-item-runtime-client.js +1 -1
  245. package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
  246. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +1 -1
  247. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  248. package/dist/store/runtime-clients/thread-list-runtime-client.js +1 -1
  249. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  250. package/dist/store/runtime-clients/thread-runtime-client.d.ts +1 -1
  251. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  252. package/dist/store/runtime-clients/thread-runtime-client.js +1 -1
  253. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  254. package/dist/store/scope-registration.d.ts +27 -0
  255. package/dist/store/scope-registration.d.ts.map +1 -0
  256. package/dist/store/scope-registration.js +2 -0
  257. package/dist/store/scope-registration.js.map +1 -0
  258. package/dist/store/scopes/composer.d.ts +2 -2
  259. package/dist/store/scopes/composer.d.ts.map +1 -1
  260. package/dist/types/attachment.d.ts +9 -2
  261. package/dist/types/attachment.d.ts.map +1 -1
  262. package/dist/types/index.d.ts +1 -1
  263. package/dist/types/index.d.ts.map +1 -1
  264. package/package.json +35 -12
  265. package/src/adapters/attachment.ts +1 -1
  266. package/src/react/AssistantProvider.tsx +34 -0
  267. package/src/react/RuntimeAdapter.ts +26 -0
  268. package/src/react/client/DataRenderers.ts +42 -0
  269. package/src/react/client/Tools.ts +97 -0
  270. package/src/react/client/index.ts +2 -0
  271. package/src/react/index.ts +50 -0
  272. package/src/react/model-context/index.ts +25 -0
  273. package/src/react/model-context/makeAssistantDataUI.ts +20 -0
  274. package/src/react/model-context/makeAssistantTool.ts +20 -0
  275. package/src/react/model-context/makeAssistantToolUI.ts +20 -0
  276. package/src/react/model-context/toolbox.ts +19 -0
  277. package/src/react/model-context/useAssistantDataUI.ts +16 -0
  278. package/src/react/model-context/useAssistantInstructions.ts +30 -0
  279. package/src/react/model-context/useAssistantTool.ts +37 -0
  280. package/src/react/model-context/useAssistantToolUI.ts +18 -0
  281. package/src/react/model-context/useInlineRender.ts +25 -0
  282. package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +73 -0
  283. package/src/react/primitives/composer/ComposerAttachments.tsx +95 -0
  284. package/src/react/primitives/composer/ComposerIf.tsx +49 -0
  285. package/src/react/primitives/message/MessageAttachments.tsx +98 -0
  286. package/src/react/primitives/message/MessageParts.tsx +561 -0
  287. package/src/react/primitives/thread/ThreadMessages.tsx +222 -0
  288. package/src/react/primitives/thread/ThreadSuggestions.tsx +82 -0
  289. package/src/react/primitives/threadList/ThreadListItems.tsx +66 -0
  290. package/src/react/primitives/threadListItem/ThreadListItemTitle.tsx +17 -0
  291. package/src/react/providers/AttachmentByIndexProvider.tsx +34 -0
  292. package/src/react/providers/ChainOfThoughtByIndicesProvider.tsx +34 -0
  293. package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +18 -0
  294. package/src/react/providers/MessageByIndexProvider.tsx +23 -0
  295. package/src/react/providers/PartByIndexProvider.tsx +18 -0
  296. package/src/react/providers/SuggestionByIndexProvider.tsx +21 -0
  297. package/src/react/providers/TextMessagePartProvider.tsx +46 -0
  298. package/src/react/providers/ThreadListItemByIndexProvider.tsx +19 -0
  299. package/src/react/providers/ThreadListItemRuntimeProvider.tsx +16 -0
  300. package/src/react/providers/index.ts +15 -0
  301. package/src/react/types/MessagePartComponentTypes.ts +66 -0
  302. package/src/react/types/index.ts +31 -0
  303. package/src/react/types/scopes/dataRenderers.ts +15 -0
  304. package/src/react/types/scopes/index.ts +6 -0
  305. package/src/react/types/scopes/tools.ts +18 -0
  306. package/src/react/types/store-augmentation.ts +11 -0
  307. package/src/runtime/api/attachment-runtime.ts +2 -7
  308. package/src/runtime/api/composer-runtime.ts +9 -8
  309. package/src/runtime/base/base-composer-runtime-core.ts +28 -8
  310. package/src/runtime/base/default-thread-composer-runtime-core.ts +1 -5
  311. package/src/runtime/index.ts +1 -0
  312. package/src/runtime/interfaces/composer-runtime-core.ts +3 -6
  313. package/src/runtime/utils/external-store-message.ts +15 -0
  314. package/src/runtime/utils/thread-message-like.ts +40 -7
  315. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +29 -12
  316. package/src/runtimes/remote-thread-list/empty-thread-core.ts +1 -1
  317. package/src/store/clients/chain-of-thought-client.ts +1 -1
  318. package/src/store/clients/model-context-client.ts +1 -1
  319. package/src/store/clients/no-op-composer-client.ts +1 -1
  320. package/src/store/clients/runtime-adapter.ts +67 -0
  321. package/src/store/clients/suggestions.ts +2 -2
  322. package/src/store/clients/thread-message-client.ts +2 -2
  323. package/src/store/index.ts +2 -38
  324. package/src/store/internal.ts +4 -31
  325. package/src/store/runtime-clients/attachment-runtime-client.ts +1 -1
  326. package/src/store/runtime-clients/composer-runtime-client.ts +5 -1
  327. package/src/store/runtime-clients/message-part-runtime-client.ts +1 -1
  328. package/src/store/runtime-clients/message-runtime-client.ts +5 -1
  329. package/src/store/runtime-clients/thread-list-item-runtime-client.ts +1 -1
  330. package/src/store/runtime-clients/thread-list-runtime-client.ts +5 -1
  331. package/src/store/runtime-clients/thread-runtime-client.ts +1 -1
  332. package/src/store/scope-registration.ts +27 -0
  333. package/src/store/scopes/composer.ts +2 -1
  334. package/src/tests/external-store-thread-runtime-core.test.ts +152 -0
  335. package/src/tests/thread-message-like.test.ts +110 -0
  336. package/src/types/attachment.ts +10 -2
  337. package/src/types/index.ts +1 -0
  338. package/dist/store/types/client.d.ts +0 -137
  339. package/dist/store/types/client.d.ts.map +0 -1
  340. package/dist/store/types/client.js +0 -2
  341. package/dist/store/types/client.js.map +0 -1
  342. package/dist/store/types/events.d.ts +0 -33
  343. package/dist/store/types/events.d.ts.map +0 -1
  344. package/dist/store/types/events.js +0 -8
  345. package/dist/store/types/events.js.map +0 -1
  346. package/dist/store/types/index.d.ts +0 -3
  347. package/dist/store/types/index.d.ts.map +0 -1
  348. package/dist/store/types/index.js +0 -2
  349. package/dist/store/types/index.js.map +0 -1
  350. package/dist/store/utils/attach-transform-scopes.d.ts +0 -11
  351. package/dist/store/utils/attach-transform-scopes.d.ts.map +0 -1
  352. package/dist/store/utils/attach-transform-scopes.js +0 -12
  353. package/dist/store/utils/attach-transform-scopes.js.map +0 -1
  354. package/dist/store/utils/base-proxy-handler.d.ts +0 -23
  355. package/dist/store/utils/base-proxy-handler.d.ts.map +0 -1
  356. package/dist/store/utils/base-proxy-handler.js +0 -46
  357. package/dist/store/utils/base-proxy-handler.js.map +0 -1
  358. package/dist/store/utils/derived.d.ts +0 -34
  359. package/dist/store/utils/derived.d.ts.map +0 -1
  360. package/dist/store/utils/derived.js +0 -24
  361. package/dist/store/utils/derived.js.map +0 -1
  362. package/dist/store/utils/index.d.ts +0 -7
  363. package/dist/store/utils/index.d.ts.map +0 -1
  364. package/dist/store/utils/index.js +0 -7
  365. package/dist/store/utils/index.js.map +0 -1
  366. package/dist/store/utils/notification-manager.d.ts +0 -11
  367. package/dist/store/utils/notification-manager.d.ts.map +0 -1
  368. package/dist/store/utils/notification-manager.js +0 -84
  369. package/dist/store/utils/notification-manager.js.map +0 -1
  370. package/dist/store/utils/proxied-assistant-state.d.ts +0 -8
  371. package/dist/store/utils/proxied-assistant-state.d.ts.map +0 -1
  372. package/dist/store/utils/proxied-assistant-state.js +0 -33
  373. package/dist/store/utils/proxied-assistant-state.js.map +0 -1
  374. package/dist/store/utils/split-clients.d.ts +0 -10
  375. package/dist/store/utils/split-clients.d.ts.map +0 -1
  376. package/dist/store/utils/split-clients.js +0 -53
  377. package/dist/store/utils/split-clients.js.map +0 -1
  378. package/dist/store/utils/tap-assistant-context.d.ts +0 -19
  379. package/dist/store/utils/tap-assistant-context.d.ts.map +0 -1
  380. package/dist/store/utils/tap-assistant-context.js +0 -23
  381. package/dist/store/utils/tap-assistant-context.js.map +0 -1
  382. package/dist/store/utils/tap-client-list.d.ts +0 -28
  383. package/dist/store/utils/tap-client-list.d.ts.map +0 -1
  384. package/dist/store/utils/tap-client-list.js +0 -68
  385. package/dist/store/utils/tap-client-list.js.map +0 -1
  386. package/dist/store/utils/tap-client-lookup.d.ts +0 -15
  387. package/dist/store/utils/tap-client-lookup.d.ts.map +0 -1
  388. package/dist/store/utils/tap-client-lookup.js +0 -42
  389. package/dist/store/utils/tap-client-lookup.js.map +0 -1
  390. package/dist/store/utils/tap-client-resource.d.ts +0 -13
  391. package/dist/store/utils/tap-client-resource.d.ts.map +0 -1
  392. package/dist/store/utils/tap-client-resource.js +0 -114
  393. package/dist/store/utils/tap-client-resource.js.map +0 -1
  394. package/dist/store/utils/tap-client-stack-context.d.ts +0 -23
  395. package/dist/store/utils/tap-client-stack-context.d.ts.map +0 -1
  396. package/dist/store/utils/tap-client-stack-context.js +0 -28
  397. package/dist/store/utils/tap-client-stack-context.js.map +0 -1
  398. package/dist/store/utils/wrapper-resource.d.ts +0 -3
  399. package/dist/store/utils/wrapper-resource.d.ts.map +0 -1
  400. package/dist/store/utils/wrapper-resource.js +0 -11
  401. package/dist/store/utils/wrapper-resource.js.map +0 -1
  402. package/src/store/types/client.ts +0 -203
  403. package/src/store/types/events.ts +0 -77
  404. package/src/store/types/index.ts +0 -23
  405. package/src/store/utils/attach-transform-scopes.ts +0 -38
  406. package/src/store/utils/base-proxy-handler.ts +0 -50
  407. package/src/store/utils/derived.ts +0 -46
  408. package/src/store/utils/index.ts +0 -28
  409. package/src/store/utils/notification-manager.ts +0 -114
  410. package/src/store/utils/proxied-assistant-state.ts +0 -55
  411. package/src/store/utils/split-clients.ts +0 -82
  412. package/src/store/utils/tap-assistant-context.ts +0 -58
  413. package/src/store/utils/tap-client-list.ts +0 -121
  414. package/src/store/utils/tap-client-lookup.ts +0 -79
  415. package/src/store/utils/tap-client-resource.ts +0 -187
  416. package/src/store/utils/tap-client-stack-context.ts +0 -51
  417. package/src/store/utils/wrapper-resource.ts +0 -17
@@ -0,0 +1,16 @@
1
+ import { useEffect } from "react";
2
+ import { useAui } from "@assistant-ui/store";
3
+ import type { DataMessagePartComponent } from "../types/MessagePartComponentTypes";
4
+
5
+ export type AssistantDataUIProps<T = any> = {
6
+ name: string;
7
+ render: DataMessagePartComponent<T>;
8
+ };
9
+
10
+ export const useAssistantDataUI = (dataUI: AssistantDataUIProps | null) => {
11
+ const aui = useAui();
12
+ useEffect(() => {
13
+ if (!dataUI?.name || !dataUI?.render) return undefined;
14
+ return aui.dataRenderers().setDataUI(dataUI.name, dataUI.render);
15
+ }, [aui, dataUI?.name, dataUI?.render]);
16
+ };
@@ -0,0 +1,30 @@
1
+ import { useEffect } from "react";
2
+ import { useAui } from "@assistant-ui/store";
3
+ import type { AssistantInstructionsConfig } from "../..";
4
+
5
+ export type { AssistantInstructionsConfig };
6
+
7
+ const getInstructions = (
8
+ instruction: string | AssistantInstructionsConfig,
9
+ ): AssistantInstructionsConfig => {
10
+ if (typeof instruction === "string") return { instruction };
11
+ return instruction;
12
+ };
13
+
14
+ export const useAssistantInstructions = (
15
+ config: string | AssistantInstructionsConfig,
16
+ ) => {
17
+ const { instruction, disabled = false } = getInstructions(config);
18
+ const aui = useAui();
19
+
20
+ useEffect(() => {
21
+ if (disabled) return;
22
+
23
+ const config = {
24
+ system: instruction,
25
+ };
26
+ return aui.modelContext().register({
27
+ getModelContext: () => config,
28
+ });
29
+ }, [aui, instruction, disabled]);
30
+ };
@@ -0,0 +1,37 @@
1
+ import { useEffect } from "react";
2
+ import { useAui } from "@assistant-ui/store";
3
+ import type { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
4
+ import type { AssistantToolProps as CoreAssistantToolProps } from "../..";
5
+
6
+ export type AssistantToolProps<
7
+ TArgs extends Record<string, unknown>,
8
+ TResult,
9
+ > = CoreAssistantToolProps<TArgs, TResult> & {
10
+ render?: ToolCallMessagePartComponent<TArgs, TResult> | undefined;
11
+ };
12
+
13
+ export const useAssistantTool = <
14
+ TArgs extends Record<string, unknown>,
15
+ TResult,
16
+ >(
17
+ tool: AssistantToolProps<TArgs, TResult>,
18
+ ) => {
19
+ const aui = useAui();
20
+
21
+ useEffect(() => {
22
+ if (!tool.render) return undefined;
23
+ return aui.tools().setToolUI(tool.toolName, tool.render);
24
+ }, [aui, tool.toolName, tool.render]);
25
+
26
+ useEffect(() => {
27
+ const { toolName, render, ...rest } = tool;
28
+ const context = {
29
+ tools: {
30
+ [toolName]: rest,
31
+ },
32
+ };
33
+ return aui.modelContext().register({
34
+ getModelContext: () => context,
35
+ });
36
+ }, [aui, tool]);
37
+ };
@@ -0,0 +1,18 @@
1
+ import { useEffect } from "react";
2
+ import { useAui } from "@assistant-ui/store";
3
+ import type { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
4
+
5
+ export type AssistantToolUIProps<TArgs, TResult> = {
6
+ toolName: string;
7
+ render: ToolCallMessagePartComponent<TArgs, TResult>;
8
+ };
9
+
10
+ export const useAssistantToolUI = (
11
+ tool: AssistantToolUIProps<any, any> | null,
12
+ ) => {
13
+ const aui = useAui();
14
+ useEffect(() => {
15
+ if (!tool?.toolName || !tool?.render) return undefined;
16
+ return aui.tools().setToolUI(tool.toolName, tool.render);
17
+ }, [aui, tool?.toolName, tool?.render]);
18
+ };
@@ -0,0 +1,25 @@
1
+ import { FC, useCallback, useEffect, useState } from "react";
2
+ import { ToolCallMessagePartProps } from "../types";
3
+ import { create } from "zustand";
4
+
5
+ export const useInlineRender = <TArgs, TResult>(
6
+ toolUI: FC<ToolCallMessagePartProps<TArgs, TResult>>,
7
+ ): FC<ToolCallMessagePartProps<TArgs, TResult>> => {
8
+ const [useToolUIStore] = useState(() =>
9
+ create(() => ({
10
+ toolUI,
11
+ })),
12
+ );
13
+
14
+ useEffect(() => {
15
+ useToolUIStore.setState({ toolUI });
16
+ }, [toolUI, useToolUIStore]);
17
+
18
+ return useCallback(
19
+ function ToolUI(args) {
20
+ const store = useToolUIStore();
21
+ return store.toolUI(args);
22
+ },
23
+ [useToolUIStore],
24
+ );
25
+ };
@@ -0,0 +1,73 @@
1
+ import {
2
+ type ComponentType,
3
+ type FC,
4
+ type PropsWithChildren,
5
+ useMemo,
6
+ } from "react";
7
+ import { useAuiState } from "@assistant-ui/store";
8
+ import { ChainOfThoughtPartByIndexProvider } from "../../providers/ChainOfThoughtPartByIndexProvider";
9
+ import { MessagePartComponent } from "../message/MessageParts";
10
+ import type {
11
+ ReasoningMessagePartComponent,
12
+ ToolCallMessagePartComponent,
13
+ } from "../../types";
14
+
15
+ export namespace ChainOfThoughtPrimitiveParts {
16
+ export type Props = {
17
+ /**
18
+ * Component configuration for rendering chain of thought parts.
19
+ */
20
+ components?: {
21
+ /** Component for rendering reasoning parts */
22
+ Reasoning?: ReasoningMessagePartComponent | undefined;
23
+ /** Fallback component for tool-call parts */
24
+ tools?: {
25
+ Fallback?: ToolCallMessagePartComponent | undefined;
26
+ };
27
+ /** Layout component to wrap the rendered parts when expanded */
28
+ Layout?: ComponentType<PropsWithChildren> | undefined;
29
+ };
30
+ };
31
+ }
32
+
33
+ /**
34
+ * Renders the parts within a chain of thought, with support for collapsed/expanded states.
35
+ *
36
+ * When collapsed, no parts are shown. When expanded, all parts are rendered
37
+ * using the provided component configuration through the part scope mechanism.
38
+ */
39
+ export const ChainOfThoughtPrimitiveParts: FC<
40
+ ChainOfThoughtPrimitiveParts.Props
41
+ > = ({ components }) => {
42
+ const partsLength = useAuiState((s) => s.chainOfThought.parts.length);
43
+
44
+ const messageComponents = useMemo(
45
+ () => ({
46
+ Reasoning: components?.Reasoning,
47
+ tools: {
48
+ Fallback: components?.tools?.Fallback,
49
+ },
50
+ }),
51
+ [components?.Reasoning, components?.tools?.Fallback],
52
+ );
53
+
54
+ const Layout = components?.Layout;
55
+
56
+ const elements = useMemo(() => {
57
+ return Array.from({ length: partsLength }, (_, index) => (
58
+ <ChainOfThoughtPartByIndexProvider key={index} index={index}>
59
+ {Layout ? (
60
+ <Layout>
61
+ <MessagePartComponent components={messageComponents} />
62
+ </Layout>
63
+ ) : (
64
+ <MessagePartComponent components={messageComponents} />
65
+ )}
66
+ </ChainOfThoughtPartByIndexProvider>
67
+ ));
68
+ }, [partsLength, messageComponents, Layout]);
69
+
70
+ return <>{elements}</>;
71
+ };
72
+
73
+ ChainOfThoughtPrimitiveParts.displayName = "ChainOfThoughtPrimitive.Parts";
@@ -0,0 +1,95 @@
1
+ import type { Attachment } from "../../../types";
2
+ import { ComponentType, type FC, memo, useMemo } from "react";
3
+ import { useAuiState } from "@assistant-ui/store";
4
+ import { ComposerAttachmentByIndexProvider } from "../../providers";
5
+
6
+ export namespace ComposerPrimitiveAttachments {
7
+ export type Props = {
8
+ components:
9
+ | {
10
+ Image?: ComponentType | undefined;
11
+ Document?: ComponentType | undefined;
12
+ File?: ComponentType | undefined;
13
+ Attachment?: ComponentType | undefined;
14
+ }
15
+ | undefined;
16
+ };
17
+ }
18
+
19
+ const getComponent = (
20
+ components: ComposerPrimitiveAttachments.Props["components"],
21
+ attachment: Attachment,
22
+ ) => {
23
+ const type = attachment.type;
24
+ switch (type) {
25
+ case "image":
26
+ return components?.Image ?? components?.Attachment;
27
+ case "document":
28
+ return components?.Document ?? components?.Attachment;
29
+ case "file":
30
+ return components?.File ?? components?.Attachment;
31
+ default:
32
+ return components?.Attachment;
33
+ }
34
+ };
35
+
36
+ const AttachmentComponent: FC<{
37
+ components: ComposerPrimitiveAttachments.Props["components"];
38
+ }> = ({ components }) => {
39
+ const attachment = useAuiState((s) => s.attachment);
40
+ if (!attachment) return null;
41
+
42
+ const Component = getComponent(components, attachment);
43
+ if (!Component) return null;
44
+ return <Component />;
45
+ };
46
+
47
+ export namespace ComposerPrimitiveAttachmentByIndex {
48
+ export type Props = {
49
+ index: number;
50
+ components?: ComposerPrimitiveAttachments.Props["components"];
51
+ };
52
+ }
53
+
54
+ /**
55
+ * Renders a single attachment at the specified index within the composer.
56
+ */
57
+ export const ComposerPrimitiveAttachmentByIndex: FC<ComposerPrimitiveAttachmentByIndex.Props> =
58
+ memo(
59
+ ({ index, components }) => {
60
+ return (
61
+ <ComposerAttachmentByIndexProvider index={index}>
62
+ <AttachmentComponent components={components} />
63
+ </ComposerAttachmentByIndexProvider>
64
+ );
65
+ },
66
+ (prev, next) =>
67
+ prev.index === next.index &&
68
+ prev.components?.Image === next.components?.Image &&
69
+ prev.components?.Document === next.components?.Document &&
70
+ prev.components?.File === next.components?.File &&
71
+ prev.components?.Attachment === next.components?.Attachment,
72
+ );
73
+
74
+ ComposerPrimitiveAttachmentByIndex.displayName =
75
+ "ComposerPrimitive.AttachmentByIndex";
76
+
77
+ export const ComposerPrimitiveAttachments: FC<
78
+ ComposerPrimitiveAttachments.Props
79
+ > = ({ components }) => {
80
+ const attachmentsCount = useAuiState((s) => s.composer.attachments.length);
81
+
82
+ const attachmentElements = useMemo(() => {
83
+ return Array.from({ length: attachmentsCount }, (_, index) => (
84
+ <ComposerPrimitiveAttachmentByIndex
85
+ key={index}
86
+ index={index}
87
+ components={components}
88
+ />
89
+ ));
90
+ }, [attachmentsCount, components]);
91
+
92
+ return attachmentElements;
93
+ };
94
+
95
+ ComposerPrimitiveAttachments.displayName = "ComposerPrimitive.Attachments";
@@ -0,0 +1,49 @@
1
+ import type { FC, PropsWithChildren } from "react";
2
+ import { useAuiState } from "@assistant-ui/store";
3
+
4
+ type ComposerIfFilters = {
5
+ /** Whether the composer is in editing mode */
6
+ editing: boolean | undefined;
7
+ /** Whether dictation is currently active */
8
+ dictation: boolean | undefined;
9
+ };
10
+
11
+ export type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
12
+ T,
13
+ Exclude<keyof T, Keys>
14
+ > &
15
+ {
16
+ [K in Keys]-?: Required<Pick<T, K>> & Partial<Pick<T, Exclude<Keys, K>>>;
17
+ }[Keys];
18
+
19
+ export type UseComposerIfProps = RequireAtLeastOne<ComposerIfFilters>;
20
+
21
+ const useComposerIf = (props: UseComposerIfProps) => {
22
+ return useAuiState((s) => {
23
+ if (props.editing === true && !s.composer.isEditing) return false;
24
+ if (props.editing === false && s.composer.isEditing) return false;
25
+
26
+ const isDictating = s.composer.dictation != null;
27
+ if (props.dictation === true && !isDictating) return false;
28
+ if (props.dictation === false && isDictating) return false;
29
+
30
+ return true;
31
+ });
32
+ };
33
+
34
+ export namespace ComposerPrimitiveIf {
35
+ export type Props = PropsWithChildren<UseComposerIfProps>;
36
+ }
37
+
38
+ /**
39
+ * @deprecated Use `<AuiIf condition={(s) => s.composer...} />` instead.
40
+ */
41
+ export const ComposerPrimitiveIf: FC<ComposerPrimitiveIf.Props> = ({
42
+ children,
43
+ ...query
44
+ }) => {
45
+ const result = useComposerIf(query);
46
+ return result ? children : null;
47
+ };
48
+
49
+ ComposerPrimitiveIf.displayName = "ComposerPrimitive.If";
@@ -0,0 +1,98 @@
1
+ import type { CompleteAttachment } from "../../../types";
2
+ import { ComponentType, type FC, memo, useMemo } from "react";
3
+ import { useAuiState } from "@assistant-ui/store";
4
+ import { MessageAttachmentByIndexProvider } from "../../providers";
5
+
6
+ export namespace MessagePrimitiveAttachments {
7
+ export type Props = {
8
+ components:
9
+ | {
10
+ Image?: ComponentType | undefined;
11
+ Document?: ComponentType | undefined;
12
+ File?: ComponentType | undefined;
13
+ Attachment?: ComponentType | undefined;
14
+ }
15
+ | undefined;
16
+ };
17
+ }
18
+
19
+ const getComponent = (
20
+ components: MessagePrimitiveAttachments.Props["components"],
21
+ attachment: CompleteAttachment,
22
+ ) => {
23
+ const type = attachment.type;
24
+ switch (type) {
25
+ case "image":
26
+ return components?.Image ?? components?.Attachment;
27
+ case "document":
28
+ return components?.Document ?? components?.Attachment;
29
+ case "file":
30
+ return components?.File ?? components?.Attachment;
31
+ default:
32
+ return components?.Attachment;
33
+ }
34
+ };
35
+
36
+ const AttachmentComponent: FC<{
37
+ components: MessagePrimitiveAttachments.Props["components"];
38
+ }> = ({ components }) => {
39
+ const attachment = useAuiState((s) => s.attachment);
40
+ if (!attachment) return null;
41
+
42
+ const Component = getComponent(components, attachment as CompleteAttachment);
43
+ if (!Component) return null;
44
+ return <Component />;
45
+ };
46
+
47
+ export namespace MessagePrimitiveAttachmentByIndex {
48
+ export type Props = {
49
+ index: number;
50
+ components?: MessagePrimitiveAttachments.Props["components"];
51
+ };
52
+ }
53
+
54
+ /**
55
+ * Renders a single attachment at the specified index within the current message.
56
+ */
57
+ export const MessagePrimitiveAttachmentByIndex: FC<MessagePrimitiveAttachmentByIndex.Props> =
58
+ memo(
59
+ ({ index, components }) => {
60
+ return (
61
+ <MessageAttachmentByIndexProvider index={index}>
62
+ <AttachmentComponent components={components} />
63
+ </MessageAttachmentByIndexProvider>
64
+ );
65
+ },
66
+ (prev, next) =>
67
+ prev.index === next.index &&
68
+ prev.components?.Image === next.components?.Image &&
69
+ prev.components?.Document === next.components?.Document &&
70
+ prev.components?.File === next.components?.File &&
71
+ prev.components?.Attachment === next.components?.Attachment,
72
+ );
73
+
74
+ MessagePrimitiveAttachmentByIndex.displayName =
75
+ "MessagePrimitive.AttachmentByIndex";
76
+
77
+ export const MessagePrimitiveAttachments: FC<
78
+ MessagePrimitiveAttachments.Props
79
+ > = ({ components }) => {
80
+ const attachmentsCount = useAuiState((s) => {
81
+ if (s.message.role !== "user") return 0;
82
+ return s.message.attachments.length;
83
+ });
84
+
85
+ const attachmentElements = useMemo(() => {
86
+ return Array.from({ length: attachmentsCount }, (_, index) => (
87
+ <MessagePrimitiveAttachmentByIndex
88
+ key={index}
89
+ index={index}
90
+ components={components}
91
+ />
92
+ ));
93
+ }, [attachmentsCount, components]);
94
+
95
+ return attachmentElements;
96
+ };
97
+
98
+ MessagePrimitiveAttachments.displayName = "MessagePrimitive.Attachments";