@assistant-ui/core 0.1.0 → 0.1.1

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 +13 -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 +10 -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 +22 -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 +15 -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
@@ -1,6 +1,6 @@
1
1
  import { resource, tapState, withKey } from "@assistant-ui/tap";
2
- import type { ClientOutput } from "../types/client";
3
- import { tapClientLookup } from "../utils/tap-client-lookup";
2
+ import type { ClientOutput } from "@assistant-ui/store";
3
+ import { tapClientLookup } from "@assistant-ui/store";
4
4
  import type { SuggestionsState, SuggestionState } from "../scopes";
5
5
 
6
6
  export type SuggestionConfig =
@@ -11,8 +11,8 @@ import {
11
11
  tapResource,
12
12
  withKey,
13
13
  } from "@assistant-ui/tap";
14
- import type { ClientOutput } from "../types/client";
15
- import { tapClientLookup } from "../utils/tap-client-lookup";
14
+ import type { ClientOutput } from "@assistant-ui/store";
15
+ import { tapClientLookup } from "@assistant-ui/store";
16
16
  import type { MessageState, PartState } from "../scopes";
17
17
  import { NoOpComposerClient } from "./no-op-composer-client";
18
18
 
@@ -1,41 +1,5 @@
1
- // resources
2
- export { Derived } from "./utils/derived";
3
- export type { DerivedElement } from "./utils/derived";
4
- export { attachTransformScopes } from "./utils/attach-transform-scopes";
5
- export type { ScopesConfig } from "./utils/attach-transform-scopes";
6
-
7
- // tap hooks
8
- export {
9
- tapAssistantClientRef,
10
- tapAssistantEmit,
11
- } from "./utils/tap-assistant-context";
12
- export { tapClientResource } from "./utils/tap-client-resource";
13
- export { tapClientLookup } from "./utils/tap-client-lookup";
14
- export { tapClientList } from "./utils/tap-client-list";
15
-
16
- // types
17
- export type {
18
- ScopeRegistry,
19
- ClientOutput,
20
- AssistantClient,
21
- AssistantState,
22
- ClientMethods,
23
- ClientSchema,
24
- ClientNames,
25
- ClientEvents,
26
- ClientMeta,
27
- ClientElement,
28
- Unsubscribe,
29
- AssistantClientAccessor,
30
- } from "./types/client";
31
- export type {
32
- AssistantEventName,
33
- AssistantEventCallback,
34
- AssistantEventPayload,
35
- AssistantEventSelector,
36
- AssistantEventScope,
37
- } from "./types/events";
38
- export { normalizeEventSelector } from "./types/events";
1
+ // scope registration (module augmentation side effect)
2
+ import "./scope-registration";
39
3
 
40
4
  // scopes
41
5
  export * from "./scopes";
@@ -1,32 +1,5 @@
1
- // Internal utilities — consumed by @assistant-ui/store, not public API.
2
-
3
- export {
4
- BaseProxyHandler,
5
- handleIntrospectionProp,
6
- } from "./utils/base-proxy-handler";
7
- export {
8
- SYMBOL_CLIENT_INDEX,
9
- getClientIndex,
10
- type ClientStack,
11
- tapClientStack,
12
- tapWithClientStack,
13
- } from "./utils/tap-client-stack-context";
14
- export {
15
- type AssistantTapContextValue,
16
- withAssistantTapContextProvider,
17
- } from "./utils/tap-assistant-context";
18
- export { NotificationManager } from "./utils/notification-manager";
19
- export {
20
- PROXIED_ASSISTANT_STATE_SYMBOL,
21
- createProxiedAssistantState,
22
- getProxiedAssistantState,
23
- } from "./utils/proxied-assistant-state";
24
- export {
25
- type RootClients,
26
- type DerivedClients,
27
- tapSplitClients,
28
- } from "./utils/split-clients";
29
- export { getClientState, ClientResource } from "./utils/tap-client-resource";
30
- export { wrapperResource } from "./utils/wrapper-resource";
31
- export { getTransformScopes } from "./utils/attach-transform-scopes";
32
1
  export * from "./runtime-clients";
2
+ export {
3
+ RuntimeAdapterResource,
4
+ baseRuntimeAdapterTransformScopes,
5
+ } from "./clients/runtime-adapter";
@@ -1,5 +1,5 @@
1
1
  import { resource } from "@assistant-ui/tap";
