@assistant-ui/core 0.2.20 → 0.2.21

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 (509) hide show
  1. package/dist/adapters/attachment.d.ts +2 -2
  2. package/dist/adapters/attachment.d.ts.map +1 -1
  3. package/dist/adapters/attachment.js +14 -7
  4. package/dist/adapters/attachment.js.map +1 -1
  5. package/dist/adapters/directive-formatter.d.ts +0 -1
  6. package/dist/adapters/directive-formatter.d.ts.map +1 -1
  7. package/dist/adapters/feedback.d.ts +0 -1
  8. package/dist/adapters/feedback.d.ts.map +1 -1
  9. package/dist/adapters/index.d.ts +2 -2
  10. package/dist/adapters/index.js +2 -1
  11. package/dist/adapters/speech.d.ts +0 -1
  12. package/dist/adapters/speech.d.ts.map +1 -1
  13. package/dist/adapters/suggestion.d.ts +16 -2
  14. package/dist/adapters/suggestion.d.ts.map +1 -1
  15. package/dist/adapters/suggestion.js +36 -0
  16. package/dist/adapters/suggestion.js.map +1 -0
  17. package/dist/adapters/thread-history.d.ts +2 -2
  18. package/dist/adapters/thread-history.d.ts.map +1 -1
  19. package/dist/adapters/trigger.d.ts +5 -3
  20. package/dist/adapters/trigger.d.ts.map +1 -1
  21. package/dist/adapters/voice.d.ts +0 -1
  22. package/dist/adapters/voice.d.ts.map +1 -1
  23. package/dist/index.d.ts +4 -3
  24. package/dist/index.js +3 -1
  25. package/dist/index.js.map +1 -1
  26. package/dist/internal/duplicate-detection.d.ts.map +1 -1
  27. package/dist/internal.d.ts +7 -1
  28. package/dist/internal.js +6 -2
  29. package/dist/model-context/frame/host.d.ts +0 -1
  30. package/dist/model-context/frame/host.d.ts.map +1 -1
  31. package/dist/model-context/frame/provider.d.ts +0 -1
  32. package/dist/model-context/frame/provider.d.ts.map +1 -1
  33. package/dist/model-context/frame/types.d.ts.map +1 -1
  34. package/dist/model-context/interactable-composer-metadata.d.ts +4 -2
  35. package/dist/model-context/interactable-composer-metadata.d.ts.map +1 -1
  36. package/dist/model-context/registry-handles.d.ts +0 -1
  37. package/dist/model-context/registry-handles.d.ts.map +1 -1
  38. package/dist/model-context/registry.d.ts +0 -1
  39. package/dist/model-context/registry.d.ts.map +1 -1
  40. package/dist/model-context/tool.d.ts +23 -9
  41. package/dist/model-context/tool.d.ts.map +1 -1
  42. package/dist/model-context/tool.js +0 -25
  43. package/dist/model-context/tool.js.map +1 -1
  44. package/dist/model-context/types.d.ts +0 -1
  45. package/dist/model-context/types.d.ts.map +1 -1
  46. package/dist/react/AssistantProvider.d.ts +0 -1
  47. package/dist/react/AssistantProvider.d.ts.map +1 -1
  48. package/dist/react/AssistantRuntimeProvider.d.ts +1 -6
  49. package/dist/react/AssistantRuntimeProvider.d.ts.map +1 -1
  50. package/dist/react/RuntimeAdapter.d.ts +1 -0
  51. package/dist/react/RuntimeAdapter.d.ts.map +1 -1
  52. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts +13 -2
  53. package/dist/react/adapters/LocalStorageThreadListAdapter.d.ts.map +1 -1
  54. package/dist/react/adapters/LocalStorageThreadListAdapter.js +122 -7
  55. package/dist/react/adapters/LocalStorageThreadListAdapter.js.map +1 -1
  56. package/dist/react/adapters/TitleGenerationAdapter.d.ts +0 -1
  57. package/dist/react/adapters/TitleGenerationAdapter.d.ts.map +1 -1
  58. package/dist/react/client/DataRenderers.d.ts +0 -1
  59. package/dist/react/client/DataRenderers.d.ts.map +1 -1
  60. package/dist/react/client/Interactables.d.ts +0 -1
  61. package/dist/react/client/Interactables.d.ts.map +1 -1
  62. package/dist/react/client/Tools.d.ts +3 -2
  63. package/dist/react/client/Tools.d.ts.map +1 -1
  64. package/dist/react/client/interactable-model-context.d.ts +0 -1
  65. package/dist/react/client/interactable-model-context.d.ts.map +1 -1
  66. package/dist/react/index.d.ts +2 -2
  67. package/dist/react/interactables-legacy/Interactables.d.ts +0 -1
  68. package/dist/react/interactables-legacy/Interactables.d.ts.map +1 -1
  69. package/dist/react/interactables-legacy/interactable-model-context.d.ts +0 -1
  70. package/dist/react/interactables-legacy/interactable-model-context.d.ts.map +1 -1
  71. package/dist/react/interactables-legacy/scopes.d.ts +4 -2
  72. package/dist/react/interactables-legacy/scopes.d.ts.map +1 -1
  73. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts +0 -1
  74. package/dist/react/interactables-legacy/useAssistantInteractable.d.ts.map +1 -1
  75. package/dist/react/interactables-legacy/useInteractableState.d.ts.map +1 -1
  76. package/dist/react/model-context/define-mcp-toolkit.d.ts +19 -4
  77. package/dist/react/model-context/define-mcp-toolkit.d.ts.map +1 -1
  78. package/dist/react/model-context/define-mcp-toolkit.js +17 -5
  79. package/dist/react/model-context/define-mcp-toolkit.js.map +1 -1
  80. package/dist/react/model-context/define-toolkit.d.ts +1 -2
  81. package/dist/react/model-context/define-toolkit.d.ts.map +1 -1
  82. package/dist/react/model-context/external-tool.d.ts.map +1 -1
  83. package/dist/react/model-context/human-tool.d.ts.map +1 -1
  84. package/dist/react/model-context/interactableTool.d.ts +2 -2
  85. package/dist/react/model-context/interactableTool.d.ts.map +1 -1
  86. package/dist/react/model-context/makeAssistantDataUI.d.ts +2 -2
  87. package/dist/react/model-context/makeAssistantDataUI.d.ts.map +1 -1
  88. package/dist/react/model-context/makeAssistantTool.d.ts +2 -2
  89. package/dist/react/model-context/makeAssistantTool.d.ts.map +1 -1
  90. package/dist/react/model-context/makeAssistantToolUI.d.ts +2 -2
  91. package/dist/react/model-context/makeAssistantToolUI.d.ts.map +1 -1
  92. package/dist/react/model-context/provider-tool.d.ts +0 -1
  93. package/dist/react/model-context/provider-tool.d.ts.map +1 -1
  94. package/dist/react/model-context/stub-tool.d.ts.map +1 -1
  95. package/dist/react/model-context/toolbox.d.ts +5 -5
  96. package/dist/react/model-context/toolbox.d.ts.map +1 -1
  97. package/dist/react/model-context/useAssistantContext.d.ts +1 -0
  98. package/dist/react/model-context/useAssistantContext.d.ts.map +1 -1
  99. package/dist/react/model-context/useAssistantDataUI.d.ts +3 -2
  100. package/dist/react/model-context/useAssistantDataUI.d.ts.map +1 -1
  101. package/dist/react/model-context/useAssistantInstructions.d.ts +1 -0
  102. package/dist/react/model-context/useAssistantInstructions.d.ts.map +1 -1
  103. package/dist/react/model-context/useAssistantTool.d.ts +4 -2
  104. package/dist/react/model-context/useAssistantTool.d.ts.map +1 -1
  105. package/dist/react/model-context/useAssistantToolUI.d.ts +3 -2
  106. package/dist/react/model-context/useAssistantToolUI.d.ts.map +1 -1
  107. package/dist/react/model-context/useAuiToolOverrides.d.ts +0 -1
  108. package/dist/react/model-context/useAuiToolOverrides.d.ts.map +1 -1
  109. package/dist/react/model-context/useInlineRender.d.ts +0 -1
  110. package/dist/react/model-context/useInlineRender.d.ts.map +1 -1
  111. package/dist/react/model-context/useInteractable.d.ts +7 -4
  112. package/dist/react/model-context/useInteractable.d.ts.map +1 -1
  113. package/dist/react/model-context/useInteractableState.d.ts.map +1 -1
  114. package/dist/react/model-context/useInteractableVersions.d.ts +0 -1
  115. package/dist/react/model-context/useInteractableVersions.d.ts.map +1 -1
  116. package/dist/react/model-context/useToolArgsStatus.d.ts +3 -1
  117. package/dist/react/model-context/useToolArgsStatus.d.ts.map +1 -1
  118. package/dist/react/primitive-hooks/useActionBarCopy.d.ts +1 -4
  119. package/dist/react/primitive-hooks/useActionBarCopy.d.ts.map +1 -1
  120. package/dist/react/primitive-hooks/useActionBarEdit.d.ts.map +1 -1
  121. package/dist/react/primitive-hooks/useActionBarFeedback.d.ts.map +1 -1
  122. package/dist/react/primitive-hooks/useActionBarReload.d.ts.map +1 -1
  123. package/dist/react/primitive-hooks/useActionBarSpeak.d.ts.map +1 -1
  124. package/dist/react/primitive-hooks/useActionBarStopSpeaking.d.ts.map +1 -1
  125. package/dist/react/primitive-hooks/useBranchPickerNext.d.ts.map +1 -1
  126. package/dist/react/primitive-hooks/useBranchPickerPrevious.d.ts.map +1 -1
  127. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts +0 -1
  128. package/dist/react/primitive-hooks/useComposerAddAttachment.d.ts.map +1 -1
  129. package/dist/react/primitive-hooks/useComposerCancel.d.ts.map +1 -1
  130. package/dist/react/primitive-hooks/useComposerDictate.d.ts.map +1 -1
  131. package/dist/react/primitive-hooks/useComposerSend.d.ts +0 -1
  132. package/dist/react/primitive-hooks/useComposerSend.d.ts.map +1 -1
  133. package/dist/react/primitive-hooks/useEditComposerCancel.d.ts.map +1 -1
  134. package/dist/react/primitive-hooks/useEditComposerSend.d.ts.map +1 -1
  135. package/dist/react/primitive-hooks/useMessageBranching.d.ts.map +1 -1
  136. package/dist/react/primitive-hooks/useMessageError.d.ts.map +1 -1
  137. package/dist/react/primitive-hooks/useMessageError.js +5 -1
  138. package/dist/react/primitive-hooks/useMessageError.js.map +1 -1
  139. package/dist/react/primitive-hooks/useMessageReload.d.ts.map +1 -1
  140. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts +1 -5
  141. package/dist/react/primitive-hooks/useSuggestionTrigger.d.ts.map +1 -1
  142. package/dist/react/primitive-hooks/useThreadIsEmpty.d.ts.map +1 -1
  143. package/dist/react/primitive-hooks/useThreadIsRunning.d.ts.map +1 -1
  144. package/dist/react/primitive-hooks/useThreadListItemArchive.d.ts.map +1 -1
  145. package/dist/react/primitive-hooks/useThreadListItemDelete.d.ts.map +1 -1
  146. package/dist/react/primitive-hooks/useThreadListItemTrigger.d.ts.map +1 -1
  147. package/dist/react/primitive-hooks/useThreadListItemUnarchive.d.ts.map +1 -1
  148. package/dist/react/primitive-hooks/useThreadListLoadMore.d.ts.map +1 -1
  149. package/dist/react/primitive-hooks/useThreadListNew.d.ts.map +1 -1
  150. package/dist/react/primitive-hooks/useThreadMessageIds.d.ts.map +1 -1
  151. package/dist/react/primitive-hooks/useThreadMessages.d.ts +0 -1
  152. package/dist/react/primitive-hooks/useThreadMessages.d.ts.map +1 -1
  153. package/dist/react/primitive-hooks/useVoice.d.ts +0 -1
  154. package/dist/react/primitive-hooks/useVoice.d.ts.map +1 -1
  155. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts +7 -4
  156. package/dist/react/primitives/chainOfThought/ChainOfThoughtParts.d.ts.map +1 -1
  157. package/dist/react/primitives/composer/ComposerAttachments.d.ts +4 -3
  158. package/dist/react/primitives/composer/ComposerAttachments.d.ts.map +1 -1
  159. package/dist/react/primitives/composer/ComposerIf.d.ts +4 -3
  160. package/dist/react/primitives/composer/ComposerIf.d.ts.map +1 -1
  161. package/dist/react/primitives/composer/ComposerQueue.d.ts +2 -2
  162. package/dist/react/primitives/composer/ComposerQueue.d.ts.map +1 -1
  163. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts +2 -2
  164. package/dist/react/primitives/generativeUI/GenerativeUI.d.ts.map +1 -1
  165. package/dist/react/primitives/message/MessageAttachments.d.ts +4 -3
  166. package/dist/react/primitives/message/MessageAttachments.d.ts.map +1 -1
  167. package/dist/react/primitives/message/MessageGroupedParts.d.ts +1 -6
  168. package/dist/react/primitives/message/MessageGroupedParts.d.ts.map +1 -1
  169. package/dist/react/primitives/message/MessageParts.d.ts +42 -24
  170. package/dist/react/primitives/message/MessageParts.d.ts.map +1 -1
  171. package/dist/react/primitives/message/MessageParts.js +2 -1
  172. package/dist/react/primitives/message/MessageParts.js.map +1 -1
  173. package/dist/react/primitives/message/MessageQuote.d.ts +2 -2
  174. package/dist/react/primitives/message/MessageQuote.d.ts.map +1 -1
  175. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts +0 -1
  176. package/dist/react/primitives/messagePart/MessagePartInProgress.d.ts.map +1 -1
  177. package/dist/react/primitives/part/PartMessages.d.ts +2 -2
  178. package/dist/react/primitives/part/PartMessages.d.ts.map +1 -1
  179. package/dist/react/primitives/thread/ThreadMessages.d.ts +35 -17
  180. package/dist/react/primitives/thread/ThreadMessages.d.ts.map +1 -1
  181. package/dist/react/primitives/thread/ThreadSuggestions.d.ts +6 -4
  182. package/dist/react/primitives/thread/ThreadSuggestions.d.ts.map +1 -1
  183. package/dist/react/primitives/threadList/ThreadListItems.d.ts +4 -3
  184. package/dist/react/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  185. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts +0 -1
  186. package/dist/react/primitives/threadListItem/ThreadListItemTitle.d.ts.map +1 -1
  187. package/dist/react/providers/AttachmentByIndexProvider.d.ts +0 -1
  188. package/dist/react/providers/AttachmentByIndexProvider.d.ts.map +1 -1
  189. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts +0 -1
  190. package/dist/react/providers/ChainOfThoughtByIndicesProvider.d.ts.map +1 -1
  191. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts +0 -1
  192. package/dist/react/providers/ChainOfThoughtPartByIndexProvider.d.ts.map +1 -1
  193. package/dist/react/providers/MessageByIdProvider.d.ts +0 -1
  194. package/dist/react/providers/MessageByIdProvider.d.ts.map +1 -1
  195. package/dist/react/providers/MessageByIndexProvider.d.ts +0 -1
  196. package/dist/react/providers/MessageByIndexProvider.d.ts.map +1 -1
  197. package/dist/react/providers/PartByIndexProvider.d.ts +0 -1
  198. package/dist/react/providers/PartByIndexProvider.d.ts.map +1 -1
  199. package/dist/react/providers/QueueItemByIndexProvider.d.ts +0 -1
  200. package/dist/react/providers/QueueItemByIndexProvider.d.ts.map +1 -1
  201. package/dist/react/providers/ReadonlyThreadProvider.d.ts +0 -1
  202. package/dist/react/providers/ReadonlyThreadProvider.d.ts.map +1 -1
  203. package/dist/react/providers/SuggestionByIndexProvider.d.ts +0 -1
  204. package/dist/react/providers/SuggestionByIndexProvider.d.ts.map +1 -1
  205. package/dist/react/providers/TextMessagePartProvider.d.ts +0 -1
  206. package/dist/react/providers/TextMessagePartProvider.d.ts.map +1 -1
  207. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts +0 -1
  208. package/dist/react/providers/ThreadListItemByIndexProvider.d.ts.map +1 -1
  209. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts +1 -1
  210. package/dist/react/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -1
  211. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts +2 -1
  212. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  213. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js +1 -1
  214. package/dist/react/runtimes/RemoteThreadListHookInstanceManager.js.map +1 -1
  215. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts +3 -1
  216. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  217. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js +21 -19
  218. package/dist/react/runtimes/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  219. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts +0 -1
  220. package/dist/react/runtimes/RuntimeAdapterProvider.d.ts.map +1 -1
  221. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts +0 -1
  222. package/dist/react/runtimes/cloud/AssistantCloudThreadHistoryAdapter.d.ts.map +1 -1
  223. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts +1 -4
  224. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.d.ts.map +1 -1
  225. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js +6 -3
  226. package/dist/react/runtimes/cloud/CloudFileAttachmentAdapter.js.map +1 -1
  227. package/dist/react/runtimes/cloud/auiV0.d.ts +12 -2
  228. package/dist/react/runtimes/cloud/auiV0.d.ts.map +1 -1
  229. package/dist/react/runtimes/cloud/auiV0.js +30 -1
  230. package/dist/react/runtimes/cloud/auiV0.js.map +1 -1
  231. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts +0 -1
  232. package/dist/react/runtimes/cloud/useCloudThreadListAdapter.d.ts.map +1 -1
  233. package/dist/react/runtimes/createMessageConverter.d.ts +1 -7
  234. package/dist/react/runtimes/createMessageConverter.d.ts.map +1 -1
  235. package/dist/react/runtimes/createRuntimeExtras.d.ts +0 -1
  236. package/dist/react/runtimes/createRuntimeExtras.d.ts.map +1 -1
  237. package/dist/react/runtimes/external-message-converter.d.ts +1 -8
  238. package/dist/react/runtimes/external-message-converter.d.ts.map +1 -1
  239. package/dist/react/runtimes/external-message-converter.js +42 -44
  240. package/dist/react/runtimes/external-message-converter.js.map +1 -1
  241. package/dist/react/runtimes/useExternalStoreRuntime.d.ts +0 -1
  242. package/dist/react/runtimes/useExternalStoreRuntime.d.ts.map +1 -1
  243. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts +0 -1
  244. package/dist/react/runtimes/useExternalStoreSharedOptions.d.ts.map +1 -1
  245. package/dist/react/runtimes/useLocalRuntime.d.ts +2 -5
  246. package/dist/react/runtimes/useLocalRuntime.d.ts.map +1 -1
  247. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts +0 -1
  248. package/dist/react/runtimes/useRemoteThreadListRuntime.d.ts.map +1 -1
  249. package/dist/react/runtimes/useStreamingTiming.d.ts +0 -1
  250. package/dist/react/runtimes/useStreamingTiming.d.ts.map +1 -1
  251. package/dist/react/types/MessagePartComponentTypes.d.ts +6 -3
  252. package/dist/react/types/MessagePartComponentTypes.d.ts.map +1 -1
  253. package/dist/react/types/scopes/dataRenderers.d.ts +1 -1
  254. package/dist/react/types/scopes/dataRenderers.d.ts.map +1 -1
  255. package/dist/react/types/scopes/interactables.d.ts +4 -2
  256. package/dist/react/types/scopes/interactables.d.ts.map +1 -1
  257. package/dist/react/types/scopes/tools.d.ts +5 -3
  258. package/dist/react/types/scopes/tools.d.ts.map +1 -1
  259. package/dist/react/types/store-augmentation.d.ts +1 -2
  260. package/dist/react/types/store-augmentation.d.ts.map +1 -1
  261. package/dist/react/utils/getMessageQuote.d.ts +0 -1
  262. package/dist/react/utils/getMessageQuote.d.ts.map +1 -1
  263. package/dist/react/utils/groupParts.d.ts +2 -2
  264. package/dist/react/utils/groupParts.d.ts.map +1 -1
  265. package/dist/react/utils/useJSONEqual.d.ts.map +1 -1
  266. package/dist/runtime/api/assistant-runtime.d.ts +0 -1
  267. package/dist/runtime/api/assistant-runtime.d.ts.map +1 -1
  268. package/dist/runtime/api/attachment-runtime.d.ts +0 -1
  269. package/dist/runtime/api/attachment-runtime.d.ts.map +1 -1
  270. package/dist/runtime/api/bindings.d.ts +0 -1
  271. package/dist/runtime/api/bindings.d.ts.map +1 -1
  272. package/dist/runtime/api/composer-runtime.d.ts +6 -4
  273. package/dist/runtime/api/composer-runtime.d.ts.map +1 -1
  274. package/dist/runtime/api/message-part-runtime.d.ts +0 -1
  275. package/dist/runtime/api/message-part-runtime.d.ts.map +1 -1
  276. package/dist/runtime/api/message-runtime.d.ts +6 -16
  277. package/dist/runtime/api/message-runtime.d.ts.map +1 -1
  278. package/dist/runtime/api/message-runtime.js +1 -1
  279. package/dist/runtime/api/paths.d.ts.map +1 -1
  280. package/dist/runtime/api/thread-list-item-runtime.d.ts +0 -1
  281. package/dist/runtime/api/thread-list-item-runtime.d.ts.map +1 -1
  282. package/dist/runtime/api/thread-list-runtime.d.ts +0 -1
  283. package/dist/runtime/api/thread-list-runtime.d.ts.map +1 -1
  284. package/dist/runtime/api/thread-runtime.d.ts +3 -1
  285. package/dist/runtime/api/thread-runtime.d.ts.map +1 -1
  286. package/dist/runtime/base/base-assistant-runtime-core.d.ts +0 -1
  287. package/dist/runtime/base/base-assistant-runtime-core.d.ts.map +1 -1
  288. package/dist/runtime/base/base-composer-runtime-core.d.ts +0 -1
  289. package/dist/runtime/base/base-composer-runtime-core.d.ts.map +1 -1
  290. package/dist/runtime/base/base-composer-runtime-core.js +17 -3
  291. package/dist/runtime/base/base-composer-runtime-core.js.map +1 -1
  292. package/dist/runtime/base/base-thread-runtime-core.d.ts +2 -4
  293. package/dist/runtime/base/base-thread-runtime-core.d.ts.map +1 -1
  294. package/dist/runtime/base/base-thread-runtime-core.js +1 -1
  295. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts +1 -5
  296. package/dist/runtime/base/default-edit-composer-runtime-core.d.ts.map +1 -1
  297. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts +1 -0
  298. package/dist/runtime/base/default-thread-composer-runtime-core.d.ts.map +1 -1
  299. package/dist/runtime/branch/external-thread-branch-adapter.d.ts.map +1 -1
  300. package/dist/runtime/interfaces/assistant-runtime-core.d.ts +0 -1
  301. package/dist/runtime/interfaces/assistant-runtime-core.d.ts.map +1 -1
  302. package/dist/runtime/interfaces/composer-runtime-core.d.ts +2 -2
  303. package/dist/runtime/interfaces/composer-runtime-core.d.ts.map +1 -1
  304. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts +0 -1
  305. package/dist/runtime/interfaces/thread-list-runtime-core.d.ts.map +1 -1
  306. package/dist/runtime/interfaces/thread-runtime-core.d.ts +2 -2
  307. package/dist/runtime/interfaces/thread-runtime-core.d.ts.map +1 -1
  308. package/dist/runtime/queue/external-thread-queue-adapter.d.ts +0 -1
  309. package/dist/runtime/queue/external-thread-queue-adapter.d.ts.map +1 -1
  310. package/dist/runtime/queue/message-queue.d.ts +6 -4
  311. package/dist/runtime/queue/message-queue.d.ts.map +1 -1
  312. package/dist/runtime/queue/message-queue.js +1 -1
  313. package/dist/runtime/utils/auto-status.d.ts +0 -1
  314. package/dist/runtime/utils/auto-status.d.ts.map +1 -1
  315. package/dist/runtime/utils/chat-model-adapter.d.ts +0 -1
  316. package/dist/runtime/utils/chat-model-adapter.d.ts.map +1 -1
  317. package/dist/runtime/utils/external-store-message.d.ts +0 -1
  318. package/dist/runtime/utils/external-store-message.d.ts.map +1 -1
  319. package/dist/runtime/utils/message-repository.d.ts +1 -5
  320. package/dist/runtime/utils/message-repository.d.ts.map +1 -1
  321. package/dist/runtime/utils/message-repository.js +3 -1
  322. package/dist/runtime/utils/message-repository.js.map +1 -1
  323. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts +0 -1
  324. package/dist/runtime/utils/resolveToolApprovalResponse.d.ts.map +1 -1
  325. package/dist/runtime/utils/streaming-timing.d.ts +5 -3
  326. package/dist/runtime/utils/streaming-timing.d.ts.map +1 -1
  327. package/dist/runtime/utils/thread-message-like.d.ts +2 -2
  328. package/dist/runtime/utils/thread-message-like.d.ts.map +1 -1
  329. package/dist/runtime/utils/thread-message-like.js.map +1 -1
  330. package/dist/runtimes/assistant-transport/utils.d.ts.map +1 -1
  331. package/dist/runtimes/external-store/external-store-adapter.d.ts +2 -2
  332. package/dist/runtimes/external-store/external-store-adapter.d.ts.map +1 -1
  333. package/dist/runtimes/external-store/external-store-runtime-core.d.ts +0 -1
  334. package/dist/runtimes/external-store/external-store-runtime-core.d.ts.map +1 -1
  335. package/dist/runtimes/external-store/external-store-shared-options.d.ts +0 -1
  336. package/dist/runtimes/external-store/external-store-shared-options.d.ts.map +1 -1
  337. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts +0 -1
  338. package/dist/runtimes/external-store/external-store-thread-list-runtime-core.d.ts.map +1 -1
  339. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts +2 -0
  340. package/dist/runtimes/external-store/external-store-thread-runtime-core.d.ts.map +1 -1
  341. package/dist/runtimes/external-store/external-store-thread-runtime-core.js +1 -1
  342. package/dist/runtimes/external-store/thread-message-converter.d.ts +0 -1
  343. package/dist/runtimes/external-store/thread-message-converter.d.ts.map +1 -1
  344. package/dist/runtimes/local/local-runtime-core.d.ts +0 -1
  345. package/dist/runtimes/local/local-runtime-core.d.ts.map +1 -1
  346. package/dist/runtimes/local/local-runtime-options.d.ts +0 -1
  347. package/dist/runtimes/local/local-runtime-options.d.ts.map +1 -1
  348. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts +0 -1
  349. package/dist/runtimes/local/local-thread-list-runtime-core.d.ts.map +1 -1
  350. package/dist/runtimes/local/local-thread-runtime-core.d.ts +5 -21
  351. package/dist/runtimes/local/local-thread-runtime-core.d.ts.map +1 -1
  352. package/dist/runtimes/local/local-thread-runtime-core.js +24 -15
  353. package/dist/runtimes/local/local-thread-runtime-core.js.map +1 -1
  354. package/dist/runtimes/local/should-continue.d.ts +0 -1
  355. package/dist/runtimes/local/should-continue.d.ts.map +1 -1
  356. package/dist/runtimes/local/should-continue.js +2 -2
  357. package/dist/runtimes/local/should-continue.js.map +1 -1
  358. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts +0 -1
  359. package/dist/runtimes/readonly/ReadonlyThreadRuntimeCore.d.ts.map +1 -1
  360. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts +1 -2
  361. package/dist/runtimes/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  362. package/dist/runtimes/remote-thread-list/adapter/in-memory.js +5 -3
  363. package/dist/runtimes/remote-thread-list/adapter/in-memory.js.map +1 -1
  364. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts +0 -1
  365. package/dist/runtimes/remote-thread-list/empty-thread-core.d.ts.map +1 -1
  366. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts +6 -4
  367. package/dist/runtimes/remote-thread-list/optimistic-state.d.ts.map +1 -1
  368. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts +0 -1
  369. package/dist/runtimes/remote-thread-list/remote-thread-state.d.ts.map +1 -1
  370. package/dist/runtimes/remote-thread-list/types.d.ts +0 -1
  371. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  372. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts +2 -2
  373. package/dist/runtimes/tool-invocations/ToolInvocationTracker.d.ts.map +1 -1
  374. package/dist/store/clients/chain-of-thought-client.d.ts +0 -1
  375. package/dist/store/clients/chain-of-thought-client.d.ts.map +1 -1
  376. package/dist/store/clients/model-context-client.d.ts +0 -1
  377. package/dist/store/clients/model-context-client.d.ts.map +1 -1
  378. package/dist/store/clients/no-op-composer-client.d.ts +0 -1
  379. package/dist/store/clients/no-op-composer-client.d.ts.map +1 -1
  380. package/dist/store/clients/runtime-adapter.d.ts +0 -1
  381. package/dist/store/clients/runtime-adapter.d.ts.map +1 -1
  382. package/dist/store/clients/suggestions.d.ts +0 -1
  383. package/dist/store/clients/suggestions.d.ts.map +1 -1
  384. package/dist/store/clients/thread-message-client.d.ts +0 -1
  385. package/dist/store/clients/thread-message-client.d.ts.map +1 -1
  386. package/dist/store/runtime-clients/attachment-runtime-client.d.ts +0 -1
  387. package/dist/store/runtime-clients/attachment-runtime-client.d.ts.map +1 -1
  388. package/dist/store/runtime-clients/composer-runtime-client.d.ts +0 -1
  389. package/dist/store/runtime-clients/composer-runtime-client.d.ts.map +1 -1
  390. package/dist/store/runtime-clients/liveRef.d.ts.map +1 -1
  391. package/dist/store/runtime-clients/message-part-runtime-client.d.ts +0 -1
  392. package/dist/store/runtime-clients/message-part-runtime-client.d.ts.map +1 -1
  393. package/dist/store/runtime-clients/message-runtime-client.d.ts +0 -1
  394. package/dist/store/runtime-clients/message-runtime-client.d.ts.map +1 -1
  395. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts +0 -1
  396. package/dist/store/runtime-clients/thread-list-item-runtime-client.d.ts.map +1 -1
  397. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts +0 -1
  398. package/dist/store/runtime-clients/thread-list-runtime-client.d.ts.map +1 -1
  399. package/dist/store/runtime-clients/thread-runtime-client.d.ts +0 -1
  400. package/dist/store/runtime-clients/thread-runtime-client.d.ts.map +1 -1
  401. package/dist/store/runtime-clients/useSubscribable.d.ts +0 -1
  402. package/dist/store/runtime-clients/useSubscribable.d.ts.map +1 -1
  403. package/dist/store/scope-registration.d.ts +1 -2
  404. package/dist/store/scope-registration.d.ts.map +1 -1
  405. package/dist/store/scopes/attachment.d.ts +0 -1
  406. package/dist/store/scopes/attachment.d.ts.map +1 -1
  407. package/dist/store/scopes/chain-of-thought.d.ts +0 -1
  408. package/dist/store/scopes/chain-of-thought.d.ts.map +1 -1
  409. package/dist/store/scopes/composer.d.ts +0 -1
  410. package/dist/store/scopes/composer.d.ts.map +1 -1
  411. package/dist/store/scopes/message.d.ts +6 -4
  412. package/dist/store/scopes/message.d.ts.map +1 -1
  413. package/dist/store/scopes/model-context.d.ts +0 -1
  414. package/dist/store/scopes/model-context.d.ts.map +1 -1
  415. package/dist/store/scopes/part.d.ts +0 -1
  416. package/dist/store/scopes/part.d.ts.map +1 -1
  417. package/dist/store/scopes/queue-item.d.ts.map +1 -1
  418. package/dist/store/scopes/suggestion.d.ts.map +1 -1
  419. package/dist/store/scopes/suggestions.d.ts +0 -1
  420. package/dist/store/scopes/suggestions.d.ts.map +1 -1
  421. package/dist/store/scopes/thread-list-item.d.ts +0 -1
  422. package/dist/store/scopes/thread-list-item.d.ts.map +1 -1
  423. package/dist/store/scopes/thread.d.ts +4 -3
  424. package/dist/store/scopes/thread.d.ts.map +1 -1
  425. package/dist/store/scopes/threads.d.ts +0 -1
  426. package/dist/store/scopes/threads.d.ts.map +1 -1
  427. package/dist/subscribable/subscribable.d.ts +0 -1
  428. package/dist/subscribable/subscribable.d.ts.map +1 -1
  429. package/dist/tests/remote-thread-list-test-helpers.d.ts +0 -1
  430. package/dist/tests/remote-thread-list-test-helpers.d.ts.map +1 -1
  431. package/dist/types/attachment.d.ts +1 -1
  432. package/dist/types/attachment.d.ts.map +1 -1
  433. package/dist/types/directive.d.ts +3 -2
  434. package/dist/types/directive.d.ts.map +1 -1
  435. package/dist/types/error.d.ts +15 -0
  436. package/dist/types/error.d.ts.map +1 -0
  437. package/dist/types/error.js +46 -0
  438. package/dist/types/error.js.map +1 -0
  439. package/dist/types/index.d.ts +2 -2
  440. package/dist/types/message.d.ts +70 -33
  441. package/dist/types/message.d.ts.map +1 -1
  442. package/dist/types/message.js.map +1 -1
  443. package/dist/types/quote.d.ts.map +1 -1
  444. package/dist/types/trigger.d.ts +0 -1
  445. package/dist/types/trigger.d.ts.map +1 -1
  446. package/dist/types/unsubscribe.d.ts.map +1 -1
  447. package/dist/utils/composite-context-provider.d.ts +1 -0
  448. package/dist/utils/composite-context-provider.d.ts.map +1 -1
  449. package/dist/utils/id.d.ts.map +1 -1
  450. package/dist/utils/json/is-json-equal.d.ts.map +1 -1
  451. package/dist/utils/json/is-json.d.ts +0 -1
  452. package/dist/utils/json/is-json.d.ts.map +1 -1
  453. package/dist/utils/json/is-json.js +1 -1
  454. package/dist/utils/json/is-json.js.map +1 -1
  455. package/dist/utils/json/stable-stringify-tool-args.d.ts +7 -0
  456. package/dist/utils/json/stable-stringify-tool-args.d.ts.map +1 -0
  457. package/dist/utils/json/stable-stringify-tool-args.js +32 -0
  458. package/dist/utils/json/stable-stringify-tool-args.js.map +1 -0
  459. package/dist/utils/text.d.ts +0 -1
  460. package/dist/utils/text.d.ts.map +1 -1
  461. package/package.json +12 -9
  462. package/src/adapters/attachment.test.ts +107 -0
  463. package/src/adapters/attachment.ts +20 -10
  464. package/src/adapters/index.ts +6 -1
  465. package/src/adapters/suggestion.test.ts +187 -0
  466. package/src/adapters/suggestion.ts +75 -1
  467. package/src/index.ts +15 -1
  468. package/src/internal.ts +16 -0
  469. package/src/model-context/tool.test.ts +110 -0
  470. package/src/model-context/tool.ts +31 -9
  471. package/src/react/adapters/LocalStorageThreadListAdapter.test.ts +222 -0
  472. package/src/react/adapters/LocalStorageThreadListAdapter.tsx +214 -7
  473. package/src/react/index.ts +2 -0
  474. package/src/react/model-context/define-mcp-toolkit.ts +39 -6
  475. package/src/react/model-context/define-toolkit.test.ts +107 -0
  476. package/src/react/primitive-hooks/useMessageError.test.ts +64 -0
  477. package/src/react/primitive-hooks/useMessageError.ts +19 -6
  478. package/src/react/runtimes/RemoteThreadListHookInstanceManager.tsx +3 -1
  479. package/src/react/runtimes/RemoteThreadListThreadListRuntimeCore.tsx +48 -19
  480. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.test.ts +111 -0
  481. package/src/react/runtimes/cloud/CloudFileAttachmentAdapter.ts +13 -3
  482. package/src/react/runtimes/cloud/auiV0.ts +71 -2
  483. package/src/react/runtimes/external-message-converter.test.tsx +102 -0
  484. package/src/react/runtimes/external-message-converter.ts +35 -10
  485. package/src/runtime/base/base-composer-runtime-core.ts +26 -7
  486. package/src/runtime/utils/message-repository.ts +8 -3
  487. package/src/runtime/utils/thread-message-like.ts +2 -0
  488. package/src/runtimes/local/local-thread-runtime-core.test.ts +127 -3
  489. package/src/runtimes/local/local-thread-runtime-core.ts +25 -23
  490. package/src/runtimes/local/should-continue.ts +5 -2
  491. package/src/runtimes/remote-thread-list/adapter/in-memory.test.ts +14 -0
  492. package/src/runtimes/remote-thread-list/adapter/in-memory.ts +13 -5
  493. package/src/tests/MessageRepository.test.ts +26 -0
  494. package/src/tests/RemoteThreadListThreadListRuntimeCore-errors.test.ts +42 -0
  495. package/src/tests/attachment-adapters.test.ts +14 -2
  496. package/src/tests/auiV0Encode.test.ts +134 -1
  497. package/src/tests/base-composer-runtime-core-addAttachment.test.ts +79 -5
  498. package/src/tests/base-composer-runtime-core-send.test.ts +145 -0
  499. package/src/tests/thread-message-like.test.ts +40 -0
  500. package/src/types/attachment.ts +1 -0
  501. package/src/types/error.test.ts +122 -0
  502. package/src/types/error.ts +74 -0
  503. package/src/types/index.ts +1 -0
  504. package/src/types/message.ts +11 -3
  505. package/src/utils/json/is-json-equal.test.ts +84 -0
  506. package/src/utils/json/is-json.test.ts +123 -0
  507. package/src/utils/json/is-json.ts +1 -1
  508. package/src/utils/json/stable-stringify-tool-args.test.ts +105 -0
  509. package/src/utils/json/stable-stringify-tool-args.ts +70 -0
