@assistant-ui/core 0.2.22 → 0.3.0

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 (349) hide show
  1. package/dist/adapters/thread-history.d.ts +8 -0
  2. package/dist/adapters/thread-history.d.ts.map +1 -1
  3. package/dist/internal.d.ts +3 -2
  4. package/dist/internal.js +3 -2
  5. package/dist/model-context/frame/host.d.ts.map +1 -1
  6. package/dist/model-context/frame/host.js +36 -21
  7. package/dist/model-context/frame/host.js.map +1 -1
  8. package/dist/model-context/types.d.ts.map +1 -1
  9. package/dist/model-context/types.js +13 -4
  10. package/dist/model-context/types.js.map +1 -1
  11. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  12. package/dist/react/adapters/LocalStorageThreadListAdapter.js +3 -2
  13. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  14. package/dist/react/client/Tools.d.ts.map +1 -1
  15. package/dist/react/client/Tools.js +40 -55
  16. package/dist/react/client/Tools.js.map +1 -1
  17. package/dist/react/client/interactable-model-context.js +1 -0
  18. package/dist/react/client/interactable-model-context.js.map +1 -1
  19. package/dist/react/interactables-legacy/useAssistantInteractable.js +1 -1
  20. package/dist/react/interactables-legacy/useAssistantInteractable.js.map +1 -1
  21. package/dist/react/interactables-legacy/useInteractableState.js +4 -3
  22. package/dist/react/interactables-legacy/useInteractableState.js.map +1 -1
  23. package/dist/react/model-context/useAssistantContext.js +1 -1
  24. package/dist/react/model-context/useAssistantContext.js.map +1 -1
  25. package/dist/react/model-context/useAssistantDataUI.js +1 -1
  26. package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
  27. package/dist/react/model-context/useAssistantInstructions.js +1 -1
  28. package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
  29. package/dist/react/model-context/useAssistantTool.js +29 -25
  30. package/dist/react/model-context/useAssistantTool.js.map +1 -1
  31. package/dist/react/model-context/useAssistantToolUI.js +1 -1
  32. package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
  33. package/dist/react/model-context/useAuiToolOverrides.js +1 -1
  34. package/dist/react/model-context/useAuiToolOverrides.js.map +1 -1
  35. package/dist/react/model-context/useInteractable.js +1 -1
  36. package/dist/react/model-context/useInteractable.js.map +1 -1
  37. package/dist/react/model-context/useInteractableState.js +3 -2
  38. package/dist/react/model-context/useInteractableState.js.map +1 -1
  39. package/dist/react/model-context/useInteractableVersions.js +1 -0
  40. package/dist/react/model-context/useInteractableVersions.js.map +1 -1
  41. package/dist/react/model-context/useToolArgsStatus.js +1 -0
  42. package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
  43. package/dist/react/primitive-hooks/useActionBarCopy.js +4 -3
  44. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  45. package/dist/react/primitive-hooks/useActionBarEdit.js +2 -1
  46. package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
  47. package/dist/react/primitive-hooks/useActionBarFeedback.js +3 -2
  48. package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
  49. package/dist/react/primitive-hooks/useActionBarReload.js +2 -1
  50. package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
  51. package/dist/react/primitive-hooks/useActionBarSpeak.js +2 -1
  52. package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
  53. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +2 -1
  54. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
  55. package/dist/react/primitive-hooks/useBranchPickerNext.js +2 -1
  56. package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
  57. package/dist/react/primitive-hooks/useBranchPickerPrevious.js +2 -1
  58. package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
  59. package/dist/react/primitive-hooks/useComposerAddAttachment.js +2 -1
  60. package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
  61. package/dist/react/primitive-hooks/useComposerCancel.js +2 -1
  62. package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
  63. package/dist/react/primitive-hooks/useComposerDictate.js +2 -1
  64. package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
  65. package/dist/react/primitive-hooks/useComposerSend.js +2 -1
  66. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  67. package/dist/react/primitive-hooks/useEditComposerCancel.js +2 -1
  68. package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
  69. package/dist/react/primitive-hooks/useEditComposerSend.js +2 -1
  70. package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
  71. package/dist/react/primitive-hooks/useMessageBranching.js +3 -2
  72. package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
  73. package/dist/react/primitive-hooks/useMessageReload.js +2 -1
  74. package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
  75. package/dist/react/primitive-hooks/useSuggestionTrigger.js +8 -7
  76. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  77. package/dist/react/primitive-hooks/useThreadListItemArchive.js +2 -1
  78. package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
  79. package/dist/react/primitive-hooks/useThreadListItemDelete.js +2 -1
  80. package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
  81. package/dist/react/primitive-hooks/useThreadListItemTrigger.js +2 -1
  82. package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
  83. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +2 -1
  84. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
  85. package/dist/react/primitive-hooks/useThreadListLoadMore.js +2 -1
  86. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
  87. package/dist/react/primitive-hooks/useThreadListNew.js +2 -1
  88. package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
  89. package/dist/react/primitive-hooks/useVoice.js +5 -13
  90. package/dist/react/primitive-hooks/useVoice.js.map +1 -1
  91. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +1 -1
  92. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
  93. package/dist/react/primitives/composer/ComposerAttachments.js +1 -1
  94. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
  95. package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
  96. package/dist/react/primitives/composer/ComposerQueue.js +1 -1
  97. package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
  98. package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
  99. package/dist/react/primitives/message/MessageAttachments.js +1 -1
  100. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  101. package/dist/react/primitives/message/MessageParts.js +84 -122
  102. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  103. package/dist/react/primitives/thread/ThreadMessages.js +1 -1
  104. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  105. package/dist/react/primitives/thread/ThreadSuggestions.js +1 -1
  106. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  107. package/dist/react/primitives/threadList/ThreadListItems.js +1 -1
  108. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
  109. package/dist/react/providers/AttachmentByIndexProvider.js +2 -2
  110. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
  111. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +1 -1
  112. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
  113. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
  114. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +30 -18
  115. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  116. package/dist/react/providers/MessageByIdProvider.js +2 -2
  117. package/dist/react/providers/MessageByIdProvider.js.map +1 -1
  118. package/dist/react/providers/MessageByIndexProvider.js +2 -2
  119. package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
  120. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
  121. package/dist/react/providers/PartByIndexProvider.js +30 -18
  122. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  123. package/dist/react/providers/QueueItemByIndexProvider.js +1 -1
  124. package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
  125. package/dist/react/providers/ReadonlyThreadProvider.js +1 -1
  126. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  127. package/dist/react/providers/SuggestionByIndexProvider.js +1 -1
  128. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
  129. package/dist/react/providers/TextMessagePartProvider.js +1 -0
  130. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  131. package/dist/react/providers/ThreadListItemByIndexProvider.js +1 -1
  132. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
  133. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +3 -3
  134. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  135. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  136. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +6 -4
  137. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  138. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +31 -1
  139. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  140. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +42 -20
  141. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  142. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -1
  143. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
  144. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +1 -1
  145. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  146. package/dist/react/runtimes/cloud/auiV0.d.ts +12 -1
  147. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  148. package/dist/react/runtimes/cloud/auiV0.js +2 -1
  149. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  150. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +75 -73
  151. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  152. package/dist/react/runtimes/createRuntimeExtras.js +1 -1
  153. package/dist/react/runtimes/createRuntimeExtras.js.map +1 -1
  154. package/dist/react/runtimes/external-message-converter.js +1 -1
  155. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  156. package/dist/react/runtimes/useExternalStoreSharedOptions.js +1 -0
  157. package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
  158. package/dist/react/runtimes/useLocalRuntime.d.ts +0 -1
  159. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  160. package/dist/react/types/scopes/tools.d.ts +0 -6
  161. package/dist/react/types/scopes/tools.d.ts.map +1 -1
  162. package/dist/react/utils/groupParts.d.ts +1 -3
  163. package/dist/react/utils/groupParts.d.ts.map +1 -1
  164. package/dist/react/utils/groupParts.js +1 -3
  165. package/dist/react/utils/groupParts.js.map +1 -1
  166. package/dist/runtime/api/assistant-runtime.d.ts +1 -1
  167. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  168. package/dist/runtime/api/assistant-runtime.js +1 -1
  169. package/dist/runtime/api/assistant-runtime.js.map +1 -1
  170. package/dist/runtime/api/attachment-runtime.d.ts +1 -1
  171. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  172. package/dist/runtime/api/attachment-runtime.js +1 -1
  173. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  174. package/dist/runtime/api/composer-runtime.d.ts +2 -2
  175. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  176. package/dist/runtime/api/composer-runtime.js +2 -2
  177. package/dist/runtime/api/composer-runtime.js.map +1 -1
  178. package/dist/runtime/api/message-part-runtime.d.ts +4 -4
  179. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  180. package/dist/runtime/api/message-part-runtime.js +3 -3
  181. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  182. package/dist/runtime/api/message-runtime.d.ts +1 -1
  183. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  184. package/dist/runtime/api/message-runtime.js +2 -2
  185. package/dist/runtime/api/message-runtime.js.map +1 -1
  186. package/dist/runtime/api/thread-list-item-runtime.d.ts +1 -1
  187. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  188. package/dist/runtime/api/thread-list-item-runtime.js +2 -2
  189. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  190. package/dist/runtime/api/thread-list-runtime.d.ts +1 -1
  191. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  192. package/dist/runtime/api/thread-list-runtime.js +1 -1
  193. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  194. package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -1
  195. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  196. package/dist/runtime/base/base-thread-runtime-core.js +1 -1
  197. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  198. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +2 -2
  199. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  200. package/dist/runtime/base/default-edit-composer-runtime-core.js +2 -2
  201. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  202. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -1
  203. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  204. package/dist/runtime/base/default-thread-composer-runtime-core.js +1 -1
  205. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  206. package/dist/runtime/utils/message-repository.d.ts.map +1 -1
  207. package/dist/runtime/utils/message-repository.js +4 -2
  208. package/dist/runtime/utils/message-repository.js.map +1 -1
  209. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +1 -1
  210. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  211. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js +1 -1
  212. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  213. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  214. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +12 -0
  215. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  216. package/dist/runtimes/internal.d.ts +2 -1
  217. package/dist/runtimes/internal.js +2 -1
  218. package/dist/runtimes/local/local-thread-runtime-core.d.ts +3 -0
  219. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  220. package/dist/runtimes/local/local-thread-runtime-core.js +44 -13
  221. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  222. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +32 -27
  223. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
  224. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +2 -0
  225. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  226. package/dist/store/clients/no-op-composer-client.js +1 -0
  227. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  228. package/dist/store/clients/runtime-adapter.js +3 -3
  229. package/dist/store/clients/runtime-adapter.js.map +1 -1
  230. package/dist/store/runtime-clients/thread-list-runtime-client.js +1 -0
  231. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  232. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  233. package/dist/store/runtime-clients/thread-runtime-client.js +17 -15
  234. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  235. package/dist/store/scopes/thread.d.ts +1 -0
  236. package/dist/store/scopes/thread.d.ts.map +1 -1
  237. package/dist/subscribable/subscribable.d.ts +3 -3
  238. package/dist/subscribable/subscribable.d.ts.map +1 -1
  239. package/dist/subscribable/subscribable.js +3 -3
  240. package/dist/subscribable/subscribable.js.map +1 -1
  241. package/package.json +8 -8
  242. package/src/adapters/thread-history.ts +8 -0
  243. package/src/internal.ts +1 -1
  244. package/src/model-context/frame/host.test.ts +47 -0
  245. package/src/model-context/frame/host.ts +46 -19
  246. package/src/model-context/types.ts +16 -6
  247. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +17 -7
  248. package/src/react/client/Tools.ts +0 -7
  249. package/src/react/interactables-legacy/useAssistantInteractable.ts +1 -1
  250. package/src/react/interactables-legacy/useInteractableState.ts +3 -3
  251. package/src/react/model-context/useAssistantContext.ts +1 -1
  252. package/src/react/model-context/useAssistantDataUI.ts +1 -1
  253. package/src/react/model-context/useAssistantInstructions.ts +1 -1
  254. package/src/react/model-context/useAssistantTool.ts +2 -2
  255. package/src/react/model-context/useAssistantToolUI.ts +1 -1
  256. package/src/react/model-context/useAuiToolOverrides.ts +1 -1
  257. package/src/react/model-context/useInteractable.ts +1 -1
  258. package/src/react/model-context/useInteractableState.ts +2 -2
  259. package/src/react/primitive-hooks/useActionBarCopy.test.ts +2 -2
  260. package/src/react/primitive-hooks/useActionBarCopy.ts +3 -3
  261. package/src/react/primitive-hooks/useActionBarEdit.ts +1 -1
  262. package/src/react/primitive-hooks/useActionBarFeedback.ts +2 -2
  263. package/src/react/primitive-hooks/useActionBarReload.ts +1 -1
  264. package/src/react/primitive-hooks/useActionBarSpeak.ts +1 -1
  265. package/src/react/primitive-hooks/useActionBarStopSpeaking.ts +1 -1
  266. package/src/react/primitive-hooks/useBranchPickerNext.ts +1 -1
  267. package/src/react/primitive-hooks/useBranchPickerPrevious.ts +1 -1
  268. package/src/react/primitive-hooks/useComposerAddAttachment.ts +1 -1
  269. package/src/react/primitive-hooks/useComposerCancel.ts +1 -1
  270. package/src/react/primitive-hooks/useComposerDictate.ts +1 -1
  271. package/src/react/primitive-hooks/useComposerSend.ts +1 -1
  272. package/src/react/primitive-hooks/useEditComposerCancel.ts +1 -1
  273. package/src/react/primitive-hooks/useEditComposerSend.ts +1 -1
  274. package/src/react/primitive-hooks/useMessageBranching.ts +2 -2
  275. package/src/react/primitive-hooks/useMessageReload.ts +1 -1
  276. package/src/react/primitive-hooks/useSuggestionTrigger.ts +9 -9
  277. package/src/react/primitive-hooks/useThreadListItemArchive.ts +1 -1
  278. package/src/react/primitive-hooks/useThreadListItemDelete.ts +1 -1
  279. package/src/react/primitive-hooks/useThreadListItemTrigger.ts +1 -1
  280. package/src/react/primitive-hooks/useThreadListItemUnarchive.ts +1 -1
  281. package/src/react/primitive-hooks/useThreadListLoadMore.ts +1 -1
  282. package/src/react/primitive-hooks/useThreadListNew.ts +1 -1
  283. package/src/react/primitive-hooks/useVoice.ts +5 -5
  284. package/src/react/primitives/chainOfThought/ChainOfThoughtParts.tsx +1 -1
  285. package/src/react/primitives/composer/ComposerAttachments.tsx +1 -1
  286. package/src/react/primitives/composer/ComposerQueue.tsx +1 -3
  287. package/src/react/primitives/message/MessageAttachments.tsx +1 -3
  288. package/src/react/primitives/message/MessageParts.tsx +9 -9
  289. package/src/react/primitives/thread/ThreadMessages.tsx +1 -1
  290. package/src/react/primitives/thread/ThreadSuggestions.tsx +1 -1
  291. package/src/react/primitives/threadList/ThreadListItems.tsx +1 -1
  292. package/src/react/providers/AttachmentByIndexProvider.tsx +2 -2
  293. package/src/react/providers/ChainOfThoughtByIndicesProvider.tsx +1 -1
  294. package/src/react/providers/ChainOfThoughtPartByIndexProvider.tsx +2 -19
  295. package/src/react/providers/MessageByIdProvider.tsx +2 -2
  296. package/src/react/providers/MessageByIndexProvider.tsx +2 -2
  297. package/src/react/providers/PartByIndexProvider.tsx +2 -16
  298. package/src/react/providers/QueueItemByIndexProvider.tsx +1 -1
  299. package/src/react/providers/ReadonlyThreadProvider.tsx +1 -1
  300. package/src/react/providers/SuggestionByIndexProvider.tsx +1 -1
  301. package/src/react/providers/ThreadListItemByIndexProvider.tsx +1 -1
  302. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +3 -3
  303. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +20 -6
  304. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +34 -0
  305. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +32 -7
  306. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +47 -16
  307. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +5 -1
  308. package/src/react/runtimes/cloud/auiV0.ts +14 -0
  309. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +90 -88
  310. package/src/react/runtimes/createRuntimeExtras.test.ts +1 -1
  311. package/src/react/runtimes/createRuntimeExtras.ts +1 -1
  312. package/src/react/runtimes/external-message-converter.test.ts +346 -0
  313. package/src/react/runtimes/external-message-converter.ts +1 -1
  314. package/src/react/runtimes/useLocalRuntime.test.tsx +43 -0
  315. package/src/react/types/scopes/tools.ts +0 -6
  316. package/src/react/utils/groupParts.ts +1 -7
  317. package/src/runtime/api/assistant-runtime.ts +4 -1
  318. package/src/runtime/api/attachment-runtime.ts +8 -2
  319. package/src/runtime/api/composer-runtime.ts +9 -5
  320. package/src/runtime/api/message-part-runtime.ts +10 -3
  321. package/src/runtime/api/message-runtime.ts +7 -2
  322. package/src/runtime/api/thread-list-item-runtime.ts +7 -2
  323. package/src/runtime/api/thread-list-runtime.ts +10 -2
  324. package/src/runtime/base/base-thread-runtime-core.ts +5 -1
  325. package/src/runtime/base/default-edit-composer-runtime-core.ts +14 -2
  326. package/src/runtime/base/default-thread-composer-runtime-core.ts +11 -1
  327. package/src/runtime/utils/message-repository.ts +19 -13
  328. package/src/runtimes/external-store/external-store-thread-list-runtime-core.ts +4 -1
  329. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +15 -0
  330. package/src/runtimes/internal.ts +3 -0
  331. package/src/runtimes/local/local-thread-runtime-core.test.ts +596 -0
  332. package/src/runtimes/local/local-thread-runtime-core.ts +85 -21
  333. package/src/runtimes/local/should-continue.test.ts +122 -0
  334. package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +9 -10
  335. package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +38 -32
  336. package/src/store/clients/model-context-client.test.ts +21 -1
  337. package/src/store/clients/runtime-adapter.ts +3 -3
  338. package/src/store/runtime-clients/thread-runtime-client.ts +2 -1
  339. package/src/store/scopes/thread.ts +1 -0
  340. package/src/subscribable/subscribable.ts +16 -8
  341. package/src/tests/MessageRepository.test.ts +12 -0
  342. package/src/tests/RemoteThreadListThreadListRuntimeCore-switchToThread-position.test.ts +121 -0
  343. package/src/tests/auiV0Encode.test.ts +74 -0
  344. package/src/tests/base-composer-runtime-core.test.ts +422 -0
  345. package/src/tests/external-store-thread-list-runtime-core.test.ts +6 -6
  346. package/src/tests/external-store-thread-runtime-core-adapter.test.ts +575 -0
  347. package/src/tests/external-store-thread-runtime-core.test.ts +55 -1
  348. package/src/tests/groupParts.test.ts +3 -48
  349. package/src/tests/OptimisticState-delete-crash.test.ts +0 -208
