@assistant-ui/core 0.2.12 → 0.2.15

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 (445) hide show
  1. package/dist/adapters/attachment.js.map +1 -1
  2. package/dist/adapters/directive-formatter.js.map +1 -1
  3. package/dist/adapters/speech.js.map +1 -1
  4. package/dist/adapters/thread-history.d.ts +3 -1
  5. package/dist/adapters/thread-history.d.ts.map +1 -1
  6. package/dist/adapters/voice.js.map +1 -1
  7. package/dist/index.d.ts +3 -2
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/duplicate-detection.js.map +1 -1
  10. package/dist/internal.d.ts +2 -1
  11. package/dist/internal.js +2 -1
  12. package/dist/model-context/frame/host.js.map +1 -1
  13. package/dist/model-context/frame/provider.js.map +1 -1
  14. package/dist/model-context/frame/types.js.map +1 -1
  15. package/dist/model-context/registry.js.map +1 -1
  16. package/dist/model-context/tool.js.map +1 -1
  17. package/dist/model-context/types.d.ts +1 -0
  18. package/dist/model-context/types.d.ts.map +1 -1
  19. package/dist/model-context/types.js.map +1 -1
  20. package/dist/react/AssistantProvider.js +7 -1
  21. package/dist/react/AssistantProvider.js.map +1 -1
  22. package/dist/react/AssistantRuntimeProvider.js +18 -6
  23. package/dist/react/AssistantRuntimeProvider.js.map +1 -1
  24. package/dist/react/RuntimeAdapter.d.ts +1 -1
  25. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  26. package/dist/react/RuntimeAdapter.js +35 -6
  27. package/dist/react/RuntimeAdapter.js.map +1 -1
  28. package/dist/react/adapters/LocalStorageThreadListAdapter.js +29 -7
  29. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  30. package/dist/react/adapters/TitleGenerationAdapter.js.map +1 -1
  31. package/dist/react/client/DataRenderers.d.ts +1 -8
  32. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  33. package/dist/react/client/DataRenderers.js +56 -36
  34. package/dist/react/client/DataRenderers.js.map +1 -1
  35. package/dist/react/client/Interactables.d.ts +1 -1
  36. package/dist/react/client/Interactables.d.ts.map +1 -1
  37. package/dist/react/client/Interactables.js +71 -70
  38. package/dist/react/client/Interactables.js.map +1 -1
  39. package/dist/react/client/Tools.d.ts +2 -13
  40. package/dist/react/client/Tools.d.ts.map +1 -1
  41. package/dist/react/client/Tools.js +121 -57
  42. package/dist/react/client/Tools.js.map +1 -1
  43. package/dist/react/client/interactable-model-context.js.map +1 -1
  44. package/dist/react/model-context/define-mcp-toolkit.js.map +1 -1
  45. package/dist/react/model-context/define-toolkit.js.map +1 -1
  46. package/dist/react/model-context/external-tool.js.map +1 -1
  47. package/dist/react/model-context/human-tool.js.map +1 -1
  48. package/dist/react/model-context/makeAssistantDataUI.js.map +1 -1
  49. package/dist/react/model-context/makeAssistantTool.js.map +1 -1
  50. package/dist/react/model-context/makeAssistantToolUI.js.map +1 -1
  51. package/dist/react/model-context/provider-tool.js.map +1 -1
  52. package/dist/react/model-context/stub-tool.js.map +1 -1
  53. package/dist/react/model-context/toolbox.js.map +1 -1
  54. package/dist/react/model-context/useAssistantContext.js.map +1 -1
  55. package/dist/react/model-context/useAssistantDataUI.js +27 -8
  56. package/dist/react/model-context/useAssistantDataUI.js.map +1 -1
  57. package/dist/react/model-context/useAssistantInstructions.js +33 -10
  58. package/dist/react/model-context/useAssistantInstructions.js.map +1 -1
  59. package/dist/react/model-context/useAssistantInteractable.js.map +1 -1
  60. package/dist/react/model-context/useAssistantTool.js +59 -17
  61. package/dist/react/model-context/useAssistantTool.js.map +1 -1
  62. package/dist/react/model-context/useAssistantToolUI.js +30 -9
  63. package/dist/react/model-context/useAssistantToolUI.js.map +1 -1
  64. package/dist/react/model-context/useAuiToolOverrides.js.map +1 -1
  65. package/dist/react/model-context/useInlineRender.js +35 -8
  66. package/dist/react/model-context/useInlineRender.js.map +1 -1
  67. package/dist/react/model-context/useInteractableState.js +65 -19
  68. package/dist/react/model-context/useInteractableState.js.map +1 -1
  69. package/dist/react/model-context/useToolArgsStatus.js +42 -14
  70. package/dist/react/model-context/useToolArgsStatus.js.map +1 -1
  71. package/dist/react/primitive-hooks/useActionBarCopy.js +59 -22
  72. package/dist/react/primitive-hooks/useActionBarCopy.js.map +1 -1
  73. package/dist/react/primitive-hooks/useActionBarEdit.js +25 -7
  74. package/dist/react/primitive-hooks/useActionBarEdit.js.map +1 -1
  75. package/dist/react/primitive-hooks/useActionBarFeedback.js +49 -13
  76. package/dist/react/primitive-hooks/useActionBarFeedback.js.map +1 -1
  77. package/dist/react/primitive-hooks/useActionBarReload.js +25 -7
  78. package/dist/react/primitive-hooks/useActionBarReload.js.map +1 -1
  79. package/dist/react/primitive-hooks/useActionBarSpeak.js +28 -9
  80. package/dist/react/primitive-hooks/useActionBarSpeak.js.map +1 -1
  81. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js +25 -7
  82. package/dist/react/primitive-hooks/useActionBarStopSpeaking.js.map +1 -1
  83. package/dist/react/primitive-hooks/useBranchPickerNext.js +27 -11
  84. package/dist/react/primitive-hooks/useBranchPickerNext.js.map +1 -1
  85. package/dist/react/primitive-hooks/useBranchPickerPrevious.js +27 -11
  86. package/dist/react/primitive-hooks/useBranchPickerPrevious.js.map +1 -1
  87. package/dist/react/primitive-hooks/useComposerAddAttachment.js +24 -8
  88. package/dist/react/primitive-hooks/useComposerAddAttachment.js.map +1 -1
  89. package/dist/react/primitive-hooks/useComposerCancel.js +25 -7
  90. package/dist/react/primitive-hooks/useComposerCancel.js.map +1 -1
  91. package/dist/react/primitive-hooks/useComposerDictate.js +25 -7
  92. package/dist/react/primitive-hooks/useComposerDictate.js.map +1 -1
  93. package/dist/react/primitive-hooks/useComposerSend.js +25 -7
  94. package/dist/react/primitive-hooks/useComposerSend.js.map +1 -1
  95. package/dist/react/primitive-hooks/useEditComposerCancel.js +18 -4
  96. package/dist/react/primitive-hooks/useEditComposerCancel.js.map +1 -1
  97. package/dist/react/primitive-hooks/useEditComposerSend.js +25 -7
  98. package/dist/react/primitive-hooks/useEditComposerSend.js.map +1 -1
  99. package/dist/react/primitive-hooks/useMessageBranching.js +41 -9
  100. package/dist/react/primitive-hooks/useMessageBranching.js.map +1 -1
  101. package/dist/react/primitive-hooks/useMessageError.js +4 -1
  102. package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
  103. package/dist/react/primitive-hooks/useMessageReload.js +25 -7
  104. package/dist/react/primitive-hooks/useMessageReload.js.map +1 -1
  105. package/dist/react/primitive-hooks/useSuggestionTrigger.js +31 -13
  106. package/dist/react/primitive-hooks/useSuggestionTrigger.js.map +1 -1
  107. package/dist/react/primitive-hooks/useThreadIsEmpty.js +4 -1
  108. package/dist/react/primitive-hooks/useThreadIsEmpty.js.map +1 -1
  109. package/dist/react/primitive-hooks/useThreadIsRunning.js +4 -1
  110. package/dist/react/primitive-hooks/useThreadIsRunning.js.map +1 -1
  111. package/dist/react/primitive-hooks/useThreadListItemArchive.js +18 -4
  112. package/dist/react/primitive-hooks/useThreadListItemArchive.js.map +1 -1
  113. package/dist/react/primitive-hooks/useThreadListItemDelete.js +18 -4
  114. package/dist/react/primitive-hooks/useThreadListItemDelete.js.map +1 -1
  115. package/dist/react/primitive-hooks/useThreadListItemTrigger.js +18 -4
  116. package/dist/react/primitive-hooks/useThreadListItemTrigger.js.map +1 -1
  117. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js +18 -4
  118. package/dist/react/primitive-hooks/useThreadListItemUnarchive.js.map +1 -1
  119. package/dist/react/primitive-hooks/useThreadListLoadMore.js +25 -7
  120. package/dist/react/primitive-hooks/useThreadListLoadMore.js.map +1 -1
  121. package/dist/react/primitive-hooks/useThreadListNew.js +18 -4
  122. package/dist/react/primitive-hooks/useThreadListNew.js.map +1 -1
  123. package/dist/react/primitive-hooks/useThreadMessages.js +4 -1
  124. package/dist/react/primitive-hooks/useThreadMessages.js.map +1 -1
  125. package/dist/react/primitive-hooks/useVoice.js +63 -13
  126. package/dist/react/primitive-hooks/useVoice.js.map +1 -1
  127. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js +42 -7
  128. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.js.map +1 -1
  129. package/dist/react/primitives/composer/ComposerAttachments.js +67 -16
  130. package/dist/react/primitives/composer/ComposerAttachments.js.map +1 -1
  131. package/dist/react/primitives/composer/ComposerIf.js +30 -9
  132. package/dist/react/primitives/composer/ComposerIf.js.map +1 -1
  133. package/dist/react/primitives/composer/ComposerQueue.js.map +1 -1
  134. package/dist/react/primitives/generativeUI/GenerativeUI.js +55 -13
  135. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  136. package/dist/react/primitives/message/MessageAttachments.js +68 -16
  137. package/dist/react/primitives/message/MessageAttachments.js.map +1 -1
  138. package/dist/react/primitives/message/MessageGroupedParts.d.ts +3 -2
  139. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  140. package/dist/react/primitives/message/MessageGroupedParts.js +6 -6
  141. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  142. package/dist/react/primitives/message/MessageParts.d.ts +28 -1
  143. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  144. package/dist/react/primitives/message/MessageParts.js +665 -163
  145. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  146. package/dist/react/primitives/message/MessageQuote.js +18 -2
  147. package/dist/react/primitives/message/MessageQuote.js.map +1 -1
  148. package/dist/react/primitives/messagePart/MessagePartInProgress.js +6 -2
  149. package/dist/react/primitives/messagePart/MessagePartInProgress.js.map +1 -1
  150. package/dist/react/primitives/part/PartMessages.js +46 -14
  151. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  152. package/dist/react/primitives/thread/ThreadMessages.js +67 -10
  153. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  154. package/dist/react/primitives/thread/ThreadSuggestions.js +50 -10
  155. package/dist/react/primitives/thread/ThreadSuggestions.js.map +1 -1
  156. package/dist/react/primitives/threadList/ThreadListItems.js +55 -14
  157. package/dist/react/primitives/threadList/ThreadListItems.js.map +1 -1
  158. package/dist/react/primitives/threadListItem/ThreadListItemTitle.js +15 -2
  159. package/dist/react/primitives/threadListItem/ThreadListItemTitle.js.map +1 -1
  160. package/dist/react/providers/AttachmentByIndexProvider.js +57 -12
  161. package/dist/react/providers/AttachmentByIndexProvider.js.map +1 -1
  162. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js +33 -11
  163. package/dist/react/providers/ChainOfThoughtByIndicesProvider.js.map +1 -1
  164. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js +29 -6
  165. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.js.map +1 -1
  166. package/dist/react/providers/MessageByIndexProvider.js +49 -19
  167. package/dist/react/providers/MessageByIndexProvider.js.map +1 -1
  168. package/dist/react/providers/PartByIndexProvider.js +29 -6
  169. package/dist/react/providers/PartByIndexProvider.js.map +1 -1
  170. package/dist/react/providers/QueueItemByIndexProvider.js +29 -6
  171. package/dist/react/providers/QueueItemByIndexProvider.js.map +1 -1
  172. package/dist/react/providers/ReadonlyThreadProvider.js +83 -28
  173. package/dist/react/providers/ReadonlyThreadProvider.js.map +1 -1
  174. package/dist/react/providers/SuggestionByIndexProvider.js +29 -6
  175. package/dist/react/providers/SuggestionByIndexProvider.js.map +1 -1
  176. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  177. package/dist/react/providers/TextMessagePartProvider.js +75 -26
  178. package/dist/react/providers/TextMessagePartProvider.js.map +1 -1
  179. package/dist/react/providers/ThreadListItemByIndexProvider.js +30 -6
  180. package/dist/react/providers/ThreadListItemByIndexProvider.js.map +1 -1
  181. package/dist/react/providers/ThreadListItemRuntimeProvider.js +28 -5
  182. package/dist/react/providers/ThreadListItemRuntimeProvider.js.map +1 -1
  183. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -0
  184. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  185. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +19 -4
  186. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  187. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +2 -0
  188. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  189. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +1 -0
  190. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  191. package/dist/react/runtimes/RuntimeAdapterProvider.js +27 -10
  192. package/dist/react/runtimes/RuntimeAdapterProvider.js.map +1 -1
  193. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  194. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +16 -1
  195. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  196. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  197. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  198. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  199. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js +19 -17
  200. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.js.map +1 -1
  201. package/dist/react/runtimes/createMessageConverter.js.map +1 -1
  202. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  203. package/dist/react/runtimes/external-message-converter.js +67 -30
  204. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  205. package/dist/react/runtimes/useExternalStoreRuntime.js +44 -10
  206. package/dist/react/runtimes/useExternalStoreRuntime.js.map +1 -1
  207. package/dist/react/runtimes/useExternalStoreSharedOptions.js +17 -12
  208. package/dist/react/runtimes/useExternalStoreSharedOptions.js.map +1 -1
  209. package/dist/react/runtimes/useLocalRuntime.js.map +1 -1
  210. package/dist/react/runtimes/useRemoteThreadListRuntime.js +34 -6
  211. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  212. package/dist/react/types/MessagePartComponentTypes.d.ts +5 -6
  213. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
  214. package/dist/react/utils/getMessageQuote.js.map +1 -1
  215. package/dist/react/utils/groupParts.d.ts +13 -1
  216. package/dist/react/utils/groupParts.d.ts.map +1 -1
  217. package/dist/react/utils/groupParts.js +17 -5
  218. package/dist/react/utils/groupParts.js.map +1 -1
  219. package/dist/runtime/api/assistant-runtime.js.map +1 -1
  220. package/dist/runtime/api/attachment-runtime.js.map +1 -1
  221. package/dist/runtime/api/bindings.d.ts +1 -0
  222. package/dist/runtime/api/bindings.d.ts.map +1 -1
  223. package/dist/runtime/api/composer-runtime.js.map +1 -1
  224. package/dist/runtime/api/message-part-runtime.d.ts +3 -9
  225. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  226. package/dist/runtime/api/message-part-runtime.js +3 -6
  227. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  228. package/dist/runtime/api/message-runtime.d.ts +2 -0
  229. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  230. package/dist/runtime/api/message-runtime.js +5 -0
  231. package/dist/runtime/api/message-runtime.js.map +1 -1
  232. package/dist/runtime/api/thread-list-item-runtime.js.map +1 -1
  233. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  234. package/dist/runtime/api/thread-list-runtime.js +1 -0
  235. package/dist/runtime/api/thread-list-runtime.js.map +1 -1
  236. package/dist/runtime/api/thread-runtime.d.ts +3 -0
  237. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  238. package/dist/runtime/api/thread-runtime.js +4 -0
  239. package/dist/runtime/api/thread-runtime.js.map +1 -1
  240. package/dist/runtime/base/base-assistant-runtime-core.js.map +1 -1
  241. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  242. package/dist/runtime/base/base-thread-runtime-core.d.ts +1 -0
  243. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  244. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  245. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  246. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  247. package/dist/runtime/branch/external-thread-branch-adapter.d.ts +30 -0
  248. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -0
  249. package/dist/runtime/branch/external-thread-branch-adapter.js +0 -0
  250. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +1 -0
  251. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  252. package/dist/runtime/interfaces/thread-runtime-core.d.ts +4 -1
  253. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  254. package/dist/runtime/queue/message-queue.js.map +1 -1
  255. package/dist/runtime/utils/auto-status.js.map +1 -1
  256. package/dist/runtime/utils/external-store-message.js.map +1 -1
  257. package/dist/runtime/utils/message-repository.js.map +1 -1
  258. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +15 -0
  259. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -0
  260. package/dist/runtime/utils/resolveToolApprovalResponse.js +35 -0
  261. package/dist/runtime/utils/resolveToolApprovalResponse.js.map +1 -0
  262. package/dist/runtime/utils/thread-message-like.d.ts +5 -1
  263. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  264. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  265. package/dist/runtimes/assistant-transport/utils.js.map +1 -1
  266. package/dist/runtimes/external-store/external-store-adapter.d.ts +1 -0
  267. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  268. package/dist/runtimes/external-store/external-store-runtime-core.js.map +1 -1
  269. package/dist/runtimes/external-store/external-store-shared-options.js.map +1 -1
  270. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.js.map +1 -1
  271. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +1 -0
  272. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  273. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +13 -0
  274. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  275. package/dist/runtimes/external-store/thread-message-converter.js.map +1 -1
  276. package/dist/runtimes/local/local-runtime-core.js.map +1 -1
  277. package/dist/runtimes/local/local-runtime-options.d.ts +1 -1
  278. package/dist/runtimes/local/local-thread-list-runtime-core.js.map +1 -1
  279. package/dist/runtimes/local/local-thread-runtime-core.d.ts +9 -1
  280. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  281. package/dist/runtimes/local/local-thread-runtime-core.js +65 -5
  282. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  283. package/dist/runtimes/local/should-continue.js +4 -2
  284. package/dist/runtimes/local/should-continue.js.map +1 -1
  285. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +2 -0
  286. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  287. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js +4 -0
  288. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.js.map +1 -1
  289. package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
  290. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  291. package/dist/runtimes/remote-thread-list/empty-thread-core.js +4 -0
  292. package/dist/runtimes/remote-thread-list/empty-thread-core.js.map +1 -1
  293. package/dist/runtimes/remote-thread-list/optimistic-state.js.map +1 -1
  294. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +1 -0
  295. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  296. package/dist/runtimes/remote-thread-list/remote-thread-state.js +1 -0
  297. package/dist/runtimes/remote-thread-list/remote-thread-state.js.map +1 -1
  298. package/dist/runtimes/remote-thread-list/types.d.ts +1 -0
  299. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  300. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  301. package/dist/store/clients/chain-of-thought-client.d.ts +2 -7
  302. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  303. package/dist/store/clients/chain-of-thought-client.js +39 -20
  304. package/dist/store/clients/chain-of-thought-client.js.map +1 -1
  305. package/dist/store/clients/model-context-client.d.ts +1 -1
  306. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  307. package/dist/store/clients/model-context-client.js +67 -16
  308. package/dist/store/clients/model-context-client.js.map +1 -1
  309. package/dist/store/clients/no-op-composer-client.d.ts +2 -4
  310. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  311. package/dist/store/clients/no-op-composer-client.js +96 -54
  312. package/dist/store/clients/no-op-composer-client.js.map +1 -1
  313. package/dist/store/clients/runtime-adapter.d.ts +1 -3
  314. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  315. package/dist/store/clients/runtime-adapter.js +2 -15
  316. package/dist/store/clients/runtime-adapter.js.map +1 -1
  317. package/dist/store/clients/suggestions.d.ts +1 -4
  318. package/dist/store/clients/suggestions.d.ts.map +1 -1
  319. package/dist/store/clients/suggestions.js +63 -23
  320. package/dist/store/clients/suggestions.js.map +1 -1
  321. package/dist/store/clients/thread-message-client.d.ts +1 -1
  322. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  323. package/dist/store/clients/thread-message-client.js +184 -73
  324. package/dist/store/clients/thread-message-client.js.map +1 -1
  325. package/dist/store/internal.d.ts +2 -2
  326. package/dist/store/internal.js +2 -2
  327. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +2 -4
  328. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  329. package/dist/store/runtime-clients/attachment-runtime-client.js +31 -7
  330. package/dist/store/runtime-clients/attachment-runtime-client.js.map +1 -1
  331. package/dist/store/runtime-clients/composer-runtime-client.d.ts +2 -10
  332. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  333. package/dist/store/runtime-clients/composer-runtime-client.js +195 -72
  334. package/dist/store/runtime-clients/composer-runtime-client.js.map +1 -1
  335. package/dist/store/runtime-clients/liveRef.d.ts +7 -0
  336. package/dist/store/runtime-clients/liveRef.d.ts.map +1 -0
  337. package/dist/store/runtime-clients/liveRef.js +8 -0
  338. package/dist/store/runtime-clients/liveRef.js.map +1 -0
  339. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +2 -4
  340. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  341. package/dist/store/runtime-clients/message-part-runtime-client.js +49 -9
  342. package/dist/store/runtime-clients/message-part-runtime-client.js.map +1 -1
  343. package/dist/store/runtime-clients/message-runtime-client.d.ts +2 -7
  344. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  345. package/dist/store/runtime-clients/message-runtime-client.js +220 -54
  346. package/dist/store/runtime-clients/message-runtime-client.js.map +1 -1
  347. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +2 -4
  348. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  349. package/dist/store/runtime-clients/thread-list-item-runtime-client.js +71 -26
  350. package/dist/store/runtime-clients/thread-list-item-runtime-client.js.map +1 -1
  351. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +2 -5
  352. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  353. package/dist/store/runtime-clients/thread-list-runtime-client.js +141 -36
  354. package/dist/store/runtime-clients/thread-list-runtime-client.js.map +1 -1
  355. package/dist/store/runtime-clients/thread-runtime-client.d.ts +2 -4
  356. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  357. package/dist/store/runtime-clients/thread-runtime-client.js +196 -72
  358. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  359. package/dist/store/runtime-clients/useSubscribable.js +2 -9
  360. package/dist/store/runtime-clients/useSubscribable.js.map +1 -1
  361. package/dist/store/scopes/message.d.ts +1 -0
  362. package/dist/store/scopes/message.d.ts.map +1 -1
  363. package/dist/store/scopes/part.d.ts +5 -6
  364. package/dist/store/scopes/part.d.ts.map +1 -1
  365. package/dist/store/scopes/queue-item.js.map +1 -1
  366. package/dist/store/scopes/thread-list-item.d.ts +1 -0
  367. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  368. package/dist/store/scopes/thread.d.ts +1 -0
  369. package/dist/store/scopes/thread.d.ts.map +1 -1
  370. package/dist/subscribable/subscribable.js.map +1 -1
  371. package/dist/tests/remote-thread-list-test-helpers.js.map +1 -1
  372. package/dist/types/message.d.ts +38 -5
  373. package/dist/types/message.d.ts.map +1 -1
  374. package/dist/types/message.js.map +1 -1
  375. package/dist/utils/composite-context-provider.js.map +1 -1
  376. package/dist/utils/id.js.map +1 -1
  377. package/dist/utils/json/is-json-equal.js.map +1 -1
  378. package/dist/utils/json/is-json.js.map +1 -1
  379. package/dist/utils/text.js.map +1 -1
  380. package/package.json +6 -6
  381. package/src/adapters/thread-history.ts +2 -0
  382. package/src/index.ts +5 -0
  383. package/src/internal.ts +1 -0
  384. package/src/model-context/types.ts +1 -0
  385. package/src/react/AssistantProvider.tsx +10 -1
  386. package/src/react/RuntimeAdapter.ts +25 -8
  387. package/src/react/client/DataRenderers.ts +42 -45
  388. package/src/react/client/Interactables.ts +261 -261
  389. package/src/react/client/Tools.ts +9 -9
  390. package/src/react/primitives/message/MessageGroupedParts.tsx +19 -7
  391. package/src/react/primitives/message/MessageParts.tsx +64 -13
  392. package/src/react/providers/TextMessagePartProvider.tsx +5 -3
  393. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +1 -0
  394. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +11 -0
  395. package/src/react/runtimes/cloud/useCloudThreadListAdapter.tsx +6 -0
  396. package/src/react/runtimes/external-message-converter.ts +3 -1
  397. package/src/react/types/MessagePartComponentTypes.ts +5 -5
  398. package/src/react/utils/groupParts.ts +27 -0
  399. package/src/runtime/api/bindings.ts +1 -0
  400. package/src/runtime/api/message-part-runtime.ts +14 -11
  401. package/src/runtime/api/message-runtime.ts +7 -0
  402. package/src/runtime/api/thread-list-runtime.ts +1 -0
  403. package/src/runtime/api/thread-runtime.ts +7 -0
  404. package/src/runtime/base/base-thread-runtime-core.ts +1 -0
  405. package/src/runtime/branch/external-thread-branch-adapter.ts +26 -0
  406. package/src/runtime/interfaces/thread-list-runtime-core.ts +1 -0
  407. package/src/runtime/interfaces/thread-runtime-core.ts +4 -0
  408. package/src/runtime/utils/resolveToolApprovalResponse.test.ts +91 -0
  409. package/src/runtime/utils/resolveToolApprovalResponse.ts +55 -0
  410. package/src/runtime/utils/thread-message-like.ts +10 -1
  411. package/src/runtimes/external-store/external-store-adapter.ts +1 -0
  412. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +24 -0
  413. package/src/runtimes/local/local-runtime-options.ts +1 -1
  414. package/src/runtimes/local/local-thread-runtime-core.test.ts +370 -0
  415. package/src/runtimes/local/local-thread-runtime-core.ts +113 -7
  416. package/src/runtimes/local/should-continue.ts +24 -13
  417. package/src/runtimes/readonly/ReadonlyThreadRuntimeCore.ts +5 -0
  418. package/src/runtimes/remote-thread-list/empty-thread-core.ts +5 -0
  419. package/src/runtimes/remote-thread-list/remote-thread-state.ts +2 -0
  420. package/src/runtimes/remote-thread-list/types.ts +1 -0
  421. package/src/store/clients/chain-of-thought-client.ts +5 -3
  422. package/src/store/clients/model-context-client.test.ts +5 -4
  423. package/src/store/clients/model-context-client.ts +21 -21
  424. package/src/store/clients/no-op-composer-client.ts +5 -3
  425. package/src/store/clients/runtime-adapter.ts +0 -24
  426. package/src/store/clients/suggestions.ts +12 -23
  427. package/src/store/clients/thread-message-client.ts +42 -40
  428. package/src/store/internal.ts +1 -4
  429. package/src/store/runtime-clients/attachment-runtime-client.ts +14 -14
  430. package/src/store/runtime-clients/composer-runtime-client.ts +48 -45
  431. package/src/store/runtime-clients/liveRef.ts +5 -0
  432. package/src/store/runtime-clients/message-part-runtime-client.ts +5 -3
  433. package/src/store/runtime-clients/message-runtime-client.ts +42 -40
  434. package/src/store/runtime-clients/thread-list-item-runtime-client.ts +5 -3
  435. package/src/store/runtime-clients/thread-list-runtime-client.ts +13 -11
  436. package/src/store/runtime-clients/thread-runtime-client.ts +20 -16
  437. package/src/store/runtime-clients/useSubscribable.ts +2 -10
  438. package/src/store/scopes/message.ts +1 -0
  439. package/src/store/scopes/part.ts +5 -2
  440. package/src/store/scopes/thread-list-item.ts +1 -0
  441. package/src/store/scopes/thread.ts +1 -0
  442. package/src/tests/external-store-thread-runtime-core.test.ts +57 -0
  443. package/src/tests/groupMessageParts.test.ts +84 -0
  444. package/src/tests/groupParts.test.ts +55 -0
  445. package/src/types/message.ts +45 -3
