@assistant-ui/core 0.2.9 → 0.2.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (437) hide show
  1. package/dist/adapters/attachment.d.ts.map +1 -1
  2. package/dist/adapters/attachment.js +22 -12
  3. package/dist/adapters/attachment.js.map +1 -1
  4. package/dist/adapters/directive-formatter.js.map +1 -1
  5. package/dist/adapters/speech.js.map +1 -1
  6. package/dist/index.d.ts +3 -1
  7. package/dist/index.js +2 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal.js +1 -1
  10. package/dist/model-context/frame/host.js.map +1 -1
  11. package/dist/model-context/frame/provider.js.map +1 -1
  12. package/dist/model-context/registry.js.map +1 -1
  13. package/dist/model-context/tool.d.ts +1 -1
  14. package/dist/model-context/tool.js +1 -1
  15. package/dist/model-context/tool.js.map +1 -1
  16. package/dist/model-context/types.js +17 -2
  17. package/dist/model-context/types.js.map +1 -1
  18. package/dist/react/AssistantProvider.js +1 -1
  19. package/dist/react/AssistantRuntimeProvider.d.ts +1 -1
  20. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  21. package/dist/react/AssistantRuntimeProvider.js +1 -1
  22. package/dist/react/RuntimeAdapter.js +4 -2
  23. package/dist/react/RuntimeAdapter.js.map +1 -1
  24. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  25. package/dist/react/adapters/LocalStorageThreadListAdapter.js +13 -3
  26. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  27. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  28. package/dist/react/client/DataRenderers.js +6 -5
  29. package/dist/react/client/DataRenderers.js.map +1 -1
  30. package/dist/react/client/Interactables.d.ts.map +1 -1
  31. package/dist/react/client/Interactables.js +30 -29
  32. package/dist/react/client/Interactables.js.map +1 -1
  33. package/dist/react/client/Tools.d.ts.map +1 -1
  34. package/dist/react/client/Tools.js +19 -12
  35. package/dist/react/client/Tools.js.map +1 -1
  36. package/dist/react/index.d.ts +10 -5
  37. package/dist/react/index.js +7 -2
  38. package/dist/react/model-context/define-mcp-toolkit.d.ts +12 -0
  39. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -0
  40. package/dist/react/model-context/define-mcp-toolkit.js +14 -0
  41. package/dist/react/model-context/define-mcp-toolkit.js.map +1 -0
  42. package/dist/react/model-context/define-toolkit.d.ts +10 -12
  43. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  44. package/dist/react/model-context/define-toolkit.js +2 -15
  45. package/dist/react/model-context/define-toolkit.js.map +1 -1
  46. package/dist/react/model-context/external-tool.d.ts +14 -0
  47. package/dist/react/model-context/external-tool.d.ts.map +1 -0
  48. package/dist/react/model-context/external-tool.js +17 -0
  49. package/dist/react/model-context/external-tool.js.map +1 -0
  50. package/dist/react/model-context/human-tool.d.ts +27 -0
  51. package/dist/react/model-context/human-tool.d.ts.map +1 -0
  52. package/dist/react/model-context/human-tool.js +30 -0
  53. package/dist/react/model-context/human-tool.js.map +1 -0
  54. package/dist/react/model-context/makeAssistantTool.d.ts +8 -0
  55. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  56. package/dist/react/model-context/makeAssistantTool.js +4 -0
  57. package/dist/react/model-context/makeAssistantTool.js.map +1 -1
  58. package/dist/react/model-context/makeAssistantToolUI.d.ts +8 -0
  59. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  60. package/dist/react/model-context/makeAssistantToolUI.js +4 -0
  61. package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
  62. package/dist/react/model-context/provider-tool.d.ts +15 -0
  63. package/dist/react/model-context/provider-tool.d.ts.map +1 -0
  64. package/dist/react/model-context/provider-tool.js +12 -0
  65. package/dist/react/model-context/provider-tool.js.map +1 -0
  66. package/dist/react/model-context/stub-tool.d.ts +12 -0
  67. package/dist/react/model-context/stub-tool.d.ts.map +1 -0
  68. package/dist/react/model-context/stub-tool.js +15 -0
  69. package/dist/react/model-context/stub-tool.js.map +1 -0
  70. package/dist/react/model-context/toolbox.d.ts +64 -17
  71. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  72. package/dist/react/model-context/toolbox.js +19 -1
  73. package/dist/react/model-context/toolbox.js.map +1 -1
  74. package/dist/react/model-context/useAssistantContext.js +1 -1
  75. package/dist/react/model-context/useAssistantContext.js.map +1 -1
  76. package/dist/react/model-context/useAssistantDataUI.js +1 -1
  77. package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
  78. package/dist/react/model-context/useAssistantInstructions.js +1 -1
  79. package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
  80. package/dist/react/model-context/useAssistantInteractable.js +1 -1
  81. package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
  82. package/dist/react/model-context/useAssistantTool.d.ts +11 -1
  83. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  84. package/dist/react/model-context/useAssistantTool.js +12 -6
  85. package/dist/react/model-context/useAssistantTool.js.map +1 -1
  86. package/dist/react/model-context/useAssistantToolUI.d.ts +13 -4
  87. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  88. package/dist/react/model-context/useAssistantToolUI.js +7 -4
  89. package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
  90. package/dist/react/model-context/useAuiToolOverrides.d.ts +22 -0
  91. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -0
  92. package/dist/react/model-context/useAuiToolOverrides.js +31 -0
  93. package/dist/react/model-context/useAuiToolOverrides.js.map +1 -0
  94. package/dist/react/model-context/useInlineRender.js +1 -1
  95. package/dist/react/model-context/useInlineRender.js.map +1 -1
  96. package/dist/react/model-context/useInteractableState.js +1 -1
  97. package/dist/react/model-context/useInteractableState.js.map +1 -1
  98. package/dist/react/model-context/useToolArgsStatus.js +1 -1
  99. package/dist/react/primitive-hooks/useActionBarCopy.js +1 -1
  100. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  101. package/dist/react/primitive-hooks/useActionBarEdit.js +1 -1
  102. package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
  103. package/dist/react/primitive-hooks/useActionBarFeedback.js +1 -1
  104. package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
  105. package/dist/react/primitive-hooks/useActionBarReload.js +1 -1
  106. package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
  107. package/dist/react/primitive-hooks/useActionBarSpeak.js +1 -1
  108. package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
  109. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +1 -1
  110. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
  111. package/dist/react/primitive-hooks/useBranchPickerNext.js +1 -1
  112. package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
  113. package/dist/react/primitive-hooks/useBranchPickerPrevious.js +1 -1
  114. package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
  115. package/dist/react/primitive-hooks/useComposerAddAttachment.js +1 -1
  116. package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
  117. package/dist/react/primitive-hooks/useComposerCancel.js +1 -1
  118. package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
  119. package/dist/react/primitive-hooks/useComposerDictate.js +1 -1
  120. package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
  121. package/dist/react/primitive-hooks/useComposerSend.js +1 -1
  122. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  123. package/dist/react/primitive-hooks/useEditComposerCancel.js +1 -1
  124. package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
  125. package/dist/react/primitive-hooks/useEditComposerSend.js +1 -1
  126. package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
  127. package/dist/react/primitive-hooks/useMessageBranching.js +1 -1
  128. package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
  129. package/dist/react/primitive-hooks/useMessageReload.js +1 -1
  130. package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
  131. package/dist/react/primitive-hooks/useSuggestionTrigger.js +1 -1
  132. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  133. package/dist/react/primitive-hooks/useThreadListItemArchive.js +1 -1
  134. package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
  135. package/dist/react/primitive-hooks/useThreadListItemDelete.js +1 -1
  136. package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
  137. package/dist/react/primitive-hooks/useThreadListItemTrigger.js +1 -1
  138. package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
  139. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +1 -1
  140. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
  141. package/dist/react/primitive-hooks/useThreadListLoadMore.js +1 -1
  142. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
  143. package/dist/react/primitive-hooks/useThreadListNew.js +1 -1
  144. package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
  145. package/dist/react/primitive-hooks/useVoice.js +1 -1
  146. package/dist/react/primitive-hooks/useVoice.js.map +1 -1
  147. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +1 -1
  148. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
  149. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
  150. package/dist/react/primitives/composer/ComposerAttachments.js +1 -1
  151. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
  152. package/dist/react/primitives/composer/ComposerQueue.js +1 -1
  153. package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
  154. package/dist/react/primitives/generativeUI/GenerativeUI.js +1 -1
  155. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  156. package/dist/react/primitives/message/MessageAttachments.js +1 -1
  157. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  158. package/dist/react/primitives/message/MessageGroupedParts.js +1 -1
  159. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  160. package/dist/react/primitives/message/MessageParts.d.ts +1 -1
  161. package/dist/react/primitives/message/MessageParts.js +1 -1
  162. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  163. package/dist/react/primitives/message/MessageQuote.js +1 -1
  164. package/dist/react/primitives/part/PartMessages.d.ts +12 -10
  165. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  166. package/dist/react/primitives/part/PartMessages.js +13 -11
  167. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  168. package/dist/react/primitives/thread/ThreadMessages.js +1 -1
  169. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  170. package/dist/react/primitives/thread/ThreadSuggestions.js +1 -1
  171. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  172. package/dist/react/primitives/threadList/ThreadListItems.js +1 -1
  173. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
  174. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
  175. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
  176. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  177. package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
  178. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  179. package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
  180. package/dist/react/providers/ReadonlyThreadProvider.js +1 -1
  181. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  182. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
  183. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  184. package/dist/react/providers/TextMessagePartProvider.js +4 -3
  185. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  186. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
  187. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +7 -0
  188. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  189. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +1 -1
  190. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  191. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +8 -0
  192. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  193. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +29 -1
  194. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  195. package/dist/react/runtimes/RuntimeAdapterProvider.js +1 -1
  196. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +1 -1
  197. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  198. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  199. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +10 -3
  200. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  201. package/dist/react/runtimes/createMessageConverter.d.ts +2 -2
  202. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  203. package/dist/react/runtimes/createMessageConverter.js.map +1 -1
  204. package/dist/react/runtimes/external-message-converter.d.ts +4 -3
  205. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  206. package/dist/react/runtimes/external-message-converter.js +1 -1
  207. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  208. package/dist/react/runtimes/useExternalStoreRuntime.js +1 -1
  209. package/dist/react/runtimes/useExternalStoreSharedOptions.js +1 -1
  210. package/dist/react/runtimes/useLocalRuntime.d.ts +2 -1
  211. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  212. package/dist/react/runtimes/useLocalRuntime.js +4 -3
  213. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  214. package/dist/react/runtimes/useRemoteThreadListRuntime.js +1 -1
  215. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  216. package/dist/react/utils/groupParts.d.ts +1 -1
  217. package/dist/react/utils/groupParts.js.map +1 -1
  218. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  219. package/dist/runtime/api/composer-runtime.d.ts +8 -2
  220. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  221. package/dist/runtime/api/composer-runtime.js +14 -0
  222. package/dist/runtime/api/composer-runtime.js.map +1 -1
  223. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  224. package/dist/runtime/api/message-runtime.js +1 -1
  225. package/dist/runtime/api/message-runtime.js.map +1 -1
  226. package/dist/runtime/api/thread-list-item-runtime.d.ts +2 -0
  227. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  228. package/dist/runtime/api/thread-list-item-runtime.js +6 -0
  229. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  230. package/dist/runtime/api/thread-runtime.d.ts +7 -0
  231. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  232. package/dist/runtime/api/thread-runtime.js.map +1 -1
  233. package/dist/runtime/base/base-composer-runtime-core.d.ts +4 -0
  234. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  235. package/dist/runtime/base/base-composer-runtime-core.js +7 -1
  236. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  237. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  238. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +4 -0
  239. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  240. package/dist/runtime/base/default-thread-composer-runtime-core.js +17 -1
  241. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  242. package/dist/runtime/interfaces/composer-runtime-core.d.ts +6 -1
  243. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  244. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
  245. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  246. package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -0
  247. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  248. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +20 -0
  249. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -0
  250. package/dist/runtime/queue/external-thread-queue-adapter.js +0 -0
  251. package/dist/runtime/queue/message-queue.d.ts +20 -0
  252. package/dist/runtime/queue/message-queue.d.ts.map +1 -0
  253. package/dist/runtime/queue/message-queue.js +97 -0
  254. package/dist/runtime/queue/message-queue.js.map +1 -0
  255. package/dist/runtime/utils/message-repository.js.map +1 -1
  256. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  257. package/dist/runtimes/external-store/external-store-adapter.d.ts +5 -1
  258. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  259. package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
  260. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -0
  261. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  262. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +5 -0
  263. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  264. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +4 -0
  265. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  266. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +20 -2
  267. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  268. package/dist/runtimes/local/local-runtime-core.js.map +1 -1
  269. package/dist/runtimes/local/local-runtime-options.d.ts +5 -0
  270. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  271. package/dist/runtimes/local/local-thread-runtime-core.d.ts +7 -0
  272. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  273. package/dist/runtimes/local/local-thread-runtime-core.js +45 -0
  274. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  275. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +3 -0
  276. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  277. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +3 -0
  278. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  279. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -0
  280. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  281. package/dist/runtimes/remote-thread-list/adapter/in-memory.js +3 -0
  282. package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
  283. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  284. package/dist/runtimes/remote-thread-list/empty-thread-core.js +3 -0
  285. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  286. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  287. package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
  288. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  289. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  290. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  291. package/dist/store/clients/chain-of-thought-client.js +6 -5
  292. package/dist/store/clients/chain-of-thought-client.js.map +1 -1
  293. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  294. package/dist/store/clients/model-context-client.js +6 -5
  295. package/dist/store/clients/model-context-client.js.map +1 -1
  296. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  297. package/dist/store/clients/no-op-composer-client.js +4 -3
  298. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  299. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  300. package/dist/store/clients/runtime-adapter.js +7 -6
  301. package/dist/store/clients/runtime-adapter.js.map +1 -1
  302. package/dist/store/clients/suggestions.d.ts.map +1 -1
  303. package/dist/store/clients/suggestions.js +7 -6
  304. package/dist/store/clients/suggestions.js.map +1 -1
  305. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  306. package/dist/store/clients/thread-message-client.js +13 -12
  307. package/dist/store/clients/thread-message-client.js.map +1 -1
  308. package/dist/store/index.d.ts +1 -1
  309. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  310. package/dist/store/runtime-clients/attachment-runtime-client.js +3 -3
  311. package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
  312. package/dist/store/runtime-clients/composer-runtime-client.d.ts +12 -5
  313. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  314. package/dist/store/runtime-clients/composer-runtime-client.js +32 -16
  315. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  316. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  317. package/dist/store/runtime-clients/message-part-runtime-client.js +3 -3
  318. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  319. package/dist/store/runtime-clients/message-runtime-client.d.ts +6 -3
  320. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  321. package/dist/store/runtime-clients/message-runtime-client.js +17 -16
  322. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  323. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  324. package/dist/store/runtime-clients/thread-list-item-runtime-client.js +9 -7
  325. package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
  326. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  327. package/dist/store/runtime-clients/thread-list-runtime-client.js +11 -10
  328. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  329. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  330. package/dist/store/runtime-clients/thread-runtime-client.js +15 -14
  331. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  332. package/dist/store/runtime-clients/useSubscribable.d.ts +7 -0
  333. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -0
  334. package/dist/store/runtime-clients/useSubscribable.js +16 -0
  335. package/dist/store/runtime-clients/useSubscribable.js.map +1 -0
  336. package/dist/store/scope-registration.d.ts +1 -1
  337. package/dist/store/scopes/composer.d.ts +1 -1
  338. package/dist/store/scopes/queue-item.d.ts +2 -1
  339. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  340. package/dist/store/scopes/queue-item.js +6 -0
  341. package/dist/store/scopes/queue-item.js.map +1 -0
  342. package/dist/store/scopes/thread-list-item.d.ts +1 -0
  343. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  344. package/dist/store/scopes/thread.d.ts +1 -1
  345. package/dist/store/scopes/threads.d.ts +1 -1
  346. package/dist/types/message.d.ts +2 -1
  347. package/dist/types/message.d.ts.map +1 -1
  348. package/dist/types/message.js.map +1 -1
  349. package/dist/utils/composite-context-provider.d.ts +1 -1
  350. package/dist/utils/composite-context-provider.js +3 -1
  351. package/dist/utils/composite-context-provider.js.map +1 -1
  352. package/dist/utils/json/is-json.js.map +1 -1
  353. package/dist/utils/text.js.map +1 -1
  354. package/package.json +15 -11
  355. package/src/adapters/attachment.ts +24 -4
  356. package/src/index.ts +8 -0
  357. package/src/model-context/tool.ts +1 -1
  358. package/src/model-context/types.ts +21 -3
  359. package/src/react/RuntimeAdapter.ts +6 -4
  360. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +15 -2
  361. package/src/react/client/DataRenderers.ts +48 -42
  362. package/src/react/client/Interactables.ts +263 -267
  363. package/src/react/client/Tools.ts +123 -115
  364. package/src/react/index.ts +16 -3
  365. package/src/react/model-context/define-mcp-toolkit.ts +16 -0
  366. package/src/react/model-context/define-toolkit.test.ts +101 -6
  367. package/src/react/model-context/define-toolkit.ts +35 -18
  368. package/src/react/model-context/external-tool.ts +16 -0
  369. package/src/react/model-context/human-tool.ts +32 -0
  370. package/src/react/model-context/makeAssistantTool.ts +8 -0
  371. package/src/react/model-context/makeAssistantToolUI.ts +8 -0
  372. package/src/react/model-context/provider-tool.ts +30 -0
  373. package/src/react/model-context/stub-tool.ts +14 -0
  374. package/src/react/model-context/toolbox.test.ts +182 -0
  375. package/src/react/model-context/toolbox.ts +191 -23
  376. package/src/react/model-context/useAssistantTool.ts +28 -8
  377. package/src/react/model-context/useAssistantToolUI.ts +13 -4
  378. package/src/react/model-context/useAuiToolOverrides.ts +38 -0
  379. package/src/react/primitives/message/MessageGroupedParts.tsx +1 -1
  380. package/src/react/primitives/part/PartMessages.tsx +12 -10
  381. package/src/react/providers/TextMessagePartProvider.tsx +31 -32
  382. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +43 -0
  383. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +9 -0
  384. package/src/react/runtimes/createMessageConverter.ts +2 -1
  385. package/src/react/runtimes/external-message-converter.ts +5 -3
  386. package/src/react/runtimes/useLocalRuntime.ts +2 -0
  387. package/src/runtime/api/composer-runtime.ts +26 -0
  388. package/src/runtime/api/thread-list-item-runtime.ts +15 -0
  389. package/src/runtime/base/base-composer-runtime-core.ts +11 -0
  390. package/src/runtime/base/default-thread-composer-runtime-core.ts +22 -0
  391. package/src/runtime/interfaces/composer-runtime-core.ts +7 -0
  392. package/src/runtime/interfaces/thread-list-runtime-core.ts +4 -0
  393. package/src/runtime/interfaces/thread-runtime-core.ts +5 -0
  394. package/src/runtime/queue/external-thread-queue-adapter.ts +14 -0
  395. package/src/runtime/queue/message-queue.ts +128 -0
  396. package/src/runtimes/external-store/external-store-adapter.ts +10 -0
  397. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +13 -0
  398. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +31 -2
  399. package/src/runtimes/local/local-runtime-options.ts +6 -0
  400. package/src/runtimes/local/local-thread-runtime-core.ts +70 -0
  401. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +4 -0
  402. package/src/runtimes/remote-thread-list/adapter/in-memory.ts +4 -0
  403. package/src/runtimes/remote-thread-list/empty-thread-core.ts +4 -0
  404. package/src/runtimes/remote-thread-list/types.ts +4 -0
  405. package/src/store/clients/chain-of-thought-client.ts +24 -25
  406. package/src/store/clients/model-context-client.test.ts +87 -2
  407. package/src/store/clients/model-context-client.ts +22 -19
  408. package/src/store/clients/no-op-composer-client.ts +69 -66
  409. package/src/store/clients/runtime-adapter.ts +9 -6
  410. package/src/store/clients/suggestions.ts +41 -40
  411. package/src/store/clients/thread-message-client.ts +127 -132
  412. package/src/store/runtime-clients/attachment-runtime-client.ts +7 -3
  413. package/src/store/runtime-clients/composer-runtime-client.ts +142 -113
  414. package/src/store/runtime-clients/message-part-runtime-client.ts +16 -14
  415. package/src/store/runtime-clients/message-runtime-client.ts +124 -122
  416. package/src/store/runtime-clients/thread-list-item-runtime-client.ts +44 -44
  417. package/src/store/runtime-clients/thread-list-runtime-client.ts +83 -80
  418. package/src/store/runtime-clients/thread-runtime-client.ts +113 -119
  419. package/src/store/runtime-clients/{tap-subscribable.ts → useSubscribable.ts} +4 -4
  420. package/src/store/scopes/queue-item.ts +2 -0
  421. package/src/store/scopes/thread-list-item.ts +1 -0
  422. package/src/tests/RemoteThreadListThreadListRuntimeCore-custom-metadata.test.ts +69 -1
  423. package/src/tests/attachment-adapters.test.ts +86 -0
  424. package/src/tests/external-store-thread-runtime-core.test.ts +125 -0
  425. package/src/tests/message-queue.test.ts +168 -0
  426. package/src/tests/thread-list-runtime-getLoadThreadsPromise.test.ts +1 -0
  427. package/src/types/message.ts +2 -0
  428. package/src/utils/composite-context-provider.ts +3 -1
  429. package/dist/react/model-context/hitl.d.ts +0 -19
  430. package/dist/react/model-context/hitl.d.ts.map +0 -1
  431. package/dist/react/model-context/hitl.js +0 -22
  432. package/dist/react/model-context/hitl.js.map +0 -1
  433. package/dist/store/runtime-clients/tap-subscribable.d.ts +0 -7
  434. package/dist/store/runtime-clients/tap-subscribable.d.ts.map +0 -1
  435. package/dist/store/runtime-clients/tap-subscribable.js +0 -16
  436. package/dist/store/runtime-clients/tap-subscribable.js.map +0 -1
  437. package/src/react/model-context/hitl.ts +0 -22