@@ -1 +1 @@
1
- {"version":3,"file":"createRuntimeExtras.js","names":["useAuiState","AssistantClient","RuntimeExtras","provide","value","T","is","extras","tryGet","get","client","use","select","S","fallback","createRuntimeExtras","runtimeName","brand","Symbol","assert","Error","Object","defineProperty","enumerable","configurable","undefined","thread","getState","rest","hasFallback","length","s"],"sources":["../../../src/react/runtimes/createRuntimeExtras.ts"],"sourcesContent":["\"use client\";\n\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { AssistantClient } from \"@assistant-ui/store\";\n\n/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport type RuntimeExtras<T extends object> = {\n provide: (value: T) => T;\n is: (extras: unknown) => extras is T;\n tryGet: (extras: unknown) => T | undefined;\n get: (client: AssistantClient) => T;\n use: {\n (): T;\n <S>(select: (extras: T) => S): S;\n <S>(select: (extras: T) => S, fallback: S): S;\n };\n};\n\n/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport const createRuntimeExtras = <T extends object>(\n runtimeName: string,\n): RuntimeExtras<T> => {\n const brand = Symbol(`${runtimeName} extras`);\n\n const is = (extras: unknown): extras is T =>\n typeof extras === \"object\" && extras !== null && brand in extras;\n\n const assert = (extras: unknown): T => {\n if (!is(extras))\n throw new Error(\n `The current thread is not backed by the ${runtimeName} runtime.`,\n );\n return extras;\n };\n\n const provide = (value: T): T => {\n Object.defineProperty(value, brand, {\n value: true,\n enumerable: false,\n configurable: true,\n });\n return value;\n };\n\n const tryGet = (extras: unknown): T | undefined =>\n is(extras) ? extras : undefined;\n\n const get = (client: AssistantClient): T =>\n assert(client.thread().getState().extras);\n\n function use<S>(\n select?: (extras: T) => S,\n ...rest: [fallback: S] | []\n ): S | T {\n // Detect a provided fallback by arity, not value: callers pass an explicit\n // `undefined` fallback, which must return `undefined` rather than throw.\n const hasFallback = rest.length > 0;\n const fallback = rest[0] as S;\n return useAuiState((s) => {\n const extras = s.thread.extras;\n if (is(extras)) return select ? select(extras) : extras;\n if (hasFallback) return fallback;\n return assert(extras);\n });\n }\n\n return { provide, is, tryGet, get, use: use as RuntimeExtras<T>[\"use\"] };\n};\n"],"mappings":";;;;AAmBA,MAAae,uBACXC,gBACqB;CACrB,MAAMC,QAAQC,OAAO,GAAGF,YAAW,QAAS;CAE5C,MAAMV,MAAMC,WACV,OAAOA,WAAW,YAAYA,WAAW,QAAQU,SAASV;CAE5D,MAAMY,UAAUZ,WAAuB;EACrC,IAAI,CAACD,GAAGC,MAAM,GACZ,MAAM,IAAIa,MACR,2CAA2CJ,YAAW,UACxD;EACF,OAAOT;CACT;CAEA,MAAMJ,WAAWC,UAAgB;EAC/BiB,OAAOC,eAAelB,OAAOa,OAAO;GAClCb,OAAO;GACPmB,YAAY;GACZC,cAAc;EAChB,CAAC;EACD,OAAOpB;CACT;CAEA,MAAMI,UAAUD,WACdD,GAAGC,MAAM,IAAIA,SAASkB,KAAAA;CAExB,MAAMhB,OAAOC,WACXS,OAAOT,OAAOgB,OAAO,CAAC,CAACC,SAAS,CAAC,CAACpB,MAAM;CAE1C,SAASI,IACPC,QACA,GAAGgB,MACI;EAGP,MAAMC,cAAcD,KAAKE,SAAS;EAClC,MAAMhB,WAAWc,KAAK;EACtB,OAAO5B,aAAa+B,MAAM;GACxB,MAAMxB,SAASwB,EAAEL,OAAOnB;GACxB,IAAID,GAAGC,MAAM,GAAG,OAAOK,SAASA,OAAOL,MAAM,IAAIA;GACjD,IAAIsB,aAAa,OAAOf;GACxB,OAAOK,OAAOZ,MAAM;EACtB,CAAC;CACH;CAEA,OAAO;EAAEJ;EAASG;EAAIE;EAAQC;EAAUE;CAA+B;AACzE"}
1
+ {"version":3,"file":"createRuntimeExtras.js","names":["useAuiState","AssistantClient","RuntimeExtras","provide","value","T","is","extras","tryGet","get","client","use","select","S","fallback","createRuntimeExtras","runtimeName","brand","Symbol","assert","Error","Object","defineProperty","enumerable","configurable","undefined","thread","getState","rest","hasFallback","length","s"],"sources":["../../../src/react/runtimes/createRuntimeExtras.ts"],"sourcesContent":["\"use client\";\n\nimport { useAuiState } from \"@assistant-ui/store\";\nimport type { AssistantClient } from \"@assistant-ui/store\";\n\n/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport type RuntimeExtras<T extends object> = {\n provide: (value: T) => T;\n is: (extras: unknown) => extras is T;\n tryGet: (extras: unknown) => T | undefined;\n get: (client: AssistantClient) => T;\n use: {\n (): T;\n <S>(select: (extras: T) => S): S;\n <S>(select: (extras: T) => S, fallback: S): S;\n };\n};\n\n/** @deprecated Internal API for external-store adapter authors. Not part of the public API; may change or be removed without notice. */\nexport const createRuntimeExtras = <T extends object>(\n runtimeName: string,\n): RuntimeExtras<T> => {\n const brand = Symbol(`${runtimeName} extras`);\n\n const is = (extras: unknown): extras is T =>\n typeof extras === \"object\" && extras !== null && brand in extras;\n\n const assert = (extras: unknown): T => {\n if (!is(extras))\n throw new Error(\n `The current thread is not backed by the ${runtimeName} runtime.`,\n );\n return extras;\n };\n\n const provide = (value: T): T => {\n Object.defineProperty(value, brand, {\n value: true,\n enumerable: false,\n configurable: true,\n });\n return value;\n };\n\n const tryGet = (extras: unknown): T | undefined =>\n is(extras) ? extras : undefined;\n\n const get = (client: AssistantClient): T =>\n assert(client.thread.getState().extras);\n\n function use<S>(\n select?: (extras: T) => S,\n ...rest: [fallback: S] | []\n ): S | T {\n // Detect a provided fallback by arity, not value: callers pass an explicit\n // `undefined` fallback, which must return `undefined` rather than throw.\n const hasFallback = rest.length > 0;\n const fallback = rest[0] as S;\n return useAuiState((s) => {\n const extras = s.thread.extras;\n if (is(extras)) return select ? select(extras) : extras;\n if (hasFallback) return fallback;\n return assert(extras);\n });\n }\n\n return { provide, is, tryGet, get, use: use as RuntimeExtras<T>[\"use\"] };\n};\n"],"mappings":";;;;AAmBA,MAAae,uBACXC,gBACqB;CACrB,MAAMC,QAAQC,OAAO,GAAGF,YAAW,QAAS;CAE5C,MAAMV,MAAMC,WACV,OAAOA,WAAW,YAAYA,WAAW,QAAQU,SAASV;CAE5D,MAAMY,UAAUZ,WAAuB;EACrC,IAAI,CAACD,GAAGC,MAAM,GACZ,MAAM,IAAIa,MACR,2CAA2CJ,YAAW,UACxD;EACF,OAAOT;CACT;CAEA,MAAMJ,WAAWC,UAAgB;EAC/BiB,OAAOC,eAAelB,OAAOa,OAAO;GAClCb,OAAO;GACPmB,YAAY;GACZC,cAAc;EAChB,CAAC;EACD,OAAOpB;CACT;CAEA,MAAMI,UAAUD,WACdD,GAAGC,MAAM,IAAIA,SAASkB,KAAAA;CAExB,MAAMhB,OAAOC,WACXS,OAAOT,OAAOgB,OAAOC,SAAS,CAAC,CAACpB,MAAM;CAExC,SAASI,IACPC,QACA,GAAGgB,MACI;EAGP,MAAMC,cAAcD,KAAKE,SAAS;EAClC,MAAMhB,WAAWc,KAAK;EACtB,OAAO5B,aAAa+B,MAAM;GACxB,MAAMxB,SAASwB,EAAEL,OAAOnB;GACxB,IAAID,GAAGC,MAAM,GAAG,OAAOK,SAASA,OAAOL,MAAM,IAAIA;GACjD,IAAIsB,aAAa,OAAOf;GACxB,OAAOK,OAAOZ,MAAM;EACtB,CAAC;CACH;CAEA,OAAO;EAAEJ;EAASG;EAAIE;EAAQC;EAAUE;CAA+B;AACzE"}
@@ -22,7 +22,7 @@ const joinExternalMessages = (messages) => {
22
22
  const toolCallIdx = assistantMessage.content.findIndex((c) => c.type === "tool-call" && c.toolCallId === output.toolCallId);
23
23
  if (toolCallIdx !== -1) {
24
24
  const toolCall = assistantMessage.content[toolCallIdx];
25
- if (output.toolName !== void 0) {
25
+ if (output.toolName != null) {
26
26
  if (toolCall.toolName !== output.toolName) throw new Error(`Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`);
27
27
  }
28
28
  assistantMessage.content[toolCallIdx] = {
@@ -1 +1 @@
1
- {"version":3,"file":"external-message-converter.js","names":["c","_c","useMemo","useState","ThreadMessageConverter","getExternalStoreMessages","symbolInnerMessage","bindExternalStoreMessage","fromThreadMessageLike","ThreadMessageLike","getAutoStatus","isAutoStatus","ToolExecutionStatus","ReadonlyJSONValue","generateErrorMessageId","ThreadAssistantMessage","ThreadMessage","ToolCallMessagePart","MessageTiming","JoinStrategy","ThreadMessageLikeContentItem","Exclude","isPendingToolCall","type","result","undefined","isInterruptedToolCall","interrupt","approval","approved","resolution","useExternalMessageConverter","Message","convertConfig","joinStrategy","role","toolCallId","toolName","artifact","isError","messages","Metadata","toolStatuses","Record","error","messageTiming","Callback","message","T","metadata","CallbackResult","input","outputs","CallbackCacheEntry","callback","ChunkResult","inputs","Mutable","P","mergeInnerMessages","existing","incoming","joinExternalMessages","assistantMessage","Omit","content","output","toolCallIdx","findIndex","toolCall","Error","const","text","map","length","id","createdAt","status","attachments","unstable_state","unstable_annotations","unstable_data","steps","custom","timing","submittedFeedback","isOptimistic","part","existingIdx","parentId","push","unsupportedRole","chunkExternalMessages","callbackResults","results","isAssistant","pendingNone","flush","callbackResult","at","createErrorAssistantMessage","msg","reason","Date","convertExternalMessages","WeakKey","isRunning","Array","isArray","chunks","idx","isLast","joined","hasInterruptedToolCalls","some","hasPendingToolCalls","autoStatus","newMessage","toString","lastMessage","t0","$","caches","_temp","t1","t2","state","threadMessages","callbackCache","get","set","t3","chunkCache","m","key","cached","shallowArrayEqual","converterCache","convertMessages","cache","message_0","a","b","i","WeakMap"],"sources":["../../../src/react/runtimes/external-message-converter.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo, useState } from \"react\";\nimport { ThreadMessageConverter } from \"../../runtimes/external-store/thread-message-converter\";\nimport {\n getExternalStoreMessages,\n symbolInnerMessage,\n bindExternalStoreMessage,\n} from \"../../runtime/utils/external-store-message\";\nimport {\n fromThreadMessageLike,\n type ThreadMessageLike,\n} from \"../../runtime/utils/thread-message-like\";\nimport { getAutoStatus, isAutoStatus } from \"../../runtime/utils/auto-status\";\nimport type { ToolExecutionStatus } from \"../../runtimes/tool-invocations/ToolInvocationTracker\";\nimport type { ReadonlyJSONValue } from \"assistant-stream/utils\";\nimport { generateErrorMessageId } from \"../../utils/id\";\nimport type {\n ThreadAssistantMessage,\n ThreadMessage,\n ToolCallMessagePart,\n} from \"../../types/message\";\nimport type { MessageTiming } from \"../../types/message\";\n\nexport type JoinStrategy = \"concat-content\" | \"none\";\n\ntype ThreadMessageLikeContentItem = Exclude<\n ThreadMessageLike[\"content\"],\n string\n>[number];\n\nconst isPendingToolCall = (c: ThreadMessageLikeContentItem): boolean =>\n c.type === \"tool-call\" && c.result === undefined;\n\nconst isInterruptedToolCall = (c: ThreadMessageLikeContentItem): boolean => {\n if (c.type !== \"tool-call\" || c.result !== undefined) return false;\n return (\n c.interrupt != null ||\n (c.approval != null &&\n c.approval.approved === undefined &&\n c.approval.resolution === undefined)\n );\n};\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | (ThreadMessageLike & {\n readonly convertConfig?: {\n readonly joinStrategy?: JoinStrategy;\n };\n })\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n artifact?: any;\n isError?: boolean;\n messages?: readonly ThreadMessage[];\n };\n\n export type Metadata = {\n readonly toolStatuses?: Record<string, ToolExecutionStatus>;\n readonly error?: ReadonlyJSONValue;\n readonly messageTiming?: Record<string, MessageTiming>;\n };\n\n export type Callback<T> = (\n message: T,\n metadata: Metadata,\n ) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype CallbackCacheEntry<T> = CallbackResult<T> & {\n metadata: useExternalMessageConverter.Metadata;\n callback: useExternalMessageConverter.Callback<T>;\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nconst mergeInnerMessages = (existing: object, incoming: object) => ({\n [symbolInnerMessage]: [\n ...((existing as any)[symbolInnerMessage] ?? []),\n ...((incoming as any)[symbolInnerMessage] ?? []),\n ],\n});\n\nconst joinExternalMessages = (\n messages: readonly useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: Mutable<Omit<ThreadMessageLike, \"metadata\">> & {\n content: Exclude<ThreadMessageLike[\"content\"][0], string>[];\n metadata?: Mutable<ThreadMessageLike[\"metadata\"]>;\n } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n // Ignore orphaned tool results so one bad tool message does not\n // prevent rendering the rest of the conversation.\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallMessagePart;\n if (output.toolName !== undefined) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n ...{\n [symbolInnerMessage]: [\n ...((toolCall as any)[symbolInnerMessage] ?? []),\n output,\n ],\n },\n result: output.result,\n artifact: output.artifact,\n isError: output.isError,\n messages: output.messages,\n };\n }\n } else {\n const role = output.role;\n const content = (\n typeof output.content === \"string\"\n ? [{ type: \"text\" as const, text: output.content }]\n : output.content\n ).map((c) => ({\n ...c,\n ...{ [symbolInnerMessage]: [output] },\n }));\n switch (role) {\n case \"system\":\n case \"user\":\n return {\n ...output,\n content,\n };\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n\n if (output.attachments) {\n assistantMessage.attachments = [\n ...(assistantMessage.attachments ?? []),\n ...output.attachments,\n ];\n }\n\n if (output.metadata) {\n assistantMessage.metadata ??= {};\n if (output.metadata.unstable_state !== undefined) {\n assistantMessage.metadata.unstable_state =\n output.metadata.unstable_state;\n }\n if (output.metadata.unstable_annotations) {\n assistantMessage.metadata.unstable_annotations = [\n ...(assistantMessage.metadata.unstable_annotations ?? []),\n ...output.metadata.unstable_annotations,\n ];\n }\n if (output.metadata.unstable_data) {\n assistantMessage.metadata.unstable_data = [\n ...(assistantMessage.metadata.unstable_data ?? []),\n ...output.metadata.unstable_data,\n ];\n }\n if (output.metadata.steps) {\n assistantMessage.metadata.steps = [\n ...(assistantMessage.metadata.steps ?? []),\n ...output.metadata.steps,\n ];\n }\n if (output.metadata.custom) {\n assistantMessage.metadata.custom = {\n ...(assistantMessage.metadata.custom ?? {}),\n ...output.metadata.custom,\n };\n }\n\n if (output.metadata.timing) {\n assistantMessage.metadata.timing = output.metadata.timing;\n }\n\n if (output.metadata.submittedFeedback) {\n assistantMessage.metadata.submittedFeedback =\n output.metadata.submittedFeedback;\n }\n\n if (output.metadata.isOptimistic) {\n assistantMessage.metadata.isOptimistic = true;\n }\n }\n // TODO keep this in sync\n }\n\n // Add content parts, merging reasoning parts with same parentId\n for (const part of content) {\n if (part.type === \"tool-call\") {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"tool-call\" && c.toolCallId === part.toolCallId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n ...part,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n\n if (\n part.type === \"reasoning\" &&\n \"parentId\" in part &&\n part.parentId\n ) {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"reasoning\" &&\n \"parentId\" in c &&\n c.parentId === part.parentId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n text: `${existing.text}\\n\\n${part.text}`,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n assistantMessage.content.push(part);\n }\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T>(\n callbackResults: CallbackResult<T>[],\n joinStrategy?: JoinStrategy,\n) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let pendingNone = false; // true if the previous assistant message had joinStrategy \"none\"\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n isAssistant = false;\n pendingNone = false;\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (\n (pendingNone && output.role !== \"tool\") ||\n !isAssistant ||\n output.role === \"user\" ||\n output.role === \"system\"\n ) {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n\n if (\n output.role === \"assistant\" &&\n (output.convertConfig?.joinStrategy === \"none\" ||\n joinStrategy === \"none\")\n ) {\n pendingNone = true;\n }\n }\n }\n flush();\n return results;\n};\n\nfunction createErrorAssistantMessage(\n error: ReadonlyJSONValue,\n): ThreadAssistantMessage {\n const msg: ThreadAssistantMessage = {\n id: generateErrorMessageId(),\n role: \"assistant\",\n content: [],\n status: { type: \"incomplete\", reason: \"error\", error },\n createdAt: new Date(),\n metadata: {\n unstable_state: null,\n unstable_annotations: [],\n unstable_data: [],\n custom: {},\n steps: [],\n },\n };\n bindExternalStoreMessage(msg, []);\n return msg;\n}\n\nexport const convertExternalMessages = <T extends WeakKey>(\n messages: T[],\n callback: useExternalMessageConverter.Callback<T>,\n isRunning: boolean,\n metadata: useExternalMessageConverter.Metadata,\n) => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n const output = callback(message, metadata);\n const outputs = Array.isArray(output) ? output : [output];\n const result = { input: message, outputs };\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults);\n\n const result = chunks.map((message, idx) => {\n const isLast = idx === chunks.length - 1;\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? metadata.error : undefined,\n );\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n });\n\n if (metadata.error) {\n const lastMessage = result.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n result.push(createErrorAssistantMessage(metadata.error));\n }\n }\n\n return result;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n joinStrategy,\n metadata,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n joinStrategy?: JoinStrategy | undefined;\n metadata?: useExternalMessageConverter.Metadata | undefined;\n}) => {\n // The caches live for the component lifetime; React Compiler hoists\n // allocations without reactive dependencies out of useMemo, so re-creating\n // them on dependency change would not survive compilation. Staleness is\n // instead tracked per entry via the metadata/callback that produced it,\n // keeping correctness independent of memoization (which React treats as\n // droppable). A \"use no memo\" opt-out would restore the useMemo semantics\n // but leave cache flushing coupled to memo firing.\n const [caches] = useState(() => ({\n callbackCache: new WeakMap<T, CallbackCacheEntry<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }));\n\n const state = useMemo(\n () => ({\n metadata: metadata ?? {},\n callback,\n ...caches,\n }),\n [callback, metadata, caches],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (\n !result ||\n result.metadata !== state.metadata ||\n result.callback !== state.callback\n ) {\n const output = state.callback(message, state.metadata);\n const outputs = Array.isArray(output) ? output : [output];\n result = {\n input: message,\n outputs,\n metadata: state.metadata,\n callback: state.callback,\n };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults, joinStrategy).map(\n (m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs))\n return cached;\n state.chunkCache.set(key, m);\n return m;\n },\n );\n\n const threadMessages = state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? state.metadata.error : undefined,\n );\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessages<T>(cache);\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n },\n );\n\n bindExternalStoreMessage(threadMessages, messages);\n\n if (state.metadata.error) {\n const lastMessage = threadMessages.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n threadMessages.push(createErrorAssistantMessage(state.metadata.error));\n }\n }\n\n return threadMessages;\n }, [state, messages, isRunning, joinStrategy]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":";;;;;;;;;AA+BA,MAAMsB,qBAAqBtB,MACzBA,EAAEuB,SAAS,eAAevB,EAAEwB,WAAWC,KAAAA;AAEzC,MAAMC,yBAAyB1B,MAA6C;CAC1E,IAAIA,EAAEuB,SAAS,eAAevB,EAAEwB,WAAWC,KAAAA,GAAW,OAAO;CAC7D,OACEzB,EAAE2B,aAAa,QACd3B,EAAE4B,YAAY,QACb5B,EAAE4B,SAASC,aAAaJ,KAAAA,KACxBzB,EAAE4B,SAASE,eAAeL,KAAAA;AAEhC;AAkDA,MAAMkC,sBAAsBC,UAAkBC,cAAsB,GACjEvD,qBAAqB,CACpB,GAAKsD,SAAiBtD,uBAAuB,CAAA,GAC7C,GAAKuD,SAAiBvD,uBAAuB,CAAA,CAAG,EAEpD;AAEA,MAAMwD,wBACJtB,aACsB;CACtB,MAAMuB,mBAGF;EACF5B,MAAM;EACN8B,SAAS,CAAA;CACX;CACA,KAAK,MAAMC,UAAU1B,UACnB,IAAI0B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,aAAagI,MAAK9D,MAAO,KAC1B8D,MAAK9D,WAAYuC,aAAW;IAE9B,MAAA5D,SAAenD,yBAA4BsI,KAAK;IAChD,IAAIH,kBAAkBhF,QAAQT,UAAOS,MAAO,GAAC,OACpCmF;GACR;GAGH,MAAAtB,aAAmB7G,sBACjBwG,QACAF,IAAGQ,SAAU,GACbF,UACF;GACA7G,yBAAyB8G,YAAYtE,UAAOS,MAAO;GAAC,OAC7C6D;EAAU,CAErB;EAEA9G,yBAAyBwH,gBAAgBvF,QAAQ;EAEjD,IAAIsF,MAAK7E,SAASL,OAAM;GACtB,MAAA2E,cAAoBQ,eAAc5B,GAAI,EAAE;GACxC,IAAI,CAACoB,eAAeA,YAAWpF,SAAU,aACvC4F,eAAcrC,KAAMU,4BAA4B0B,MAAK7E,SAASL,KAAM,CAAC;EACtE;EACF6E,EAAA,KAAAf;EAAAe,EAAA,KAAAvF;EAAAuF,EAAA,KAAAjF;EAAAiF,EAAA,KAAAK;EAAAL,EAAA,MAAAM;CAAA,OAAAA,iBAAAN,EAAA;CAAA,OAEDM;AAAsB;AAI1B,MAAMS,qBAAqBK,GAAcC,MAAiB;CACxD,IAAID,EAAEnE,WAAWoE,EAAEpE,QAAQ,OAAO;CAClC,KAAK,IAAIqE,IAAI,GAAGA,IAAIF,EAAEnE,QAAQqE,KAC5B,IAAIF,EAAEE,OAAOD,EAAEC,IAAI,OAAO;CAE5B,OAAO;AACT;AAtI2C,SAAApB,QAAA;CAAA,OAoBR;EAAAK,+BAChB,IAAIgB,QAAkC;EAACZ,4BAC1C,IAAIY,QAGd;EAACP,gBACa,IAAIrI,uBAAuB;CAC7C;AAAC"}
1
+ {"version":3,"file":"external-message-converter.js","names":["c","_c","useMemo","useState","ThreadMessageConverter","getExternalStoreMessages","symbolInnerMessage","bindExternalStoreMessage","fromThreadMessageLike","ThreadMessageLike","getAutoStatus","isAutoStatus","ToolExecutionStatus","ReadonlyJSONValue","generateErrorMessageId","ThreadAssistantMessage","ThreadMessage","ToolCallMessagePart","MessageTiming","JoinStrategy","ThreadMessageLikeContentItem","Exclude","isPendingToolCall","type","result","undefined","isInterruptedToolCall","interrupt","approval","approved","resolution","useExternalMessageConverter","Message","convertConfig","joinStrategy","role","toolCallId","toolName","artifact","isError","messages","Metadata","toolStatuses","Record","error","messageTiming","Callback","message","T","metadata","CallbackResult","input","outputs","CallbackCacheEntry","callback","ChunkResult","inputs","Mutable","P","mergeInnerMessages","existing","incoming","joinExternalMessages","assistantMessage","Omit","content","output","toolCallIdx","findIndex","toolCall","Error","const","text","map","length","id","createdAt","status","attachments","unstable_state","unstable_annotations","unstable_data","steps","custom","timing","submittedFeedback","isOptimistic","part","existingIdx","parentId","push","unsupportedRole","chunkExternalMessages","callbackResults","results","isAssistant","pendingNone","flush","callbackResult","at","createErrorAssistantMessage","msg","reason","Date","convertExternalMessages","WeakKey","isRunning","Array","isArray","chunks","idx","isLast","joined","hasInterruptedToolCalls","some","hasPendingToolCalls","autoStatus","newMessage","toString","lastMessage","t0","$","caches","_temp","t1","t2","state","threadMessages","callbackCache","get","set","t3","chunkCache","m","key","cached","shallowArrayEqual","converterCache","convertMessages","cache","message_0","a","b","i","WeakMap"],"sources":["../../../src/react/runtimes/external-message-converter.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo, useState } from \"react\";\nimport { ThreadMessageConverter } from \"../../runtimes/external-store/thread-message-converter\";\nimport {\n getExternalStoreMessages,\n symbolInnerMessage,\n bindExternalStoreMessage,\n} from \"../../runtime/utils/external-store-message\";\nimport {\n fromThreadMessageLike,\n type ThreadMessageLike,\n} from \"../../runtime/utils/thread-message-like\";\nimport { getAutoStatus, isAutoStatus } from \"../../runtime/utils/auto-status\";\nimport type { ToolExecutionStatus } from \"../../runtimes/tool-invocations/ToolInvocationTracker\";\nimport type { ReadonlyJSONValue } from \"assistant-stream/utils\";\nimport { generateErrorMessageId } from \"../../utils/id\";\nimport type {\n ThreadAssistantMessage,\n ThreadMessage,\n ToolCallMessagePart,\n} from \"../../types/message\";\nimport type { MessageTiming } from \"../../types/message\";\n\nexport type JoinStrategy = \"concat-content\" | \"none\";\n\ntype ThreadMessageLikeContentItem = Exclude<\n ThreadMessageLike[\"content\"],\n string\n>[number];\n\nconst isPendingToolCall = (c: ThreadMessageLikeContentItem): boolean =>\n c.type === \"tool-call\" && c.result === undefined;\n\nconst isInterruptedToolCall = (c: ThreadMessageLikeContentItem): boolean => {\n if (c.type !== \"tool-call\" || c.result !== undefined) return false;\n return (\n c.interrupt != null ||\n (c.approval != null &&\n c.approval.approved === undefined &&\n c.approval.resolution === undefined)\n );\n};\n\nexport namespace useExternalMessageConverter {\n export type Message =\n | (ThreadMessageLike & {\n readonly convertConfig?: {\n readonly joinStrategy?: JoinStrategy;\n };\n })\n | {\n role: \"tool\";\n toolCallId: string;\n toolName?: string | undefined;\n result: any;\n artifact?: any;\n isError?: boolean;\n messages?: readonly ThreadMessage[];\n };\n\n export type Metadata = {\n readonly toolStatuses?: Record<string, ToolExecutionStatus>;\n readonly error?: ReadonlyJSONValue;\n readonly messageTiming?: Record<string, MessageTiming>;\n };\n\n export type Callback<T> = (\n message: T,\n metadata: Metadata,\n ) => Message | Message[];\n}\n\ntype CallbackResult<T> = {\n input: T;\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype CallbackCacheEntry<T> = CallbackResult<T> & {\n metadata: useExternalMessageConverter.Metadata;\n callback: useExternalMessageConverter.Callback<T>;\n};\n\ntype ChunkResult<T> = {\n inputs: T[];\n outputs: useExternalMessageConverter.Message[];\n};\n\ntype Mutable<T> = {\n -readonly [P in keyof T]: T[P];\n};\n\nconst mergeInnerMessages = (existing: object, incoming: object) => ({\n [symbolInnerMessage]: [\n ...((existing as any)[symbolInnerMessage] ?? []),\n ...((incoming as any)[symbolInnerMessage] ?? []),\n ],\n});\n\nconst joinExternalMessages = (\n messages: readonly useExternalMessageConverter.Message[],\n): ThreadMessageLike => {\n const assistantMessage: Mutable<Omit<ThreadMessageLike, \"metadata\">> & {\n content: Exclude<ThreadMessageLike[\"content\"][0], string>[];\n metadata?: Mutable<ThreadMessageLike[\"metadata\"]>;\n } = {\n role: \"assistant\",\n content: [],\n };\n for (const output of messages) {\n if (output.role === \"tool\") {\n const toolCallIdx = assistantMessage.content.findIndex(\n (c) => c.type === \"tool-call\" && c.toolCallId === output.toolCallId,\n );\n // Ignore orphaned tool results so one bad tool message does not\n // prevent rendering the rest of the conversation.\n if (toolCallIdx !== -1) {\n const toolCall = assistantMessage.content[\n toolCallIdx\n ]! as ToolCallMessagePart;\n if (output.toolName != null) {\n if (toolCall.toolName !== output.toolName)\n throw new Error(\n `Tool call name ${output.toolCallId} ${output.toolName} does not match existing tool call ${toolCall.toolName}`,\n );\n }\n assistantMessage.content[toolCallIdx] = {\n ...toolCall,\n ...{\n [symbolInnerMessage]: [\n ...((toolCall as any)[symbolInnerMessage] ?? []),\n output,\n ],\n },\n result: output.result,\n artifact: output.artifact,\n isError: output.isError,\n messages: output.messages,\n };\n }\n } else {\n const role = output.role;\n const content = (\n typeof output.content === \"string\"\n ? [{ type: \"text\" as const, text: output.content }]\n : output.content\n ).map((c) => ({\n ...c,\n ...{ [symbolInnerMessage]: [output] },\n }));\n switch (role) {\n case \"system\":\n case \"user\":\n return {\n ...output,\n content,\n };\n case \"assistant\":\n if (assistantMessage.content.length === 0) {\n assistantMessage.id = output.id;\n assistantMessage.createdAt ??= output.createdAt;\n assistantMessage.status ??= output.status;\n\n if (output.attachments) {\n assistantMessage.attachments = [\n ...(assistantMessage.attachments ?? []),\n ...output.attachments,\n ];\n }\n\n if (output.metadata) {\n assistantMessage.metadata ??= {};\n if (output.metadata.unstable_state !== undefined) {\n assistantMessage.metadata.unstable_state =\n output.metadata.unstable_state;\n }\n if (output.metadata.unstable_annotations) {\n assistantMessage.metadata.unstable_annotations = [\n ...(assistantMessage.metadata.unstable_annotations ?? []),\n ...output.metadata.unstable_annotations,\n ];\n }\n if (output.metadata.unstable_data) {\n assistantMessage.metadata.unstable_data = [\n ...(assistantMessage.metadata.unstable_data ?? []),\n ...output.metadata.unstable_data,\n ];\n }\n if (output.metadata.steps) {\n assistantMessage.metadata.steps = [\n ...(assistantMessage.metadata.steps ?? []),\n ...output.metadata.steps,\n ];\n }\n if (output.metadata.custom) {\n assistantMessage.metadata.custom = {\n ...(assistantMessage.metadata.custom ?? {}),\n ...output.metadata.custom,\n };\n }\n\n if (output.metadata.timing) {\n assistantMessage.metadata.timing = output.metadata.timing;\n }\n\n if (output.metadata.submittedFeedback) {\n assistantMessage.metadata.submittedFeedback =\n output.metadata.submittedFeedback;\n }\n\n if (output.metadata.isOptimistic) {\n assistantMessage.metadata.isOptimistic = true;\n }\n }\n // TODO keep this in sync\n }\n\n // Add content parts, merging reasoning parts with same parentId\n for (const part of content) {\n if (part.type === \"tool-call\") {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"tool-call\" && c.toolCallId === part.toolCallId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n ...part,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n\n if (\n part.type === \"reasoning\" &&\n \"parentId\" in part &&\n part.parentId\n ) {\n const existingIdx = assistantMessage.content.findIndex(\n (c) =>\n c.type === \"reasoning\" &&\n \"parentId\" in c &&\n c.parentId === part.parentId,\n );\n if (existingIdx !== -1) {\n const existing = assistantMessage.content[\n existingIdx\n ] as typeof part;\n assistantMessage.content[existingIdx] = {\n ...existing,\n text: `${existing.text}\\n\\n${part.text}`,\n ...mergeInnerMessages(existing, part),\n };\n continue;\n }\n }\n assistantMessage.content.push(part);\n }\n break;\n default: {\n const unsupportedRole: never = role;\n throw new Error(`Unknown message role: ${unsupportedRole}`);\n }\n }\n }\n }\n return assistantMessage;\n};\n\nconst chunkExternalMessages = <T>(\n callbackResults: CallbackResult<T>[],\n joinStrategy?: JoinStrategy,\n) => {\n const results: ChunkResult<T>[] = [];\n let isAssistant = false;\n let pendingNone = false; // true if the previous assistant message had joinStrategy \"none\"\n let inputs: T[] = [];\n let outputs: useExternalMessageConverter.Message[] = [];\n\n const flush = () => {\n if (outputs.length) {\n results.push({\n inputs,\n outputs,\n });\n }\n inputs = [];\n outputs = [];\n isAssistant = false;\n pendingNone = false;\n };\n\n for (const callbackResult of callbackResults) {\n for (const output of callbackResult.outputs) {\n if (\n (pendingNone && output.role !== \"tool\") ||\n !isAssistant ||\n output.role === \"user\" ||\n output.role === \"system\"\n ) {\n flush();\n }\n isAssistant = output.role === \"assistant\" || output.role === \"tool\";\n\n if (inputs.at(-1) !== callbackResult.input) {\n inputs.push(callbackResult.input);\n }\n outputs.push(output);\n\n if (\n output.role === \"assistant\" &&\n (output.convertConfig?.joinStrategy === \"none\" ||\n joinStrategy === \"none\")\n ) {\n pendingNone = true;\n }\n }\n }\n flush();\n return results;\n};\n\nfunction createErrorAssistantMessage(\n error: ReadonlyJSONValue,\n): ThreadAssistantMessage {\n const msg: ThreadAssistantMessage = {\n id: generateErrorMessageId(),\n role: \"assistant\",\n content: [],\n status: { type: \"incomplete\", reason: \"error\", error },\n createdAt: new Date(),\n metadata: {\n unstable_state: null,\n unstable_annotations: [],\n unstable_data: [],\n custom: {},\n steps: [],\n },\n };\n bindExternalStoreMessage(msg, []);\n return msg;\n}\n\nexport const convertExternalMessages = <T extends WeakKey>(\n messages: T[],\n callback: useExternalMessageConverter.Callback<T>,\n isRunning: boolean,\n metadata: useExternalMessageConverter.Metadata,\n) => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n const output = callback(message, metadata);\n const outputs = Array.isArray(output) ? output : [output];\n const result = { input: message, outputs };\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults);\n\n const result = chunks.map((message, idx) => {\n const isLast = idx === chunks.length - 1;\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? metadata.error : undefined,\n );\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n });\n\n if (metadata.error) {\n const lastMessage = result.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n result.push(createErrorAssistantMessage(metadata.error));\n }\n }\n\n return result;\n};\n\nexport const useExternalMessageConverter = <T extends WeakKey>({\n callback,\n messages,\n isRunning,\n joinStrategy,\n metadata,\n}: {\n callback: useExternalMessageConverter.Callback<T>;\n messages: T[];\n isRunning: boolean;\n joinStrategy?: JoinStrategy | undefined;\n metadata?: useExternalMessageConverter.Metadata | undefined;\n}) => {\n // The caches live for the component lifetime; React Compiler hoists\n // allocations without reactive dependencies out of useMemo, so re-creating\n // them on dependency change would not survive compilation. Staleness is\n // instead tracked per entry via the metadata/callback that produced it,\n // keeping correctness independent of memoization (which React treats as\n // droppable). A \"use no memo\" opt-out would restore the useMemo semantics\n // but leave cache flushing coupled to memo firing.\n const [caches] = useState(() => ({\n callbackCache: new WeakMap<T, CallbackCacheEntry<T>>(),\n chunkCache: new WeakMap<\n useExternalMessageConverter.Message,\n ChunkResult<T>\n >(),\n converterCache: new ThreadMessageConverter(),\n }));\n\n const state = useMemo(\n () => ({\n metadata: metadata ?? {},\n callback,\n ...caches,\n }),\n [callback, metadata, caches],\n );\n\n return useMemo(() => {\n const callbackResults: CallbackResult<T>[] = [];\n for (const message of messages) {\n let result = state.callbackCache.get(message);\n if (\n !result ||\n result.metadata !== state.metadata ||\n result.callback !== state.callback\n ) {\n const output = state.callback(message, state.metadata);\n const outputs = Array.isArray(output) ? output : [output];\n result = {\n input: message,\n outputs,\n metadata: state.metadata,\n callback: state.callback,\n };\n state.callbackCache.set(message, result);\n }\n callbackResults.push(result);\n }\n\n const chunks = chunkExternalMessages(callbackResults, joinStrategy).map(\n (m) => {\n const key = m.outputs[0];\n if (!key) return m;\n\n const cached = state.chunkCache.get(key);\n if (cached && shallowArrayEqual(cached.outputs, m.outputs))\n return cached;\n state.chunkCache.set(key, m);\n return m;\n },\n );\n\n const threadMessages = state.converterCache.convertMessages(\n chunks,\n (cache, message, idx) => {\n const isLast = idx === chunks.length - 1;\n\n const joined = joinExternalMessages(message.outputs);\n const hasInterruptedToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isInterruptedToolCall);\n const hasPendingToolCalls =\n typeof joined.content === \"object\" &&\n joined.content.some(isPendingToolCall);\n const autoStatus = getAutoStatus(\n isLast,\n isRunning,\n hasInterruptedToolCalls,\n hasPendingToolCalls,\n isLast ? state.metadata.error : undefined,\n );\n\n if (\n cache &&\n (cache.role !== \"assistant\" ||\n !isAutoStatus(cache.status) ||\n cache.status === autoStatus)\n ) {\n const inputs = getExternalStoreMessages<T>(cache);\n if (shallowArrayEqual(inputs, message.inputs)) {\n return cache;\n }\n }\n\n const newMessage = fromThreadMessageLike(\n joined,\n idx.toString(),\n autoStatus,\n );\n bindExternalStoreMessage(newMessage, message.inputs);\n return newMessage;\n },\n );\n\n bindExternalStoreMessage(threadMessages, messages);\n\n if (state.metadata.error) {\n const lastMessage = threadMessages.at(-1);\n if (!lastMessage || lastMessage.role !== \"assistant\") {\n threadMessages.push(createErrorAssistantMessage(state.metadata.error));\n }\n }\n\n return threadMessages;\n }, [state, messages, isRunning, joinStrategy]);\n};\n\nconst shallowArrayEqual = (a: unknown[], b: unknown[]) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) return false;\n }\n return true;\n};\n"],"mappings":";;;;;;;;;AA+BA,MAAMsB,qBAAqBtB,MACzBA,EAAEuB,SAAS,eAAevB,EAAEwB,WAAWC,KAAAA;AAEzC,MAAMC,yBAAyB1B,MAA6C;CAC1E,IAAIA,EAAEuB,SAAS,e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GA,IAAIF,EAAEnE,QAAQqE,KAC5B,IAAIF,EAAEE,OAAOD,EAAEC,IAAI,OAAO;CAE5B,OAAO;AACT;AAtI2C,SAAApB,QAAA;CAAA,OAoBR;EAAAK,+BAChB,IAAIgB,QAAkC;EAACZ,4BAC1C,IAAIY,QAGd;EAACP,gBACa,IAAIrI,uBAAuB;CAC7C;AAAC"}
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import "@assistant-ui/tap/react-shim";
2
3
  import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
3
4
  //#region src/react/runtimes/useExternalStoreSharedOptions.ts
4
5
  const useExternalStoreSharedOptions = (options) => {
@@ -1 +1 @@
1
- {"version":3,"file":"useExternalStoreSharedOptions.js","names":["c","_c","useMemo","ExternalStoreSharedOptions","useExternalStoreSharedOptions","options","$","isDisabled","isSendDisabled","unstable_capabilities","suggestions","t0","Required","K"],"sources":["../../../src/react/runtimes/useExternalStoreSharedOptions.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { ExternalStoreSharedOptions } from \"../../runtimes/external-store/external-store-shared-options\";\n\nexport const useExternalStoreSharedOptions = (\n options: ExternalStoreSharedOptions,\n): ExternalStoreSharedOptions => {\n const { isDisabled, isSendDisabled, unstable_capabilities, suggestions } =\n options;\n return useMemo(\n () =>\n ({\n isDisabled,\n isSendDisabled,\n unstable_capabilities,\n suggestions,\n }) satisfies {\n [K in keyof Required<ExternalStoreSharedOptions>]: ExternalStoreSharedOptions[K];\n },\n [isDisabled, isSendDisabled, unstable_capabilities, suggestions],\n );\n};\n"],"mappings":";;;AAKA,MAAaI,iCAAgCC,YAAA;CAAA,MAAAC,IAAAL,EAAA,CAAA;CAG3C,MAAA,EAAAM,YAAAC,gBAAAC,uBAAAC,gBACEL;CAAQ,IAAAM;CAAA,IAAAL,EAAA,OAAAC,cAAAD,EAAA,OAAAE,kBAAAF,EAAA,OAAAI,eAAAJ,EAAA,OAAAG,uBAAA;EAGLE,KAAA;GAAAJ;GAAAC;GAAAC;GAAAC;EAKD;EAACJ,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OALAK;AAOA"}
1
+ {"version":3,"file":"useExternalStoreSharedOptions.js","names":["c","_c","useMemo","ExternalStoreSharedOptions","useExternalStoreSharedOptions","options","$","isDisabled","isSendDisabled","unstable_capabilities","suggestions","t0","Required","K"],"sources":["../../../src/react/runtimes/useExternalStoreSharedOptions.ts"],"sourcesContent":["\"use client\";\n\nimport { useMemo } from \"react\";\nimport type { ExternalStoreSharedOptions } from \"../../runtimes/external-store/external-store-shared-options\";\n\nexport const useExternalStoreSharedOptions = (\n options: ExternalStoreSharedOptions,\n): ExternalStoreSharedOptions => {\n const { isDisabled, isSendDisabled, unstable_capabilities, suggestions } =\n options;\n return useMemo(\n () =>\n ({\n isDisabled,\n isSendDisabled,\n unstable_capabilities,\n suggestions,\n }) satisfies {\n [K in keyof Required<ExternalStoreSharedOptions>]: ExternalStoreSharedOptions[K];\n },\n [isDisabled, isSendDisabled, unstable_capabilities, suggestions],\n );\n};\n"],"mappings":";;;;AAKA,MAAaI,iCAAgCC,YAAA;CAAA,MAAAC,IAAAL,EAAA,CAAA;CAG3C,MAAA,EAAAM,YAAAC,gBAAAC,uBAAAC,gBACEL;CAAQ,IAAAM;CAAA,IAAAL,EAAA,OAAAC,cAAAD,EAAA,OAAAE,kBAAAF,EAAA,OAAAI,eAAAJ,EAAA,OAAAG,uBAAA;EAGLE,KAAA;GAAAJ;GAAAC;GAAAC;GAAAC;EAKD;EAACJ,EAAA,KAAAC;EAAAD,EAAA,KAAAE;EAAAF,EAAA,KAAAI;EAAAJ,EAAA,KAAAG;EAAAH,EAAA,KAAAK;CAAA,OAAAA,KAAAL,EAAA;CAAA,OALAK;AAOA"}
@@ -6,7 +6,6 @@ import { ChatModelAdapter } from "../../runtime/utils/chat-model-adapter.js";
6
6
  import { ThreadMessageLike } from "../../runtime/utils/thread-message-like.js";
7
7
  import { SuggestionAdapter } from "../../adapters/suggestion.js";
8
8
  import { ThreadHistoryAdapter } from "../../adapters/thread-history.js";
9
- import "../../adapters/index.js";
10
9
  import { LocalRuntimeOptionsBase } from "../../runtimes/local/local-runtime-options.js";
11
10
  import { AssistantRuntime } from "../../runtime/api/assistant-runtime.js";
12
11
  import "../../index.js";
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalRuntime.d.ts","names":[],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"mappings":";;;;;;;;;;;;;;KAcY,sBAAsB,KAAK;EACrC,QAAQ;EACR,2BAA2B;EAC3B,WAAW,KAAK;;cA2DL,2BAA4B,UAAU,qBACjD,SAAS;;;;;;;;;;;;;;;;;;;;cAyBE,kBACX,WAAW,oBACX,UAAA,YAAuB,wBACtB"}
1
+ {"version":3,"file":"useLocalRuntime.d.ts","names":[],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"mappings":";;;;;;;;;;;;;KAcY,sBAAsB,KAAK;EACrC,QAAQ;EACR,2BAA2B;EAC3B,WAAW,KAAK;;cA2DL,2BAA4B,UAAU,qBACjD,SAAS;;;;;;;;;;;;;;;;;;;;cAyBE,kBACX,WAAW,oBACX,UAAA,YAAuB,wBACtB"}
@@ -19,12 +19,6 @@ type ToolsState = {
19
19
  /** Registered tool UIs (renderer + presentation options) keyed by tool name. */
20
20
  toolUIs: Record<string, readonly ToolRegistration[]>;
21
21
  mcpApp?: McpAppResourceOutput | undefined;
22
- /**
23
- * @deprecated Use {@link toolUIs} instead, whose entries carry the renderer
24
- * alongside its presentation options. This component-only map is kept for
25
- * back-compat and will be removed in v0.15.
26
- */
27
- tools: Record<string, ToolCallMessagePartComponent[]>;
28
22
  };
29
23
  type ToolsMethods = {
30
24
  getState(): ToolsState;
@@ -1 +1 @@
1
- {"version":3,"file":"tools.d.ts","names":[],"sources":["../../../../src/react/types/scopes/tools.ts"],"mappings":";;;;KAGY;WACD,QAAQ;;;;;;;KAQd;WACM,QAAQ;;WAER;;KAGC;;EAEV,SAAS,wBAAwB;EACjC,SAAS;;;;;;EAMT,OAAO,eAAe;;KAGZ;EACV,YAAY;EACZ,UACE,kBACA,QAAQ,8BACR;IAAY;MACX;;KAGO;EACV,SAAS"}
1
+ {"version":3,"file":"tools.d.ts","names":[],"sources":["../../../../src/react/types/scopes/tools.ts"],"mappings":";;;;KAGY;WACD,QAAQ;;;;;;;KAQd;WACM,QAAQ;;WAER;;KAGC;;EAEV,SAAS,wBAAwB;EACjC,SAAS;;KAGC;EACV,YAAY;EACZ,UACE,kBACA,QAAQ,8BACR;IAAY;MACX;;KAGO;EACV,SAAS"}
@@ -41,10 +41,8 @@ declare const GROUPBY_MEMO_KEY: unique symbol;
41
41
  * `display: "standalone"`). Resolving the registry-driven cases reads the
42
42
  * {@link GroupByContext} passed to the `groupBy` function. Takes precedence
43
43
  * over the `"tool-call"` entry.
44
- * - `"mcp-app"` — **deprecated**, kept for back-compat. Matches only MCP-app
45
- * tool calls. Prefer `"standalone-tool-call"`, which is a superset.
46
44
  */
47
- type GroupPartType = PartState["type"] | "standalone-tool-call" | "mcp-app";
45
+ type GroupPartType = PartState["type"] | "standalone-tool-call";
48
46
  /**
49
47
  * Build a `groupBy` from a `part.type → group-key path` lookup.
50
48
  * Parts whose type isn't in the map are left ungrouped. The returned
@@ -1 +1 @@
1
- {"version":3,"file":"groupParts.d.ts","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"mappings":";;;;;;;;;KAUY;;WAED,UAAU;;;;;;;;;;;;;;;;;;;;cAsBR;;;;;;;;;;;;;;;KAkBR,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BR,kBAAmB,gCAC9B,KAAK,QAAQ,SAAS,OAAO,wBAAwB,gBAClD,MAAM,WAAW,UAAU,4BAA4B;KA+BhD,YAAY,iBAAiB;UAExB;WACN;;WAEA;;WAEA;;;;;WAKA;;WAEA;WACA,mBAAmB;;UAGb;WACN;;WAEA;;WAEA;;;;;WAKA;;;;;;;;;cAiCE,iBACX,uCACA,uDACU"}
1
+ {"version":3,"file":"groupParts.d.ts","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"mappings":";;;;;;;;;KAUY;;WAED,UAAU;;;;;;;;;;;;;;;;;;;;cAsBR;;;;;;;;;;;;;KAgBR,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;cA4BR,kBAAmB,gCAC9B,KAAK,QAAQ,SAAS,OAAO,wBAAwB,gBAClD,MAAM,WAAW,UAAU,4BAA4B;KA2BhD,YAAY,iBAAiB;UAExB;WACN;;WAEA;;WAEA;;;;;WAKA;;WAEA;WACA,mBAAmB;;UAGb;WACN;;WAEA;;WAEA;;;;;WAKA;;;;;;;;;cAiCE,iBACX,uCACA,uDACU"}
@@ -49,9 +49,7 @@ const groupPartByType = (map) => {
49
49
  const lookup = map;
50
50
  const fn = ((part, context) => {
51
51
  if (part.type === "tool-call") {
52
- const isMcpApp = isMcpAppUri(part.mcp?.app?.resourceUri);
53
- if ((isMcpApp || (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false)) && lookup["standalone-tool-call"] !== void 0) return lookup["standalone-tool-call"];
54
- if (isMcpApp && lookup["mcp-app"] !== void 0) return lookup["mcp-app"];
52
+ if ((isMcpAppUri(part.mcp?.app?.resourceUri) || (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false)) && lookup["standalone-tool-call"] !== void 0) return lookup["standalone-tool-call"];
55
53
  }
56
54
  return lookup[part.type] ?? [];
57
55
  });
@@ -1 +1 @@
1
- {"version":3,"file":"groupParts.js","names":["isMcpAppUri","PartState","ToolsState","GroupByContext","toolUIs","GROUPBY_MEMO_KEY","Symbol","for","GroupPartType","groupPartByType","map","Partial","Readonly","Record","TKey","part","context","lookup","fn","type","isMcpApp","mcp","app","resourceUri","isStandalone","toolName","standalone","undefined","sortedKeys","Object","keys","sort","sortedEntries","k","JSON","stringify","GroupNode","GroupNodeGroup","GroupNodePart","key","nodeKey","idKey","indices","children","index","BuildFrame","nextChildIdx","claimed","Set","makeChildNodeKey","parent","idx","String","claimIdKey","frame","id","has","add","buildGroupTree","paths","partIds","root","stack","closeTop","closing","pop","length","push","i","path","common","top","s"],"sources":["../../../src/react/utils/groupParts.ts"],"sourcesContent":["import { isMcpAppUri } from \"../../types/message\";\nimport type { PartState } from \"../../store/scopes/part\";\nimport type { ToolsState } from \"../types/scopes/tools\";\n\n/**\n * Registry context passed to a `groupBy` function as its second argument by\n * `<MessagePrimitive.GroupedParts>`. Carries the live tool-UI registry so a\n * `groupBy` can resolve registry-driven grouping (e.g. standalone tool calls)\n * without the part itself having to carry that information.\n */\nexport type GroupByContext = {\n /** Tool UIs registered in the tool-UI registry, keyed by tool name. */\n readonly toolUIs?: ToolsState[\"toolUIs\"];\n};\n\n/**\n * Hierarchical adjacent-coalescing grouping for message parts.\n *\n * Given a group path per part (from `groupBy`), builds a tree of group\n * nodes wrapping individual parts. Adjacent parts sharing a path prefix\n * coalesce into the same group; ungrouped parts are direct children of\n * the root.\n *\n * Each node gets a structural `nodeKey` built from sibling indices\n * (`\"0.1.0\"`), stable under append-only streaming.\n */\n\n/**\n * Symbol attached to memoizable `groupBy` functions (e.g. those returned\n * by {@link groupPartByType}). Carries a string fingerprint of the config\n * so `MessagePrimitive.GroupedParts` can memo the tree on\n * `[parts, memoKey]` across renders — even when the helper call site\n * reconstructs the function each render.\n */\nexport const GROUPBY_MEMO_KEY: unique symbol = Symbol.for(\n \"@assistant-ui/groupBy.memoKey\",\n);\n\n/**\n * Synthetic part-type keys recognized by {@link groupPartByType}, in\n * addition to real {@link PartState} types:\n *\n * - `\"standalone-tool-call\"` — a tool-call whose UI should be presented on its\n * own, outside the chain-of-thought grouping. Matches MCP-app tool calls plus\n * any tool-call whose registered UI opts into standalone display (human\n * tools, the built-in generative-UI tool, and tools that set\n * `display: \"standalone\"`). Resolving the registry-driven cases reads the\n * {@link GroupByContext} passed to the `groupBy` function. Takes precedence\n * over the `\"tool-call\"` entry.\n * - `\"mcp-app\"` — **deprecated**, kept for back-compat. Matches only MCP-app\n * tool calls. Prefer `\"standalone-tool-call\"`, which is a superset.\n */\ntype GroupPartType = PartState[\"type\"] | \"standalone-tool-call\" | \"mcp-app\";\n\n/**\n * Build a `groupBy` from a `part.type → group-key path` lookup.\n * Parts whose type isn't in the map are left ungrouped. The returned\n * function carries a stable {@link GROUPBY_MEMO_KEY} fingerprint so\n * `<MessagePrimitive.GroupedParts>` can memoize its tree across renders.\n *\n * The synthetic `\"standalone-tool-call\"` key matches tool calls that should\n * render outside the chain-of-thought grouping. MCP-app calls are detected from\n * the part alone; the registry-driven cases (human tools, the generative-UI\n * tool, `display: \"standalone\"` opt-ins) are resolved from the\n * {@link GroupByContext} that `<MessagePrimitive.GroupedParts>` passes to the\n * `groupBy` function — the helper needs nothing threaded into it.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * \"standalone-tool-call\": [],\n * })}\n * >\n * {({ part, children }) => { ... }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const groupPartByType = <TKey extends `group-${string}`>(\n map: Partial<Readonly<Record<GroupPartType, readonly TKey[]>>>,\n): ((part: PartState, context?: GroupByContext) => readonly TKey[]) => {\n const lookup = map as Readonly<Record<string, readonly TKey[] | undefined>>;\n const fn = ((part, context) => {\n if (part.type === \"tool-call\") {\n const isMcpApp = isMcpAppUri(part.mcp?.app?.resourceUri);\n // Read the first registration's flag — the same one `resolveToolRender`\n // renders — so grouping and rendering never disagree for a tool name.\n const isStandalone =\n isMcpApp ||\n (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false);\n if (isStandalone && lookup[\"standalone-tool-call\"] !== undefined) {\n return lookup[\"standalone-tool-call\"]!;\n }\n // TODO(v0.15): drop the deprecated \"mcp-app\" key (superseded by \"standalone-tool-call\").\n if (isMcpApp && lookup[\"mcp-app\"] !== undefined) {\n return lookup[\"mcp-app\"]!;\n }\n }\n return lookup[part.type] ?? [];\n }) as ((part: PartState, context?: GroupByContext) => readonly TKey[]) & {\n [GROUPBY_MEMO_KEY]?: string;\n };\n // Sort keys so the fingerprint is insensitive to map insertion order —\n // two maps with the same key/value pairs but different declaration order\n // would otherwise hash differently and invalidate the memo unnecessarily.\n const sortedKeys = Object.keys(map).sort();\n const sortedEntries = sortedKeys.map((k) => [k, map[k as keyof typeof map]]);\n fn[GROUPBY_MEMO_KEY] = `groupPartByType:${JSON.stringify(sortedEntries)}`;\n return fn;\n};\n\nexport type GroupNode = GroupNodeGroup | GroupNodePart;\n\nexport interface GroupNodeGroup {\n readonly type: \"group\";\n /** Current-level group key (last segment of the path). */\n readonly key: string;\n /** Structural React key: sibling-index path, e.g. `\"0.1.0\"`. */\n readonly nodeKey: string;\n /**\n * Identity key (`\"id:<partId>\"`) from the group's first part; undefined\n * when absent or already claimed by an earlier sibling.\n */\n readonly idKey: string | undefined;\n /** Indices of parts in this subtree, in order. */\n readonly indices: readonly number[];\n readonly children: readonly GroupNode[];\n}\n\nexport interface GroupNodePart {\n readonly type: \"part\";\n /** Index of the part in the message. */\n readonly index: number;\n /** Structural React key: sibling-index path within parent. */\n readonly nodeKey: string;\n /**\n * Identity key (`\"id:<partId>\"`); undefined when absent or already\n * claimed by an earlier sibling.\n */\n readonly idKey: string | undefined;\n}\n\ninterface BuildFrame {\n key: string;\n nodeKey: string;\n indices: number[];\n children: GroupNode[];\n nextChildIdx: number;\n claimed: Set<string>;\n}\n\nconst makeChildNodeKey = (parent: BuildFrame): string => {\n const idx = parent.nextChildIdx++;\n return parent.nodeKey === \"\" ? String(idx) : `${parent.nodeKey}.${idx}`;\n};\n\nconst claimIdKey = (\n frame: BuildFrame,\n id: string | undefined,\n): string | undefined => {\n if (id === undefined || frame.claimed.has(id)) return undefined;\n frame.claimed.add(id);\n return `id:${id}`;\n};\n\n/**\n * Build the group tree from an array of normalized group paths.\n * `paths[i]` is the path for part `i`. The output tree contains one\n * `part` node per part and one `group` node per coalesced run.\n * `partIds[i]` optionally carries a stable identity for part `i` (e.g. a\n * tool call id), from which nodes derive an `idKey`.\n */\nexport const buildGroupTree = (\n paths: readonly (readonly string[])[],\n partIds?: readonly (string | undefined)[],\n): readonly GroupNode[] => {\n const root: BuildFrame = {\n key: \"\",\n nodeKey: \"\",\n indices: [],\n children: [],\n nextChildIdx: 0,\n claimed: new Set(),\n };\n const stack: BuildFrame[] = [root];\n\n const closeTop = (): void => {\n const closing = stack.pop()!;\n const parent = stack[stack.length - 1]!;\n parent.children.push({\n type: \"group\",\n key: closing.key,\n nodeKey: closing.nodeKey,\n idKey: claimIdKey(parent, partIds?.[closing.indices[0]!]),\n indices: closing.indices,\n children: closing.children,\n });\n };\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]!;\n\n // Find the longest prefix shared between currently-open groups\n // (excluding root) and this part's path.\n let common = 0;\n while (\n common < stack.length - 1 &&\n common < path.length &&\n stack[common + 1]!.key === path[common]\n ) {\n common++;\n }\n\n // Close groups not on this path.\n while (stack.length - 1 > common) {\n closeTop();\n }\n\n // Open new groups down to the part's depth.\n while (stack.length - 1 < path.length) {\n const parent = stack[stack.length - 1]!;\n stack.push({\n key: path[stack.length - 1]!,\n nodeKey: makeChildNodeKey(parent),\n indices: [],\n children: [],\n nextChildIdx: 0,\n claimed: new Set(),\n });\n }\n\n // Push this part as a leaf in the deepest open group (or root).\n const top = stack[stack.length - 1]!;\n top.children.push({\n type: \"part\",\n index: i,\n nodeKey: makeChildNodeKey(top),\n idKey: claimIdKey(top, partIds?.[i]),\n });\n\n // Record the part index in every open ancestor group.\n for (let s = 1; s < stack.length; s++) {\n stack[s]!.indices.push(i);\n }\n }\n\n // Close any still-open groups.\n while (stack.length > 1) {\n closeTop();\n }\n\n return root.children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,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Context","toolUIs","GROUPBY_MEMO_KEY","Symbol","for","GroupPartType","groupPartByType","map","Partial","Readonly","Record","TKey","part","context","lookup","fn","type","isMcpApp","mcp","app","resourceUri","isStandalone","toolName","standalone","undefined","sortedKeys","Object","keys","sort","sortedEntries","k","JSON","stringify","GroupNode","GroupNodeGroup","GroupNodePart","key","nodeKey","idKey","indices","children","index","BuildFrame","nextChildIdx","claimed","Set","makeChildNodeKey","parent","idx","String","claimIdKey","frame","id","has","add","buildGroupTree","paths","partIds","root","stack","closeTop","closing","pop","length","push","i","path","common","top","s"],"sources":["../../../src/react/utils/groupParts.ts"],"sourcesContent":["import { isMcpAppUri } from \"../../types/message\";\nimport type { PartState } from \"../../store/scopes/part\";\nimport type { ToolsState } from \"../types/scopes/tools\";\n\n/**\n * Registry context passed to a `groupBy` function as its second argument by\n * `<MessagePrimitive.GroupedParts>`. Carries the live tool-UI registry so a\n * `groupBy` can resolve registry-driven grouping (e.g. standalone tool calls)\n * without the part itself having to carry that information.\n */\nexport type GroupByContext = {\n /** Tool UIs registered in the tool-UI registry, keyed by tool name. */\n readonly toolUIs?: ToolsState[\"toolUIs\"];\n};\n\n/**\n * Hierarchical adjacent-coalescing grouping for message parts.\n *\n * Given a group path per part (from `groupBy`), builds a tree of group\n * nodes wrapping individual parts. Adjacent parts sharing a path prefix\n * coalesce into the same group; ungrouped parts are direct children of\n * the root.\n *\n * Each node gets a structural `nodeKey` built from sibling indices\n * (`\"0.1.0\"`), stable under append-only streaming.\n */\n\n/**\n * Symbol attached to memoizable `groupBy` functions (e.g. those returned\n * by {@link groupPartByType}). Carries a string fingerprint of the config\n * so `MessagePrimitive.GroupedParts` can memo the tree on\n * `[parts, memoKey]` across renders — even when the helper call site\n * reconstructs the function each render.\n */\nexport const GROUPBY_MEMO_KEY: unique symbol = Symbol.for(\n \"@assistant-ui/groupBy.memoKey\",\n);\n\n/**\n * Synthetic part-type keys recognized by {@link groupPartByType}, in\n * addition to real {@link PartState} types:\n *\n * - `\"standalone-tool-call\"` — a tool-call whose UI should be presented on its\n * own, outside the chain-of-thought grouping. Matches MCP-app tool calls plus\n * any tool-call whose registered UI opts into standalone display (human\n * tools, the built-in generative-UI tool, and tools that set\n * `display: \"standalone\"`). Resolving the registry-driven cases reads the\n * {@link GroupByContext} passed to the `groupBy` function. Takes precedence\n * over the `\"tool-call\"` entry.\n */\ntype GroupPartType = PartState[\"type\"] | \"standalone-tool-call\";\n\n/**\n * Build a `groupBy` from a `part.type → group-key path` lookup.\n * Parts whose type isn't in the map are left ungrouped. The returned\n * function carries a stable {@link GROUPBY_MEMO_KEY} fingerprint so\n * `<MessagePrimitive.GroupedParts>` can memoize its tree across renders.\n *\n * The synthetic `\"standalone-tool-call\"` key matches tool calls that should\n * render outside the chain-of-thought grouping. MCP-app calls are detected from\n * the part alone; the registry-driven cases (human tools, the generative-UI\n * tool, `display: \"standalone\"` opt-ins) are resolved from the\n * {@link GroupByContext} that `<MessagePrimitive.GroupedParts>` passes to the\n * `groupBy` function — the helper needs nothing threaded into it.\n *\n * @example\n * ```tsx\n * <MessagePrimitive.GroupedParts\n * groupBy={groupPartByType({\n * reasoning: [\"group-thought\", \"group-reasoning\"],\n * \"tool-call\": [\"group-thought\", \"group-tool\"],\n * \"standalone-tool-call\": [],\n * })}\n * >\n * {({ part, children }) => { ... }}\n * </MessagePrimitive.GroupedParts>\n * ```\n */\nexport const groupPartByType = <TKey extends `group-${string}`>(\n map: Partial<Readonly<Record<GroupPartType, readonly TKey[]>>>,\n): ((part: PartState, context?: GroupByContext) => readonly TKey[]) => {\n const lookup = map as Readonly<Record<string, readonly TKey[] | undefined>>;\n const fn = ((part, context) => {\n if (part.type === \"tool-call\") {\n const isMcpApp = isMcpAppUri(part.mcp?.app?.resourceUri);\n // Read the first registration's flag — the same one `resolveToolRender`\n // renders — so grouping and rendering never disagree for a tool name.\n const isStandalone =\n isMcpApp ||\n (context?.toolUIs?.[part.toolName]?.[0]?.standalone ?? false);\n if (isStandalone && lookup[\"standalone-tool-call\"] !== undefined) {\n return lookup[\"standalone-tool-call\"]!;\n }\n }\n return lookup[part.type] ?? [];\n }) as ((part: PartState, context?: GroupByContext) => readonly TKey[]) & {\n [GROUPBY_MEMO_KEY]?: string;\n };\n // Sort keys so the fingerprint is insensitive to map insertion order —\n // two maps with the same key/value pairs but different declaration order\n // would otherwise hash differently and invalidate the memo unnecessarily.\n const sortedKeys = Object.keys(map).sort();\n const sortedEntries = sortedKeys.map((k) => [k, map[k as keyof typeof map]]);\n fn[GROUPBY_MEMO_KEY] = `groupPartByType:${JSON.stringify(sortedEntries)}`;\n return fn;\n};\n\nexport type GroupNode = GroupNodeGroup | GroupNodePart;\n\nexport interface GroupNodeGroup {\n readonly type: \"group\";\n /** Current-level group key (last segment of the path). */\n readonly key: string;\n /** Structural React key: sibling-index path, e.g. `\"0.1.0\"`. */\n readonly nodeKey: string;\n /**\n * Identity key (`\"id:<partId>\"`) from the group's first part; undefined\n * when absent or already claimed by an earlier sibling.\n */\n readonly idKey: string | undefined;\n /** Indices of parts in this subtree, in order. */\n readonly indices: readonly number[];\n readonly children: readonly GroupNode[];\n}\n\nexport interface GroupNodePart {\n readonly type: \"part\";\n /** Index of the part in the message. */\n readonly index: number;\n /** Structural React key: sibling-index path within parent. */\n readonly nodeKey: string;\n /**\n * Identity key (`\"id:<partId>\"`); undefined when absent or already\n * claimed by an earlier sibling.\n */\n readonly idKey: string | undefined;\n}\n\ninterface BuildFrame {\n key: string;\n nodeKey: string;\n indices: number[];\n children: GroupNode[];\n nextChildIdx: number;\n claimed: Set<string>;\n}\n\nconst makeChildNodeKey = (parent: BuildFrame): string => {\n const idx = parent.nextChildIdx++;\n return parent.nodeKey === \"\" ? String(idx) : `${parent.nodeKey}.${idx}`;\n};\n\nconst claimIdKey = (\n frame: BuildFrame,\n id: string | undefined,\n): string | undefined => {\n if (id === undefined || frame.claimed.has(id)) return undefined;\n frame.claimed.add(id);\n return `id:${id}`;\n};\n\n/**\n * Build the group tree from an array of normalized group paths.\n * `paths[i]` is the path for part `i`. The output tree contains one\n * `part` node per part and one `group` node per coalesced run.\n * `partIds[i]` optionally carries a stable identity for part `i` (e.g. a\n * tool call id), from which nodes derive an `idKey`.\n */\nexport const buildGroupTree = (\n paths: readonly (readonly string[])[],\n partIds?: readonly (string | undefined)[],\n): readonly GroupNode[] => {\n const root: BuildFrame = {\n key: \"\",\n nodeKey: \"\",\n indices: [],\n children: [],\n nextChildIdx: 0,\n claimed: new Set(),\n };\n const stack: BuildFrame[] = [root];\n\n const closeTop = (): void => {\n const closing = stack.pop()!;\n const parent = stack[stack.length - 1]!;\n parent.children.push({\n type: \"group\",\n key: closing.key,\n nodeKey: closing.nodeKey,\n idKey: claimIdKey(parent, partIds?.[closing.indices[0]!]),\n indices: closing.indices,\n children: closing.children,\n });\n };\n\n for (let i = 0; i < paths.length; i++) {\n const path = paths[i]!;\n\n // Find the longest prefix shared between currently-open groups\n // (excluding root) and this part's path.\n let common = 0;\n while (\n common < stack.length - 1 &&\n common < path.length &&\n stack[common + 1]!.key === path[common]\n ) {\n common++;\n }\n\n // Close groups not on this path.\n while (stack.length - 1 > common) {\n closeTop();\n }\n\n // Open new groups down to the part's depth.\n while (stack.length - 1 < path.length) {\n const parent = stack[stack.length - 1]!;\n stack.push({\n key: path[stack.length - 1]!,\n nodeKey: makeChildNodeKey(parent),\n indices: [],\n children: [],\n nextChildIdx: 0,\n claimed: new Set(),\n });\n }\n\n // Push this part as a leaf in the deepest open group (or root).\n const top = stack[stack.length - 1]!;\n top.children.push({\n type: \"part\",\n index: i,\n nodeKey: makeChildNodeKey(top),\n idKey: claimIdKey(top, partIds?.[i]),\n });\n\n // Record the part index in every open ancestor group.\n for (let s = 1; s < stack.length; s++) {\n stack[s]!.indices.push(i);\n }\n }\n\n // Close any still-open groups.\n while (stack.length > 1) {\n closeTop();\n }\n\n return root.children;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAkCA,MAAaK,mBAAkCC,OAAOC,IACpD,+BACF;;;;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zB;GACbC,SAASwB,QAAQxB;GACjBC,OAAOY,WAAWH,QAAQU,UAAUI,QAAQtB,QAAQ,GAAI;GACxDA,SAASsB,QAAQtB;GACjBC,UAAUqB,QAAQrB;EACpB,CAAC;CACH;CAEA,KAAK,IAAIyB,IAAI,GAAGA,IAAIT,MAAMO,QAAQE,KAAK;EACrC,MAAMC,OAAOV,MAAMS;EAInB,IAAIE,SAAS;EACb,OACEA,SAASR,MAAMI,SAAS,KACxBI,SAASD,KAAKH,UACdJ,MAAMQ,SAAS,EAAE,CAAE/B,QAAQ8B,KAAKC,SAEhCA;EAIF,OAAOR,MAAMI,SAAS,IAAII,QACxBP,SAAS;EAIX,OAAOD,MAAMI,SAAS,IAAIG,KAAKH,QAAQ;GACrC,MAAMhB,SAASY,MAAMA,MAAMI,SAAS;GACpCJ,MAAMK,KAAK;IACT5B,KAAK8B,KAAKP,MAAMI,SAAS;IACzB1B,SAASS,iBAAiBC,MAAM;IAChCR,SAAS,CAAA;IACTC,UAAU,CAAA;IACVG,cAAc;IACdC,yBAAS,IAAIC,IAAI;GACnB,CAAC;EACH;EAGA,MAAMuB,MAAMT,MAAMA,MAAMI,SAAS;EACjCK,IAAI5B,SAASwB,KAAK;GAChBhD,MAAM;GACNyB,OAAOwB;GACP5B,SAASS,iBAAiBsB,GAAG;GAC7B9B,OAAOY,WAAWkB,KAAKX,UAAUQ,EAAE;EACrC,CAAC;EAGD,KAAK,IAAII,IAAI,GAAGA,IAAIV,MAAMI,QAAQM,KAChCV,MAAMU,EAAE,CAAE9B,QAAQyB,KAAKC,CAAC;CAE5B;CAGA,OAAON,MAAMI,SAAS,GACpBH,SAAS;CAGX,OAAOF,KAAKlB;AACd"}
@@ -21,9 +21,9 @@ type AssistantRuntime = {
21
21
  registerModelContextProvider(provider: ModelContextProvider): Unsubscribe;
22
22
  };
23
23
  declare class AssistantRuntimeImpl implements AssistantRuntime {
24
- private readonly _core;
25
24
  readonly threads: ThreadListRuntimeImpl;
26
25
  readonly _thread: ThreadRuntime;
26
+ private readonly _core;
27
27
  constructor(_core: AssistantRuntimeCore);
28
28
  protected __internal_bindMethods(): void;
29
29
  get thread(): ThreadRuntime;
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/assistant-runtime.ts"],"mappings":";;;;;;KASY;;;;WAID,SAAS;;;;WAKT,QAAQ;;;;;;EAOjB,6BAA6B,UAAU,uBAAuB;;cAGnD,gCAAgC;mBAKP;WAJpB,SAAO;WAEP,SAAS;EAEW,YAAA,OAAO;YAOjC;MAKC,UAAM;EAIV,6BAA6B,UAAU,uBAAoB"}
1
+ {"version":3,"file":"assistant-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/assistant-runtime.ts"],"mappings":";;;;;;KASY;;;;WAID,SAAS;;;;WAKT,QAAQ;;;;;;EAOjB,6BAA6B,UAAU,uBAAuB;;cAGnD,gCAAgC;WAC3B,SAAO;WAEP,SAAS;mBAER;EAEL,YAAA,OAAO;YAQT;MAKC,UAAM;EAIV,6BAA6B,UAAU,uBAAoB"}
@@ -1,9 +1,9 @@
1
1
  import { ThreadListRuntimeImpl } from "./thread-list-runtime.js";
2
2
  //#region src/runtime/api/assistant-runtime.ts
3
3
  var AssistantRuntimeImpl = class {
4
- _core;
5
4
  threads;
6
5
  _thread;
6
+ _core;
7
7
  constructor(_core) {
8
8
  this._core = _core;
9
9
  this.threads = new ThreadListRuntimeImpl(_core.threads);
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-runtime.js","names":["Unsubscribe","ModelContextProvider","AssistantRuntimeCore","ThreadRuntime","ThreadListRuntime","ThreadListRuntimeImpl","AssistantRuntime","threads","thread","registerModelContextProvider","provider","AssistantRuntimeImpl","_thread","constructor","_core","main","__internal_bindMethods","bind"],"sources":["../../../src/runtime/api/assistant-runtime.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport type { AssistantRuntimeCore } from \"../interfaces/assistant-runtime-core\";\nimport type { ThreadRuntime } from \"./thread-runtime\";\nimport {\n type ThreadListRuntime,\n ThreadListRuntimeImpl,\n} from \"./thread-list-runtime\";\n\nexport type AssistantRuntime = {\n /**\n * The threads in this assistant.\n */\n readonly threads: ThreadListRuntime;\n\n /**\n * The currently selected main thread. Equivalent to `threads.main`.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * Register a model context provider. Model context providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model context provider to register.\n */\n registerModelContextProvider(provider: ModelContextProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl implements AssistantRuntime {\n public readonly threads;\n\n public readonly _thread: ThreadRuntime;\n\n public constructor(private readonly _core: AssistantRuntimeCore) {\n this.threads = new ThreadListRuntimeImpl(_core.threads);\n this._thread = this.threads.main;\n\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.registerModelContextProvider =\n this.registerModelContextProvider.bind(this);\n }\n\n public get thread() {\n return this._thread;\n }\n\n public registerModelContextProvider(provider: ModelContextProvider) {\n return this._core.registerModelContextProvider(provider);\n }\n}\n"],"mappings":";;AA4BA,IAAaW,uBAAb,MAA8D;CAKxBG;CAJpC;CAEA;CAEA,YAAmB,OAA8C;EAA7BA,KAAAA,QAAAA;EAClC,KAAKP,UAAU,IAAIF,sBAAsBS,MAAMP,OAAO;EACtD,KAAKK,UAAU,KAAKL,QAAQQ;EAE5B,KAAKC,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAKP,+BACH,KAAKA,6BAA6BQ,KAAK,IAAI;CAC/C;CAEA,IAAWT,SAAS;EAClB,OAAO,KAAKI;CACd;CAEA,6BAAoCF,UAAgC;EAClE,OAAO,KAAKI,MAAML,6BAA6BC,QAAQ;CACzD;AACF"}
1
+ {"version":3,"file":"assistant-runtime.js","names":["Unsubscribe","ModelContextProvider","AssistantRuntimeCore","ThreadRuntime","ThreadListRuntime","ThreadListRuntimeImpl","AssistantRuntime","threads","thread","registerModelContextProvider","provider","AssistantRuntimeImpl","_thread","_core","constructor","main","__internal_bindMethods","bind"],"sources":["../../../src/runtime/api/assistant-runtime.ts"],"sourcesContent":["import type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { ModelContextProvider } from \"../../model-context/types\";\nimport type { AssistantRuntimeCore } from \"../interfaces/assistant-runtime-core\";\nimport type { ThreadRuntime } from \"./thread-runtime\";\nimport {\n type ThreadListRuntime,\n ThreadListRuntimeImpl,\n} from \"./thread-list-runtime\";\n\nexport type AssistantRuntime = {\n /**\n * The threads in this assistant.\n */\n readonly threads: ThreadListRuntime;\n\n /**\n * The currently selected main thread. Equivalent to `threads.main`.\n */\n readonly thread: ThreadRuntime;\n\n /**\n * Register a model context provider. Model context providers are configuration such as system message, temperature, etc. that are set in the frontend.\n *\n * @param provider The model context provider to register.\n */\n registerModelContextProvider(provider: ModelContextProvider): Unsubscribe;\n};\n\nexport class AssistantRuntimeImpl implements AssistantRuntime {\n public readonly threads;\n\n public readonly _thread: ThreadRuntime;\n\n private readonly _core: AssistantRuntimeCore;\n\n constructor(_core: AssistantRuntimeCore) {\n this._core = _core;\n this.threads = new ThreadListRuntimeImpl(_core.threads);\n this._thread = this.threads.main;\n\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.registerModelContextProvider =\n this.registerModelContextProvider.bind(this);\n }\n\n public get thread() {\n return this._thread;\n }\n\n public registerModelContextProvider(provider: ModelContextProvider) {\n return this._core.registerModelContextProvider(provider);\n }\n}\n"],"mappings":";;AA4BA,IAAaW,uBAAb,MAA8D;CAC5D;CAEA;CAEA;CAEAG,YAAYD,OAA6B;EACvC,KAAKA,QAAQA;EACb,KAAKN,UAAU,IAAIF,sBAAsBQ,MAAMN,OAAO;EACtD,KAAKK,UAAU,KAAKL,QAAQQ;EAE5B,KAAKC,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAKP,+BACH,KAAKA,6BAA6BQ,KAAK,IAAI;CAC/C;CAEA,IAAWT,SAAS;EAClB,OAAO,KAAKI;CACd;CAEA,6BAAoCF,UAAgC;EAClE,OAAO,KAAKG,MAAMJ,6BAA6BC,QAAQ;CACzD;AACF"}
@@ -32,11 +32,11 @@ type AttachmentRuntime<TSource extends AttachmentRuntimeSource = AttachmentRunti
32
32
  subscribe(callback: () => void): Unsubscribe;
33
33
  };
34
34
  declare abstract class AttachmentRuntimeImpl<Source extends AttachmentRuntimeSource = AttachmentRuntimeSource> implements AttachmentRuntime {
35
- private _core;
36
35
  get path(): AttachmentRuntimePath & {
37
36
  attachmentSource: Source;
38
37
  };
39
38
  abstract get source(): Source;
39
+ private _core;
40
40
  constructor(_core: AttachmentSnapshotBinding<Source>);
41
41
  protected __internal_bindMethods(): void;
42
42
  getState(): AttachmentState & {
@@ -1 +1 @@
1
- {"version":3,"file":"attachment-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/attachment-runtime.ts"],"mappings":";;;;;;KAOK,yBAAyB;WACnB;;KAGN,gCAAgC;WAC1B;;KAGN,8BAA8B;WACxB;;KAGC,kBACR,gCACA,8BACA;KAEC,0BAA0B,eAAe,2BAC5C,sBACE;EAAoB,QAAQ;GAC5B;EAA0B,kBAAkB;;KAG3C,0BAA0B;KAEnB,kBACV,gBAAgB,0BAA0B;WAEjC,MAAM;IAA0B,kBAAkB;;WAClD,QAAQ;EACjB,YAAY;IAAoB,QAAQ;;EACxC,UAAU;EACV,UAAU,uBAAuB;;uBAGb,sBACpB,eAAe,0BAA0B,oCAC9B;UAOS;MANT,QAAI;;;eAIK,UAAU;EAEV,YAAA,OAAO,0BAA0B;YAI3C;EAMH,YAAY;IAAoB,QAAQ;;WAI/B,UAAU;EAEnB,UAAU,uBAAoB;;uBAKxB,0BACb,4DACQ,sBAAsB;UAGpB;EADR,YAAA,MAAM,0BAA0B,SACxB,cAAc;EAKjB,UAAM;;cAOF,4CAA4C;MAC5C;;cAKA,0CAA0C;MAC1C;;cAKA,qCAAqC;MACrC;EAIJ"}
1
+ {"version":3,"file":"attachment-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/attachment-runtime.ts"],"mappings":";;;;;;KAOK,yBAAyB;WACnB;;KAGN,gCAAgC;WAC1B;;KAGN,8BAA8B;WACxB;;KAGC,kBACR,gCACA,8BACA;KAEC,0BAA0B,eAAe,2BAC5C,sBACE;EAAoB,QAAQ;GAC5B;EAA0B,kBAAkB;;KAG3C,0BAA0B;KAEnB,kBACV,gBAAgB,0BAA0B;WAEjC,MAAM;IAA0B,kBAAkB;;WAClD,QAAQ;EACjB,YAAY;IAAoB,QAAQ;;EACxC,UAAU;EACV,UAAU,uBAAuB;;uBAGb,sBACpB,eAAe,0BAA0B,oCAC9B;MACA,QAAI;;;eAIK,UAAU;UAEtB;EAEI,YAAA,OAAO,0BAA0B;YAKnC;EAMH,YAAY;IAAoB,QAAQ;;WAI/B,UAAU;EAEnB,UAAU,uBAAoB;;uBAKxB,0BACb,4DACQ,sBAAsB;UACtB;EAGN,YAAA,MAAM,0BAA0B,SAChC,cAAc;EAMT,UAAM;;cAOF,4CAA4C;MAC5C;;cAKA,0CAA0C;MAC1C;;cAKA,qCAAqC;MACrC;EAIJ"}
@@ -1,9 +1,9 @@
1
1
  //#region src/runtime/api/attachment-runtime.ts
2
2
  var AttachmentRuntimeImpl = class {
3
- _core;
4
3
  get path() {
5
4
  return this._core.path;
6
5
  }
6
+ _core;
7
7
  constructor(_core) {
8
8
  this._core = _core;
9
9
  this.__internal_bindMethods();
@@ -1 +1 @@
1
- {"version":3,"file":"attachment-runtime.js","names":["Attachment","CompleteAttachment","Unsubscribe","SubscribableWithState","ComposerRuntimeCoreBinding","AttachmentRuntimePath","MessageAttachmentState","source","ThreadComposerAttachmentState","EditComposerAttachmentState","AttachmentState","AttachmentSnapshotBinding","AttachmentRuntimeSource","Source","attachmentSource","AttachmentRuntime","path","TSource","getState","remove","Promise","subscribe","callback","AttachmentRuntimeImpl","_core","constructor","__internal_bindMethods","bind","ComposerAttachmentRuntime","core","_composerApi","Error","removeAttachment","id","ThreadComposerAttachmentRuntimeImpl","EditComposerAttachmentRuntimeImpl","MessageAttachmentRuntimeImpl"],"sources":["../../../src/runtime/api/attachment-runtime.ts"],"sourcesContent":["import type { Attachment, CompleteAttachment } from \"../../types/attachment\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { SubscribableWithState } from \"../../subscribable/subscribable\";\n\nimport type { ComposerRuntimeCoreBinding } from \"./bindings\";\nimport type { AttachmentRuntimePath } from \"./paths\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n readonly source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = Attachment & {\n readonly source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n readonly source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n readonly path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n constructor(private _core: AttachmentSnapshotBinding<Source>) {\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.getState = this.getState.bind(this);\n this.remove = this.remove.bind(this);\n this.subscribe = this.subscribe.bind(this);\n }\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n private _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";AA0CA,IAAsBuB,wBAAtB,MAE+B;CAOTC;CANpB,IAAWR,OAAO;EAChB,OAAO,KAAKQ,MAAMR;CACpB;CAIAS,YAAY,OAAkD;EAA1CD,KAAAA,QAAAA;EAClB,KAAKE,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAKR,WAAW,KAAKA,SAASS,KAAK,IAAI;EACvC,KAAKR,SAAS,KAAKA,OAAOQ,KAAK,IAAI;EACnC,KAAKN,YAAY,KAAKA,UAAUM,KAAK,IAAI;CAC3C;CAEA,WAAwD;EACtD,OAAO,KAAKH,MAAMN,SAAS;CAC7B;CAIA,UAAiBI,UAAsB;EACrC,OAAO,KAAKE,MAAMH,UAAUC,QAAQ;CACtC;AACF;AAEA,IAAeM,4BAAf,cAEUL,sBAA8B;CAG5BO;CAFVL,YACEI,MACA,cACA;EACA,MAAMA,IAAI;EAFFC,KAAAA,eAAAA;CAGV;CAEA,SAAgB;EACd,MAAMD,OAAO,KAAKC,aAAaZ,SAAS;EACxC,IAAI,CAACW,MAAM,MAAM,IAAIE,MAAM,2BAA2B;EACtD,OAAOF,KAAKG,iBAAiB,KAAKd,SAAS,CAAC,CAACe,EAAE;CACjD;AACF;AAEA,IAAaC,sCAAb,cAAyDN,0BAA6C;CACpG,IAAWrB,SAA4B;EACrC,OAAO;CACT;AACF;AAEA,IAAa4B,oCAAb,cAAuDP,0BAA2C;CAChG,IAAWrB,SAA0B;EACnC,OAAO;CACT;AACF;AAEA,IAAa6B,+BAAb,cAAkDb,sBAAiC;CACjF,IAAWhB,SAAoB;EAC7B,OAAO;CACT;CAEA,SAAuB;EACrB,MAAM,IAAIwB,MAAM,uCAAuC;CACzD;AACF"}
1
+ {"version":3,"file":"attachment-runtime.js","names":["Attachment","CompleteAttachment","Unsubscribe","SubscribableWithState","ComposerRuntimeCoreBinding","AttachmentRuntimePath","MessageAttachmentState","source","ThreadComposerAttachmentState","EditComposerAttachmentState","AttachmentState","AttachmentSnapshotBinding","AttachmentRuntimeSource","Source","attachmentSource","AttachmentRuntime","path","TSource","getState","remove","Promise","subscribe","callback","AttachmentRuntimeImpl","_core","constructor","__internal_bindMethods","bind","ComposerAttachmentRuntime","_composerApi","core","Error","removeAttachment","id","ThreadComposerAttachmentRuntimeImpl","EditComposerAttachmentRuntimeImpl","MessageAttachmentRuntimeImpl"],"sources":["../../../src/runtime/api/attachment-runtime.ts"],"sourcesContent":["import type { Attachment, CompleteAttachment } from \"../../types/attachment\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { SubscribableWithState } from \"../../subscribable/subscribable\";\n\nimport type { ComposerRuntimeCoreBinding } from \"./bindings\";\nimport type { AttachmentRuntimePath } from \"./paths\";\n\ntype MessageAttachmentState = CompleteAttachment & {\n readonly source: \"message\";\n};\n\ntype ThreadComposerAttachmentState = Attachment & {\n readonly source: \"thread-composer\";\n};\n\ntype EditComposerAttachmentState = Attachment & {\n readonly source: \"edit-composer\";\n};\n\nexport type AttachmentState =\n | ThreadComposerAttachmentState\n | EditComposerAttachmentState\n | MessageAttachmentState;\n\ntype AttachmentSnapshotBinding<Source extends AttachmentRuntimeSource> =\n SubscribableWithState<\n AttachmentState & { source: Source },\n AttachmentRuntimePath & { attachmentSource: Source }\n >;\n\ntype AttachmentRuntimeSource = AttachmentState[\"source\"];\n\nexport type AttachmentRuntime<\n TSource extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> = {\n readonly path: AttachmentRuntimePath & { attachmentSource: TSource };\n readonly source: TSource;\n getState(): AttachmentState & { source: TSource };\n remove(): Promise<void>;\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport abstract class AttachmentRuntimeImpl<\n Source extends AttachmentRuntimeSource = AttachmentRuntimeSource,\n> implements AttachmentRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get source(): Source;\n\n private _core: AttachmentSnapshotBinding<Source>;\n\n constructor(_core: AttachmentSnapshotBinding<Source>) {\n this._core = _core;\n this.__internal_bindMethods();\n }\n\n protected __internal_bindMethods() {\n this.getState = this.getState.bind(this);\n this.remove = this.remove.bind(this);\n this.subscribe = this.subscribe.bind(this);\n }\n\n public getState(): AttachmentState & { source: Source } {\n return this._core.getState();\n }\n\n public abstract remove(): Promise<void>;\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n}\n\nabstract class ComposerAttachmentRuntime<\n Source extends \"thread-composer\" | \"edit-composer\",\n> extends AttachmentRuntimeImpl<Source> {\n private _composerApi: ComposerRuntimeCoreBinding;\n\n constructor(\n core: AttachmentSnapshotBinding<Source>,\n _composerApi: ComposerRuntimeCoreBinding,\n ) {\n super(core);\n this._composerApi = _composerApi;\n }\n\n public remove() {\n const core = this._composerApi.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.removeAttachment(this.getState().id);\n }\n}\n\nexport class ThreadComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"thread-composer\"> {\n public get source(): \"thread-composer\" {\n return \"thread-composer\";\n }\n}\n\nexport class EditComposerAttachmentRuntimeImpl extends ComposerAttachmentRuntime<\"edit-composer\"> {\n public get source(): \"edit-composer\" {\n return \"edit-composer\";\n }\n}\n\nexport class MessageAttachmentRuntimeImpl extends AttachmentRuntimeImpl<\"message\"> {\n public get source(): \"message\" {\n return \"message\";\n }\n\n public remove(): never {\n throw new Error(\"Message attachments cannot be removed\");\n }\n}\n"],"mappings":";AA0CA,IAAsBuB,wBAAtB,MAE+B;CAC7B,IAAWP,OAAO;EAChB,OAAO,KAAKQ,MAAMR;CACpB;CAIA;CAEAS,YAAYD,OAA0C;EACpD,KAAKA,QAAQA;EACb,KAAKE,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAKR,WAAW,KAAKA,SAASS,KAAK,IAAI;EACvC,KAAKR,SAAS,KAAKA,OAAOQ,KAAK,IAAI;EACnC,KAAKN,YAAY,KAAKA,UAAUM,KAAK,IAAI;CAC3C;CAEA,WAAwD;EACtD,OAAO,KAAKH,MAAMN,SAAS;CAC7B;CAIA,UAAiBI,UAAsB;EACrC,OAAO,KAAKE,MAAMH,UAAUC,QAAQ;CACtC;AACF;AAEA,IAAeM,4BAAf,cAEUL,sBAA8B;CACtC;CAEAE,YACEK,MACAD,cACA;EACA,MAAMC,IAAI;EACV,KAAKD,eAAeA;CACtB;CAEA,SAAgB;EACd,MAAMC,OAAO,KAAKD,aAAaX,SAAS;EACxC,IAAI,CAACY,MAAM,MAAM,IAAIC,MAAM,2BAA2B;EACtD,OAAOD,KAAKE,iBAAiB,KAAKd,SAAS,CAAC,CAACe,EAAE;CACjD;AACF;AAEA,IAAaC,sCAAb,cAAyDN,0BAA6C;CACpG,IAAWrB,SAA4B;EACrC,OAAO;CACT;AACF;AAEA,IAAa4B,oCAAb,cAAuDP,0BAA2C;CAChG,IAAWrB,SAA0B;EACnC,OAAO;CACT;AACF;AAEA,IAAa6B,+BAAb,cAAkDb,sBAAiC;CACjF,IAAWhB,SAAoB;EAC7B,OAAO;CACT;CAEA,SAAuB;EACrB,MAAM,IAAIwB,MAAM,uCAAuC;CACzD;AACF"}
@@ -130,9 +130,9 @@ type ComposerRuntime = {
130
130
  unstable_on<E extends ComposerRuntimeEventType>(event: E, callback: ComposerRuntimeEventCallback<E>): Unsubscribe;
131
131
  };
132
132
  declare abstract class ComposerRuntimeImpl implements ComposerRuntime {
133
- protected _core: ComposerRuntimeCoreBinding;
134
133
  get path(): ComposerRuntimePath;
135
134
  abstract get type(): "edit" | "thread";
135
+ protected _core: ComposerRuntimeCoreBinding;
136
136
  constructor(_core: ComposerRuntimeCoreBinding);
137
137
  protected __internal_bindMethods(): void;
138
138
  abstract getState(): ComposerState;
@@ -186,12 +186,12 @@ type EditComposerRuntime = Omit<ComposerRuntime, "getState" | "getAttachmentByIn
186
186
  };
187
187
  };
188
188
  declare class EditComposerRuntimeImpl extends ComposerRuntimeImpl implements EditComposerRuntime {
189
- private _beginEdit;
190
189
  get path(): ComposerRuntimePath & {
191
190
  composerSource: "edit";
192
191
  };
193
192
  get type(): "edit";
194
193
  private _getState;
194
+ private _beginEdit;
195
195
  constructor(core: EditComposerRuntimeCoreBinding, _beginEdit: () => void);
196
196
  __internal_bindMethods(): void;
197
197
  getState(): EditComposerState;
@@ -1 +1 @@
1
- {"version":3,"file":"composer-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/composer-runtime.ts"],"mappings":";;;;;;;;;;KA0CK;WACM;WACA;WACA;WACA;WAEA;WACA,MAAM;WACN,sBAAsB;WACtB,WAAW;WAEX;;;;;WAMA,WAAW;;;;;WAMX,OAAO;;WAGP,gBAAgB;;KAGf,sBAAsB;WACvB;;KAGC,oBAAoB;WACrB;WACA;WACA;;KAGC,gBAAgB,sBAAsB;KAuDtC;WACD,MAAM;WACN;;;;EAKT,YAAY;;;;;;;;;;EAWZ,cAAc,kBAAkB,OAAO,mBAAmB;;;;;EAM1D,QAAQ;;;;;EAMR,QAAQ,MAAM;;;;;;;;;;;;EAad,aAAa,WAAW;;;;EAKxB,SAAS;;;;EAKT,oB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ACA;EAEI,YAAA,MAAM,gCAAgC;EAmBlC;EAKA,YAAY;EAIrB;EAIA,qBAAqB,cAAW"}
@@ -42,10 +42,10 @@ const getEditComposerState = (runtime) => {
42
42
  });
43
43
  };
44
44
  var ComposerRuntimeImpl = class {
45
- _core;
46
45
  get path() {
47
46
  return this._core.path;
48
47
  }
48
+ _core;
49
49
  constructor(_core) {
50
50
  this._core = _core;
51
51
  }
@@ -198,7 +198,6 @@ var ThreadComposerRuntimeImpl = class extends ComposerRuntimeImpl {
198
198
  }
199
199
  };
200
200
  var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
201
- _beginEdit;
202
201
  get path() {
203
202
  return this._core.path;
204
203
  }
@@ -206,6 +205,7 @@ var EditComposerRuntimeImpl = class extends ComposerRuntimeImpl {
206
205
  return "edit";
207
206
  }
208
207
  _getState;
208
+ _beginEdit;
209
209
  constructor(core, _beginEdit) {
210
210
  const stateBinding = new LazyMemoizeSubject({
211
211
  path: core.path,