@assistant-ui/react 0.15.21 → 0.15.23

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 (634) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +1 -1
  3. package/dist/assistant-transport.d.ts +24 -24
  4. package/dist/assistant-transport.d.ts.map +1 -1
  5. package/dist/assistant-transport.js.map +1 -1
  6. package/dist/augmentations.d.ts +28 -5
  7. package/dist/augmentations.d.ts.map +1 -1
  8. package/dist/cloud-renderer/CloudRendererHost.d.ts +13 -0
  9. package/dist/cloud-renderer/CloudRendererHost.d.ts.map +1 -0
  10. package/dist/cloud-renderer/CloudRendererHost.js +291 -0
  11. package/dist/cloud-renderer/CloudRendererHost.js.map +1 -0
  12. package/dist/context/ReadonlyStore.d.ts +1 -3
  13. package/dist/context/ReadonlyStore.d.ts.map +1 -1
  14. package/dist/context/index.d.ts +13 -13
  15. package/dist/context/index.d.ts.map +1 -0
  16. package/dist/context/providers/AttachmentByIndexProvider.d.ts +2 -2
  17. package/dist/context/providers/AttachmentByIndexProvider.d.ts.map +1 -0
  18. package/dist/context/providers/ChainOfThoughtByIndicesProvider.d.ts +2 -2
  19. package/dist/context/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -0
  20. package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts +2 -2
  21. package/dist/context/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -0
  22. package/dist/context/providers/MessageByIndexProvider.d.ts +2 -2
  23. package/dist/context/providers/MessageByIndexProvider.d.ts.map +1 -0
  24. package/dist/context/providers/MessageProvider.d.ts +2 -4
  25. package/dist/context/providers/MessageProvider.d.ts.map +1 -1
  26. package/dist/context/providers/PartByIndexProvider.d.ts +2 -2
  27. package/dist/context/providers/PartByIndexProvider.d.ts.map +1 -0
  28. package/dist/context/providers/SuggestionByIndexProvider.d.ts +2 -2
  29. package/dist/context/providers/SuggestionByIndexProvider.d.ts.map +1 -0
  30. package/dist/context/providers/TextMessagePartProvider.d.ts +2 -2
  31. package/dist/context/providers/TextMessagePartProvider.d.ts.map +1 -0
  32. package/dist/context/providers/ThreadListItemProvider.d.ts +2 -2
  33. package/dist/context/providers/ThreadListItemProvider.d.ts.map +1 -0
  34. package/dist/context/providers/ThreadViewportProvider.d.ts +3 -5
  35. package/dist/context/providers/ThreadViewportProvider.d.ts.map +1 -1
  36. package/dist/context/react/ThreadViewportContext.d.ts +17 -19
  37. package/dist/context/react/ThreadViewportContext.d.ts.map +1 -1
  38. package/dist/context/react/utils/createContextHook.d.ts +2 -4
  39. package/dist/context/react/utils/createContextHook.d.ts.map +1 -1
  40. package/dist/context/react/utils/createContextStoreHook.d.ts +15 -17
  41. package/dist/context/react/utils/createContextStoreHook.d.ts.map +1 -1
  42. package/dist/context/stores/ThreadViewport.d.ts +72 -74
  43. package/dist/context/stores/ThreadViewport.d.ts.map +1 -1
  44. package/dist/devtools/DevToolsHooks.d.ts +19 -20
  45. package/dist/devtools/DevToolsHooks.d.ts.map +1 -1
  46. package/dist/hooks/useMessageQuote.d.ts +1 -3
  47. package/dist/hooks/useMessageQuote.d.ts.map +1 -1
  48. package/dist/hooks/useMessageTiming.d.ts +1 -3
  49. package/dist/hooks/useMessageTiming.d.ts.map +1 -1
  50. package/dist/hooks/useToolCallElapsed.d.ts +0 -2
  51. package/dist/hooks/useToolCallElapsed.d.ts.map +1 -1
  52. package/dist/hooks/useToolCallElapsed.js +1 -1
  53. package/dist/index.d.ts +126 -82
  54. package/dist/index.d.ts.map +1 -0
  55. package/dist/index.js +14 -13
  56. package/dist/internal.d.ts +8 -11
  57. package/dist/internal.d.ts.map +1 -1
  58. package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts +24 -26
  59. package/dist/legacy-runtime/AssistantRuntimeProvider.d.ts.map +1 -1
  60. package/dist/legacy-runtime/AssistantRuntimeProvider.js +1 -1
  61. package/dist/legacy-runtime/RuntimeAdapter.d.ts +2 -2
  62. package/dist/legacy-runtime/RuntimeAdapter.d.ts.map +1 -0
  63. package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts +2 -2
  64. package/dist/legacy-runtime/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -0
  65. package/dist/legacy-runtime/runtime/AssistantRuntime.d.ts +3 -3
  66. package/dist/legacy-runtime/runtime/AssistantRuntime.d.ts.map +1 -0
  67. package/dist/legacy-runtime/runtime/AttachmentRuntime.d.ts +3 -3
  68. package/dist/legacy-runtime/runtime/AttachmentRuntime.d.ts.map +1 -0
  69. package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts +4 -3
  70. package/dist/legacy-runtime/runtime/ComposerRuntime.d.ts.map +1 -0
  71. package/dist/legacy-runtime/runtime/RuntimeBindings.d.ts +3 -3
  72. package/dist/legacy-runtime/runtime/RuntimeBindings.d.ts.map +1 -0
  73. package/dist/legacy-runtime/runtime/RuntimePathTypes.d.ts +2 -2
  74. package/dist/legacy-runtime/runtime/RuntimePathTypes.d.ts.map +1 -0
  75. package/dist/legacy-runtime/runtime/ThreadListItemRuntime.d.ts +5 -3
  76. package/dist/legacy-runtime/runtime/ThreadListItemRuntime.d.ts.map +1 -0
  77. package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts +4 -3
  78. package/dist/legacy-runtime/runtime/ThreadRuntime.d.ts.map +1 -0
  79. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts +2 -2
  80. package/dist/legacy-runtime/runtime-cores/adapters/RuntimeAdapterProvider.d.ts.map +1 -0
  81. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts +2 -2
  82. package/dist/legacy-runtime/runtime-cores/adapters/attachment/CloudFileAttachmentAdapter.d.ts.map +1 -0
  83. package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts +2 -2
  84. package/dist/legacy-runtime/runtime-cores/composer/BaseComposerRuntimeCore.d.ts.map +1 -0
  85. package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.d.ts +2 -2
  86. package/dist/legacy-runtime/runtime-cores/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -0
  87. package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.d.ts +2 -2
  88. package/dist/legacy-runtime/runtime-cores/composer/DefaultThreadComposerRuntimeCore.d.ts.map +1 -0
  89. package/dist/legacy-runtime/runtime-cores/core/AssistantRuntimeCore.d.ts +2 -2
  90. package/dist/legacy-runtime/runtime-cores/core/AssistantRuntimeCore.d.ts.map +1 -0
  91. package/dist/legacy-runtime/runtime-cores/core/BaseAssistantRuntimeCore.d.ts +2 -2
  92. package/dist/legacy-runtime/runtime-cores/core/BaseAssistantRuntimeCore.d.ts.map +1 -0
  93. package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.d.ts +2 -2
  94. package/dist/legacy-runtime/runtime-cores/core/BaseThreadRuntimeCore.d.ts.map +1 -0
  95. package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts +2 -2
  96. package/dist/legacy-runtime/runtime-cores/core/ComposerRuntimeCore.d.ts.map +1 -0
  97. package/dist/legacy-runtime/runtime-cores/core/ThreadListRuntimeCore.d.ts +2 -2
  98. package/dist/legacy-runtime/runtime-cores/core/ThreadListRuntimeCore.d.ts.map +1 -0
  99. package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts +2 -2
  100. package/dist/legacy-runtime/runtime-cores/core/ThreadRuntimeCore.d.ts.map +1 -0
  101. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts +2 -2
  102. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreAdapter.d.ts.map +1 -0
  103. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreRuntimeCore.d.ts +2 -2
  104. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -0
  105. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadListRuntimeCore.d.ts +3 -2
  106. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -0
  107. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts +2 -2
  108. package/dist/legacy-runtime/runtime-cores/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -0
  109. package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageConverter.d.ts +3 -2
  110. package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageConverter.d.ts.map +1 -0
  111. package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.d.ts +3 -3
  112. package/dist/legacy-runtime/runtime-cores/external-store/ThreadMessageLike.d.ts.map +1 -0
  113. package/dist/legacy-runtime/runtime-cores/external-store/auto-status.d.ts +2 -2
  114. package/dist/legacy-runtime/runtime-cores/external-store/auto-status.d.ts.map +1 -0
  115. package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts +2 -2
  116. package/dist/legacy-runtime/runtime-cores/external-store/createMessageConverter.d.ts.map +1 -0
  117. package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts +2 -2
  118. package/dist/legacy-runtime/runtime-cores/external-store/external-message-converter.d.ts.map +1 -0
  119. package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts +2 -2
  120. package/dist/legacy-runtime/runtime-cores/external-store/useExternalStoreRuntime.d.ts.map +1 -0
  121. package/dist/legacy-runtime/runtime-cores/local/ChatModelAdapter.d.ts +2 -2
  122. package/dist/legacy-runtime/runtime-cores/local/ChatModelAdapter.d.ts.map +1 -0
  123. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeCore.d.ts +2 -2
  124. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeCore.d.ts.map +1 -0
  125. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts +4 -3
  126. package/dist/legacy-runtime/runtime-cores/local/LocalRuntimeOptions.d.ts.map +1 -0
  127. package/dist/legacy-runtime/runtime-cores/local/LocalThreadListRuntimeCore.d.ts +3 -2
  128. package/dist/legacy-runtime/runtime-cores/local/LocalThreadListRuntimeCore.d.ts.map +1 -0
  129. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts +2 -2
  130. package/dist/legacy-runtime/runtime-cores/local/LocalThreadRuntimeCore.d.ts.map +1 -0
  131. package/dist/legacy-runtime/runtime-cores/local/shouldContinue.d.ts +2 -2
  132. package/dist/legacy-runtime/runtime-cores/local/shouldContinue.d.ts.map +1 -0
  133. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts +2 -2
  134. package/dist/legacy-runtime/runtime-cores/local/useLocalRuntime.d.ts.map +1 -0
  135. package/dist/legacy-runtime/runtime-cores/remote-thread-list/BaseSubscribable.d.ts +2 -2
  136. package/dist/legacy-runtime/runtime-cores/remote-thread-list/BaseSubscribable.d.ts.map +1 -0
  137. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts +2 -2
  138. package/dist/legacy-runtime/runtime-cores/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -0
  139. package/dist/legacy-runtime/runtime-cores/remote-thread-list/OptimisticState.d.ts +2 -2
  140. package/dist/legacy-runtime/runtime-cores/remote-thread-list/OptimisticState.d.ts.map +1 -0
  141. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +2 -2
  142. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -0
  143. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +2 -2
  144. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -0
  145. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts +2 -2
  146. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -0
  147. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.d.ts +2 -2
  148. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.d.ts.map +1 -0
  149. package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts +2 -2
  150. package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts.map +1 -0
  151. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts +2 -2
  152. package/dist/legacy-runtime/runtime-cores/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -0
  153. package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.d.ts +4 -3
  154. package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.d.ts.map +1 -0
  155. package/dist/legacy-runtime/runtime-cores/utils/MessageRepository.js +1 -1
  156. package/dist/mcp-apps/McpAppRenderer.d.ts +49 -51
  157. package/dist/mcp-apps/McpAppRenderer.d.ts.map +1 -1
  158. package/dist/mcp-apps/McpAppRenderer.js +2 -2
  159. package/dist/mcp-apps/McpAppsRemoteHost.d.ts +1 -3
  160. package/dist/mcp-apps/McpAppsRemoteHost.d.ts.map +1 -1
  161. package/dist/mcp-apps/app-frame.d.ts +2 -4
  162. package/dist/mcp-apps/app-frame.d.ts.map +1 -1
  163. package/dist/mcp-apps/bridge.d.ts +11 -13
  164. package/dist/mcp-apps/bridge.d.ts.map +1 -1
  165. package/dist/mcp-apps/index.d.ts +5 -5
  166. package/dist/mcp-apps/index.d.ts.map +1 -0
  167. package/dist/mcp-apps/types.d.ts +95 -97
  168. package/dist/mcp-apps/types.d.ts.map +1 -1
  169. package/dist/mcp-apps/utils.d.ts +2 -3
  170. package/dist/mcp-apps/utils.d.ts.map +1 -1
  171. package/dist/model-context/frame/useAssistantFrameHost.d.ts +8 -8
  172. package/dist/model-context/frame/useAssistantFrameHost.d.ts.map +1 -1
  173. package/dist/model-context/frame/useAssistantFrameHost.js +1 -1
  174. package/dist/model-context/makeAssistantVisible.d.ts +4 -6
  175. package/dist/model-context/makeAssistantVisible.d.ts.map +1 -1
  176. package/dist/model-context/makeAssistantVisible.js +2 -2
  177. package/dist/primitives/actionBar/ActionBarCopy.d.ts +13 -14
  178. package/dist/primitives/actionBar/ActionBarCopy.d.ts.map +1 -1
  179. package/dist/primitives/actionBar/ActionBarCopy.js +1 -1
  180. package/dist/primitives/actionBar/ActionBarEdit.d.ts +10 -11
  181. package/dist/primitives/actionBar/ActionBarEdit.d.ts.map +1 -1
  182. package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts +11 -12
  183. package/dist/primitives/actionBar/ActionBarExportMarkdown.d.ts.map +1 -1
  184. package/dist/primitives/actionBar/ActionBarExportMarkdown.js +4 -1
  185. package/dist/primitives/actionBar/ActionBarExportMarkdown.js.map +1 -1
  186. package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts +6 -7
  187. package/dist/primitives/actionBar/ActionBarFeedbackNegative.d.ts.map +1 -1
  188. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js +11 -9
  189. package/dist/primitives/actionBar/ActionBarFeedbackNegative.js.map +1 -1
  190. package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts +6 -7
  191. package/dist/primitives/actionBar/ActionBarFeedbackPositive.d.ts.map +1 -1
  192. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js +11 -9
  193. package/dist/primitives/actionBar/ActionBarFeedbackPositive.js.map +1 -1
  194. package/dist/primitives/actionBar/ActionBarInteractionContext.d.ts +1 -3
  195. package/dist/primitives/actionBar/ActionBarInteractionContext.d.ts.map +1 -1
  196. package/dist/primitives/actionBar/ActionBarReload.d.ts +10 -11
  197. package/dist/primitives/actionBar/ActionBarReload.d.ts.map +1 -1
  198. package/dist/primitives/actionBar/ActionBarRoot.d.ts +49 -50
  199. package/dist/primitives/actionBar/ActionBarRoot.d.ts.map +1 -1
  200. package/dist/primitives/actionBar/ActionBarSpeak.d.ts +6 -7
  201. package/dist/primitives/actionBar/ActionBarSpeak.d.ts.map +1 -1
  202. package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts +6 -7
  203. package/dist/primitives/actionBar/ActionBarStopSpeaking.d.ts.map +1 -1
  204. package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts +8 -10
  205. package/dist/primitives/actionBar/useActionBarFloatStatus.d.ts.map +1 -1
  206. package/dist/primitives/actionBar.d.ts +9 -14
  207. package/dist/primitives/actionBar.d.ts.map +1 -1
  208. package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts +10 -12
  209. package/dist/primitives/actionBarMore/ActionBarMoreContent.d.ts.map +1 -1
  210. package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts +7 -9
  211. package/dist/primitives/actionBarMore/ActionBarMoreItem.d.ts.map +1 -1
  212. package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts +3 -5
  213. package/dist/primitives/actionBarMore/ActionBarMoreRoot.d.ts.map +1 -1
  214. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts +7 -9
  215. package/dist/primitives/actionBarMore/ActionBarMoreSeparator.d.ts.map +1 -1
  216. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts +7 -9
  217. package/dist/primitives/actionBarMore/ActionBarMoreTrigger.d.ts.map +1 -1
  218. package/dist/primitives/actionBarMore/scope.d.ts +4 -6
  219. package/dist/primitives/actionBarMore/scope.d.ts.map +1 -1
  220. package/dist/primitives/actionBarMore.d.ts +5 -10
  221. package/dist/primitives/actionBarMore.d.ts.map +1 -1
  222. package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts +7 -9
  223. package/dist/primitives/assistantModal/AssistantModalAnchor.d.ts.map +1 -1
  224. package/dist/primitives/assistantModal/AssistantModalContent.d.ts +12 -14
  225. package/dist/primitives/assistantModal/AssistantModalContent.d.ts.map +1 -1
  226. package/dist/primitives/assistantModal/AssistantModalRoot.d.ts +5 -7
  227. package/dist/primitives/assistantModal/AssistantModalRoot.d.ts.map +1 -1
  228. package/dist/primitives/assistantModal/AssistantModalRoot.js +1 -1
  229. package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts +7 -9
  230. package/dist/primitives/assistantModal/AssistantModalTrigger.d.ts.map +1 -1
  231. package/dist/primitives/assistantModal/popoverRenderPrimitives.d.ts +7 -9
  232. package/dist/primitives/assistantModal/popoverRenderPrimitives.d.ts.map +1 -1
  233. package/dist/primitives/assistantModal/scope.d.ts +4 -6
  234. package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
  235. package/dist/primitives/assistantModal.d.ts +4 -9
  236. package/dist/primitives/assistantModal.d.ts.map +1 -1
  237. package/dist/primitives/attachment/AttachmentName.d.ts +2 -4
  238. package/dist/primitives/attachment/AttachmentName.d.ts.map +1 -1
  239. package/dist/primitives/attachment/AttachmentRemove.d.ts +6 -7
  240. package/dist/primitives/attachment/AttachmentRemove.d.ts.map +1 -1
  241. package/dist/primitives/attachment/AttachmentRemove.js +1 -1
  242. package/dist/primitives/attachment/AttachmentRoot.d.ts +10 -11
  243. package/dist/primitives/attachment/AttachmentRoot.d.ts.map +1 -1
  244. package/dist/primitives/attachment/AttachmentThumb.d.ts +6 -7
  245. package/dist/primitives/attachment/AttachmentThumb.d.ts.map +1 -1
  246. package/dist/primitives/attachment/AttachmentThumb.js +1 -1
  247. package/dist/primitives/attachment.d.ts +4 -9
  248. package/dist/primitives/attachment.d.ts.map +1 -1
  249. package/dist/primitives/branchPicker/BranchPickerCount.d.ts +6 -8
  250. package/dist/primitives/branchPicker/BranchPickerCount.d.ts.map +1 -1
  251. package/dist/primitives/branchPicker/BranchPickerNext.d.ts +10 -11
  252. package/dist/primitives/branchPicker/BranchPickerNext.d.ts.map +1 -1
  253. package/dist/primitives/branchPicker/BranchPickerNumber.d.ts +2 -4
  254. package/dist/primitives/branchPicker/BranchPickerNumber.d.ts.map +1 -1
  255. package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts +10 -11
  256. package/dist/primitives/branchPicker/BranchPickerPrevious.d.ts.map +1 -1
  257. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts +18 -20
  258. package/dist/primitives/branchPicker/BranchPickerRoot.d.ts.map +1 -1
  259. package/dist/primitives/branchPicker/BranchPickerRoot.js +1 -1
  260. package/dist/primitives/branchPicker.d.ts +5 -10
  261. package/dist/primitives/branchPicker.d.ts.map +1 -1
  262. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts +10 -11
  263. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.d.ts.map +1 -1
  264. package/dist/primitives/chainOfThought/ChainOfThoughtAccordionTrigger.js +1 -1
  265. package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts +2 -2
  266. package/dist/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -0
  267. package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts +6 -7
  268. package/dist/primitives/chainOfThought/ChainOfThoughtRoot.d.ts.map +1 -1
  269. package/dist/primitives/chainOfThought.d.ts +3 -8
  270. package/dist/primitives/chainOfThought.d.ts.map +1 -1
  271. package/dist/primitives/composer/ComposerAddAttachment.d.ts +11 -12
  272. package/dist/primitives/composer/ComposerAddAttachment.d.ts.map +1 -1
  273. package/dist/primitives/composer/ComposerAddAttachment.js +1 -1
  274. package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts +10 -11
  275. package/dist/primitives/composer/ComposerAttachmentDropzone.d.ts.map +1 -1
  276. package/dist/primitives/composer/ComposerAttachmentDropzone.js +9 -7
  277. package/dist/primitives/composer/ComposerAttachmentDropzone.js.map +1 -1
  278. package/dist/primitives/composer/ComposerAttachments.d.ts +2 -2
  279. package/dist/primitives/composer/ComposerAttachments.d.ts.map +1 -0
  280. package/dist/primitives/composer/ComposerCancel.d.ts +10 -11
  281. package/dist/primitives/composer/ComposerCancel.d.ts.map +1 -1
  282. package/dist/primitives/composer/ComposerCompactContext.d.ts +1 -3
  283. package/dist/primitives/composer/ComposerCompactContext.d.ts.map +1 -1
  284. package/dist/primitives/composer/ComposerDictate.d.ts +6 -7
  285. package/dist/primitives/composer/ComposerDictate.d.ts.map +1 -1
  286. package/dist/primitives/composer/ComposerDictationTranscript.d.ts +5 -7
  287. package/dist/primitives/composer/ComposerDictationTranscript.d.ts.map +1 -1
  288. package/dist/primitives/composer/ComposerDictationTranscript.js +1 -1
  289. package/dist/primitives/composer/ComposerIf.d.ts +3 -2
  290. package/dist/primitives/composer/ComposerIf.d.ts.map +1 -0
  291. package/dist/primitives/composer/ComposerInput.d.ts +72 -74
  292. package/dist/primitives/composer/ComposerInput.d.ts.map +1 -1
  293. package/dist/primitives/composer/ComposerInput.js +3 -3
  294. package/dist/primitives/composer/ComposerInput.js.map +1 -1
  295. package/dist/primitives/composer/ComposerInputPluginContext.d.ts +22 -24
  296. package/dist/primitives/composer/ComposerInputPluginContext.d.ts.map +1 -1
  297. package/dist/primitives/composer/ComposerQueue.d.ts +2 -2
  298. package/dist/primitives/composer/ComposerQueue.d.ts.map +1 -0
  299. package/dist/primitives/composer/ComposerQuote.d.ts +13 -15
  300. package/dist/primitives/composer/ComposerQuote.d.ts.map +1 -1
  301. package/dist/primitives/composer/ComposerQuote.js +1 -1
  302. package/dist/primitives/composer/ComposerRoot.d.ts +26 -28
  303. package/dist/primitives/composer/ComposerRoot.d.ts.map +1 -1
  304. package/dist/primitives/composer/ComposerRoot.js +1 -1
  305. package/dist/primitives/composer/ComposerSend.d.ts +9 -11
  306. package/dist/primitives/composer/ComposerSend.d.ts.map +1 -1
  307. package/dist/primitives/composer/ComposerStopDictation.d.ts +6 -7
  308. package/dist/primitives/composer/ComposerStopDictation.d.ts.map +1 -1
  309. package/dist/primitives/composer/ComposerStopDictation.js +1 -1
  310. package/dist/primitives/composer/trigger/TriggerPopover.d.ts +27 -29
  311. package/dist/primitives/composer/trigger/TriggerPopover.d.ts.map +1 -1
  312. package/dist/primitives/composer/trigger/TriggerPopover.js +2 -2
  313. package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts +10 -12
  314. package/dist/primitives/composer/trigger/TriggerPopoverAction.d.ts.map +1 -1
  315. package/dist/primitives/composer/trigger/TriggerPopoverAction.js +1 -1
  316. package/dist/primitives/composer/trigger/TriggerPopoverBack.d.ts +5 -7
  317. package/dist/primitives/composer/trigger/TriggerPopoverBack.d.ts.map +1 -1
  318. package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts +16 -18
  319. package/dist/primitives/composer/trigger/TriggerPopoverCategories.d.ts.map +1 -1
  320. package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts +8 -10
  321. package/dist/primitives/composer/trigger/TriggerPopoverDirective.d.ts.map +1 -1
  322. package/dist/primitives/composer/trigger/TriggerPopoverDirective.js +1 -1
  323. package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts +18 -20
  324. package/dist/primitives/composer/trigger/TriggerPopoverItems.d.ts.map +1 -1
  325. package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts +41 -43
  326. package/dist/primitives/composer/trigger/TriggerPopoverResource.d.ts.map +1 -1
  327. package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts +27 -28
  328. package/dist/primitives/composer/trigger/TriggerPopoverRootContext.d.ts.map +1 -1
  329. package/dist/primitives/composer/trigger/detectTrigger.d.ts +3 -5
  330. package/dist/primitives/composer/trigger/detectTrigger.d.ts.map +1 -1
  331. package/dist/primitives/composer/trigger/index.d.ts +15 -18
  332. package/dist/primitives/composer/trigger/index.d.ts.map +1 -1
  333. package/dist/primitives/composer/trigger/matchesTriggerItemQuery.d.ts +1 -3
  334. package/dist/primitives/composer/trigger/matchesTriggerItemQuery.d.ts.map +1 -1
  335. package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts +10 -12
  336. package/dist/primitives/composer/trigger/triggerDetectionResource.d.ts.map +1 -1
  337. package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts +22 -24
  338. package/dist/primitives/composer/trigger/triggerKeyboardResource.d.ts.map +1 -1
  339. package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts +18 -20
  340. package/dist/primitives/composer/trigger/triggerNavigationResource.d.ts.map +1 -1
  341. package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts +23 -25
  342. package/dist/primitives/composer/trigger/triggerSelectionResource.d.ts.map +1 -1
  343. package/dist/primitives/composer/useComposerInputState.d.ts +4 -6
  344. package/dist/primitives/composer/useComposerInputState.d.ts.map +1 -1
  345. package/dist/primitives/composer.d.ts +31 -25
  346. package/dist/primitives/composer.d.ts.map +1 -1
  347. package/dist/primitives/dropdownMenuRenderPrimitives.d.ts +9 -11
  348. package/dist/primitives/dropdownMenuRenderPrimitives.d.ts.map +1 -1
  349. package/dist/primitives/error/ErrorMessage.d.ts +5 -7
  350. package/dist/primitives/error/ErrorMessage.d.ts.map +1 -1
  351. package/dist/primitives/error/ErrorRoot.d.ts +5 -7
  352. package/dist/primitives/error/ErrorRoot.d.ts.map +1 -1
  353. package/dist/primitives/error.d.ts +2 -7
  354. package/dist/primitives/error.d.ts.map +1 -1
  355. package/dist/primitives/message/MessageAttachments.d.ts +2 -2
  356. package/dist/primitives/message/MessageAttachments.d.ts.map +1 -0
  357. package/dist/primitives/message/MessageError.d.ts +1 -3
  358. package/dist/primitives/message/MessageError.d.ts.map +1 -1
  359. package/dist/primitives/message/MessageIf.d.ts +15 -16
  360. package/dist/primitives/message/MessageIf.d.ts.map +1 -1
  361. package/dist/primitives/message/MessageIf.js +6 -3
  362. package/dist/primitives/message/MessageIf.js.map +1 -1
  363. package/dist/primitives/message/MessageParts.d.ts +4 -6
  364. package/dist/primitives/message/MessageParts.d.ts.map +1 -1
  365. package/dist/primitives/message/MessagePartsGrouped.d.ts +132 -133
  366. package/dist/primitives/message/MessagePartsGrouped.d.ts.map +1 -1
  367. package/dist/primitives/message/MessagePartsGrouped.js +103 -71
  368. package/dist/primitives/message/MessagePartsGrouped.js.map +1 -1
  369. package/dist/primitives/message/MessageRoot.d.ts +5 -7
  370. package/dist/primitives/message/MessageRoot.d.ts.map +1 -1
  371. package/dist/primitives/message/MessageRoot.js +6 -2
  372. package/dist/primitives/message/MessageRoot.js.map +1 -1
  373. package/dist/primitives/message.d.ts +12 -12
  374. package/dist/primitives/message.d.ts.map +1 -1
  375. package/dist/primitives/messagePart/MessagePartImage.d.ts +9 -11
  376. package/dist/primitives/messagePart/MessagePartImage.d.ts.map +1 -1
  377. package/dist/primitives/messagePart/MessagePartInProgress.d.ts +2 -2
  378. package/dist/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -0
  379. package/dist/primitives/messagePart/MessagePartText.d.ts +35 -37
  380. package/dist/primitives/messagePart/MessagePartText.d.ts.map +1 -1
  381. package/dist/primitives/messagePart/useMessagePartData.d.ts +1 -3
  382. package/dist/primitives/messagePart/useMessagePartData.d.ts.map +1 -1
  383. package/dist/primitives/messagePart/useMessagePartFile.d.ts +2 -4
  384. package/dist/primitives/messagePart/useMessagePartFile.d.ts.map +1 -1
  385. package/dist/primitives/messagePart/useMessagePartImage.d.ts +2 -4
  386. package/dist/primitives/messagePart/useMessagePartImage.d.ts.map +1 -1
  387. package/dist/primitives/messagePart/useMessagePartReasoning.d.ts +2 -4
  388. package/dist/primitives/messagePart/useMessagePartReasoning.d.ts.map +1 -1
  389. package/dist/primitives/messagePart/useMessagePartSource.d.ts +19 -21
  390. package/dist/primitives/messagePart/useMessagePartSource.d.ts.map +1 -1
  391. package/dist/primitives/messagePart/useMessagePartText.d.ts +3 -5
  392. package/dist/primitives/messagePart/useMessagePartText.d.ts.map +1 -1
  393. package/dist/primitives/messagePart.d.ts +4 -9
  394. package/dist/primitives/messagePart.d.ts.map +1 -1
  395. package/dist/primitives/queueItem/QueueItemRemove.d.ts +6 -7
  396. package/dist/primitives/queueItem/QueueItemRemove.d.ts.map +1 -1
  397. package/dist/primitives/queueItem/QueueItemRemove.js +1 -1
  398. package/dist/primitives/queueItem/QueueItemSteer.d.ts +6 -7
  399. package/dist/primitives/queueItem/QueueItemSteer.d.ts.map +1 -1
  400. package/dist/primitives/queueItem/QueueItemSteer.js +1 -1
  401. package/dist/primitives/queueItem/QueueItemText.d.ts +5 -7
  402. package/dist/primitives/queueItem/QueueItemText.d.ts.map +1 -1
  403. package/dist/primitives/queueItem/QueueItemText.js +1 -1
  404. package/dist/primitives/queueItem.d.ts +3 -8
  405. package/dist/primitives/queueItem.d.ts.map +1 -1
  406. package/dist/primitives/reasoning/useScrollLock.d.ts +1 -3
  407. package/dist/primitives/reasoning/useScrollLock.d.ts.map +1 -1
  408. package/dist/primitives/reasoning/useScrollLock.js +14 -15
  409. package/dist/primitives/reasoning/useScrollLock.js.map +1 -1
  410. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts +5 -7
  411. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.d.ts.map +1 -1
  412. package/dist/primitives/selectionToolbar/SelectionToolbarQuote.js +1 -1
  413. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts +12 -13
  414. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.d.ts.map +1 -1
  415. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js +81 -42
  416. package/dist/primitives/selectionToolbar/SelectionToolbarRoot.js.map +1 -1
  417. package/dist/primitives/selectionToolbar.d.ts +2 -7
  418. package/dist/primitives/selectionToolbar.d.ts.map +1 -1
  419. package/dist/primitives/suggestion/SuggestionDescription.d.ts +5 -7
  420. package/dist/primitives/suggestion/SuggestionDescription.d.ts.map +1 -1
  421. package/dist/primitives/suggestion/SuggestionDescription.js +1 -1
  422. package/dist/primitives/suggestion/SuggestionTitle.d.ts +5 -7
  423. package/dist/primitives/suggestion/SuggestionTitle.d.ts.map +1 -1
  424. package/dist/primitives/suggestion/SuggestionTitle.js +1 -1
  425. package/dist/primitives/suggestion/SuggestionTrigger.d.ts +35 -36
  426. package/dist/primitives/suggestion/SuggestionTrigger.d.ts.map +1 -1
  427. package/dist/primitives/suggestion.d.ts +3 -8
  428. package/dist/primitives/suggestion.d.ts.map +1 -1
  429. package/dist/primitives/thread/ThreadEmpty.d.ts +2 -4
  430. package/dist/primitives/thread/ThreadEmpty.d.ts.map +1 -1
  431. package/dist/primitives/thread/ThreadIf.d.ts +7 -8
  432. package/dist/primitives/thread/ThreadIf.d.ts.map +1 -1
  433. package/dist/primitives/thread/ThreadMessages.d.ts +2 -2
  434. package/dist/primitives/thread/ThreadMessages.d.ts.map +1 -0
  435. package/dist/primitives/thread/ThreadRoot.d.ts +12 -13
  436. package/dist/primitives/thread/ThreadRoot.d.ts.map +1 -1
  437. package/dist/primitives/thread/ThreadRoot.js +57 -30
  438. package/dist/primitives/thread/ThreadRoot.js.map +1 -1
  439. package/dist/primitives/thread/ThreadRootElementContext.d.ts +4 -0
  440. package/dist/primitives/thread/ThreadRootElementContext.d.ts.map +1 -0
  441. package/dist/primitives/thread/ThreadRootElementContext.js +11 -0
  442. package/dist/primitives/thread/ThreadRootElementContext.js.map +1 -0
  443. package/dist/primitives/thread/ThreadScrollToBottom.d.ts +11 -13
  444. package/dist/primitives/thread/ThreadScrollToBottom.d.ts.map +1 -1
  445. package/dist/primitives/thread/ThreadSuggestion.d.ts +47 -48
  446. package/dist/primitives/thread/ThreadSuggestion.d.ts.map +1 -1
  447. package/dist/primitives/thread/ThreadSuggestions.d.ts +2 -2
  448. package/dist/primitives/thread/ThreadSuggestions.d.ts.map +1 -0
  449. package/dist/primitives/thread/ThreadViewport.d.ts +88 -90
  450. package/dist/primitives/thread/ThreadViewport.d.ts.map +1 -1
  451. package/dist/primitives/thread/ThreadViewport.js +1 -1
  452. package/dist/primitives/thread/ThreadViewportFooter.d.ts +5 -7
  453. package/dist/primitives/thread/ThreadViewportFooter.d.ts.map +1 -1
  454. package/dist/primitives/thread/topAnchor/computeTopAnchorSlack.d.ts +6 -8
  455. package/dist/primitives/thread/topAnchor/computeTopAnchorSlack.d.ts.map +1 -1
  456. package/dist/primitives/thread/topAnchor/createReserveObservers.d.ts +2 -4
  457. package/dist/primitives/thread/topAnchor/createReserveObservers.d.ts.map +1 -1
  458. package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.d.ts +16 -18
  459. package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.d.ts.map +1 -1
  460. package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js +55 -6
  461. package/dist/primitives/thread/topAnchor/mountTopAnchorReserve.js.map +1 -1
  462. package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts +10 -11
  463. package/dist/primitives/thread/topAnchor/topAnchorTurn.d.ts.map +1 -1
  464. package/dist/primitives/thread/topAnchor/topAnchorUtils.d.ts +0 -2
  465. package/dist/primitives/thread/topAnchor/topAnchorUtils.d.ts.map +1 -1
  466. package/dist/primitives/thread/topAnchor/useTopAnchorReserve.d.ts +0 -2
  467. package/dist/primitives/thread/topAnchor/useTopAnchorReserve.d.ts.map +1 -1
  468. package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts +29 -31
  469. package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
  470. package/dist/primitives/thread/useThreadViewportAutoScroll.js +16 -1
  471. package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
  472. package/dist/primitives/thread.d.ts +12 -15
  473. package/dist/primitives/thread.d.ts.map +1 -1
  474. package/dist/primitives/threadList/ThreadListItems.d.ts +2 -2
  475. package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -0
  476. package/dist/primitives/threadList/ThreadListLoadMore.d.ts +6 -7
  477. package/dist/primitives/threadList/ThreadListLoadMore.d.ts.map +1 -1
  478. package/dist/primitives/threadList/ThreadListNew.d.ts +5 -7
  479. package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -1
  480. package/dist/primitives/threadList/ThreadListNew.js +1 -1
  481. package/dist/primitives/threadList/ThreadListRoot.d.ts +6 -7
  482. package/dist/primitives/threadList/ThreadListRoot.d.ts.map +1 -1
  483. package/dist/primitives/threadList.d.ts +5 -9
  484. package/dist/primitives/threadList.d.ts.map +1 -1
  485. package/dist/primitives/threadListFocusGroup.d.ts +14 -16
  486. package/dist/primitives/threadListFocusGroup.d.ts.map +1 -1
  487. package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +6 -7
  488. package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -1
  489. package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +6 -7
  490. package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -1
  491. package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts +6 -7
  492. package/dist/primitives/threadListItem/ThreadListItemRoot.d.ts.map +1 -1
  493. package/dist/primitives/threadListItem/ThreadListItemRoot.js +2 -1
  494. package/dist/primitives/threadListItem/ThreadListItemRoot.js.map +1 -1
  495. package/dist/primitives/threadListItem/ThreadListItemTitle.d.ts +2 -2
  496. package/dist/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -0
  497. package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts +6 -7
  498. package/dist/primitives/threadListItem/ThreadListItemTrigger.d.ts.map +1 -1
  499. package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +6 -7
  500. package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -1
  501. package/dist/primitives/threadListItem.d.ts +6 -11
  502. package/dist/primitives/threadListItem.d.ts.map +1 -1
  503. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts +10 -12
  504. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.d.ts.map +1 -1
  505. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js +1 -0
  506. package/dist/primitives/threadListItemMore/ThreadListItemMoreContent.js.map +1 -1
  507. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts +7 -9
  508. package/dist/primitives/threadListItemMore/ThreadListItemMoreItem.d.ts.map +1 -1
  509. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts +11 -13
  510. package/dist/primitives/threadListItemMore/ThreadListItemMoreRoot.d.ts.map +1 -1
  511. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts +7 -9
  512. package/dist/primitives/threadListItemMore/ThreadListItemMoreSeparator.d.ts.map +1 -1
  513. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts +7 -9
  514. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.d.ts.map +1 -1
  515. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js +1 -0
  516. package/dist/primitives/threadListItemMore/ThreadListItemMoreTrigger.js.map +1 -1
  517. package/dist/primitives/threadListItemMore/scope.d.ts +4 -6
  518. package/dist/primitives/threadListItemMore/scope.d.ts.map +1 -1
  519. package/dist/primitives/threadListItemMore.d.ts +5 -10
  520. package/dist/primitives/threadListItemMore.d.ts.map +1 -1
  521. package/dist/sandbox-host/SandboxHost.d.ts +24 -26
  522. package/dist/sandbox-host/SandboxHost.d.ts.map +1 -1
  523. package/dist/unstable/useComposerInput.d.ts +32 -34
  524. package/dist/unstable/useComposerInput.d.ts.map +1 -1
  525. package/dist/unstable/useComposerInput.js +1 -1
  526. package/dist/unstable/useComposerInputHistory.d.ts +3 -5
  527. package/dist/unstable/useComposerInputHistory.d.ts.map +1 -1
  528. package/dist/unstable/useComposerInputHistory.js +2 -2
  529. package/dist/unstable/useLiveCompletionAdapter.d.ts +18 -20
  530. package/dist/unstable/useLiveCompletionAdapter.d.ts.map +1 -1
  531. package/dist/unstable/useMentionAdapter.d.ts +57 -59
  532. package/dist/unstable/useMentionAdapter.d.ts.map +1 -1
  533. package/dist/unstable/useMentionAdapter.js +1 -1
  534. package/dist/unstable/useMessageStallDetection.d.ts +10 -12
  535. package/dist/unstable/useMessageStallDetection.d.ts.map +1 -1
  536. package/dist/unstable/useMessageStallDetection.js +1 -1
  537. package/dist/unstable/useModelContextSnapshot.d.ts +13 -15
  538. package/dist/unstable/useModelContextSnapshot.d.ts.map +1 -1
  539. package/dist/unstable/useSlashCommandAdapter.d.ts +20 -22
  540. package/dist/unstable/useSlashCommandAdapter.d.ts.map +1 -1
  541. package/dist/unstable/webmcp/WebMcpRegistrationResource.d.ts +8 -9
  542. package/dist/unstable/webmcp/WebMcpRegistrationResource.d.ts.map +1 -1
  543. package/dist/unstable/webmcp/WebMcpRegistrationResource.js +27 -39
  544. package/dist/unstable/webmcp/WebMcpRegistrationResource.js.map +1 -1
  545. package/dist/unstable/webmcp/convertTools.d.ts +5 -7
  546. package/dist/unstable/webmcp/convertTools.d.ts.map +1 -1
  547. package/dist/unstable/webmcp/convertTools.js +2 -2
  548. package/dist/unstable/webmcp/convertTools.js.map +1 -1
  549. package/dist/unstable/webmcp/useWebMcpProvider.d.ts +4 -6
  550. package/dist/unstable/webmcp/useWebMcpProvider.d.ts.map +1 -1
  551. package/dist/unstable/webmcp/useWebMcpProvider.js +22 -13
  552. package/dist/unstable/webmcp/useWebMcpProvider.js.map +1 -1
  553. package/dist/unstable/webmcp/webmcp-host.d.ts +23 -25
  554. package/dist/unstable/webmcp/webmcp-host.d.ts.map +1 -1
  555. package/dist/utils/Primitive.d.ts +91 -92
  556. package/dist/utils/Primitive.d.ts.map +1 -1
  557. package/dist/utils/RequireAtLeastOne.d.ts +3 -3
  558. package/dist/utils/RequireAtLeastOne.d.ts.map +1 -1
  559. package/dist/utils/createActionButton.d.ts +5 -6
  560. package/dist/utils/createActionButton.d.ts.map +1 -1
  561. package/dist/utils/getSelectionMessageId.d.ts +1 -3
  562. package/dist/utils/getSelectionMessageId.d.ts.map +1 -1
  563. package/dist/utils/getSelectionMessageId.js +2 -1
  564. package/dist/utils/getSelectionMessageId.js.map +1 -1
  565. package/dist/utils/hooks/useManagedRef.d.ts +0 -2
  566. package/dist/utils/hooks/useManagedRef.d.ts.map +1 -1
  567. package/dist/utils/hooks/useMediaQuery.d.ts +0 -2
  568. package/dist/utils/hooks/useMediaQuery.d.ts.map +1 -1
  569. package/dist/utils/hooks/useOnResizeContent.d.ts +0 -2
  570. package/dist/utils/hooks/useOnResizeContent.d.ts.map +1 -1
  571. package/dist/utils/hooks/useOnScrollToBottom.d.ts +1 -3
  572. package/dist/utils/hooks/useOnScrollToBottom.d.ts.map +1 -1
  573. package/dist/utils/hooks/useSizeHandle.d.ts +1 -3
  574. package/dist/utils/hooks/useSizeHandle.d.ts.map +1 -1
  575. package/dist/utils/smooth/SmoothContext.d.ts +105 -107
  576. package/dist/utils/smooth/SmoothContext.d.ts.map +1 -1
  577. package/dist/utils/smooth/SmoothContext.js +1 -1
  578. package/dist/utils/smooth/useSmooth.d.ts +26 -28
  579. package/dist/utils/smooth/useSmooth.d.ts.map +1 -1
  580. package/dist/utils/smooth/useSmooth.js +1 -1
  581. package/package.json +12 -9
  582. package/src/assistant-transport.ts +5 -4
  583. package/src/cloud-renderer/CloudRendererHost.test.tsx +362 -0
  584. package/src/cloud-renderer/CloudRendererHost.tsx +249 -0
  585. package/src/index.ts +29 -1
  586. package/src/primitives/actionBar/ActionBarExportMarkdown.test.tsx +30 -0
  587. package/src/primitives/actionBar/ActionBarExportMarkdown.tsx +4 -0
  588. package/src/primitives/actionBar/ActionBarFeedback.test.tsx +87 -0
  589. package/src/primitives/actionBar/ActionBarFeedbackNegative.tsx +1 -0
  590. package/src/primitives/actionBar/ActionBarFeedbackPositive.tsx +1 -0
  591. package/src/primitives/composer/ComposerAttachmentDropzone.test.tsx +54 -0
  592. package/src/primitives/composer/ComposerAttachmentDropzone.tsx +12 -6
  593. package/src/primitives/composer/ComposerInput.test.tsx +18 -0
  594. package/src/primitives/composer/ComposerInput.tsx +8 -2
  595. package/src/primitives/message/MessageIf.test.tsx +72 -0
  596. package/src/primitives/message/MessageIf.ts +8 -3
  597. package/src/primitives/message/MessagePartsGrouped.test.tsx +151 -4
  598. package/src/primitives/message/MessagePartsGrouped.tool-interaction.test.tsx +97 -0
  599. package/src/primitives/message/MessagePartsGrouped.tsx +14 -5
  600. package/src/primitives/message/MessageRoot.test.tsx +108 -0
  601. package/src/primitives/message/MessageRoot.tsx +5 -1
  602. package/src/primitives/reasoning/useScrollLock.test.tsx +47 -0
  603. package/src/primitives/reasoning/useScrollLock.ts +15 -17
  604. package/src/primitives/selectionToolbar/SelectionToolbarRoot.test.tsx +228 -14
  605. package/src/primitives/selectionToolbar/SelectionToolbarRoot.tsx +60 -12
  606. package/src/primitives/thread/ThreadRoot.test.tsx +130 -0
  607. package/src/primitives/thread/ThreadRoot.tsx +39 -3
  608. package/src/primitives/thread/ThreadRootElementContext.ts +10 -0
  609. package/src/primitives/thread/topAnchor/mountTopAnchorReserve.test.ts +196 -0
  610. package/src/primitives/thread/topAnchor/mountTopAnchorReserve.ts +78 -5
  611. package/src/primitives/thread/useThreadViewportAutoScroll.test.tsx +222 -0
  612. package/src/primitives/thread/useThreadViewportAutoScroll.ts +37 -2
  613. package/src/primitives/threadListItem/ThreadListItemRoot.tsx +2 -0
  614. package/src/primitives/threadListItem/ThreadListKeyboardNav.test.tsx +65 -0
  615. package/src/primitives/threadListItemMore/ThreadListItemMoreContent.tsx +7 -0
  616. package/src/primitives/threadListItemMore/ThreadListItemMoreTrigger.tsx +2 -0
  617. package/src/tests/RemoteThreadListRuntime.reloadMainThread.test.tsx +8 -13
  618. package/src/tests/augmentations.test.ts +7 -0
  619. package/src/tests/remote-thread-list-test-helpers.ts +15 -0
  620. package/src/tests/threadListItemIsRunning.test.tsx +10 -7
  621. package/src/unstable/webmcp/WebMcpRegistrationResource.ts +9 -8
  622. package/src/unstable/webmcp/convertTools.test.ts +23 -3
  623. package/src/unstable/webmcp/convertTools.ts +7 -11
  624. package/src/unstable/webmcp/useWebMcpProvider.test.tsx +36 -2
  625. package/src/unstable/webmcp/useWebMcpProvider.ts +40 -13
  626. package/src/utils/getSelectionMessageId.test.ts +28 -0
  627. package/src/utils/getSelectionMessageId.ts +7 -1
  628. package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -5
  629. package/dist/tests/remote-thread-list-test-helpers.d.ts.map +0 -1
  630. package/dist/tests/remote-thread-list-test-helpers.js +0 -29
  631. package/dist/tests/remote-thread-list-test-helpers.js.map +0 -1
  632. package/dist/tests/setup.d.ts +0 -1
  633. package/dist/tests/setup.js +0 -6
  634. package/dist/tests/setup.js.map +0 -1