@@ -1,15 +1,12 @@
1
+ import { useState, useEffect, useCallback, useMemo } from "react";
1
2
  import {
3
+ useResources,
2
4
  resource,
3
- tapState,
4
- tapEffect,
5
- tapCallback,
6
- tapMemo,
7
- tapResources,
8
5
  withKey,
9
6
  type ResourceElement,
10
7
  } from "@assistant-ui/tap";
11
8
  import {
12
- tapAssistantClientRef,
9
+ useAssistantClientRef,
13
10
  type ClientOutput,
14
11
  attachTransformScopes,
15
12
  } from "@assistant-ui/store";
@@ -17,6 +14,7 @@ import type { McpAppResourceOutput, ToolsState } from "../types/scopes/tools";
17
14
  import type { Tool } from "assistant-stream";
18
15
  import {
19
16
  isStandaloneToolDisplay,
17
+ makeToolCallTextComponent,
20
18
  type Toolkit,
21
19
  } from "../model-context/toolbox";
22
20
  import type { ToolCallMessagePartComponent } from "../types/MessagePartComponentTypes";
@@ -32,122 +30,132 @@ export type { McpAppResourceOutput };
32
30
  * context, while each tool renderer is registered with the tools scope for
33
31
  * message rendering.
34
32
  */
35
- export const Tools = resource(
36
- ({
37
- toolkit,
38
- mcpApp,
39
- }: {
40
- /** Tools to expose to the model and optional renderers to install. */
41
- toolkit?: Toolkit;
42
- /** Optional MCP app resource whose tools should be merged into context. */
43
- mcpApp?: ResourceElement<McpAppResourceOutput> | undefined;
44
- }): ClientOutput<"tools"> => {
45
- const mcpAppOutputs = tapResources(
46
- () => (mcpApp ? [withKey("mcpApp", mcpApp)] : []),
47
- [mcpApp],
48
- );
49
- const mcpAppOutput = mcpAppOutputs[0];
50
-
51
- const [toolUIs, setToolUIs] = tapState<ToolsState["toolUIs"]>(() => ({}));
52
-
53
- const state = tapMemo(
54
- (): ToolsState => ({
55
- toolUIs,
56
- mcpApp: mcpAppOutput,
57
- // Deprecated component-only view, derived from `toolUIs`. Removed in v0.15.
58
- tools: Object.fromEntries(
59
- Object.entries(toolUIs).map(([name, regs]) => [
60
- name,
61
- regs.map((r) => r.render),
62
- ]),
63
- ),
64
- }),
65
- [toolUIs, mcpAppOutput],
66
- );
67
-
68
- const clientRef = tapAssistantClientRef();
69
-
70
- const setToolUI = tapCallback(
71
- (
72
- toolName: string,
73
- render: ToolCallMessagePartComponent,
74
- options?: { standalone?: boolean },
75
- ) => {
76
- // One registration object per call; identity is the removal key, so
77
- // the per-name list stays correctly ref-counted across re-registers.
78
- const registration = {
79
- render,
80
- standalone: options?.standalone ?? false,
81
- };
82
-
83
- setToolUIs((prev) => ({
84
- ...prev,
85
- [toolName]: [...(prev[toolName] ?? []), registration],
86
- }));
87
-
88
- return () => {
89
- setToolUIs((prev) => {
90
- const next =
91
- prev[toolName]?.filter((r) => r !== registration) ?? [];
92
- if (next.length > 0) return { ...prev, [toolName]: next };
93
- // Drop the key entirely so repeatedly mounted/unmounted tools
94
- // don't leave empty arrays accumulating across a long session.
95
- const { [toolName]: _removed, ...rest } = prev;
96
- return rest;
97
- });
98
- };
99
- },
100
- [],
101
- );
102
-
103
- tapEffect(() => {
104
- if (!toolkit) return;
105
- const unsubscribes: (() => void)[] = [];
106
-
107
- // Register tool UIs (exclude symbols)
108
- for (const [toolName, tool] of Object.entries(toolkit)) {
109
- if (tool.render) {
110
- unsubscribes.push(
111
- setToolUI(toolName, tool.render, {
112
- standalone: isStandaloneToolDisplay(tool),
113
- }),
114
- );
115
- }
116
- }
117
-
118
- // Register tools with model context (exclude symbols). `render` and
119
- // `display` are client-only presentation concerns and never reach the
120
- // model.
121
- const toolsWithoutRender = Object.entries(toolkit).reduce(
122
- (acc, [name, tool]) => {
123
- const { render, display, ...rest } = tool;
124
- acc[name] = rest;
125
- return acc;
126
- },
127
- {} as Record<string, Tool<any, any>>,
128
- );
129
-
130
- const modelContextProvider = {
131
- getModelContext: () => ({
132
- tools: toolsWithoutRender,
133
- }),
33
+ export const Tools = resource(function Tools({
34
+ toolkit,
35
+ mcpApp,
36
+ }: {
37
+ /** Tools to expose to the model and optional renderers to install. */
38
+ toolkit?: Toolkit;
39
+ /** Optional MCP app resource whose tools should be merged into context. */
40
+ mcpApp?: ResourceElement<McpAppResourceOutput> | undefined;
41
+ }): ClientOutput<"tools"> {
42
+ const mcpAppOutputs = useResources(
43
+ () => (mcpApp ? [withKey("mcpApp", mcpApp)] : []),
44
+ [mcpApp],
45
+ );
46
+ const mcpAppOutput = mcpAppOutputs[0];
47
+
48
+ const [toolUIs, setToolUIs] = useState<ToolsState["toolUIs"]>(() => ({}));
49
+
50
+ const state = useMemo(
51
+ (): ToolsState => ({
52
+ toolUIs,
53
+ mcpApp: mcpAppOutput,
54
+ // Deprecated component-only view, derived from `toolUIs`. Removed in v0.15.
55
+ tools: Object.fromEntries(
56
+ Object.entries(toolUIs).map(([name, regs]) => [
57
+ name,
58
+ regs.map((r) => r.render),
59
+ ]),
60
+ ),
61
+ }),
62
+ [toolUIs, mcpAppOutput],
63
+ );
64
+
65
+ const clientRef = useAssistantClientRef();
66
+
67
+ const setToolUI = useCallback(
68
+ (
69
+ toolName: string,
70
+ render: ToolCallMessagePartComponent,
71
+ options?: { standalone?: boolean },
72
+ ) => {
73
+ // One registration object per call; identity is the removal key, so
74
+ // the per-name list stays correctly ref-counted across re-registers.
75
+ const registration = {
76
+ render,
77
+ standalone: options?.standalone ?? false,
134
78
  };
135
79
 
136
- unsubscribes.push(
137
- clientRef.current!.modelContext().register(modelContextProvider),
138
- );
80
+ setToolUIs((prev) => ({
81
+ ...prev,
82
+ [toolName]: [...(prev[toolName] ?? []), registration],
83
+ }));
139
84
 
140
85
  return () => {
141
- unsubscribes.forEach((fn) => fn());
86
+ setToolUIs((prev) => {
87
+ const next = prev[toolName]?.filter((r) => r !== registration) ?? [];
88
+ if (next.length > 0) return { ...prev, [toolName]: next };
89
+ // Drop the key entirely so repeatedly mounted/unmounted tools
90
+ // don't leave empty arrays accumulating across a long session.
91
+ const { [toolName]: _removed, ...rest } = prev;
92
+ return rest;
93
+ });
142
94
  };
143
- }, [toolkit, setToolUI, clientRef]);
95
+ },
96
+ [],
97
+ );
98
+
99
+ useEffect(() => {
100
+ if (!toolkit) return;
101
+ const unsubscribes: (() => void)[] = [];
102
+
103
+ // Register tool UIs (exclude symbols)
104
+ for (const [toolName, tool] of Object.entries(toolkit)) {
105
+ const toolRender = "render" in tool ? tool.render : undefined;
106
+ const toolRenderText = "renderText" in tool ? tool.renderText : undefined;
107
+ const render =
108
+ toolRender ??
109
+ (toolRenderText
110
+ ? makeToolCallTextComponent(toolRenderText)
111
+ : undefined);
112
+ if (render) {
113
+ unsubscribes.push(
114
+ setToolUI(toolName, render, {
115
+ standalone: isStandaloneToolDisplay(tool),
116
+ }),
117
+ );
118
+ }
119
+ }
120
+
121
+ // Register tools with model context (exclude symbols). `render`,
122
+ // `renderText`, and `display` are client-only presentation concerns and
123
+ // never reach the model.
124
+ const toolsWithoutRender = Object.entries(toolkit).reduce(
125
+ (acc, [name, tool]) => {
126
+ if (tool.type === "mcp") return acc;
127
+ const {
128
+ display: _display,
129
+ render: _render,
130
+ renderText: _renderText,
131
+ ...rest
132
+ } = tool as typeof tool & { renderText?: unknown };
133
+ acc[name] = rest as Tool<any, any>;
134
+ return acc;
135
+ },
136
+ {} as Record<string, Tool<any, any>>,
137
+ );
144
138
 
145
- return {
146
- getState: () => state,
147
- setToolUI,
139
+ const modelContextProvider = {
140
+ getModelContext: () => ({
141
+ tools: toolsWithoutRender,
142
+ }),
148
143
  };
149
- },
150
- );
144
+
145
+ unsubscribes.push(
146
+ clientRef.current!.modelContext().register(modelContextProvider),
147
+ );
148
+
149
+ return () => {
150
+ unsubscribes.forEach((fn) => fn());
151
+ };
152
+ }, [toolkit, setToolUI, clientRef]);
153
+
154
+ return {
155
+ getState: () => state,
156
+ setToolUI,
157
+ };
158
+ });
151
159
 
152
160
  attachTransformScopes(Tools, (scopes, parent) => {
153
161
  if (!scopes.modelContext && parent.modelContext.source === null) {
@@ -35,11 +35,23 @@ export { useInlineRender } from "./model-context/useInlineRender";
35
35
  export {
36
36
  type Toolkit,
37
37
  type ToolDefinition,
38
- type ToolkitDeclaration,
39
- type ToolkitDeclarationDefinition,
38
+ type ToolkitDefinition,
39
+ type ToolkitDefinitionEntry,
40
+ type ToolCallText,
40
41
  } from "./model-context/toolbox";
41
42
  export { defineToolkit } from "./model-context/define-toolkit";
42
- export { hitl } from "./model-context/hitl";
43
+ export { stubTool } from "./model-context/stub-tool";
44
+ export { externalTool } from "./model-context/external-tool";
45
+ export { useAuiToolOverrides } from "./model-context/useAuiToolOverrides";
46
+ export { hitl, hitlTool, humanTool } from "./model-context/human-tool";
47
+ export {
48
+ providerTool,
49
+ type ProviderToolConfig,
50
+ } from "./model-context/provider-tool";
51
+ export {
52
+ defineMcpToolkit,
53
+ type McpToolkitDefinition,
54
+ } from "./model-context/define-mcp-toolkit";
43
55
  export {
44
56
  useAssistantInteractable,
45
57
  type AssistantInteractableProps,
@@ -143,6 +155,7 @@ export {
143
155
  useExternalMessageConverter,
144
156
  convertExternalMessages,
145
157
  } from "./runtimes/external-message-converter";
158
+ export type { JoinStrategy } from "./runtimes/external-message-converter";
146
159
  export { createMessageConverter } from "./runtimes/createMessageConverter";
147
160
  export { RemoteThreadListHookInstanceManager } from "./runtimes/RemoteThreadListHookInstanceManager";
148
161
  export { RemoteThreadListThreadListRuntimeCore } from "./runtimes/RemoteThreadListThreadListRuntimeCore";
@@ -0,0 +1,16 @@
1
+ import type { McpServerConfig } from "assistant-stream";
2
+ import type { Toolkit } from "./toolbox";
3
+
4
+ export type McpToolkitDefinition = Record<string, McpServerConfig>;
5
+
6
+ /**
7
+ * Defines MCP server tools as a spreadable toolkit fragment.
8
+ */
9
+ export function defineMcpToolkit(definition: McpToolkitDefinition): Toolkit {
10
+ return Object.fromEntries(
11
+ Object.entries(definition).map(([name, server]) => [
12
+ name,
13
+ { type: "mcp", server },
14
+ ]),
15
+ ) as Toolkit;
16
+ }
@@ -1,13 +1,108 @@
1
- import { describe, it, expect } from "vitest";
1
+ import { describe, it, expect, expectTypeOf } from "vitest";
2
+ import type { AsyncIterableStream } from "assistant-stream/utils";
2
3
  import { defineToolkit } from "./define-toolkit";
3
- import { hitl } from "./hitl";
4
+ import { hitl, hitlTool, humanTool } from "./human-tool";
5
+ import { providerTool } from "./provider-tool";
6
+ import { stubTool } from "./stub-tool";
7
+ import { externalTool } from "./external-tool";
8
+ import type { ToolkitDefinition } from "./toolbox";
9
+
10
+ type TestStandardSchema<T> = {
11
+ readonly "~standard": {
12
+ readonly version: 1;
13
+ readonly vendor: "test";
14
+ readonly types?: {
15
+ readonly input: T;
16
+ readonly output: T;
17
+ };
18
+ readonly validate: (value: unknown) => { readonly value: T };
19
+ };
20
+ };
21
+
22
+ const checkDefineToolkitTypes = () => {
23
+ defineToolkit({
24
+ search: {
25
+ parameters: {} as TestStandardSchema<{
26
+ query: string;
27
+ limit?: number;
28
+ tags: string[];
29
+ }>,
30
+ execute: async ({
31
+ query,
32
+ limit,
33
+ }: {
34
+ query: string;
35
+ limit?: number;
36
+ tags: string[];
37
+ }) => ({
38
+ ids: [query],
39
+ count: limit ?? 0,
40
+ }),
41
+ streamCall: async (reader) => {
42
+ const query = await reader.args.get("query");
43
+ expectTypeOf(query).toEqualTypeOf<string>();
44
+
45
+ expectTypeOf(reader.args.streamValues("query")).toEqualTypeOf<
46
+ AsyncIterableStream<string>
47
+ >();
48
+ expectTypeOf(reader.args.streamText("query")).toEqualTypeOf<
49
+ AsyncIterableStream<unknown>
50
+ >();
51
+ expectTypeOf(reader.args.forEach("tags")).toEqualTypeOf<
52
+ AsyncIterableStream<string>
53
+ >();
54
+
55
+ const response = await reader.response.get();
56
+ expectTypeOf(response.result).toEqualTypeOf<unknown>();
57
+
58
+ // @ts-expect-error unknown argument paths should not be accepted
59
+ reader.args.get("missing");
60
+ },
61
+ },
62
+ });
63
+ };
64
+ expectTypeOf(checkDefineToolkitTypes).toEqualTypeOf<() => void>();
65
+
66
+ const checkToolkitDefinitionTypes = () => {
67
+ ({
68
+ invalidMcp: {
69
+ // @ts-expect-error MCP-shaped tools cannot also declare an execute callback
70
+ server: { type: "http", url: "https://example.com/mcp" },
71
+ execute: async () => "invalid",
72
+ },
73
+ }) satisfies ToolkitDefinition;
74
+ };
75
+ expectTypeOf(checkToolkitDefinitionTypes).toEqualTypeOf<() => void>();
4
76
 
5
77
  describe("use-generative markers", () => {
6
- it("defineToolkit throws at runtime — it must be stripped by the compiler, never called", () => {
7
- expect(() => defineToolkit({})).toThrow(/no runtime implementation/);
78
+ it("defineToolkit returns the toolkit at runtime", () => {
79
+ const toolkit = {};
80
+ expect(defineToolkit(toolkit)).toBe(toolkit);
81
+ });
82
+
83
+ it("humanTool throws at runtime — it must be stripped by the compiler, never called", () => {
84
+ expect(() => humanTool()).toThrow(/no runtime implementation/);
85
+ });
86
+
87
+ it("hitlTool and hitl remain compatibility aliases", () => {
88
+ expect(hitlTool).toBe(humanTool);
89
+ expect(hitl).toBe(humanTool);
90
+ });
91
+
92
+ it("providerTool throws at runtime — it must be stripped by the compiler, never called", () => {
93
+ expect(() =>
94
+ providerTool({
95
+ providerId: "openai.web_search_preview",
96
+ args: {},
97
+ }),
98
+ ).toThrow(/no runtime implementation/);
99
+ });
100
+
101
+ it("stubTool throws at runtime — it must be stripped by the compiler, never called", () => {
102
+ expect(() => stubTool()).toThrow(/no runtime implementation/);
8
103
  });
9
104
 
10
- it("hitl throws at runtime — it must be stripped by the compiler, never called", () => {
11
- expect(() => hitl()).toThrow(/no runtime implementation/);
105
+ it("externalTool throws at runtime — it must be stripped by the compiler, never called", () => {
106
+ expect(() => externalTool()).toThrow(/no runtime implementation/);
12
107
  });
13
108
  });
@@ -1,23 +1,40 @@
1
- import type { Toolkit, ToolkitDeclaration } from "./toolbox";
1
+ import type {
2
+ Toolkit,
3
+ ToolkitDefinition,
4
+ ToolkitDefinitionEntryWithParameters,
5
+ } from "./toolbox";
2
6
 
3
7
  /**
4
- * Authoring helper for a `"use generative"` toolkit. Accepts the permissive
5
- * {@link ToolkitDeclaration} (a `backend` tool may carry its server `execute`)
6
- * and types the result as the canonical {@link Toolkit}.
8
+ * Toolkit authoring helper. Accepts the permissive {@link ToolkitDefinition}
9
+ * (a generative `backend` tool may carry its server `execute`) and types the
10
+ * result as the canonical {@link Toolkit}.
7
11
  *
8
- * It has **no runtime implementation**. A `"use generative"` compiler (e.g.
9
- * `@assistant-ui/next` or `@assistant-ui/vite`) strips the `defineToolkit(...)`
10
- * wrapper (and its import) per build, so a correctly compiled
11
- * `export default defineToolkit({...})` never calls this. If it *does* run, the
12
- * module was not compiled by a use-generative loader — e.g. `defineToolkit` used
13
- * outside a `"use generative"` file — which would ship a backend `execute` to the
14
- * client. So it throws instead of silently leaking.
12
+ * In a `"use generative"` file, the compiler strips the wrapper per build so it
13
+ * can split schemas, renderers, and executors across the client/server boundary.
14
+ * Outside generative compilation, it returns the toolkit unchanged and can be
15
+ * used for plain frontend/backend/human toolkit objects.
15
16
  */
16
- export function defineToolkit(_declaration: ToolkitDeclaration): Toolkit {
17
- throw new Error(
18
- "[assistant-ui] defineToolkit() has no runtime implementation — it is " +
19
- "stripped at build time by the use-generative compiler. Reaching it means " +
20
- 'this module was not compiled (e.g. defineToolkit used outside a "use ' +
21
- 'generative" file). Add the directive, or do not use defineToolkit here.',
22
- );
17
+ export function defineToolkit<
18
+ TArgsByName extends {
19
+ [K in keyof TArgsByName]: Record<string, unknown>;
20
+ },
21
+ TResultByName extends { [K in keyof TArgsByName]: unknown } = {
22
+ [K in keyof TArgsByName]: any;
23
+ },
24
+ >(_definition: {
25
+ [K in keyof TArgsByName]: ToolkitDefinitionEntryWithParameters<
26
+ TArgsByName[K],
27
+ TResultByName[K]
28
+ >;
29
+ }): Toolkit & {
30
+ [K in keyof TArgsByName]: ToolkitDefinitionEntryWithParameters<
31
+ TArgsByName[K],
32
+ TResultByName[K]
33
+ >;
34
+ };
35
+ export function defineToolkit<const TDefinition extends ToolkitDefinition>(
36
+ _definition: TDefinition,
37
+ ): Toolkit & TDefinition;
38
+ export function defineToolkit(_definition: ToolkitDefinition): Toolkit {
39
+ return _definition as Toolkit;
23
40
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Marks a generative toolkit entry as an externally executed backend tool.
3
+ *
4
+ * Use this when another system (for example a backend route or LangGraph node)
5
+ * already defines and executes the tool, but assistant-ui should render its
6
+ * tool calls. The use-generative compiler omits `execute: externalTool()`
7
+ * entries from the server build and keeps a `type: "backend"` renderer on the
8
+ * client build.
9
+ */
10
+ export function externalTool(): never {
11
+ throw new Error(
12
+ "[assistant-ui] externalTool() has no runtime implementation - it marks a " +
13
+ "tool that executes outside assistant-ui and is stripped at build time " +
14
+ 'by the use-generative compiler. Make sure this module is compiled as "use generative".',
15
+ );
16
+ }
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Marks a tool as **human-in-the-loop**: the agent pauses and the UI (`render`)
3
+ * supplies the result instead of code. Use it as the tool's `execute`:
4
+ *
5
+ * ```tsx
6
+ * confirm: { execute: humanTool(), render: (props) => <Confirm {...props} /> }
7
+ * ```
8
+ *
9
+ * Unlike {@link defineToolkit}, it has **no runtime implementation**: a
10
+ * `"use generative"` compiler (e.g. `@assistant-ui/next` or `@assistant-ui/vite`)
11
+ * detects `execute: humanTool()`, drops it, and stamps the tool `type: "human"`.
12
+ * Reaching it at runtime means the module wasn't compiled (used outside a
13
+ * `"use generative"` file), so it throws.
14
+ */
15
+ export function humanTool(): never {
16
+ throw new Error(
17
+ "[assistant-ui] humanTool() has no runtime implementation — it marks a " +
18
+ "human-in-the-loop tool and is stripped at build time by the " +
19
+ "use-generative compiler. Reaching it means this module was not compiled " +
20
+ '(e.g. humanTool() used outside a "use generative" file).',
21
+ );
22
+ }
23
+
24
+ /**
25
+ * @deprecated Use {@link humanTool}.
26
+ */
27
+ export const hitlTool = humanTool;
28
+
29
+ /**
30
+ * @deprecated Use {@link humanTool}.
31
+ */
32
+ export const hitl = humanTool;
@@ -6,6 +6,10 @@ import { type AssistantToolProps, useAssistantTool } from "./useAssistantTool";
6
6
  *
7
7
  * Rendering the component registers its tool for the lifetime of that render
8
8
  * subtree.
9
+ *
10
+ * @deprecated Use a toolkit with `Tools({ toolkit })` and register it via
11
+ * `useAui({ tools: Tools({ toolkit }) })` instead. See
12
+ * https://assistant-ui.com/docs/migrations/toolkit-tools.
9
13
  */
10
14
  export type AssistantTool = FC & {
11
15
  /** Tool definition registered by this component. */
@@ -19,6 +23,10 @@ export type AssistantTool = FC & {
19
23
  * rather than calling {@link useAssistantTool} directly.
20
24
  *
21
25
  * @param tool - Tool definition and name to register.
26
+ *
27
+ * @deprecated Use a toolkit with `Tools({ toolkit })` and register it via
28
+ * `useAui({ tools: Tools({ toolkit }) })` instead. See
29
+ * https://assistant-ui.com/docs/migrations/toolkit-tools.
22
30
  */
23
31
  export const makeAssistantTool = <
24
32
  TArgs extends Record<string, unknown>,
@@ -9,6 +9,10 @@ import {
9
9
  *
10
10
  * Rendering the component registers a renderer for matching tool-call message
11
11
  * parts.
12
+ *
13
+ * @deprecated Put `render`/`renderText` on the matching toolkit entry, or use
14
+ * `MessagePrimitive.Parts` inline tool render overrides for per-message UI.
15
+ * See https://assistant-ui.com/docs/migrations/toolkit-tools.
12
16
  */
13
17
  export type AssistantToolUI = FC & {
14
18
  /** Tool renderer registered by this component. */
@@ -22,6 +26,10 @@ export type AssistantToolUI = FC & {
22
26
  * are registered elsewhere.
23
27
  *
24
28
  * @param tool - Tool renderer registration.
29
+ *
30
+ * @deprecated Put `render`/`renderText` on the matching toolkit entry, or use
31
+ * `MessagePrimitive.Parts` inline tool render overrides for per-message UI.
32
+ * See https://assistant-ui.com/docs/migrations/toolkit-tools.
25
33
  */
26
34
  export const makeAssistantToolUI = <TArgs, TResult>(
27
35
  tool: AssistantToolUIProps<TArgs, TResult>,
@@ -0,0 +1,30 @@
1
+ import type { Tool } from "assistant-stream";
2
+
3
+ type ProviderToolDefinition<TArgs extends Record<string, unknown>> = Extract<
4
+ Tool<TArgs, unknown>,
5
+ { type: "provider" }
6
+ >;
7
+
8
+ export type ProviderToolConfig<
9
+ TArgs extends Record<string, unknown> = Record<string, unknown>,
10
+ > = Pick<
11
+ ProviderToolDefinition<TArgs>,
12
+ | "providerId"
13
+ | "args"
14
+ | "parameters"
15
+ | "providerOptions"
16
+ | "supportsDeferredResults"
17
+ >;
18
+
19
+ /**
20
+ * Marks a tool as provider-executed. The use-generative compiler converts
21
+ * `execute: providerTool(...)` into a `type: "provider"` tool entry.
22
+ */
23
+ export function providerTool(_config: ProviderToolConfig): never {
24
+ throw new Error(
25
+ "[assistant-ui] providerTool() has no runtime implementation — it marks a " +
26
+ "provider-executed tool and is stripped at build time by the " +
27
+ "use-generative compiler. Reaching it means this module was not compiled " +
28
+ '(e.g. providerTool() used outside a "use generative" file).',
29
+ );
30
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Marks a generative toolkit entry as a frontend tool whose executor will be
3
+ * supplied by `useAuiToolOverrides(...)`.
4
+ *
5
+ * `stubTool()` has no runtime implementation. It must be used inside a
6
+ * `"use generative"` toolkit file so the compiler can strip it.
7
+ */
8
+ export function stubTool(): never {
9
+ throw new Error(
10
+ "[assistant-ui] stubTool() has no runtime implementation - it marks a " +
11
+ "tool executor that must be supplied via useAuiToolOverrides(...). Make " +
12
+ 'sure this module is compiled as "use generative".',
13
+ );
14
+ }