@assistant-ui/core 0.3.18 → 0.3.20

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 (804) hide show
  1. package/dist/adapters/attachment.d.ts +9 -10
  2. package/dist/adapters/attachment.d.ts.map +1 -1
  3. package/dist/adapters/attachment.js +2 -1
  4. package/dist/adapters/attachment.js.map +1 -1
  5. package/dist/adapters/directive-formatter.d.ts +1 -2
  6. package/dist/adapters/directive-formatter.d.ts.map +1 -1
  7. package/dist/adapters/feedback.d.ts +2 -2
  8. package/dist/adapters/feedback.d.ts.map +1 -1
  9. package/dist/adapters/speech.d.ts +6 -7
  10. package/dist/adapters/speech.d.ts.map +1 -1
  11. package/dist/adapters/speech.js +13 -3
  12. package/dist/adapters/speech.js.map +1 -1
  13. package/dist/adapters/suggestion.d.ts +5 -6
  14. package/dist/adapters/suggestion.d.ts.map +1 -1
  15. package/dist/adapters/thread-history.d.ts +10 -7
  16. package/dist/adapters/thread-history.d.ts.map +1 -1
  17. package/dist/adapters/trigger.d.ts +1 -2
  18. package/dist/adapters/trigger.d.ts.map +1 -1
  19. package/dist/adapters/voice.d.ts +5 -6
  20. package/dist/adapters/voice.d.ts.map +1 -1
  21. package/dist/index.d.ts +2 -2
  22. package/dist/index.js.map +1 -1
  23. package/dist/internal/duplicate-detection.d.ts +1 -2
  24. package/dist/internal/duplicate-detection.d.ts.map +1 -1
  25. package/dist/internal.d.ts +1 -1
  26. package/dist/model-context/frame/host.d.ts +1 -2
  27. package/dist/model-context/frame/host.d.ts.map +1 -1
  28. package/dist/model-context/frame/host.js +26 -11
  29. package/dist/model-context/frame/host.js.map +1 -1
  30. package/dist/model-context/frame/provider.d.ts +1 -2
  31. package/dist/model-context/frame/provider.d.ts.map +1 -1
  32. package/dist/model-context/frame/types.d.ts +5 -6
  33. package/dist/model-context/frame/types.d.ts.map +1 -1
  34. package/dist/model-context/interactable-composer-metadata.d.ts +9 -10
  35. package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
  36. package/dist/model-context/interactable-composer-metadata.js +11 -9
  37. package/dist/model-context/interactable-composer-metadata.js.map +1 -1
  38. package/dist/model-context/registry-handles.d.ts +3 -4
  39. package/dist/model-context/registry-handles.d.ts.map +1 -1
  40. package/dist/model-context/registry.d.ts +1 -2
  41. package/dist/model-context/registry.d.ts.map +1 -1
  42. package/dist/model-context/tool-call-text.d.ts +2 -3
  43. package/dist/model-context/tool-call-text.d.ts.map +1 -1
  44. package/dist/model-context/tool.d.ts +2 -3
  45. package/dist/model-context/tool.d.ts.map +1 -1
  46. package/dist/model-context/types.d.ts +8 -9
  47. package/dist/model-context/types.d.ts.map +1 -1
  48. package/dist/react/AssistantProvider.d.ts +3 -4
  49. package/dist/react/AssistantProvider.d.ts.map +1 -1
  50. package/dist/react/AssistantRuntimeProvider.d.ts +1 -2
  51. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  52. package/dist/react/RuntimeAdapter.d.ts +2 -3
  53. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  54. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +4 -5
  55. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  56. package/dist/react/adapters/LocalStorageThreadListAdapter.js +43 -19
  57. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  58. package/dist/react/adapters/TitleGenerationAdapter.d.ts +2 -3
  59. package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
  60. package/dist/react/client/AdaptedRemoteThread.d.ts +1 -2
  61. package/dist/react/client/AdaptedRemoteThread.d.ts.map +1 -1
  62. package/dist/react/client/DataRenderers.d.ts +1 -2
  63. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  64. package/dist/react/client/DataRenderers.js +20 -15
  65. package/dist/react/client/DataRenderers.js.map +1 -1
  66. package/dist/react/client/InMemoryThreadList.d.ts +3 -4
  67. package/dist/react/client/InMemoryThreadList.d.ts.map +1 -1
  68. package/dist/react/client/Interactables.d.ts +1 -2
  69. package/dist/react/client/Interactables.d.ts.map +1 -1
  70. package/dist/react/client/Interactables.js +11 -5
  71. package/dist/react/client/Interactables.js.map +1 -1
  72. package/dist/react/client/RemoteThreadList.d.ts +2 -3
  73. package/dist/react/client/RemoteThreadList.d.ts.map +1 -1
  74. package/dist/react/client/RemoteThreadList.js +3 -2
  75. package/dist/react/client/RemoteThreadList.js.map +1 -1
  76. package/dist/react/client/Tools.d.ts +2 -2
  77. package/dist/react/client/Tools.d.ts.map +1 -1
  78. package/dist/react/client/interactable-model-context.d.ts +2 -3
  79. package/dist/react/client/interactable-model-context.d.ts.map +1 -1
  80. package/dist/react/client/interactable-model-context.js +3 -2
  81. package/dist/react/client/interactable-model-context.js.map +1 -1
  82. package/dist/react/index.d.ts +2 -2
  83. package/dist/react/index.js +2 -2
  84. package/dist/react/interactables-legacy/Interactables.d.ts +1 -2
  85. package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
  86. package/dist/react/interactables-legacy/interactable-model-context.d.ts +2 -3
  87. package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
  88. package/dist/react/interactables-legacy/scopes.d.ts +9 -10
  89. package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
  90. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +2 -3
  91. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
  92. package/dist/react/interactables-legacy/useAssistantInteractable.js +3 -0
  93. package/dist/react/interactables-legacy/useAssistantInteractable.js.map +1 -1
  94. package/dist/react/interactables-legacy/useInteractableState.d.ts +1 -2
  95. package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
  96. package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts +1 -2
  97. package/dist/react/interactables-shared/useInteractablePersistenceQueue.d.ts.map +1 -1
  98. package/dist/react/model-context/define-mcp-toolkit.d.ts +4 -5
  99. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
  100. package/dist/react/model-context/define-toolkit.d.ts +2 -3
  101. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  102. package/dist/react/model-context/external-tool.d.ts +1 -2
  103. package/dist/react/model-context/external-tool.d.ts.map +1 -1
  104. package/dist/react/model-context/human-tool.d.ts +3 -4
  105. package/dist/react/model-context/human-tool.d.ts.map +1 -1
  106. package/dist/react/model-context/interactableTool.d.ts +3 -4
  107. package/dist/react/model-context/interactableTool.d.ts.map +1 -1
  108. package/dist/react/model-context/makeAssistantDataUI.d.ts +2 -3
  109. package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
  110. package/dist/react/model-context/makeAssistantTool.d.ts +2 -3
  111. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  112. package/dist/react/model-context/makeAssistantToolUI.d.ts +2 -3
  113. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  114. package/dist/react/model-context/provider-tool.d.ts +2 -3
  115. package/dist/react/model-context/provider-tool.d.ts.map +1 -1
  116. package/dist/react/model-context/stub-tool.d.ts +1 -2
  117. package/dist/react/model-context/stub-tool.d.ts.map +1 -1
  118. package/dist/react/model-context/toolbox.d.ts +9 -10
  119. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  120. package/dist/react/model-context/useAssistantContext.d.ts +2 -2
  121. package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
  122. package/dist/react/model-context/useAssistantDataUI.d.ts +2 -3
  123. package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
  124. package/dist/react/model-context/useAssistantInstructions.d.ts +2 -2
  125. package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
  126. package/dist/react/model-context/useAssistantTool.d.ts +2 -3
  127. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  128. package/dist/react/model-context/useAssistantToolUI.d.ts +2 -3
  129. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  130. package/dist/react/model-context/useAuiToolOverrides.d.ts +1 -2
  131. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
  132. package/dist/react/model-context/useInlineRender.d.ts +1 -2
  133. package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
  134. package/dist/react/model-context/useInteractable.d.ts +4 -5
  135. package/dist/react/model-context/useInteractable.d.ts.map +1 -1
  136. package/dist/react/model-context/useInteractable.js +4 -1
  137. package/dist/react/model-context/useInteractable.js.map +1 -1
  138. package/dist/react/model-context/useInteractableState.d.ts +1 -2
  139. package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
  140. package/dist/react/model-context/useInteractableVersions.d.ts +1 -2
  141. package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
  142. package/dist/react/model-context/useInteractableVersions.js +1 -1
  143. package/dist/react/model-context/useToolArgsStatus.d.ts +2 -3
  144. package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
  145. package/dist/react/primitive-hooks/useActionBarCopy.d.ts +2 -3
  146. package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
  147. package/dist/react/primitive-hooks/useActionBarEdit.d.ts +1 -2
  148. package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
  149. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts +2 -3
  150. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
  151. package/dist/react/primitive-hooks/useActionBarReload.d.ts +1 -2
  152. package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
  153. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts +1 -2
  154. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
  155. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts +1 -2
  156. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
  157. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts +1 -2
  158. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
  159. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts +1 -2
  160. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
  161. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +1 -2
  162. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
  163. package/dist/react/primitive-hooks/useComposerCancel.d.ts +1 -2
  164. package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
  165. package/dist/react/primitive-hooks/useComposerDictate.d.ts +1 -2
  166. package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
  167. package/dist/react/primitive-hooks/useComposerSend.d.ts +1 -2
  168. package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
  169. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts +1 -2
  170. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
  171. package/dist/react/primitive-hooks/useEditComposerSend.d.ts +1 -2
  172. package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
  173. package/dist/react/primitive-hooks/useMessageBranching.d.ts +1 -2
  174. package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
  175. package/dist/react/primitive-hooks/useMessageError.d.ts +1 -2
  176. package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
  177. package/dist/react/primitive-hooks/useMessageReload.d.ts +1 -2
  178. package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
  179. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +2 -3
  180. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
  181. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts +1 -2
  182. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
  183. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts +1 -2
  184. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
  185. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts +1 -2
  186. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
  187. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts +1 -2
  188. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
  189. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts +1 -2
  190. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
  191. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts +1 -2
  192. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
  193. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts +1 -2
  194. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
  195. package/dist/react/primitive-hooks/useThreadListNew.d.ts +1 -2
  196. package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
  197. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts +1 -2
  198. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
  199. package/dist/react/primitive-hooks/useThreadMessages.d.ts +1 -2
  200. package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
  201. package/dist/react/primitive-hooks/useVoice.d.ts +3 -4
  202. package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
  203. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +2 -3
  204. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
  205. package/dist/react/primitives/composer/ComposerAttachments.d.ts +4 -5
  206. package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
  207. package/dist/react/primitives/composer/ComposerIf.d.ts +4 -5
  208. package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
  209. package/dist/react/primitives/composer/ComposerQueue.d.ts +2 -3
  210. package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
  211. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +4 -5
  212. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
  213. package/dist/react/primitives/generativeUI/GenerativeUI.js +27 -28
  214. package/dist/react/primitives/generativeUI/GenerativeUI.js.map +1 -1
  215. package/dist/react/primitives/message/MessageAttachments.d.ts +4 -5
  216. package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
  217. package/dist/react/primitives/message/MessageGroupedParts.d.ts +13 -5
  218. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  219. package/dist/react/primitives/message/MessageGroupedParts.js +3 -2
  220. package/dist/react/primitives/message/MessageGroupedParts.js.map +1 -1
  221. package/dist/react/primitives/message/MessageParts.d.ts +10 -10
  222. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  223. package/dist/react/primitives/message/MessageQuote.d.ts +2 -3
  224. package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
  225. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +2 -3
  226. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
  227. package/dist/react/primitives/part/PartMessages.d.ts +4 -4
  228. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  229. package/dist/react/primitives/part/PartMessages.js +1 -0
  230. package/dist/react/primitives/part/PartMessages.js.map +1 -1
  231. package/dist/react/primitives/thread/ThreadMessages.d.ts +7 -8
  232. package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
  233. package/dist/react/primitives/thread/ThreadMessages.js +6 -5
  234. package/dist/react/primitives/thread/ThreadMessages.js.map +1 -1
  235. package/dist/react/primitives/thread/ThreadSuggestions.d.ts +5 -6
  236. package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
  237. package/dist/react/primitives/threadList/ThreadListItems.d.ts +4 -5
  238. package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  239. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +2 -3
  240. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
  241. package/dist/react/providers/AttachmentByIndexProvider.d.ts +2 -3
  242. package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
  243. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +1 -2
  244. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
  245. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +1 -2
  246. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
  247. package/dist/react/providers/MessageByIdProvider.d.ts +1 -2
  248. package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
  249. package/dist/react/providers/MessageByIndexProvider.d.ts +1 -2
  250. package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
  251. package/dist/react/providers/PartByIndexProvider.d.ts +1 -2
  252. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
  253. package/dist/react/providers/QueueItemByIndexProvider.d.ts +2 -3
  254. package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
  255. package/dist/react/providers/ReadonlyThreadProvider.d.ts +2 -3
  256. package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
  257. package/dist/react/providers/SuggestionByIndexProvider.d.ts +2 -3
  258. package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
  259. package/dist/react/providers/TextMessagePartProvider.d.ts +1 -2
  260. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  261. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +1 -2
  262. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
  263. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +1 -2
  264. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
  265. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +3 -2
  266. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  267. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +17 -7
  268. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  269. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +1 -2
  270. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  271. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +2 -1
  272. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  273. package/dist/react/runtimes/RemoteThreadResource.d.ts +4 -5
  274. package/dist/react/runtimes/RemoteThreadResource.d.ts.map +1 -1
  275. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +3 -3
  276. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
  277. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts +2 -3
  278. package/dist/react/runtimes/assistant-transport/commandQueue.d.ts.map +1 -1
  279. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts +3 -4
  280. package/dist/react/runtimes/assistant-transport/replayBoundaryStream.d.ts.map +1 -1
  281. package/dist/react/runtimes/assistant-transport/runManager.d.ts +2 -3
  282. package/dist/react/runtimes/assistant-transport/runManager.d.ts.map +1 -1
  283. package/dist/react/runtimes/assistant-transport/types.d.ts +17 -18
  284. package/dist/react/runtimes/assistant-transport/types.d.ts.map +1 -1
  285. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts +4 -5
  286. package/dist/react/runtimes/assistant-transport/useAssistantTransportRuntime.d.ts.map +1 -1
  287. package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts +1 -2
  288. package/dist/react/runtimes/assistant-transport/useConvertedState.d.ts.map +1 -1
  289. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts +1 -2
  290. package/dist/react/runtimes/assistant-transport/useLatestRef.d.ts.map +1 -1
  291. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +3 -26
  292. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  293. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js +152 -378
  294. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.js.map +1 -1
  295. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +2 -2
  296. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
  297. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +22 -2
  298. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  299. package/dist/react/runtimes/cloud/auiV0.d.ts +51 -18
  300. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  301. package/dist/react/runtimes/cloud/auiV0.js +125 -17
  302. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  303. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts +6 -6
  304. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.d.ts.map +1 -1
  305. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js +4 -0
  306. package/dist/react/runtimes/cloud/createCloudThreadListAdapter.js.map +1 -1
  307. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts +1 -2
  308. package/dist/react/runtimes/cloud/createCloudThreadListAdapterCreateFallback.d.ts.map +1 -1
  309. package/dist/react/runtimes/cloud/sdkIdentity.d.ts +5 -0
  310. package/dist/react/runtimes/cloud/sdkIdentity.d.ts.map +1 -0
  311. package/dist/react/runtimes/cloud/sdkIdentity.js +9 -0
  312. package/dist/react/runtimes/cloud/sdkIdentity.js.map +1 -0
  313. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +1 -2
  314. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  315. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts +1 -2
  316. package/dist/react/runtimes/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  317. package/dist/react/runtimes/createMessageConverter.d.ts +1 -2
  318. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  319. package/dist/react/runtimes/createRuntimeExtras.d.ts +3 -4
  320. package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
  321. package/dist/react/runtimes/external-message-converter.d.ts +14 -4
  322. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  323. package/dist/react/runtimes/external-message-converter.js +26 -61
  324. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  325. package/dist/react/runtimes/useExternalStoreRuntime.d.ts +1 -2
  326. package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
  327. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +1 -2
  328. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
  329. package/dist/react/runtimes/useLocalRuntime.d.ts +3 -4
  330. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  331. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +1 -2
  332. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
  333. package/dist/react/runtimes/useRemoteThreadListRuntime.js +3 -3
  334. package/dist/react/runtimes/useRemoteThreadListRuntime.js.map +1 -1
  335. package/dist/react/runtimes/useRuntimeAdapters.d.ts +4 -4
  336. package/dist/react/runtimes/useRuntimeAdapters.d.ts.map +1 -1
  337. package/dist/react/runtimes/useStreamingTiming.d.ts +2 -2
  338. package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
  339. package/dist/react/types/MessagePartComponentTypes.d.ts +26 -27
  340. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
  341. package/dist/react/types/scopes/dataRenderers.d.ts +3 -4
  342. package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
  343. package/dist/react/types/scopes/interactables.d.ts +10 -11
  344. package/dist/react/types/scopes/interactables.d.ts.map +1 -1
  345. package/dist/react/types/scopes/tools.d.ts +4 -5
  346. package/dist/react/types/scopes/tools.d.ts.map +1 -1
  347. package/dist/react/utils/getMessageQuote.d.ts +1 -2
  348. package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
  349. package/dist/react/utils/groupParts.d.ts +13 -9
  350. package/dist/react/utils/groupParts.d.ts.map +1 -1
  351. package/dist/react/utils/groupParts.js +6 -0
  352. package/dist/react/utils/groupParts.js.map +1 -1
  353. package/dist/react/utils/useJSONEqual.d.ts +3 -2
  354. package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
  355. package/dist/react/utils/useJSONEqual.js +6 -1
  356. package/dist/react/utils/useJSONEqual.js.map +1 -1
  357. package/dist/react/utils/useJSONSchemaDependency.d.ts +6 -0
  358. package/dist/react/utils/useJSONSchemaDependency.d.ts.map +1 -0
  359. package/dist/react/utils/useJSONSchemaDependency.js +20 -0
  360. package/dist/react/utils/useJSONSchemaDependency.js.map +1 -0
  361. package/dist/runtime/api/assistant-runtime.d.ts +2 -3
  362. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  363. package/dist/runtime/api/attachment-runtime.d.ts +6 -7
  364. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  365. package/dist/runtime/api/bindings.d.ts +5 -6
  366. package/dist/runtime/api/bindings.d.ts.map +1 -1
  367. package/dist/runtime/api/composer-runtime.d.ts +10 -10
  368. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  369. package/dist/runtime/api/message-part-runtime.d.ts +3 -4
  370. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  371. package/dist/runtime/api/message-part-runtime.js +3 -2
  372. package/dist/runtime/api/message-part-runtime.js.map +1 -1
  373. package/dist/runtime/api/message-runtime.d.ts +8 -6
  374. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  375. package/dist/runtime/api/message-runtime.js +3 -2
  376. package/dist/runtime/api/message-runtime.js.map +1 -1
  377. package/dist/runtime/api/paths.d.ts +6 -7
  378. package/dist/runtime/api/paths.d.ts.map +1 -1
  379. package/dist/runtime/api/thread-list-item-runtime.d.ts +8 -8
  380. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  381. package/dist/runtime/api/thread-list-runtime.d.ts +4 -5
  382. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  383. package/dist/runtime/api/thread-runtime.d.ts +10 -11
  384. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  385. package/dist/runtime/api/thread-runtime.js +2 -5
  386. package/dist/runtime/api/thread-runtime.js.map +1 -1
  387. package/dist/runtime/base/base-assistant-runtime-core.d.ts +1 -2
  388. package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
  389. package/dist/runtime/base/base-composer-runtime-core.d.ts +2 -2
  390. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  391. package/dist/runtime/base/base-composer-runtime-core.js +46 -10
  392. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  393. package/dist/runtime/base/base-thread-runtime-core.d.ts +10 -3
  394. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  395. package/dist/runtime/base/base-thread-runtime-core.js +212 -77
  396. package/dist/runtime/base/base-thread-runtime-core.js.map +1 -1
  397. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +1 -2
  398. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  399. package/dist/runtime/base/default-edit-composer-runtime-core.js +12 -2
  400. package/dist/runtime/base/default-edit-composer-runtime-core.js.map +1 -1
  401. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -2
  402. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  403. package/dist/runtime/base/default-thread-composer-runtime-core.js +7 -1
  404. package/dist/runtime/base/default-thread-composer-runtime-core.js.map +1 -1
  405. package/dist/runtime/branch/external-thread-branch-adapter.d.ts +1 -2
  406. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
  407. package/dist/runtime/interfaces/assistant-runtime-core.d.ts +1 -2
  408. package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
  409. package/dist/runtime/interfaces/composer-runtime-core.d.ts +10 -11
  410. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  411. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +4 -5
  412. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  413. package/dist/runtime/interfaces/thread-runtime-core.d.ts +23 -16
  414. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  415. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +2 -3
  416. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
  417. package/dist/runtime/queue/message-queue.d.ts +10 -4
  418. package/dist/runtime/queue/message-queue.d.ts.map +1 -1
  419. package/dist/runtime/queue/message-queue.js +70 -7
  420. package/dist/runtime/queue/message-queue.js.map +1 -1
  421. package/dist/runtime/queue/queue-item.d.ts +2 -3
  422. package/dist/runtime/queue/queue-item.d.ts.map +1 -1
  423. package/dist/runtime/utils/abortable-thread-load.d.ts +2 -3
  424. package/dist/runtime/utils/abortable-thread-load.d.ts.map +1 -1
  425. package/dist/runtime/utils/attachment-add-operations.d.ts +3 -4
  426. package/dist/runtime/utils/attachment-add-operations.d.ts.map +1 -1
  427. package/dist/runtime/utils/auto-status.d.ts +9 -6
  428. package/dist/runtime/utils/auto-status.d.ts.map +1 -1
  429. package/dist/runtime/utils/auto-status.js +12 -4
  430. package/dist/runtime/utils/auto-status.js.map +1 -1
  431. package/dist/runtime/utils/chat-model-adapter.d.ts +5 -6
  432. package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
  433. package/dist/runtime/utils/external-message-conversion.d.ts +26 -15
  434. package/dist/runtime/utils/external-message-conversion.d.ts.map +1 -1
  435. package/dist/runtime/utils/external-message-conversion.js +51 -14
  436. package/dist/runtime/utils/external-message-conversion.js.map +1 -1
  437. package/dist/runtime/utils/external-store-message.d.ts +4 -5
  438. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  439. package/dist/runtime/utils/message-repository-session.d.ts +3 -4
  440. package/dist/runtime/utils/message-repository-session.d.ts.map +1 -1
  441. package/dist/runtime/utils/message-repository.d.ts +4 -5
  442. package/dist/runtime/utils/message-repository.d.ts.map +1 -1
  443. package/dist/runtime/utils/message-repository.js +3 -3
  444. package/dist/runtime/utils/message-repository.js.map +1 -1
  445. package/dist/runtime/utils/pending-tool-calls.d.ts +2 -3
  446. package/dist/runtime/utils/pending-tool-calls.d.ts.map +1 -1
  447. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +1 -2
  448. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
  449. package/dist/runtime/utils/runtime-extras-brand.d.ts +2 -3
  450. package/dist/runtime/utils/runtime-extras-brand.d.ts.map +1 -1
  451. package/dist/runtime/utils/stored-message-parts.d.ts +21 -0
  452. package/dist/runtime/utils/stored-message-parts.d.ts.map +1 -0
  453. package/dist/runtime/utils/stored-message-parts.js +83 -0
  454. package/dist/runtime/utils/stored-message-parts.js.map +1 -0
  455. package/dist/runtime/utils/streaming-timing.d.ts +4 -5
  456. package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
  457. package/dist/runtime/utils/thread-message-like.d.ts +7 -6
  458. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  459. package/dist/runtime/utils/thread-message-like.js +4 -2
  460. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  461. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts +3 -4
  462. package/dist/runtime/utils/thread-runtime-lifecycle.d.ts.map +1 -1
  463. package/dist/runtime/utils/tool-call-tree.d.ts +4 -5
  464. package/dist/runtime/utils/tool-call-tree.d.ts.map +1 -1
  465. package/dist/runtimes/assistant-transport/utils.d.ts +1 -2
  466. package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
  467. package/dist/runtimes/external-store/external-store-adapter.d.ts +9 -6
  468. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  469. package/dist/runtimes/external-store/external-store-runtime-core.d.ts +1 -2
  470. package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
  471. package/dist/runtimes/external-store/external-store-shared-options.d.ts +2 -3
  472. package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
  473. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +2 -3
  474. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  475. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +4 -3
  476. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  477. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +36 -6
  478. package/dist/runtimes/external-store/external-store-thread-runtime-core.js.map +1 -1
  479. package/dist/runtimes/external-store/thread-message-converter.d.ts +2 -3
  480. package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
  481. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts +2 -3
  482. package/dist/runtimes/inert/InertThreadRuntimeCore.d.ts.map +1 -1
  483. package/dist/runtimes/internal.d.ts +1 -1
  484. package/dist/runtimes/local/local-runtime-core.d.ts +1 -2
  485. package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
  486. package/dist/runtimes/local/local-runtime-options.d.ts +1 -2
  487. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  488. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +2 -3
  489. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
  490. package/dist/runtimes/local/local-thread-runtime-core.d.ts +10 -5
  491. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  492. package/dist/runtimes/local/local-thread-runtime-core.js +57 -10
  493. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  494. package/dist/runtimes/local/should-continue.d.ts +1 -2
  495. package/dist/runtimes/local/should-continue.d.ts.map +1 -1
  496. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +1 -2
  497. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  498. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -2
  499. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  500. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts +1 -2
  501. package/dist/runtimes/remote-thread-list/adapter-changed.d.ts.map +1 -1
  502. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +1 -2
  503. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  504. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +1 -2
  505. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
  506. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +16 -17
  507. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  508. package/dist/runtimes/remote-thread-list/title-generation.d.ts +7 -8
  509. package/dist/runtimes/remote-thread-list/title-generation.d.ts.map +1 -1
  510. package/dist/runtimes/remote-thread-list/title.d.ts +2 -3
  511. package/dist/runtimes/remote-thread-list/title.d.ts.map +1 -1
  512. package/dist/runtimes/remote-thread-list/types.d.ts +8 -9
  513. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  514. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +4 -5
  515. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
  516. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js +2 -1
  517. package/dist/runtimes/tool-invocations/ToolInvocationTracker.js.map +1 -1
  518. package/dist/store/clients/chain-of-thought-client.d.ts +1 -2
  519. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  520. package/dist/store/clients/external-thread.d.ts +3 -4
  521. package/dist/store/clients/external-thread.d.ts.map +1 -1
  522. package/dist/store/clients/external-thread.js +256 -211
  523. package/dist/store/clients/external-thread.js.map +1 -1
  524. package/dist/store/clients/model-context-client.d.ts +1 -2
  525. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  526. package/dist/store/clients/no-op-composer-client.d.ts +1 -2
  527. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  528. package/dist/store/clients/runtime-adapter.d.ts +1 -2
  529. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  530. package/dist/store/clients/single-thread-list.d.ts +1 -2
  531. package/dist/store/clients/single-thread-list.d.ts.map +1 -1
  532. package/dist/store/clients/suggestions.d.ts +3 -4
  533. package/dist/store/clients/suggestions.d.ts.map +1 -1
  534. package/dist/store/clients/thread-message-client.d.ts +2 -3
  535. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  536. package/dist/store/clients/thread-selection-events.d.ts +1 -2
  537. package/dist/store/clients/thread-selection-events.d.ts.map +1 -1
  538. package/dist/store/clients/thread-tasks.d.ts +12 -0
  539. package/dist/store/clients/thread-tasks.d.ts.map +1 -0
  540. package/dist/store/clients/thread-tasks.js +69 -0
  541. package/dist/store/clients/thread-tasks.js.map +1 -0
  542. package/dist/store/env.d.ts +1 -2
  543. package/dist/store/env.d.ts.map +1 -1
  544. package/dist/store/index.d.ts +3 -2
  545. package/dist/store/index.js +3 -3
  546. package/dist/store/primitive-predicates.d.ts +11 -12
  547. package/dist/store/primitive-predicates.d.ts.map +1 -1
  548. package/dist/store/primitive-predicates.js +4 -4
  549. package/dist/store/primitive-predicates.js.map +1 -1
  550. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +1 -2
  551. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  552. package/dist/store/runtime-clients/composer-runtime-client.d.ts +1 -2
  553. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  554. package/dist/store/runtime-clients/handle-runtime-action.d.ts +1 -2
  555. package/dist/store/runtime-clients/handle-runtime-action.d.ts.map +1 -1
  556. package/dist/store/runtime-clients/handle-thread-list-action.d.ts +1 -2
  557. package/dist/store/runtime-clients/handle-thread-list-action.d.ts.map +1 -1
  558. package/dist/store/runtime-clients/liveRef.d.ts +1 -2
  559. package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
  560. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +1 -2
  561. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  562. package/dist/store/runtime-clients/message-runtime-client.d.ts +1 -2
  563. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  564. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +1 -2
  565. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  566. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +1 -2
  567. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  568. package/dist/store/runtime-clients/thread-runtime-client.d.ts +1 -2
  569. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  570. package/dist/store/runtime-clients/thread-runtime-client.js +176 -128
  571. package/dist/store/runtime-clients/thread-runtime-client.js.map +1 -1
  572. package/dist/store/runtime-clients/useSubscribable.d.ts +1 -2
  573. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
  574. package/dist/store/scope-registration.d.ts +2 -0
  575. package/dist/store/scope-registration.d.ts.map +1 -1
  576. package/dist/store/scopes/attachment.d.ts +4 -5
  577. package/dist/store/scopes/attachment.d.ts.map +1 -1
  578. package/dist/store/scopes/chain-of-thought.d.ts +5 -6
  579. package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
  580. package/dist/store/scopes/composer.d.ts +6 -7
  581. package/dist/store/scopes/composer.d.ts.map +1 -1
  582. package/dist/store/scopes/message.d.ts +6 -6
  583. package/dist/store/scopes/message.d.ts.map +1 -1
  584. package/dist/store/scopes/model-context.d.ts +3 -4
  585. package/dist/store/scopes/model-context.d.ts.map +1 -1
  586. package/dist/store/scopes/part.d.ts +4 -5
  587. package/dist/store/scopes/part.d.ts.map +1 -1
  588. package/dist/store/scopes/queue-item.d.ts +4 -4
  589. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  590. package/dist/store/scopes/suggestion.d.ts +4 -5
  591. package/dist/store/scopes/suggestion.d.ts.map +1 -1
  592. package/dist/store/scopes/suggestions.d.ts +5 -6
  593. package/dist/store/scopes/suggestions.d.ts.map +1 -1
  594. package/dist/store/scopes/task.d.ts +35 -0
  595. package/dist/store/scopes/task.d.ts.map +1 -0
  596. package/dist/store/scopes/task.js +0 -0
  597. package/dist/store/scopes/thread-list-item.d.ts +5 -6
  598. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  599. package/dist/store/scopes/thread.d.ts +25 -6
  600. package/dist/store/scopes/thread.d.ts.map +1 -1
  601. package/dist/store/scopes/threads.d.ts +4 -5
  602. package/dist/store/scopes/threads.d.ts.map +1 -1
  603. package/dist/subscribable/subscribable.d.ts +15 -15
  604. package/dist/subscribable/subscribable.d.ts.map +1 -1
  605. package/dist/subscribable/subscribable.js +23 -15
  606. package/dist/subscribable/subscribable.js.map +1 -1
  607. package/dist/tests/remote-thread-list-test-helpers.d.ts +5 -6
  608. package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
  609. package/dist/types/attachment.d.ts +9 -10
  610. package/dist/types/attachment.d.ts.map +1 -1
  611. package/dist/types/augmentations.d.ts +3 -4
  612. package/dist/types/augmentations.d.ts.map +1 -1
  613. package/dist/types/directive.d.ts +2 -3
  614. package/dist/types/directive.d.ts.map +1 -1
  615. package/dist/types/error.d.ts +8 -9
  616. package/dist/types/error.d.ts.map +1 -1
  617. package/dist/types/index.d.ts +2 -2
  618. package/dist/types/message.d.ts +53 -44
  619. package/dist/types/message.d.ts.map +1 -1
  620. package/dist/types/message.js.map +1 -1
  621. package/dist/types/quote.d.ts +1 -2
  622. package/dist/types/quote.d.ts.map +1 -1
  623. package/dist/types/trigger.d.ts +2 -3
  624. package/dist/types/trigger.d.ts.map +1 -1
  625. package/dist/types/unsubscribe.d.ts +1 -2
  626. package/dist/types/unsubscribe.d.ts.map +1 -1
  627. package/dist/utils/abortable-iterable.d.ts +2 -3
  628. package/dist/utils/abortable-iterable.d.ts.map +1 -1
  629. package/dist/utils/abortable-iterable.js +30 -14
  630. package/dist/utils/abortable-iterable.js.map +1 -1
  631. package/dist/utils/composite-context-provider.d.ts +1 -2
  632. package/dist/utils/composite-context-provider.d.ts.map +1 -1
  633. package/dist/utils/data-url.d.ts +6 -7
  634. package/dist/utils/data-url.d.ts.map +1 -1
  635. package/dist/utils/getGroupStatus.d.ts +17 -2
  636. package/dist/utils/getGroupStatus.d.ts.map +1 -1
  637. package/dist/utils/getGroupStatus.js +32 -7
  638. package/dist/utils/getGroupStatus.js.map +1 -1
  639. package/dist/utils/id.d.ts +3 -4
  640. package/dist/utils/id.d.ts.map +1 -1
  641. package/dist/utils/image-media-type.d.ts +1 -2
  642. package/dist/utils/image-media-type.d.ts.map +1 -1
  643. package/dist/utils/invoke-user-callback.d.ts +1 -2
  644. package/dist/utils/invoke-user-callback.d.ts.map +1 -1
  645. package/dist/utils/json/is-json-equal.d.ts +1 -2
  646. package/dist/utils/json/is-json-equal.d.ts.map +1 -1
  647. package/dist/utils/json/is-json.d.ts +4 -5
  648. package/dist/utils/json/is-json.d.ts.map +1 -1
  649. package/dist/utils/json/stable-stringify-tool-args.d.ts +2 -3
  650. package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -1
  651. package/dist/utils/normalizePartStatus.d.ts +4 -5
  652. package/dist/utils/normalizePartStatus.d.ts.map +1 -1
  653. package/dist/utils/notify-event-listeners.d.ts +1 -2
  654. package/dist/utils/notify-event-listeners.d.ts.map +1 -1
  655. package/dist/utils/record.d.ts +1 -2
  656. package/dist/utils/record.d.ts.map +1 -1
  657. package/dist/utils/silent-runtime-action.d.ts +2 -3
  658. package/dist/utils/silent-runtime-action.d.ts.map +1 -1
  659. package/dist/utils/text.d.ts +1 -2
  660. package/dist/utils/text.d.ts.map +1 -1
  661. package/dist/utils/wire-media.d.ts +3 -4
  662. package/dist/utils/wire-media.d.ts.map +1 -1
  663. package/dist/utils/wire-media.js +2 -2
  664. package/dist/utils/wire-media.js.map +1 -1
  665. package/package.json +15 -14
  666. package/src/adapters/attachment.ts +8 -1
  667. package/src/adapters/feedback.ts +1 -0
  668. package/src/adapters/speech.test.ts +236 -0
  669. package/src/adapters/speech.ts +17 -10
  670. package/src/adapters/thread-history.ts +3 -0
  671. package/src/index.ts +1 -0
  672. package/src/model-context/frame/host.test.ts +113 -1
  673. package/src/model-context/frame/host.ts +39 -12
  674. package/src/model-context/frame/provider.test.ts +45 -20
  675. package/src/model-context/interactable-composer-metadata.test.ts +30 -0
  676. package/src/model-context/interactable-composer-metadata.ts +10 -10
  677. package/src/react/RuntimeAdapter.test.ts +4 -1
  678. package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +361 -0
  679. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +69 -19
  680. package/src/react/client/DataRenderers.test.tsx +45 -0
  681. package/src/react/client/DataRenderers.ts +13 -9
  682. package/src/react/client/Interactables.test.ts +52 -4
  683. package/src/react/client/Interactables.ts +7 -1
  684. package/src/react/client/RemoteThreadList.concurrent.test.tsx +9 -3
  685. package/src/react/client/RemoteThreadList.test.ts +46 -7
  686. package/src/react/client/RemoteThreadList.ts +15 -2
  687. package/src/react/client/interactable-model-context.test.ts +44 -0
  688. package/src/react/client/interactable-model-context.ts +3 -2
  689. package/src/react/index.ts +5 -1
  690. package/src/react/interactables-legacy/Interactables.test.ts +9 -3
  691. package/src/react/interactables-legacy/useAssistantInteractable.test.tsx +150 -0
  692. package/src/react/interactables-legacy/useAssistantInteractable.ts +10 -1
  693. package/src/react/model-context/useInteractable.test.tsx +204 -0
  694. package/src/react/model-context/useInteractable.ts +3 -0
  695. package/src/react/primitive-hooks/useActionBarCopy.test.ts +5 -6
  696. package/src/react/primitive-hooks/useSuggestionTrigger.test.ts +0 -1
  697. package/src/react/primitives/generativeUI/GenerativeUI.test.tsx +54 -0
  698. package/src/react/primitives/generativeUI/GenerativeUI.tsx +13 -18
  699. package/src/react/primitives/message/MessageGroupedParts.test.tsx +99 -0
  700. package/src/react/primitives/message/MessageGroupedParts.tsx +15 -4
  701. package/src/react/primitives/part/PartMessages.test.tsx +104 -1
  702. package/src/react/primitives/part/PartMessages.tsx +1 -0
  703. package/src/react/primitives/thread/ThreadMessages.test.tsx +160 -0
  704. package/src/react/primitives/thread/ThreadMessages.tsx +8 -5
  705. package/src/react/providers/ReadonlyThreadProvider.test.tsx +56 -0
  706. package/src/react/runtimes/RemoteThreadListHookInstanceManager.layout.test.tsx +62 -0
  707. package/src/react/runtimes/RemoteThreadListHookInstanceManager.retry.test.tsx +2 -2
  708. package/src/react/runtimes/RemoteThreadListHookInstanceManager.test.tsx +23 -20
  709. package/src/react/runtimes/RemoteThreadListHookInstanceManager.title.test.tsx +24 -17
  710. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +39 -24
  711. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +7 -1
  712. package/src/react/runtimes/assistant-transport/transport-scheduling.test.ts +73 -46
  713. package/src/react/runtimes/assistant-transport/useAssistantTransportRuntime.test.tsx +66 -1
  714. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.ts +20 -14
  715. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.test.tsx +323 -1
  716. package/src/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.ts +190 -523
  717. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +81 -0
  718. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +27 -1
  719. package/src/react/runtimes/cloud/auiV0.ts +281 -26
  720. package/src/react/runtimes/cloud/auiV0DecodeSafely.test.ts +522 -0
  721. package/src/react/runtimes/cloud/createCloudThreadListAdapter.test.ts +21 -0
  722. package/src/react/runtimes/cloud/createCloudThreadListAdapter.ts +7 -1
  723. package/src/react/runtimes/cloud/sdkIdentity.ts +9 -0
  724. package/src/react/runtimes/cloud/useCloudThreadListAdapter.test.tsx +18 -4
  725. package/src/react/runtimes/external-message-converter.test.ts +143 -4
  726. package/src/react/runtimes/external-message-converter.ts +39 -93
  727. package/src/react/runtimes/remote-thread-hook-on-tap.test.ts +2 -1
  728. package/src/react/runtimes/useExternalStoreRuntime.lifecycle.test.tsx +8 -2
  729. package/src/react/runtimes/useExternalStoreRuntime.suggestions.test.tsx +6 -2
  730. package/src/react/runtimes/useRemoteThreadListRuntime.concurrent.test.tsx +84 -4
  731. package/src/react/runtimes/useRemoteThreadListRuntime.ts +6 -2
  732. package/src/react/utils/groupParts.ts +12 -1
  733. package/src/react/utils/useJSONEqual.ts +9 -0
  734. package/src/react/utils/useJSONSchemaDependency.ts +22 -0
  735. package/src/runtime/api/message-part-runtime.ts +4 -1
  736. package/src/runtime/api/message-runtime.ts +15 -2
  737. package/src/runtime/api/thread-runtime.test.ts +58 -0
  738. package/src/runtime/api/thread-runtime.ts +2 -4
  739. package/src/runtime/base/base-composer-runtime-core.ts +69 -16
  740. package/src/runtime/base/base-thread-runtime-core.test.ts +1799 -49
  741. package/src/runtime/base/base-thread-runtime-core.ts +296 -94
  742. package/src/runtime/base/default-edit-composer-runtime-core.ts +12 -2
  743. package/src/runtime/base/default-thread-composer-runtime-core.ts +12 -1
  744. package/src/runtime/interfaces/thread-runtime-core.ts +8 -0
  745. package/src/runtime/queue/message-queue.ts +79 -7
  746. package/src/runtime/utils/auto-status.test.ts +112 -1
  747. package/src/runtime/utils/auto-status.ts +31 -5
  748. package/src/runtime/utils/external-message-conversion.test.ts +177 -0
  749. package/src/runtime/utils/external-message-conversion.ts +128 -33
  750. package/src/runtime/utils/message-repository.test.ts +49 -0
  751. package/src/runtime/utils/message-repository.ts +3 -3
  752. package/src/runtime/utils/stored-message-parts.ts +174 -0
  753. package/src/runtime/utils/thread-message-like.test.ts +52 -0
  754. package/src/runtime/utils/thread-message-like.ts +11 -2
  755. package/src/runtimes/external-store/external-store-adapter.ts +4 -0
  756. package/src/runtimes/external-store/external-store-thread-runtime-core.ts +74 -9
  757. package/src/runtimes/local/local-thread-runtime-core.test.ts +189 -12
  758. package/src/runtimes/local/local-thread-runtime-core.ts +91 -10
  759. package/src/runtimes/tool-invocations/EDGE_CASES.md +2 -6
  760. package/src/runtimes/tool-invocations/ToolInvocationTracker.test.ts +133 -0
  761. package/src/runtimes/tool-invocations/ToolInvocationTracker.ts +10 -6
  762. package/src/store/clients/external-thread.ts +53 -14
  763. package/src/store/clients/thread-tasks.test.ts +274 -0
  764. package/src/store/clients/thread-tasks.ts +138 -0
  765. package/src/store/index.ts +8 -0
  766. package/src/store/primitive-predicates.test.ts +64 -5
  767. package/src/store/primitive-predicates.ts +10 -2
  768. package/src/store/runtime-clients/thread-runtime-client.test.tsx +110 -0
  769. package/src/store/runtime-clients/thread-runtime-client.ts +31 -1
  770. package/src/store/scope-registration.ts +2 -0
  771. package/src/store/scopes/message.ts +4 -1
  772. package/src/store/scopes/task.ts +34 -0
  773. package/src/store/scopes/thread.ts +16 -0
  774. package/src/store/thread-tasks.test.tsx +209 -0
  775. package/src/subscribable/subscribable.test.ts +161 -1
  776. package/src/subscribable/subscribable.ts +25 -15
  777. package/src/tests/MessageRepository.test.ts +1 -5
  778. package/src/tests/attachment-adapters.test.ts +16 -1
  779. package/src/tests/auiV0Encode.test.ts +304 -0
  780. package/src/tests/base-composer-runtime-core-addAttachment.test.ts +6 -6
  781. package/src/tests/base-composer-runtime-core-send.test.ts +51 -0
  782. package/src/tests/base-composer-runtime-core.test.ts +329 -6
  783. package/src/tests/composer-can-cancel.test.ts +35 -6
  784. package/src/tests/composer-can-send.test.ts +22 -0
  785. package/src/tests/default-edit-composer-runtime-core.test.ts +47 -0
  786. package/src/tests/external-store-thread-runtime-core-adapter.test.ts +369 -16
  787. package/src/tests/external-store-thread-runtime-core.test.ts +31 -0
  788. package/src/tests/external-thread-attachments.test.tsx +91 -23
  789. package/src/tests/external-thread-feedback.test.tsx +20 -7
  790. package/src/tests/external-thread-parity.test.tsx +35 -1
  791. package/src/tests/groupParts.test.ts +71 -0
  792. package/src/tests/message-queue.test.ts +290 -2
  793. package/src/tests/remote-thread-list-reactive-threadId.test.ts +51 -0
  794. package/src/tests/thread-switch-events.test.tsx +11 -7
  795. package/src/tests/useRemoteThreadListRuntime-controlled.test.tsx +45 -1
  796. package/src/types/index.ts +1 -0
  797. package/src/types/message.test.ts +19 -0
  798. package/src/types/message.ts +23 -7
  799. package/src/utils/abortable-iterable.test.ts +115 -0
  800. package/src/utils/abortable-iterable.ts +34 -23
  801. package/src/utils/getGroupStatus.test.ts +70 -4
  802. package/src/utils/getGroupStatus.ts +35 -12
  803. package/src/utils/wire-media.test.ts +10 -0
  804. package/src/utils/wire-media.ts +6 -2