@@ -1 +1 @@
1
- {"version":3,"file":"useLocalRuntime.js","names":[],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n AssistantRuntime,\n ChatModelAdapter,\n ThreadMessageLike,\n} from \"../../index\";\nimport type { LocalRuntimeOptionsBase } from \"../../runtimes/local/local-runtime-options\";\nimport { AssistantRuntimeImpl, LocalRuntimeCore } from \"../../internal\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useRemoteThreadListRuntime } from \"./useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"./cloud/useCloudThreadListAdapter\";\nimport { useRuntimeAdapters } from \"./RuntimeAdapterProvider\";\nimport type { AssistantCloud } from \"assistant-cloud\";\n\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n cloud?: AssistantCloud | undefined;\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nconst useLocalThreadRuntime = (\n chatModel: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions,\n): AssistantRuntime => {\n const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};\n const opt = {\n ...options,\n adapters: {\n ...threadListAdapters,\n ...options.adapters,\n chatModel,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n const threadIdRef = useRef<string | undefined>(undefined);\n threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);\n\n useEffect(() => {\n runtime.threads\n .getMainThreadRuntimeCore()\n .__internal_setGetThreadId(() => threadIdRef.current);\n }, [runtime]);\n\n useEffect(() => {\n return () => {\n runtime.threads.getMainThreadRuntimeCore().detach();\n };\n }, [runtime]);\n\n useEffect(() => {\n runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);\n runtime.threads.getMainThreadRuntimeCore().__internal_load();\n });\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n unstable_enableMessageQueue,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n unstable_enableMessageQueue,\n },\n otherOptions: rest,\n };\n};\n\nexport const useLocalRuntime = (\n chatModel: ChatModelAdapter,\n { cloud, ...options }: LocalRuntimeOptions = {},\n): AssistantRuntime => {\n const cloudAdapter = useCloudThreadListAdapter({ cloud });\n return useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useLocalThreadRuntime(chatModel, options);\n },\n adapter: cloudAdapter,\n allowNesting: true,\n });\n};\n"],"mappings":";;;;;;;;AAoBA,MAAM,yBACJ,WACA,EAAE,iBAAiB,GAAG,cACD;CACrB,MAAM,EAAE,cAAc,GAAG,uBAAuB,mBAAmB,KAAK,CAAC;CACzE,MAAM,MAAM;EACV,GAAG;EACH,UAAU;GACR,GAAG;GACH,GAAG,QAAQ;GACX;EACF;CACF;CAEA,MAAM,CAAC,WAAW,eAAe,IAAI,iBAAiB,KAAK,eAAe,CAAC;CAE3E,MAAM,cAAc,OAA2B,KAAA,CAAS;CACxD,YAAY,UAAU,aAAa,MAAM,EAAE,eAAe,QAAQ;CAElE,gBAAgB;EACd,QAAQ,QACL,yBAAyB,CAAC,CAC1B,gCAAgC,YAAY,OAAO;CACxD,GAAG,CAAC,OAAO,CAAC;CAEZ,gBAAgB;EACd,aAAa;GACX,QAAQ,QAAQ,yBAAyB,CAAC,CAAC,OAAO;EACpD;CACF,GAAG,CAAC,OAAO,CAAC;CAEZ,gBAAgB;EACd,QAAQ,QAAQ,yBAAyB,CAAC,CAAC,sBAAsB,GAAG;EACpE,QAAQ,QAAQ,yBAAyB,CAAC,CAAC,gBAAgB;CAC7D,CAAC;CAED,gBAAgB;EACd,IAAI,CAAC,cAAc,OAAO,KAAA;EAC1B,OAAO,QAAQ,6BAA6B,YAAY;CAC1D,GAAG,CAAC,cAAc,OAAO,CAAC;CAE1B,OAAO,cAAc,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEA,MAAa,4BACX,YACG;CACH,MAAM,EACJ,OACA,iBACA,UACA,UACA,yBACA,6BACA,GAAG,SACD;CAEJ,OAAO;EACL,qBAAqB;GACnB;GACA;GACA;GACA;GACA;GACA;EACF;EACA,cAAc;CAChB;AACF;AAEA,MAAa,mBACX,WACA,EAAE,OAAO,GAAG,YAAiC,CAAC,MACzB;CAErB,OAAO,2BAA2B;EAChC,aAAa,SAAS,cAAc;GAClC,OAAO,sBAAsB,WAAW,OAAO;EACjD;EACA,SALmB,0BAA0B,EAAE,MAAM,CAKjC;EACpB,cAAc;CAChB,CAAC;AACH"}
1
+ {"version":3,"file":"useLocalRuntime.js","names":["useEffect","useMemo","useRef","useState","AssistantRuntime","ChatModelAdapter","ThreadMessageLike","LocalRuntimeOptionsBase","AssistantRuntimeImpl","LocalRuntimeCore","useAuiState","useRemoteThreadListRuntime","useCloudThreadListAdapter","useRuntimeAdapters","AssistantCloud","LocalRuntimeOptions","Omit","cloud","initialMessages","adapters","useLocalThreadRuntime","chatModel","options","modelContext","threadListAdapters","opt","runtime","threadIdRef","undefined","current","s","threadListItem","remoteId","threads","getMainThreadRuntimeCore","__internal_setGetThreadId","detach","__internal_setOptions","__internal_load","registerModelContextProvider","splitLocalRuntimeOptions","T","maxSteps","unstable_humanToolNames","unstable_enableMessageQueue","rest","localRuntimeOptions","otherOptions","useLocalRuntime","cloudAdapter","runtimeHook","RuntimeHook","adapter","allowNesting"],"sources":["../../../src/react/runtimes/useLocalRuntime.ts"],"sourcesContent":["import { useEffect, useMemo, useRef, useState } from \"react\";\nimport type {\n AssistantRuntime,\n ChatModelAdapter,\n ThreadMessageLike,\n} from \"../../index\";\nimport type { LocalRuntimeOptionsBase } from \"../../runtimes/local/local-runtime-options\";\nimport { AssistantRuntimeImpl, LocalRuntimeCore } from \"../../internal\";\nimport { useAuiState } from \"@assistant-ui/store\";\nimport { useRemoteThreadListRuntime } from \"./useRemoteThreadListRuntime\";\nimport { useCloudThreadListAdapter } from \"./cloud/useCloudThreadListAdapter\";\nimport { useRuntimeAdapters } from \"./RuntimeAdapterProvider\";\nimport type { AssistantCloud } from \"assistant-cloud\";\n\nexport type LocalRuntimeOptions = Omit<LocalRuntimeOptionsBase, \"adapters\"> & {\n cloud?: AssistantCloud | undefined;\n initialMessages?: readonly ThreadMessageLike[] | undefined;\n adapters?: Omit<LocalRuntimeOptionsBase[\"adapters\"], \"chatModel\"> | undefined;\n};\n\nconst useLocalThreadRuntime = (\n chatModel: ChatModelAdapter,\n { initialMessages, ...options }: LocalRuntimeOptions,\n): AssistantRuntime => {\n const { modelContext, ...threadListAdapters } = useRuntimeAdapters() ?? {};\n const opt = {\n ...options,\n adapters: {\n ...threadListAdapters,\n ...options.adapters,\n chatModel,\n },\n };\n\n const [runtime] = useState(() => new LocalRuntimeCore(opt, initialMessages));\n\n const threadIdRef = useRef<string | undefined>(undefined);\n threadIdRef.current = useAuiState((s) => s.threadListItem.remoteId);\n\n useEffect(() => {\n runtime.threads\n .getMainThreadRuntimeCore()\n .__internal_setGetThreadId(() => threadIdRef.current);\n }, [runtime]);\n\n useEffect(() => {\n return () => {\n runtime.threads.getMainThreadRuntimeCore().detach();\n };\n }, [runtime]);\n\n useEffect(() => {\n runtime.threads.getMainThreadRuntimeCore().__internal_setOptions(opt);\n runtime.threads.getMainThreadRuntimeCore().__internal_load();\n });\n\n useEffect(() => {\n if (!modelContext) return undefined;\n return runtime.registerModelContextProvider(modelContext);\n }, [modelContext, runtime]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const splitLocalRuntimeOptions = <T extends LocalRuntimeOptions>(\n options: T,\n) => {\n const {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n unstable_enableMessageQueue,\n ...rest\n } = options;\n\n return {\n localRuntimeOptions: {\n cloud,\n initialMessages,\n maxSteps,\n adapters,\n unstable_humanToolNames,\n unstable_enableMessageQueue,\n },\n otherOptions: rest,\n };\n};\n\nexport const useLocalRuntime = (\n chatModel: ChatModelAdapter,\n { cloud, ...options }: LocalRuntimeOptions = {},\n): AssistantRuntime => {\n const cloudAdapter = useCloudThreadListAdapter({ cloud });\n return useRemoteThreadListRuntime({\n runtimeHook: function RuntimeHook() {\n return useLocalThreadRuntime(chatModel, options);\n },\n adapter: cloudAdapter,\n allowNesting: true,\n });\n};\n"],"mappings":";;;;;;;;AAoBA,MAAMoB,yBACJC,WACA,EAAEH,iBAAiB,GAAGI,cACD;CACrB,MAAM,EAAEC,cAAc,GAAGC,uBAAuBX,mBAAmB,KAAK,CAAC;CACzE,MAAMY,MAAM;EACV,GAAGH;EACHH,UAAU;GACR,GAAGK;GACH,GAAGF,QAAQH;GACXE;EACF;CACF;CAEA,MAAM,CAACK,WAAWvB,eAAe,IAAIM,iBAAiBgB,KAAKP,eAAe,CAAC;CAE3E,MAAMS,cAAczB,OAA2B0B,KAAAA,CAAS;CACxDD,YAAYE,UAAUnB,aAAaoB,MAAMA,EAAEC,eAAeC,QAAQ;CAElEhC,gBAAgB;EACd0B,QAAQO,QACLC,yBAAyB,CAAC,CAC1BC,gCAAgCR,YAAYE,OAAO;CACxD,GAAG,CAACH,OAAO,CAAC;CAEZ1B,gBAAgB;EACd,aAAa;GACX0B,QAAQO,QAAQC,yBAAyB,CAAC,CAACE,OAAO;EACpD;CACF,GAAG,CAACV,OAAO,CAAC;CAEZ1B,gBAAgB;EACd0B,QAAQO,QAAQC,yBAAyB,CAAC,CAACG,sBAAsBZ,GAAG;EACpEC,QAAQO,QAAQC,yBAAyB,CAAC,CAACI,gBAAgB;CAC7D,CAAC;CAEDtC,gBAAgB;EACd,IAAI,CAACuB,cAAc,OAAOK,KAAAA;EAC1B,OAAOF,QAAQa,6BAA6BhB,YAAY;CAC1D,GAAG,CAACA,cAAcG,OAAO,CAAC;CAE1B,OAAOzB,cAAc,IAAIO,qBAAqBkB,OAAO,GAAG,CAACA,OAAO,CAAC;AACnE;AAEA,MAAac,4BACXlB,YACG;CACH,MAAM,EACJL,OACAC,iBACAwB,UACAvB,UACAwB,yBACAC,6BACA,GAAGC,SACDvB;CAEJ,OAAO;EACLwB,qBAAqB;GACnB7B;GACAC;GACAwB;GACAvB;GACAwB;GACAC;EACF;EACAG,cAAcF;CAChB;AACF;AAEA,MAAaG,mBACX3B,WACA,EAAEJ,OAAO,GAAGK,YAAiC,CAAC,MACzB;CAErB,OAAOX,2BAA2B;EAChCuC,aAAa,SAASC,cAAc;GAClC,OAAO/B,sBAAsBC,WAAWC,OAAO;EACjD;EACA8B,SALmBxC,0BAA0B,EAAEK,MAAM,CAK5CgC;EACTI,cAAc;CAChB,CAAC;AACH"}
@@ -3,6 +3,7 @@ import { AssistantRuntimeImpl } from "../../runtime/api/assistant-runtime.js";
3
3
  import { RemoteThreadListThreadListRuntimeCore } from "./RemoteThreadListThreadListRuntimeCore.js";
