@assistant-ui/react 0.7.43 → 0.7.45

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 (321) hide show
  1. package/dist/api/AssistantRuntime.d.ts +11 -3
  2. package/dist/api/AssistantRuntime.d.ts.map +1 -1
  3. package/dist/api/AssistantRuntime.js +8 -17
  4. package/dist/api/AssistantRuntime.js.map +1 -1
  5. package/dist/api/AssistantRuntime.mjs +8 -17
  6. package/dist/api/AssistantRuntime.mjs.map +1 -1
  7. package/dist/api/RuntimePathTypes.d.ts +4 -1
  8. package/dist/api/RuntimePathTypes.d.ts.map +1 -1
  9. package/dist/api/RuntimePathTypes.js.map +1 -1
  10. package/dist/api/ThreadListItemRuntime.d.ts +8 -0
  11. package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
  12. package/dist/api/ThreadListItemRuntime.js +4 -0
  13. package/dist/api/ThreadListItemRuntime.js.map +1 -1
  14. package/dist/api/ThreadListItemRuntime.mjs +4 -0
  15. package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
  16. package/dist/api/ThreadListRuntime.d.ts +11 -1
  17. package/dist/api/ThreadListRuntime.d.ts.map +1 -1
  18. package/dist/api/ThreadListRuntime.js +37 -1
  19. package/dist/api/ThreadListRuntime.js.map +1 -1
  20. package/dist/api/ThreadListRuntime.mjs +39 -1
  21. package/dist/api/ThreadListRuntime.mjs.map +1 -1
  22. package/dist/runtimes/adapters/RuntimeAdapterProvider.d.ts +15 -0
  23. package/dist/runtimes/adapters/RuntimeAdapterProvider.d.ts.map +1 -0
  24. package/dist/runtimes/adapters/RuntimeAdapterProvider.js +45 -0
  25. package/dist/runtimes/adapters/RuntimeAdapterProvider.js.map +1 -0
  26. package/dist/runtimes/adapters/RuntimeAdapterProvider.mjs +19 -0
  27. package/dist/runtimes/adapters/RuntimeAdapterProvider.mjs.map +1 -0
  28. package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.d.ts +1 -1
  29. package/dist/runtimes/adapters/attachment/AttachmentAdapter.d.ts.map +1 -0
  30. package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.js +1 -1
  31. package/dist/runtimes/adapters/attachment/AttachmentAdapter.js.map +1 -0
  32. package/dist/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.d.ts +2 -2
  33. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.d.ts.map +1 -0
  34. package/dist/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.js +1 -1
  35. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.js.map +1 -0
  36. package/dist/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.mjs +1 -1
  37. package/dist/runtimes/adapters/attachment/CompositeAttachmentAdapter.mjs.map +1 -0
  38. package/dist/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.d.ts +1 -1
  39. package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.d.ts.map +1 -0
  40. package/dist/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.js +1 -1
  41. package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.js.map +1 -0
  42. package/dist/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.mjs +1 -1
  43. package/dist/runtimes/adapters/attachment/SimpleImageAttachmentAdapter.mjs.map +1 -0
  44. package/dist/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.d.ts +1 -1
  45. package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.d.ts.map +1 -0
  46. package/dist/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.js +1 -1
  47. package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.js.map +1 -0
  48. package/dist/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.mjs +1 -1
  49. package/dist/runtimes/adapters/attachment/SimpleTextAttachmentAdapter.mjs.map +1 -0
  50. package/dist/runtimes/adapters/attachment/index.d.ts.map +1 -0
  51. package/dist/runtimes/{attachment → adapters/attachment}/index.js +1 -1
  52. package/dist/runtimes/adapters/attachment/index.js.map +1 -0
  53. package/dist/runtimes/{attachment → adapters/attachment}/index.mjs +1 -1
  54. package/dist/runtimes/adapters/attachment/index.mjs.map +1 -0
  55. package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.d.ts +1 -1
  56. package/dist/runtimes/adapters/feedback/FeedbackAdapter.d.ts.map +1 -0
  57. package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.js +1 -1
  58. package/dist/runtimes/adapters/feedback/FeedbackAdapter.js.map +1 -0
  59. package/dist/runtimes/adapters/feedback/index.d.ts.map +1 -0
  60. package/dist/runtimes/{feedback → adapters/feedback}/index.js +1 -1
  61. package/dist/runtimes/adapters/feedback/index.js.map +1 -0
  62. package/dist/runtimes/adapters/index.d.ts +4 -0
  63. package/dist/runtimes/adapters/index.d.ts.map +1 -0
  64. package/dist/runtimes/adapters/index.js +29 -0
  65. package/dist/runtimes/adapters/index.js.map +1 -0
  66. package/dist/runtimes/adapters/index.mjs +5 -0
  67. package/dist/runtimes/adapters/index.mjs.map +1 -0
  68. package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.d.ts +1 -1
  69. package/dist/runtimes/adapters/speech/SpeechAdapterTypes.d.ts.map +1 -0
  70. package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.js +1 -1
  71. package/dist/runtimes/adapters/speech/SpeechAdapterTypes.js.map +1 -0
  72. package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.d.ts.map +1 -0
  73. package/dist/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.js +1 -1
  74. package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.js.map +1 -0
  75. package/dist/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.mjs +1 -1
  76. package/dist/runtimes/adapters/speech/WebSpeechSynthesisAdapter.mjs.map +1 -0
  77. package/dist/runtimes/adapters/speech/index.d.ts.map +1 -0
  78. package/dist/runtimes/{speech → adapters/speech}/index.js +1 -1
  79. package/dist/runtimes/adapters/speech/index.js.map +1 -0
  80. package/dist/runtimes/{speech → adapters/speech}/index.mjs +1 -1
  81. package/dist/runtimes/adapters/speech/index.mjs.map +1 -0
  82. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts +6 -0
  83. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.d.ts.map +1 -0
  84. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.js +19 -0
  85. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.js.map +1 -0
  86. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.mjs +1 -0
  87. package/dist/runtimes/adapters/thread-history/ThreadHistoryAdapter.mjs.map +1 -0
  88. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +1 -1
  89. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
  90. package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
  91. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
  92. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts +1 -1
  93. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  94. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  95. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
  96. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.d.ts +1 -1
  97. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.d.ts.map +1 -1
  98. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
  99. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs.map +1 -1
  100. package/dist/runtimes/core/AssistantRuntimeCore.d.ts +1 -1
  101. package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
  102. package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
  103. package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts +1 -1
  104. package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts.map +1 -1
  105. package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
  106. package/dist/runtimes/core/BaseAssistantRuntimeCore.mjs.map +1 -1
  107. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts +3 -3
  108. package/dist/runtimes/core/BaseThreadRuntimeCore.d.ts.map +1 -1
  109. package/dist/runtimes/core/BaseThreadRuntimeCore.js.map +1 -1
  110. package/dist/runtimes/core/BaseThreadRuntimeCore.mjs.map +1 -1
  111. package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +5 -0
  112. package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
  113. package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -1
  114. package/dist/runtimes/core/ThreadRuntimeCore.d.ts +2 -2
  115. package/dist/runtimes/core/ThreadRuntimeCore.d.ts.map +1 -1
  116. package/dist/runtimes/core/ThreadRuntimeCore.js.map +1 -1
  117. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +3 -3
  118. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
  119. package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
  120. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts +1 -1
  121. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
  122. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +4 -4
  123. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
  124. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +4 -4
  125. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
  126. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +2 -0
  127. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
  128. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +6 -0
  129. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
  130. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs +6 -0
  131. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -1
  132. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
  133. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +7 -0
  134. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
  135. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +7 -0
  136. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
  137. package/dist/runtimes/index.d.ts +1 -3
  138. package/dist/runtimes/index.d.ts.map +1 -1
  139. package/dist/runtimes/index.js +3 -7
  140. package/dist/runtimes/index.js.map +1 -1
  141. package/dist/runtimes/index.mjs +1 -3
  142. package/dist/runtimes/index.mjs.map +1 -1
  143. package/dist/runtimes/local/LocalRuntimeCore.d.ts +1 -1
  144. package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
  145. package/dist/runtimes/local/LocalRuntimeCore.js +5 -5
  146. package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
  147. package/dist/runtimes/local/LocalRuntimeCore.mjs +5 -5
  148. package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
  149. package/dist/runtimes/local/LocalRuntimeOptions.d.ts +6 -3
  150. package/dist/runtimes/local/LocalRuntimeOptions.d.ts.map +1 -1
  151. package/dist/runtimes/local/LocalRuntimeOptions.js.map +1 -1
  152. package/dist/runtimes/local/LocalRuntimeOptions.mjs.map +1 -1
  153. package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +2 -0
  154. package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
  155. package/dist/runtimes/local/LocalThreadListRuntimeCore.js +8 -0
  156. package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
  157. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +8 -0
  158. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
  159. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts +1 -0
  160. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
  161. package/dist/runtimes/local/LocalThreadRuntimeCore.js +7 -3
  162. package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
  163. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +7 -3
  164. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
  165. package/dist/runtimes/local/useLocalRuntime.js +1 -1
  166. package/dist/runtimes/local/useLocalRuntime.js.map +1 -1
  167. package/dist/runtimes/local/useLocalRuntime.mjs +1 -1
  168. package/dist/runtimes/local/useLocalRuntime.mjs.map +1 -1
  169. package/dist/runtimes/remote-thread-list/OptimisticState.d.ts +1 -1
  170. package/dist/runtimes/remote-thread-list/OptimisticState.d.ts.map +1 -1
  171. package/dist/runtimes/remote-thread-list/OptimisticState.js +7 -5
  172. package/dist/runtimes/remote-thread-list/OptimisticState.js.map +1 -1
  173. package/dist/runtimes/remote-thread-list/OptimisticState.mjs +7 -5
  174. package/dist/runtimes/remote-thread-list/OptimisticState.mjs.map +1 -1
  175. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -1
  176. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +9 -1
  177. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -1
  178. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +13 -2
  179. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -1
  180. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +41 -3
  181. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  182. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +46 -14
  183. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  184. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +46 -14
  185. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -1
  186. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts +3 -2
  187. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts.map +1 -1
  188. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js +9 -4
  189. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js.map +1 -1
  190. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs +9 -4
  191. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs.map +1 -1
  192. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts +6 -3
  193. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts.map +1 -1
  194. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js +13 -1
  195. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js.map +1 -1
  196. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs +13 -1
  197. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs.map +1 -1
  198. package/dist/runtimes/remote-thread-list/cloud/index.d.ts +0 -1
  199. package/dist/runtimes/remote-thread-list/cloud/index.d.ts.map +1 -1
  200. package/dist/runtimes/remote-thread-list/cloud/index.js +0 -3
  201. package/dist/runtimes/remote-thread-list/cloud/index.js.map +1 -1
  202. package/dist/runtimes/remote-thread-list/cloud/index.mjs +0 -2
  203. package/dist/runtimes/remote-thread-list/cloud/index.mjs.map +1 -1
  204. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts.map +1 -1
  205. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js +26 -49
  206. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js.map +1 -1
  207. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs +27 -56
  208. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs.map +1 -1
  209. package/dist/runtimes/remote-thread-list/types.d.ts +2 -2
  210. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -1
  211. package/dist/runtimes/remote-thread-list/types.js.map +1 -1
  212. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +5 -5
  213. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -1
  214. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +5 -5
  215. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -1
  216. package/dist/runtimes/utils/MessageRepository.d.ts +4 -0
  217. package/dist/runtimes/utils/MessageRepository.d.ts.map +1 -1
  218. package/dist/runtimes/utils/MessageRepository.js.map +1 -1
  219. package/dist/runtimes/utils/MessageRepository.mjs.map +1 -1
  220. package/dist/ui/assistant-message.d.ts.map +1 -1
  221. package/dist/ui/assistant-message.js +14 -10
  222. package/dist/ui/assistant-message.js.map +1 -1
  223. package/dist/ui/assistant-message.mjs +14 -10
  224. package/dist/ui/assistant-message.mjs.map +1 -1
  225. package/dist/ui/thread-config.d.ts +1 -0
  226. package/dist/ui/thread-config.d.ts.map +1 -1
  227. package/dist/ui/thread-config.js.map +1 -1
  228. package/dist/ui/thread-config.mjs.map +1 -1
  229. package/package.json +1 -1
  230. package/src/api/AssistantRuntime.ts +19 -18
  231. package/src/api/RuntimePathTypes.ts +6 -1
  232. package/src/api/ThreadListItemRuntime.ts +9 -0
  233. package/src/api/ThreadListRuntime.ts +56 -1
  234. package/src/runtimes/adapters/RuntimeAdapterProvider.tsx +31 -0
  235. package/src/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.ts +1 -1
  236. package/src/runtimes/{attachment → adapters/attachment}/CompositeAttachmentAdapter.ts +1 -1
  237. package/src/runtimes/{attachment → adapters/attachment}/SimpleImageAttachmentAdapter.ts +1 -1
  238. package/src/runtimes/{attachment → adapters/attachment}/SimpleTextAttachmentAdapter.ts +1 -1
  239. package/src/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.ts +1 -1
  240. package/src/runtimes/adapters/index.ts +3 -0
  241. package/src/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.ts +1 -1
  242. package/src/runtimes/adapters/thread-history/ThreadHistoryAdapter.ts +9 -0
  243. package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +1 -1
  244. package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +1 -1
  245. package/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx +1 -1
  246. package/src/runtimes/core/AssistantRuntimeCore.tsx +1 -1
  247. package/src/runtimes/core/BaseAssistantRuntimeCore.tsx +1 -1
  248. package/src/runtimes/core/BaseThreadRuntimeCore.tsx +3 -3
  249. package/src/runtimes/core/ThreadListRuntimeCore.tsx +6 -0
  250. package/src/runtimes/core/ThreadRuntimeCore.tsx +2 -1
  251. package/src/runtimes/external-store/ExternalStoreAdapter.tsx +3 -3
  252. package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +4 -4
  253. package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +8 -0
  254. package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +8 -0
  255. package/src/runtimes/index.ts +1 -3
  256. package/src/runtimes/local/LocalRuntimeCore.tsx +5 -5
  257. package/src/runtimes/local/LocalRuntimeOptions.tsx +5 -3
  258. package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +10 -0
  259. package/src/runtimes/local/LocalThreadRuntimeCore.tsx +7 -3
  260. package/src/runtimes/local/useLocalRuntime.tsx +1 -1
  261. package/src/runtimes/remote-thread-list/OptimisticState.ts +15 -8
  262. package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +15 -2
  263. package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +56 -16
  264. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAPI.tsx +13 -5
  265. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.tsx +24 -4
  266. package/src/runtimes/remote-thread-list/cloud/index.ts +0 -1
  267. package/src/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.tsx +36 -60
  268. package/src/runtimes/remote-thread-list/types.tsx +2 -5
  269. package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +5 -5
  270. package/src/runtimes/utils/MessageRepository.tsx +5 -0
  271. package/src/ui/assistant-message.tsx +2 -0
  272. package/src/ui/thread-config.tsx +1 -0
  273. package/dist/runtimes/attachment/AttachmentAdapter.d.ts.map +0 -1
  274. package/dist/runtimes/attachment/AttachmentAdapter.js.map +0 -1
  275. package/dist/runtimes/attachment/CompositeAttachmentAdapter.d.ts.map +0 -1
  276. package/dist/runtimes/attachment/CompositeAttachmentAdapter.js.map +0 -1
  277. package/dist/runtimes/attachment/CompositeAttachmentAdapter.mjs.map +0 -1
  278. package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.d.ts.map +0 -1
  279. package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.js.map +0 -1
  280. package/dist/runtimes/attachment/SimpleImageAttachmentAdapter.mjs.map +0 -1
  281. package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.d.ts.map +0 -1
  282. package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.js.map +0 -1
  283. package/dist/runtimes/attachment/SimpleTextAttachmentAdapter.mjs.map +0 -1
  284. package/dist/runtimes/attachment/index.d.ts.map +0 -1
  285. package/dist/runtimes/attachment/index.js.map +0 -1
  286. package/dist/runtimes/attachment/index.mjs.map +0 -1
  287. package/dist/runtimes/feedback/FeedbackAdapter.d.ts.map +0 -1
  288. package/dist/runtimes/feedback/FeedbackAdapter.js.map +0 -1
  289. package/dist/runtimes/feedback/index.d.ts.map +0 -1
  290. package/dist/runtimes/feedback/index.js.map +0 -1
  291. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts +0 -22
  292. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.d.ts.map +0 -1
  293. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js +0 -85
  294. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.js.map +0 -1
  295. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs +0 -60
  296. package/dist/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.mjs.map +0 -1
  297. package/dist/runtimes/speech/SpeechAdapterTypes.d.ts.map +0 -1
  298. package/dist/runtimes/speech/SpeechAdapterTypes.js.map +0 -1
  299. package/dist/runtimes/speech/WebSpeechSynthesisAdapter.d.ts.map +0 -1
  300. package/dist/runtimes/speech/WebSpeechSynthesisAdapter.js.map +0 -1
  301. package/dist/runtimes/speech/WebSpeechSynthesisAdapter.mjs.map +0 -1
  302. package/dist/runtimes/speech/index.d.ts.map +0 -1
  303. package/dist/runtimes/speech/index.js.map +0 -1
  304. package/dist/runtimes/speech/index.mjs.map +0 -1
  305. package/src/runtimes/remote-thread-list/cloud/CloudThreadListItemRuntime.tsx +0 -89
  306. /package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.mjs +0 -0
  307. /package/dist/runtimes/{attachment → adapters/attachment}/AttachmentAdapter.mjs.map +0 -0
  308. /package/dist/runtimes/{attachment → adapters/attachment}/index.d.ts +0 -0
  309. /package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.mjs +0 -0
  310. /package/dist/runtimes/{feedback → adapters/feedback}/FeedbackAdapter.mjs.map +0 -0
  311. /package/dist/runtimes/{feedback → adapters/feedback}/index.d.ts +0 -0
  312. /package/dist/runtimes/{feedback → adapters/feedback}/index.mjs +0 -0
  313. /package/dist/runtimes/{feedback → adapters/feedback}/index.mjs.map +0 -0
  314. /package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.mjs +0 -0
  315. /package/dist/runtimes/{speech → adapters/speech}/SpeechAdapterTypes.mjs.map +0 -0
  316. /package/dist/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.d.ts +0 -0
  317. /package/dist/runtimes/{speech → adapters/speech}/index.d.ts +0 -0
  318. /package/src/runtimes/{attachment → adapters/attachment}/index.ts +0 -0
  319. /package/src/runtimes/{feedback → adapters/feedback}/index.ts +0 -0
  320. /package/src/runtimes/{speech → adapters/speech}/WebSpeechSynthesisAdapter.ts +0 -0
  321. /package/src/runtimes/{speech → adapters/speech}/index.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport {\n EmptyContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartProps,\n} from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\n prompt: string;\n};\n\nexport type ThreadWelcomeConfig = {\n message?: string | null | undefined;\n suggestions?: SuggestionConfig[] | undefined;\n};\n\nexport type UserMessageConfig = {\n allowEdit?: boolean | undefined;\n};\n\nexport type AssistantMessageConfig = {\n allowReload?: boolean | undefined;\n allowCopy?: boolean | undefined;\n allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n Empty?: EmptyContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: boolean | undefined;\n};\n\nexport type StringsConfig = {\n assistantModal?: {\n open: {\n button: {\n tooltip?: string | undefined;\n };\n };\n closed: {\n button: {\n tooltip?: string | undefined;\n };\n };\n };\n threadList?: {\n new?: {\n label?: string | undefined;\n };\n item?: {\n title?: {\n fallback?: string | undefined;\n };\n archive?: {\n tooltip?: string | undefined;\n };\n };\n };\n thread?: {\n scrollToBottom?: {\n tooltip?: string | undefined;\n };\n };\n welcome?: {\n message?: string | undefined;\n };\n userMessage?: {\n edit?: {\n tooltip?: string | undefined;\n };\n };\n assistantMessage?: {\n reload?: {\n tooltip?: string | undefined;\n };\n copy?: {\n tooltip?: string | undefined;\n };\n speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\n };\n };\n branchPicker?: {\n previous?: {\n tooltip?: string | undefined;\n };\n next?: {\n tooltip?: string | undefined;\n };\n };\n composer?: {\n send?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n cancel?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\n input?: {\n placeholder?: string | undefined;\n };\n };\n editComposer?: {\n send?: {\n label?: string | undefined;\n };\n cancel?: {\n label?: string | undefined;\n };\n };\n code?: {\n header?: {\n copy?: {\n tooltip?: string | undefined;\n };\n };\n };\n};\n\nconst ThreadConfigContext = createContext<ThreadConfig>({});\n\nexport type ThreadConfig = {\n runtime?: AssistantRuntime | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\n};\n\nexport const useThreadConfig = (): Omit<ThreadConfig, \"runtime\"> => {\n return useContext(ThreadConfigContext);\n};\n\nexport type ThreadConfigProviderProps = PropsWithChildren<{\n config?: ThreadConfig | undefined;\n}>;\n\nexport const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({\n children,\n config,\n}) => {\n const hasAssistant = !!useAssistantRuntime({ optional: true });\n\n const hasConfig = config && Object.keys(config).length > 0;\n const outerConfig = useThreadConfig();\n\n if (hasConfig && Object.keys(outerConfig).length > 0) {\n throw new Error(\n \"You are providing ThreadConfig to several nested components. Please provide all configuration to the same component.\",\n );\n }\n\n const configProvider = hasConfig ? (\n <ThreadConfigContext.Provider value={config}>\n {children}\n </ThreadConfigContext.Provider>\n ) : (\n <>{children}</>\n );\n\n if (!config?.runtime) return configProvider;\n\n if (hasAssistant) {\n throw new Error(\n \"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed.\",\n );\n }\n return (\n <AssistantRuntimeProvider runtime={config.runtime}>\n {configProvider}\n </AssistantRuntimeProvider>\n );\n};\n\nThreadConfigProvider.displayName = \"ThreadConfigProvider\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAOO;AASP,qBAAyC;AAEzC,8BAAoC;AA0MhC;AAtDJ,IAAM,0BAAsB,4BAA4B,CAAC,CAAC;AA8BnD,IAAM,kBAAkB,MAAqC;AAClE,aAAO,yBAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,KAAC,6CAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,YAAY,UAAU,OAAO,KAAK,MAAM,EAAE,SAAS;AACzD,QAAM,cAAc,gBAAgB;AAEpC,MAAI,aAAa,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACpD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,YACrB,4CAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,2EAAG,UAAS;AAGd,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,4CAAC,2CAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport {\n EmptyContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartProps,\n} from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\n prompt: string;\n};\n\nexport type ThreadWelcomeConfig = {\n message?: string | null | undefined;\n suggestions?: SuggestionConfig[] | undefined;\n};\n\nexport type UserMessageConfig = {\n allowEdit?: boolean | undefined;\n};\n\nexport type AssistantMessageConfig = {\n allowReload?: boolean | undefined;\n allowCopy?: boolean | undefined;\n allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n Empty?: EmptyContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n Footer?: ComponentType | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: boolean | undefined;\n};\n\nexport type StringsConfig = {\n assistantModal?: {\n open: {\n button: {\n tooltip?: string | undefined;\n };\n };\n closed: {\n button: {\n tooltip?: string | undefined;\n };\n };\n };\n threadList?: {\n new?: {\n label?: string | undefined;\n };\n item?: {\n title?: {\n fallback?: string | undefined;\n };\n archive?: {\n tooltip?: string | undefined;\n };\n };\n };\n thread?: {\n scrollToBottom?: {\n tooltip?: string | undefined;\n };\n };\n welcome?: {\n message?: string | undefined;\n };\n userMessage?: {\n edit?: {\n tooltip?: string | undefined;\n };\n };\n assistantMessage?: {\n reload?: {\n tooltip?: string | undefined;\n };\n copy?: {\n tooltip?: string | undefined;\n };\n speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\n };\n };\n branchPicker?: {\n previous?: {\n tooltip?: string | undefined;\n };\n next?: {\n tooltip?: string | undefined;\n };\n };\n composer?: {\n send?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n cancel?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\n input?: {\n placeholder?: string | undefined;\n };\n };\n editComposer?: {\n send?: {\n label?: string | undefined;\n };\n cancel?: {\n label?: string | undefined;\n };\n };\n code?: {\n header?: {\n copy?: {\n tooltip?: string | undefined;\n };\n };\n };\n};\n\nconst ThreadConfigContext = createContext<ThreadConfig>({});\n\nexport type ThreadConfig = {\n runtime?: AssistantRuntime | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\n};\n\nexport const useThreadConfig = (): Omit<ThreadConfig, \"runtime\"> => {\n return useContext(ThreadConfigContext);\n};\n\nexport type ThreadConfigProviderProps = PropsWithChildren<{\n config?: ThreadConfig | undefined;\n}>;\n\nexport const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({\n children,\n config,\n}) => {\n const hasAssistant = !!useAssistantRuntime({ optional: true });\n\n const hasConfig = config && Object.keys(config).length > 0;\n const outerConfig = useThreadConfig();\n\n if (hasConfig && Object.keys(outerConfig).length > 0) {\n throw new Error(\n \"You are providing ThreadConfig to several nested components. Please provide all configuration to the same component.\",\n );\n }\n\n const configProvider = hasConfig ? (\n <ThreadConfigContext.Provider value={config}>\n {children}\n </ThreadConfigContext.Provider>\n ) : (\n <>{children}</>\n );\n\n if (!config?.runtime) return configProvider;\n\n if (hasAssistant) {\n throw new Error(\n \"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed.\",\n );\n }\n return (\n <AssistantRuntimeProvider runtime={config.runtime}>\n {configProvider}\n </AssistantRuntimeProvider>\n );\n};\n\nThreadConfigProvider.displayName = \"ThreadConfigProvider\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAOO;AASP,qBAAyC;AAEzC,8BAAoC;AA2MhC;AAtDJ,IAAM,0BAAsB,4BAA4B,CAAC,CAAC;AA8BnD,IAAM,kBAAkB,MAAqC;AAClE,aAAO,yBAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,KAAC,6CAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,YAAY,UAAU,OAAO,KAAK,MAAM,EAAE,SAAS;AACzD,QAAM,cAAc,gBAAgB;AAEpC,MAAI,aAAa,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACpD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,YACrB,4CAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,2EAAG,UAAS;AAGd,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,4CAAC,2CAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport {\n EmptyContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartProps,\n} from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\n prompt: string;\n};\n\nexport type ThreadWelcomeConfig = {\n message?: string | null | undefined;\n suggestions?: SuggestionConfig[] | undefined;\n};\n\nexport type UserMessageConfig = {\n allowEdit?: boolean | undefined;\n};\n\nexport type AssistantMessageConfig = {\n allowReload?: boolean | undefined;\n allowCopy?: boolean | undefined;\n allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n Empty?: EmptyContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: boolean | undefined;\n};\n\nexport type StringsConfig = {\n assistantModal?: {\n open: {\n button: {\n tooltip?: string | undefined;\n };\n };\n closed: {\n button: {\n tooltip?: string | undefined;\n };\n };\n };\n threadList?: {\n new?: {\n label?: string | undefined;\n };\n item?: {\n title?: {\n fallback?: string | undefined;\n };\n archive?: {\n tooltip?: string | undefined;\n };\n };\n };\n thread?: {\n scrollToBottom?: {\n tooltip?: string | undefined;\n };\n };\n welcome?: {\n message?: string | undefined;\n };\n userMessage?: {\n edit?: {\n tooltip?: string | undefined;\n };\n };\n assistantMessage?: {\n reload?: {\n tooltip?: string | undefined;\n };\n copy?: {\n tooltip?: string | undefined;\n };\n speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\n };\n };\n branchPicker?: {\n previous?: {\n tooltip?: string | undefined;\n };\n next?: {\n tooltip?: string | undefined;\n };\n };\n composer?: {\n send?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n cancel?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\n input?: {\n placeholder?: string | undefined;\n };\n };\n editComposer?: {\n send?: {\n label?: string | undefined;\n };\n cancel?: {\n label?: string | undefined;\n };\n };\n code?: {\n header?: {\n copy?: {\n tooltip?: string | undefined;\n };\n };\n };\n};\n\nconst ThreadConfigContext = createContext<ThreadConfig>({});\n\nexport type ThreadConfig = {\n runtime?: AssistantRuntime | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\n};\n\nexport const useThreadConfig = (): Omit<ThreadConfig, \"runtime\"> => {\n return useContext(ThreadConfigContext);\n};\n\nexport type ThreadConfigProviderProps = PropsWithChildren<{\n config?: ThreadConfig | undefined;\n}>;\n\nexport const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({\n children,\n config,\n}) => {\n const hasAssistant = !!useAssistantRuntime({ optional: true });\n\n const hasConfig = config && Object.keys(config).length > 0;\n const outerConfig = useThreadConfig();\n\n if (hasConfig && Object.keys(outerConfig).length > 0) {\n throw new Error(\n \"You are providing ThreadConfig to several nested components. Please provide all configuration to the same component.\",\n );\n }\n\n const configProvider = hasConfig ? (\n <ThreadConfigContext.Provider value={config}>\n {children}\n </ThreadConfigContext.Provider>\n ) : (\n <>{children}</>\n );\n\n if (!config?.runtime) return configProvider;\n\n if (hasAssistant) {\n throw new Error(\n \"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed.\",\n );\n }\n return (\n <AssistantRuntimeProvider runtime={config.runtime}>\n {configProvider}\n </AssistantRuntimeProvider>\n );\n};\n\nThreadConfigProvider.displayName = \"ThreadConfigProvider\";\n"],"mappings":";;;AAEA;AAAA,EAKE;AAAA,EACA;AAAA,OACK;AASP,SAAS,gCAAgC;AAEzC,SAAS,2BAA2B;AA0MhC,SAIA,UAJA;AAtDJ,IAAM,sBAAsB,cAA4B,CAAC,CAAC;AA8BnD,IAAM,kBAAkB,MAAqC;AAClE,SAAO,WAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,CAAC,oBAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,YAAY,UAAU,OAAO,KAAK,MAAM,EAAE,SAAS;AACzD,QAAM,cAAc,gBAAgB;AAEpC,MAAI,aAAa,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACpD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,YACrB,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,gCAAG,UAAS;AAGd,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,oBAAC,4BAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/ui/thread-config.tsx"],"sourcesContent":["\"use client\";\n\nimport {\n ComponentType,\n FC,\n PropsWithChildren,\n ReactNode,\n createContext,\n useContext,\n} from \"react\";\n\nimport { AssistantRuntime } from \"../api/AssistantRuntime\";\nimport { AvatarProps } from \"./base/avatar\";\nimport {\n EmptyContentPartComponent,\n TextContentPartComponent,\n ToolCallContentPartProps,\n} from \"../types\";\nimport { AssistantRuntimeProvider } from \"../context\";\nimport { AssistantToolUI } from \"../model-config\";\nimport { useAssistantRuntime } from \"../context/react/AssistantContext\";\n\nexport type SuggestionConfig = {\n text?: ReactNode | undefined;\n prompt: string;\n};\n\nexport type ThreadWelcomeConfig = {\n message?: string | null | undefined;\n suggestions?: SuggestionConfig[] | undefined;\n};\n\nexport type UserMessageConfig = {\n allowEdit?: boolean | undefined;\n};\n\nexport type AssistantMessageConfig = {\n allowReload?: boolean | undefined;\n allowCopy?: boolean | undefined;\n allowSpeak?: boolean | undefined;\n allowFeedbackPositive?: boolean | undefined;\n allowFeedbackNegative?: boolean | undefined;\n components?:\n | {\n Text?: TextContentPartComponent | undefined;\n Empty?: EmptyContentPartComponent | undefined;\n ToolFallback?: ComponentType<ToolCallContentPartProps> | undefined;\n Footer?: ComponentType | undefined;\n }\n | undefined;\n};\n\nexport type BranchPickerConfig = {\n allowBranchPicker?: boolean | undefined;\n};\n\nexport type ComposerConfig = {\n allowAttachments?: boolean | undefined;\n};\n\nexport type StringsConfig = {\n assistantModal?: {\n open: {\n button: {\n tooltip?: string | undefined;\n };\n };\n closed: {\n button: {\n tooltip?: string | undefined;\n };\n };\n };\n threadList?: {\n new?: {\n label?: string | undefined;\n };\n item?: {\n title?: {\n fallback?: string | undefined;\n };\n archive?: {\n tooltip?: string | undefined;\n };\n };\n };\n thread?: {\n scrollToBottom?: {\n tooltip?: string | undefined;\n };\n };\n welcome?: {\n message?: string | undefined;\n };\n userMessage?: {\n edit?: {\n tooltip?: string | undefined;\n };\n };\n assistantMessage?: {\n reload?: {\n tooltip?: string | undefined;\n };\n copy?: {\n tooltip?: string | undefined;\n };\n speak?: {\n tooltip?: string | undefined;\n stop?: {\n tooltip?: string | undefined;\n };\n };\n feedback?: {\n positive?: {\n tooltip?: string | undefined;\n };\n negative?: {\n tooltip?: string | undefined;\n };\n };\n };\n branchPicker?: {\n previous?: {\n tooltip?: string | undefined;\n };\n next?: {\n tooltip?: string | undefined;\n };\n };\n composer?: {\n send?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n cancel?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n addAttachment?:\n | {\n tooltip?: string | undefined;\n }\n | undefined;\n removeAttachment?: {\n tooltip?: string | undefined;\n };\n input?: {\n placeholder?: string | undefined;\n };\n };\n editComposer?: {\n send?: {\n label?: string | undefined;\n };\n cancel?: {\n label?: string | undefined;\n };\n };\n code?: {\n header?: {\n copy?: {\n tooltip?: string | undefined;\n };\n };\n };\n};\n\nconst ThreadConfigContext = createContext<ThreadConfig>({});\n\nexport type ThreadConfig = {\n runtime?: AssistantRuntime | undefined;\n\n assistantAvatar?: AvatarProps | undefined;\n\n welcome?: ThreadWelcomeConfig | undefined;\n assistantMessage?: AssistantMessageConfig | undefined;\n userMessage?: UserMessageConfig | undefined;\n\n branchPicker?: BranchPickerConfig | undefined;\n\n composer?: ComposerConfig | undefined;\n\n strings?: StringsConfig | undefined;\n\n tools?: AssistantToolUI[] | undefined; // TODO add AssistantTool support\n\n components?:\n | {\n UserMessage?: ComponentType | undefined;\n AssistantMessage?: ComponentType | undefined;\n EditComposer?: ComponentType | undefined;\n Composer?: ComponentType | undefined;\n ThreadWelcome?: ComponentType | undefined;\n }\n | undefined;\n};\n\nexport const useThreadConfig = (): Omit<ThreadConfig, \"runtime\"> => {\n return useContext(ThreadConfigContext);\n};\n\nexport type ThreadConfigProviderProps = PropsWithChildren<{\n config?: ThreadConfig | undefined;\n}>;\n\nexport const ThreadConfigProvider: FC<ThreadConfigProviderProps> = ({\n children,\n config,\n}) => {\n const hasAssistant = !!useAssistantRuntime({ optional: true });\n\n const hasConfig = config && Object.keys(config).length > 0;\n const outerConfig = useThreadConfig();\n\n if (hasConfig && Object.keys(outerConfig).length > 0) {\n throw new Error(\n \"You are providing ThreadConfig to several nested components. Please provide all configuration to the same component.\",\n );\n }\n\n const configProvider = hasConfig ? (\n <ThreadConfigContext.Provider value={config}>\n {children}\n </ThreadConfigContext.Provider>\n ) : (\n <>{children}</>\n );\n\n if (!config?.runtime) return configProvider;\n\n if (hasAssistant) {\n throw new Error(\n \"You provided a runtime to <Thread> while simulataneously using <AssistantRuntimeProvider>. This is not allowed.\",\n );\n }\n return (\n <AssistantRuntimeProvider runtime={config.runtime}>\n {configProvider}\n </AssistantRuntimeProvider>\n );\n};\n\nThreadConfigProvider.displayName = \"ThreadConfigProvider\";\n"],"mappings":";;;AAEA;AAAA,EAKE;AAAA,EACA;AAAA,OACK;AASP,SAAS,gCAAgC;AAEzC,SAAS,2BAA2B;AA2MhC,SAIA,UAJA;AAtDJ,IAAM,sBAAsB,cAA4B,CAAC,CAAC;AA8BnD,IAAM,kBAAkB,MAAqC;AAClE,SAAO,WAAW,mBAAmB;AACvC;AAMO,IAAM,uBAAsD,CAAC;AAAA,EAClE;AAAA,EACA;AACF,MAAM;AACJ,QAAM,eAAe,CAAC,CAAC,oBAAoB,EAAE,UAAU,KAAK,CAAC;AAE7D,QAAM,YAAY,UAAU,OAAO,KAAK,MAAM,EAAE,SAAS;AACzD,QAAM,cAAc,gBAAgB;AAEpC,MAAI,aAAa,OAAO,KAAK,WAAW,EAAE,SAAS,GAAG;AACpD,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,QAAM,iBAAiB,YACrB,oBAAC,oBAAoB,UAApB,EAA6B,OAAO,QAClC,UACH,IAEA,gCAAG,UAAS;AAGd,MAAI,CAAC,QAAQ,QAAS,QAAO;AAE7B,MAAI,cAAc;AAChB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AACA,SACE,oBAAC,4BAAyB,SAAS,OAAO,SACvC,0BACH;AAEJ;AAEA,qBAAqB,cAAc;","names":[]}