@@ -1,23 +1,22 @@
1
- import { AssistantClient } from "@assistant-ui/store";
2
- import { Unsubscribe } from "@assistant-ui/core";
3
- //#region src/unstable/useModelContextSnapshot.d.ts
1
+ import type { AssistantClient } from "@assistant-ui/store";
2
+ import type { Unsubscribe } from "@assistant-ui/core";
4
3
  /**
5
4
  * Where a snapshot comes from and what counts as a change to it. Declared once
6
5
  * per consumer at module scope: the subscription effect keys on this object, so
7
6
  * an inline source without an `isEqual` re-reads itself into a render loop.
8
7
  */
9
8
  export type ModelContextSnapshotSource<T> = {
10
- /** Seeds the snapshot when it starts disabled. */
11
- readonly empty: T;
12
- /** Projects the fields the consumer observes out of the live model context. */
13
- read(aui: AssistantClient): T;
14
- subscribe(aui: AssistantClient, onChange: () => void): Unsubscribe;
15
- /**
16
- * An equal pair keeps the previous reference. Omitted by a consumer that
17
- * re-derives on every notification, where a caller republishing an unchanged
18
- * tool set is how it asks to be re-run.
19
- */
20
- isEqual?(previous: T, next: T): boolean;
9
+ /** Seeds the snapshot when it starts disabled. */
10
+ readonly empty: T;
11
+ /** Projects the fields the consumer observes out of the live model context. */
12
+ read(aui: AssistantClient): T;
13
+ subscribe(aui: AssistantClient, onChange: () => void): Unsubscribe;
14
+ /**
15
+ * An equal pair keeps the previous reference. Omitted by a consumer that
16
+ * re-derives on every notification, where a caller republishing an unchanged
17
+ * tool set is how it asks to be re-run.
18
+ */
19
+ isEqual?(previous: T, next: T): boolean;
21
20
  };