4
4
  import { useCallback, useEffect, useMemo, useRef, useState } from "@assistant-ui/tap/react-shim";
5
5
  import { useAui } from "@assistant-ui/store";
6
+ import { c } from "@assistant-ui/tap/react-shim/compiler-runtime";
6
7
  //#region src/react/runtimes/useRemoteThreadListRuntime.ts
7
8
  var RemoteThreadListRuntimeCore = class extends BaseAssistantRuntimeCore {
8
9
  threads;
@@ -15,12 +16,39 @@ var RemoteThreadListRuntimeCore = class extends BaseAssistantRuntimeCore {
15
16
  }
16
17
  };
17
18
  const useRemoteThreadListRuntimeImpl = (options) => {
18
- const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));
19
- useEffect(() => {
20
- runtime.threads.__internal_setOptions(options);
21
- runtime.threads.__internal_load();
22
- }, [runtime, options]);
23
- return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);
19
+ const $ = c(10);
20
+ let t0;
21
+ if ($[0] !== options) {
22
+ t0 = () => new RemoteThreadListRuntimeCore(options);
23
+ $[0] = options;
24
+ $[1] = t0;
25
+ } else t0 = $[1];
26
+ const [runtime] = useState(t0);
27
+ let t1;
28
+ if ($[2] !== options || $[3] !== runtime.threads) {
29
+ t1 = () => {
30
+ runtime.threads.__internal_setOptions(options);
31
+ runtime.threads.__internal_load();
32
+ };
33
+ $[2] = options;
34
+ $[3] = runtime.threads;
35
+ $[4] = t1;
36
+ } else t1 = $[4];
37
+ let t2;
38
+ if ($[5] !== options || $[6] !== runtime) {
39
+ t2 = [runtime, options];
40
+ $[5] = options;
41
+ $[6] = runtime;
42
+ $[7] = t2;
43
+ } else t2 = $[7];
44
+ useEffect(t1, t2);
45
+ let t3;
46
+ if ($[8] !== runtime) {
47
+ t3 = new AssistantRuntimeImpl(runtime);
48
+ $[8] = runtime;
49
+ $[9] = t3;
50
+ } else t3 = $[9];
51
+ return t3;
24
52
  };