@@ -7,25 +7,30 @@ import type {
7
7
  MessageFormatRepository,
8
8
  } from "../../../adapters/thread-history";
9
9
  import type { ExportedMessageRepositoryItem } from "../../../runtime/utils/message-repository";
10
+ import type { ThreadMessage } from "../../../types";
10
11
  import {
11
12
  type AssistantCloud,
12
13
  type AssistantCloudEvent,
13
- type AssistantCloudRunReportToolCall,
14
+ CloudEngagementReporter,
14
15
  CloudMessagePersistence,
16
+ CloudRunReporter,
15
17
  createFormattedPersistence,
16
- createRunReport,
17
18
  createRunTelemetryToolCall,
18
19
  deriveRunOutcome,
19
20
  describeRunError,
20
21
  extractRunTelemetryModelId,
21
22
  normalizeRunTelemetryUsage,
23
+ type RunMessageTelemetry,
22
24
  type RunReportOutcome,
23
25
  type RunReportStepInit,
24
- type RunTelemetryUsage,
25
26
  type RunTelemetryUsageInit,
26
27
  truncateRunTelemetryText,
27
28
  } from "assistant-cloud";
28
- import { auiV0Decode, auiV0Encode } from "./auiV0";
29
+ import {
30
+ extractAISDKRunTelemetry,
31
+ type AISDKMessageLike,
32
+ } from "assistant-cloud/ai-sdk";
33
+ import { auiV0DecodeSafely, auiV0Encode } from "./auiV0";
29
34
  import { type AssistantClient, getClientId, useAui } from "@assistant-ui/store";