@@ -1,6 +1,5 @@
1
1
  import { ThreadUserMessagePart } from "../types/message.js";
2
2
  import { Attachment, CompleteAttachment, PendingAttachment } from "../types/attachment.js";
3
-
4
3
  //#region src/adapters/attachment.d.ts
5
4
  type AttachmentAdapter = {
6
5
  accept: string;
@@ -18,6 +17,7 @@ declare class SimpleImageAttachmentAdapter implements AttachmentAdapter {
18
17
  send(attachment: PendingAttachment): Promise<CompleteAttachment>;
19
18
  remove(): Promise<void>;
20
19
  }
20
+ declare const getFileDataURL: (file: File) => Promise<string>;
21
21
  declare class SimpleTextAttachmentAdapter implements AttachmentAdapter {
22
22
  accept: string;
23
23
  add(state: {
@@ -46,5 +46,5 @@ declare class CompositeAttachmentAdapter implements AttachmentAdapter {
46
46
  remove(attachment: Attachment): Promise<void>;
47
47
  }
48
48
  //#endregion
49
- export { AttachmentAdapter, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, attachmentsEqual, fileMatchesAccept, liftNonTextParts, partToCompleteAttachment };
49
+ export { AttachmentAdapter, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, attachmentsEqual, fileMatchesAccept, getFileDataURL, liftNonTextParts, partToCompleteAttachment };
50
50
  //# sourceMappingURL=attachment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"attachment.d.ts","names":[],"sources":["../../src/adapters/attachment.ts"],"mappings":";;;;KAQY,iBAAA;EACV,MAAA;EACA,GAAA,CAAI,KAAA;IACF,IAAA,EAAM,IAAA;EAAA,IACJ,OAAA,CAAQ,iBAAA,IAAqB,cAAA,CAAe,iBAAA;EAChD,MAAA,CAAO,UAAA,EAAY,UAAA,GAAa,OAAA;EAChC,IAAA,CAAK,UAAA,EAAY,iBAAA,GAAoB,OAAA,CAAQ,kBAAA;AAAA;AAAA,cAGlC,4BAAA,YAAwC,iBAAA;EAC5C,MAAA;EAEM,GAAA,CAAI,KAAA;IAAS,IAAA,EAAM,IAAA;EAAA,IAAS,OAAA,CAAQ,iBAAA;EAWpC,IAAA,CACX,UAAA,EAAY,iBAAA,GACX,OAAA,CAAQ,kBAAA;EAaE,MAAA,IAAM,OAAA;AAAA;AAAA,cA6BR,2BAAA,YAAuC,iBAAA;EAC3C,MAAA;EAGM,GAAA,CAAI,KAAA;IAAS,IAAA,EAAM,IAAA;EAAA,IAAS,OAAA,CAAQ,iBAAA;EAWpC,IAAA,CACX,UAAA,EAAY,iBAAA,GACX,OAAA,CAAQ,kBAAA;EAaE,MAAA,IAAM,OAAA;AAAA;AAAA,iBAiBL,iBAAA,CACd,IAAA;EAAQ,IAAA;EAAc,IAAA;AAAA,G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EAUlC,OAAO,YAAY,aAAU"}
@@ -4,7 +4,7 @@ var SimpleImageAttachmentAdapter = class {
4
4
  accept = "image/*";
5
5
  async add(state) {
6
6
  return {
7
- id: state.file.name,
7
+ id: generateId(),
8
8
  type: "image",
9
9
  name: state.file.name,
10
10
  contentType: state.file.type,
@@ -27,11 +27,18 @@ var SimpleImageAttachmentAdapter = class {
27
27
  }
28
28
  async remove() {}
29
29
  };
30
- const bytesToBase64 = (bytes) => globalThis.Buffer.from(bytes).toString("base64");
30
+ const bytesToBase64 = (bytes) => {
31
+ const nodeBuffer = globalThis.Buffer;
32
+ if (nodeBuffer) return nodeBuffer.from(bytes).toString("base64");
33
+ let binary = "";
34
+ const chunkSize = 32768;
35
+ for (let i = 0; i < bytes.length; i += chunkSize) binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));
36
+ return btoa(binary);
37
+ };
31
38
  const getFileDataURL = async (file) => {
32
39
  if (typeof FileReader === "undefined") {
33
40
  const buffer = await file.arrayBuffer();
34
- return `data:${file.type};base64,${bytesToBase64(new Uint8Array(buffer))}`;
41
+ return `data:${file.type || "application/octet-stream"};base64,${bytesToBase64(new Uint8Array(buffer))}`;
35
42
  }
36
43
  return new Promise((resolve, reject) => {
37
44
  const reader = new FileReader();
@@ -41,10 +48,10 @@ const getFileDataURL = async (file) => {
41
48
  });
42
49
  };
43
50
  var SimpleTextAttachmentAdapter = class {
44
- accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css";
51
+ accept = "text/plain,text/html,text/markdown,text/csv,text/xml,text/json,application/json,text/css";
45
52
  async add(state) {
46
53
  return {
47
- id: state.file.name,
54
+ id: generateId(),
48
55
  type: "document",
49
56
  name: state.file.name,
50
57
  contentType: state.file.type,
@@ -80,7 +87,7 @@ function fileMatchesAccept(file, acceptString) {
80
87
  if (acceptString === "*") return true;
81
88
  const allowedTypes = acceptString.split(",").map((type) => type.trim().toLowerCase());
82
89
  const fileExtension = `.${file.name.split(".").pop().toLowerCase()}`;
83
- const fileMimeType = file.type.toLowerCase();
90
+ const fileMimeType = file.type.split(";", 1)[0].trim().toLowerCase();
84
91
  for (const type of allowedTypes) {
85
92
  if (type.startsWith(".") && type === fileExtension) return true;
86
93
  if (type.includes("/") && type === fileMimeType) return true;
@@ -163,6 +170,6 @@ var CompositeAttachmentAdapter = class {
163
170
  }
164
171
  };
165
172
  //#endregion
166
- export { CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, attachmentsEqual, fileMatchesAccept, liftNonTextParts, partToCompleteAttachment };
173
+ export { CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, attachmentsEqual, fileMatchesAccept, getFileDataURL, liftNonTextParts, partToCompleteAttachment };
167
174
 
168
175
  //# sourceMappingURL=attachment.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"attachment.js","names":["Attachment","PendingAttachment","CompleteAttachment","ThreadUserMessagePart","generateId","AttachmentAdapter","accept","add","state","file","File","Promise","AsyncGenerator","remove","attachment","send","SimpleImageAttachmentAdapter","id","name","type","contentType","status","reason","content","image","getFileDataURL","bytesToBase64","bytes","Uint8Array","globalThis","Buffer","from","toString","encoding","FileReader","buffer","arrayBuffer","resolve","reject","reader","onload","result","onerror","error","readAsDataURL","SimpleTextAttachmentAdapter","text","getFileText","readAsText","fileMatchesAccept","acceptString","allowedTypes","split","map","trim","toLowerCase","fileExtension","pop","fileMimeType","startsWith","includes","endsWith","generalType","attachmentsEqual","a","b","length","every","att","i","partToCompleteAttachment","part","Exclude","filename","mimeType","audio","format","liftNonTextParts","push","CompositeAttachmentAdapter","_adapters","constructor","adapters","wildcardIdx","findIndex","Error","join","adapter","slice"],"sources":["../../src/adapters/attachment.ts"],"sourcesContent":["import type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n} from \"../types/attachment\";\nimport type { ThreadUserMessagePart } from \"../types/message\";\nimport { generateId } from \"../utils/id\";\n\nexport type AttachmentAdapter = {\n accept: string;\n add(state: {\n file: File;\n }): Promise<PendingAttachment> | AsyncGenerator<PendingAttachment, void>;\n remove(attachment: Attachment): Promise<void>;\n send(attachment: PendingAttachment): Promise<CompleteAttachment>;\n};\n\nexport class SimpleImageAttachmentAdapter implements AttachmentAdapter {\n public accept = \"image/*\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: state.file.name,\n type: \"image\",\n name: state.file.name,\n contentType: state.file.type,\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [\n {\n type: \"image\",\n image: await getFileDataURL(attachment.file),\n },\n ],\n };\n }\n\n public async remove() {\n // noop\n }\n}\n\nconst bytesToBase64 = (bytes: Uint8Array): string =>\n (\n globalThis as {\n Buffer: {\n from(bytes: Uint8Array): { toString(encoding: string): string };\n };\n }\n ).Buffer.from(bytes).toString(\"base64\");\n\n// React Native's Blob polyfill has FileReader but not file.text()/arrayBuffer(); Node has\n// the reverse. Prefer FileReader when present, falling back to the Blob methods otherwise.\nconst getFileDataURL = async (file: File): Promise<string> => {\n if (typeof FileReader === \"undefined\") {\n const buffer = await file.arrayBuffer();\n return `data:${file.type};base64,${bytesToBase64(new Uint8Array(buffer))}`;\n }\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = (error) => reject(error);\n reader.readAsDataURL(file);\n });\n};\n\nexport class SimpleTextAttachmentAdapter implements AttachmentAdapter {\n public accept =\n \"text/plain,text/html,text/markdown,text/csv,text/xml,text/json,text/css\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: state.file.name,\n type: \"document\",\n name: state.file.name,\n contentType: state.file.type,\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [\n {\n type: \"text\",\n text: `<attachment name=${attachment.name}>\\n${await getFileText(attachment.file)}\\n</attachment>`,\n },\n ],\n };\n }\n\n public async remove() {\n // noop\n }\n}\n\nconst getFileText = async (file: File): Promise<string> => {\n if (typeof FileReader === \"undefined\") {\n return file.text();\n }\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = (error) => reject(error);\n reader.readAsText(file);\n });\n};\n\nexport function fileMatchesAccept(\n file: { name: string; type: string },\n acceptString: string,\n) {\n if (acceptString === \"*\") {\n return true;\n }\n\n const allowedTypes = acceptString\n .split(\",\")\n .map((type) => type.trim().toLowerCase());\n\n const fileExtension = `.${file.name.split(\".\").pop()!.toLowerCase()}`;\n const fileMimeType = file.type.toLowerCase();\n\n for (const type of allowedTypes) {\n if (type.startsWith(\".\") && type === fileExtension) {\n return true;\n }\n\n if (type.includes(\"/\") && type === fileMimeType) {\n return true;\n }\n\n if (type.endsWith(\"/*\")) {\n const generalType = type.split(\"/\")[0]!;\n if (fileMimeType.startsWith(`${generalType}/`)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function attachmentsEqual(\n a: readonly CompleteAttachment[],\n b: readonly CompleteAttachment[],\n): boolean {\n if (a.length !== b.length) return false;\n return a.every((att, i) => att.id === b[i]!.id);\n}\n\nexport function partToCompleteAttachment(\n part: Exclude<ThreadUserMessagePart, { type: \"text\" }>,\n): CompleteAttachment {\n const id = generateId();\n\n if (part.type === \"image\") {\n return {\n id,\n type: \"image\",\n name: part.filename ?? \"image\",\n content: [part],\n status: { type: \"complete\" },\n };\n }\n\n if (part.type === \"file\") {\n return {\n id,\n type: \"document\",\n name: part.filename ?? \"document\",\n contentType: part.mimeType,\n content: [part],\n status: { type: \"complete\" },\n };\n }\n\n if (part.type === \"audio\") {\n return {\n id,\n type: \"audio\",\n name: `audio.${part.audio.format}`,\n contentType: `audio/${part.audio.format}`,\n content: [part],\n status: { type: \"complete\" },\n };\n }\n\n return {\n id,\n type: \"data\",\n name: part.name,\n content: [part],\n status: { type: \"complete\" },\n };\n}\n\nexport function liftNonTextParts(\n content: readonly ThreadUserMessagePart[],\n): CompleteAttachment[] {\n const result: CompleteAttachment[] = [];\n for (const part of content) {\n if (part.type !== \"text\") {\n result.push(partToCompleteAttachment(part));\n }\n }\n return result;\n}\n\nexport class CompositeAttachmentAdapter implements AttachmentAdapter {\n private _adapters: AttachmentAdapter[];\n\n public accept: string;\n\n constructor(adapters: AttachmentAdapter[]) {\n this._adapters = adapters;\n\n const wildcardIdx = adapters.findIndex((a) => a.accept === \"*\");\n if (wildcardIdx !== -1) {\n if (wildcardIdx !== adapters.length - 1)\n throw new Error(\n \"A wildcard adapter (handling all files) can only be specified as the last adapter.\",\n );\n\n this.accept = \"*\";\n } else {\n this.accept = adapters.map((a) => a.accept).join(\",\");\n }\n }\n\n public add(state: { file: File }) {\n for (const adapter of this._adapters) {\n if (fileMatchesAccept(state.file, adapter.accept)) {\n return adapter.add(state);\n }\n }\n throw new Error(\"No matching adapter found for file\");\n }\n\n public async send(attachment: PendingAttachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (fileMatchesAccept(attachment.file, adapter.accept)) {\n return adapter.send(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n\n public async remove(attachment: Attachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (\n fileMatchesAccept(\n {\n name: attachment.name,\n type: attachment.contentType ?? \"\",\n },\n adapter.accept,\n )\n ) {\n return adapter.remove(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n}\n"],"mappings":";;AAiBA,IAAagB,+BAAb,MAAuE;CACrE,SAAgB;CAEhB,MAAaT,IAAIC,OAAmD;EAClE,OAAO;GACLS,IAAIT,MAAMC,KAAKS;GACfC,MAAM;GACND,MAAMV,MAAMC,KAAKS;GACjBE,aAAaZ,MAAMC,KAAKU;GACxBV,MAAMD,MAAMC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KAAKP,WACzB,IAAI/B,kBAAkBzC,MAAMC,MAAM8E,QAAQjF,MAAM,GAC9C,OAAOiF,QAAQhF,IAAIC,KAAK;EAG5B,MAAM,IAAI6E,MAAM,oCAAoC;CACtD;CAEA,MAAatE,KAAKD,YAA+B;EAC/C,MAAMoE,WAAW,KAAKF,UAAUQ,MAAM;EACtC,KAAK,MAAMD,WAAWL,UACpB,IAAIjC,kBAAkBnC,WAAWL,MAAM8E,QAAQjF,MAAM,GACnD,OAAOiF,QAAQxE,KAAKD,UAAU;EAGlC,MAAM,IAAIuE,MAAM,0CAA0C;CAC5D;CAEA,MAAaxE,OAAOC,YAAwB;EAC1C,MAAMoE,WAAW,KAAKF,UAAUQ,MAAM;EACtC,KAAK,MAAMD,WAAWL,UACpB,IACEjC,kBACE;GACE/B,MAAMJ,WAAWI;GACjBC,MAAML,WAAWM,eAAe;EAClC,GACAmE,QAAQjF,MACV,GAEA,OAAOiF,QAAQ1E,OAAOC,UAAU;EAGpC,MAAM,IAAIuE,MAAM,0CAA0C;CAC5D;AACF"}
1
+ {"version":3,"file":"attachment.js","names":["Attachment","PendingAttachment","CompleteAttachment","ThreadUserMessagePart","generateId","AttachmentAdapter","accept","add","state","file","File","Promise","AsyncGenerator","remove","attachment","send","SimpleImageAttachmentAdapter","id","type","name","contentType","status","reason","content","image","getFileDataURL","bytesToBase64","bytes","Uint8Array","nodeBuffer","globalThis","Buffer","from","toString","encoding","binary","chunkSize","i","length","String","fromCharCode","subarray","btoa","FileReader","buffer","arrayBuffer","resolve","reject","reader","onload","result","onerror","error","readAsDataURL","SimpleTextAttachmentAdapter","text","getFileText","readAsText","fileMatchesAccept","acceptString","allowedTypes","split","map","trim","toLowerCase","fileExtension","pop","fileMimeType","startsWith","includes","endsWith","generalType","attachmentsEqual","a","b","every","att","partToCompleteAttachment","part","Exclude","filename","mimeType","audio","format","liftNonTextParts","push","CompositeAttachmentAdapter","_adapters","constructor","adapters","wildcardIdx","findIndex","Error","join","adapter","slice"],"sources":["../../src/adapters/attachment.ts"],"sourcesContent":["import type {\n Attachment,\n PendingAttachment,\n CompleteAttachment,\n} from \"../types/attachment\";\nimport type { ThreadUserMessagePart } from \"../types/message\";\nimport { generateId } from \"../utils/id\";\n\nexport type AttachmentAdapter = {\n accept: string;\n add(state: {\n file: File;\n }): Promise<PendingAttachment> | AsyncGenerator<PendingAttachment, void>;\n remove(attachment: Attachment): Promise<void>;\n send(attachment: PendingAttachment): Promise<CompleteAttachment>;\n};\n\nexport class SimpleImageAttachmentAdapter implements AttachmentAdapter {\n public accept = \"image/*\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: generateId(),\n type: \"image\",\n name: state.file.name,\n contentType: state.file.type,\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [\n {\n type: \"image\",\n image: await getFileDataURL(attachment.file),\n },\n ],\n };\n }\n\n public async remove() {\n // noop\n }\n}\n\nconst bytesToBase64 = (bytes: Uint8Array): string => {\n const nodeBuffer = (\n globalThis as {\n Buffer?: {\n from(bytes: Uint8Array): { toString(encoding: string): string };\n };\n }\n ).Buffer;\n if (nodeBuffer) {\n return nodeBuffer.from(bytes).toString(\"base64\");\n }\n let binary = \"\";\n const chunkSize = 0x8000;\n for (let i = 0; i < bytes.length; i += chunkSize) {\n binary += String.fromCharCode(...bytes.subarray(i, i + chunkSize));\n }\n return btoa(binary);\n};\n\n// React Native's Blob polyfill has FileReader but not file.text()/arrayBuffer(); Node has\n// the reverse. Prefer FileReader when present, falling back to the Blob methods otherwise.\nexport const getFileDataURL = async (file: File): Promise<string> => {\n if (typeof FileReader === \"undefined\") {\n const buffer = await file.arrayBuffer();\n return `data:${file.type || \"application/octet-stream\"};base64,${bytesToBase64(new Uint8Array(buffer))}`;\n }\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = (error) => reject(error);\n reader.readAsDataURL(file);\n });\n};\n\nexport class SimpleTextAttachmentAdapter implements AttachmentAdapter {\n public accept =\n \"text/plain,text/html,text/markdown,text/csv,text/xml,text/json,application/json,text/css\";\n\n public async add(state: { file: File }): Promise<PendingAttachment> {\n return {\n id: generateId(),\n type: \"document\",\n name: state.file.name,\n contentType: state.file.type,\n file: state.file,\n status: { type: \"requires-action\", reason: \"composer-send\" },\n };\n }\n\n public async send(\n attachment: PendingAttachment,\n ): Promise<CompleteAttachment> {\n return {\n ...attachment,\n status: { type: \"complete\" },\n content: [\n {\n type: \"text\",\n text: `<attachment name=${attachment.name}>\\n${await getFileText(attachment.file)}\\n</attachment>`,\n },\n ],\n };\n }\n\n public async remove() {\n // noop\n }\n}\n\nconst getFileText = async (file: File): Promise<string> => {\n if (typeof FileReader === \"undefined\") {\n return file.text();\n }\n return new Promise<string>((resolve, reject) => {\n const reader = new FileReader();\n reader.onload = () => resolve(reader.result as string);\n reader.onerror = (error) => reject(error);\n reader.readAsText(file);\n });\n};\n\nexport function fileMatchesAccept(\n file: { name: string; type: string },\n acceptString: string,\n) {\n if (acceptString === \"*\") {\n return true;\n }\n\n const allowedTypes = acceptString\n .split(\",\")\n .map((type) => type.trim().toLowerCase());\n\n const fileExtension = `.${file.name.split(\".\").pop()!.toLowerCase()}`;\n const fileMimeType = file.type.split(\";\", 1)[0]!.trim().toLowerCase();\n\n for (const type of allowedTypes) {\n if (type.startsWith(\".\") && type === fileExtension) {\n return true;\n }\n\n if (type.includes(\"/\") && type === fileMimeType) {\n return true;\n }\n\n if (type.endsWith(\"/*\")) {\n const generalType = type.split(\"/\")[0]!;\n if (fileMimeType.startsWith(`${generalType}/`)) {\n return true;\n }\n }\n }\n\n return false;\n}\n\nexport function attachmentsEqual(\n a: readonly CompleteAttachment[],\n b: readonly CompleteAttachment[],\n): boolean {\n if (a.length !== b.length) return false;\n return a.every((att, i) => att.id === b[i]!.id);\n}\n\nexport function partToCompleteAttachment(\n part: Exclude<ThreadUserMessagePart, { type: \"text\" }>,\n): CompleteAttachment {\n const id = generateId();\n\n if (part.type === \"image\") {\n return {\n id,\n type: \"image\",\n name: part.filename ?? \"image\",\n content: [part],\n status: { type: \"complete\" },\n };\n }\n\n if (part.type === \"file\") {\n return {\n id,\n type: \"document\",\n name: part.filename ?? \"document\",\n contentType: part.mimeType,\n content: [part],\n status: { type: \"complete\" },\n };\n }\n\n if (part.type === \"audio\") {\n return {\n id,\n type: \"audio\",\n name: `audio.${part.audio.format}`,\n contentType: `audio/${part.audio.format}`,\n content: [part],\n status: { type: \"complete\" },\n };\n }\n\n return {\n id,\n type: \"data\",\n name: part.name,\n content: [part],\n status: { type: \"complete\" },\n };\n}\n\nexport function liftNonTextParts(\n content: readonly ThreadUserMessagePart[],\n): CompleteAttachment[] {\n const result: CompleteAttachment[] = [];\n for (const part of content) {\n if (part.type !== \"text\") {\n result.push(partToCompleteAttachment(part));\n }\n }\n return result;\n}\n\nexport class CompositeAttachmentAdapter implements AttachmentAdapter {\n private _adapters: AttachmentAdapter[];\n\n public accept: string;\n\n constructor(adapters: AttachmentAdapter[]) {\n this._adapters = adapters;\n\n const wildcardIdx = adapters.findIndex((a) => a.accept === \"*\");\n if (wildcardIdx !== -1) {\n if (wildcardIdx !== adapters.length - 1)\n throw new Error(\n \"A wildcard adapter (handling all files) can only be specified as the last adapter.\",\n );\n\n this.accept = \"*\";\n } else {\n this.accept = adapters.map((a) => a.accept).join(\",\");\n }\n }\n\n public add(state: { file: File }) {\n for (const adapter of this._adapters) {\n if (fileMatchesAccept(state.file, adapter.accept)) {\n return adapter.add(state);\n }\n }\n throw new Error(\"No matching adapter found for file\");\n }\n\n public async send(attachment: PendingAttachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (fileMatchesAccept(attachment.file, adapter.accept)) {\n return adapter.send(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n\n public async remove(attachment: Attachment) {\n const adapters = this._adapters.slice();\n for (const adapter of adapters) {\n if (\n fileMatchesAccept(\n {\n name: attachment.name,\n type: attachment.contentType ?? \"\",\n },\n adapter.accept,\n )\n ) {\n return adapter.remove(attachment);\n }\n }\n throw new Error(\"No matching adapter found for attachment\");\n }\n}\n"],"mappings":";;AAiBA,IAAagB,+BAAb,MAAuE;CACrE,SAAgB;CAEhB,MAAaT,IAAIC,OAAmD;EAClE,OAAO;GACLS,IAAIb,WAAW;GACfc,MAAM;GACNC,MAAMX,MAAMC,KAAKU;GACjBC,aAAaZ,MAAMC,KAAKS;GACxBT,MAAMD,MAAMC;GACZY,QAAQ;IAAEH,MAAM;IAAmBI,QAAQ;GAAgB;EAC7D;CACF;CAEA,MAAaP,KACXD,YAC6B;EAC7B,OAAO;GACL,GAAGA;GACHO,QAAQ,EAAEH,MAAM,WAAW;GAC3BK,SAAS,CACP;IACEL,MAAM;IACNM,OAAO,MAAMC,eAAeX,WAAWL,IAAI;GAC7C,CAAC;EAEL;CACF;CAEA,MAAaI,SAAS,CACpB;AAEJ;AAEA,MAAMa,iBAAiBC,UAA8B;CACnD,MAAME,aACJC,WAKAC;CACF,IAAIF,YACF,OAAOA,WAAWG,KAAKL,KAAK,CAAC,CAACM,SAAS,QAAQ;CAEjD,IAAIE,SAAS;CACb,MAAMC,YAAY;CAClB,KAAK,IAAIC,IAAI,GAAGA,IAAIV,MAAMW,QAAQD,KAAKD,WACrCD,UAAUI,OAAOC,aAAa,GAAGb,MAAMc,SAASJ,GAAGA,IAAID,SAAS,CAAC;CAEnE,OAAOM,KAAKP,MAAM;AACpB;AAIA,MAAaV,iBAAiB,OAAOhB,SAAgC;CACnE,IAAI,OAAOkC,eAAe,aAAa;EACrC,MAAMC,SAAS,MAAMnC,KAAKoC,YAAY;EACtC,OAAO,QAAQpC,KAAKS,QAAQ,2BAA0B,UAAWQ,cAAc,IAAIE,WAAWgB,MAAM,CAAC;CACvG;CACA,OAAO,IAAIjC,SAAiBmC,SAASC,WAAW;E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D,MAAMJ,WAAWM,eAAe;EAClC,GACA0E,QAAQxF,MACV,GAEA,OAAOwF,QAAQjF,OAAOC,UAAU;EAGpC,MAAM,IAAI8E,MAAM,0CAA0C;CAC5D;AACF"}
@@ -1,5 +1,4 @@
1
1
  import { Unstable_DirectiveFormatter } from "../types/directive.js";
2
-
3
2
  //#region src/adapters/directive-formatter.d.ts
4
3
  /**
5
4
  * Default directive formatter using the `:type[label]{name=id}` syntax.
@@ -1 +1 @@
1
- {"version":3,"file":"directive-formatter.d.ts","names":[],"sources":["../../src/adapters/directive-formatter.ts"],"mappings":";;;;;AAcA;;;cAAa,kCAAA,EAAoC,2BAiChD"}
1
+ {"version":3,"file":"directive-formatter.d.ts","names":[],"sources":["../../src/adapters/directive-formatter.ts"],"mappings":";;;;;;;cAca,oCAAoC"}
@@ -1,5 +1,4 @@
1
1
  import { ThreadMessage } from "../types/message.js";
2
-
3
2
  //#region src/adapters/feedback.d.ts
4
3
  type FeedbackAdapterFeedback = {
5
4
  message: ThreadMessage;
@@ -1 +1 @@
1
- {"version":3,"file":"feedback.d.ts","names":[],"sources":["../../src/adapters/feedback.ts"],"mappings":";;;KAEK,uBAAA;EACH,OAAA,EAAS,aAAa;EACtB,IAAA;AAAA;AAAA,KAGU,eAAA;EACV,MAAA,GAAS,QAAA,EAAU,uBAAuB;AAAA"}
1
+ {"version":3,"file":"feedback.d.ts","names":[],"sources":["../../src/adapters/feedback.ts"],"mappings":";;KAEK;EACH,SAAS;EACT;;KAGU;EACV,SAAS,UAAU"}
@@ -3,7 +3,7 @@ import { unstable_defaultDirectiveFormatter } from "./directive-formatter.js";
3
3
  import { FeedbackAdapter } from "./feedback.js";
4
4
  import { DictationAdapter, SpeechSynthesisAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter } from "./speech.js";
5
5
  import { RealtimeVoiceAdapter, VoiceSessionControls, VoiceSessionHelpers, createVoiceSession } from "./voice.js";
6
- import { SuggestionAdapter } from "./suggestion.js";
6
+ import { CreateSuggestionAdapterOptions, SuggestionAdapter, SuggestionAdapterGenerateOptions, createSuggestionAdapter } from "./suggestion.js";
7
7
  import { Unstable_TriggerAdapter } from "./trigger.js";
8
8
  import { GenericThreadHistoryAdapter, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessageStorageEntry, ThreadHistoryAdapter } from "./thread-history.js";
9
- export { type AttachmentAdapter, CompositeAttachmentAdapter, type DictationAdapter, type FeedbackAdapter, type GenericThreadHistoryAdapter, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, type MessageStorageEntry, type RealtimeVoiceAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SpeechSynthesisAdapter, type SuggestionAdapter, type ThreadHistoryAdapter, type Unstable_TriggerAdapter, type VoiceSessionControls, type VoiceSessionHelpers, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, createVoiceSession, unstable_defaultDirectiveFormatter };
9
+ export { type AttachmentAdapter, CompositeAttachmentAdapter, type CreateSuggestionAdapterOptions, type DictationAdapter, type FeedbackAdapter, type GenericThreadHistoryAdapter, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, type MessageStorageEntry, type RealtimeVoiceAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SpeechSynthesisAdapter, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, type ThreadHistoryAdapter, type Unstable_TriggerAdapter, type VoiceSessionControls, type VoiceSessionHelpers, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, createSuggestionAdapter, createVoiceSession, unstable_defaultDirectiveFormatter };
@@ -1,5 +1,6 @@
1
1
  import { CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter } from "./attachment.js";
2
2
  import { WebSpeechDictationAdapter, WebSpeechSynthesisAdapter } from "./speech.js";
3
3
  import { createVoiceSession } from "./voice.js";
4
+ import { createSuggestionAdapter } from "./suggestion.js";
4
5
  import { unstable_defaultDirectiveFormatter } from "./directive-formatter.js";
5
- export { CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, createVoiceSession, unstable_defaultDirectiveFormatter };
6
+ export { CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, createSuggestionAdapter, createVoiceSession, unstable_defaultDirectiveFormatter };
@@ -1,5 +1,4 @@
1
1
  import { Unsubscribe } from "../types/unsubscribe.js";
2
-
3
2
  //#region src/adapters/speech.d.ts
4
3
  declare namespace SpeechSynthesisAdapter {
5
4
  type Status = {
@@ -1 +1 @@
1
- {"version":3,"file":"speech.d.ts","names":[],"sources":["../../src/adapters/speech.ts"],"mappings":";;;kBAEiB,sBAAA;EAAA,KACH,MAAA;IAEN,IAAA;EAAA;IAGA,IAAA;IACA,MAAA;IACA,KAAA;EAAA;EAAA,KAGM,SAAA;IACV,MAAA,EAAQ,MAAA;IACR,MAAA;IACA,SAAA,GAAY,QAAA,iBAAyB,WAAW;EAAA;AAAA;AAAA,KAIxC,sBAAA;EACV,KAAA,GAAQ,IAAA,aAAiB,sBAAA,CAAuB,SAAS;AAAA;AAAA,kBAG1C,gBAAA;EAAA,KACH,MAAA;IAEN,IAAA;EAAA;IAGA,IAAA;IACA,MAAA;EAAA;EAAA,KAGM,MAAA;IACV,UAAA;IACA,OAAA;EAAA;EAAA,KAGU,OAAA;IACV,MAAA,EAAQ,MAAA;IACR,IAAA,QAAY,OAAA;IACZ,MAAA;IACA,aAAA,GAAgB,QAAA,iBAAyB,WAAA;IACzC,WAAA,GAAc,QAAA,GAAW,MAAA,EAAQ,MAAA,cAAoB,WAAA;IACrD,QAAA,GAAW,QAAA,GAAW,MAAA,EAAQ,MAAA,cAAoB,WAAA;EAAA;AAAA;AAAA,KAI1C,gBAAA;EACV,MAAA,QAAc,gBAAA,CAAiB,OAAO;EACtC,2BAAA;AAAA;AAAA,cAGW,yBAAA,YAAqC,sBAAsB;EACtE,KAAA,CAAM,IAAA,WAAe,sBAAA,CAAuB,SAAA;AAAA;AAAA,UA0EpC,yBAAA,SAAkC,WAAW;EACrD,IAAA;EACA,UAAA;EACA,cAAA;EACA,KAAA;EACA,IAAA;EACA,KAAA;AAAA;AAAA,UAGQ,4BAAA;EAAA,QACA,yBAAyB;AAAA;AAAA,QAG3B,MAAA;EAAA,UACI,MAAA;IACR,iBAAA,GAAoB,4BAAA;IACpB,uBAAA,GAA0B,4BAA4B;EAAA;AAAA;AAAA,cAW7C,yBAAA,YAAqC,gBAAgB;EAAA,QACxD,SAAA;EAAA,QACA,WAAA;EAAA,QACA,eAAA;cAGN,OAAA;IACE,QAAA;IACA,UAAA;IACA,cAAA;EAAA;EAAA,OAYG,WAAA;EAIP,MAAA,IAAU,gBAAA,CAAiB,OAAA;AAAA"}
1
+ {"version":3,"file":"speech.d.ts","names":[],"sources":["../../src/adapters/speech.ts"],"mappings":";;kBAEiB;OACH;IAEN;;IAGA;IACA;IACA;;OAGM;IACV,QAAQ;IACR;IACA,YAAY,yBAAyB;;;KAI7B;EACV,QAAQ,iBAAiB,uBAAuB;;kBAGjC;OACH;IAEN;;IAGA;IACA;;OAGM;IACV;IACA;;OAGU;IACV,QAAQ;IACR,YAAY;IACZ;IACA,gBAAgB,yBAAyB;IACzC,cAAc,WAAW,QAAQ,oBAAoB;IACrD,WAAW,WAAW,QAAQ,oBAAoB;;;KAI1C;EACV,cAAc,iBAAiB;EAC/B;;cAGW,qCAAqC;EAChD,MAAM,eAAe,uBAAuB;;UA0EpC,kCAAkC;EAC1C;EACA;EACA;EACA;EACA;EACA;;UAGQ;UACA;;QAGF;YACI;IACR,oBAAoB;IACpB,0BAA0B;;;cAWjB,qCAAqC;UACxC;UACA;UACA;cAGN;IACE;IACA;IACA;;SAYG;EAIP,UAAU,iBAAiB"}
@@ -1,13 +1,27 @@
1
1
  import { ThreadMessage } from "../types/message.js";
2
2
  import { ThreadSuggestion } from "../runtime/interfaces/thread-runtime-core.js";
3
-
4
3
  //#region src/adapters/suggestion.d.ts
5
4
  type SuggestionAdapterGenerateOptions = {
6
5
  messages: readonly ThreadMessage[];
6
+ signal?: AbortSignal;
7
7
  };
8
8
  type SuggestionAdapter = {
9
9
  generate: (options: SuggestionAdapterGenerateOptions) => Promise<readonly ThreadSuggestion[]> | AsyncGenerator<readonly ThreadSuggestion[], void>;
10
10
  };
11
+ declare const consumeSuggestionResult: (result: ReturnType<SuggestionAdapter["generate"]>, options: {
12
+ signal: AbortSignal;
13
+ onUpdate: (suggestions: readonly ThreadSuggestion[]) => void;
14
+ }) => Promise<void>;
15
+ type CreateSuggestionAdapterOptions = {
16
+ complete: (options: {
17
+ prompt: string;
18
+ signal?: AbortSignal;
19
+ }) => Promise<readonly string[]>;
20
+ count?: number | undefined;
21
+ instructions?: string | undefined;
22
+ maxMessages?: number | undefined;
23
+ };
24
+ declare const createSuggestionAdapter: (options: CreateSuggestionAdapterOptions) => SuggestionAdapter;
11
25
  //#endregion
12
- export { SuggestionAdapter };
26
+ export { CreateSuggestionAdapterOptions, SuggestionAdapter, SuggestionAdapterGenerateOptions, consumeSuggestionResult, createSuggestionAdapter };
13
27
  //# sourceMappingURL=suggestion.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"suggestion.d.ts","names":[],"sources":["../../src/adapters/suggestion.ts"],"mappings":";;;;KAGK,gCAAA;EACH,QAAA,WAAmB,aAAa;AAAA;AAAA,KAGtB,iBAAA;EACV,QAAA,GACE,OAAA,EAAS,gCAAA,KAEP,OAAA,UAAiB,gBAAA,MACjB,cAAA,UAAwB,gBAAA;AAAA"}
1
+ {"version":3,"file":"suggestion.d.ts","names":[],"sources":["../../src/adapters/suggestion.ts"],"mappings":";;;KAIY;EACV,mBAAmB;EACnB,SAAS;;KAGC;EACV,WACE,SAAS,qCAEP,iBAAiB,sBACjB,wBAAwB;;cAGjB,0BACX,QAAQ,WAAW,gCACnB;EACE,QAAQ;EACR,WAAW,sBAAsB;MAElC;KAcS;EACV,WAAW;IACT;IACA,SAAS;QACL;EACN;EACA;EACA;;cAGW,0BACX,SAAS,mCACR"}
@@ -0,0 +1,36 @@
1
+ import { getThreadMessageText } from "../utils/text.js";
2
+ //#region src/adapters/suggestion.ts
3
+ const consumeSuggestionResult = async (result, options) => {
4
+ const { signal, onUpdate } = options;
5
+ if (Symbol.asyncIterator in result) for await (const r of result) {
6
+ if (signal.aborted) break;
7
+ onUpdate(r);
8
+ }
9
+ else {
10
+ const suggestions = await result;
11
+ if (signal.aborted) return;
12
+ onUpdate(suggestions);
13
+ }
14
+ };
15
+ const createSuggestionAdapter = (options) => {
16
+ const count = options.count ?? 3;
17
+ const maxMessages = options.maxMessages ?? 10;
18
+ return { async generate({ messages, signal }) {
19
+ const limit = Math.max(0, Math.floor(maxMessages));
20
+ const transcript = (limit === 0 ? [] : messages.slice(-limit)).map((message) => {
21
+ const text = getThreadMessageText(message).trim();
22
+ if (!text) return null;
23
+ return `${message.role}: ${text}`;
24
+ }).filter((line) => line != null).join("\n");
25
+ let prompt = `Based on the following conversation, suggest exactly ${count} short follow-up prompts that the USER would plausibly send next. Write each prompt in the user's voice as something they would type. Return only the prompts, one per line, with no numbering or extra commentary.\n\nConversation:\n${transcript}`;
26
+ if (options.instructions) prompt += `\n\nAdditional instructions:\n${options.instructions}`;
27
+ return (await options.complete({
28
+ prompt,
29
+ ...signal !== void 0 && { signal }
30
+ })).map((s) => s.trim()).filter((s) => s.length > 0).slice(0, count).map((text) => ({ prompt: text }));
31
+ } };
32
+ };
33
+ //#endregion
34
+ export { consumeSuggestionResult, createSuggestionAdapter };
35
+
36
+ //# sourceMappingURL=suggestion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"suggestion.js","names":["ThreadMessage","ThreadSuggestion","getThreadMessageText","SuggestionAdapterGenerateOptions","messages","signal","AbortSignal","SuggestionAdapter","generate","options","Promise","AsyncGenerator","consumeSuggestionResult","result","ReturnType","onUpdate","suggestions","Symbol","asyncIterator","r","aborted","CreateSuggestionAdapterOptions","complete","prompt","count","instructions","maxMessages","createSuggestionAdapter","limit","Math","max","floor","recent","slice","transcript","map","message","text","trim","role","filter","line","join","results","undefined","s","length"],"sources":["../../src/adapters/suggestion.ts"],"sourcesContent":["import type { ThreadMessage } from \"../types/message\";\nimport type { ThreadSuggestion } from \"../runtime/interfaces/thread-runtime-core\";\nimport { getThreadMessageText } from \"../utils/text\";\n\nexport type SuggestionAdapterGenerateOptions = {\n messages: readonly ThreadMessage[];\n signal?: AbortSignal;\n};\n\nexport type SuggestionAdapter = {\n generate: (\n options: SuggestionAdapterGenerateOptions,\n ) =>\n | Promise<readonly ThreadSuggestion[]>\n | AsyncGenerator<readonly ThreadSuggestion[], void>;\n};\n\nexport const consumeSuggestionResult = async (\n result: ReturnType<SuggestionAdapter[\"generate\"]>,\n options: {\n signal: AbortSignal;\n onUpdate: (suggestions: readonly ThreadSuggestion[]) => void;\n },\n): Promise<void> => {\n const { signal, onUpdate } = options;\n if (Symbol.asyncIterator in result) {\n for await (const r of result) {\n if (signal.aborted) break;\n onUpdate(r);\n }\n } else {\n const suggestions = await result;\n if (signal.aborted) return;\n onUpdate(suggestions);\n }\n};\n\nexport type CreateSuggestionAdapterOptions = {\n complete: (options: {\n prompt: string;\n signal?: AbortSignal;\n }) => Promise<readonly string[]>;\n count?: number | undefined;\n instructions?: string | undefined;\n maxMessages?: number | undefined;\n};\n\nexport const createSuggestionAdapter = (\n options: CreateSuggestionAdapterOptions,\n): SuggestionAdapter => {\n const count = options.count ?? 3;\n const maxMessages = options.maxMessages ?? 10;\n\n return {\n async generate({ messages, signal }) {\n const limit = Math.max(0, Math.floor(maxMessages));\n const recent = limit === 0 ? [] : messages.slice(-limit);\n const transcript = recent\n .map((message) => {\n const text = getThreadMessageText(message).trim();\n if (!text) return null;\n return `${message.role}: ${text}`;\n })\n .filter((line): line is string => line != null)\n .join(\"\\n\");\n\n let prompt =\n `Based on the following conversation, suggest exactly ${count} short follow-up prompts that the USER would plausibly send next. ` +\n `Write each prompt in the user's voice as something they would type. ` +\n `Return only the prompts, one per line, with no numbering or extra commentary.\\n\\n` +\n `Conversation:\\n${transcript}`;\n\n if (options.instructions) {\n prompt += `\\n\\nAdditional instructions:\\n${options.instructions}`;\n }\n\n const results = await options.complete({\n prompt,\n ...(signal !== undefined && { signal }),\n });\n return results\n .map((s) => s.trim())\n .filter((s) => s.length > 0)\n .slice(0, count)\n .map((text) => ({ prompt: text }));\n },\n };\n};\n"],"mappings":";;AAiBA,MAAaY,0BAA0B,OACrCC,QACAJ,YAIkB;CAClB,MAAM,EAAEJ,QAAQU,aAAaN;CAC7B,IAAIQ,OAAOC,iBAAiBL,QAC1B,WAAW,MAAMM,KAAKN,QAAQ;EAC5B,IAAIR,OAAOe,SAAS;EACpBL,SAASI,CAAC;CACZ;MACK;EACL,MAAMH,cAAc,MAAMH;EAC1B,IAAIR,OAAOe,SAAS;EACpBL,SAASC,WAAW;CACtB;AACF;AAYA,MAAaW,2BACXlB,YACsB;CACtB,MAAMe,QAAQf,QAAQe,SAAS;CAC/B,MAAME,cAAcjB,QAAQiB,eAAe;CAE3C,OAAO,EACL,MAAMlB,SAAS,EAAEJ,UAAUC,UAAU;EACnC,MAAMuB,QAAQC,KAAKC,IAAI,GAAGD,KAAKE,MAAML,WAAW,CAAC;EAEjD,MAAMQ,cADSN,UAAU,IAAI,CAAA,IAAKxB,SAAS6B,MAAM,CAACL,KAAK,EAAA,CAEpDO,KAAKC,YAAY;GAChB,MAAMC,OAAOnC,qBAAqBkC,OAAO,CAAC,CAACE,KAAK;GAChD,IAAI,CAACD,MAAM,OAAO;GAClB,OAAO,GAAGD,QAAQG,KAAI,IAAKF;EAC7B,CAAC,CAAC,CACDG,QAAQC,SAAyBA,QAAQ,IAAI,CAAC,CAC9CC,KAAK,IAAI;EAEZ,IAAInB,SACF,wDAAwDC,MAAK,wOAG3CU;EAEpB,IAAIzB,QAAQgB,cACVF,UAAU,iCAAiCd,QAAQgB;EAOrD,QAAOkB,MAJelC,QAAQa,SAAS;GACrCC;GACA,GAAIlB,WAAWuC,KAAAA,KAAa,EAAEvC,OAAO;EACvC,CAAC,EAAA,CAEE8B,KAAKU,MAAMA,EAAEP,KAAK,CAAC,CAAC,CACpBE,QAAQK,MAAMA,EAAEC,SAAS,CAAC,CAAC,CAC3Bb,MAAM,GAAGT,KAAK,CAAC,CACfW,KAAKE,UAAU,EAAEd,QAAQc,KAAK,EAAE;CACrC,EACF;AACF"}
@@ -1,7 +1,6 @@
1
1
  import { ChatModelRunOptions, ChatModelRunResult } from "../runtime/utils/chat-model-adapter.js";
2
2
  import { ExportedMessageRepository, ExportedMessageRepositoryItem } from "../runtime/utils/message-repository.js";
3
3
  import { ReadonlyJSONValue } from "assistant-stream/utils";
4
-
5
4
  //#region src/adapters/thread-history.d.ts
6
5
  interface MessageStorageEntry<TPayload> {
7
6
  id: string;
@@ -43,7 +42,8 @@ type ThreadHistoryAdapter = {
43
42
  }>;
44
43
  resume?(options: ChatModelRunOptions): AsyncGenerator<ChatModelRunResult, void, unknown>;
45
44
  append(item: ExportedMessageRepositoryItem): Promise<void>;
46
- delete?(items: ExportedMessageRepositoryItem[]): Promise<void>; /** Required when used with `useAISDKRuntime` / `useChatRuntime`. */
45
+ delete?(items: ExportedMessageRepositoryItem[]): Promise<void>;
46
+ /** Required when used with `useAISDKRuntime` / `useChatRuntime`. */
47
47
  withFormat?<TMessage, TStorageFormat extends Record<string, unknown>>(formatAdapter: MessageFormatAdapter<TMessage, TStorageFormat>): GenericThreadHistoryAdapter<TMessage>;
48
48
  };
49
49
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"thread-history.d.ts","names":[],"sources":["../../src/adapters/thread-history.ts"],"mappings":";;;;;UAUiB,mBAAA;EACf,EAAA;EACA,SAAA;EACA,MAAA;EACA,OAAA,EAAS,QAAQ;AAAA;AAAA,UAGF,iBAAA;EACf,QAAA;EACA,OAAA,EAAS,QAAQ;AAAA;AAAA,UAGF,uBAAA;E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ACvC;EACA,UAAU,kBAAkB;;UAGb,qBACf,UACA,uBAAuB;EAEvB;EACA,OAAO,MAAM,kBAAkB,YAAY;EAC3C,OACE,QAAQ,oBAAoB,kBAC3B,kBAAkB;EACrB,MAAM,SAAS;;KAGL,4BAA4B;EACtC,QAAQ,QAAQ,wBAAwB;EACxC,OAAO,MAAM,kBAAkB,YAAY;EAC3C,QACE,MAAM,kBAAkB,WACxB,yBACC;EACH,QAAQ,OAAO,kBAAkB,cAAc;EAC/C,iBACE,OAAO,kBAAkB,aACzB;IACE;IACA;MAAmB;MAAkB;;;;KAK/B;EACV,QAAQ,QACN;IACE,QAAQ;IACR;;EAGJ,QACE,SAAS,sBACR,eAAe;EAClB,OAAO,MAAM,gCAAgC;EAC7C,QAAQ,OAAO,kCAAkC;;EAEjD,YAAY,UAAU,uBAAuB,yBAC3C,eAAe,qBAAqB,UAAU,kBAC7C,4BAA4B"}
@@ -1,10 +1,12 @@
1
1
  import { Unstable_TriggerCategory, Unstable_TriggerItem } from "../types/trigger.js";
2
-
3
2
  //#region src/adapters/trigger.d.ts
4
3
  /** Adapter providing synchronous categories and items to a trigger popover. */
5
4
  type Unstable_TriggerAdapter = {
6
- /** Return the top-level categories for the trigger popover. */categories(): readonly Unstable_TriggerCategory[]; /** Return items within a category. */
7
- categoryItems(categoryId: string): readonly Unstable_TriggerItem[]; /** Global search across all categories (optional). */
5
+ /** Return the top-level categories for the trigger popover. */
6
+ categories(): readonly Unstable_TriggerCategory[];
7
+ /** Return items within a category. */
8
+ categoryItems(categoryId: string): readonly Unstable_TriggerItem[];
9
+ /** Global search across all categories (optional). */
8
10
  search?(query: string): readonly Unstable_TriggerItem[];
9
11
  };
10
12
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"trigger.d.ts","names":[],"sources":["../../src/adapters/trigger.ts"],"mappings":";;;;KAMY,uBAAA;EAAA,+DAEV,UAAA,aAAuB,wBAAA;EAGvB,aAAA,CAAc,UAAA,oBAA8B,oBAAA,IAAA;EAG5C,MAAA,EAAQ,KAAA,oBAAyB,oBAAA;AAAA"}
1
+ {"version":3,"file":"trigger.d.ts","names":[],"sources":["../../src/adapters/trigger.ts"],"mappings":";;;KAMY;;EAEV,uBAAuB;;EAGvB,cAAc,8BAA8B;;EAG5C,QAAQ,yBAAyB"}
@@ -1,5 +1,4 @@
1
1
  import { Unsubscribe } from "../types/unsubscribe.js";
2
-
3
2
  //#region src/adapters/voice.d.ts
4
3
  declare namespace RealtimeVoiceAdapter {
5
4
  type Status = {
@@ -1 +1 @@
1
- {"version":3,"file":"voice.d.ts","names":[],"sources":["../../src/adapters/voice.ts"],"mappings":";;;kBAEiB,oBAAA;EAAA,KACH,MAAA;IAEN,IAAA;EAAA;IAGA,IAAA;IACA,MAAA;IACA,KAAA;EAAA;EAAA,KAGM,IAAA;EAAA,KAEA,cAAA;IACV,IAAA;IACA,IAAA;IACA,OAAA;EAAA;EAAA,KAGU,OAAA;IACV,MAAA,EAAQ,MAAA;IACR,OAAA;IAEA,UAAA;IACA,IAAA;IACA,MAAA;IAEA,cAAA,GAAiB,QAAA,GAAW,MAAA,EAAQ,MAAA,cAAoB,WAAA;IACxD,YAAA,GACE,QAAA,GAAW,UAAA,EAAY,cAAA,cACpB,WAAA;IACL,YAAA,GAAe,QAAA,GAAW,IAAA,EAAM,IAAA,cAAkB,WAAA;IAClD,cAAA,GAAiB,QAAA,GAAW,MAAA,sBAA4B,WAAA;EAAA;AAAA;AAAA,KAIhD,oBAAA;EACV,OAAA,GAAU,OAAA;IACR,WAAA,GAAc,WAAA;EAAA,MACV,oBAAA,CAAqB,OAAO;AAAA;AAAA,KAGxB,oBAAA;EACV,UAAA;EACA,IAAA;EACA,MAAA;AAAA;AAAA,KAGU,mBAAA;EACV,SAAA,GAAY,MAAA,EAAQ,oBAAA,CAAqB,MAAA;EACzC,GAAA,GAAM,MAAA,sCAA4C,KAAA;EAClD,cAAA,GAAiB,IAAA,EAAM,oBAAA,CAAqB,cAAA;EAC5C,QAAA,GAAW,IAAA,EAAM,oBAAA,CAAqB,IAAA;EACtC,UAAA,GAAa,MAAA;EACb,UAAA;AAAA;AAAA,iBAGc,kBAAA,CACd,OAAA;EAAW,WAAA,GAAc,WAAA;AAAA,GACzB,KAAA,GAAQ,OAAA,EAAS,mBAAA,KAAwB,OAAA,CAAQ,oBAAA,IAChD,oBAAA,CAAqB,OAAA"}
1
+ {"version":3,"file":"voice.d.ts","names":[],"sources":["../../src/adapters/voice.ts"],"mappings":";;kBAEiB;OACH;IAEN;;IAGA;IACA;IACA;;OAGM;OAEA;IACV;IACA;IACA;;OAGU;IACV,QAAQ;IACR;IAEA;IACA;IACA;IAEA,iBAAiB,WAAW,QAAQ,oBAAoB;IACxD,eACE,WAAW,YAAY,4BACpB;IACL,eAAe,WAAW,MAAM,kBAAkB;IAClD,iBAAiB,WAAW,4BAA4B;;;KAIhD;EACV,UAAU;IACR,cAAc;QACV,qBAAqB;;KAGjB;EACV;EACA;EACA;;KAGU;EACV,YAAY,QAAQ,qBAAqB;EACzC,MAAM,4CAA4C;EAClD,iBAAiB,MAAM,qBAAqB;EAC5C,WAAW,MAAM,qBAAqB;EACtC,aAAa;EACb;;iBAGc,mBACd;EAAW,cAAc;GACzB,QAAQ,SAAS,wBAAwB,QAAQ,wBAChD,qBAAqB"}
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./store/scope-registration.d.ts" />
2
- import { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MCP_APP_URI_SCHEME, McpAppMetadata, MessagePartStatus, MessageRole, MessageStatus, MessageTiming, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartMcpMetadata, ToolCallMessagePartStatus, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, isMcpAppUri } from "./types/message.js";
2
+ import { AppendMessage, DataMessagePart, FileMessagePart, GenerativeUIMessagePart, GenerativeUINode, GenerativeUISpec, ImageMessagePart, MCP_APP_URI_SCHEME, McpAppMetadata, MessagePartStatus, MessageRole, MessageStatus, MessageTiming, PartProviderMetadata, ReasoningMessagePart, RunConfig, SourceMessagePart, SourceProviderMetadata, TextMessagePart, ThreadAssistantMessage, ThreadAssistantMessagePart, ThreadMessage, ThreadStep, ThreadSystemMessage, ThreadUserMessage, ThreadUserMessagePart, ToolApprovalOption, ToolApprovalOptionKind, ToolApprovalResponse, ToolCallMessagePart, ToolCallMessagePartMcpMetadata, ToolCallMessagePartStatus, ToolCallTiming, ToolModelContentPart, Unstable_AudioMessagePart, isMcpAppUri } from "./types/message.js";
3
3
  import { Attachment, AttachmentStatus, CompleteAttachment, CompleteAttachmentStatus, CreateAttachment, PendingAttachment, PendingAttachmentStatus } from "./types/attachment.js";
4
4
  import { AttachmentAdapter, CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter } from "./adapters/attachment.js";
5
5
  import { Unstable_TriggerCategory, Unstable_TriggerItem } from "./types/trigger.js";
@@ -16,7 +16,7 @@ import { ExportedMessageRepository, ExportedMessageRepositoryItem } from "./runt
16
16
  import { QuoteInfo } from "./types/quote.js";
17
17
  import { AttachmentAddErrorEvent, AttachmentAddErrorReason, ComposerRuntimeCore, ComposerRuntimeEventCallback, ComposerRuntimeEventPayload, ComposerRuntimeEventType, DictationState, EditComposerRuntimeCore, SendOptions, ThreadComposerRuntimeCore } from "./runtime/interfaces/composer-runtime-core.js";
18
18
  import { AddToolResultOptions, RespondToToolApprovalOptions, ResumeRunConfig, ResumeToolCallOptions, RuntimeCapabilities, SpeechState, StartRunConfig, SubmitFeedbackOptions, SubmittedFeedback, ThreadRuntimeCore, ThreadRuntimeEventCallback, ThreadRuntimeEventPayload, ThreadRuntimeEventType, ThreadSuggestion, VoiceSessionState } from "./runtime/interfaces/thread-runtime-core.js";
19
- import { SuggestionAdapter } from "./adapters/suggestion.js";
19
+ import { CreateSuggestionAdapterOptions, SuggestionAdapter, SuggestionAdapterGenerateOptions, createSuggestionAdapter } from "./adapters/suggestion.js";
20
20
  import { Unstable_TriggerAdapter } from "./adapters/trigger.js";
21
21
  import { GenericThreadHistoryAdapter, MessageFormatAdapter, MessageFormatItem, MessageFormatRepository, MessageStorageEntry, ThreadHistoryAdapter } from "./adapters/thread-history.js";
22
22
  import { tool } from "./model-context/tool.js";
@@ -28,6 +28,7 @@ import { AssistantFrameHost } from "./model-context/frame/host.js";
28
28
  import { AssistantFrameProvider } from "./model-context/frame/provider.js";
29
29
  import { FRAME_MESSAGE_CHANNEL, FrameMessage, FrameMessageType, SerializedModelContext, SerializedTool } from "./model-context/frame/types.js";
30
30
  import { AttachmentRuntimePath, ComposerRuntimePath, MessagePartRuntimePath, MessageRuntimePath, ThreadListItemRuntimePath, ThreadRuntimePath } from "./runtime/api/paths.js";
31
+ import { AssistantError, AssistantErrorCode, ErrorDisplay, ErrorSeverity, isAssistantError, toAssistantError } from "./types/error.js";
31
32
  import { ThreadListItemCoreState, ThreadListItemStatus, ThreadListRuntimeCore } from "./runtime/interfaces/thread-list-runtime-core.js";
32
33
  import { AssistantRuntimeCore } from "./runtime/interfaces/assistant-runtime-core.js";
33
34
  import { generateId } from "./utils/id.js";
@@ -51,4 +52,4 @@ import { ExternalThreadBranchAdapter } from "./runtime/branch/external-thread-br
51
52
  import { MessageQueueController, MessageQueueDriver, createMessageQueue } from "./runtime/queue/message-queue.js";
52
53
  import { InMemoryThreadListAdapter } from "./runtimes/remote-thread-list/adapter/in-memory.js";
53
54
  import { createRequestHeaders } from "./runtimes/assistant-transport/utils.js";
54
- export { type AddToolResultOptions, type AppendMessage, type AssistantContextConfig, AssistantFrameHost, AssistantFrameProvider, type AssistantInstructionsConfig, type AssistantRuntime, type AssistantRuntimeCore, type AssistantToolProps, type Attachment, type AttachmentAdapter, type AttachmentAddErrorEvent, type AttachmentAddErrorReason, type AttachmentRuntime, type AttachmentRuntimePath, type AttachmentState, type AttachmentStatus, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, type CompleteAttachment, type CompleteAttachmentStatus, type ComposerRuntime, type ComposerRuntimeCore, type ComposerRuntimeEventCallback, type ComposerRuntimeEventPayload, type ComposerRuntimeEventType, type ComposerRuntimePath, type ComposerState, CompositeAttachmentAdapter, type CoreChatModelRunResult, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type DataMessagePart, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerRuntimeCore, type EditComposerState, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, type ExternalThreadBranchAdapter, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FrameMessage, type FrameMessageType, type GenerativeUIMessagePart, type GenerativeUINode, type GenerativeUISpec, type GenericThreadHistoryAdapter, type ImageMessagePart, InMemoryThreadListAdapter, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptionsBase, MCP_APP_URI_SCHEME, type McpAppMetadata, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, type MessagePartRuntime, type MessagePartRuntimePath, type MessagePartState, type MessagePartStatus, type MessageQueueController, type MessageQueueDriver, type MessageRole, type MessageRuntime, type MessageRuntimePath, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, type PendingAttachment, type PendingAttachmentStatus, type QuoteInfo, type RealtimeVoiceAdapter, type ReasoningMessagePart, type RemoteThreadInitializeResponse, type RemoteThreadListAdapter, type RemoteThreadListOptions, type RemoteThreadListPageOptions, type RemoteThreadListResponse, type RemoteThreadMetadata, type RespondToToolApprovalOptions, type ResumeRunConfig, type ResumeToolCallOptions, type RunConfig, type RuntimeCapabilities, type SendOptions, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SourceMessagePart, type SourceProviderMetadata, type SpeechState, type SpeechSynthesisAdapter, type StartRunConfig, type StreamingTimingAccessors, type StreamingTimingOptions, type StreamingTimingState, type SubmitFeedbackOptions, type SubmittedFeedback, type SuggestionAdapter, type TextMessagePart, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerRuntimeCore, type ThreadComposerState, type ThreadHistoryAdapter, type ThreadListItemCoreState, type ThreadListItemEventCallback, type ThreadListItemEventPayload, type ThreadListItemEventType, type ThreadListItemRuntime, type ThreadListItemRuntimePath, type ThreadListItemState, type ThreadListItemStatus, type ThreadListRuntime, type ThreadListRuntimeCore, type ThreadListState, type ThreadMessage, type ThreadMessageLike, type ThreadRuntime, type ThreadRuntimeCore, type ThreadRuntimeEventCallback, type ThreadRuntimeEventPayload, type ThreadRuntimeEventType, type ThreadRuntimePath, type ThreadState, type ThreadStep, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolCallMessagePart, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartStatus, type ToolCallTiming, type ToolExecutionStatus, type ToolModelContentPart, type Unstable_AudioMessagePart, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableVersion, type Unstable_TriggerAdapter, type Unstable_TriggerCategory, type Unstable_TriggerItem, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createRequestHeaders, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMcpAppUri, mergeModelContexts, pickExternalStoreSharedOptions, stepStreamingTiming, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions };
55
+ export { type AddToolResultOptions, type AppendMessage, type AssistantContextConfig, type AssistantError, type AssistantErrorCode, AssistantFrameHost, AssistantFrameProvider, type AssistantInstructionsConfig, type AssistantRuntime, type AssistantRuntimeCore, type AssistantToolProps, type Attachment, type AttachmentAdapter, type AttachmentAddErrorEvent, type AttachmentAddErrorReason, type AttachmentRuntime, type AttachmentRuntimePath, type AttachmentState, type AttachmentStatus, type ChatModelAdapter, type ChatModelRunOptions, type ChatModelRunResult, type ChatModelRunUpdate, type CompleteAttachment, type CompleteAttachmentStatus, type ComposerRuntime, type ComposerRuntimeCore, type ComposerRuntimeEventCallback, type ComposerRuntimeEventPayload, type ComposerRuntimeEventType, type ComposerRuntimePath, type ComposerState, CompositeAttachmentAdapter, type CoreChatModelRunResult, type CreateAppendMessage, type CreateAttachment, type CreateResumeRunConfig, type CreateStartRunConfig, type CreateSuggestionAdapterOptions, type DataMessagePart, type DictationAdapter, type DictationState, type EditComposerRuntime, type EditComposerRuntimeCore, type EditComposerState, type ErrorDisplay, type ErrorSeverity, ExportedMessageRepository, type ExportedMessageRepositoryItem, type ExternalStoreAdapter, type ExternalStoreBranchChange, type ExternalStoreMessageConverter, type ExternalStoreSharedOptions, type ExternalStoreThreadData, type ExternalStoreThreadListAdapter, type ExternalThreadBranchAdapter, type ExternalThreadQueueAdapter, FRAME_MESSAGE_CHANNEL, type FeedbackAdapter, type FileMessagePart, type FrameMessage, type FrameMessageType, type GenerativeUIMessagePart, type GenerativeUINode, type GenerativeUISpec, type GenericThreadHistoryAdapter, type ImageMessagePart, InMemoryThreadListAdapter, type LanguageModelConfig, type LanguageModelV1CallSettings, type LocalRuntimeOptionsBase, MCP_APP_URI_SCHEME, type McpAppMetadata, type MessageFormatAdapter, type MessageFormatItem, type MessageFormatRepository, type MessagePartRuntime, type MessagePartRuntimePath, type MessagePartState, type MessagePartStatus, type MessageQueueController, type MessageQueueDriver, type MessageRole, type MessageRuntime, type MessageRuntimePath, type MessageState, type MessageStatus, type MessageStorageEntry, type MessageTiming, type ModelContext, type ModelContextProvider, ModelContextRegistry, type ModelContextRegistryInstructionHandle, type ModelContextRegistryProviderHandle, type ModelContextRegistryToolHandle, type PartProviderMetadata, type PendingAttachment, type PendingAttachmentStatus, type QuoteInfo, type RealtimeVoiceAdapter, type ReasoningMessagePart, type RemoteThreadInitializeResponse, type RemoteThreadListAdapter, type RemoteThreadListOptions, type RemoteThreadListPageOptions, type RemoteThreadListResponse, type RemoteThreadMetadata, type RespondToToolApprovalOptions, type ResumeRunConfig, type ResumeToolCallOptions, type RunConfig, type RuntimeCapabilities, type SendOptions, type SerializedModelContext, type SerializedTool, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, type SourceMessagePart, type SourceProviderMetadata, type SpeechState, type SpeechSynthesisAdapter, type StartRunConfig, type StreamingTimingAccessors, type StreamingTimingOptions, type StreamingTimingState, type SubmitFeedbackOptions, type SubmittedFeedback, type SuggestionAdapter, type SuggestionAdapterGenerateOptions, type TextMessagePart, type ThreadAssistantMessage, type ThreadAssistantMessagePart, type ThreadComposerRuntime, type ThreadComposerRuntimeCore, type ThreadComposerState, type ThreadHistoryAdapter, type ThreadListItemCoreState, type ThreadListItemEventCallback, type ThreadListItemEventPayload, type ThreadListItemEventType, type ThreadListItemRuntime, type ThreadListItemRuntimePath, type ThreadListItemState, type ThreadListItemStatus, type ThreadListRuntime, type ThreadListRuntimeCore, type ThreadListState, type ThreadMessage, type ThreadMessageLike, type ThreadRuntime, type ThreadRuntimeCore, type ThreadRuntimeEventCallback, type ThreadRuntimeEventPayload, type ThreadRuntimeEventType, type ThreadRuntimePath, type ThreadState, type ThreadStep, type ThreadSuggestion, type ThreadSystemMessage, type ThreadUserMessage, type ThreadUserMessagePart, type ToolApprovalOption, type ToolApprovalOptionKind, type ToolApprovalResponse, type ToolCallMessagePart, type ToolCallMessagePartMcpMetadata, type ToolCallMessagePartStatus, type ToolCallTiming, type ToolExecutionStatus, type ToolModelContentPart, type Unstable_AudioMessagePart, type Unstable_DirectiveFormatter, type Unstable_DirectiveSegment, type Unstable_InteractableSnapshotEntry, type Unstable_InteractableVersion, type Unstable_TriggerAdapter, type Unstable_TriggerCategory, type Unstable_TriggerItem, type Unsubscribe, type VoiceSessionControls, type VoiceSessionHelpers, type VoiceSessionState, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createRequestHeaders, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isAssistantError, isMcpAppUri, mergeModelContexts, pickExternalStoreSharedOptions, stepStreamingTiming, toAssistantError, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions };
package/dist/index.js CHANGED
@@ -11,7 +11,9 @@ import { generateId } from "./utils/id.js";
11
11
  import { CompositeAttachmentAdapter, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter } from "./adapters/attachment.js";
12
12
  import { WebSpeechDictationAdapter, WebSpeechSynthesisAdapter } from "./adapters/speech.js";
13
13
  import { createVoiceSession } from "./adapters/voice.js";
14
+ import { createSuggestionAdapter } from "./adapters/suggestion.js";
14
15
  import { unstable_defaultDirectiveFormatter } from "./adapters/directive-formatter.js";
16
+ import { isAssistantError, toAssistantError } from "./types/error.js";
15
17
  import { fromThreadMessageLike } from "./runtime/utils/thread-message-like.js";
16
18
  import { stepStreamingTiming } from "./runtime/utils/streaming-timing.js";
17
19
  import { bindExternalStoreMessage, getExternalStoreMessages } from "./runtime/utils/external-store-message.js";
@@ -23,6 +25,6 @@ import { createRequestHeaders } from "./runtimes/assistant-transport/utils.js";
23
25
  //#region src/index.ts
24
26
  if (process.env.NODE_ENV !== "production") checkDuplicateCore();
25
27
  //#endregion
26
- export { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, MCP_APP_URI_SCHEME, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createRequestHeaders, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isMcpAppUri, mergeModelContexts, pickExternalStoreSharedOptions, stepStreamingTiming, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions };
28
+ export { AssistantFrameHost, AssistantFrameProvider, CompositeAttachmentAdapter, ExportedMessageRepository, FRAME_MESSAGE_CHANNEL, InMemoryThreadListAdapter, MCP_APP_URI_SCHEME, ModelContextRegistry, SimpleImageAttachmentAdapter, SimpleTextAttachmentAdapter, WebSpeechDictationAdapter, WebSpeechSynthesisAdapter, bindExternalStoreMessage, createMessageQueue, createRequestHeaders, createSuggestionAdapter, createVoiceSession, fromThreadMessageLike, generateId, getExternalStoreMessages, isAssistantError, isMcpAppUri, mergeModelContexts, pickExternalStoreSharedOptions, stepStreamingTiming, toAssistantError, tool, unstable_defaultDirectiveFormatter, unstable_formatInteractableSnapshot, unstable_getInteractableSnapshots, unstable_getInteractableVersions };
27
29
 
28
30
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["checkDuplicateCore","process","env","NODE_ENV","TextMessagePart","ReasoningMessagePart","SourceProviderMetadata","SourceMessagePart","ImageMessagePart","FileMessagePart","DataMessagePart","GenerativeUIMessagePart","GenerativeUINode","GenerativeUISpec","Unstable_AudioMessagePart","ToolApprovalOption","ToolApprovalOptionKind","ToolApprovalResponse","ToolCallMessagePart","ToolCallTiming","ToolCallMessagePartMcpMetadata","McpAppMetadata","ToolModelContentPart","ThreadUserMessagePart","ThreadAssistantMessagePart","MessagePartStatus","ToolCallMessagePartStatus","MessageStatus","MessageTiming","ThreadStep","ThreadSystemMessage","ThreadUserMessage","ThreadAssistantMessage","ThreadMessage","MessageRole","RunConfig","AppendMessage","MCP_APP_URI_SCHEME","isMcpAppUri","Attachment","PendingAttachment","PendingAttachmentStatus","CompleteAttachment","CompleteAttachmentStatus","AttachmentStatus","CreateAttachment","Unsubscribe","QuoteInfo","Unstable_DirectiveSegment","Unstable_DirectiveFormatter","Unstable_TriggerItem","Unstable_TriggerCategory","Unstable_TriggerAdapter","LanguageModelV1CallSettings","LanguageModelConfig","ModelContext","ModelContextProvider","AssistantToolProps","AssistantInstructionsConfig","AssistantContextConfig","mergeModelContexts","tool","unstable_getInteractableSnapshots","unstable_formatInteractableSnapshot","unstable_getInteractableVersions","Unstable_InteractableSnapshotEntry","Unstable_InteractableVersion","ToolExecutionStatus","ModelContextRegistry","ModelContextRegistryToolHandle","ModelContextRegistryInstructionHandle","ModelContextRegistryProviderHandle","AssistantFrameHost","AssistantFrameProvider","SerializedTool","SerializedModelContext","FrameMessageType","FrameMessage","FRAME_MESSAGE_CHANNEL","AttachmentAdapter","SimpleImageAttachmentAdapter","SimpleTextAttachmentAdapter","CompositeAttachmentAdapter","SpeechSynthesisAdapter","DictationAdapter","WebSpeechSynthesisAdapter","WebSpeechDictationAdapter","RealtimeVoiceAdapter","createVoiceSession","VoiceSessionControls","VoiceSessionHelpers","FeedbackAdapter","SuggestionAdapter","unstable_defaultDirectiveFormatter","ThreadHistoryAdapter","GenericThreadHistoryAdapter","MessageFormatAdapter","MessageFormatItem","MessageFormatRepository","MessageStorageEntry","ThreadListItemRuntimePath","ThreadRuntimePath","MessageRuntimePath","MessagePartRuntimePath","AttachmentRuntimePath","ComposerRuntimePath","AttachmentAddErrorEvent","AttachmentAddErrorReason","ComposerRuntimeCore","ComposerRuntimeEventCallback","ComposerRuntimeEventPayload","ComposerRuntimeEventType","DictationState","EditComposerRuntimeCore","SendOptions","ThreadComposerRuntimeCore","RuntimeCapabilities","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","SubmitFeedbackOptions","ThreadSuggestion","SpeechState","VoiceSessionState","SubmittedFeedback","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","ThreadRuntimeCore","ThreadListItemStatus","ThreadListItemCoreState","ThreadListRuntimeCore","AssistantRuntimeCore","AssistantRuntime","CreateStartRunConfig","CreateResumeRunConfig","CreateAppendMessage","ThreadState","ThreadRuntime","ThreadListState","ThreadListRuntime","ThreadListItemEventCallback","ThreadListItemEventPayload","ThreadListItemEventType","ThreadListItemRuntime","ThreadListItemState","MessageState","MessageRuntime","MessagePartState","MessagePartRuntime","ThreadComposerState","EditComposerState","ComposerState","ComposerRuntime","ThreadComposerRuntime","EditComposerRuntime","AttachmentState","AttachmentRuntime","ChatModelRunUpdate","ChatModelRunResult","CoreChatModelRunResult","ChatModelRunOptions","ChatModelAdapter","ThreadMessageLike","fromThreadMessageLike","StreamingTimingAccessors","StreamingTimingOptions","StreamingTimingState","stepStreamingTiming","generateId","getExternalStoreMessages","bindExternalStoreMessage","ExportedMessageRepositoryItem","ExportedMessageRepository","LocalRuntimeOptionsBase","ExternalStoreAdapter","ExternalStoreMessageConverter","ExternalStoreThreadListAdapter","ExternalStoreThreadData","ExternalStoreBranchChange","ExternalStoreSharedOptions","pickExternalStoreSharedOptions","ExternalThreadQueueAdapter","ExternalThreadBranchAdapter","createMessageQueue","MessageQueueDriver","MessageQueueController","RemoteThreadListAdapter","RemoteThreadListOptions","RemoteThreadInitializeResponse","RemoteThreadMetadata","RemoteThreadListResponse","RemoteThreadListPageOptions","InMemoryThreadListAdapter","createRequestHeaders"],"sources":["../src/index.ts"],"sourcesContent":["// @assistant-ui/core - Framework-agnostic core runtime (public API)\n\n/// <reference path=\"./store/scope-registration.ts\" />\n\nimport { checkDuplicateCore } from \"./internal/duplicate-detection\";\n\nif (process.env.NODE_ENV !== \"production\") {\n checkDuplicateCore();\n}\n\nexport type {\n // Message parts\n TextMessagePart,\n ReasoningMessagePart,\n SourceProviderMetadata,\n SourceMessagePart,\n ImageMessagePart,\n FileMessagePart,\n DataMessagePart,\n GenerativeUIMessagePart,\n GenerativeUINode,\n GenerativeUISpec,\n Unstable_AudioMessagePart,\n ToolApprovalOption,\n ToolApprovalOptionKind,\n ToolApprovalResponse,\n ToolCallMessagePart,\n ToolCallTiming,\n ToolCallMessagePartMcpMetadata,\n McpAppMetadata,\n ToolModelContentPart,\n ThreadUserMessagePart,\n ThreadAssistantMessagePart,\n // Message status\n MessagePartStatus,\n ToolCallMessagePartStatus,\n MessageStatus,\n // Thread messages\n MessageTiming,\n ThreadStep,\n ThreadSystemMessage,\n ThreadUserMessage,\n ThreadAssistantMessage,\n ThreadMessage,\n MessageRole,\n // Config\n RunConfig,\n AppendMessage,\n} from \"./types/message\";\n\nexport { MCP_APP_URI_SCHEME, isMcpAppUri } from \"./types/message\";\n\nexport type {\n Attachment,\n PendingAttachment,\n PendingAttachmentStatus,\n CompleteAttachment,\n CompleteAttachmentStatus,\n AttachmentStatus,\n CreateAttachment,\n} from \"./types/attachment\";\n\nexport type { Unsubscribe } from \"./types/unsubscribe\";\n\nexport type { QuoteInfo } from \"./types/quote\";\n\nexport type {\n Unstable_DirectiveSegment,\n Unstable_DirectiveFormatter,\n} from \"./types/directive\";\n\nexport type {\n Unstable_TriggerItem,\n Unstable_TriggerCategory,\n} from \"./types/trigger\";\n\nexport type { Unstable_TriggerAdapter } from \"./adapters/trigger\";\n\nexport type {\n // Language model settings\n LanguageModelV1CallSettings,\n LanguageModelConfig,\n // Model context\n ModelContext,\n ModelContextProvider,\n // Tool & instruction config\n AssistantToolProps,\n AssistantInstructionsConfig,\n AssistantContextConfig,\n} from \"./model-context/types\";\nexport { mergeModelContexts } from \"./model-context/types\";\n\nexport { tool } from \"./model-context/tool\";\n\nexport {\n unstable_getInteractableSnapshots,\n unstable_formatInteractableSnapshot,\n unstable_getInteractableVersions,\n type Unstable_InteractableSnapshotEntry,\n type Unstable_InteractableVersion,\n} from \"./model-context/interactable-composer-metadata\";\n\nexport type { ToolExecutionStatus } from \"./runtimes/tool-invocations/ToolInvocationTracker\";\n\nexport { ModelContextRegistry } from \"./model-context/registry\";\nexport type {\n ModelContextRegistryToolHandle,\n ModelContextRegistryInstructionHandle,\n ModelContextRegistryProviderHandle,\n} from \"./model-context/registry-handles\";\n\nexport { AssistantFrameHost } from \"./model-context/frame/host\";\nexport { AssistantFrameProvider } from \"./model-context/frame/provider\";\nexport type {\n SerializedTool,\n SerializedModelContext,\n FrameMessageType,\n FrameMessage,\n} from \"./model-context/frame/types\";\nexport { FRAME_MESSAGE_CHANNEL } from \"./model-context/frame/types\";\n\n// Attachment adapters\nexport type { AttachmentAdapter } from \"./adapters/attachment\";\nexport {\n SimpleImageAttachmentAdapter,\n SimpleTextAttachmentAdapter,\n CompositeAttachmentAdapter,\n} from \"./adapters/attachment\";\n\n// Speech adapters\nexport type {\n SpeechSynthesisAdapter,\n DictationAdapter,\n} from \"./adapters/speech\";\nexport {\n WebSpeechSynthesisAdapter,\n WebSpeechDictationAdapter,\n} from \"./adapters/speech\";\n\n// Voice adapter\nexport type { RealtimeVoiceAdapter } from \"./adapters/voice\";\nexport { createVoiceSession } from \"./adapters/voice\";\nexport type {\n VoiceSessionControls,\n VoiceSessionHelpers,\n} from \"./adapters/voice\";\n\n// Feedback adapter\nexport type { FeedbackAdapter } from \"./adapters/feedback\";\n\n// Suggestion adapter\nexport type { SuggestionAdapter } from \"./adapters/suggestion\";\n\n// Directive formatter\nexport { unstable_defaultDirectiveFormatter } from \"./adapters/directive-formatter\";\n\n// Thread history adapters\nexport type {\n ThreadHistoryAdapter,\n GenericThreadHistoryAdapter,\n MessageFormatAdapter,\n MessageFormatItem,\n MessageFormatRepository,\n MessageStorageEntry,\n} from \"./adapters/thread-history\";\n\n// Path Types\nexport type {\n ThreadListItemRuntimePath,\n ThreadRuntimePath,\n MessageRuntimePath,\n MessagePartRuntimePath,\n AttachmentRuntimePath,\n ComposerRuntimePath,\n} from \"./runtime/api/paths\";\n\n// Runtime Core Interface Types\nexport type {\n AttachmentAddErrorEvent,\n AttachmentAddErrorReason,\n ComposerRuntimeCore,\n ComposerRuntimeEventCallback,\n ComposerRuntimeEventPayload,\n ComposerRuntimeEventType,\n DictationState,\n EditComposerRuntimeCore,\n SendOptions,\n ThreadComposerRuntimeCore,\n} from \"./runtime/interfaces/composer-runtime-core\";\n\nexport type {\n RuntimeCapabilities,\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n SubmitFeedbackOptions,\n ThreadSuggestion,\n SpeechState,\n VoiceSessionState,\n SubmittedFeedback,\n ThreadRuntimeEventCallback,\n ThreadRuntimeEventPayload,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n ThreadRuntimeCore,\n} from \"./runtime/interfaces/thread-runtime-core\";\n\nexport type {\n ThreadListItemStatus,\n ThreadListItemCoreState,\n ThreadListRuntimeCore,\n} from \"./runtime/interfaces/thread-list-runtime-core\";\n\nexport type { AssistantRuntimeCore } from \"./runtime/interfaces/assistant-runtime-core\";\n\n// Public Runtime Types\nexport type { AssistantRuntime } from \"./runtime/api/assistant-runtime\";\n\nexport type {\n CreateStartRunConfig,\n CreateResumeRunConfig,\n CreateAppendMessage,\n ThreadState,\n ThreadRuntime,\n} from \"./runtime/api/thread-runtime\";\n\nexport type {\n ThreadListState,\n ThreadListRuntime,\n} from \"./runtime/api/thread-list-runtime\";\n\nexport type {\n ThreadListItemEventCallback,\n ThreadListItemEventPayload,\n ThreadListItemEventType,\n ThreadListItemRuntime,\n} from \"./runtime/api/thread-list-item-runtime\";\n\nexport type { ThreadListItemState } from \"./runtime/api/bindings\";\n\nexport type {\n MessageState,\n MessageRuntime,\n} from \"./runtime/api/message-runtime\";\nexport type {\n MessagePartState,\n MessagePartRuntime,\n} from \"./runtime/api/message-part-runtime\";\n\nexport type {\n ThreadComposerState,\n EditComposerState,\n ComposerState,\n ComposerRuntime,\n ThreadComposerRuntime,\n EditComposerRuntime,\n} from \"./runtime/api/composer-runtime\";\n\nexport type {\n AttachmentState,\n AttachmentRuntime,\n} from \"./runtime/api/attachment-runtime\";\n\n// ChatModel Types\nexport type {\n ChatModelRunUpdate,\n ChatModelRunResult,\n CoreChatModelRunResult,\n ChatModelRunOptions,\n ChatModelAdapter,\n} from \"./runtime/utils/chat-model-adapter\";\n\n// ThreadMessageLike\nexport type { ThreadMessageLike } from \"./runtime/utils/thread-message-like\";\nexport { fromThreadMessageLike } from \"./runtime/utils/thread-message-like\";\n\n// Streaming timing (client-side)\nexport type {\n StreamingTimingAccessors,\n StreamingTimingOptions,\n StreamingTimingState,\n} from \"./runtime/utils/streaming-timing\";\nexport { stepStreamingTiming } from \"./runtime/utils/streaming-timing\";\n\n// ID generation\nexport { generateId } from \"./utils/id\";\n\n// External Store Message Utilities\nexport {\n getExternalStoreMessages,\n bindExternalStoreMessage,\n} from \"./runtime/utils/external-store-message\";\n\n// ExportedMessageRepository\nexport type { ExportedMessageRepositoryItem } from \"./runtime/utils/message-repository\";\nexport { ExportedMessageRepository } from \"./runtime/utils/message-repository\";\n\n// Local Runtime Options\nexport type { LocalRuntimeOptionsBase } from \"./runtimes/local/local-runtime-options\";\n\n// External Store Adapter Types (user-facing)\nexport type {\n ExternalStoreAdapter,\n ExternalStoreMessageConverter,\n ExternalStoreThreadListAdapter,\n ExternalStoreThreadData,\n ExternalStoreBranchChange,\n} from \"./runtimes/external-store/external-store-adapter\";\nexport type { ExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\nexport { pickExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\n\n// Message queue\nexport type { ExternalThreadQueueAdapter } from \"./runtime/queue/external-thread-queue-adapter\";\nexport type { ExternalThreadBranchAdapter } from \"./runtime/branch/external-thread-branch-adapter\";\nexport {\n createMessageQueue,\n type MessageQueueDriver,\n type MessageQueueController,\n} from \"./runtime/queue/message-queue\";\n\n// Remote Thread List (user-facing)\nexport type {\n RemoteThreadListAdapter,\n RemoteThreadListOptions,\n RemoteThreadInitializeResponse,\n RemoteThreadMetadata,\n RemoteThreadListResponse,\n RemoteThreadListPageOptions,\n} from \"./runtimes/remote-thread-list/types\";\n\nexport { InMemoryThreadListAdapter } from \"./runtimes/remote-thread-list/adapter/in-memory\";\n\n// Assistant Transport Utilities\nexport { createRequestHeaders } from \"./runtimes/assistant-transport/utils\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAIC,QAAQC,IAAIC,aAAa,cAC3BH,mBAAmB"}
1
+ {"version":3,"file":"index.js","names":["checkDuplicateCore","process","env","NODE_ENV","TextMessagePart","ReasoningMessagePart","PartProviderMetadata","SourceProviderMetadata","SourceMessagePart","ImageMessagePart","FileMessagePart","DataMessagePart","GenerativeUIMessagePart","GenerativeUINode","GenerativeUISpec","Unstable_AudioMessagePart","ToolApprovalOption","ToolApprovalOptionKind","ToolApprovalResponse","ToolCallMessagePart","ToolCallTiming","ToolCallMessagePartMcpMetadata","McpAppMetadata","ToolModelContentPart","ThreadUserMessagePart","ThreadAssistantMessagePart","MessagePartStatus","ToolCallMessagePartStatus","MessageStatus","MessageTiming","ThreadStep","ThreadSystemMessage","ThreadUserMessage","ThreadAssistantMessage","ThreadMessage","MessageRole","RunConfig","AppendMessage","MCP_APP_URI_SCHEME","isMcpAppUri","Attachment","PendingAttachment","PendingAttachmentStatus","CompleteAttachment","CompleteAttachmentStatus","AttachmentStatus","CreateAttachment","Unsubscribe","QuoteInfo","Unstable_DirectiveSegment","Unstable_DirectiveFormatter","Unstable_TriggerItem","Unstable_TriggerCategory","Unstable_TriggerAdapter","LanguageModelV1CallSettings","LanguageModelConfig","ModelContext","ModelContextProvider","AssistantToolProps","AssistantInstructionsConfig","AssistantContextConfig","mergeModelContexts","tool","unstable_getInteractableSnapshots","unstable_formatInteractableSnapshot","unstable_getInteractableVersions","Unstable_InteractableSnapshotEntry","Unstable_InteractableVersion","ToolExecutionStatus","ModelContextRegistry","ModelContextRegistryToolHandle","ModelContextRegistryInstructionHandle","ModelContextRegistryProviderHandle","AssistantFrameHost","AssistantFrameProvider","SerializedTool","SerializedModelContext","FrameMessageType","FrameMessage","FRAME_MESSAGE_CHANNEL","AttachmentAdapter","SimpleImageAttachmentAdapter","SimpleTextAttachmentAdapter","CompositeAttachmentAdapter","SpeechSynthesisAdapter","DictationAdapter","WebSpeechSynthesisAdapter","WebSpeechDictationAdapter","RealtimeVoiceAdapter","createVoiceSession","VoiceSessionControls","VoiceSessionHelpers","FeedbackAdapter","SuggestionAdapter","SuggestionAdapterGenerateOptions","CreateSuggestionAdapterOptions","createSuggestionAdapter","unstable_defaultDirectiveFormatter","ThreadHistoryAdapter","GenericThreadHistoryAdapter","MessageFormatAdapter","MessageFormatItem","MessageFormatRepository","MessageStorageEntry","ThreadListItemRuntimePath","ThreadRuntimePath","MessageRuntimePath","MessagePartRuntimePath","AttachmentRuntimePath","ComposerRuntimePath","AttachmentAddErrorEvent","AttachmentAddErrorReason","ComposerRuntimeCore","ComposerRuntimeEventCallback","ComposerRuntimeEventPayload","ComposerRuntimeEventType","DictationState","EditComposerRuntimeCore","SendOptions","ThreadComposerRuntimeCore","ErrorSeverity","ErrorDisplay","AssistantErrorCode","AssistantError","toAssistantError","isAssistantError","RuntimeCapabilities","AddToolResultOptions","ResumeToolCallOptions","RespondToToolApprovalOptions","SubmitFeedbackOptions","ThreadSuggestion","SpeechState","VoiceSessionState","SubmittedFeedback","ThreadRuntimeEventCallback","ThreadRuntimeEventPayload","ThreadRuntimeEventType","StartRunConfig","ResumeRunConfig","ThreadRuntimeCore","ThreadListItemStatus","ThreadListItemCoreState","ThreadListRuntimeCore","AssistantRuntimeCore","AssistantRuntime","CreateStartRunConfig","CreateResumeRunConfig","CreateAppendMessage","ThreadState","ThreadRuntime","ThreadListState","ThreadListRuntime","ThreadListItemEventCallback","ThreadListItemEventPayload","ThreadListItemEventType","ThreadListItemRuntime","ThreadListItemState","MessageState","MessageRuntime","MessagePartState","MessagePartRuntime","ThreadComposerState","EditComposerState","ComposerState","ComposerRuntime","ThreadComposerRuntime","EditComposerRuntime","AttachmentState","AttachmentRuntime","ChatModelRunUpdate","ChatModelRunResult","CoreChatModelRunResult","ChatModelRunOptions","ChatModelAdapter","ThreadMessageLike","fromThreadMessageLike","StreamingTimingAccessors","StreamingTimingOptions","StreamingTimingState","stepStreamingTiming","generateId","getExternalStoreMessages","bindExternalStoreMessage","ExportedMessageRepositoryItem","ExportedMessageRepository","LocalRuntimeOptionsBase","ExternalStoreAdapter","ExternalStoreMessageConverter","ExternalStoreThreadListAdapter","ExternalStoreThreadData","ExternalStoreBranchChange","ExternalStoreSharedOptions","pickExternalStoreSharedOptions","ExternalThreadQueueAdapter","ExternalThreadBranchAdapter","createMessageQueue","MessageQueueDriver","MessageQueueController","RemoteThreadListAdapter","RemoteThreadListOptions","RemoteThreadInitializeResponse","RemoteThreadMetadata","RemoteThreadListResponse","RemoteThreadListPageOptions","InMemoryThreadListAdapter","createRequestHeaders"],"sources":["../src/index.ts"],"sourcesContent":["// @assistant-ui/core - Framework-agnostic core runtime (public API)\n\n/// <reference path=\"./store/scope-registration.ts\" />\n\nimport { checkDuplicateCore } from \"./internal/duplicate-detection\";\n\nif (process.env.NODE_ENV !== \"production\") {\n checkDuplicateCore();\n}\n\nexport type {\n // Message parts\n TextMessagePart,\n ReasoningMessagePart,\n PartProviderMetadata,\n SourceProviderMetadata,\n SourceMessagePart,\n ImageMessagePart,\n FileMessagePart,\n DataMessagePart,\n GenerativeUIMessagePart,\n GenerativeUINode,\n GenerativeUISpec,\n Unstable_AudioMessagePart,\n ToolApprovalOption,\n ToolApprovalOptionKind,\n ToolApprovalResponse,\n ToolCallMessagePart,\n ToolCallTiming,\n ToolCallMessagePartMcpMetadata,\n McpAppMetadata,\n ToolModelContentPart,\n ThreadUserMessagePart,\n ThreadAssistantMessagePart,\n // Message status\n MessagePartStatus,\n ToolCallMessagePartStatus,\n MessageStatus,\n // Thread messages\n MessageTiming,\n ThreadStep,\n ThreadSystemMessage,\n ThreadUserMessage,\n ThreadAssistantMessage,\n ThreadMessage,\n MessageRole,\n // Config\n RunConfig,\n AppendMessage,\n} from \"./types/message\";\n\nexport { MCP_APP_URI_SCHEME, isMcpAppUri } from \"./types/message\";\n\nexport type {\n Attachment,\n PendingAttachment,\n PendingAttachmentStatus,\n CompleteAttachment,\n CompleteAttachmentStatus,\n AttachmentStatus,\n CreateAttachment,\n} from \"./types/attachment\";\n\nexport type { Unsubscribe } from \"./types/unsubscribe\";\n\nexport type { QuoteInfo } from \"./types/quote\";\n\nexport type {\n Unstable_DirectiveSegment,\n Unstable_DirectiveFormatter,\n} from \"./types/directive\";\n\nexport type {\n Unstable_TriggerItem,\n Unstable_TriggerCategory,\n} from \"./types/trigger\";\n\nexport type { Unstable_TriggerAdapter } from \"./adapters/trigger\";\n\nexport type {\n // Language model settings\n LanguageModelV1CallSettings,\n LanguageModelConfig,\n // Model context\n ModelContext,\n ModelContextProvider,\n // Tool & instruction config\n AssistantToolProps,\n AssistantInstructionsConfig,\n AssistantContextConfig,\n} from \"./model-context/types\";\nexport { mergeModelContexts } from \"./model-context/types\";\n\nexport { tool } from \"./model-context/tool\";\n\nexport {\n unstable_getInteractableSnapshots,\n unstable_formatInteractableSnapshot,\n unstable_getInteractableVersions,\n type Unstable_InteractableSnapshotEntry,\n type Unstable_InteractableVersion,\n} from \"./model-context/interactable-composer-metadata\";\n\nexport type { ToolExecutionStatus } from \"./runtimes/tool-invocations/ToolInvocationTracker\";\n\nexport { ModelContextRegistry } from \"./model-context/registry\";\nexport type {\n ModelContextRegistryToolHandle,\n ModelContextRegistryInstructionHandle,\n ModelContextRegistryProviderHandle,\n} from \"./model-context/registry-handles\";\n\nexport { AssistantFrameHost } from \"./model-context/frame/host\";\nexport { AssistantFrameProvider } from \"./model-context/frame/provider\";\nexport type {\n SerializedTool,\n SerializedModelContext,\n FrameMessageType,\n FrameMessage,\n} from \"./model-context/frame/types\";\nexport { FRAME_MESSAGE_CHANNEL } from \"./model-context/frame/types\";\n\n// Attachment adapters\nexport type { AttachmentAdapter } from \"./adapters/attachment\";\nexport {\n SimpleImageAttachmentAdapter,\n SimpleTextAttachmentAdapter,\n CompositeAttachmentAdapter,\n} from \"./adapters/attachment\";\n\n// Speech adapters\nexport type {\n SpeechSynthesisAdapter,\n DictationAdapter,\n} from \"./adapters/speech\";\nexport {\n WebSpeechSynthesisAdapter,\n WebSpeechDictationAdapter,\n} from \"./adapters/speech\";\n\n// Voice adapter\nexport type { RealtimeVoiceAdapter } from \"./adapters/voice\";\nexport { createVoiceSession } from \"./adapters/voice\";\nexport type {\n VoiceSessionControls,\n VoiceSessionHelpers,\n} from \"./adapters/voice\";\n\n// Feedback adapter\nexport type { FeedbackAdapter } from \"./adapters/feedback\";\n\n// Suggestion adapter\nexport type {\n SuggestionAdapter,\n SuggestionAdapterGenerateOptions,\n CreateSuggestionAdapterOptions,\n} from \"./adapters/suggestion\";\nexport { createSuggestionAdapter } from \"./adapters/suggestion\";\n\n// Directive formatter\nexport { unstable_defaultDirectiveFormatter } from \"./adapters/directive-formatter\";\n\n// Thread history adapters\nexport type {\n ThreadHistoryAdapter,\n GenericThreadHistoryAdapter,\n MessageFormatAdapter,\n MessageFormatItem,\n MessageFormatRepository,\n MessageStorageEntry,\n} from \"./adapters/thread-history\";\n\n// Path Types\nexport type {\n ThreadListItemRuntimePath,\n ThreadRuntimePath,\n MessageRuntimePath,\n MessagePartRuntimePath,\n AttachmentRuntimePath,\n ComposerRuntimePath,\n} from \"./runtime/api/paths\";\n\n// Runtime Core Interface Types\nexport type {\n AttachmentAddErrorEvent,\n AttachmentAddErrorReason,\n ComposerRuntimeCore,\n ComposerRuntimeEventCallback,\n ComposerRuntimeEventPayload,\n ComposerRuntimeEventType,\n DictationState,\n EditComposerRuntimeCore,\n SendOptions,\n ThreadComposerRuntimeCore,\n} from \"./runtime/interfaces/composer-runtime-core\";\n\nexport type {\n ErrorSeverity,\n ErrorDisplay,\n AssistantErrorCode,\n AssistantError,\n} from \"./types/error\";\nexport { toAssistantError, isAssistantError } from \"./types/error\";\n\nexport type {\n RuntimeCapabilities,\n AddToolResultOptions,\n ResumeToolCallOptions,\n RespondToToolApprovalOptions,\n SubmitFeedbackOptions,\n ThreadSuggestion,\n SpeechState,\n VoiceSessionState,\n SubmittedFeedback,\n ThreadRuntimeEventCallback,\n ThreadRuntimeEventPayload,\n ThreadRuntimeEventType,\n StartRunConfig,\n ResumeRunConfig,\n ThreadRuntimeCore,\n} from \"./runtime/interfaces/thread-runtime-core\";\n\nexport type {\n ThreadListItemStatus,\n ThreadListItemCoreState,\n ThreadListRuntimeCore,\n} from \"./runtime/interfaces/thread-list-runtime-core\";\n\nexport type { AssistantRuntimeCore } from \"./runtime/interfaces/assistant-runtime-core\";\n\n// Public Runtime Types\nexport type { AssistantRuntime } from \"./runtime/api/assistant-runtime\";\n\nexport type {\n CreateStartRunConfig,\n CreateResumeRunConfig,\n CreateAppendMessage,\n ThreadState,\n ThreadRuntime,\n} from \"./runtime/api/thread-runtime\";\n\nexport type {\n ThreadListState,\n ThreadListRuntime,\n} from \"./runtime/api/thread-list-runtime\";\n\nexport type {\n ThreadListItemEventCallback,\n ThreadListItemEventPayload,\n ThreadListItemEventType,\n ThreadListItemRuntime,\n} from \"./runtime/api/thread-list-item-runtime\";\n\nexport type { ThreadListItemState } from \"./runtime/api/bindings\";\n\nexport type {\n MessageState,\n MessageRuntime,\n} from \"./runtime/api/message-runtime\";\nexport type {\n MessagePartState,\n MessagePartRuntime,\n} from \"./runtime/api/message-part-runtime\";\n\nexport type {\n ThreadComposerState,\n EditComposerState,\n ComposerState,\n ComposerRuntime,\n ThreadComposerRuntime,\n EditComposerRuntime,\n} from \"./runtime/api/composer-runtime\";\n\nexport type {\n AttachmentState,\n AttachmentRuntime,\n} from \"./runtime/api/attachment-runtime\";\n\n// ChatModel Types\nexport type {\n ChatModelRunUpdate,\n ChatModelRunResult,\n CoreChatModelRunResult,\n ChatModelRunOptions,\n ChatModelAdapter,\n} from \"./runtime/utils/chat-model-adapter\";\n\n// ThreadMessageLike\nexport type { ThreadMessageLike } from \"./runtime/utils/thread-message-like\";\nexport { fromThreadMessageLike } from \"./runtime/utils/thread-message-like\";\n\n// Streaming timing (client-side)\nexport type {\n StreamingTimingAccessors,\n StreamingTimingOptions,\n StreamingTimingState,\n} from \"./runtime/utils/streaming-timing\";\nexport { stepStreamingTiming } from \"./runtime/utils/streaming-timing\";\n\n// ID generation\nexport { generateId } from \"./utils/id\";\n\n// External Store Message Utilities\nexport {\n getExternalStoreMessages,\n bindExternalStoreMessage,\n} from \"./runtime/utils/external-store-message\";\n\n// ExportedMessageRepository\nexport type { ExportedMessageRepositoryItem } from \"./runtime/utils/message-repository\";\nexport { ExportedMessageRepository } from \"./runtime/utils/message-repository\";\n\n// Local Runtime Options\nexport type { LocalRuntimeOptionsBase } from \"./runtimes/local/local-runtime-options\";\n\n// External Store Adapter Types (user-facing)\nexport type {\n ExternalStoreAdapter,\n ExternalStoreMessageConverter,\n ExternalStoreThreadListAdapter,\n ExternalStoreThreadData,\n ExternalStoreBranchChange,\n} from \"./runtimes/external-store/external-store-adapter\";\nexport type { ExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\nexport { pickExternalStoreSharedOptions } from \"./runtimes/external-store/external-store-shared-options\";\n\n// Message queue\nexport type { ExternalThreadQueueAdapter } from \"./runtime/queue/external-thread-queue-adapter\";\nexport type { ExternalThreadBranchAdapter } from \"./runtime/branch/external-thread-branch-adapter\";\nexport {\n createMessageQueue,\n type MessageQueueDriver,\n type MessageQueueController,\n} from \"./runtime/queue/message-queue\";\n\n// Remote Thread List (user-facing)\nexport type {\n RemoteThreadListAdapter,\n RemoteThreadListOptions,\n RemoteThreadInitializeResponse,\n RemoteThreadMetadata,\n RemoteThreadListResponse,\n RemoteThreadListPageOptions,\n} from \"./runtimes/remote-thread-list/types\";\n\nexport { InMemoryThreadListAdapter } from \"./runtimes/remote-thread-list/adapter/in-memory\";\n\n// Assistant Transport Utilities\nexport { createRequestHeaders } from \"./runtimes/assistant-transport/utils\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAMA,IAAIC,QAAQC,IAAIC,aAAa,cAC3BH,mBAAmB"}
@@ -1 +1 @@
1
- {"version":3,"file":"duplicate-detection.d.ts","names":[],"sources":["../../src/internal/duplicate-detection.ts"],"mappings":";iBAYgB,kBAAA"}
1
+ {"version":3,"file":"duplicate-detection.d.ts","names":[],"sources":["../../src/internal/duplicate-detection.ts"],"mappings":";iBAYgB"}