25
53
  const useRemoteThreadListRuntime = (options) => {
26
54
  const runtimeHookRef = useRef(options.runtimeHook);
@@ -1 +1 @@
1
- {"version":3,"file":"useRemoteThreadListRuntime.js","names":[],"sources":["../../../src/react/runtimes/useRemoteThreadListRuntime.ts"],"sourcesContent":["import { useState, useEffect, useMemo, useRef, useCallback } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../../runtime/base/base-assistant-runtime-core\";\nimport { AssistantRuntimeImpl } from \"../../runtime/api/assistant-runtime\";\nimport type { RemoteThreadListOptions } from \"../../runtimes/remote-thread-list/types\";\nimport type { AssistantRuntimeCore } from \"../../runtime/interfaces/assistant-runtime-core\";\nimport type { AssistantRuntime } from \"../../runtime/api/assistant-runtime\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { useAui } from \"@assistant-ui/store\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\nconst useRemoteThreadListRuntimeImpl = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));\n useEffect(() => {\n runtime.threads.__internal_setOptions(options);\n runtime.threads.__internal_load();\n }, [runtime, options]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useRemoteThreadListRuntime = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const runtimeHookRef = useRef(options.runtimeHook);\n runtimeHookRef.current = options.runtimeHook;\n\n // threadId/initialThreadId only affect the constructor; capture once via ref\n const startThreadIdRef = useRef(options.threadId ?? options.initialThreadId);\n\n const stableRuntimeHook = useCallback(() => {\n return runtimeHookRef.current();\n }, []);\n\n const stableOptions = useMemo<RemoteThreadListOptions>(\n () => ({\n adapter: options.adapter,\n allowNesting: options.allowNesting,\n initialThreadId: startThreadIdRef.current,\n runtimeHook: stableRuntimeHook,\n }),\n [options.adapter, options.allowNesting, stableRuntimeHook],\n );\n\n const aui = useAui();\n const isNested = aui.threadListItem.source !== null;\n\n if (isNested) {\n if (!stableOptions.allowNesting) {\n throw new Error(\n \"useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. \" +\n \"Set allowNesting: true to allow nesting (the inner runtime will become a no-op).\",\n );\n }\n\n // If allowNesting is true and already inside a thread list context,\n // just call the runtimeHook directly (no-op behavior)\n return stableRuntimeHook();\n }\n\n const runtime = useRemoteThreadListRuntimeImpl(stableOptions);\n\n const prevThreadIdRef = useRef(options.threadId);\n useEffect(() => {\n if (options.threadId === prevThreadIdRef.current) return;\n prevThreadIdRef.current = options.threadId;\n if (options.threadId) {\n runtime.threads.switchToThread(options.threadId).catch(() => {});\n } else {\n runtime.threads.switchToNewThread().catch(() => {});\n }\n }, [runtime, options.threadId]);\n\n return runtime;\n};\n"],"mappings":";;;;;;AASA,IAAM,8BAAN,cACU,yBAEV;CACE;CAEA,YAAY,SAAkC;EAC5C,MAAM;EACN,KAAK,UAAU,IAAI,sCACjB,SACA,KAAK,gBACP;CACF;CAEA,IAAW,kBAAkB;EAC3B,OAAO,KAAK,QAAQ;CACtB;AACF;AAEA,MAAM,kCACJ,YACqB;CACrB,MAAM,CAAC,WAAW,eAAe,IAAI,4BAA4B,OAAO,CAAC;CACzE,gBAAgB;EACd,QAAQ,QAAQ,sBAAsB,OAAO;EAC7C,QAAQ,QAAQ,gBAAgB;CAClC,GAAG,CAAC,SAAS,OAAO,CAAC;CAErB,OAAO,cAAc,IAAI,qBAAqB,OAAO,GAAG,CAAC,OAAO,CAAC;AACnE;AAEA,MAAa,8BACX,YACqB;CACrB,MAAM,iBAAiB,OAAO,QAAQ,WAAW;CACjD,eAAe,UAAU,QAAQ;CAGjC,MAAM,mBAAmB,OAAO,QAAQ,YAAY,QAAQ,eAAe;CAE3E,MAAM,oBAAoB,kBAAkB;EAC1C,OAAO,eAAe,QAAQ;CAChC,GAAG,CAAC,CAAC;CAEL,MAAM,gBAAgB,eACb;EACL,SAAS,QAAQ;EACjB,cAAc,QAAQ;EACtB,iBAAiB,iBAAiB;EAClC,aAAa;CACf,IACA;EAAC,QAAQ;EAAS,QAAQ;EAAc;CAAiB,CAC3D;CAKA,IAHY,OACO,CAAC,CAAC,eAAe,WAAW,MAEjC;EACZ,IAAI,CAAC,cAAc,cACjB,MAAM,IAAI,MACR,sKAEF;EAKF,OAAO,kBAAkB;CAC3B;CAEA,MAAM,UAAU,+BAA+B,aAAa;CAE5D,MAAM,kBAAkB,OAAO,QAAQ,QAAQ;CAC/C,gBAAgB;EACd,IAAI,QAAQ,aAAa,gBAAgB,SAAS;EAClD,gBAAgB,UAAU,QAAQ;EAClC,IAAI,QAAQ,UACV,QAAQ,QAAQ,eAAe,QAAQ,QAAQ,CAAC,CAAC,YAAY,CAAC,CAAC;OAE/D,QAAQ,QAAQ,kBAAkB,CAAC,CAAC,YAAY,CAAC,CAAC;CAEtD,GAAG,CAAC,SAAS,QAAQ,QAAQ,CAAC;CAE9B,OAAO;AACT"}
1
+ {"version":3,"file":"useRemoteThreadListRuntime.js","names":["useState","useEffect","useMemo","useRef","useCallback","BaseAssistantRuntimeCore","AssistantRuntimeImpl","RemoteThreadListOptions","AssistantRuntimeCore","AssistantRuntime","RemoteThreadListThreadListRuntimeCore","useAui","RemoteThreadListRuntimeCore","threads","constructor","options","_contextProvider","RenderComponent","__internal_RenderComponent","useRemoteThreadListRuntimeImpl","$","_c","t0","runtime","t1","__internal_setOptions","__internal_load","t2","t3","useRemoteThreadListRuntime","runtimeHookRef","runtimeHook","current","startThreadIdRef","threadId","initialThreadId","stableRuntimeHook","stableOptions","adapter","allowNesting","aui","isNested","threadListItem","source","Error","prevThreadIdRef","switchToThread","catch","switchToNewThread"],"sources":["../../../src/react/runtimes/useRemoteThreadListRuntime.ts"],"sourcesContent":["import { useState, useEffect, useMemo, useRef, useCallback } from \"react\";\nimport { BaseAssistantRuntimeCore } from \"../../runtime/base/base-assistant-runtime-core\";\nimport { AssistantRuntimeImpl } from \"../../runtime/api/assistant-runtime\";\nimport type { RemoteThreadListOptions } from \"../../runtimes/remote-thread-list/types\";\nimport type { AssistantRuntimeCore } from \"../../runtime/interfaces/assistant-runtime-core\";\nimport type { AssistantRuntime } from \"../../runtime/api/assistant-runtime\";\nimport { RemoteThreadListThreadListRuntimeCore } from \"./RemoteThreadListThreadListRuntimeCore\";\nimport { useAui } from \"@assistant-ui/store\";\n\nclass RemoteThreadListRuntimeCore\n extends BaseAssistantRuntimeCore\n implements AssistantRuntimeCore\n{\n public readonly threads;\n\n constructor(options: RemoteThreadListOptions) {\n super();\n this.threads = new RemoteThreadListThreadListRuntimeCore(\n options,\n this._contextProvider,\n );\n }\n\n public get RenderComponent() {\n return this.threads.__internal_RenderComponent;\n }\n}\n\nconst useRemoteThreadListRuntimeImpl = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const [runtime] = useState(() => new RemoteThreadListRuntimeCore(options));\n useEffect(() => {\n runtime.threads.__internal_setOptions(options);\n runtime.threads.__internal_load();\n }, [runtime, options]);\n\n return useMemo(() => new AssistantRuntimeImpl(runtime), [runtime]);\n};\n\nexport const useRemoteThreadListRuntime = (\n options: RemoteThreadListOptions,\n): AssistantRuntime => {\n const runtimeHookRef = useRef(options.runtimeHook);\n runtimeHookRef.current = options.runtimeHook;\n\n // threadId/initialThreadId only affect the constructor; capture once via ref\n const startThreadIdRef = useRef(options.threadId ?? options.initialThreadId);\n\n const stableRuntimeHook = useCallback(() => {\n return runtimeHookRef.current();\n }, []);\n\n const stableOptions = useMemo<RemoteThreadListOptions>(\n () => ({\n adapter: options.adapter,\n allowNesting: options.allowNesting,\n initialThreadId: startThreadIdRef.current,\n runtimeHook: stableRuntimeHook,\n }),\n [options.adapter, options.allowNesting, stableRuntimeHook],\n );\n\n const aui = useAui();\n const isNested = aui.threadListItem.source !== null;\n\n if (isNested) {\n if (!stableOptions.allowNesting) {\n throw new Error(\n \"useRemoteThreadListRuntime cannot be nested inside another RemoteThreadListRuntime. \" +\n \"Set allowNesting: true to allow nesting (the inner runtime will become a no-op).\",\n );\n }\n\n // If allowNesting is true and already inside a thread list context,\n // just call the runtimeHook directly (no-op behavior)\n return stableRuntimeHook();\n }\n\n const runtime = useRemoteThreadListRuntimeImpl(stableOptions);\n\n const prevThreadIdRef = useRef(options.threadId);\n useEffect(() => {\n if (options.threadId === prevThreadIdRef.current) return;\n prevThreadIdRef.current = options.threadId;\n if (options.threadId) {\n runtime.threads.switchToThread(options.threadId).catch(() => {});\n } else {\n runtime.threads.switchToNewThread().catch(() => {});\n }\n }, [runtime, options.threadId]);\n\n return runtime;\n};\n"],"mappings":";;;;;;;AASA,IAAMY,8BAAN,cACUP,yBAEV;CACE;CAEAS,YAAYC,SAAkC;EAC5C,MAAM;EACN,KAAKF,UAAU,IAAIH,sCACjBK,SACA,KAAKC,gBACP;CACF;CAEA,IAAWC,kBAAkB;EAC3B,OAAO,KAAKJ,QAAQK;CACtB;AACF;AAEA,MAAMC,kCAAiCJ,YAAA;CAAA,MAAAK,IAAAC,EAAA,EAAA;CAAA,IAAAC;CAAA,IAAAF,EAAA,OAAAL,SAAA;EAGVO,WAAM,IAAIV,4BAA4BG,OAAO;EAACK,EAAA,KAAAL;EAAAK,EAAA,KAAAE;CAAA,OAAAA,KAAAF,EAAA;CAAzE,MAAA,CAAAG,WAAkBvB,SAASsB,EAA8C;CAAE,IAAAE;CAAA,IAAAJ,EAAA,OAAAL,WAAAK,EAAA,OAAAG,QAAAV,SAAA;EACjEW,WAAA;GACRD,QAAOV,QAAQY,sBAAuBV,OAAO;GAC7CQ,QAAOV,QAAQa,gBAAiB;EAAC;EAClCN,EAAA,KAAAL;EAAAK,EAAA,KAAAG,QAAAV;EAAAO,EAAA,KAAAI;CAAA,OAAAA,KAAAJ,EAAA;CAAA,IAAAO;CAAA,IAAAP,EAAA,OAAAL,WAAAK,EAAA,OAAAG,SAAA;EAAEI,KAAA,CAACJ,SAASR,OAAO;EAACK,EAAA,KAAAL;EAAAK,EAAA,KAAAG;EAAAH,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}
@@ -1,4 +1,4 @@
1
- import { DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUISpec, ImageMessagePart, MessagePartStatus, ReasoningMessagePart, SourceMessagePart, TextMessagePart, ToolCallMessagePart, Unstable_AudioMessagePart } from "../../types/message.js";
1
+ import { DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUISpec, ImageMessagePart, MessagePartStatus, ReasoningMessagePart, SourceMessagePart, TextMessagePart, ToolApprovalResponse, ToolCallMessagePart, Unstable_AudioMessagePart } from "../../types/message.js";
2
2
  import { QuoteInfo } from "../../types/quote.js";
3
3
  import { MessagePartState } from "../../runtime/api/message-part-runtime.js";
4
4
  import { ToolResponse } from "assistant-stream";
@@ -43,12 +43,11 @@ type ToolCallMessagePartProps<TArgs = any, TResult = unknown> = MessagePartState
43
43
  resume: (payload: unknown) => void;
44
44
  /**
45
45
  * Responds to a server-side tool approval gate. Only valid while
46
- * `approval` is set on the part and `approval.approved === undefined`.
46
+ * `approval` is set on the part, `approval.approved === undefined`, and
47
+ * no `approval.resolution` is recorded. Accepts a boolean decision or the
48
+ * id of one of `approval.options`; option kinds resolve to the boolean.
47
49
  */
48
- respondToApproval: (response: {
49
- approved: boolean;
50
- reason?: string;
51
- }) => void;
50
+ respondToApproval: (response: ToolApprovalResponse) => void;
52
51
  };
53
52
  /** Component used to render a tool-call message part. */
54
53
  type ToolCallMessagePartComponent<TArgs = any, TResult = any> = ComponentType<ToolCallMessagePartProps<TArgs, TResult>>;
@@ -1 +1 @@
1
- {"version":3,"file":"MessagePartComponentTypes.d.ts","names":[],"sources":["../../../src/react/types/MessagePartComponentTypes.ts"],"mappings":";;;;;;;KAkBY,qBAAA;EACV,MAAA,EAAQ,iBAAiB;AAAA;AAAA,KAEf,yBAAA,GAA4B,aAAa,CAAC,qBAAA;AAAA,KAE1C,oBAAA,GAAuB,gBAAA,GAAmB,eAAe;AAAA,KACzD,wBAAA,GAA2B,aAAa,CAAC,oBAAA;AAAA,KAEzC,y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A;EAlCjB;;;;AAAmE;AAC/E;EAwCI,SAAA,GAAY,MAAA,EAAQ,OAAA,GAAU,YAAA,CAAa,OAAA;;;AAvCN;AAEzC;EA0CI,MAAA,GAAS,OAAA;;;;;;;EAOT,iBAAA,GAAoB,QAAA,EAAU,oBAAA;AAAA;;KAItB,4BAAA,+BAGR,aAAA,CAAc,wBAAA,CAAyB,KAAA,EAAO,OAAA;AAAA,KAEtC,qBAAA,GAAwB,SAAS;AAAA,KACjC,yBAAA,GAA4B,aAAa,CAAC,qBAAA;AArDtD;;;;AAAyE;AACzE;;;AADA,KA+DY,6BAAA,GAAgC,MAAM,SAAS,aAAA;AAAA,KAE/C,4BAAA,GAA+B,gBAAA,GACzC,uBAAuB;AAAA,KACb,gCAAA,GACV,aAAa,CAAC,4BAAA;AAAA,KAEJ,uBAAA;iCAEV,IAAA,EAAM,gBAAA,EArE+D;EAuErE,UAAA,EAAY,6BAAA,EAtEuB;EAwEnC,QAAA,GAAW,aAAA;IAAgB,SAAA;IAAmB,KAAA;EAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"getMessageQuote.js","names":[],"sources":["../../../src/react/utils/getMessageQuote.ts"],"sourcesContent":["import type { QuoteInfo } from \"../../types/quote\";\n\ntype MessageQuoteState = {\n message: {\n metadata?: unknown;\n };\n};\n\nexport const getMessageQuote = (\n state: MessageQuoteState,\n): QuoteInfo | undefined => {\n const metadata = state.message.metadata;\n if (!metadata || typeof metadata !== \"object\") return undefined;\n\n return (metadata as { custom?: Record<string, unknown> }).custom?.quote as\n | QuoteInfo\n | undefined;\n};\n"],"mappings":";AAQA,MAAa,mBACX,UAC0B;CAC1B,MAAM,WAAW,MAAM,QAAQ;CAC/B,IAAI,CAAC,YAAY,OAAO,aAAa,UAAU,OAAO,KAAA;CAEtD,OAAQ,SAAkD,QAAQ;AAGpE"}
1
+ {"version":3,"file":"getMessageQuote.js","names":["QuoteInfo","MessageQuoteState","message","metadata","getMessageQuote","state","undefined","custom","Record","quote"],"sources":["../../../src/react/utils/getMessageQuote.ts"],"sourcesContent":["import type { QuoteInfo } from \"../../types/quote\";\n\ntype MessageQuoteState = {\n message: {\n metadata?: unknown;\n };\n};\n\nexport const getMessageQuote = (\n state: MessageQuoteState,\n): QuoteInfo | undefined => {\n const metadata = state.message.metadata;\n if (!metadata || typeof metadata !== \"object\") return undefined;\n\n return (metadata as { custom?: Record<string, unknown> }).custom?.quote as\n | QuoteInfo\n | undefined;\n};\n"],"mappings":";AAQA,MAAaI,mBACXC,UAC0B;CAC1B,MAAMF,WAAWE,MAAMH,QAAQC;CAC/B,IAAI,CAACA,YAAY,OAAOA,aAAa,UAAU,OAAOG,KAAAA;CAEtD,OAAQH,SAAkDI,QAAQE;AAGpE"}
@@ -79,6 +79,11 @@ interface GroupNodeGroup {
79
79
  readonly key: string;
80
80
  /** Structural React key: sibling-index path, e.g. `"0.1.0"`. */
81
81
  readonly nodeKey: string;
82
+ /**
83
+ * Identity key (`"id:<partId>"`) from the group's first part; undefined
84
+ * when absent or already claimed by an earlier sibling.
85
+ */
86
+ readonly idKey: string | undefined;
82
87
  /** Indices of parts in this subtree, in order. */
83
88
  readonly indices: readonly number[];
84
89
  readonly children: readonly GroupNode[];
@@ -89,13 +94,20 @@ interface GroupNodePart {
89
94
  readonly index: number;
90
95
  /** Structural React key: sibling-index path within parent. */
91
96
  readonly nodeKey: string;
97
+ /**
98
+ * Identity key (`"id:<partId>"`); undefined when absent or already
99
+ * claimed by an earlier sibling.
100
+ */
101
+ readonly idKey: string | undefined;
92
102
  }
93
103
  /**
94
104
  * Build the group tree from an array of normalized group paths.
95
105
  * `paths[i]` is the path for part `i`. The output tree contains one
96
106
  * `part` node per part and one `group` node per coalesced run.
107
+ * `partIds[i]` optionally carries a stable identity for part `i` (e.g. a
108
+ * tool call id), from which nodes derive an `idKey`.
97
109
  */
98
- declare const buildGroupTree: (paths: readonly (readonly string[])[]) => readonly GroupNode[];
110
+ declare const buildGroupTree: (paths: readonly (readonly string[])[], partIds?: readonly (string | undefined)[]) => readonly GroupNode[];
99
111
  //#endregion
100
112
  export { GROUPBY_MEMO_KEY, GroupByContext, GroupNode, GroupNodeGroup, GroupNodePart, buildGroupTree, groupPartByType };
101
113
  //# sourceMappingURL=groupParts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"groupParts.d.ts","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"mappings":";;;;;;AAUA;;;;KAAY,cAAA;EAwBC,gFAtBF,OAAA,GAAU,UAAU;AAAA;;AAwB9B;AAAC;;;;AAgB4B;AA4B9B;;;;;;;;;;;cA9Ca,gBAAA;;;;;;;;;;;;;;;KAkBR,aAAA,GAAgB,SAAS;AA6D9B;;;;AAAsD;AAEtD;;;;;;;;;;;AAQuC;AAGvC;;;;;;;;AAKkB;AAlBlB,cAjCa,eAAA,mCACX,GAAA,EAAK,OAAA,CAAQ,QAAA,CAAS,MAAA,CAAO,aAAA,WAAwB,IAAA,YAClD,IAAA,EAAM,SAAA,EAAW,OAAA,GAAU,cAAA,cAA4B,IAAA;AAAA,KA+BhD,SAAA,GAAY,cAAA,GAAiB,aAAa;AAAA,UAErC,cAAA;EAAA,SACN,IAAA;EAsCU;EAAA,SApCV,GAAA;;WAEA,OAAA;;WAEA,OAAA;EAAA,SACA,QAAA,WAAmB,SAAS;AAAA;AAAA,UAGtB,aAAA;EAAA,SACN,IAAA;;WAEA,KAAA;;WAEA,OAAA;AAAA;;;;;;cAqBE,cAAA,GACX,KAAA,8CACU,SAAS"}
1
+ {"version":3,"file":"groupParts.d.ts","names":[],"sources":["../../../src/react/utils/groupParts.ts"],"mappings":";;;;;;AAUA;;;;KAAY,cAAA;EAwBC,gFAtBF,OAAA,GAAU,UAAU;AAAA;;AAwB9B;AAAC;;;;AAgB4B;AA4B9B;;;;;;;;;;;cA9Ca,gBAAA;;;;;;;;;;;;;;;KAkBR,aAAA,GAAgB,SAAS;AA6D9B;;;;AAAsD;AAEtD;;;;;;;;;;;;AAauC;AAGvC;;;;;;;;AAlBA,cAjCa,eAAA,mCACX,GAAA,EAAK,OAAA,CAAQ,QAAA,CAAS,MAAA,CAAO,aAAA,WAAwB,IAAA,YAClD,IAAA,EAAM,SAAA,EAAW,OAAA,GAAU,cAAA,cAA4B,IAAA;AAAA,KA+BhD,SAAA,GAAY,cAAA,GAAiB,aAAa;AAAA,UAErC,cAAA;EAAA,SACN,IAAA;;WAEA,GAAA;EAyDT;EAAA,SAvDS,OAAA;EAyDC;;AAAS;;EAAT,SApDD,KAAA;;WAEA,OAAA;EAAA,SACA,QAAA,WAAmB,SAAS;AAAA;AAAA,UAGtB,aAAA;EAAA,SACN,IAAA;;WAEA,KAAA;;WAEA,OAAA;;;;;WAKA,KAAA;AAAA;;;;;;;;cAiCE,cAAA,GACX,KAAA,kCACA,OAAA,gDACU,SAAS"}
@@ -63,26 +63,36 @@ const makeChildNodeKey = (parent) => {
63
63
  const idx = parent.nextChildIdx++;
64
64
  return parent.nodeKey === "" ? String(idx) : `${parent.nodeKey}.${idx}`;
65
65
  };
66
+ const claimIdKey = (frame, id) => {
67
+ if (id === void 0 || frame.claimed.has(id)) return void 0;
68
+ frame.claimed.add(id);
69
+ return `id:${id}`;
70
+ };
66
71
  /**
67
72
  * Build the group tree from an array of normalized group paths.
68
73
  * `paths[i]` is the path for part `i`. The output tree contains one
69
74
  * `part` node per part and one `group` node per coalesced run.
75
+ * `partIds[i]` optionally carries a stable identity for part `i` (e.g. a
76
+ * tool call id), from which nodes derive an `idKey`.
70
77
  */
71
- const buildGroupTree = (paths) => {
78
+ const buildGroupTree = (paths, partIds) => {
72
79
  const root = {
73
80
  key: "",
74
81
  nodeKey: "",
75
82
  indices: [],
76
83
  children: [],
77
- nextChildIdx: 0
84
+ nextChildIdx: 0,
85
+ claimed: /* @__PURE__ */ new Set()
78
86
  };
79
87
  const stack = [root];
80
88
  const closeTop = () => {
81
89
  const closing = stack.pop();
82
- stack[stack.length - 1].children.push({
90
+ const parent = stack[stack.length - 1];
91
+ parent.children.push({
83
92
  type: "group",
84
93
  key: closing.key,
85
94
  nodeKey: closing.nodeKey,
95
+ idKey: claimIdKey(parent, partIds?.[closing.indices[0]]),
86
96
  indices: closing.indices,
87
97
  children: closing.children
88
98
  });
@@ -99,14 +109,16 @@ const buildGroupTree = (paths) => {
99
109
  nodeKey: makeChildNodeKey(parent),
100
110
  indices: [],
101
111
  children: [],
102
- nextChildIdx: 0
112
+ nextChildIdx: 0,
113
+ claimed: /* @__PURE__ */ new Set()
103
114
  });
104
115
  }
105
116
  const top = stack[stack.length - 1];
106
117
  top.children.push({
107
118
  type: "part",
108
119
  index: i,
109
- nodeKey: makeChildNodeKey(top)
120
+ nodeKey: makeChildNodeKey(top),
121
+ idKey: claimIdKey(top, partIds?.[i])
110
122
  });
111
123
  for (let s = 1; s < stack.length; s++) stack[s].indices.push(i);
112
124
  }
@@ -1 +1 @@
1
- {"version":3,"file":"groupParts.js","names":[],"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 /** 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\ninterface BuildFrame {\n key: string;\n nodeKey: string;\n indices: number[];\n children: GroupNode[];\n nextChildIdx: number;\n}\n\nconst makeChildNodeKey = (parent: BuildFrame): string => {\n const idx = parent.nextChildIdx++;\n return parent.nodeKey === \"\" ? String(idx) : `${parent.nodeKey}.${idx}`;\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 */\nexport const buildGroupTree = (\n paths: readonly (readonly string[])[],\n): readonly GroupNode[] => {\n const root: BuildFrame = {\n key: \"\",\n nodeKey: \"\",\n indices: [],\n children: [],\n nextChildIdx: 0,\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 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 });\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 });\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,MAAa,mBAAkC,OAAO,IACpD,+BACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAa,mBACX,QAC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,QACxB,SAAS;EAIX,OAAO,MAAM,SAAS,IAAI,KAAK,QAAQ;GACrC,MAAM,SAAS,MAAM,MAAM,SAAS;GACpC,MAAM,KAAK;IACT,KAAK,KAAK,MAAM,SAAS;IACzB,SAAS,iBAAiB,MAAM;IAChC,SAAS,CAAC;IACV,UAAU,CAAC;IACX,cAAc;GAChB,CAAC;EACH;EAGA,MAAM,MAAM,MAAM,MAAM,SAAS;EACjC,IAAI,SAAS,KAAK;GAChB,MAAM;GACN,OAAO;GACP,SAAS,iBAAiB,GAAG;EAC/B,CAAC;EAGD,KAAK,IAAI,IAAI,GAAG,IAAI,MAAM,QAAQ,KAChC,MAAM,EAAE,CAAE,QAAQ,KAAK,CAAC;CAE5B;CAGA,OAAO,MAAM,SAAS,GACpB,SAAS;CAGX,OAAO,KAAK;AACd"}
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,MAAaK,mBAAkCC,OAAOC,IACpD,+BACF;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,MAAaE,mBACXC,QACqE;CACrE,MAAMO,SAASP;CACf,MAAMQ,OAAOH,MAAMC,YAAY;EAC7B,IAAID,KAAKI,SAAS,aAAa;GAC7B,MAAMC,WAAWpB,YAAYe,KAAKM,KAAKC,KAAKC,WAAW;GAMvD,KAFEH,aACCJ,SAASZ,UAAUW,KAAKU,SAAS,GAAG,EAAE,EAAEC,cAAc,WACrCT,OAAO,4BAA4BU,KAAAA,GACrD,OAAOV,OAAO;GAGhB,IAAIG,YAAYH,OAAO,eAAeU,KAAAA,GACpC,OAAOV,OAAO;EAElB;EACA,OAAOA,OAAOF,KAAKI,SAAS,CAAA;CAC9B;CAOA,MA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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"}
@@ -1 +1 @@
1
- {"version":3,"file":"assistant-runtime.js","names":[],"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,IAAa,uBAAb,MAA8D;CAKxB;CAJpC;CAEA;CAEA,YAAmB,OAA8C;EAA7B,KAAA,QAAA;EAClC,KAAK,UAAU,IAAI,sBAAsB,MAAM,OAAO;EACtD,KAAK,UAAU,KAAK,QAAQ;EAE5B,KAAK,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAK,+BACH,KAAK,6BAA6B,KAAK,IAAI;CAC/C;CAEA,IAAW,SAAS;EAClB,OAAO,KAAK;CACd;CAEA,6BAAoC,UAAgC;EAClE,OAAO,KAAK,MAAM,6BAA6B,QAAQ;CACzD;AACF"}
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 +1 @@
1
- {"version":3,"file":"attachment-runtime.js","names":[],"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,IAAsB,wBAAtB,MAE+B;CAOT;CANpB,IAAW,OAAO;EAChB,OAAO,KAAK,MAAM;CACpB;CAIA,YAAY,OAAkD;EAA1C,KAAA,QAAA;EAClB,KAAK,uBAAuB;CAC9B;CAEA,yBAAmC;EACjC,KAAK,WAAW,KAAK,SAAS,KAAK,IAAI;EACvC,KAAK,SAAS,KAAK,OAAO,KAAK,IAAI;EACnC,KAAK,YAAY,KAAK,UAAU,KAAK,IAAI;CAC3C;CAEA,WAAwD;EACtD,OAAO,KAAK,MAAM,SAAS;CAC7B;CAIA,UAAiB,UAAsB;EACrC,OAAO,KAAK,MAAM,UAAU,QAAQ;CACtC;AACF;AAEA,IAAe,4BAAf,cAEU,sBAA8B;CAG5B;CAFV,YACE,MACA,cACA;EACA,MAAM,IAAI;EAFF,KAAA,eAAA;CAGV;CAEA,SAAgB;EACd,MAAM,OAAO,KAAK,aAAa,SAAS;EACxC,IAAI,CAAC,MAAM,MAAM,IAAI,MAAM,2BAA2B;EACtD,OAAO,KAAK,iBAAiB,KAAK,SAAS,CAAC,CAAC,EAAE;CACjD;AACF;AAEA,IAAa,sCAAb,cAAyD,0BAA6C;CACpG,IAAW,SAA4B;EACrC,OAAO;CACT;AACF;AAEA,IAAa,oCAAb,cAAuD,0BAA2C;CAChG,IAAW,SAA0B;EACnC,OAAO;CACT;AACF;AAEA,IAAa,+BAAb,cAAkD,sBAAiC;CACjF,IAAW,SAAoB;EAC7B,OAAO;CACT;CAEA,SAAuB;EACrB,MAAM,IAAI,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","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"}
@@ -28,6 +28,7 @@ type ThreadListItemState = {
28
28
  readonly externalId: string | undefined;
29
29
  readonly status: ThreadListItemStatus;
30
30
  readonly title?: string | undefined;
31
+ readonly lastMessageAt?: Date | undefined;
31
32
  readonly custom?: Record<string, unknown> | undefined;
32
33
  };
33
34
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"bindings.d.ts","names":[],"sources":["../../../src/runtime/api/bindings.ts"],"mappings":";;;;;;;;KAUY,0BAAA,GAA6B,qBAAA,CACvC,mBAAA,cACA,mBAAA;AAAA,KAGU,gCAAA,GAAmC,qBAAA,CAC7C,yBAAA,cACA,mBAAA;EAAwB,cAAA;AAAA;AAAA,KAGd,8BAAA,GAAiC,qBAAA,CAC3C,uBAAA,cACA,mBAAA;EAAwB,cAAA;AAAA;AAAA,KAGd,mBAAA,GAAsB,qBAAA,CAChC,aAAA;EAAA,SACW,QAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;EAAA,SACA,YAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,EAAQ,WAAA;AAAA,GAEnB,kBAAA;AAAA,KAGU,mBAAA;EAAA,SACD,MAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA,EALoB,oBAAA;EAAA,SAMpB,KAAA;EAAA,SACA,MAAA,GAAS,MAAM;AAAA"}
1
+ {"version":3,"file":"bindings.d.ts","names":[],"sources":["../../../src/runtime/api/bindings.ts"],"mappings":";;;;;;;;KAUY,0BAAA,GAA6B,qBAAA,CACvC,mBAAA,cACA,mBAAA;AAAA,KAGU,gCAAA,GAAmC,qBAAA,CAC7C,yBAAA,cACA,mBAAA;EAAwB,cAAA;AAAA;AAAA,KAGd,8BAAA,GAAiC,qBAAA,CAC3C,uBAAA,cACA,mBAAA;EAAwB,cAAA;AAAA;AAAA,KAGd,mBAAA,GAAsB,qBAAA,CAChC,aAAA;EAAA,SACW,QAAA;EAAA,SACA,KAAA;EAAA,SACA,MAAA;EAAA,SACA,YAAA;EAAA,SACA,WAAA;EAAA,SACA,MAAA,EAAQ,WAAA;AAAA,GAEnB,kBAAA;AAAA,KAGU,mBAAA;EAAA,SACD,MAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,UAAA;EAAA,SACA,MAAA,EALoB,oBAAA;EAAA,SAMpB,KAAA;EAAA,SACA,aAAA,GAAgB,IAAA;EAAA,SAChB,MAAA,GAAS,MAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"composer-runtime.js","names":[],"sources":["../../../src/runtime/api/composer-runtime.ts"],"sourcesContent":["import type { Attachment, CreateAttachment } from \"../../types/attachment\";\nimport type { MessageRole } from \"../../types/message\";\nimport type { QuoteInfo } from \"../../types/quote\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { RunConfig } from \"../../types/message\";\nimport type { QueueItemState } from \"../../store/scopes/queue-item\";\nimport {\n LazyMemoizeSubject,\n EventSubscriptionSubject,\n} from \"../../subscribable/subscribable\";\nimport {\n ShallowMemoizeSubject,\n SKIP_UPDATE,\n} from \"../../subscribable/subscribable\";\nimport type {\n ComposerRuntimeEventCallback,\n ComposerRuntimeEventType,\n DictationState,\n EditComposerRuntimeCore,\n SendOptions,\n ThreadComposerRuntimeCore,\n} from \"../interfaces/composer-runtime-core\";\nimport type {\n ThreadComposerRuntimeCoreBinding,\n EditComposerRuntimeCoreBinding,\n ComposerRuntimeCoreBinding,\n} from \"./bindings\";\nimport type { ComposerRuntimePath } from \"./paths\";\n\nimport {\n type AttachmentRuntime,\n type AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./attachment-runtime\";\n\nexport type {\n ThreadComposerRuntimeCoreBinding,\n EditComposerRuntimeCoreBinding,\n ComposerRuntimeCoreBinding,\n};\n\ntype BaseComposerState = {\n readonly canCancel: boolean;\n readonly canSend: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n readonly runConfig: RunConfig;\n\n readonly attachmentAccept: string;\n\n /**\n * The current state of dictation.\n * Undefined when dictation is not active.\n */\n readonly dictation: DictationState | undefined;\n\n /**\n * The currently quoted text, if any.\n * Undefined when no quote is set.\n */\n readonly quote: QuoteInfo | undefined;\n\n /** Messages waiting to be processed. Empty unless the `queue` capability is set. */\n readonly queue: readonly QueueItemState[];\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n readonly parentId: string | null;\n readonly sourceId: string | null;\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst EMPTY_OBJECT = Object.freeze({});\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n canSend: runtime?.canSend ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n attachmentAccept: runtime?.attachmentAccept ?? \"\",\n dictation: runtime?.dictation,\n quote: runtime?.quote,\n queue: runtime?.queue ?? EMPTY_ARRAY,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: EditComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n canSend: runtime?.canSend ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n attachmentAccept: runtime?.attachmentAccept ?? \"\",\n dictation: runtime?.dictation,\n quote: runtime?.quote,\n queue: runtime?.queue ?? EMPTY_ARRAY,\n\n parentId: runtime?.parentId ?? null,\n sourceId: runtime?.sourceId ?? null,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n\n /**\n * Get the current state of the composer. Includes any data that has been added to the composer.\n */\n getState(): ComposerState;\n\n /**\n * Add an attachment to the composer. Accepts either a standard File object\n * (processed through the AttachmentAdapter) or a CreateAttachment descriptor\n * for external-source attachments (URLs, API data, CMS references). External\n * descriptors bypass the adapter's `add()` step but still respect\n * `adapter.accept` when an adapter is configured; without an adapter they\n * are added as-is.\n * @param fileOrAttachment The file or attachment descriptor to add.\n */\n addAttachment(fileOrAttachment: File | CreateAttachment): Promise<void>;\n\n /**\n * Set the text of the composer.\n * @param text The text to set in the composer.\n */\n setText(text: string): void;\n\n /**\n * Set the role of the composer. For instance, if you'd like a specific message to have the 'assistant' role, you can do so here.\n * @param role The role to set in the composer.\n */\n setRole(role: MessageRole): void;\n\n /**\n * Set the run config of the composer. This is used to send custom configuration data to the model.\n * Within your backend, you can use the `runConfig` object.\n * Example:\n * ```ts\n * composerRuntime.setRunConfig({\n * custom: { customField: \"customValue\" }\n * });\n * ```\n * @param runConfig The run config to set in the composer.\n */\n setRunConfig(runConfig: RunConfig): void;\n\n /**\n * Reset the composer. This will clear the entire state of the composer, including all text and attachments.\n */\n reset(): Promise<void>;\n\n /**\n * Clear all attachments from the composer.\n */\n clearAttachments(): Promise<void>;\n\n /**\n * Send a message. This will send whatever text or attachments are in the composer.\n * @param options Optional send options. Use `{ startRun: true }` to force starting a new run.\n */\n send(options?: SendOptions): void;\n\n /**\n * Cancel the current run. In edit mode, this will exit edit mode.\n */\n cancel(): void;\n\n /** Promote a queued message so it processes next. */\n steerQueueItem(queueItemId: string): void;\n\n /** Remove a queued message. */\n removeQueueItem(queueItemId: string): void;\n\n /**\n * Listens for changes to the composer state.\n * @param callback The callback to call when the composer state changes.\n */\n subscribe(callback: () => void): Unsubscribe;\n\n /**\n * Get an attachment by index.\n * @param idx The index of the attachment to get.\n */\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n\n /**\n * Start dictation to convert voice to text input.\n * Requires a DictationAdapter to be configured.\n */\n startDictation(): void;\n\n /**\n * Stop the current dictation session.\n */\n stopDictation(): void;\n\n /**\n * Set a quote for the next message. Pass undefined to clear.\n * @param quote The quote info to set, or undefined to clear.\n */\n setQuote(quote: QuoteInfo | undefined): void;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n unstable_on<E extends ComposerRuntimeEventType>(\n event: E,\n callback: ComposerRuntimeEventCallback<E>,\n ): Unsubscribe;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n protected __internal_bindMethods() {\n this.setText = this.setText.bind(this);\n this.setRunConfig = this.setRunConfig.bind(this);\n this.getState = this.getState.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.addAttachment = this.addAttachment.bind(this);\n this.reset = this.reset.bind(this);\n this.clearAttachments = this.clearAttachments.bind(this);\n this.send = this.send.bind(this);\n this.cancel = this.cancel.bind(this);\n this.steerQueueItem = this.steerQueueItem.bind(this);\n this.removeQueueItem = this.removeQueueItem.bind(this);\n this.setRole = this.setRole.bind(this);\n this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);\n this.startDictation = this.startDictation.bind(this);\n this.stopDictation = this.stopDictation.bind(this);\n this.setQuote = this.setQuote.bind(this);\n this.unstable_on = this.unstable_on.bind(this);\n }\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setRunConfig(runConfig: RunConfig) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRunConfig(runConfig);\n }\n\n public addAttachment(fileOrAttachment: File | CreateAttachment) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(fileOrAttachment);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.reset();\n }\n\n public clearAttachments() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.clearAttachments();\n }\n\n public send(options?: SendOptions) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send(options);\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public steerQueueItem(queueItemId: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.steerQueueItem(queueItemId);\n }\n\n public removeQueueItem(queueItemId: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.removeQueueItem(queueItemId);\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public startDictation() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.startDictation();\n }\n\n public stopDictation() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.stopDictation();\n }\n\n public setQuote(quote: QuoteInfo | undefined) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setQuote(quote);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n private _eventSubscriptionSubjects = new Map<\n string,\n EventSubscriptionSubject<ComposerRuntimeEventType>\n >();\n\n public unstable_on<E extends ComposerRuntimeEventType>(\n event: E,\n callback: ComposerRuntimeEventCallback<E>,\n ): Unsubscribe {\n let subject = this._eventSubscriptionSubjects.get(event);\n if (!subject) {\n subject = new EventSubscriptionSubject<ComposerRuntimeEventType>({\n event,\n binding: this._core,\n });\n this._eventSubscriptionSubjects.set(event, subject);\n }\n return subject.subscribe(callback as (payload?: unknown) => void);\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n\n this.__internal_bindMethods();\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n\n this.__internal_bindMethods();\n }\n\n public override __internal_bindMethods() {\n super.__internal_bindMethods();\n this.beginEdit = this.beginEdit.bind(this);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;AAmFA,MAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,MAAM,eAAe,OAAO,OAAO,CAAC,CAAC;AACrC,MAAM,0BACJ,YACwB;CACxB,OAAO,OAAO,OAAO;EACnB,MAAM;EAEN,WAAW,SAAS,aAAa;EACjC,WAAW,SAAS,aAAa;EACjC,SAAS,SAAS,WAAW;EAC7B,SAAS,SAAS,WAAW;EAE7B,aAAa,SAAS,eAAe;EACrC,MAAM,SAAS,QAAQ;EACvB,MAAM,SAAS,QAAQ;EACvB,WAAW,SAAS,aAAa;EACjC,kBAAkB,SAAS,oBAAoB;EAC/C,WAAW,SAAS;EACpB,OAAO,SAAS;EAChB,OAAO,SAAS,SAAS;EAEzB,OAAO,SAAS,QAAQ;CAC1B,CAAC;AACH;AAEA,MAAM,wBACJ,YACsB;CACtB,OAAO,OAAO,OAAO;EACnB,MAAM;EAEN,WAAW,SAAS,aAAa;EACjC,WAAW,SAAS,aAAa;EACjC,SAAS,SAAS,WAAW;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J,GAAG,KAAK;IACR,kBAAkB;IAClB,oBAAoB;KAAE,MAAM;KAAS,OAAO;IAAI;IAChD,KAAK,GAAG,KAAK,KAAK,IAAI,eAAe,IAAI;GAC3C;GACA,gBAAgB;IAEd,MAAM,aADc,KAAK,SAAS,CAAC,CAAC,YACL;IAC/B,IAAI,CAAC,YAAY,OAAO;IAExB,OAAO;KACL,GAAG;KACH,QAAQ;IACV;GACF;GACA,YAAY,aAAa,KAAK,MAAM,UAAU,QAAQ;EACxD,CAAC,GACD,KAAK,KACP;CACF;AACF"}
1
+ {"version":3,"file":"composer-runtime.js","names":["Attachment","CreateAttachment","MessageRole","QuoteInfo","Unsubscribe","RunConfig","QueueItemState","LazyMemoizeSubject","EventSubscriptionSubject","ShallowMemoizeSubject","SKIP_UPDATE","ComposerRuntimeEventCallback","ComposerRuntimeEventType","DictationState","EditComposerRuntimeCore","SendOptions","ThreadComposerRuntimeCore","ThreadComposerRuntimeCoreBinding","EditComposerRuntimeCoreBinding","ComposerRuntimeCoreBinding","ComposerRuntimePath","AttachmentRuntime","AttachmentState","EditComposerAttachmentRuntimeImpl","ThreadComposerAttachmentRuntimeImpl","BaseComposerState","canCancel","canSend","isEditing","isEmpty","text","role","attachments","runConfig","attachmentAccept","dictation","quote","queue","ThreadComposerState","type","EditComposerState","parentId","sourceId","ComposerState","EMPTY_ARRAY","Object","freeze","EMPTY_OBJECT","getThreadComposerState","runtime","value","getEditComposerState","ComposerRuntime","path","getState","addAttachment","fileOrAttachment","File","Promise","setText","setRole","setRunConfig","reset","clearAttachments","send","options","cancel","steerQueueItem","queueItemId","removeQueueItem","subscribe","callback","getAttachmentByIndex","idx","startDictation","stopDictation","setQuote","unstable_on","event","E","ComposerRuntimeImpl","_core","constructor","__internal_bindMethods","bind","core","Error","_eventSubscriptionSubjects","Map","subject","get","binding","set","payload","ThreadComposerRuntime","Omit","composerSource","source","ThreadComposerRuntimeImpl","const","_getState","stateBinding","attachmentSource","attachmentSelector","index","ref","attachment","EditComposerRuntime","beginEdit","EditComposerRuntimeImpl","_beginEdit"],"sources":["../../../src/runtime/api/composer-runtime.ts"],"sourcesContent":["import type { Attachment, CreateAttachment } from \"../../types/attachment\";\nimport type { MessageRole } from \"../../types/message\";\nimport type { QuoteInfo } from \"../../types/quote\";\nimport type { Unsubscribe } from \"../../types/unsubscribe\";\nimport type { RunConfig } from \"../../types/message\";\nimport type { QueueItemState } from \"../../store/scopes/queue-item\";\nimport {\n LazyMemoizeSubject,\n EventSubscriptionSubject,\n} from \"../../subscribable/subscribable\";\nimport {\n ShallowMemoizeSubject,\n SKIP_UPDATE,\n} from \"../../subscribable/subscribable\";\nimport type {\n ComposerRuntimeEventCallback,\n ComposerRuntimeEventType,\n DictationState,\n EditComposerRuntimeCore,\n SendOptions,\n ThreadComposerRuntimeCore,\n} from \"../interfaces/composer-runtime-core\";\nimport type {\n ThreadComposerRuntimeCoreBinding,\n EditComposerRuntimeCoreBinding,\n ComposerRuntimeCoreBinding,\n} from \"./bindings\";\nimport type { ComposerRuntimePath } from \"./paths\";\n\nimport {\n type AttachmentRuntime,\n type AttachmentState,\n EditComposerAttachmentRuntimeImpl,\n ThreadComposerAttachmentRuntimeImpl,\n} from \"./attachment-runtime\";\n\nexport type {\n ThreadComposerRuntimeCoreBinding,\n EditComposerRuntimeCoreBinding,\n ComposerRuntimeCoreBinding,\n};\n\ntype BaseComposerState = {\n readonly canCancel: boolean;\n readonly canSend: boolean;\n readonly isEditing: boolean;\n readonly isEmpty: boolean;\n\n readonly text: string;\n readonly role: MessageRole;\n readonly attachments: readonly Attachment[];\n readonly runConfig: RunConfig;\n\n readonly attachmentAccept: string;\n\n /**\n * The current state of dictation.\n * Undefined when dictation is not active.\n */\n readonly dictation: DictationState | undefined;\n\n /**\n * The currently quoted text, if any.\n * Undefined when no quote is set.\n */\n readonly quote: QuoteInfo | undefined;\n\n /** Messages waiting to be processed. Empty unless the `queue` capability is set. */\n readonly queue: readonly QueueItemState[];\n};\n\nexport type ThreadComposerState = BaseComposerState & {\n readonly type: \"thread\";\n};\n\nexport type EditComposerState = BaseComposerState & {\n readonly type: \"edit\";\n readonly parentId: string | null;\n readonly sourceId: string | null;\n};\n\nexport type ComposerState = ThreadComposerState | EditComposerState;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst EMPTY_OBJECT = Object.freeze({});\nconst getThreadComposerState = (\n runtime: ThreadComposerRuntimeCore | undefined,\n): ThreadComposerState => {\n return Object.freeze({\n type: \"thread\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n canSend: runtime?.canSend ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n attachmentAccept: runtime?.attachmentAccept ?? \"\",\n dictation: runtime?.dictation,\n quote: runtime?.quote,\n queue: runtime?.queue ?? EMPTY_ARRAY,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nconst getEditComposerState = (\n runtime: EditComposerRuntimeCore | undefined,\n): EditComposerState => {\n return Object.freeze({\n type: \"edit\",\n\n isEditing: runtime?.isEditing ?? false,\n canCancel: runtime?.canCancel ?? false,\n canSend: runtime?.canSend ?? false,\n isEmpty: runtime?.isEmpty ?? true,\n\n text: runtime?.text ?? \"\",\n role: runtime?.role ?? \"user\",\n attachments: runtime?.attachments ?? EMPTY_ARRAY,\n runConfig: runtime?.runConfig ?? EMPTY_OBJECT,\n attachmentAccept: runtime?.attachmentAccept ?? \"\",\n dictation: runtime?.dictation,\n quote: runtime?.quote,\n queue: runtime?.queue ?? EMPTY_ARRAY,\n\n parentId: runtime?.parentId ?? null,\n sourceId: runtime?.sourceId ?? null,\n\n value: runtime?.text ?? \"\",\n });\n};\n\nexport type ComposerRuntime = {\n readonly path: ComposerRuntimePath;\n readonly type: \"edit\" | \"thread\";\n\n /**\n * Get the current state of the composer. Includes any data that has been added to the composer.\n */\n getState(): ComposerState;\n\n /**\n * Add an attachment to the composer. Accepts either a standard File object\n * (processed through the AttachmentAdapter) or a CreateAttachment descriptor\n * for external-source attachments (URLs, API data, CMS references). External\n * descriptors bypass the adapter's `add()` step but still respect\n * `adapter.accept` when an adapter is configured; without an adapter they\n * are added as-is.\n * @param fileOrAttachment The file or attachment descriptor to add.\n */\n addAttachment(fileOrAttachment: File | CreateAttachment): Promise<void>;\n\n /**\n * Set the text of the composer.\n * @param text The text to set in the composer.\n */\n setText(text: string): void;\n\n /**\n * Set the role of the composer. For instance, if you'd like a specific message to have the 'assistant' role, you can do so here.\n * @param role The role to set in the composer.\n */\n setRole(role: MessageRole): void;\n\n /**\n * Set the run config of the composer. This is used to send custom configuration data to the model.\n * Within your backend, you can use the `runConfig` object.\n * Example:\n * ```ts\n * composerRuntime.setRunConfig({\n * custom: { customField: \"customValue\" }\n * });\n * ```\n * @param runConfig The run config to set in the composer.\n */\n setRunConfig(runConfig: RunConfig): void;\n\n /**\n * Reset the composer. This will clear the entire state of the composer, including all text and attachments.\n */\n reset(): Promise<void>;\n\n /**\n * Clear all attachments from the composer.\n */\n clearAttachments(): Promise<void>;\n\n /**\n * Send a message. This will send whatever text or attachments are in the composer.\n * @param options Optional send options. Use `{ startRun: true }` to force starting a new run.\n */\n send(options?: SendOptions): void;\n\n /**\n * Cancel the current run. In edit mode, this will exit edit mode.\n */\n cancel(): void;\n\n /** Promote a queued message so it processes next. */\n steerQueueItem(queueItemId: string): void;\n\n /** Remove a queued message. */\n removeQueueItem(queueItemId: string): void;\n\n /**\n * Listens for changes to the composer state.\n * @param callback The callback to call when the composer state changes.\n */\n subscribe(callback: () => void): Unsubscribe;\n\n /**\n * Get an attachment by index.\n * @param idx The index of the attachment to get.\n */\n getAttachmentByIndex(idx: number): AttachmentRuntime;\n\n /**\n * Start dictation to convert voice to text input.\n * Requires a DictationAdapter to be configured.\n */\n startDictation(): void;\n\n /**\n * Stop the current dictation session.\n */\n stopDictation(): void;\n\n /**\n * Set a quote for the next message. Pass undefined to clear.\n * @param quote The quote info to set, or undefined to clear.\n */\n setQuote(quote: QuoteInfo | undefined): void;\n\n /**\n * @deprecated This API is still under active development and might change without notice.\n */\n unstable_on<E extends ComposerRuntimeEventType>(\n event: E,\n callback: ComposerRuntimeEventCallback<E>,\n ): Unsubscribe;\n};\n\nexport abstract class ComposerRuntimeImpl implements ComposerRuntime {\n public get path() {\n return this._core.path;\n }\n\n public abstract get type(): \"edit\" | \"thread\";\n\n constructor(protected _core: ComposerRuntimeCoreBinding) {}\n\n protected __internal_bindMethods() {\n this.setText = this.setText.bind(this);\n this.setRunConfig = this.setRunConfig.bind(this);\n this.getState = this.getState.bind(this);\n this.subscribe = this.subscribe.bind(this);\n this.addAttachment = this.addAttachment.bind(this);\n this.reset = this.reset.bind(this);\n this.clearAttachments = this.clearAttachments.bind(this);\n this.send = this.send.bind(this);\n this.cancel = this.cancel.bind(this);\n this.steerQueueItem = this.steerQueueItem.bind(this);\n this.removeQueueItem = this.removeQueueItem.bind(this);\n this.setRole = this.setRole.bind(this);\n this.getAttachmentByIndex = this.getAttachmentByIndex.bind(this);\n this.startDictation = this.startDictation.bind(this);\n this.stopDictation = this.stopDictation.bind(this);\n this.setQuote = this.setQuote.bind(this);\n this.unstable_on = this.unstable_on.bind(this);\n }\n\n public abstract getState(): ComposerState;\n\n public setText(text: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setText(text);\n }\n\n public setRunConfig(runConfig: RunConfig) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRunConfig(runConfig);\n }\n\n public addAttachment(fileOrAttachment: File | CreateAttachment) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.addAttachment(fileOrAttachment);\n }\n\n public reset() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.reset();\n }\n\n public clearAttachments() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n return core.clearAttachments();\n }\n\n public send(options?: SendOptions) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.send(options);\n }\n\n public cancel() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.cancel();\n }\n\n public steerQueueItem(queueItemId: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.steerQueueItem(queueItemId);\n }\n\n public removeQueueItem(queueItemId: string) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.removeQueueItem(queueItemId);\n }\n\n public setRole(role: MessageRole) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setRole(role);\n }\n\n public startDictation() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.startDictation();\n }\n\n public stopDictation() {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.stopDictation();\n }\n\n public setQuote(quote: QuoteInfo | undefined) {\n const core = this._core.getState();\n if (!core) throw new Error(\"Composer is not available\");\n core.setQuote(quote);\n }\n\n public subscribe(callback: () => void) {\n return this._core.subscribe(callback);\n }\n\n private _eventSubscriptionSubjects = new Map<\n string,\n EventSubscriptionSubject<ComposerRuntimeEventType>\n >();\n\n public unstable_on<E extends ComposerRuntimeEventType>(\n event: E,\n callback: ComposerRuntimeEventCallback<E>,\n ): Unsubscribe {\n let subject = this._eventSubscriptionSubjects.get(event);\n if (!subject) {\n subject = new EventSubscriptionSubject<ComposerRuntimeEventType>({\n event,\n binding: this._core,\n });\n this._eventSubscriptionSubjects.set(event, subject);\n }\n return subject.subscribe(callback as (payload?: unknown) => void);\n }\n\n public abstract getAttachmentByIndex(idx: number): AttachmentRuntime;\n}\n\nexport type ThreadComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"thread\" };\n readonly type: \"thread\";\n getState(): ThreadComposerState;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"thread-composer\" };\n};\n\nexport class ThreadComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements ThreadComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & {\n composerSource: \"thread\";\n };\n }\n\n public get type() {\n return \"thread\" as const;\n }\n\n private _getState;\n\n constructor(core: ThreadComposerRuntimeCoreBinding) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getThreadComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n this._getState = stateBinding.getState.bind(stateBinding);\n\n this.__internal_bindMethods();\n }\n\n public override getState(): ThreadComposerState {\n return this._getState();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new ThreadComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"thread-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"thread-composer\",\n } satisfies AttachmentState & { source: \"thread-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n\nexport type EditComposerRuntime = Omit<\n ComposerRuntime,\n \"getState\" | \"getAttachmentByIndex\"\n> & {\n readonly path: ComposerRuntimePath & { composerSource: \"edit\" };\n readonly type: \"edit\";\n\n getState(): EditComposerState;\n beginEdit(): void;\n\n getAttachmentByIndex(\n idx: number,\n ): AttachmentRuntime & { source: \"edit-composer\" };\n};\n\nexport class EditComposerRuntimeImpl\n extends ComposerRuntimeImpl\n implements EditComposerRuntime\n{\n public override get path() {\n return this._core.path as ComposerRuntimePath & { composerSource: \"edit\" };\n }\n\n public get type() {\n return \"edit\" as const;\n }\n\n private _getState;\n constructor(\n core: EditComposerRuntimeCoreBinding,\n private _beginEdit: () => void,\n ) {\n const stateBinding = new LazyMemoizeSubject({\n path: core.path,\n getState: () => getEditComposerState(core.getState()),\n subscribe: (callback) => core.subscribe(callback),\n });\n\n super({\n path: core.path,\n getState: () => core.getState(),\n subscribe: (callback) => stateBinding.subscribe(callback),\n });\n\n this._getState = stateBinding.getState.bind(stateBinding);\n\n this.__internal_bindMethods();\n }\n\n public override __internal_bindMethods() {\n super.__internal_bindMethods();\n this.beginEdit = this.beginEdit.bind(this);\n }\n\n public override getState(): EditComposerState {\n return this._getState();\n }\n\n public beginEdit() {\n this._beginEdit();\n }\n\n public getAttachmentByIndex(idx: number) {\n return new EditComposerAttachmentRuntimeImpl(\n new ShallowMemoizeSubject({\n path: {\n ...this.path,\n attachmentSource: \"edit-composer\",\n attachmentSelector: { type: \"index\", index: idx },\n ref: `${this.path.ref}.attachments[${idx}]`,\n },\n getState: () => {\n const attachments = this.getState().attachments;\n const attachment = attachments[idx];\n if (!attachment) return SKIP_UPDATE;\n\n return {\n ...attachment,\n source: \"edit-composer\",\n } satisfies AttachmentState & { source: \"edit-composer\" };\n },\n subscribe: (callback) => this._core.subscribe(callback),\n }),\n this._core,\n );\n }\n}\n"],"mappings":";;;AAmFA,MAAM4C,cAAcC,OAAOC,OAAO,CAAA,CAAE;AACpC,MAAMC,eAAeF,OAAOC,OAAO,CAAC,CAAC;AACrC,MAAME,0BACJC,YACwB;CACxB,OAAOJ,OAAOC,OAAO;EACnBP,MAAM;EAENX,WAAWqB,SAASrB,aAAa;EACjCF,WAAWuB,SAASvB,aAAa;EACjCC,SAASsB,SAAStB,WAAW;EAC7BE,SAASoB,SAASpB,WAAW;EAE7BG,aAAaiB,SAASjB,eAAeY;EACrCd,MAAMmB,SAASnB,QAAQ;EACvBC,MAAMkB,SAASlB,QAAQ;EACvBE,WAAWgB,SAAShB,aAAac;EACjCb,kBAAkBe,SAASf,oBAAoB;EAC/CC,WAAWc,SAASd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CAAC,GACD,KAAKU,KACP;CACF;AACF"}
@@ -1,4 +1,4 @@
1
- import { MessagePartStatus, ThreadAssistantMessagePart, ThreadUserMessagePart, ToolCallMessagePartStatus } from "../../types/message.js";
1
+ import { MessagePartStatus, ThreadAssistantMessagePart, ThreadUserMessagePart, ToolApprovalResponse, ToolCallMessagePartStatus } from "../../types/message.js";
2
2
  import { Unsubscribe } from "../../types/unsubscribe.js";
3
3
  import { MessagePartRuntimePath } from "./paths.js";
4
4
  import { SubscribableWithState } from "../../subscribable/subscribable.js";
@@ -14,10 +14,7 @@ type MessagePartSnapshotBinding = SubscribableWithState<MessagePartState, Messag
14
14
  type MessagePartRuntime = {
15
15
  addToolResult(result: any | ToolResponse<any>): void;
16
16
  resumeToolCall(payload: unknown): void;
17
- respondToToolApproval(response: {
18
- approved: boolean;
19
- reason?: string;
20
- }): void;
17
+ respondToToolApproval(response: ToolApprovalResponse): void;
21
18
  readonly path: MessagePartRuntimePath;
22
19
  getState(): MessagePartState;
23
20
  subscribe(callback: () => void): Unsubscribe;
@@ -32,10 +29,7 @@ declare class MessagePartRuntimeImpl implements MessagePartRuntime {
32
29
  getState(): MessagePartState;
33
30
  addToolResult(result: any | ToolResponse<any>): void;
34
31
  resumeToolCall(payload: unknown): void;
35
- respondToToolApproval(response: {
36
- approved: boolean;
37
- reason?: string;
38
- }): void;
32
+ respondToToolApproval(response: ToolApprovalResponse): void;
39
33
  subscribe(callback: () => void): Unsubscribe;
40
34
  }
41
35
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"message-part-runtime.d.ts","names":[],"sources":["../../../src/runtime/api/message-part-runtime.ts"],"mappings":";;;;;;;;;KAaY,gBAAA,IACR,qBAAA,GACA,0BAAA;EAAA,SAEO,MAAA,EAAQ,iBAAA,GAAoB,yBAAA;AAAA;AAAA,KAGlC,0BAAA,GAA6B,qBAAA,CAChC,gBAAA,EACA,sBAAA;AAAA,KAGU,kBAAA;EACV,aAAA,CAAc,MAAA,QAAc,YAAA;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Y,wBAAA;EAAA,UAKZ,sBAAA;EAQH,QAAA,IAAQ,gBAAA;EAIR,aAAA,CAAc,MAAA,QAAc,YAAA;EA8B5B,cAAA,CAAe,OAAA;EAgBf,qBAAA,CAAsB,QAAA,EAAU,oBAAA;EAyBhC,SAAA,CAAU,QAAA,eAAoB,WAAA;AAAA"}
@@ -1,3 +1,4 @@
1
+ import { resolveToolApprovalResponse } from "../utils/resolveToolApprovalResponse.js";
1
2
  import { ToolResponse } from "assistant-stream";
2
3
  //#region src/runtime/api/message-part-runtime.ts
3
4
  var MessagePartRuntimeImpl = class {
@@ -58,13 +59,9 @@ var MessagePartRuntimeImpl = class {
58
59
  const state = this.contentBinding.getState();
59
60
  if (!state) throw new Error("Message part is not available");
60
61
  if (state.type !== "tool-call") throw new Error("Tried to respond to tool approval on non-tool message part");
61
- if (!state.approval || state.approval.approved !== void 0) throw new Error("Tool call has no pending approval");
62
+ if (!state.approval || state.approval.approved !== void 0 || state.approval.resolution !== void 0) throw new Error("Tool call has no pending approval");
62
63
  if (!this.threadApi) throw new Error("Thread API is not available");
63
- this.threadApi.getState().respondToToolApproval({
64
- approvalId: state.approval.id,
65
- approved: response.approved,
66
- ...response.reason != null && { reason: response.reason }
67
- });
64
+ this.threadApi.getState().respondToToolApproval(resolveToolApprovalResponse(state.approval, response));
68
65
  }
69
66
  subscribe(callback) {
70
67
  return this.contentBinding.subscribe(callback);