2
- import { type ClientOutput } from "../";
2
+ import { type ClientOutput } from "@assistant-ui/store";
3
3
  import { AttachmentRuntime } from "../../runtime";
4
4
  import { tapSubscribable } from "./tap-subscribable";
5
5
 
@@ -7,7 +7,11 @@ import {
7
7
  type tapRef,
8
8
  withKey,
9
9
  } from "@assistant-ui/tap";
10
- import { type ClientOutput, tapAssistantEmit, tapClientLookup } from "../";
10
+ import {
11
+ type ClientOutput,
12
+ tapAssistantEmit,
13
+ tapClientLookup,
14
+ } from "@assistant-ui/store";
11
15
  import {
12
16
  ComposerRuntime,
13
17
  EditComposerRuntime,
@@ -1,5 +1,5 @@
1
1
  import { resource } from "@assistant-ui/tap";
2
- import { type ClientOutput } from "../";
2
+ import { type ClientOutput } from "@assistant-ui/store";
3
3
  import { MessagePartRuntime } from "../../runtime";
4
4
  import { tapSubscribable } from "./tap-subscribable";
5
5
 
@@ -6,7 +6,11 @@ import {
6
6
  tapState,
7
7
  type tapRef,
8
8
  } from "@assistant-ui/tap";
9
- import { type ClientOutput, tapClientLookup, tapClientResource } from "../";
9
+ import {
10
+ type ClientOutput,
11
+ tapClientLookup,
12
+ tapClientResource,
13
+ } from "@assistant-ui/store";
10
14
  import { MessageRuntime } from "../../runtime";
11
15
  import { tapSubscribable } from "./tap-subscribable";
12
16
  import { ComposerClient } from "./composer-runtime-client";
@@ -1,6 +1,6 @@
1
1
  import type { Unsubscribe } from "../../types";
2
2
  import { resource, tapEffect } from "@assistant-ui/tap";
3
- import { type ClientOutput, tapAssistantEmit } from "../";
3
+ import { type ClientOutput, tapAssistantEmit } from "@assistant-ui/store";
4
4
  import { ThreadListItemEventType, ThreadListItemRuntime } from "../../runtime";
5
5
  import { tapSubscribable } from "./tap-subscribable";
6
6
 
@@ -1,5 +1,9 @@
1
1
  import { withKey, resource, tapResource, tapMemo } from "@assistant-ui/tap";
2
- import { type ClientOutput, tapClientLookup, tapClientResource } from "../";
2
+ import {
3
+ type ClientOutput,
4
+ tapClientLookup,
5
+ tapClientResource,
6
+ } from "@assistant-ui/store";
3
7
  import { ThreadListRuntime, AssistantRuntime } from "../../runtime";
4
8
  import { tapSubscribable } from "./tap-subscribable";
5
9
  import { ThreadListItemClient } from "./thread-list-item-runtime-client";
@@ -13,7 +13,7 @@ import {
13
13
  tapAssistantEmit,
14
14
  tapClientLookup,
15
15
  tapClientResource,
16
- } from "../";
16
+ } from "@assistant-ui/store";
17
17
  import { ComposerClient } from "./composer-runtime-client";
18
18
  import { MessageClient } from "./message-runtime-client";
19
19
  import { tapSubscribable } from "./tap-subscribable";