30
35
  import type { ThreadListItemMethods } from "../../../store/scopes/thread-list-item";
31
36
  import type { FeedbackAdapter } from "../../../adapters/feedback";
@@ -43,6 +48,8 @@ const globalPersistence = new WeakMap<
43
48
  class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
44
49
  private cloudRef: RefObject<AssistantCloud>;
45
50
  private getAui: () => AssistantClient;
51
+ private runReporter: CloudRunReporter;
52
+ public readonly engagementReporter: CloudEngagementReporter;
46
53
 
47
54
  constructor(
48
55
  cloudRef: RefObject<AssistantCloud>,
@@ -50,6 +57,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
50
57
  ) {
51
58
  this.cloudRef = cloudRef;
52
59
  this.getAui = getAui;
60
+ this.runReporter = new CloudRunReporter(() => this.cloudRef.current);
61
+ this.engagementReporter = new CloudEngagementReporter(
62
+ () => this.cloudRef.current,
63
+ (threadId, messageId, options) =>
64
+ this.resolveEngagementEventIds(threadId, messageId, options),
65
+ );
53
66
  }
54
67
 
55
68
  private get aui(): AssistantClient {
@@ -104,7 +117,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
104
117
  }
105
118
 
106
119
  public readonly feedback: FeedbackAdapter = {
107
- submit: ({ message, type }) => {
120
+ submit: ({ message, type, comment }) => {
108
121
  void (async () => {
109
122
  const threadListItem = this.tryGetKeyedThreadListItem();
110
123
  const remoteThreadId = threadListItem?.getState().remoteId;
@@ -128,7 +141,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
128
141
  await this.cloudRef.current.threads.messages.feedback(
129
142
  remoteThreadId,
130
143
  cloudMessageId,
131
- { type },
144
+ { type, ...(comment ? { comment } : undefined) },
132
145
  );
133
146
  })().catch((error: unknown) => {
134
147
  console.error(
@@ -215,6 +228,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
215
228
  options?: {
216
229
  durationMs?: number;
217
230
  stepTimestamps?: StepTimestamp[];
231
+ message?: ThreadMessage;
218
232
  },
219
233
  ) {
220
234
  const encodedRunMessages = items.map((item) =>
@@ -225,7 +239,12 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
225
239
  encodedRunMessages,
226
240
  options,
227
241
  resolvePinned(),
228
- extractLastRunMessageInfo(items, formatAdapter),
242
+ mergeRunMessageInfo(
243
+ extractLastRunMessageInfo(items, formatAdapter),
244
+ options?.message
245
+ ? extractRunMessageInfo(options.message, "aui/v0")
246
+ : undefined,
247
+ ),
229
248
  );
230
249
  },
231
250
  async load(): Promise<MessageFormatRepository<TMessage>> {
@@ -292,14 +311,27 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
292
311
  const remoteId = this.aui.threadListItem.getState().remoteId;
293
312
  if (!remoteId) return { messages: [] };
294
313
  const messages = await this._persistence.load(remoteId, "aui/v0");
295
- return {
296
- messages: messages
297
- .filter(
298
- (m): m is typeof m & { format: "aui/v0" } => m.format === "aui/v0",
299
- )
300
- .map(auiV0Decode)
301
- .reverse(),
302
- };
314
+ // The cloud lists rows newest first, so walking them oldest first puts a
315
+ // parent ahead of its children and a row orphaned by an unreadable parent
316
+ // can be dropped in the same pass; MessageRepository.import throws on a
317
+ // message whose parent is missing.
318
+ const rows = messages
319
+ .filter(
320
+ (m): m is typeof m & { format: "aui/v0" } => m.format === "aui/v0",
321
+ )
322
+ .reverse();
323
+
324
+ const loaded: ExportedMessageRepositoryItem[] = [];
325
+ const loadedIds = new Set<string>();
326
+ for (const row of rows) {
327
+ const item = auiV0DecodeSafely(row);
328
+ if (!item) continue;
329
+ if (item.parentId && !loadedIds.has(item.parentId)) continue;
330
+ loadedIds.add(item.message.id);
331
+ loaded.push(item);
332
+ }
333
+
334
+ return { messages: loaded };
303
335
  }
304
336
 
305
337
  private _reportRunTelemetry<T>(
@@ -312,13 +344,15 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
312
344
  threadListItem?: CloudThreadListItem,
313
345
  messageInfo?: RunMessageInfo,
314
346
  ) {
315
- if (!this.cloudRef.current.telemetry.enabled) return;
316
-
317
347
  const item = threadListItem ?? this.aui.threadListItem;
318
348
  const remoteId = item.getState().remoteId;
319
349
  if (!remoteId) return;
320
350
 
321
- const extracted = extractRunTelemetry(format, runMessages);
351
+ const extracted =
352
+ extractRunTelemetry(format, runMessages) ??
353
+ (messageInfo?.status !== undefined
354
+ ? { status: "incomplete" as const }
355
+ : undefined);
322
356
  if (!extracted) return;
323
357
 
324
358
  this._sendReport(
@@ -345,7 +379,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
345
379
 
346
380
  private _sendReport(
347
381
  remoteId: string,
348
- data: TelemetryData,
382
+ data: RunMessageTelemetry,
349
383
  durationMs?: number,
350
384
  stepTimestamps?: StepTimestamp[],
351
385
  messageInfo?: RunMessageInfo,
@@ -355,7 +389,7 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
355
389
  const messageId = messageInfo?.localMessageId
356
390
  ? persistence.getResolvedRemoteId(messageInfo.localMessageId)
357
391
  : undefined;
358
- const initial = createRunReport({
392
+ void this.runReporter.report({
359
393
  threadId: remoteId,
360
394
  status: messageInfo?.status ?? data.status,
361
395
  outcome: messageInfo?.outcomeType,
@@ -365,90 +399,47 @@ class AssistantCloudThreadHistoryAdapter implements ThreadHistoryAdapter {
365
399
  traceId: messageInfo?.traceId,
366
400
  modelId: data.modelId,
367
401
  provider: messageInfo?.provider,
368
- usage: {
369
- inputTokens: data.inputTokens,
370
- outputTokens: data.outputTokens,
371
- reasoningTokens: data.reasoningTokens,
372
- cachedInputTokens: data.cachedInputTokens,
373
- },
374
- steps: toRunReportSteps(mergedSteps),
402
+ usage: data.usage,
403
+ steps: mergedSteps,
375
404
  totalSteps: data.totalSteps,
376
405
  toolCalls: data.toolCalls,
377
406
  durationMs,
378
407
  firstTokenMs: messageInfo?.firstTokenMs,
379
408
  outputText: data.outputText,
380
409
  metadata: data.metadata,
381
- telemetry: this.cloudRef.current.telemetry,
382
410
  });
383
-
384
- const { beforeReport } = this.cloudRef.current.telemetry;
385
- const report = beforeReport ? beforeReport(initial) : initial;
386
- if (!report) return;
387
-
388
- this.cloudRef.current.runs.report(report).catch(() => {});
389
411
  }
390
412
  }
391
413
 
392
- type TelemetryStepData = {
393
- input_tokens?: number;
394
- output_tokens?: number;
395
- reasoning_tokens?: number;
396
- cached_input_tokens?: number;
397
- tool_calls?: AssistantCloudRunReportToolCall[];
398
- start_ms?: number;
399
- end_ms?: number;
400
- };
401
-
402
414
  type StepTimestamp = { start_ms: number; end_ms: number };
403
415
 
404
- function toRunReportSteps(
405
- steps: TelemetryStepData[] | undefined,
406
- ): RunReportStepInit[] | undefined {
407
- if (!steps) return undefined;
408
- return steps.map((step) => ({
409
- usage: {
410
- inputTokens: step.input_tokens,
411
- outputTokens: step.output_tokens,
412
- reasoningTokens: step.reasoning_tokens,
413
- cachedInputTokens: step.cached_input_tokens,
414
- },
415
- toolCalls: step.tool_calls,
416
- startMs: step.start_ms,
417
- endMs: step.end_ms,
418
- }));
419
- }
420
-
421
416
  function mergeStepTimestamps(
422
- steps: TelemetryStepData[] | undefined,
417
+ steps: RunReportStepInit[] | undefined,
423
418
  timestamps: StepTimestamp[] | undefined,
424
- ): TelemetryStepData[] | undefined {
419
+ ): RunReportStepInit[] | undefined {
425
420
  if (!timestamps) return steps;
426
- if (!steps) return timestamps.map((t) => ({ ...t }));
421
+ if (!steps) {
422
+ return timestamps.map(({ start_ms, end_ms }) => ({
423
+ startMs: start_ms,
424
+ endMs: end_ms,
425
+ }));
426
+ }
427
427
 
428
428
  const len = Math.min(steps.length, timestamps.length);
429
- return steps.map((s, i) => ({
430
- ...s,
431
- ...(i < len ? timestamps[i] : undefined),
429
+ return steps.map((step, index) => ({
430
+ ...step,
431
+ ...(index < len
432
+ ? {
433
+ startMs: timestamps[index]!.start_ms,
434
+ endMs: timestamps[index]!.end_ms,
435
+ }
436
+ : undefined),
432
437
  }));
433
438
  }
434
439
 
435
- type TelemetryData = {
436
- status: "completed" | "incomplete" | "error";
437
- toolCalls?: AssistantCloudRunReportToolCall[];
438
- totalSteps?: number;
439
- inputTokens?: number;
440
- outputTokens?: number;
441
- reasoningTokens?: number;
442
- cachedInputTokens?: number;
443
- outputText?: string;
444
- metadata?: Record<string, unknown>;
445
- steps?: TelemetryStepData[];
446
- modelId?: string;
447
- };
448
-
449
440
  type RunMessageInfo = {
450
441
  localMessageId?: string;
451
- status?: "error";
442
+ status?: "completed" | "incomplete" | "error";
452
443
  outcomeType?: RunReportOutcome;
453
444
  error?: string;
454
445
  errorCode?: string;
@@ -476,6 +467,15 @@ function extractLastRunMessageInfo<
476
467
  return undefined;
477
468
  }
478
469
 
470
+ function mergeRunMessageInfo(
471
+ stored: RunMessageInfo | undefined,
472
+ observed: RunMessageInfo | undefined,
473
+ ): RunMessageInfo | undefined {
474
+ if (!observed) return stored;
475
+ const { localMessageId: _observedId, ...outcome } = observed;
476
+ return { ...stored, ...outcome };
477
+ }
478
+
479
479
  function extractRunMessageInfo(
480
480
  message: unknown,
481
481
  format: string,
@@ -487,27 +487,30 @@ function extractRunMessageInfo(
487
487
  const metadata = isRecord(message.metadata) ? message.metadata : undefined;
488
488
  const custom = isRecord(metadata?.custom) ? metadata.custom : undefined;
489
489
  const timing = isRecord(metadata?.timing) ? metadata.timing : undefined;
490
- const streamStartTime = timing?.streamStartTime;
491
490
  const firstTokenTime = timing?.firstTokenTime;
492
491
  const firstTokenMs =
493
- typeof streamStartTime === "number" &&
494
- Number.isFinite(streamStartTime) &&
495
- typeof firstTokenTime === "number" &&
496
- Number.isFinite(firstTokenTime)
497
- ? Math.round(firstTokenTime - streamStartTime)
492
+ typeof firstTokenTime === "number" && Number.isFinite(firstTokenTime)
493
+ ? Math.round(firstTokenTime)
498
494
  : undefined;
499
495
  const finishReason =
500
496
  status?.type === "incomplete"
501
- ? status.reason
497
+ ? typeof status.reason === "string"
498
+ ? status.reason
499
+ : undefined
502
500
  : typeof metadata?.finishReason === "string"
503
501
  ? metadata.finishReason
504
502
  : undefined;
505
503
  const failed = status?.type === "incomplete" && status.reason === "error";
506
- const outcome = deriveRunOutcome({
507
- finishReason: typeof finishReason === "string" ? finishReason : undefined,
508
- isError: failed,
509
- });
504
+ const outcome = deriveRunOutcome({ finishReason, isError: failed });
510
505
  const outcomeType = outcome.outcome;
506
+ const runStatus =
507
+ outcome.status === "error"
508
+ ? "error"
509
+ : status?.type === "incomplete"
510
+ ? "incomplete"
511
+ : finishReason !== undefined
512
+ ? outcome.status
513
+ : undefined;
511
514
  const failure = failed ? describeRunError(status.error) : {};
512
515
  const messageId =
513
516
  localMessageId ?? (typeof message.id === "string" ? message.id : undefined);
@@ -526,7 +529,7 @@ function extractRunMessageInfo(
526
529
 
527
530
  return {
528
531
  ...(messageId ? { localMessageId: messageId } : undefined),
529
- ...(outcome.status === "error" ? { status: "error" as const } : undefined),
532
+ ...(runStatus !== undefined ? { status: runStatus } : undefined),
530
533
  ...(outcomeType ? { outcomeType } : undefined),
531
534
  ...failure,
532
535
  ...(firstTokenMs != null && firstTokenMs >= 0
@@ -541,12 +544,15 @@ function isRecord(value: unknown): value is Record<string, unknown> {
541
544
  return value !== null && typeof value === "object";
542
545
  }
543
546
 
544
- function extractTelemetry<T>(format: string, content: T): TelemetryData | null {
547
+ function extractTelemetry<T>(
548
+ format: string,
549
+ content: T,
550
+ ): RunMessageTelemetry | null {
545
551
  switch (format) {
546
552
  case "aui/v0":
547
553
  return extractAuiV0(content);
548
554
  case "ai-sdk/v6":
549
- return extractAiSdkV6(content);
555
+ return extractAISDKRunTelemetry([content as AISDKMessageLike]);
550
556
  default:
551
557
  return null;
552
558
  }
@@ -555,9 +561,9 @@ function extractTelemetry<T>(format: string, content: T): TelemetryData | null {
555
561
  function extractRunTelemetry<T>(
556
562
  format: string,
557
563
  runMessages: T[],
558
- ): TelemetryData | null {
564
+ ): RunMessageTelemetry | null {
559
565
  if (format === "ai-sdk/v6") {
560
- return aggregateAiSdkV6RunSteps(runMessages);
566
+ return extractAISDKRunTelemetry(runMessages as AISDKMessageLike[]);
561
567
  }
562
568
  for (let i = runMessages.length - 1; i >= 0; i--) {
563
569
  const result = extractTelemetry(format, runMessages[i]!);
@@ -566,12 +572,7 @@ function extractRunTelemetry<T>(
566
572
  return null;
567
573
  }
568
574
 
569
- const AUI_STATUS_MAP: Record<string, TelemetryData["status"]> = {
570
- error: "error",
571
- incomplete: "incomplete",
572
- };
573
-
574
- export function extractAuiV0<T>(content: T): TelemetryData | null {
575
+ export function extractAuiV0<T>(content: T): RunMessageTelemetry | null {
575
576
  const msg = content as {
576
577
  role?: string;
577
578
  status?: { type: string; reason?: string };
@@ -655,317 +656,42 @@ export function extractAuiV0<T>(content: T): TelemetryData | null {
655
656
  cachedInputTokens = hasCachedInput ? totalCachedInput : undefined;
656
657
  }
657
658
 
658
- const statusType = msg.status?.type;
659
- const status: TelemetryData["status"] =
660
- statusType === "incomplete" && msg.status?.reason === "error"
661
- ? "error"
662
- : (statusType && AUI_STATUS_MAP[statusType]) || "completed";
659
+ const status = msg.status?.type === "incomplete" ? "incomplete" : "completed";
663
660
 
664
661
  const metadata = msg.metadata?.custom as Record<string, unknown> | undefined;
665
662
  const modelId = extractRunTelemetryModelId(
666
663
  msg.metadata as Record<string, unknown> | undefined,
667
664
  );
668
665
 
669
- const telemetrySteps: TelemetryStepData[] | undefined =
670
- steps && steps.length > 1
671
- ? steps.map((s) => {
672
- const usage = s.usage
673
- ? normalizeRunTelemetryUsage(s.usage)
674
- : undefined;
675
- return {
676
- ...(usage?.inputTokens != null
677
- ? { input_tokens: usage.inputTokens }
678
- : undefined),
679
- ...(usage?.outputTokens != null
680
- ? { output_tokens: usage.outputTokens }
681
- : undefined),
682
- ...(usage?.reasoningTokens != null
683
- ? { reasoning_tokens: usage.reasoningTokens }
684
- : undefined),
685
- ...(usage?.cachedInputTokens != null
686
- ? { cached_input_tokens: usage.cachedInputTokens }
687
- : undefined),
688
- };
689
- })
666
+ const telemetrySteps: RunReportStepInit[] | undefined =
667
+ steps && steps.length > 0
668
+ ? steps.map((step) => (step.usage ? { usage: step.usage } : {}))
690
669
  : undefined;
691
670
 
692
671
  return {
693
672
  status,
694
673
  ...(toolCalls && toolCalls.length > 0 ? { toolCalls } : undefined),
695
674
  ...(steps?.length ? { totalSteps: steps.length } : undefined),
696
- ...(inputTokens != null ? { inputTokens } : undefined),
697
- ...(outputTokens != null ? { outputTokens } : undefined),
698
- ...(reasoningTokens != null ? { reasoningTokens } : undefined),
699
- ...(cachedInputTokens != null ? { cachedInputTokens } : undefined),
700
- ...(outputText != null ? { outputText } : undefined),
701
- ...(metadata ? { metadata } : undefined),
702
- ...(telemetrySteps ? { steps: telemetrySteps } : undefined),
703
- ...(modelId ? { modelId } : undefined),
704
- };
705
- }
706
-
707
- type AiSdkV6Part = {
708
- type: string;
709
- text?: string;
710
- toolName?: string;
711
- toolCallId?: string;
712
- args?: unknown;
713
- result?: unknown;
714
- input?: unknown;
715
- output?: unknown;
716
- };
717
-
718
- type AiSdkV6Message = {
719
- role?: string;
720
- parts?: readonly AiSdkV6Part[];
721
- metadata?: Record<string, unknown>;
722
- };
723
-
724
- function isToolCallPart(p: AiSdkV6Part): boolean {
725
- if (!p.toolCallId) return false;
726
- if (p.type === "tool-call" || p.type === "dynamic-tool") return !!p.toolName;
727
- return p.type.startsWith("tool-") || p.type.startsWith("dynamic-tool-");
728
- }
729
-
730
- function isDynamicToolPart(p: AiSdkV6Part): boolean {
731
- return p.type === "dynamic-tool" || p.type.startsWith("dynamic-tool-");
732
- }
733
-
734
- function partToToolCall(p: AiSdkV6Part): AssistantCloudRunReportToolCall {
735
- const toolSource: "mcp" | "frontend" = isDynamicToolPart(p)
736
- ? "mcp"
737
- : "frontend";
738
- return createRunTelemetryToolCall({
739
- toolName: p.toolName ?? p.type.slice(5),
740
- toolCallId: p.toolCallId!,
741
- args: p.args ?? p.input,
742
- result: p.result ?? p.output,
743
- toolSource,
744
- });
745
- }
746
-
747
- function collectAiSdkV6Parts(parts: readonly AiSdkV6Part[]): {
748
- textParts: string[];
749
- toolCalls: AssistantCloudRunReportToolCall[];
750
- stepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[];
751
- } {
752
- const textParts: string[] = [];
753
- const toolCalls: AssistantCloudRunReportToolCall[] = [];
754
- const stepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[] = [];
755
- let currentStepToolCalls: AssistantCloudRunReportToolCall[] | null = null;
756
-
757
- for (const p of parts) {
758
- if (p.type === "step-start") {
759
- if (currentStepToolCalls !== null) {
760
- stepsData.push({ tool_calls: currentStepToolCalls });
761
- }
762
- currentStepToolCalls = [];
763
- } else if (p.type === "text" && p.text) {
764
- textParts.push(p.text);
765
- } else if (isToolCallPart(p)) {
766
- const tc = partToToolCall(p);
767
- toolCalls.push(tc);
768
- if (currentStepToolCalls !== null) {
769
- currentStepToolCalls.push(tc);
770
- }
771
- }
772
- }
773
-
774
- if (currentStepToolCalls !== null) {
775
- stepsData.push({ tool_calls: currentStepToolCalls });
776
- }
777
-
778
- return { textParts, toolCalls, stepsData };
779
- }
780
-
781
- function buildAiSdkV6Result(
782
- textParts: string[],
783
- toolCalls: AssistantCloudRunReportToolCall[],
784
- totalSteps: number,
785
- metadata?: Record<string, unknown>,
786
- stepsData?: { tool_calls: AssistantCloudRunReportToolCall[] }[],
787
- usage?: RunTelemetryUsage,
788
- ): TelemetryData {
789
- const hasText = textParts.length > 0;
790
- const outputText = hasText
791
- ? truncateRunTelemetryText(textParts.join(""))
792
- : undefined;
793
- const modelId = extractRunTelemetryModelId(metadata);
794
-
795
- const steps: TelemetryStepData[] | undefined =
796
- stepsData && stepsData.length > 1
797
- ? stepsData.map((s) => ({
798
- ...(s.tool_calls.length > 0
799
- ? { tool_calls: s.tool_calls }
800
- : undefined),
801
- }))
802
- : undefined;
803
-
804
- return {
805
- status: hasText ? "completed" : "incomplete",
806
- ...(toolCalls.length > 0 ? { toolCalls } : undefined),
807
- ...(totalSteps > 0 ? { totalSteps } : undefined),
808
- ...(usage?.inputTokens != null
809
- ? { inputTokens: usage.inputTokens }
810
- : undefined),
811
- ...(usage?.outputTokens != null
812
- ? { outputTokens: usage.outputTokens }
813
- : undefined),
814
- ...(usage?.reasoningTokens != null
815
- ? { reasoningTokens: usage.reasoningTokens }
816
- : undefined),
817
- ...(usage?.cachedInputTokens != null
818
- ? { cachedInputTokens: usage.cachedInputTokens }
675
+ ...(inputTokens != null ||
676
+ outputTokens != null ||
677
+ reasoningTokens != null ||
678
+ cachedInputTokens != null
679
+ ? {
680
+ usage: {
681
+ ...(inputTokens != null ? { inputTokens } : undefined),
682
+ ...(outputTokens != null ? { outputTokens } : undefined),
683
+ ...(reasoningTokens != null ? { reasoningTokens } : undefined),
684
+ ...(cachedInputTokens != null ? { cachedInputTokens } : undefined),
685
+ },
686
+ }
819
687
  : undefined),
820
688
  ...(outputText != null ? { outputText } : undefined),
821
689
  ...(metadata ? { metadata } : undefined),
822
- ...(steps ? { steps } : undefined),
690
+ ...(telemetrySteps ? { steps: telemetrySteps } : undefined),
823
691
  ...(modelId ? { modelId } : undefined),
824
692
  };
825
693
  }
826
694
 
827
- function extractAiSdkV6Usage(
828
- metadata?: Record<string, unknown>,
829
- ): RunTelemetryUsage | undefined {
830
- // Try top-level metadata.usage
831
- const usage = metadata?.usage as RunTelemetryUsageInit | undefined;
832
- if (usage) {
833
- const normalized = normalizeRunTelemetryUsage(usage);
834
- if (normalized) return normalized;
835
- }
836
-
837
- // Try aggregating from metadata.steps[].usage
838
- const steps = metadata?.steps as
839
- | readonly { usage?: RunTelemetryUsageInit }[]
840
- | undefined;
841
- if (steps && steps.length > 0) {
842
- let inputTokens = 0;
843
- let outputTokens = 0;
844
- let reasoningTokens = 0;
845
- let cachedInputTokens = 0;
846
- let hasInput = false;
847
- let hasOutput = false;
848
- let hasReasoning = false;
849
- let hasCachedInput = false;
850
- let hasAny = false;
851
- for (const s of steps) {
852
- if (!s.usage) continue;
853
- const n = normalizeRunTelemetryUsage(s.usage);
854
- if (n) {
855
- if (n.inputTokens != null) {
856
- inputTokens += n.inputTokens;
857
- hasInput = true;
858
- }
859
- if (n.outputTokens != null) {
860
- outputTokens += n.outputTokens;
861
- hasOutput = true;
862
- }
863
- if (n.reasoningTokens != null) {
864
- reasoningTokens += n.reasoningTokens;
865
- hasReasoning = true;
866
- }
867
- if (n.cachedInputTokens != null) {
868
- cachedInputTokens += n.cachedInputTokens;
869
- hasCachedInput = true;
870
- }
871
- hasAny = true;
872
- }
873
- }
874
- if (hasAny) {
875
- return {
876
- ...(hasInput ? { inputTokens } : undefined),
877
- ...(hasOutput ? { outputTokens } : undefined),
878
- ...(hasReasoning ? { reasoningTokens } : undefined),
879
- ...(hasCachedInput ? { cachedInputTokens } : undefined),
880
- };
881
- }
882
- }
883
-
884
- return undefined;
885
- }
886
-
887
- function extractAiSdkV6<T>(content: T): TelemetryData | null {
888
- const msg = content as AiSdkV6Message;
889
- if (msg.role !== "assistant") return null;
890
-
891
- const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(
892
- msg.parts ?? [],
893
- );
894
- return buildAiSdkV6Result(
895
- textParts,
896
- toolCalls,
897
- stepsData.length,
898
- msg.metadata,
899
- stepsData,
900
- extractAiSdkV6Usage(msg.metadata),
901
- );
902
- }
903
-
904
- function aggregateAiSdkV6RunSteps<T>(stepMessages: T[]): TelemetryData | null {
905
- const allTextParts: string[] = [];
906
- const allToolCalls: AssistantCloudRunReportToolCall[] = [];
907
- const allStepsData: { tool_calls: AssistantCloudRunReportToolCall[] }[] = [];
908
- let hasAssistant = false;
909
- let metadata: Record<string, unknown> | undefined;
910
- let inputTokens = 0;
911
- let outputTokens = 0;
912
- let reasoningTokens = 0;
913
- let cachedInputTokens = 0;
914
- let hasInput = false;
915
- let hasOutput = false;
916
- let hasReasoning = false;
917
- let hasCachedInput = false;
918
-
919
- for (const content of stepMessages) {
920
- const msg = content as AiSdkV6Message;
921
- if (msg.role !== "assistant") continue;
922
- hasAssistant = true;
923
-
924
- const { textParts, toolCalls, stepsData } = collectAiSdkV6Parts(
925
- msg.parts ?? [],
926
- );
927
- allTextParts.push(...textParts);
928
- allToolCalls.push(...toolCalls);
929
- allStepsData.push(...stepsData);
930
- if (msg.metadata) metadata = msg.metadata;
931
-
932
- const usage = extractAiSdkV6Usage(msg.metadata);
933
- if (usage) {
934
- if (usage.inputTokens != null) {
935
- inputTokens += usage.inputTokens;
936
- hasInput = true;
937
- }
938
- if (usage.outputTokens != null) {
939
- outputTokens += usage.outputTokens;
940
- hasOutput = true;
941
- }
942
- if (usage.reasoningTokens != null) {
943
- reasoningTokens += usage.reasoningTokens;
944
- hasReasoning = true;
945
- }
946
- if (usage.cachedInputTokens != null) {
947
- cachedInputTokens += usage.cachedInputTokens;
948
- hasCachedInput = true;
949
- }
950
- }
951
- }
952
-
953
- if (!hasAssistant) return null;
954
- return buildAiSdkV6Result(
955
- allTextParts,
956
- allToolCalls,
957
- allStepsData.length,
958
- metadata,
959
- allStepsData,
960
- {
961
- ...(hasInput ? { inputTokens } : undefined),
962
- ...(hasOutput ? { outputTokens } : undefined),
963
- ...(hasReasoning ? { reasoningTokens } : undefined),
964
- ...(hasCachedInput ? { cachedInputTokens } : undefined),
965
- },
966
- );
967
- }
968
-
969
695
  export function useAssistantCloudThreadHistoryAdapter(
970
696
  cloudRef: RefObject<AssistantCloud>,
971
697
  ): ThreadHistoryAdapter & { readonly feedback: FeedbackAdapter } {
@@ -979,14 +705,13 @@ export function useAssistantCloudThreadHistoryAdapter(
979
705
  () =>
980
706
  new AssistantCloudThreadHistoryAdapter(cloudRef, () => auiRef.current),
981
707
  );
982
- useAssistantCloudEngagementEvents(cloudRef, adapter, aui);
708
+ useAssistantCloudEngagementEvents(adapter, aui);
983
709
  return adapter;
984
710
  }
985
711
 
986
712
  type RootEngagementTracker = {
987
713
  count: number;
988
- adapter: AssistantCloudThreadHistoryAdapter;
989
- cloudRef: RefObject<AssistantCloud>;
714
+ engagementReporter: CloudEngagementReporter;
990
715
  dispose: () => void;
991
716
  };
992
717
 
@@ -1001,7 +726,6 @@ const rootEngagementTrackers = new WeakMap<
1001
726
  * subscription and the last one to unmount removes it.
1002
727
  */
1003
728
  const useRootEngagementEvents = (
1004
- cloudRef: RefObject<AssistantCloud>,
1005
729
  adapter: AssistantCloudThreadHistoryAdapter,
1006
730
  aui: AssistantClient,
1007
731
  ) => {
@@ -1010,31 +734,20 @@ const useRootEngagementEvents = (
1010
734
  if (!tracker) {
1011
735
  const created: RootEngagementTracker = {
1012
736
  count: 0,
1013
- adapter,
1014
- cloudRef,
737
+ engagementReporter: adapter.engagementReporter,
1015
738
  dispose: () => {},
1016
739
  };
1017
740
  created.dispose = aui.on(
1018
741
  { scope: "*", event: "threads.selectionChanged" },
1019
742
  (payload) => {
1020
- void created.adapter
1021
- .resolveEngagementEventIds(payload.threadId)
1022
- .then((ids) => {
1023
- if (!ids.thread_id) return;
1024
- created.cloudRef.current.events?.track({
1025
- kind: "thread_switched",
1026
- ...ids,
1027
- });
1028
- })
1029
- .catch(() => {});
743
+ created.engagementReporter.threadSwitched(payload.threadId);
1030
744
  },
1031
745
  );
1032
746
  rootEngagementTrackers.set(aui, created);
1033
747
  tracker = created;
1034
748
  }
1035
749
  const active = tracker;
1036
- active.adapter = adapter;
1037
- active.cloudRef = cloudRef;
750
+ active.engagementReporter = adapter.engagementReporter;
1038
751
  active.count += 1;
1039
752
  return () => {
1040
753
  active.count -= 1;
@@ -1043,175 +756,129 @@ const useRootEngagementEvents = (
1043
756
  rootEngagementTrackers.delete(aui);
1044
757
  }
1045
758
  };
1046
- }, [adapter, aui, cloudRef]);
759
+ }, [adapter, aui]);
1047
760
  };
1048
761
 
1049
762
  const useAssistantCloudEngagementEvents = (
1050
- cloudRef: RefObject<AssistantCloud>,
1051
763
  adapter: AssistantCloudThreadHistoryAdapter,
1052
764
  aui: AssistantClient,
1053
765
  ) => {
1054
- useRootEngagementEvents(cloudRef, adapter, aui);
1055
- const runStartedAt = useRef(new Map<string, number>());
1056
- const runEndedAt = useRef(new Map<string, number>());
1057
- const shownSuggestions = useRef(new Set<string>());
766
+ useRootEngagementEvents(adapter, aui);
1058
767
 
1059
768
  useEffect(() => {
1060
- const track = (
1061
- event: AssistantCloudEvent,
1062
- threadId: string,
1063
- messageId?: string,
1064
- options?: { awaitThread?: boolean },
1065
- ) => {
1066
- void adapter
1067
- .resolveEngagementEventIds(threadId, messageId, options)
1068
- .then((ids) => {
1069
- cloudRef.current.events?.track({ ...event, ...ids });
1070
- })
1071
- .catch(() => {});
1072
- };
1073
- const trackRunStopped = (threadId: string) => {
1074
- const startedAt = runStartedAt.current.get(threadId);
1075
- if (startedAt === undefined) return;
1076
- runStartedAt.current.delete(threadId);
1077
- track(
1078
- { kind: "run_stopped", value: Math.max(0, Date.now() - startedAt) },
1079
- threadId,
1080
- );
1081
- };
769
+ const reporter = adapter.engagementReporter;
1082
770
 
1083
771
  const unsubscribers = [
1084
772
  aui.on({ scope: "thread", event: "composer.send" }, (payload) => {
1085
- const previousRunEndedAt = runEndedAt.current.get(payload.threadId);
1086
- track(
1087
- {
1088
- kind: payload.messageId ? "message_edited" : "message_sent",
1089
- ...(payload.messageId
1090
- ? { props: { chars: payload.chars } }
1091
- : {
1092
- props: {
1093
- chars: payload.chars,
1094
- attachments: payload.attachments,
1095
- },
1096
- }),
1097
- ...(!payload.messageId && previousRunEndedAt !== undefined
1098
- ? { value: Math.max(0, Date.now() - previousRunEndedAt) }
1099
- : undefined),
1100
- },
1101
- payload.threadId,
1102
- payload.messageId,
1103
- { awaitThread: !payload.messageId },
1104
- );
773
+ if (payload.messageId) {
774
+ reporter.messageEdited(payload.threadId, {
775
+ messageId: payload.messageId,
776
+ chars: payload.chars,
777
+ });
778
+ } else {
779
+ reporter.messageSent(payload.threadId, {
780
+ chars: payload.chars,
781
+ attachments: payload.attachments,
782
+ });
783
+ }
1105
784
  if (payload.suggestion) {
1106
- track({ kind: "suggestion_clicked" }, payload.threadId);
785
+ reporter.suggestionClicked(payload.threadId);
1107
786
  }
1108
787
  }),
1109
788
  aui.on(
1110
789
  { scope: "thread", event: "composer.attachmentAdd" },
1111
790
  (payload) => {
1112
- track(
1113
- {
1114
- kind: "attachment_added",
1115
- ...(payload.contentType
1116
- ? { props: { type: payload.contentType } }
1117
- : undefined),
1118
- },
1119
- payload.threadId,
1120
- payload.messageId,
1121
- );
791
+ reporter.attachmentAdded(payload.threadId, {
792
+ messageId: payload.messageId,
793
+ contentType: payload.contentType,
794
+ });
1122
795
  },
1123
796
  ),
1124
797
  aui.on(
1125
798
  { scope: "thread", event: "composer.attachmentAddError" },
1126
799
  (payload) => {
1127
- track(
1128
- {
1129
- kind: "attachment_failed",
1130
- ...(payload.contentType
1131
- ? { props: { type: payload.contentType } }
1132
- : undefined),
1133
- },
1134
- payload.threadId,
1135
- payload.messageId,
1136
- );
800
+ reporter.attachmentFailed(payload.threadId, {
801
+ messageId: payload.messageId,
802
+ contentType: payload.contentType,
803
+ });
1137
804
  },
1138
805
  ),
1139
806
  aui.on({ scope: "thread", event: "composer.cancel" }, (payload) => {
1140
- trackRunStopped(payload.threadId);
807
+ reporter.runStopped(payload.threadId);
1141
808
  }),
1142
809
  aui.on({ scope: "thread", event: "thread.runStart" }, (payload) => {
1143
- runStartedAt.current.set(payload.threadId, Date.now());
810
+ reporter.runStarted(payload.threadId);
1144
811
  }),
1145
812
  aui.on({ scope: "thread", event: "thread.runEnd" }, (payload) => {
1146
- runStartedAt.current.delete(payload.threadId);
1147
- runEndedAt.current.set(payload.threadId, Date.now());
813
+ reporter.runEnded(payload.threadId);
1148
814
  }),
1149
815
  aui.on({ scope: "thread", event: "thread.cancelRun" }, (payload) => {
1150
- trackRunStopped(payload.threadId);
816
+ reporter.runStopped(payload.threadId);
1151
817
  }),
1152
818
  aui.on({ scope: "thread", event: "thread.voiceStarted" }, (payload) => {
1153
- track({ kind: "voice_started" }, payload.threadId);
819
+ reporter.voiceStarted(payload.threadId);
1154
820
  }),
1155
821
  aui.on({ scope: "thread", event: "message.reload" }, (payload) => {
1156
- track(
1157
- { kind: "message_regenerated" },
1158
- payload.threadId,
1159
- payload.messageId,
1160
- );
822
+ reporter.messageRegenerated(payload.threadId, payload.messageId);
1161
823
  }),
1162
824
  aui.on(
1163
825
  { scope: "thread", event: "message.branchSwitched" },
1164
826
  (payload) => {
1165
- track(
1166
- { kind: "branch_switched" },
1167
- payload.threadId,
1168
- payload.messageId,
1169
- );
827
+ reporter.branchSwitched(payload.threadId, payload.messageId);
1170
828
  },
1171
829
  ),
1172
830
  aui.on({ scope: "thread", event: "message.copied" }, (payload) => {
1173
- track({ kind: "message_copied" }, payload.threadId, payload.messageId);
831
+ reporter.messageCopied(payload.threadId, payload.messageId);
1174
832
  }),
833
+ aui.on(
834
+ { scope: "thread", event: "thread.toolApprovalAnswered" },
835
+ (payload) => {
836
+ if (payload.approved) {
837
+ reporter.toolApproved(
838
+ payload.threadId,
839
+ payload.messageId,
840
+ payload.toolCallId,
841
+ payload.toolName,
842
+ );
843
+ } else {
844
+ reporter.toolRejected(
845
+ payload.threadId,
846
+ payload.messageId,
847
+ payload.toolCallId,
848
+ payload.toolName,
849
+ );
850
+ }
851
+ },
852
+ ),
1175
853
  aui.on({ scope: "thread", event: "message.speak" }, (payload) => {
1176
- track({ kind: "speech_started" }, payload.threadId, payload.messageId);
854
+ reporter.speechStarted(payload.threadId, payload.messageId);
1177
855
  }),
1178
856
  aui.on({ scope: "thread", event: "message.error" }, (payload) => {
1179
- track(
1180
- { kind: "error_shown", props: { reason: payload.reason } },
1181
- payload.threadId,
1182
- payload.messageId,
1183
- );
857
+ reporter.errorShown(payload.threadId, {
858
+ messageId: payload.messageId,
859
+ reason: payload.reason,
860
+ });
1184
861
  }),
1185
862
  ];
1186
863
 
1187
864
  return () => {
1188
865
  for (const unsubscribe of unsubscribers) unsubscribe();
1189
866
  };
1190
- }, [adapter, aui, cloudRef]);
867
+ }, [adapter, aui]);
1191
868
 
1192
869
  useEffect(() => {
1193
870
  const reportSuggestions = () => {
1194
871
  const { mainThreadId } = aui.threads.getState();
1195
872
  if (aui.threadListItem.getState().id !== mainThreadId) return;
1196
873
  const { isEmpty, suggestions } = aui.thread.getState();
1197
- if (
1198
- !isEmpty ||
1199
- suggestions.length === 0 ||
1200
- shownSuggestions.current.has(mainThreadId)
1201
- ) {
1202
- return;
1203
- }
1204
- shownSuggestions.current.add(mainThreadId);
1205
- void adapter.resolveEngagementEventIds(mainThreadId).then((ids) => {
1206
- cloudRef.current.events?.track({
1207
- kind: "suggestions_shown",
1208
- value: suggestions.length,
1209
- ...ids,
1210
- });
1211
- });
874
+ if (!isEmpty || suggestions.length === 0) return;
875
+ adapter.engagementReporter.suggestionsShown(
876
+ mainThreadId,
877
+ suggestions.length,
878
+ );
1212
879
  };
1213
880
 
1214
881
  reportSuggestions();
1215
882
  return aui.subscribe(reportSuggestions);
1216
- }, [adapter, aui, cloudRef]);
883
+ }, [adapter, aui]);
1217
884
  };