package/package.json CHANGED
@@ -29,7 +29,7 @@
29
29
  "conversational-ui",
30
30
  "conversational-ai"
31
31
  ],
32
- "version": "0.7.43",
32
+ "version": "0.7.45",
33
33
  "license": "MIT",
34
34
  "exports": {
35
35
  ".": {
@@ -1,5 +1,4 @@
1
1
  import { AssistantRuntimeCore } from "../runtimes/core/AssistantRuntimeCore";
2
- import { NestedSubscriptionSubject } from "./subscribable/NestedSubscriptionSubject";
3
2
  import { ModelConfigProvider } from "../types/ModelConfigTypes";
4
3
  import {
5
4
  ThreadListItemRuntimeBinding,
@@ -12,17 +11,24 @@ import { ThreadListRuntime, ThreadListRuntimeImpl } from "./ThreadListRuntime";
12
11
 
13
12
  export type AssistantRuntime = {
14
13
  /**
15
- * The currently selected main thread.
14
+ * The threads in this assistant.
15
+ */
16
+ readonly threads: ThreadListRuntime;
17
+
18
+ /**
19
+ * The currently selected main thread. Equivalent to `threads.main`.
16
20
  */
17
21
  readonly thread: ThreadRuntime;
18
22
 
19
23
  /**
20
- * The thread manager, to rename, archive and delete threads.
24
+ * @deprecated This field was renamed to `threads.main`.
21
25
  */
22
26
  readonly threadList: ThreadListRuntime;
23
27
 
24
28
  /**
25
29
  * Switch to a new thread.
30
+ *
31
+ * @deprecated This field was moved to `threads.switchToNewThread`.
26
32
  */
27
33
  switchToNewThread(): void;
28
34
 
@@ -30,6 +36,7 @@ export type AssistantRuntime = {
30
36
  * Switch to a thread.
31
37
  *
32
38
  * @param threadId The thread ID to switch to.
39
+ * @deprecated This field was moved to `threads.switchToThread`.
33
40
  */
34
41
  switchToThread(threadId: string): void;
35
42
 
@@ -42,7 +49,11 @@ export type AssistantRuntime = {
42
49
  };
43
50
 
44
51
  export class AssistantRuntimeImpl implements AssistantRuntime {
45
- public readonly threadList;
52
+ public readonly threads;
53
+ public get threadList() {
54
+ return this.threads;
55
+ }
56
+
46
57
  public readonly _thread: ThreadRuntime;
47
58
 
48
59
  protected constructor(
@@ -52,18 +63,8 @@ export class AssistantRuntimeImpl implements AssistantRuntime {
52
63
  threadListItemBinding: ThreadListItemRuntimeBinding,
53
64
  ) => ThreadRuntime = ThreadRuntimeImpl,
54
65
  ) {
55
- this.threadList = new ThreadListRuntimeImpl(_core.threadList);
56
- this._thread = new runtimeFactory(
57
- new NestedSubscriptionSubject({
58
- path: {
59
- ref: "threads.main",
60
- threadSelector: { type: "main" },
61
- },
62
- getState: () => _core.threadList.getMainThreadRuntimeCore(),
63
- subscribe: (callback) => _core.threadList.subscribe(callback),
64
- }),
65
- this.threadList.mainItem, // TODO capture "main" threadListItem from context around useLocalRuntime / useExternalStoreRuntime
66
- );
66
+ this.threads = new ThreadListRuntimeImpl(_core.threads, runtimeFactory);
67
+ this._thread = this.threadList.main;
67
68
  }
68
69
 
69
70
  public get thread() {
@@ -71,11 +72,11 @@ export class AssistantRuntimeImpl implements AssistantRuntime {
71
72
  }
72
73
 
73
74
  public switchToNewThread() {
74
- return this._core.threadList.switchToNewThread();
75
+ return this._core.threads.switchToNewThread();
75
76
  }
76
77
 
77
78
  public switchToThread(threadId: string) {
78
- return this._core.threadList.switchToThread(threadId);
79
+ return this._core.threads.switchToThread(threadId);
79
80
  }
80
81
 
81
82
  public registerModelConfigProvider(provider: ModelConfigProvider) {
@@ -9,7 +9,12 @@ export type ThreadListItemRuntimePath = {
9
9
 
10
10
  export type ThreadRuntimePath = {
11
11
  readonly ref: string;
12
- readonly threadSelector: { type: "main" };
12
+ readonly threadSelector:
13
+ | { readonly type: "main" }
14
+ | {
15
+ readonly type: "threadId";
16
+ readonly threadId: string;
17
+ };
13
18
  };
14
19
 
15
20
  export type MessageRuntimePath = ThreadRuntimePath & {
@@ -25,6 +25,7 @@ export type ThreadListItemRuntime = {
25
25
  readonly path: ThreadListItemRuntimePath;
26
26
  getState(): ThreadListItemState;
27
27
 
28
+ initialize(): Promise<{ remoteId: string; externalId: string | undefined }>;
28
29
  switchTo(): Promise<void>;
29
30
  rename(newTitle: string): Promise<void>;
30
31
  archive(): Promise<void>;
@@ -87,6 +88,14 @@ export class ThreadListItemRuntimeImpl implements ThreadListItemRuntime {
87
88
  return this._threadListBinding.delete(state.id);
88
89
  }
89
90
 
91
+ public initialize(): Promise<{
92
+ remoteId: string;
93
+ externalId: string | undefined;
94
+ }> {
95
+ const state = this._core.getState();
96
+ return this._threadListBinding.initialize(state.id);
97
+ }
98
+
90
99
  public unstable_on(event: ThreadListItemEventType, callback: () => void) {
91
100
  let prevIsMain = this._core.getState().isMain;
92
101
  return this.subscribe(() => {
@@ -8,6 +8,13 @@ import {
8
8
  } from "./ThreadListItemRuntime";
9
9
  import { SKIP_UPDATE } from "./subscribable/SKIP_UPDATE";
10
10
  import { ShallowMemoizeSubject } from "./subscribable/ShallowMemoizeSubject";
11
+ import {
12
+ ThreadListItemRuntimeBinding,
13
+ ThreadRuntime,
14
+ ThreadRuntimeCoreBinding,
15
+ ThreadRuntimeImpl,
16
+ } from "./ThreadRuntime";
17
+ import { NestedSubscriptionSubject } from "./subscribable/NestedSubscriptionSubject";
11
18
 
12
19
  export type ThreadListState = {
13
20
  readonly mainThreadId: string;
@@ -21,10 +28,16 @@ export type ThreadListRuntime = {
21
28
 
22
29
  subscribe(callback: () => void): Unsubscribe;
23
30
 
31
+ readonly main: ThreadRuntime;
32
+ getById(threadId: string): ThreadRuntime;
33
+
24
34
  readonly mainItem: ThreadListItemRuntime;
25
35
  getItemById(threadId: string): ThreadListItemRuntime;
26
36
  getItemByIndex(idx: number): ThreadListItemRuntime;
27
37
  getArchivedItemByIndex(idx: number): ThreadListItemRuntime;
38
+
39
+ switchToThread(threadId: string): Promise<void>;
40
+ switchToNewThread(): Promise<void>;
28
41
  };
29
42
 
30
43
  const getThreadListState = (
@@ -61,7 +74,13 @@ export type ThreadListRuntimeCoreBinding = ThreadListRuntimeCore;
61
74
 
62
75
  export class ThreadListRuntimeImpl implements ThreadListRuntime {
63
76
  private _getState;
64
- constructor(private _core: ThreadListRuntimeCoreBinding) {
77
+ constructor(
78
+ private _core: ThreadListRuntimeCoreBinding,
79
+ private _runtimeFactory: new (
80
+ binding: ThreadRuntimeCoreBinding,
81
+ threadListItemBinding: ThreadListItemRuntimeBinding,
82
+ ) => ThreadRuntime = ThreadRuntimeImpl,
83
+ ) {
65
84
  const stateBinding = new LazyMemoizeSubject({
66
85
  path: {},
67
86
  getState: () => getThreadListState(_core),
@@ -83,6 +102,26 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
83
102
  }),
84
103
  this._core,
85
104
  );
105
+
106
+ this.main = new _runtimeFactory(
107
+ new NestedSubscriptionSubject({
108
+ path: {
109
+ ref: "threads.main",
110
+ threadSelector: { type: "main" },
111
+ },
112
+ getState: () => _core.getMainThreadRuntimeCore(),
113
+ subscribe: (callback) => _core.subscribe(callback),
114
+ }),
115
+ this._mainThreadListItemRuntime, // TODO capture "main" threadListItem from context around useLocalRuntime / useExternalStoreRuntime
116
+ );
117
+ }
118
+
119
+ public switchToThread(threadId: string): Promise<void> {
120
+ return this._core.switchToThread(threadId);
121
+ }
122
+
123
+ public switchToNewThread(): Promise<void> {
124
+ return this._core.switchToNewThread();
86
125
  }
87
126
 
88
127
  public getState(): ThreadListState {
@@ -95,10 +134,26 @@ export class ThreadListRuntimeImpl implements ThreadListRuntime {
95
134
 
96
135
  private _mainThreadListItemRuntime;
97
136
 
137
+ public readonly main: ThreadRuntime;
138
+
98
139
  public get mainItem() {
99
140
  return this._mainThreadListItemRuntime;
100
141
  }
101
142
 
143
+ public getById(threadId: string) {
144
+ return new this._runtimeFactory(
145
+ new NestedSubscriptionSubject({
146
+ path: {
147
+ ref: "threads[threadId=" + JSON.stringify(threadId) + "]",
148
+ threadSelector: { type: "threadId", threadId },
149
+ },
150
+ getState: () => this._core.getThreadRuntimeCore(threadId),
151
+ subscribe: (callback) => this._core.subscribe(callback),
152
+ }),
153
+ this.mainItem, // TODO capture "main" threadListItem from context around useLocalRuntime / useExternalStoreRuntime
154
+ );
155
+ }
156
+
102
157
  public getItemByIndex(idx: number) {
103
158
  return new ThreadListItemRuntimeImpl(
104
159
  new ShallowMemoizeSubject({
@@ -0,0 +1,31 @@
1
+ import { createContext, FC, useContext } from "react";
2
+ import { ThreadHistoryAdapter } from "./thread-history/ThreadHistoryAdapter";
3
+
4
+ export type RuntimeAdapters = {
5
+ history: ThreadHistoryAdapter;
6
+ };
7
+
8
+ const RuntimeAdaptersContext = createContext<RuntimeAdapters | null>(null);
9
+
10
+ namespace RuntimeAdapterProvider {
11
+ export type Props = {
12
+ adapters: RuntimeAdapters;
13
+ children: React.ReactNode;
14
+ };
15
+ }
16
+
17
+ export const RuntimeAdapterProvider: FC<RuntimeAdapterProvider.Props> = ({
18
+ adapters,
19
+ children,
20
+ }) => {
21
+ return (
22
+ <RuntimeAdaptersContext.Provider value={adapters}>
23
+ {children}
24
+ </RuntimeAdaptersContext.Provider>
25
+ );
26
+ };
27
+
28
+ export const useRuntimeAdapters = () => {
29
+ const adapters = useContext(RuntimeAdaptersContext);
30
+ return adapters;
31
+ };
@@ -2,7 +2,7 @@ import {
2
2
  Attachment,
3
3
  PendingAttachment,
4
4
  CompleteAttachment,
5
- } from "../../types/AttachmentTypes";
5
+ } from "../../../types/AttachmentTypes";
6
6
 
7
7
  export type AttachmentAdapter = {
8
8
  accept: string;
@@ -1,4 +1,4 @@
1
- import { Attachment, PendingAttachment } from "../../types/AttachmentTypes";
1
+ import { Attachment, PendingAttachment } from "../../../types/AttachmentTypes";
2
2
  import { AttachmentAdapter } from "./AttachmentAdapter";
3
3
 
4
4
  function fileMatchesAccept(
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PendingAttachment,
3
3
  CompleteAttachment,
4
- } from "../../types/AttachmentTypes";
4
+ } from "../../../types/AttachmentTypes";
5
5
  import { AttachmentAdapter } from "./AttachmentAdapter";
6
6
 
7
7
  export class SimpleImageAttachmentAdapter implements AttachmentAdapter {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  CompleteAttachment,
3
3
  PendingAttachment,
4
- } from "../../types/AttachmentTypes";
4
+ } from "../../../types/AttachmentTypes";
5
5
  import { AttachmentAdapter } from "./AttachmentAdapter";
6
6
 
7
7
  export class SimpleTextAttachmentAdapter implements AttachmentAdapter {
@@ -1,4 +1,4 @@
1
- import { ThreadMessage } from "../../types/AssistantTypes";
1
+ import { ThreadMessage } from "../../../types/AssistantTypes";
2
2
 
3
3
  type FeedbackAdapterFeedback = {
4
4
  message: ThreadMessage;
@@ -0,0 +1,3 @@
1
+ export * from "./attachment";
2
+ export * from "./feedback";
3
+ export * from "./speech";
@@ -1,4 +1,4 @@
1
- import { Unsubscribe } from "../../types";
1
+ import { Unsubscribe } from "../../../types";
2
2
 
3
3
  export namespace SpeechSynthesisAdapter {
4
4
  export type Status =
@@ -0,0 +1,9 @@
1
+ import {
2
+ ExportedMessageRepository,
3
+ ExportedMessageRepositoryItem,
4
+ } from "../../utils/MessageRepository";
5
+
6
+ export type ThreadHistoryAdapter = {
7
+ load(): Promise<ExportedMessageRepository>;
8
+ append(item: ExportedMessageRepositoryItem): Promise<void>;
9
+ };
@@ -4,7 +4,7 @@ import {
4
4
  PendingAttachment,
5
5
  } from "../../types/AttachmentTypes";
6
6
  import { AppendMessage } from "../../types";
7
- import { AttachmentAdapter } from "../attachment";
7
+ import { AttachmentAdapter } from "../adapters/attachment";
8
8
  import {
9
9
  ComposerRuntimeCore,
10
10
  ComposerRuntimeEventType,
@@ -1,6 +1,6 @@
1
1
  import { AppendMessage, ThreadMessage } from "../../types";
2
2
  import { getThreadMessageText } from "../../utils/getThreadMessageText";
3
- import { AttachmentAdapter } from "../attachment";
3
+ import { AttachmentAdapter } from "../adapters/attachment";
4
4
  import { ThreadRuntimeCore } from "../core/ThreadRuntimeCore";
5
5
  import { BaseComposerRuntimeCore } from "./BaseComposerRuntimeCore";
6
6
 
@@ -1,5 +1,5 @@
1
1
  import { AppendMessage, PendingAttachment } from "../../types";
2
- import { AttachmentAdapter } from "../attachment";
2
+ import { AttachmentAdapter } from "../adapters/attachment";
3
3
  import { ThreadComposerRuntimeCore } from "../core/ComposerRuntimeCore";
4
4
  import { ThreadRuntimeCore } from "../core/ThreadRuntimeCore";
5
5
  import { BaseComposerRuntimeCore } from "./BaseComposerRuntimeCore";
@@ -4,7 +4,7 @@ import type { Unsubscribe } from "../../types/Unsubscribe";
4
4
  import { ThreadListRuntimeCore } from "./ThreadListRuntimeCore";
5
5
 
6
6
  export type AssistantRuntimeCore = {
7
- readonly threadList: ThreadListRuntimeCore;
7
+ readonly threads: ThreadListRuntimeCore;
8
8
 
9
9
  registerModelConfigProvider: (provider: ModelConfigProvider) => Unsubscribe;
10
10
 
@@ -6,7 +6,7 @@ import { ThreadListRuntimeCore } from "./ThreadListRuntimeCore";
6
6
 
7
7
  export abstract class BaseAssistantRuntimeCore implements AssistantRuntimeCore {
8
8
  protected readonly _proxyConfigProvider = new ProxyConfigProvider();
9
- public abstract get threadList(): ThreadListRuntimeCore;
9
+ public abstract get threads(): ThreadListRuntimeCore;
10
10
 
11
11
  constructor() {}
12
12
 
@@ -20,9 +20,9 @@ import {
20
20
  StartRunConfig,
21
21
  } from "../core/ThreadRuntimeCore";
22
22
  import { DefaultEditComposerRuntimeCore } from "../composer/DefaultEditComposerRuntimeCore";
23
- import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
24
- import { FeedbackAdapter } from "../feedback/FeedbackAdapter";
25
- import { AttachmentAdapter } from "../attachment";
23
+ import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
24
+ import { FeedbackAdapter } from "../adapters/feedback/FeedbackAdapter";
25
+ import { AttachmentAdapter } from "../adapters/attachment";
26
26
  import { getThreadMessageText } from "../../utils/getThreadMessageText";
27
27
 
28
28
  type BaseThreadAdapters = {
@@ -20,6 +20,8 @@ export type ThreadListRuntimeCore = {
20
20
  archivedThreadIds: readonly string[];
21
21
 
22
22
  getMainThreadRuntimeCore(): ThreadRuntimeCore;
23
+ getThreadRuntimeCore(threadId: string): ThreadRuntimeCore;
24
+
23
25
  getItemById(threadId: string): ThreadListItemCoreState | undefined;
24
26
 
25
27
  switchToThread(threadId: string): Promise<void>;
@@ -33,5 +35,9 @@ export type ThreadListRuntimeCore = {
33
35
  unarchive(threadId: string): Promise<void>;
34
36
  delete(threadId: string): Promise<void>;
35
37
 
38
+ initialize(
39
+ threadId: string,
40
+ ): Promise<{ remoteId: string; externalId: string | undefined }>;
41
+
36
42
  subscribe(callback: () => void): Unsubscribe;
37
43
  };
@@ -1,7 +1,7 @@
1
1
  import { AppendMessage, ModelConfig, ThreadMessage } from "../../types";
2
2
  import { RunConfig } from "../../types/AssistantTypes";
3
3
  import type { Unsubscribe } from "../../types/Unsubscribe";
4
- import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
4
+ import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
5
5
  import { ExportedMessageRepository } from "../utils/MessageRepository";
6
6
  import {
7
7
  ComposerRuntimeCore,
@@ -46,6 +46,7 @@ export type SubmittedFeedback = {
46
46
 
47
47
  export type ThreadRuntimeEventType =
48
48
  | "run-start"
49
+ | "run-end"
49
50
  | "initialize"
50
51
  | "model-config-update";
51
52
 
@@ -1,12 +1,12 @@
1
1
  import { AppendMessage, ThreadMessage } from "../../types";
2
- import { AttachmentAdapter } from "../attachment";
2
+ import { AttachmentAdapter } from "../adapters/attachment";
3
3
  import {
4
4
  AddToolResultOptions,
5
5
  StartRunConfig,
6
6
  ThreadSuggestion,
7
7
  } from "../core/ThreadRuntimeCore";
8
- import { FeedbackAdapter } from "../feedback/FeedbackAdapter";
9
- import { SpeechSynthesisAdapter } from "../speech/SpeechAdapterTypes";
8
+ import { FeedbackAdapter } from "../adapters/feedback/FeedbackAdapter";
9
+ import { SpeechSynthesisAdapter } from "../adapters/speech/SpeechAdapterTypes";
10
10
  import { ThreadMessageLike } from "./ThreadMessageLike";
11
11
 
12
12
  export type ExternalStoreThreadData<TState extends "regular" | "archived"> = {
@@ -10,11 +10,11 @@ const getThreadListAdapter = (store: ExternalStoreAdapter<any>) => {
10
10
  };
11
11
 
12
12
  export class ExternalStoreRuntimeCore extends BaseAssistantRuntimeCore {
13
- public readonly threadList;
13
+ public readonly threads;
14
14
 
15
15
  constructor(adapter: ExternalStoreAdapter<any>) {
16
16
  super();
17
- this.threadList = new ExternalStoreThreadListRuntimeCore(
17
+ this.threads = new ExternalStoreThreadListRuntimeCore(
18
18
  getThreadListAdapter(adapter),
19
19
  () =>
20
20
  new ExternalStoreThreadRuntimeCore(this._proxyConfigProvider, adapter),
@@ -23,7 +23,7 @@ export class ExternalStoreRuntimeCore extends BaseAssistantRuntimeCore {
23
23
 
24
24
  public setAdapter(adapter: ExternalStoreAdapter<any>) {
25
25
  // Update the thread list adapter and propagate store changes to the main thread
26
- this.threadList.__internal_setAdapter(getThreadListAdapter(adapter));
27
- this.threadList.getMainThreadRuntimeCore().__internal_setAdapter(adapter);
26
+ this.threads.__internal_setAdapter(getThreadListAdapter(adapter));
27
+ this.threads.getMainThreadRuntimeCore().__internal_setAdapter(adapter);
28
28
  }
29
29
  }
@@ -57,6 +57,10 @@ export class ExternalStoreThreadListRuntimeCore
57
57
  return this._mainThread;
58
58
  }
59
59
 
60
+ public getThreadRuntimeCore(): never {
61
+ throw new Error("Method not implemented.");
62
+ }
63
+
60
64
  public getItemById(threadId: string) {
61
65
  for (const thread of this.adapter.threads ?? []) {
62
66
  if (thread.threadId === threadId) return thread;
@@ -159,6 +163,10 @@ export class ExternalStoreThreadListRuntimeCore
159
163
  onDelete(threadId);
160
164
  }
161
165
 
166
+ public initialize(): never {
167
+ throw new Error("Method not implemented.");
168
+ }
169
+
162
170
  private _subscriptions = new Set<() => void>();
163
171
 
164
172
  public subscribe(callback: () => void): Unsubscribe {
@@ -146,6 +146,14 @@ export class ExternalStoreThreadRuntimeCore
146
146
 
147
147
  if (messages.length > 0) this.ensureInitialized();
148
148
 
149
+ if (oldStore?.isRunning ?? false !== store.isRunning ?? false) {
150
+ if (store.isRunning) {
151
+ this._notifyEventSubscribers("run-start");
152
+ } else {
153
+ this._notifyEventSubscribers("run-end");
154
+ }
155
+ }
156
+
149
157
  for (let i = 0; i < messages.length; i++) {
150
158
  const message = messages[i]!;
151
159
  const parent = messages[i - 1];
@@ -1,9 +1,7 @@
1
- export * from "./attachment";
1
+ export * from "./adapters";
2
2
  export * from "./core";
3
3
  export * from "./dangerous-in-browser";
4
4
  export * from "./edge";
5
5
  export * from "./external-store";
6
- export * from "./feedback";
7
6
  export * from "./local";
8
7
  export * from "./remote-thread-list";
9
- export * from "./speech";
@@ -25,7 +25,7 @@ const getExportFromInitialMessages = (
25
25
  };
26
26
 
27
27
  export class LocalRuntimeCore extends BaseAssistantRuntimeCore {
28
- public readonly threadList;
28
+ public readonly threads;
29
29
  public readonly Provider = undefined;
30
30
 
31
31
  private _options: LocalRuntimeOptionsBase;
@@ -38,7 +38,7 @@ export class LocalRuntimeCore extends BaseAssistantRuntimeCore {
38
38
 
39
39
  this._options = options;
40
40
 
41
- this.threadList = new LocalThreadListRuntimeCore(() => {
41
+ this.threads = new LocalThreadListRuntimeCore(() => {
42
42
  return new LocalThreadRuntimeCore(
43
43
  this._proxyConfigProvider,
44
44
  this._options,
@@ -46,7 +46,7 @@ export class LocalRuntimeCore extends BaseAssistantRuntimeCore {
46
46
  });
47
47
 
48
48
  if (initialMessages) {
49
- this.threadList
49
+ this.threads
50
50
  .getMainThreadRuntimeCore()
51
51
  .import(getExportFromInitialMessages(initialMessages));
52
52
  }
@@ -57,10 +57,10 @@ export class LocalRuntimeCore extends BaseAssistantRuntimeCore {
57
57
  }: {
58
58
  initialMessages?: readonly CoreMessage[] | undefined;
59
59
  } = {}) {
60
- this.threadList.switchToNewThread();
60
+ this.threads.switchToNewThread();
61
61
  if (!initialMessages) return;
62
62
 
63
- this.threadList
63
+ this.threads
64
64
  .getMainThreadRuntimeCore()
65
65
  .import(getExportFromInitialMessages(initialMessages));
66
66
  }