22
21
  /**
23
22
  * `getModelContext()` rebuilds its result on every call, so a projection of the
@@ -29,5 +28,4 @@ export type ModelContextSnapshotSource<T> = {
29
28
  export declare const useModelContextSnapshot: <T>(aui: AssistantClient, enabled: boolean, source: ModelContextSnapshotSource<T>) => T;
30
29
  /** Shallow own-key comparison, for a projection whose values are records. */
31
30
  export declare const shallowEqualRecords: (previous: Readonly<Record<string, unknown>>, next: Readonly<Record<string, unknown>>) => boolean;
32
- //#endregion
33
31
  //# sourceMappingURL=useModelContextSnapshot.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useModelContextSnapshot.d.ts","names":[],"sources":["../../src/unstable/useModelContextSnapshot.ts"],"mappings":";;;;;;;;YAWY,2BAA2B;;WAE5B,OAAO;;EAEhB,KAAK,KAAK,kBAAkB;EAC5B,UAAU,KAAK,iBAAiB,uBAAuB;;;;;;EAMvD,SAAS,UAAU,GAAG,MAAM;;;;;;;;;qBAUjB,0BAA2B,GACtC,KAAK,iBACL,kBACA,QAAQ,2BAA2B,OAClC;;qBAqBU,sBACX,UAAU,SAAS,0BACnB,MAAM,SAAS"}