@@ -0,0 +1,27 @@
1
+ import type { ThreadsClientSchema } from "./scopes/threads";
2
+ import type { ThreadListItemClientSchema } from "./scopes/thread-list-item";
3
+ import type { ThreadClientSchema } from "./scopes/thread";
4
+ import type { MessageClientSchema } from "./scopes/message";
5
+ import type { PartClientSchema } from "./scopes/part";
6
+ import type { ComposerClientSchema } from "./scopes/composer";
7
+ import type { AttachmentClientSchema } from "./scopes/attachment";
8
+ import type { ModelContextClientSchema } from "./scopes/model-context";
9
+ import type { SuggestionsClientSchema } from "./scopes/suggestions";
10
+ import type { SuggestionClientSchema } from "./scopes/suggestion";
11
+ import type { ChainOfThoughtClientSchema } from "./scopes/chain-of-thought";
12
+
13
+ declare module "@assistant-ui/store" {
14
+ interface ScopeRegistry {
15
+ threads: ThreadsClientSchema;
16
+ threadListItem: ThreadListItemClientSchema;
17
+ thread: ThreadClientSchema;
18
+ message: MessageClientSchema;
19
+ part: PartClientSchema;
20
+ composer: ComposerClientSchema;
21
+ attachment: AttachmentClientSchema;
22
+ modelContext: ModelContextClientSchema;
23
+ suggestions: SuggestionsClientSchema;
24
+ suggestion: SuggestionClientSchema;
25
+ chainOfThought: ChainOfThoughtClientSchema;
26
+ }
27
+ }
@@ -1,5 +1,6 @@
1
1
  import type {
2
2
  Attachment,
3
+ CreateAttachment,
3
4
  MessageRole,
4
5
  RunConfig,
5
6
  QuoteInfo,
@@ -36,7 +37,7 @@ export type ComposerMethods = {
36
37
  setText(text: string): void;
37
38
  setRole(role: MessageRole): void;
38
39
  setRunConfig(runConfig: RunConfig): void;
39
- addAttachment(file: File): Promise<void>;
40
+ addAttachment(fileOrAttachment: File | CreateAttachment): Promise<void>;
40
41
  clearAttachments(): Promise<void>;
41
42
  attachment(selector: { index: number } | { id: string }): AttachmentMethods;
42
43
  reset(): Promise<void>;
@@ -0,0 +1,152 @@
1
+ import { describe, expect, it, vi } from "vitest";
2
+ import { ExternalStoreThreadRuntimeCore } from "../runtimes/external-store/external-store-thread-runtime-core";
3
+ import type { ExternalStoreAdapter } from "../runtimes/external-store/external-store-adapter";
4
+ import type { ModelContextProvider } from "../model-context";
5
+
6
+ const mockContextProvider: ModelContextProvider = {
7
+ getModelContext: () => ({}),
8
+ };
9
+
10
+ const makeStore = (
11
+ overrides?: Partial<ExternalStoreAdapter>,
12
+ ): ExternalStoreAdapter => ({
13
+ messages: [],
14
+ onNew: vi.fn(),
15
+ ...overrides,
16
+ });
17
+
18
+ describe("ExternalStoreThreadRuntimeCore - state reference stability", () => {
19
+ describe("capabilities", () => {
20
+ it("should preserve reference when values are unchanged", () => {
21
+ const runtime = new ExternalStoreThreadRuntimeCore(
22
+ mockContextProvider,
23
+ makeStore({ isRunning: false }),
24
+ );
25
+
26
+ const capsBefore = runtime.capabilities;
27
+
28
+ runtime.__internal_setAdapter(makeStore({ isRunning: true }));
29
+
30
+ expect(runtime.capabilities).toBe(capsBefore);
31
+ expect(runtime.capabilities).toEqual(capsBefore);
32
+ });
33
+
34
+ it("should update reference when values actually change", () => {
35
+ const runtime = new ExternalStoreThreadRuntimeCore(
36
+ mockContextProvider,
37
+ makeStore(),
38
+ );
39
+
40
+ const capsBefore = runtime.capabilities;
41
+ expect(capsBefore.edit).toBe(false);
42
+
43
+ runtime.__internal_setAdapter(makeStore({ onEdit: vi.fn() }));
44
+
45
+ expect(runtime.capabilities.edit).toBe(true);
46
+ expect(runtime.capabilities).not.toBe(capsBefore);
47
+ });
48
+
49
+ it("should maintain stable reference across repeated setAdapter calls", () => {
50
+ const runtime = new ExternalStoreThreadRuntimeCore(
51
+ mockContextProvider,
52
+ makeStore(),
53
+ );
54
+
55
+ const initialCaps = runtime.capabilities;
56
+
57
+ for (let i = 0; i < 10; i++) {
58
+ runtime.__internal_setAdapter(makeStore({ isRunning: i % 2 === 0 }));
59
+ }
60
+
61
+ expect(runtime.capabilities).toBe(initialCaps);
62
+ });
63
+ });
64
+
65
+ describe("suggestions", () => {
66
+ it("should preserve reference when array contents are identical", () => {
67
+ const suggestion = { prompt: "Hello" };
68
+ const runtime = new ExternalStoreThreadRuntimeCore(
69
+ mockContextProvider,
70
+ makeStore({ suggestions: [suggestion] }),
71
+ );
72
+
73
+ const suggestionsBefore = runtime.suggestions;
74
+
75
+ // New array reference with same contents
76
+ runtime.__internal_setAdapter(makeStore({ suggestions: [suggestion] }));
77
+
78
+ expect(runtime.suggestions).toBe(suggestionsBefore);
79
+ });
80
+
81
+ it("should update reference when contents change", () => {
82
+ const runtime = new ExternalStoreThreadRuntimeCore(
83
+ mockContextProvider,
84
+ makeStore({ suggestions: [{ prompt: "Hello" }] }),
85
+ );
86
+
87
+ const suggestionsBefore = runtime.suggestions;
88
+
89
+ runtime.__internal_setAdapter(
90
+ makeStore({ suggestions: [{ prompt: "Goodbye" }] }),
91
+ );
92
+
93
+ expect(runtime.suggestions).not.toBe(suggestionsBefore);
94
+ });
95
+
96
+ it("should preserve reference for empty arrays", () => {
97
+ const runtime = new ExternalStoreThreadRuntimeCore(
98
+ mockContextProvider,
99
+ makeStore({ suggestions: [] }),
100
+ );
101
+
102
+ const suggestionsBefore = runtime.suggestions;
103
+
104
+ runtime.__internal_setAdapter(makeStore({ suggestions: [] }));
105
+
106
+ expect(runtime.suggestions).toBe(suggestionsBefore);
107
+ });
108
+ });
109
+
110
+ describe("extras", () => {
111
+ it("should preserve reference when value is identical", () => {
112
+ const extras = { foo: "bar" };
113
+ const runtime = new ExternalStoreThreadRuntimeCore(
114
+ mockContextProvider,
115
+ makeStore({ extras }),
116
+ );
117
+
118
+ expect(runtime.extras).toBe(extras);
119
+
120
+ // New store but same extras reference
121
+ runtime.__internal_setAdapter(makeStore({ extras }));
122
+
123
+ expect(runtime.extras).toBe(extras);
124
+ });
125
+
126
+ it("should update when extras reference changes", () => {
127
+ const runtime = new ExternalStoreThreadRuntimeCore(
128
+ mockContextProvider,
129
+ makeStore({ extras: { foo: "bar" } }),
130
+ );
131
+
132
+ const newExtras = { foo: "baz" };
133
+ runtime.__internal_setAdapter(makeStore({ extras: newExtras }));
134
+
135
+ expect(runtime.extras).toBe(newExtras);
136
+ });
137
+ });
138
+
139
+ it("should skip setAdapter entirely when store reference is the same", () => {
140
+ const store = makeStore();
141
+ const runtime = new ExternalStoreThreadRuntimeCore(
142
+ mockContextProvider,
143
+ store,
144
+ );
145
+
146
+ const capsBefore = runtime.capabilities;
147
+
148
+ runtime.__internal_setAdapter(store);
149
+
150
+ expect(runtime.capabilities).toBe(capsBefore);
151
+ });
152
+ });
@@ -0,0 +1,110 @@
1
+ import { describe, expect, it } from "vitest";
2
+ import { fromThreadMessageLike } from "../runtime/utils/thread-message-like";
3
+
4
+ const fallbackId = "test-id";
5
+ const fallbackStatus = { type: "complete" as const };
6
+
7
+ describe("fromThreadMessageLike", () => {
8
+ describe("data-* prefixed types", () => {
9
+ it("converts user message data-* part to data part", () => {
10
+ const result = fromThreadMessageLike(
11
+ {
12
+ role: "user",
13
+ content: [{ type: "data-workflow", data: { step: 1, name: "test" } }],
14
+ },
15
+ fallbackId,
16
+ fallbackStatus,
17
+ );
18
+
19
+ expect(result.role).toBe("user");
20
+ expect(result.content).toEqual([
21
+ { type: "data", name: "workflow", data: { step: 1, name: "test" } },
22
+ ]);
23
+ });
24
+
25
+ it("converts assistant message data-* part to data part", () => {
26
+ const result = fromThreadMessageLike(
27
+ {
28
+ role: "assistant",
29
+ content: [{ type: "data-status", data: { progress: 50 } }],
30
+ },
31
+ fallbackId,
32
+ fallbackStatus,
33
+ );
34
+
35
+ expect(result.role).toBe("assistant");
36
+ expect(result.content).toEqual([
37
+ { type: "data", name: "status", data: { progress: 50 } },
38
+ ]);
39
+ });
40
+
41
+ it("still supports explicit data format", () => {
42
+ const result = fromThreadMessageLike(
43
+ {
44
+ role: "assistant",
45
+ content: [{ type: "data", name: "workflow", data: { step: 1 } }],
46
+ },
47
+ fallbackId,
48
+ fallbackStatus,
49
+ );
50
+
51
+ expect(result.role).toBe("assistant");
52
+ expect(result.content).toEqual([
53
+ { type: "data", name: "workflow", data: { step: 1 } },
54
+ ]);
55
+ });
56
+
57
+ it("throws on unknown non-data assistant part types", () => {
58
+ expect(() =>
59
+ fromThreadMessageLike(
60
+ {
61
+ role: "assistant",
62
+ content: [{ type: "unknown-type" } as any],
63
+ },
64
+ fallbackId,
65
+ fallbackStatus,
66
+ ),
67
+ ).toThrow("Unsupported assistant message part type: unknown-type");
68
+ });
69
+
70
+ it("converts data-* parts in attachment content", () => {
71
+ const result = fromThreadMessageLike(
72
+ {
73
+ role: "user",
74
+ content: [{ type: "text", text: "hello" }],
75
+ attachments: [
76
+ {
77
+ id: "att-1",
78
+ type: "data-workflow",
79
+ name: "My Workflow",
80
+ status: { type: "complete" },
81
+ content: [{ type: "data-workflow", data: { id: "wf-1" } }],
82
+ },
83
+ ],
84
+ },
85
+ fallbackId,
86
+ fallbackStatus,
87
+ );
88
+
89
+ expect(result.role).toBe("user");
90
+ const userMsg = result as any;
91
+ expect(userMsg.attachments[0].content).toEqual([
92
+ { type: "data", name: "workflow", data: { id: "wf-1" } },
93
+ ]);
94
+ expect(userMsg.attachments[0].type).toBe("data-workflow");
95
+ });
96
+
97
+ it("throws on unknown non-data user part types", () => {
98
+ expect(() =>
99
+ fromThreadMessageLike(
100
+ {
101
+ role: "user",
102
+ content: [{ type: "tool-call", toolName: "test" } as any],
103
+ },
104
+ fallbackId,
105
+ fallbackStatus,
106
+ ),
107
+ ).toThrow("Unsupported user message part type: tool-call");
108
+ });
109
+ });
110
+ });
@@ -25,9 +25,9 @@ export type AttachmentStatus =
25
25
 
26
26
  type BaseAttachment = {
27
27
  id: string;
28
- type: "image" | "document" | "file";
28
+ type: "image" | "document" | "file" | (string & {});
29
29
  name: string;
30
- contentType: string;
30
+ contentType?: string | undefined;
31
31
  file?: File;
32
32
  content?: ThreadUserMessagePart[];
33
33
  };
@@ -43,3 +43,11 @@ export type CompleteAttachment = BaseAttachment & {
43
43
  };
44
44
 
45
45
  export type Attachment = PendingAttachment | CompleteAttachment;
46
+
47
+ export type CreateAttachment = {
48
+ id?: string;
49
+ type?: "image" | "document" | "file" | (string & {});
50
+ name: string;
51
+ contentType?: string;
52
+ content: ThreadUserMessagePart[];
53
+ };
@@ -32,6 +32,7 @@ export type {
32
32
  PendingAttachment,
33
33
  CompleteAttachment,
34
34
  AttachmentStatus,
35
+ CreateAttachment,
35
36
  } from "./attachment";
36
37
 
37
38
  export type { Unsubscribe } from "./unsubscribe";
@@ -1,137 +0,0 @@
1
- import type { ResourceElement } from "@assistant-ui/tap";
2
- import type { AssistantEventName, AssistantEventCallback, AssistantEventSelector } from "./events.js";
3
- import type { ThreadsClientSchema } from "../scopes/threads.js";
4
- import type { ThreadListItemClientSchema } from "../scopes/thread-list-item.js";
5
- import type { ThreadClientSchema } from "../scopes/thread.js";
6
- import type { MessageClientSchema } from "../scopes/message.js";
7
- import type { PartClientSchema } from "../scopes/part.js";
8
- import type { ComposerClientSchema } from "../scopes/composer.js";
9
- import type { AttachmentClientSchema } from "../scopes/attachment.js";
10
- import type { ModelContextClientSchema } from "../scopes/model-context.js";
11
- import type { SuggestionsClientSchema } from "../scopes/suggestions.js";
12
- import type { SuggestionClientSchema } from "../scopes/suggestion.js";
13
- import type { ChainOfThoughtClientSchema } from "../scopes/chain-of-thought.js";
14
- /**
15
- * Base type for methods that can be called on a client.
16
- */
17
- export interface ClientMethods {
18
- [key: string | symbol]: (...args: any[]) => any;
19
- }
20
- type ClientMetaType = {
21
- source: ClientNames;
22
- query: Record<string, unknown>;
23
- };
24
- /**
25
- * Module augmentation interface for assistant-ui store type extensions.
26
- *
27
- * @example
28
- * ```typescript
29
- * declare module "@assistant-ui/core/store" {
30
- * interface ScopeRegistry {
31
- * // Simple client (meta and events are optional)
32
- * foo: {
33
- * methods: {
34
- * getState: () => { bar: string };
35
- * updateBar: (bar: string) => void;
36
- * };
37
- * };
38
- * // Full client with meta and events
39
- * bar: {
40
- * methods: {
41
- * getState: () => { id: string };
42
- * update: () => void;
43
- * };
44
- * meta: { source: "fooList"; query: { index: number } };
45
- * events: {
46
- * "bar.updated": { id: string };
47
- * };
48
- * };
49
- * }
50
- * }
51
- * ```
52
- */
53
- export interface ScopeRegistry {
54
- threads: ThreadsClientSchema;
55
- threadListItem: ThreadListItemClientSchema;
56
- thread: ThreadClientSchema;
57
- message: MessageClientSchema;
58
- part: PartClientSchema;
59
- composer: ComposerClientSchema;
60
- attachment: AttachmentClientSchema;
61
- modelContext: ModelContextClientSchema;
62
- suggestions: SuggestionsClientSchema;
63
- suggestion: SuggestionClientSchema;
64
- chainOfThought: ChainOfThoughtClientSchema;
65
- }
66
- type ClientEventsType<K extends ClientNames> = Record<`${K}.${string}`, unknown>;
67
- type ClientError<E extends string> = {
68
- methods: Record<E, () => E>;
69
- meta: {
70
- source: ClientNames;
71
- query: Record<E, E>;
72
- };
73
- events: Record<`${E}.`, E>;
74
- };
75
- type ValidateClient<K extends keyof ScopeRegistry> = ScopeRegistry[K] extends {
76
- methods: ClientMethods;
77
- } ? "meta" extends keyof ScopeRegistry[K] ? ScopeRegistry[K]["meta"] extends ClientMetaType ? "events" extends keyof ScopeRegistry[K] ? ScopeRegistry[K]["events"] extends ClientEventsType<K> ? ScopeRegistry[K] : ClientError<`ERROR: ${K & string} has invalid events type`> : ScopeRegistry[K] : ClientError<`ERROR: ${K & string} has invalid meta type`> : "events" extends keyof ScopeRegistry[K] ? ScopeRegistry[K]["events"] extends ClientEventsType<K> ? ScopeRegistry[K] : ClientError<`ERROR: ${K & string} has invalid events type`> : ScopeRegistry[K] : ClientError<`ERROR: ${K & string} has invalid methods type`>;
78
- type ClientSchemas = keyof ScopeRegistry extends never ? {
79
- "ERROR: No clients were defined": ClientError<"ERROR: No clients were defined">;
80
- } : {
81
- [K in keyof ScopeRegistry]: ValidateClient<K>;
82
- };
83
- /**
84
- * Output type that client resources return (just methods).
85
- *
86
- * @example
87
- * ```typescript
88
- * const FooResource = resource((): ClientResourceOutput<"foo"> => {
89
- * const [state, setState] = tapState({ bar: "hello" });
90
- * return {
91
- * getState: () => state,
92
- * updateBar: (b) => setState({ bar: b }),
93
- * };
94
- * });
95
- * ```
96
- */
97
- export type ClientOutput<K extends ClientNames> = ClientSchemas[K]["methods"] & ClientMethods;
98
- export type ClientNames = keyof ClientSchemas extends infer U ? U : never;
99
- export type ClientEvents<K extends ClientNames> = "events" extends keyof ClientSchemas[K] ? ClientSchemas[K]["events"] extends ClientEventsType<K> ? ClientSchemas[K]["events"] : never : never;
100
- export type ClientMeta<K extends ClientNames> = "meta" extends keyof ClientSchemas[K] ? Pick<ClientSchemas[K]["meta"] extends ClientMetaType ? ClientSchemas[K]["meta"] : never, "source" | "query"> : never;
101
- export type ClientElement<K extends ClientNames> = ResourceElement<ClientOutput<K>>;
102
- /**
103
- * Unsubscribe function type.
104
- */
105
- export type Unsubscribe = () => void;
106
- /**
107
- * State type extracted from all clients via their getState() methods.
108
- */
109
- export type AssistantState = {
110
- [K in ClientNames]: ClientSchemas[K]["methods"] extends {
111
- getState: () => infer S;
112
- } ? S : never;
113
- };
114
- /**
115
- * Type for a client accessor - a function that returns the methods,
116
- * with source/query metadata attached (derived from meta).
117
- */
118
- export type AssistantClientAccessor<K extends ClientNames> = (() => ClientSchemas[K]["methods"]) & (ClientMeta<K> | {
119
- source: "root";
120
- query: Record<string, never>;
121
- } | {
122
- source: null;
123
- query: null;
124
- }) & {
125
- name: K;
126
- };
127
- /**
128
- * The assistant client type with all registered clients.
129
- */
130
- export type AssistantClient = {
131
- [K in ClientNames]: AssistantClientAccessor<K>;
132
- } & {
133
- subscribe(listener: () => void): Unsubscribe;
134
- on<TEvent extends AssistantEventName>(selector: AssistantEventSelector<TEvent>, callback: AssistantEventCallback<TEvent>): Unsubscribe;
135
- };
136
- export {};
137
- //# sourceMappingURL=client.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/store/types/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EACV,kBAAkB,EAClB,sBAAsB,EACtB,sBAAsB,EACvB,oBAAiB;AAClB,OAAO,KAAK,EAAE,mBAAmB,EAAE,6BAA0B;AAC7D,OAAO,KAAK,EAAE,0BAA0B,EAAE,sCAAmC;AAC7E,OAAO,KAAK,EAAE,kBAAkB,EAAE,4BAAyB;AAC3D,OAAO,KAAK,EAAE,mBAAmB,EAAE,6BAA0B;AAC7D,OAAO,KAAK,EAAE,gBAAgB,EAAE,0BAAuB;AACvD,OAAO,KAAK,EAAE,oBAAoB,EAAE,8BAA2B;AAC/D,OAAO,KAAK,EAAE,sBAAsB,EAAE,gCAA6B;AACnE,OAAO,KAAK,EAAE,wBAAwB,EAAE,mCAAgC;AACxE,OAAO,KAAK,EAAE,uBAAuB,EAAE,iCAA8B;AACrE,OAAO,KAAK,EAAE,sBAAsB,EAAE,gCAA6B;AACnE,OAAO,KAAK,EAAE,0BA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G;IAAE,IAAI,EAAE,CAAC,CAAA;CAAE,CAAC;AAEpB;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG;KAC3B,CAAC,IAAI,WAAW,GAAG,uBAAuB,CAAC,CAAC,CAAC;CAC/C,GAAG;IACF,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IAC7C,EAAE,CAAC,MAAM,SAAS,kBAAkB,EAClC,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,EACxC,QAAQ,EAAE,sBAAsB,CAAC,MAAM,CAAC,GACvC,WAAW,CAAC;CAChB,CAAC"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=client.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/store/types/client.ts"],"names":[],"mappings":""}