1
+ {"version":3,"file":"useModelContextSnapshot.d.ts","sourceRoot":"","sources":["../../src/unstable/useModelContextSnapshot.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,MAAM,0BAA0B,CAAC,CAAC,IAAI;IAC1C,kDAAkD;IAClD,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAC;IAClB,+EAA+E;IAC/E,IAAI,CAAC,GAAG,EAAE,eAAe,GAAG,CAAC,CAAC;IAC9B,SAAS,CAAC,GAAG,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;IACnE;;;;OAIG;IACH,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC;CACzC,CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,uBAAuB,GAAI,CAAC,EACvC,KAAK,eAAe,EACpB,SAAS,OAAO,EAChB,QAAQ,0BAA0B,CAAC,CAAC,CAAC,KACpC,CAkBF,CAAC;AAEF,6EAA6E;AAC7E,eAAO,MAAM,mBAAmB,GAC9B,UAAU,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EAC3C,MAAM,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,KACtC,OAMF,CAAC"}
@@ -1,25 +1,24 @@
1
- import { Unstable_IconComponent } from "./useMentionAdapter.js";
2
- import { Unstable_TriggerAdapter, Unstable_TriggerItem } from "@assistant-ui/core";
3
- //#region src/unstable/useSlashCommandAdapter.d.ts
1
+ import type { Unstable_TriggerAdapter, Unstable_TriggerItem } from "@assistant-ui/core";
2
+ import type { Unstable_IconComponent } from "./useMentionAdapter.js";
4
3
  export type Unstable_SlashCommand = {
5
- readonly id: string;
6
- readonly label?: string | undefined;
7
- readonly description?: string | undefined;
8
- readonly icon?: string | undefined;
9
- readonly execute: () => void;
4
+ readonly id: string;
5
+ readonly label?: string | undefined;
6
+ readonly description?: string | undefined;
7
+ readonly icon?: string | undefined;
8
+ readonly execute: () => void;
10
9
  };
11
10
  export type Unstable_UseSlashCommandAdapterOptions = {
12
- readonly commands: readonly Unstable_SlashCommand[];
13
- /** Strip the trigger text from the composer after executing. @default false */
14
- readonly removeOnExecute?: boolean | undefined;
15
- /** Maps `metadata.icon` / `category.id` string keys to React components. */
16
- readonly iconMap?: Record<string, Unstable_IconComponent>;
17
- /** Fallback icon when no entry in `iconMap` matches. */
18
- readonly fallbackIcon?: Unstable_IconComponent;
11
+ readonly commands: readonly Unstable_SlashCommand[];
12
+ /** Strip the trigger text from the composer after executing. @default false */
13
+ readonly removeOnExecute?: boolean | undefined;
14
+ /** Maps `metadata.icon` / `category.id` string keys to React components. */
15
+ readonly iconMap?: Record<string, Unstable_IconComponent>;
16
+ /** Fallback icon when no entry in `iconMap` matches. */
17
+ readonly fallbackIcon?: Unstable_IconComponent;
19
18
  };
20
19
  export type Unstable_SlashCommandAction = {
21
- readonly onExecute: (item: Unstable_TriggerItem) => void;
22
- readonly removeOnExecute?: boolean | undefined;
20
+ readonly onExecute: (item: Unstable_TriggerItem) => void;
21
+ readonly removeOnExecute?: boolean | undefined;
23
22
  };
24
23
  /**
25
24
  * @deprecated Under active development and may change without notice.
@@ -42,10 +41,9 @@ export type Unstable_SlashCommandAction = {
42
41
  * ```
43
42
  */
44
43
  export declare function unstable_useSlashCommandAdapter(options: Unstable_UseSlashCommandAdapterOptions): {
45
- adapter: Unstable_TriggerAdapter;
46
- action: Unstable_SlashCommandAction;
47
- iconMap?: Record<string, Unstable_IconComponent>;
48
- fallbackIcon?: Unstable_IconComponent;
44
+ adapter: Unstable_TriggerAdapter;
45
+ action: Unstable_SlashCommandAction;
46
+ iconMap?: Record<string, Unstable_IconComponent>;
47
+ fallbackIcon?: Unstable_IconComponent;
49
48
  };
50
- //#endregion
51
49
  //# sourceMappingURL=useSlashCommandAdapter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useSlashCommandAdapter.d.ts","names":[],"sources":["../../src/unstable/useSlashCommandAdapter.ts"],"mappings":";;;YAUY;WACD;WACA;WACA;WACA;WACA;;YAGC;WACD,mBAAmB;;WAEnB;;WAEA,UAAU,eAAe;;WAEzB,eAAe;;YAGd;WACD,YAAY,MAAM;WAClB;;;;;;;;;;;;;;;;;;;;;;wBAuBK,gCACd,SAAS;EAET,SAAS;EACT,QAAQ;EACR,UAAU,eAAe;EACzB,eAAe"}
1
+ {"version":3,"file":"useSlashCommandAdapter.d.ts","sourceRoot":"","sources":["../../src/unstable/useSlashCommandAdapter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,uBAAuB,EACvB,oBAAoB,EACrB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,sBAAsB,EAAE,+BAA4B;AAGlE,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1C,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,IAAI,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,sCAAsC,GAAG;IACnD,QAAQ,CAAC,QAAQ,EAAE,SAAS,qBAAqB,EAAE,CAAC;IACpD,+EAA+E;IAC/E,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;IAC/C,4EAA4E;IAC5E,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IAC1D,wDAAwD;IACxD,QAAQ,CAAC,YAAY,CAAC,EAAE,sBAAsB,CAAC;CAChD,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,SAAS,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,CAAC;IACzD,QAAQ,CAAC,eAAe,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,EAAE,sCAAsC,GAC9C;IACD,OAAO,EAAE,uBAAuB,CAAC;IACjC,MAAM,EAAE,2BAA2B,CAAC;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,sBAAsB,CAAC,CAAC;IACjD,YAAY,CAAC,EAAE,sBAAsB,CAAC;CACvC,CAiDA"}
@@ -1,13 +1,12 @@
1
- import { WebMcpHost } from "./webmcp-host.js";
2
- import { Tool } from "assistant-stream";
3
- //#region src/unstable/webmcp/WebMcpRegistrationResource.d.ts
1
+ import type { Tool } from "assistant-stream";
2
+ import type { WebMcpHost } from "./webmcp-host.js";
4
3
  export type WebMcpRegistrationProps = {
5
- host: WebMcpHost;
6
- name: string;
7
- /** Re-registers when it changes; an execute-only edit reads through instead. */
8
- signature: string;
9
- tool: Tool<any, any>;
4
+ host: WebMcpHost;
5
+ name: string;
6
+ /** Re-registers when it changes; an execute-only edit reads through instead. */
7
+ signature: string;
8
+ tool: Tool<any, any>;
9
+ getCurrentTool: (name: string) => Tool<any, any> | undefined;
10
10
  };
11
11
  export declare const WebMcpRegistrationResource: import("@assistant-ui/tap").Resource<string | null, [WebMcpRegistrationProps]>;
12
- //#endregion
13
12
  //# sourceMappingURL=WebMcpRegistrationResource.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"WebMcpRegistrationResource.d.ts","names":[],"sources":["../../../src/unstable/webmcp/WebMcpRegistrationResource.ts"],"mappings":";;;YAMY;EACV,MAAM;EACN;;EAEA;EACA,MAAM;;qBAgFK,wDAA0B,yBAAA"}
1
+ {"version":3,"file":"WebMcpRegistrationResource.d.ts","sourceRoot":"","sources":["../../../src/unstable/webmcp/WebMcpRegistrationResource.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAsB;AAEhD,MAAM,MAAM,uBAAuB,GAAG;IACpC,IAAI,EAAE,UAAU,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrB,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,GAAG,SAAS,CAAC;CAC9D,CAAC;AA+EF,eAAO,MAAM,0BAA0B,gFAAkC,CAAC"}
@@ -6,28 +6,13 @@ import { resource } from "@assistant-ui/tap";
6
6
  const notPermitted = (error) => error?.name === "NotAllowedError";
7
7
  const notPermittedMessage = (name) => `[assistant-ui] WebMCP registration for tool "${name}" was not permitted; the page's tools permission is disabled.`;
8
8
  const useWebMcpRegistration = (t0) => {
9
- const $ = c(12);
10
- const { host, name, signature, tool } = t0;
9
+ const $ = c(11);
10
+ const { host, name, signature, tool, getCurrentTool } = t0;
11
11
  const [refused, setRefused] = useState(false);
12
- const toolRef = useRef(tool);
12
+ const fallbackToolRef = useRef(tool);
13
13
  let t1;
14
- let t2;
15
- if ($[0] !== tool) {
14
+ if ($[0] !== getCurrentTool || $[1] !== host || $[2] !== name || $[3] !== refused) {
16
15
  t1 = () => {
17
- toolRef.current = tool;
18
- };
19
- t2 = [tool];
20
- $[0] = tool;
21
- $[1] = t1;
22
- $[2] = t2;
23
- } else {
24
- t1 = $[1];
25
- t2 = $[2];
26
- }
27
- useEffect(t1, t2);
28
- let t3;
29
- if ($[3] !== host || $[4] !== name || $[5] !== refused) {
30
- t3 = () => {
31
16
  if (refused) return;
32
17
  const lifecycle = new AbortController();
33
18
  let live = true;
@@ -39,9 +24,9 @@ const useWebMcpRegistration = (t0) => {
39
24
  console.warn(message, error);
40
25
  };
41
26
  try {
42
- dispose = host.registerTool(toWebMcpTool(name, () => toolRef.current, lifecycle.signal), (error_1) => refuse(notPermitted(error_1) ? notPermittedMessage(name) : `[assistant-ui] WebMCP registration for tool "${name}" failed (name may already be registered).`, error_1));
43
- } catch (t4) {
44
- const error_0 = t4;
27
+ dispose = host.registerTool(toWebMcpTool(name, () => getCurrentTool(name) ?? fallbackToolRef.current, lifecycle.signal), (error_1) => refuse(notPermitted(error_1) ? notPermittedMessage(name) : `[assistant-ui] WebMCP registration for tool "${name}" failed (name may already be registered).`, error_1));
28
+ } catch (t2) {
29
+ const error_0 = t2;
45
30
  refuse(notPermitted(error_0) ? notPermittedMessage(name) : `[assistant-ui] Skipping WebMCP registration for tool "${name}": registerTool failed (name may already be registered).`, error_0);
46
31
  return;
47
32
  }
@@ -50,32 +35,35 @@ const useWebMcpRegistration = (t0) => {
50
35
  lifecycle.abort();
51
36
  try {
52
37
  dispose();
53
- } catch (t5) {
54
- const error_2 = t5;
38
+ } catch (t3) {
39
+ const error_2 = t3;
55
40
  console.warn(`[assistant-ui] Unregistering WebMCP tool "${name}" failed.`, error_2);
56
41
  }
57
42
  };
58
43
  };
59
- $[3] = host;
60
- $[4] = name;
61
- $[5] = refused;
62
- $[6] = t3;
63
- } else t3 = $[6];
64
- let t4;
65
- if ($[7] !== host || $[8] !== name || $[9] !== refused || $[10] !== signature) {
66
- t4 = [
44
+ $[0] = getCurrentTool;
45
+ $[1] = host;
46
+ $[2] = name;
47
+ $[3] = refused;
48
+ $[4] = t1;
49
+ } else t1 = $[4];
50
+ let t2;
51
+ if ($[5] !== getCurrentTool || $[6] !== host || $[7] !== name || $[8] !== refused || $[9] !== signature) {
52
+ t2 = [
53
+ getCurrentTool,
67
54
  host,
68
55
  name,
69
56
  signature,
70
57
  refused
71
58
  ];
72
- $[7] = host;
73
- $[8] = name;
74
- $[9] = refused;
75
- $[10] = signature;
76
- $[11] = t4;
77
- } else t4 = $[11];
78
- useEffect(t3, t4);
59
+ $[5] = getCurrentTool;
60
+ $[6] = host;
61
+ $[7] = name;
62
+ $[8] = refused;
63
+ $[9] = signature;
64
+ $[10] = t2;
65
+ } else t2 = $[10];
66
+ useEffect(t1, t2);
79
67
  return refused ? null : name;
80
68
  };
81
69
  const WebMcpRegistrationResource = resource(useWebMcpRegistration);
@@ -1 +1 @@
1
- {"version":3,"file":"WebMcpRegistrationResource.js","names":["useEffect","useRef","useState","resource","Tool","toWebMcpTool","WebMcpHost","WebMcpRegistrationProps","host","name","signature","tool","notPermitted","error","notPermittedMessage","useWebMcpRegistration","t0","$","_c","refused","setRefused","toolRef","t1","t2","current","t3","lifecycle","AbortController","live","dispose","refuse","message","console","warn","registerTool","signal","error_1","t4","abort","t5","WebMcpRegistrationResource"],"sources":["../../../src/unstable/webmcp/WebMcpRegistrationResource.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { Tool } from \"assistant-stream\";\nimport { toWebMcpTool } from \"./convertTools\";\nimport type { WebMcpHost } from \"./webmcp-host\";\n\nexport type WebMcpRegistrationProps = {\n host: WebMcpHost;\n name: string;\n /** Re-registers when it changes; an execute-only edit reads through instead. */\n signature: string;\n tool: Tool<any, any>;\n};\n\n// The explainer specifies NotAllowedError for a page whose tools permission is\n// off, which a cross-origin iframe without allow=\"tools\" reaches routinely. It\n// documents no rejection for a name already taken, so that stays a hedge.\nconst notPermitted = (error: unknown) =>\n (error as { name?: unknown } | null | undefined)?.name === \"NotAllowedError\";\n\nconst notPermittedMessage = (name: string) =>\n `[assistant-ui] WebMCP registration for tool \"${name}\" was not permitted; the page's tools permission is disabled.`;\n\nconst useWebMcpRegistration = ({\n host,\n name,\n signature,\n tool,\n}: WebMcpRegistrationProps): string | null => {\n // A refused name is remembered for as long as the tool stays in the model\n // context, so a permanent collision warns once rather than on every sync.\n const [refused, setRefused] = useState(false);\n const toolRef = useRef(tool);\n // Commit phase, so an abandoned render cannot hand the host a tool the tree\n // never committed.\n useEffect(() => {\n toolRef.current = tool;\n }, [tool]);\n\n useEffect(() => {\n if (refused) return undefined;\n\n const lifecycle = new AbortController();\n let live = true;\n let dispose: (() => void) | undefined;\n\n const refuse = (message: string, error: unknown) => {\n if (!live) return;\n live = false;\n setRefused(true);\n console.warn(message, error);\n };\n\n try {\n dispose = host.registerTool(\n toWebMcpTool(name, () => toolRef.current, lifecycle.signal),\n (error) =>\n refuse(\n notPermitted(error)\n ? notPermittedMessage(name)\n : `[assistant-ui] WebMCP registration for tool \"${name}\" failed (name may already be registered).`,\n error,\n ),\n );\n } catch (error) {\n refuse(\n notPermitted(error)\n ? notPermittedMessage(name)\n : `[assistant-ui] Skipping WebMCP registration for tool \"${name}\": registerTool failed (name may already be registered).`,\n error,\n );\n return undefined;\n }\n\n return () => {\n live = false;\n lifecycle.abort();\n try {\n dispose();\n } catch (error) {\n console.warn(\n `[assistant-ui] Unregistering WebMCP tool \"${name}\" failed.`,\n error,\n );\n }\n };\n }, [host, name, signature, refused]);\n\n return refused ? null : name;\n};\n\nexport const W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KAAI,2DACjEI,OACF;IAAC;GAAA;GAEF,aAEM;IACLe,OAAOA;IACPF,UAASY,MAAO;IAChB,IAAA;KACET,QAAQ;IAAC,SAAAU,IAAA;KACF1B,MAAAA,UAAAA;KACPmB,QAAOC,KACL,6CAA6CxB,KAAI,YACjDI,OACF;IAAC;GACF;EACF;EACFI,EAAA,KAAAT;EAAAS,EAAA,KAAAR;EAAAQ,EAAA,KAAAE;EAAAF,EAAA,KAAAQ;CAAA,OAAAA,KAAAR,EAAA;CAAA,IAAAoB;CAAA,IAAApB,EAAA,OAAAT,QAAAS,EAAA,OAAAR,QAAAQ,EAAA,OAAAE,WAAAF,EAAA,QAAAP,WAAA;EAAE2B,KAAA;GAAC7B;GAAMC;GAAMC;GAAWS;EAAO;EAACF,EAAA,KAAAT;EAAAS,EAAA,KAAAR;EAAAQ,EAAA,KAAAE;EAAAF,EAAA,MAAAP;EAAAO,EAAA,MAAAoB;CAAA,OAAAA,KAAApB,EAAA;CA/CnCjB,UAAUyB,IA+CPY,EAAgC;CAAC,OAE7BlB,UAAA,OAAAV;AAAqB;AAG9B,MAAa+B,6BAA6BrC,SAASY,qBAAqB"}
1
+ {"version":3,"file":"WebMcpRegistrationResource.js","names":["useEffect","useRef","useState","resource","Tool","toWebMcpTool","WebMcpHost","WebMcpRegistrationProps","host","name","signature","tool","getCurrentTool","notPermitted","error","notPermittedMessage","useWebMcpRegistration","t0","$","_c","refused","setRefused","fallbackToolRef","t1","lifecycle","AbortController","live","dispose","refuse","message","console","warn","registerTool","current","signal","error_1","t2","abort","t3","WebMcpRegistrationResource"],"sources":["../../../src/unstable/webmcp/WebMcpRegistrationResource.ts"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport { resource } from \"@assistant-ui/tap\";\nimport type { Tool } from \"assistant-stream\";\nimport { toWebMcpTool } from \"./convertTools\";\nimport type { WebMcpHost } from \"./webmcp-host\";\n\nexport type WebMcpRegistrationProps = {\n host: WebMcpHost;\n name: string;\n /** Re-registers when it changes; an execute-only edit reads through instead. */\n signature: string;\n tool: Tool<any, any>;\n getCurrentTool: (name: string) => Tool<any, any> | undefined;\n};\n\n// The explainer specifies NotAllowedError for a page whose tools permission is\n// off, which a cross-origin iframe without allow=\"tools\" reaches routinely. It\n// documents no rejection for a name already taken, so that stays a hedge.\nconst notPermitted = (error: unknown) =>\n (error as { name?: unknown } | null | undefined)?.name === \"NotAllowedError\";\n\nconst notPermittedMessage = (name: string) =>\n `[assistant-ui] WebMCP registration for tool \"${name}\" was not permitted; the page's tools permission is disabled.`;\n\nconst useWebMcpRegistration = ({\n host,\n name,\n signature,\n tool,\n getCurrentTool,\n}: WebMcpRegistrationProps): string | null => {\n // A refused name is remembered for as long as the tool stays in the model\n // context, so a permanent collision warns once rather than on every sync.\n const [refused, setRefused] = useState(false);\n const fallbackToolRef = useRef(tool);\n\n useEffect(() => {\n if (refused) return undefined;\n\n const lifecycle = new AbortController();\n let live = true;\n let dispose: (() => void) | undefined;\n\n const refuse = (message: string, error: unknown) => {\n if (!live) return;\n live = false;\n setRefused(true);\n console.warn(message, error);\n };\n\n try {\n dispose = host.registerTool(\n toWebMcpTool(\n name,\n () => getCurrentTool(name) ?? fallbackToolRef.current,\n lifecycle.signal,\n ),\n (error) =>\n refuse(\n notPermitted(error)\n ? notPermittedMessage(name)\n : `[assistant-ui] WebMCP registration for tool \"${name}\" failed (name may already be registered).`,\n error,\n ),\n );\n } catch (error) {\n refuse(\n notPermitted(error)\n ? notPermittedMessage(name)\n : `[assistant-ui] Skipping WebMCP registration for tool \"${name}\": registerTool failed (name may already be registered).`,\n error,\n );\n return undefined;\n }\n\n return () => {\n live = false;\n lifecycle.abort();\n try {\n dispose();\n } catch (error) {\n console.warn(\n `[assistant-ui] Unregistering WebMCP tool \"${name}\" failed.`,\n error,\n );\n }\n };\n }, [getCurrentTool, host, name, signature, refused]);\n\n return refused ? null : name;\n};\n\nexport const WebMcpRegistrationResource = resource(useWebMcpRegistration);\n"],"mappings":";;;;;AAkBA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;EAAAF,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,IAAAkB;CAAA,IAAAlB,EAAA,OAAAN,kBAAAM,EAAA,OAAAV,QAAAU,EAAA,OAAAT,QAAAS,EAAA,OAAAE,WAAAF,EAAA,OAAAR,WAAA;EAAE0B,KAAA;GAACxB;GAAgBJ;GAAMC;GAAMC;GAAWU;EAAO;EAACF,EAAA,KAAAN;EAAAM,EAAA,KAAAV;EAAAU,EAAA,KAAAT;EAAAS,EAAA,KAAAE;EAAAF,EAAA,KAAAR;EAAAQ,EAAA,MAAAkB;CAAA,OAAAA,KAAAlB,EAAA;CAnDnDlB,UAAUuB,IAmDPa,EAAgD;CAAC,OAE7ChB,UAAA,OAAAX;AAAqB;AAG9B,MAAa8B,6BAA6BpC,SAASa,qBAAqB"}
@@ -1,6 +1,5 @@
1
- import { WebMcpCallToolResult, WebMcpToolDescriptor } from "./webmcp-host.js";
2
- import { Tool } from "assistant-stream";
3
- //#region src/unstable/webmcp/convertTools.d.ts
1
+ import { type Tool } from "assistant-stream";
2
+ import type { WebMcpCallToolResult, WebMcpToolDescriptor } from "./webmcp-host.js";
4
3
  /**
5
4
  * The predicate the WebMCP provider uses when no `filter` is passed: an enabled
6
5
  * frontend tool with a client-side `execute`. A tool authored without a `type`
@@ -11,10 +10,9 @@ import { Tool } from "assistant-stream";
11
10
  export declare const defaultWebMcpFilter: (_name: string, tool: Tool<any, any>) => boolean;
12
11
  export declare const toWebMcpInputSchema: (tool: Tool<any, any>) => unknown;
13
12
  export declare const toMcpContent: (result: unknown, options: {
14
- tool: Tool<any, any>;
15
- toolCallId: string;
16
- args: Record<string, unknown>;
13
+ tool: Tool<any, any>;
14
+ toolCallId: string;
15
+ args: Record<string, unknown>;
17
16
  }) => Promise<WebMcpCallToolResult>;
18
17
  export declare const toWebMcpTool: (name: string, getTool: () => Tool<any, any>, lifecycleSignal?: AbortSignal) => WebMcpToolDescriptor;
19
- //#endregion
20
18
  //# sourceMappingURL=convertTools.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"convertTools.d.ts","names":[],"sources":["../../../src/unstable/webmcp/convertTools.ts"],"mappings":";;;;;;;;;;qBAoBa,sBACX,eACA,MAAM;qBAMK,sBAAuB,MAAM;qBA2C7B,eACX,iBACA;EACE,MAAM;EACN;EACA,MAAM;MAEP,QAAQ;qBAwGE,eACX,cACA,eAAe,gBACf,kBAAkB,gBACjB"}
1
+ {"version":3,"file":"convertTools.d.ts","sourceRoot":"","sources":["../../../src/unstable/webmcp/convertTools.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,EAEV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EACV,oBAAoB,EAEpB,oBAAoB,EACrB,yBAAsB;AAEvB;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,GAC9B,OAAO,MAAM,EACb,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,KACnB,OAGa,CAAC;AAEjB,eAAO,MAAM,mBAAmB,GAAI,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,KAAG,OAGnB,CAAC;AAwCzC,eAAO,MAAM,YAAY,GACvB,QAAQ,OAAO,EACf,SAAS;IACP,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B,KACA,OAAO,CAAC,oBAAoB,CAuB9B,CAAC;AA2EF,eAAO,MAAM,YAAY,GACvB,MAAM,MAAM,EACZ,SAAS,MAAM,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,EAC7B,kBAAkB,WAAW,KAC5B,oBA2ED,CAAC"}
@@ -112,7 +112,7 @@ const toWebMcpTool = (name, getTool, lifecycleSignal) => ({
112
112
  execute: async (rawArgs, context) => {
113
113
  if (lifecycleSignal?.aborted) return errorResult(`Tool "${name}" is no longer registered`);
114
114
  const tool = getTool();
115
- const args = rawArgs ?? {};
115
+ let args = rawArgs ?? {};
116
116
  const toolCallId = generateId();
117
117
  let cleanup;
118
118
  try {
@@ -134,7 +134,7 @@ const toWebMcpTool = (name, getTool, lifecycleSignal) => ({
134
134
  executeFn = tool.experimental_onSchemaValidationError ?? (() => {
135
135
  throw new Error(`Function parameter validation failed. ${JSON.stringify(issues)}`);
136
136
  });
137
- }
137
+ } else args = validation.value;
138
138
  }
139
139
  if (abortSignal?.aborted) return errorResult("Tool execution was cancelled.");
140
140
  if (!executeFn) return errorResult(`Tool "${name}" has no client-side implementation.`);
@@ -1 +1 @@
1
- {"version":3,"file":"convertTools.js","names":["ToolResponse","toJSONSchema","Tool","ToolModelContentPart","generateId","WebMcpCallToolResult","WebMcpContent","WebMcpToolDescriptor","defaultWebMcpFilter","_name","tool","type","undefined","execute","disabled","toWebMcpInputSchema","parameters","properties","textContent","text","errorResult","message","isError","content","toText","value","toString","JSON","stringify","String","primitiveContent","mapModelContentPart","part","mediaType","startsWith","data","mimeType","toMcpContent","result","options","toolCallId","args","Record","Promise","response","toResponse","modelContent","map","toModelOutput","parts","input","output","e","console","warn","StandardSchemaLike","version","validate","issues","isStandardSchema","schema","TOOL_ABORTED","Symbol","isThenable","T","PromiseLike","then","raceWithAbort","abortSignal","AbortSignal","onAbort","abortPromise","resolve","aborted","addEventListener","once","race","removeEventListener","combineAbortSignals","callerSignal","lifecycleSignal","signal","cleanup","controller","AbortController","teardown","length","pop","abort","reason","listen","push","toWebMcpTool","name","getTool","description","inputSchema","rawArgs","context","combined","executeFn","validation","experimental_onSchemaValidationError","Error","human","reject"],"sources":["../../../src/unstable/webmcp/convertTools.ts"],"sourcesContent":["import {\n ToolResponse,\n toJSONSchema,\n type Tool,\n type ToolModelContentPart,\n} from \"assistant-stream\";\nimport { generateId } from \"@assistant-ui/core/internal\";\nimport type {\n WebMcpCallToolResult,\n WebMcpContent,\n WebMcpToolDescriptor,\n} from \"./webmcp-host\";\n\n/**\n * The predicate the WebMCP provider uses when no `filter` is passed: an enabled\n * frontend tool with a client-side `execute`. A tool authored without a `type`\n * is included, because `execute` is what distinguishes the deprecated\n * type-less form from a backend or human tool. A `filter` replaces this, so\n * pass it through to narrow the default set rather than widen it.\n */\nexport const defaultWebMcpFilter = (\n _name: string,\n tool: Tool<any, any>,\n): boolean =>\n (tool.type === \"frontend\" || tool.type === undefined) &&\n !!tool.execute &&\n !tool.disabled;\n\nexport const toWebMcpInputSchema = (tool: Tool<any, any>): unknown =>\n tool.parameters\n ? toJSONSchema(tool.parameters)\n : { type: \"object\", properties: {} };\n\nconst textContent = (text: string): WebMcpContent => ({ type: \"text\", text });\n\nconst errorResult = (message: string): WebMcpCallToolResult => ({\n isError: true,\n content: [textContent(message)],\n});\n\n// bigint throws in JSON.stringify and symbol serializes to undefined, but both\n// have a faithful string form. A value that cannot be serialized at all still\n// throws through to the error result.\nconst toText = (value: unknown): string => {\n if (typeof value === \"string\") return value;\n if (typeof value === \"bigint\" || typeof value === \"symbol\") {\n return value.toString();\n }\n return JSON.stringify(value) ?? String(value);\n};\n\nconst primitiveContent = (value: unknown): WebMcpContent[] => [\n textContent(toText(value)),\n];\n\nconst mapModelContentPart = (part: ToolModelContentPart): WebMcpContent => {\n if (part.type === \"text\") {\n return textContent(part.text ?? \"\");\n }\n if (part.type === \"file\") {\n if (\n typeof part.mediaType === \"string\" &&\n part.mediaType.startsWith(\"image/\")\n ) {\n return { type: \"image\", data: part.data ?? \"\", mimeType: part.mediaType };\n }\n return textContent(part.data ?? \"\");\n }\n return textContent(toText(part));\n};\n\nexport const toMcpContent = async (\n result: unknown,\n options: {\n tool: Tool<any, any>;\n toolCallId: string;\n args: Record<string, unknown>;\n },\n): Promise<WebMcpCallToolResult> => {\n const response = ToolResponse.toResponse(result);\n if (response.modelContent) {\n const content = response.modelContent.map(mapModelContentPart);\n return response.isError ? { isError: true, content } : { content };\n }\n if (!response.isError && options.tool.toModelOutput) {\n try {\n const parts = await options.tool.toModelOutput({\n toolCallId: options.toolCallId,\n input: options.args,\n output: response.result,\n });\n return { content: parts.map(mapModelContentPart) };\n } catch (e) {\n console.warn(\n \"[assistant-ui] toModelOutput threw; falling back to default projection.\",\n e,\n );\n }\n }\n const content = primitiveContent(response.result);\n return response.isError ? { isError: true, content } : { content };\n};\n\ntype StandardSchemaLike = {\n \"~standard\": {\n version: number;\n validate: (\n value: unknown,\n ) =>\n | { issues?: readonly unknown[] | undefined }\n | Promise<{ issues?: readonly unknown[] | undefined }>;\n };\n};\n\nconst isStandardSchema = (schema: unknown): schema is StandardSchemaLike =>\n typeof schema === \"object\" &&\n schema !== null &&\n \"~standard\" in schema &&\n (schema as StandardSchemaLike)[\"~standard\"].version === 1;\n\nconst TOOL_ABORTED = Symbol(\"assistant-ui.webmcp-tool-aborted\");\n\nconst isThenable = <T>(value: T | PromiseLike<T>): value is PromiseLike<T> =>\n typeof (value as PromiseLike<T> | null | undefined)?.then === \"function\";\n\nconst raceWithAbort = async <T>(\n value: PromiseLike<T>,\n abortSignal: AbortSignal,\n): Promise<T | typeof TOOL_ABORTED> => {\n let onAbort!: () => void;\n const abortPromise = new Promise<typeof TOOL_ABORTED>((resolve) => {\n onAbort = () => resolve(TOOL_ABORTED);\n if (abortSignal.aborted) {\n onAbort();\n } else {\n abortSignal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n\n try {\n // Unlike assistant-stream's helper, cancellation wins when validation aborts and rejects synchronously.\n return await Promise.race([abortPromise, value]);\n } finally {\n abortSignal.removeEventListener(\"abort\", onAbort);\n }\n};\n\n// AbortSignal.any sits above the browserslist floor and rejects any input that\n// is not a native AbortSignal, which a navigator.modelContext polyfill's signal\n// is not. The merged signal tracks its inputs only until cleanup runs, where\n// the single-signal path hands the caller the lifecycle signal itself.\nconst combineAbortSignals = (\n callerSignal: AbortSignal,\n lifecycleSignal: AbortSignal,\n): { signal: AbortSignal; cleanup: () => void } => {\n const controller = new AbortController();\n const teardown: (() => void)[] = [];\n const cleanup = () => {\n while (teardown.length) teardown.pop()!();\n };\n const abort = (reason: unknown) => {\n cleanup();\n controller.abort(reason);\n };\n const listen = (signal: AbortSignal) => {\n const onAbort = () => abort(signal.reason);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n teardown.push(() => signal.removeEventListener(\"abort\", onAbort));\n };\n\n if (callerSignal.aborted) {\n abort(callerSignal.reason);\n } else if (lifecycleSignal.aborted) {\n abort(lifecycleSignal.reason);\n } else {\n listen(callerSignal);\n listen(lifecycleSignal);\n }\n\n return { signal: controller.signal, cleanup };\n};\n\nexport const toWebMcpTool = (\n name: string,\n getTool: () => Tool<any, any>,\n lifecycleSignal?: AbortSignal,\n): WebMcpToolDescriptor => ({\n name,\n description: getTool().description ?? \"\",\n inputSchema: toWebMcpInputSchema(getTool()),\n execute: async (rawArgs, context) => {\n if (lifecycleSignal?.aborted) {\n return errorResult(`Tool \"${name}\" is no longer registered`);\n }\n const tool = getTool();\n const args = (rawArgs ?? {}) as Record<string, unknown>;\n const toolCallId = generateId();\n let cleanup: (() => void) | undefined;\n try {\n const callerSignal = context?.signal;\n let abortSignal: AbortSignal | undefined;\n if (callerSignal && lifecycleSignal) {\n const combined = combineAbortSignals(callerSignal, lifecycleSignal);\n abortSignal = combined.signal;\n cleanup = combined.cleanup;\n } else {\n abortSignal = callerSignal ?? lifecycleSignal;\n }\n\n if (abortSignal?.aborted) {\n return errorResult(\"Tool execution was cancelled.\");\n }\n\n let executeFn = tool.execute;\n if (isStandardSchema(tool.parameters)) {\n const result = tool.parameters[\"~standard\"].validate(args);\n const validation = isThenable(result)\n ? abortSignal\n ? await raceWithAbort(result, abortSignal)\n : await result\n : result;\n if (validation === TOOL_ABORTED) {\n return errorResult(\"Tool execution was cancelled.\");\n }\n if (validation.issues) {\n const issues = validation.issues;\n executeFn =\n tool.experimental_onSchemaValidationError ??\n (() => {\n throw new Error(\n `Function parameter validation failed. ${JSON.stringify(issues)}`,\n );\n });\n }\n }\n\n if (abortSignal?.aborted) {\n return errorResult(\"Tool execution was cancelled.\");\n }\n\n if (!executeFn) {\n return errorResult(`Tool \"${name}\" has no client-side implementation.`);\n }\n\n const result = await executeFn(args, {\n toolCallId,\n abortSignal: abortSignal ?? new AbortController().signal,\n human: () =>\n Promise.reject(\n new Error(\"human input not supported in WebMCP context\"),\n ),\n });\n return await toMcpContent(result, { tool, toolCallId, args });\n } catch (e) {\n return errorResult(e instanceof Error ? e.message : String(e));\n } finally {\n cleanup?.();\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAoBA,MAAaQ,uBACXC,OACAC,UAECA,KAAKC,SAAS,cAAcD,KAAKC,SAASC,KAAAA,MAC3C,CAAC,CAACF,KAAKG,WACP,CAACH,KAAKI;AAER,MAAaC,uBAAuBL,SAClCA,KAAKM,aACDf,aAAaS,KAAKM,UAAU,IAC5B;CAAEL,MAAM;CAAUM,YAAY,CAAC;AAAE;AAEvC,MAAMC,eAAeC,UAAiC;CAAER,MAAM;CAAQQ;AAAK;AAE3E,MAAMC,eAAeC,aAA2C;CAC9DC,SAAS;CACTC,SAAS,CAACL,YAAYG,OAAO,CAAC;AAChC;AAKA,MAAMG,UAAUC,UAA2B;CACzC,IAAI,OAAOA,UAAU,UAAU,OAAOA;CACtC,IAAI,OAAOA,UAAU,YAAY,OAAOA,UAAU,UAChD,OAAOA,MAAMC,SAAS;CAExB,OAAOC,KAAKC,UAAUH,KAAK,KAAKI,OAAOJ,KAAK;AAC9C;AAEA,MAAMK,oBAAoBL,UAAoC,CAC5DP,YAAYM,OAAOC,KAAK,CAAC,CAAC;AAG5B,MAAMM,uBAAuBC,SAA8C;CACzE,IAAIA,KAAKrB,SAAS,QAChB,OAAOO,YAAYc,KAAKb,QAAQ,EAAE;CAEpC,IAAIa,KAAKrB,SAAS,QAAQ;EACxB,IACE,OAAOqB,KAAKC,cAAc,YAC1BD,KAAKC,UAAUC,WAAW,QAAQ,GAElC,OAAO;GAAEvB,MAAM;GAASwB,MAAMH,KAAKG,QAAQ;GAAIC,UAAUJ,KAAK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;IACvBC,UAAUiB,SAASjB;GACrB,OACEd,cAAcW,gBAAgBC;GAGhC,IAAIZ,aAAaK,SACf,OAAOrD,YAAY,+BAA+B;GAGpD,IAAIgF,YAAY1F,KAAKG;GACrB,IAAI8C,iBAAiBjD,KAAKM,UAAU,GAAG;IACrC,MAAMsB,SAAS5B,KAAKM,WAAW,YAAY,CAACyC,SAAShB,IAAI;IACzD,MAAM4D,aAAatC,WAAWzB,MAAM,IAChC8B,cACE,MAAMD,cAAc7B,QAAQ8B,WAAW,IACvC,MAAM9B,SACRA;IACJ,IAAI+D,eAAexC,cACjB,OAAOzC,YAAY,+BAA+B;IAEpD,IAAIiF,WAAW3C,QAAQ;KACrB,MAAMA,SAAS2C,WAAW3C;KAC1B0C,YACE1F,KAAK4F,+CACE;MACL,MAAM,IAAIC,MACR,yCAAyC5E,KAAKC,UAAU8B,MAAM,GAChE;KACF;IACJ;GACF;GAEA,IAAIU,aAAaK,SACf,OAAOrD,YAAY,+BAA+B;GAGpD,IAAI,CAACgF,WACH,OAAOhF,YAAY,SAASyE,KAAI,qCAAsC;GAGxE,MAAMvD,SAAS,MAAM8D,UAAU3D,MAAM;IACnCD;IACA4B,aAAaA,eAAe,IAAIgB,gBAAgB,CAAC,CAACH;IAClDuB,aACE7D,QAAQ8D,uBACN,IAAIF,MAAM,6CAA6C,CACzD;GACJ,CAAC;GACD,OAAO,MAAMlE,aAAaC,QAAQ;IAAE5B;IAAM8B;IAAYC;GAAK,CAAC;EAC9D,SAASW,GAAG;GACV,OAAOhC,YAAYgC,aAAamD,QAAQnD,EAAE/B,UAAUQ,OAAOuB,CAAC,CAAC;EAC/D,UAAU;GACR8B,UAAU;EACZ;CACF;AACF"}
1
+ {"version":3,"file":"convertTools.js","names":["ToolResponse","toJSONSchema","Tool","ToolModelContentPart","generateId","WebMcpCallToolResult","WebMcpContent","WebMcpToolDescriptor","defaultWebMcpFilter","_name","tool","type","undefined","execute","disabled","toWebMcpInputSchema","parameters","properties","textContent","text","errorResult","message","isError","content","toText","value","toString","JSON","stringify","String","primitiveContent","mapModelContentPart","part","mediaType","startsWith","data","mimeType","toMcpContent","result","options","toolCallId","args","Record","Promise","response","toResponse","modelContent","map","toModelOutput","parts","input","output","e","console","warn","StandardSchemaLike","Extract","NonNullable","isStandardSchema","schema","version","TOOL_ABORTED","Symbol","isThenable","T","PromiseLike","then","raceWithAbort","abortSignal","AbortSignal","onAbort","abortPromise","resolve","aborted","addEventListener","once","race","removeEventListener","combineAbortSignals","callerSignal","lifecycleSignal","signal","cleanup","controller","AbortController","teardown","length","pop","abort","reason","listen","push","toWebMcpTool","name","getTool","description","inputSchema","rawArgs","context","combined","executeFn","validate","validation","issues","experimental_onSchemaValidationError","Error","human","reject"],"sources":["../../../src/unstable/webmcp/convertTools.ts"],"sourcesContent":["import {\n ToolResponse,\n toJSONSchema,\n type Tool,\n type ToolModelContentPart,\n} from \"assistant-stream\";\nimport { generateId } from \"@assistant-ui/core/internal\";\nimport type {\n WebMcpCallToolResult,\n WebMcpContent,\n WebMcpToolDescriptor,\n} from \"./webmcp-host\";\n\n/**\n * The predicate the WebMCP provider uses when no `filter` is passed: an enabled\n * frontend tool with a client-side `execute`. A tool authored without a `type`\n * is included, because `execute` is what distinguishes the deprecated\n * type-less form from a backend or human tool. A `filter` replaces this, so\n * pass it through to narrow the default set rather than widen it.\n */\nexport const defaultWebMcpFilter = (\n _name: string,\n tool: Tool<any, any>,\n): boolean =>\n (tool.type === \"frontend\" || tool.type === undefined) &&\n !!tool.execute &&\n !tool.disabled;\n\nexport const toWebMcpInputSchema = (tool: Tool<any, any>): unknown =>\n tool.parameters\n ? toJSONSchema(tool.parameters)\n : { type: \"object\", properties: {} };\n\nconst textContent = (text: string): WebMcpContent => ({ type: \"text\", text });\n\nconst errorResult = (message: string): WebMcpCallToolResult => ({\n isError: true,\n content: [textContent(message)],\n});\n\n// bigint throws in JSON.stringify and symbol serializes to undefined, but both\n// have a faithful string form. A value that cannot be serialized at all still\n// throws through to the error result.\nconst toText = (value: unknown): string => {\n if (typeof value === \"string\") return value;\n if (typeof value === \"bigint\" || typeof value === \"symbol\") {\n return value.toString();\n }\n return JSON.stringify(value) ?? String(value);\n};\n\nconst primitiveContent = (value: unknown): WebMcpContent[] => [\n textContent(toText(value)),\n];\n\nconst mapModelContentPart = (part: ToolModelContentPart): WebMcpContent => {\n if (part.type === \"text\") {\n return textContent(part.text ?? \"\");\n }\n if (part.type === \"file\") {\n if (\n typeof part.mediaType === \"string\" &&\n part.mediaType.startsWith(\"image/\")\n ) {\n return { type: \"image\", data: part.data ?? \"\", mimeType: part.mediaType };\n }\n return textContent(part.data ?? \"\");\n }\n return textContent(toText(part));\n};\n\nexport const toMcpContent = async (\n result: unknown,\n options: {\n tool: Tool<any, any>;\n toolCallId: string;\n args: Record<string, unknown>;\n },\n): Promise<WebMcpCallToolResult> => {\n const response = ToolResponse.toResponse(result);\n if (response.modelContent) {\n const content = response.modelContent.map(mapModelContentPart);\n return response.isError ? { isError: true, content } : { content };\n }\n if (!response.isError && options.tool.toModelOutput) {\n try {\n const parts = await options.tool.toModelOutput({\n toolCallId: options.toolCallId,\n input: options.args,\n output: response.result,\n });\n return { content: parts.map(mapModelContentPart) };\n } catch (e) {\n console.warn(\n \"[assistant-ui] toModelOutput threw; falling back to default projection.\",\n e,\n );\n }\n }\n const content = primitiveContent(response.result);\n return response.isError ? { isError: true, content } : { content };\n};\n\ntype StandardSchemaLike = Extract<\n NonNullable<Tool[\"parameters\"]>,\n { readonly \"~standard\": unknown }\n>;\n\nconst isStandardSchema = (schema: unknown): schema is StandardSchemaLike =>\n typeof schema === \"object\" &&\n schema !== null &&\n \"~standard\" in schema &&\n (schema as StandardSchemaLike)[\"~standard\"].version === 1;\n\nconst TOOL_ABORTED = Symbol(\"assistant-ui.webmcp-tool-aborted\");\n\nconst isThenable = <T>(value: T | PromiseLike<T>): value is PromiseLike<T> =>\n typeof (value as PromiseLike<T> | null | undefined)?.then === \"function\";\n\nconst raceWithAbort = async <T>(\n value: PromiseLike<T>,\n abortSignal: AbortSignal,\n): Promise<T | typeof TOOL_ABORTED> => {\n let onAbort!: () => void;\n const abortPromise = new Promise<typeof TOOL_ABORTED>((resolve) => {\n onAbort = () => resolve(TOOL_ABORTED);\n if (abortSignal.aborted) {\n onAbort();\n } else {\n abortSignal.addEventListener(\"abort\", onAbort, { once: true });\n }\n });\n\n try {\n // Unlike assistant-stream's helper, cancellation wins when validation aborts and rejects synchronously.\n return await Promise.race([abortPromise, value]);\n } finally {\n abortSignal.removeEventListener(\"abort\", onAbort);\n }\n};\n\n// AbortSignal.any sits above the browserslist floor and rejects any input that\n// is not a native AbortSignal, which a navigator.modelContext polyfill's signal\n// is not. The merged signal tracks its inputs only until cleanup runs, where\n// the single-signal path hands the caller the lifecycle signal itself.\nconst combineAbortSignals = (\n callerSignal: AbortSignal,\n lifecycleSignal: AbortSignal,\n): { signal: AbortSignal; cleanup: () => void } => {\n const controller = new AbortController();\n const teardown: (() => void)[] = [];\n const cleanup = () => {\n while (teardown.length) teardown.pop()!();\n };\n const abort = (reason: unknown) => {\n cleanup();\n controller.abort(reason);\n };\n const listen = (signal: AbortSignal) => {\n const onAbort = () => abort(signal.reason);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n teardown.push(() => signal.removeEventListener(\"abort\", onAbort));\n };\n\n if (callerSignal.aborted) {\n abort(callerSignal.reason);\n } else if (lifecycleSignal.aborted) {\n abort(lifecycleSignal.reason);\n } else {\n listen(callerSignal);\n listen(lifecycleSignal);\n }\n\n return { signal: controller.signal, cleanup };\n};\n\nexport const toWebMcpTool = (\n name: string,\n getTool: () => Tool<any, any>,\n lifecycleSignal?: AbortSignal,\n): WebMcpToolDescriptor => ({\n name,\n description: getTool().description ?? \"\",\n inputSchema: toWebMcpInputSchema(getTool()),\n execute: async (rawArgs, context) => {\n if (lifecycleSignal?.aborted) {\n return errorResult(`Tool \"${name}\" is no longer registered`);\n }\n const tool = getTool();\n let args = (rawArgs ?? {}) as Record<string, unknown>;\n const toolCallId = generateId();\n let cleanup: (() => void) | undefined;\n try {\n const callerSignal = context?.signal;\n let abortSignal: AbortSignal | undefined;\n if (callerSignal && lifecycleSignal) {\n const combined = combineAbortSignals(callerSignal, lifecycleSignal);\n abortSignal = combined.signal;\n cleanup = combined.cleanup;\n } else {\n abortSignal = callerSignal ?? lifecycleSignal;\n }\n\n if (abortSignal?.aborted) {\n return errorResult(\"Tool execution was cancelled.\");\n }\n\n let executeFn = tool.execute;\n if (isStandardSchema(tool.parameters)) {\n const result = tool.parameters[\"~standard\"].validate(args);\n const validation = isThenable(result)\n ? abortSignal\n ? await raceWithAbort(result, abortSignal)\n : await result\n : result;\n if (validation === TOOL_ABORTED) {\n return errorResult(\"Tool execution was cancelled.\");\n }\n if (validation.issues) {\n const issues = validation.issues;\n executeFn =\n tool.experimental_onSchemaValidationError ??\n (() => {\n throw new Error(\n `Function parameter validation failed. ${JSON.stringify(issues)}`,\n );\n });\n } else {\n args = validation.value;\n }\n }\n\n if (abortSignal?.aborted) {\n return errorResult(\"Tool execution was cancelled.\");\n }\n\n if (!executeFn) {\n return errorResult(`Tool \"${name}\" has no client-side implementation.`);\n }\n\n const result = await executeFn(args, {\n toolCallId,\n abortSignal: abortSignal ?? new AbortController().signal,\n human: () =>\n Promise.reject(\n new Error(\"human input not supported in WebMCP context\"),\n ),\n });\n return await toMcpContent(result, { tool, toolCallId, args });\n } catch (e) {\n return errorResult(e instanceof Error ? e.message : String(e));\n } finally {\n cleanup?.();\n }\n },\n});\n"],"mappings":";;;;;;;;;;AAoBA,MAAaQ,uBACXC,OACAC,UAECA,KAAKC,SAAS,cAAcD,KAAKC,SAASC,KAAAA,MAC3C,CAAC,CAACF,KAAKG,WACP,CAACH,KAAKI;AAER,MAAaC,uBAAuBL,SAClCA,KAAKM,aACDf,aAAaS,KAAKM,UAAU,IAC5B;CAAEL,MAAM;CAAUM,YAAY,CAAC;AAAE;AAEvC,MAAMC,eAAeC,UAAiC;CAAER,MAAM;CAAQQ;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IAAI2C,aAAaK,SACf,OAAOrD,YAAY,+BAA+B;GAGpD,IAAI,CAACgF,WACH,OAAOhF,YAAY,SAASyE,KAAI,qCAAsC;GAGxE,MAAMvD,SAAS,MAAM8D,UAAU3D,MAAM;IACnCD;IACA4B,aAAaA,eAAe,IAAIgB,gBAAgB,CAAC,CAACH;IAClDyB,aACE/D,QAAQgE,uBACN,IAAIF,MAAM,6CAA6C,CACzD;GACJ,CAAC;GACD,OAAO,MAAMpE,aAAaC,QAAQ;IAAE5B;IAAM8B;IAAYC;GAAK,CAAC;EAC9D,SAASW,GAAG;GACV,OAAOhC,YAAYgC,aAAaqD,QAAQrD,EAAE/B,UAAUQ,OAAOuB,CAAC,CAAC;EAC/D,UAAU;GACR8B,UAAU;EACZ;CACF;AACF"}
@@ -1,11 +1,10 @@
1
- import { Tool } from "assistant-stream";
2
- //#region src/unstable/webmcp/useWebMcpProvider.d.ts
1
+ import type { Tool } from "assistant-stream";
3
2
  export type Unstable_WebMcpProviderOptions = {
4
- filter?: (name: string, tool: Tool<any, any>) => boolean;
3
+ filter?: (name: string, tool: Tool<any, any>) => boolean;
5
4
  };
6
5
  export type Unstable_WebMcpProviderResult = {
7
- status: "unsupported" | "active";
8
- registeredToolNames: readonly string[];
6
+ status: "unsupported" | "active";
7
+ registeredToolNames: readonly string[];
9
8
  };
10
9
  /**
11
10
  * Publishes the frontend tools in the model context to a WebMCP-capable
@@ -16,5 +15,4 @@ export type Unstable_WebMcpProviderResult = {
16
15
  * of the tools currently registered with the host.
17
16
  */
18
17
  export declare const unstable_useWebMcpProvider: (options?: Unstable_WebMcpProviderOptions) => Unstable_WebMcpProviderResult;
19
- //#endregion
20
18
  //# sourceMappingURL=useWebMcpProvider.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useWebMcpProvider.d.ts","names":[],"sources":["../../../src/unstable/webmcp/useWebMcpProvider.ts"],"mappings":";;YAeY;EACV,UAAU,cAAc,MAAM;;YAGpB;EACV;EACA;;;;;;;;;;qBAqGW,6BACX,UAAS,mCACR"}
1
+ {"version":3,"file":"useWebMcpProvider.d.ts","sourceRoot":"","sources":["../../../src/unstable/webmcp/useWebMcpProvider.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAU7C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,CAAC,KAAK,OAAO,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,MAAM,EAAE,aAAa,GAAG,QAAQ,CAAC;IACjC,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC,CAAC;AA8FF;;;;;;;GAOG;AACH,eAAO,MAAM,0BAA0B,GACrC,UAAS,8BAAmC,KAC3C,6BAyCF,CAAC"}
@@ -4,8 +4,8 @@ import { getDefaultWebMcpHost } from "./webmcp-host.js";
4
4
  import { defaultWebMcpFilter, toWebMcpInputSchema } from "./convertTools.js";
5
5
  import { WebMcpRegistrationResource } from "./WebMcpRegistrationResource.js";
6
6
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
7
+ import { useCallback, useEffect, useInsertionEffect, useRef, useState, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
7
8
  import { useAui } from "@assistant-ui/store";
8
- import { useEffect, useState, useSyncExternalStore } from "@assistant-ui/tap/react-shim";
9
9
  import { useResources, useTapRoot, withKey } from "@assistant-ui/tap";
10
10
  import { shallowEqual } from "@assistant-ui/store/internal";
11
11
  //#region src/unstable/webmcp/useWebMcpProvider.ts
@@ -38,11 +38,10 @@ const useStableNames = (names) => {
38
38
  return next;
39
39
  };
40
40
  const useWebMcpRegistry = (t0) => {
41
- const $ = c(4);
42
- const { aui, host, filter } = t0;
43
- const tools = useModelContextSnapshot(aui, host.available, modelContextToolSource);
41
+ const $ = c(5);
42
+ const { host, filter, tools, getCurrentTool } = t0;
44
43
  let elements;
45
- if ($[0] !== filter || $[1] !== host || $[2] !== tools) {
44
+ if ($[0] !== filter || $[1] !== getCurrentTool || $[2] !== host || $[3] !== tools) {
46
45
  elements = [];
47
46
  for (const [name, tool] of Object.entries(tools)) try {
48
47
  if (!filter(name, tool)) continue;
@@ -51,12 +50,14 @@ const useWebMcpRegistry = (t0) => {
51
50
  host,
52
51
  name,
53
52
  signature,
54
- tool
53
+ tool,
54
+ getCurrentTool
55
55
  }), [
56
56
  host,
57
57
  name,
58
58
  signature,
59
- tool
59
+ tool,
60
+ getCurrentTool
60
61
  ]));
61
62
  } catch (t1) {
62
63
  const error = t1;
@@ -65,10 +66,11 @@ const useWebMcpRegistry = (t0) => {
65
66
  console.warn(`[assistant-ui] Skipping WebMCP registration for tool "${name}": filter or schema conversion failed.`, error);
66
67
  }
67
68
  $[0] = filter;
68
- $[1] = host;
69
- $[2] = tools;
70
- $[3] = elements;
71
- } else elements = $[3];
69
+ $[1] = getCurrentTool;
70
+ $[2] = host;
71
+ $[3] = tools;
72
+ $[4] = elements;
73
+ } else elements = $[4];
72
74
  return useStableNames(useResources(elements));
73
75
  };
74
76
  /**
@@ -83,11 +85,18 @@ const unstable_useWebMcpProvider = (options = {}) => {
83
85
  const aui = useAui();
84
86
  const [host] = useState(getDefaultWebMcpHost);
85
87
  const filter = options.filter ?? defaultWebMcpFilter;
88
+ const tools = useModelContextSnapshot(aui, host.available, modelContextToolSource);
89
+ const currentToolsRef = useRef(tools);
90
+ useInsertionEffect(() => {
91
+ currentToolsRef.current = tools;
92
+ }, [tools]);
93
+ const getCurrentTool = useCallback((name) => currentToolsRef.current[name], []);
86
94
  const root = useTapRoot(function WebMcpProviderRoot() {
87
95
  return useWebMcpRegistry({
88
- aui,
89
96
  host,
90
- filter
97
+ filter,
98
+ tools,
99
+ getCurrentTool
91
100
  });
92
101
  });
93
102
  const registeredToolNames = useSyncExternalStore(root.subscribe, root.getValue, () => EMPTY_NAMES);
@@ -1 +1 @@
1
- {"version":3,"file":"useWebMcpProvider.js","names":["c","_c","useEffect","useState","useSyncExternalStore","useResources","useTapRoot","withKey","useAui","AssistantClient","Tool","getDefaultWebMcpHost","WebMcpHost","defaultWebMcpFilter","toWebMcpInputSchema","WebMcpRegistrationResource","shallowEqual","useModelContextSnapshot","ModelContextSnapshotSource","Unstable_WebMcpProviderOptions","filter","name","tool","Unstable_WebMcpProviderResult","status","registeredToolNames","EMPTY_NAMES","Object","freeze","EMPTY_TOOLS","Record","warned","WeakSet","signatures","WeakMap","description","signature","signatureOf","cached","get","JSON","stringify","set","NO_SUBSCRIPTION","modelContextToolSource","empty","read","aui","modelContext","getModelContext","tools","subscribe","onChange","useStableNames","names","cell","next","sort","previous","useWebMcpRegistry","t0","$","host","available","elements","entries","push","t1","error","has","add","console","warn","unstable_useWebMcpProvider","options","root","WebMcpProviderRoot","getValue","published","setPublished"],"sources":["../../../src/unstable/webmcp/useWebMcpProvider.ts"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useState, useSyncExternalStore } from \"react\";\nimport { useResources, useTapRoot, withKey } from \"@assistant-ui/tap\";\nimport { useAui, type AssistantClient } from \"@assistant-ui/store\";\nimport type { Tool } from \"assistant-stream\";\nimport { getDefaultWebMcpHost, type WebMcpHost } from \"./webmcp-host\";\nimport { defaultWebMcpFilter, toWebMcpInputSchema } from \"./convertTools\";\nimport { WebMcpRegistrationResource } from \"./WebMcpRegistrationResource\";\nimport { shallowEqual } from \"@assistant-ui/store/internal\";\nimport {\n useModelContextSnapshot,\n type ModelContextSnapshotSource,\n} from \"../useModelContextSnapshot\";\n\nexport type Unstable_WebMcpProviderOptions = {\n filter?: (name: string, tool: Tool<any, any>) => boolean;\n};\n\nexport type Unstable_WebMcpProviderResult = {\n status: \"unsupported\" | \"active\";\n registeredToolNames: readonly string[];\n};\n\nconst EMPTY_NAMES: readonly string[] = Object.freeze([]);\nconst EMPTY_TOOLS: Record<string, Tool<any, any>> = Object.freeze({});\n\n// The description is re-read on every sync so mutating it in place is\n// observed; the schema is converted only when the tool object itself changes.\n// Keyed on the tool so a schema or filter that throws warns once instead of\n// on every model-context notify.\nconst warned = new WeakSet<Tool<any, any>>();\n\nconst signatures = new WeakMap<\n Tool<any, any>,\n { description: string | undefined; signature: string }\n>();\n\nconst signatureOf = (tool: Tool<any, any>) => {\n const cached = signatures.get(tool);\n if (cached && cached.description === tool.description)\n return cached.signature;\n const signature = `${tool.description ?? \"\"}\\u0000${JSON.stringify(\n toWebMcpInputSchema(tool),\n )}`;\n signatures.set(tool, { description: tool.description, signature });\n return signature;\n};\n\nconst NO_SUBSCRIPTION = () => {};\n\n// No `isEqual`: a caller republishing an unchanged tool set is how it asks for\n// a re-sync, which is what re-attempts a tool whose filter has stopped throwing\n// and what picks up a description edited in place on a stable tool object.\nconst modelContextToolSource: ModelContextSnapshotSource<\n Record<string, Tool<any, any>>\n> = {\n empty: EMPTY_TOOLS,\n read: (aui) => aui.modelContext.getModelContext().tools ?? EMPTY_TOOLS,\n subscribe: (aui, onChange) =>\n aui.modelContext.subscribe?.(onChange) ?? NO_SUBSCRIPTION,\n};\n\nconst useStableNames = (names: readonly (string | null)[]) => {\n const [cell] = useState(() => ({ names: EMPTY_NAMES }));\n const next = names.filter((name): name is string => name !== null).sort();\n const previous = cell.names;\n if (shallowEqual(previous, next)) {\n return previous;\n }\n cell.names = next;\n return next;\n};\n\nconst useWebMcpRegistry = ({\n aui,\n host,\n filter,\n}: {\n aui: AssistantClient;\n host: WebMcpHost;\n filter: (name: string, tool: Tool<any, any>) => boolean;\n}) => {\n const tools = useModelContextSnapshot(\n aui,\n host.available,\n modelContextToolSource,\n );\n\n const elements = [];\n for (const [name, tool] of Object.entries(tools)) {\n try {\n if (!filter(name, tool)) continue;\n const signature = signatureOf(tool);\n elements.push(\n withKey(\n name,\n WebMcpRegistrationResource({ host, name, signature, tool }),\n [host, name, signature, tool],\n ),\n );\n } catch (error) {\n if (warned.has(tool)) continue;\n warned.add(tool);\n console.warn(\n `[assistant-ui] Skipping WebMCP registration for tool \"${name}\": filter or schema conversion failed.`,\n error,\n );\n }\n }\n\n return useStableNames(useResources(elements));\n};\n\n/**\n * Publishes the frontend tools in the model context to a WebMCP-capable\n * browser, so the user's own browser agent can call them.\n *\n * Returns `status: \"unsupported\"` when the page exposes no\n * `document.modelContext` (or `navigator.modelContext`), and the sorted names\n * of the tools currently registered with the host.\n */\nexport const unstable_useWebMcpProvider = (\n options: Unstable_WebMcpProviderOptions = {},\n): Unstable_WebMcpProviderResult => {\n const aui = useAui();\n const [host] = useState(getDefaultWebMcpHost);\n const filter = options.filter ?? defaultWebMcpFilter;\n\n const root = useTapRoot(function WebMcpProviderRoot() {\n return useWebMcpRegistry({ aui, host, filter });\n });\n const registeredToolNames = useSyncExternalStore(\n root.subscribe,\n root.getValue,\n () => EMPTY_NAMES,\n );\n\n const [published, setPublished] = useState(false);\n useEffect(() => {\n if (host.available) setPublished(true);\n }, [host]);\n\n return {\n status: published ? \"active\" : \"unsupported\",\n registeredToolNames,\n };\n};\n"],"mappings":";;;;;;;;;;;AAwBA,MAAM0B,cAAiCC,OAAOC,OAAO,CAAA,CAAE;AACvD,MAAMC,cAA8CF,OAAOC,OAAO,CAAC,CAAC;AAMpE,MAAMG,yBAAS,IAAIC,QAAwB;AAE3C,MAAMC,6BAAa,IAAIC,QAGrB;AAEF,MAAMG,eAAef,SAAyB;CAC5C,MAAMgB,SAASL,WAAWM,IAAIjB,IAAI;CAClC,IAAIgB,UAAUA,OAAOH,gBAAgBb,KAAKa,aACxC,OAAOG,OAAOF;CAChB,MAAMA,YAAY,GAAGd,KAAKa,eAAe,GAAE,QAASK,KAAKC,UACvD3B,oBAAoBQ,IAAI,CAC1B;CACAW,WAAWS,IAAIpB,MAAM;EAAEa,aAAab,KAAKa;EAAaC;CAAU,CAAC;CACjE,OAAOA;AACT;AAEA,MAAMO,wBAAwB,CAAC;AAK/B,MAAMC,yBAEF;CACFC,OAAOhB;CACPiB,OAAOC,QAAQA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G;CAAA,OAAAA,WAAAH,EAAA;CAAA,OAEMR,eAAehD,aAAa2D,QAAQ,CAAC;AAAC;;;;;;;;;AAW/C,MAAaS,8BACXC,UAA0C,CAAC,MACT;CAClC,MAAM3B,MAAMvC,OAAO;CACnB,MAAM,CAACsD,QAAQ3D,SAASQ,oBAAoB;CAC5C,MAAMS,SAASsD,QAAQtD,UAAUP;CAEjC,MAAM8D,OAAOrE,WAAW,SAASsE,qBAAqB;EACpD,OAAOjB,kBAAkB;GAAEZ;GAAKe;GAAM1C;EAAO,CAAC;CAChD,CAAC;CACD,MAAMK,sBAAsBrB,qBAC1BuE,KAAKxB,WACLwB,KAAKE,gBACCnD,WACR;CAEA,MAAM,CAACoD,WAAWC,gBAAgB5E,SAAS,KAAK;CAChDD,gBAAgB;EACd,IAAI4D,KAAKC,WAAWgB,aAAa,IAAI;CACvC,GAAG,CAACjB,IAAI,CAAC;CAET,OAAO;EACLtC,QAAQsD,YAAY,WAAW;EAC/BrD;CACF;AACF"}
1
+ {"version":3,"file":"useWebMcpProvider.js","names":["c","_c","useCallback","useEffect","useInsertionEffect","useRef","useState","useSyncExternalStore","useResources","useTapRoot","withKey","useAui","Tool","getDefaultWebMcpHost","WebMcpHost","defaultWebMcpFilter","toWebMcpInputSchema","WebMcpRegistrationResource","shallowEqual","useModelContextSnapshot","ModelContextSnapshotSource","Unstable_WebMcpProviderOptions","filter","name","tool","Unstable_WebMcpProviderResult","status","registeredToolNames","EMPTY_NAMES","Object","freeze","EMPTY_TOOLS","Record","warned","WeakSet","signatures","WeakMap","description","signature","signatureOf","cached","get","JSON","stringify","set","NO_SUBSCRIPTION","modelContextToolSource","empty","read","aui","modelContext","getModelContext","tools","subscribe","onChange","useStableNames","names","cell","next","sort","previous","useWebMcpRegistry","t0","$","host","getCurrentTool","elements","entries","push","t1","error","has","add","console","warn","unstable_useWebMcpProvider","options","available","currentToolsRef","current","root","WebMcpProviderRoot","getValue","published","setPublished"],"sources":["../../../src/unstable/webmcp/useWebMcpProvider.ts"],"sourcesContent":["\"use client\";\n\nimport {\n useCallback,\n useEffect,\n useInsertionEffect,\n useRef,\n useState,\n useSyncExternalStore,\n} from \"react\";\nimport { useResources, useTapRoot, withKey } from \"@assistant-ui/tap\";\nimport { useAui } from \"@assistant-ui/store\";\nimport type { Tool } from \"assistant-stream\";\nimport { getDefaultWebMcpHost, type WebMcpHost } from \"./webmcp-host\";\nimport { defaultWebMcpFilter, toWebMcpInputSchema } from \"./convertTools\";\nimport { WebMcpRegistrationResource } from \"./WebMcpRegistrationResource\";\nimport { shallowEqual } from \"@assistant-ui/store/internal\";\nimport {\n useModelContextSnapshot,\n type ModelContextSnapshotSource,\n} from \"../useModelContextSnapshot\";\n\nexport type Unstable_WebMcpProviderOptions = {\n filter?: (name: string, tool: Tool<any, any>) => boolean;\n};\n\nexport type Unstable_WebMcpProviderResult = {\n status: \"unsupported\" | \"active\";\n registeredToolNames: readonly string[];\n};\n\nconst EMPTY_NAMES: readonly string[] = Object.freeze([]);\nconst EMPTY_TOOLS: Record<string, Tool<any, any>> = Object.freeze({});\n\n// The description is re-read on every sync so mutating it in place is\n// observed; the schema is converted only when the tool object itself changes.\n// Keyed on the tool so a schema or filter that throws warns once instead of\n// on every model-context notify.\nconst warned = new WeakSet<Tool<any, any>>();\n\nconst signatures = new WeakMap<\n Tool<any, any>,\n { description: string | undefined; signature: string }\n>();\n\nconst signatureOf = (tool: Tool<any, any>) => {\n const cached = signatures.get(tool);\n if (cached && cached.description === tool.description)\n return cached.signature;\n const signature = `${tool.description ?? \"\"}\\u0000${JSON.stringify(\n toWebMcpInputSchema(tool),\n )}`;\n signatures.set(tool, { description: tool.description, signature });\n return signature;\n};\n\nconst NO_SUBSCRIPTION = () => {};\n\n// No `isEqual`: a caller republishing an unchanged tool set is how it asks for\n// a re-sync, which is what re-attempts a tool whose filter has stopped throwing\n// and what picks up a description edited in place on a stable tool object.\nconst modelContextToolSource: ModelContextSnapshotSource<\n Record<string, Tool<any, any>>\n> = {\n empty: EMPTY_TOOLS,\n read: (aui) => aui.modelContext.getModelContext().tools ?? EMPTY_TOOLS,\n subscribe: (aui, onChange) =>\n aui.modelContext.subscribe?.(onChange) ?? NO_SUBSCRIPTION,\n};\n\nconst useStableNames = (names: readonly (string | null)[]) => {\n const [cell] = useState(() => ({ names: EMPTY_NAMES }));\n const next = names.filter((name): name is string => name !== null).sort();\n const previous = cell.names;\n if (shallowEqual(previous, next)) {\n return previous;\n }\n cell.names = next;\n return next;\n};\n\nconst useWebMcpRegistry = ({\n host,\n filter,\n tools,\n getCurrentTool,\n}: {\n host: WebMcpHost;\n filter: (name: string, tool: Tool<any, any>) => boolean;\n tools: Record<string, Tool<any, any>>;\n getCurrentTool: (name: string) => Tool<any, any> | undefined;\n}) => {\n const elements = [];\n for (const [name, tool] of Object.entries(tools)) {\n try {\n if (!filter(name, tool)) continue;\n const signature = signatureOf(tool);\n elements.push(\n withKey(\n name,\n WebMcpRegistrationResource({\n host,\n name,\n signature,\n tool,\n getCurrentTool,\n }),\n [host, name, signature, tool, getCurrentTool],\n ),\n );\n } catch (error) {\n if (warned.has(tool)) continue;\n warned.add(tool);\n console.warn(\n `[assistant-ui] Skipping WebMCP registration for tool \"${name}\": filter or schema conversion failed.`,\n error,\n );\n }\n }\n\n return useStableNames(useResources(elements));\n};\n\n/**\n * Publishes the frontend tools in the model context to a WebMCP-capable\n * browser, so the user's own browser agent can call them.\n *\n * Returns `status: \"unsupported\"` when the page exposes no\n * `document.modelContext` (or `navigator.modelContext`), and the sorted names\n * of the tools currently registered with the host.\n */\nexport const unstable_useWebMcpProvider = (\n options: Unstable_WebMcpProviderOptions = {},\n): Unstable_WebMcpProviderResult => {\n const aui = useAui();\n const [host] = useState(getDefaultWebMcpHost);\n const filter = options.filter ?? defaultWebMcpFilter;\n const tools = useModelContextSnapshot(\n aui,\n host.available,\n modelContextToolSource,\n );\n const currentToolsRef = useRef(tools);\n useInsertionEffect(() => {\n currentToolsRef.current = tools;\n }, [tools]);\n const getCurrentTool = useCallback(\n (name: string) => currentToolsRef.current[name],\n [],\n );\n\n const root = useTapRoot(function WebMcpProviderRoot() {\n return useWebMcpRegistry({\n host,\n filter,\n tools,\n getCurrentTool,\n });\n });\n const registeredToolNames = useSyncExternalStore(\n root.subscribe,\n root.getValue,\n () => EMPTY_NAMES,\n );\n\n const [published, setPublished] = useState(false);\n useEffect(() => {\n if (host.available) setPublished(true);\n }, [host]);\n\n return {\n status: published ? \"active\" : \"unsupported\",\n registeredToolNames,\n };\n};\n"],"mappings":";;;;;;;;;;;AA+BA,MAAM4B,cAAiCC,OAAOC,OAAO,CAAA,CAAE;AACvD,MAAMC,cAA8CF,OAAOC,OAAO,CAAC,CAAC;AAMpE,MAAMG,yBAAS,IAAIC,QAAwB;AAE3C,MAAMC,6BAAa,IAAIC,QAGrB;AAEF,MAAMG,eAAef,SAAyB;CAC5C,MAAMgB,SAASL,WAAWM,IAAIjB,IAAI;CAClC,IAAIgB,UAAUA,OAAOH,gBAAgBb,KAAKa,aACxC,OAAOG,OAAOF;CAChB,MAAMA,YAAY,GAAGd,KAAKa,eAAe,GAAE,QAASK,KAAKC,UACvD3B,oBAAoBQ,IAAI,CAC1B;CACAW,WAAWS,IAAIpB,MAAM;EAAEa,aAAab,KAAKa;EAAaC;CAAU,CAAC;CACjE,OAAOA;AACT;AAEA,MAAMO,wBAAwB,CAAC;AAK/B,MAAMC,yBAEF;CACFC,OAAOhB;CACPiB,OAAOC,QAAQA,IAAIC,aAAaC,gBAAgB,CAAC,CAACC,SAASrB;CAC3DsB,YAAYJ,KAAKK,aACfL,IAAIC,aAAaG,YAAYC,QAAQ,KAAKT;AAC9C;AAEA,MAAMU,kBAAkBC,UAAsC;CAC5D,MAAM,CAACC,QAAQnD,gBAAgB,EAAEkD,OAAO5B,YAAY,EAAE;CACtD,MAAM8B,OAAOF,MAAMlC,QAAQC,SAAyBA,SAAS,IAAI,CAAC,CAACoC,KAAK;CACxE,MAAMC,WAAWH,KAAKD;CACtB,IAA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