@assistant-ui/react 0.5.98 → 0.5.100

Sign up to get free protection for your applications and to get access to all the features.
Files changed (273) hide show
  1. package/dist/api/AssistantRuntime.d.ts +4 -4
  2. package/dist/api/AssistantRuntime.d.ts.map +1 -1
  3. package/dist/api/AssistantRuntime.js +7 -7
  4. package/dist/api/AssistantRuntime.js.map +1 -1
  5. package/dist/api/AssistantRuntime.mjs +7 -9
  6. package/dist/api/AssistantRuntime.mjs.map +1 -1
  7. package/dist/api/ComposerRuntime.d.ts +7 -0
  8. package/dist/api/ComposerRuntime.d.ts.map +1 -1
  9. package/dist/api/ComposerRuntime.js +13 -0
  10. package/dist/api/ComposerRuntime.js.map +1 -1
  11. package/dist/api/ComposerRuntime.mjs +13 -0
  12. package/dist/api/ComposerRuntime.mjs.map +1 -1
  13. package/dist/api/MessageRuntime.d.ts.map +1 -1
  14. package/dist/api/MessageRuntime.js +0 -5
  15. package/dist/api/MessageRuntime.js.map +1 -1
  16. package/dist/api/MessageRuntime.mjs +0 -5
  17. package/dist/api/MessageRuntime.mjs.map +1 -1
  18. package/dist/api/RuntimePathTypes.d.ts +16 -1
  19. package/dist/api/RuntimePathTypes.d.ts.map +1 -1
  20. package/dist/api/RuntimePathTypes.js.map +1 -1
  21. package/dist/api/ThreadListItemRuntime.d.ts +29 -0
  22. package/dist/api/ThreadListItemRuntime.d.ts.map +1 -0
  23. package/dist/api/ThreadListItemRuntime.js +61 -0
  24. package/dist/api/ThreadListItemRuntime.js.map +1 -0
  25. package/dist/api/ThreadListItemRuntime.mjs +36 -0
  26. package/dist/api/ThreadListItemRuntime.mjs.map +1 -0
  27. package/dist/api/ThreadListRuntime.d.ts +51 -0
  28. package/dist/api/ThreadListRuntime.d.ts.map +1 -0
  29. package/dist/api/ThreadListRuntime.js +128 -0
  30. package/dist/api/ThreadListRuntime.js.map +1 -0
  31. package/dist/api/ThreadListRuntime.mjs +105 -0
  32. package/dist/api/ThreadListRuntime.mjs.map +1 -0
  33. package/dist/api/ThreadRuntime.d.ts +3 -0
  34. package/dist/api/ThreadRuntime.d.ts.map +1 -1
  35. package/dist/api/ThreadRuntime.js +1 -1
  36. package/dist/api/ThreadRuntime.js.map +1 -1
  37. package/dist/api/ThreadRuntime.mjs +1 -1
  38. package/dist/api/ThreadRuntime.mjs.map +1 -1
  39. package/dist/api/index.d.ts +1 -1
  40. package/dist/api/index.d.ts.map +1 -1
  41. package/dist/api/index.js.map +1 -1
  42. package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
  43. package/dist/context/providers/AssistantRuntimeProvider.js +7 -9
  44. package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
  45. package/dist/context/providers/AssistantRuntimeProvider.mjs +7 -9
  46. package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
  47. package/dist/context/providers/AttachmentRuntimeProvider.d.ts +6 -5
  48. package/dist/context/providers/AttachmentRuntimeProvider.d.ts.map +1 -1
  49. package/dist/context/providers/AttachmentRuntimeProvider.js.map +1 -1
  50. package/dist/context/providers/AttachmentRuntimeProvider.mjs.map +1 -1
  51. package/dist/context/providers/ContentPartRuntimeProvider.d.ts +6 -5
  52. package/dist/context/providers/ContentPartRuntimeProvider.d.ts.map +1 -1
  53. package/dist/context/providers/ContentPartRuntimeProvider.js +1 -4
  54. package/dist/context/providers/ContentPartRuntimeProvider.js.map +1 -1
  55. package/dist/context/providers/ContentPartRuntimeProvider.mjs +1 -4
  56. package/dist/context/providers/ContentPartRuntimeProvider.mjs.map +1 -1
  57. package/dist/context/providers/MessageRuntimeProvider.d.ts +6 -5
  58. package/dist/context/providers/MessageRuntimeProvider.d.ts.map +1 -1
  59. package/dist/context/providers/MessageRuntimeProvider.js.map +1 -1
  60. package/dist/context/providers/MessageRuntimeProvider.mjs.map +1 -1
  61. package/dist/context/providers/TextContentPartProvider.d.ts +7 -6
  62. package/dist/context/providers/TextContentPartProvider.d.ts.map +1 -1
  63. package/dist/context/providers/TextContentPartProvider.js +5 -1
  64. package/dist/context/providers/TextContentPartProvider.js.map +1 -1
  65. package/dist/context/providers/TextContentPartProvider.mjs +5 -1
  66. package/dist/context/providers/TextContentPartProvider.mjs.map +1 -1
  67. package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts +13 -0
  68. package/dist/context/providers/ThreadListItemRuntimeProvider.d.ts.map +1 -0
  69. package/dist/context/providers/ThreadListItemRuntimeProvider.js +62 -0
  70. package/dist/context/providers/ThreadListItemRuntimeProvider.js.map +1 -0
  71. package/dist/context/providers/ThreadListItemRuntimeProvider.mjs +39 -0
  72. package/dist/context/providers/ThreadListItemRuntimeProvider.mjs.map +1 -0
  73. package/dist/context/react/AssistantContext.d.ts +35 -11
  74. package/dist/context/react/AssistantContext.d.ts.map +1 -1
  75. package/dist/context/react/AssistantContext.js +4 -4
  76. package/dist/context/react/AssistantContext.js.map +1 -1
  77. package/dist/context/react/AssistantContext.mjs +3 -3
  78. package/dist/context/react/AssistantContext.mjs.map +1 -1
  79. package/dist/context/react/ThreadListItemContext.d.ts +58 -0
  80. package/dist/context/react/ThreadListItemContext.d.ts.map +1 -0
  81. package/dist/context/react/ThreadListItemContext.js +53 -0
  82. package/dist/context/react/ThreadListItemContext.js.map +1 -0
  83. package/dist/context/react/ThreadListItemContext.mjs +25 -0
  84. package/dist/context/react/ThreadListItemContext.mjs.map +1 -0
  85. package/dist/context/react/index.d.ts +1 -1
  86. package/dist/context/react/index.d.ts.map +1 -1
  87. package/dist/context/react/index.js +2 -2
  88. package/dist/context/react/index.js.map +1 -1
  89. package/dist/context/react/index.mjs +2 -2
  90. package/dist/context/react/index.mjs.map +1 -1
  91. package/dist/internal.d.ts +1 -1
  92. package/dist/internal.d.ts.map +1 -1
  93. package/dist/internal.js.map +1 -1
  94. package/dist/internal.mjs.map +1 -1
  95. package/dist/primitives/index.d.ts +2 -0
  96. package/dist/primitives/index.d.ts.map +1 -1
  97. package/dist/primitives/index.js +6 -0
  98. package/dist/primitives/index.js.map +1 -1
  99. package/dist/primitives/index.mjs +4 -0
  100. package/dist/primitives/index.mjs.map +1 -1
  101. package/dist/primitives/threadList/ThreadListItems.d.ts +11 -0
  102. package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -0
  103. package/dist/primitives/threadList/ThreadListItems.js +72 -0
  104. package/dist/primitives/threadList/ThreadListItems.js.map +1 -0
  105. package/dist/primitives/threadList/ThreadListItems.mjs +48 -0
  106. package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -0
  107. package/dist/primitives/threadList/ThreadListNew.d.ts +13 -0
  108. package/dist/primitives/threadList/ThreadListNew.d.ts.map +1 -0
  109. package/dist/primitives/threadList/ThreadListNew.js +43 -0
  110. package/dist/primitives/threadList/ThreadListNew.js.map +1 -0
  111. package/dist/primitives/threadList/ThreadListNew.mjs +21 -0
  112. package/dist/primitives/threadList/ThreadListNew.mjs.map +1 -0
  113. package/dist/primitives/threadList/index.d.ts +3 -0
  114. package/dist/primitives/threadList/index.d.ts.map +1 -0
  115. package/dist/primitives/threadList/index.js +34 -0
  116. package/dist/primitives/threadList/index.js.map +1 -0
  117. package/dist/primitives/threadList/index.mjs +8 -0
  118. package/dist/primitives/threadList/index.mjs.map +1 -0
  119. package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts +13 -0
  120. package/dist/primitives/threadListItem/ThreadListItemArchive.d.ts.map +1 -0
  121. package/dist/primitives/threadListItem/ThreadListItemArchive.js +43 -0
  122. package/dist/primitives/threadListItem/ThreadListItemArchive.js.map +1 -0
  123. package/dist/primitives/threadListItem/ThreadListItemArchive.mjs +21 -0
  124. package/dist/primitives/threadListItem/ThreadListItemArchive.mjs.map +1 -0
  125. package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts +13 -0
  126. package/dist/primitives/threadListItem/ThreadListItemDelete.d.ts.map +1 -0
  127. package/dist/primitives/threadListItem/ThreadListItemDelete.js +43 -0
  128. package/dist/primitives/threadListItem/ThreadListItemDelete.js.map +1 -0
  129. package/dist/primitives/threadListItem/ThreadListItemDelete.mjs +21 -0
  130. package/dist/primitives/threadListItem/ThreadListItemDelete.mjs.map +1 -0
  131. package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts +13 -0
  132. package/dist/primitives/threadListItem/ThreadListItemUnarchive.d.ts.map +1 -0
  133. package/dist/primitives/threadListItem/ThreadListItemUnarchive.js +43 -0
  134. package/dist/primitives/threadListItem/ThreadListItemUnarchive.js.map +1 -0
  135. package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs +21 -0
  136. package/dist/primitives/threadListItem/ThreadListItemUnarchive.mjs.map +1 -0
  137. package/dist/primitives/threadListItem/index.d.ts +4 -0
  138. package/dist/primitives/threadListItem/index.d.ts.map +1 -0
  139. package/dist/primitives/threadListItem/index.js +37 -0
  140. package/dist/primitives/threadListItem/index.js.map +1 -0
  141. package/dist/primitives/threadListItem/index.mjs +10 -0
  142. package/dist/primitives/threadListItem/index.mjs.map +1 -0
  143. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +5 -1
  144. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
  145. package/dist/runtimes/composer/BaseComposerRuntimeCore.js +14 -5
  146. package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
  147. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +14 -5
  148. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
  149. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  150. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +2 -1
  151. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  152. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +2 -1
  153. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
  154. package/dist/runtimes/core/AssistantRuntimeCore.d.ts +2 -2
  155. package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
  156. package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
  157. package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts +2 -2
  158. package/dist/runtimes/core/BaseAssistantRuntimeCore.d.ts.map +1 -1
  159. package/dist/runtimes/core/BaseAssistantRuntimeCore.js.map +1 -1
  160. package/dist/runtimes/core/BaseAssistantRuntimeCore.mjs.map +1 -1
  161. package/dist/runtimes/core/ComposerRuntimeCore.d.ts +3 -0
  162. package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
  163. package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
  164. package/dist/runtimes/core/{ThreadManagerRuntimeCore.d.ts → ThreadListRuntimeCore.d.ts} +7 -6
  165. package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -0
  166. package/dist/runtimes/core/{ThreadManagerRuntimeCore.js → ThreadListRuntimeCore.js} +4 -4
  167. package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -0
  168. package/dist/runtimes/core/ThreadListRuntimeCore.mjs +1 -0
  169. package/dist/runtimes/core/subscribeToMainThread.js +2 -2
  170. package/dist/runtimes/core/subscribeToMainThread.js.map +1 -1
  171. package/dist/runtimes/core/subscribeToMainThread.mjs +2 -2
  172. package/dist/runtimes/core/subscribeToMainThread.mjs.map +1 -1
  173. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +8 -8
  174. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
  175. package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
  176. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts +2 -2
  177. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.d.ts.map +1 -1
  178. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js +8 -8
  179. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.js.map +1 -1
  180. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs +8 -8
  181. package/dist/runtimes/external-store/ExternalStoreRuntimeCore.mjs.map +1 -1
  182. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +35 -0
  183. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -0
  184. package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.js → ExternalStoreThreadListRuntimeCore.js} +21 -9
  185. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -0
  186. package/dist/runtimes/external-store/{ExternalStoreThreadManagementAdapter.mjs → ExternalStoreThreadListRuntimeCore.mjs} +17 -5
  187. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -0
  188. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts +1 -1
  189. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.d.ts.map +1 -1
  190. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js +8 -3
  191. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.js.map +1 -1
  192. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs +8 -3
  193. package/dist/runtimes/external-store/ExternalStoreThreadRuntimeCore.mjs.map +1 -1
  194. package/dist/runtimes/local/LocalRuntimeCore.d.ts +2 -2
  195. package/dist/runtimes/local/LocalRuntimeCore.d.ts.map +1 -1
  196. package/dist/runtimes/local/LocalRuntimeCore.js +7 -7
  197. package/dist/runtimes/local/LocalRuntimeCore.js.map +1 -1
  198. package/dist/runtimes/local/LocalRuntimeCore.mjs +7 -7
  199. package/dist/runtimes/local/LocalRuntimeCore.mjs.map +1 -1
  200. package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.d.ts → LocalThreadListRuntimeCore.d.ts} +16 -6
  201. package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -0
  202. package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.js → LocalThreadListRuntimeCore.js} +11 -8
  203. package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -0
  204. package/dist/runtimes/local/{LocalThreadManagerRuntimeCore.mjs → LocalThreadListRuntimeCore.mjs} +7 -4
  205. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -0
  206. package/dist/runtimes/local/LocalThreadRuntimeCore.d.ts.map +1 -1
  207. package/dist/runtimes/local/LocalThreadRuntimeCore.js +2 -1
  208. package/dist/runtimes/local/LocalThreadRuntimeCore.js.map +1 -1
  209. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs +2 -1
  210. package/dist/runtimes/local/LocalThreadRuntimeCore.mjs.map +1 -1
  211. package/dist/types/AssistantTypes.d.ts +2 -0
  212. package/dist/types/AssistantTypes.d.ts.map +1 -1
  213. package/dist/types/AssistantTypes.js.map +1 -1
  214. package/package.json +7 -7
  215. package/src/api/AssistantRuntime.ts +9 -12
  216. package/src/api/ComposerRuntime.ts +17 -0
  217. package/src/api/MessageRuntime.ts +0 -9
  218. package/src/api/RuntimePathTypes.ts +10 -1
  219. package/src/api/ThreadListItemRuntime.ts +67 -0
  220. package/src/api/ThreadListRuntime.ts +159 -0
  221. package/src/api/ThreadRuntime.ts +2 -1
  222. package/src/api/index.ts +1 -4
  223. package/src/context/providers/AssistantRuntimeProvider.tsx +7 -9
  224. package/src/context/providers/AttachmentRuntimeProvider.tsx +6 -4
  225. package/src/context/providers/ContentPartRuntimeProvider.tsx +8 -7
  226. package/src/context/providers/MessageRuntimeProvider.tsx +6 -4
  227. package/src/context/providers/TextContentPartProvider.tsx +11 -7
  228. package/src/context/providers/ThreadListItemRuntimeProvider.tsx +54 -0
  229. package/src/context/react/AssistantContext.ts +4 -4
  230. package/src/context/react/ThreadListItemContext.ts +39 -0
  231. package/src/context/react/index.ts +2 -2
  232. package/src/internal.ts +1 -1
  233. package/src/primitives/index.ts +2 -0
  234. package/src/primitives/threadList/ThreadListItems.tsx +73 -0
  235. package/src/primitives/threadList/ThreadListNew.ts +25 -0
  236. package/src/primitives/threadList/index.ts +2 -0
  237. package/src/primitives/threadListItem/ThreadListItemArchive.ts +25 -0
  238. package/src/primitives/threadListItem/ThreadListItemDelete.ts +25 -0
  239. package/src/primitives/threadListItem/ThreadListItemUnarchive.ts +25 -0
  240. package/src/primitives/threadListItem/index.ts +3 -0
  241. package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +19 -5
  242. package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +3 -2
  243. package/src/runtimes/core/AssistantRuntimeCore.tsx +2 -2
  244. package/src/runtimes/core/BaseAssistantRuntimeCore.tsx +2 -2
  245. package/src/runtimes/core/ComposerRuntimeCore.tsx +4 -0
  246. package/src/runtimes/core/{ThreadManagerRuntimeCore.tsx → ThreadListRuntimeCore.tsx} +7 -5
  247. package/src/runtimes/core/subscribeToMainThread.ts +2 -2
  248. package/src/runtimes/external-store/ExternalStoreAdapter.tsx +8 -8
  249. package/src/runtimes/external-store/ExternalStoreRuntimeCore.tsx +8 -8
  250. package/src/runtimes/external-store/{ExternalStoreThreadManagementAdapter.tsx → ExternalStoreThreadListRuntimeCore.tsx} +24 -9
  251. package/src/runtimes/external-store/ExternalStoreThreadRuntimeCore.tsx +8 -3
  252. package/src/runtimes/local/LocalRuntimeCore.tsx +7 -7
  253. package/src/runtimes/local/{LocalThreadManagerRuntimeCore.tsx → LocalThreadListRuntimeCore.tsx} +11 -7
  254. package/src/runtimes/local/LocalThreadRuntimeCore.tsx +2 -1
  255. package/src/types/AssistantTypes.ts +3 -0
  256. package/dist/api/ThreadManagerRuntime.d.ts +0 -32
  257. package/dist/api/ThreadManagerRuntime.d.ts.map +0 -1
  258. package/dist/api/ThreadManagerRuntime.js +0 -73
  259. package/dist/api/ThreadManagerRuntime.js.map +0 -1
  260. package/dist/api/ThreadManagerRuntime.mjs +0 -48
  261. package/dist/api/ThreadManagerRuntime.mjs.map +0 -1
  262. package/dist/runtimes/core/ThreadManagerRuntimeCore.d.ts.map +0 -1
  263. package/dist/runtimes/core/ThreadManagerRuntimeCore.js.map +0 -1
  264. package/dist/runtimes/core/ThreadManagerRuntimeCore.mjs +0 -1
  265. package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts +0 -25
  266. package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.d.ts.map +0 -1
  267. package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.js.map +0 -1
  268. package/dist/runtimes/external-store/ExternalStoreThreadManagementAdapter.mjs.map +0 -1
  269. package/dist/runtimes/local/LocalThreadManagerRuntimeCore.d.ts.map +0 -1
  270. package/dist/runtimes/local/LocalThreadManagerRuntimeCore.js.map +0 -1
  271. package/dist/runtimes/local/LocalThreadManagerRuntimeCore.mjs.map +0 -1
  272. package/src/api/ThreadManagerRuntime.ts +0 -80
  273. /package/dist/runtimes/core/{ThreadManagerRuntimeCore.mjs.map → ThreadListRuntimeCore.mjs.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"ThreadManagerRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/core/ThreadManagerRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,MAAM,MAAM,qBAAqB,GAAG;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,UAAU,EAAE,iBAAiB,CAAC;IAE9B,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAC1C,eAAe,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAElD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,iBAAiB,IAAI,IAAI,CAAC;IAK1B,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;CAC9C,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtimes/core/ThreadManagerRuntimeCore.tsx"],"sourcesContent":["import { Unsubscribe } from \"../../types\";\nimport { ThreadRuntimeCore } from \"./ThreadRuntimeCore\";\n\nexport type ThreadManagerMetadata = {\n threadId: string;\n title?: string;\n};\n\nexport type ThreadManagerRuntimeCore = {\n mainThread: ThreadRuntimeCore;\n\n threads: readonly ThreadManagerMetadata[];\n archivedThreads: readonly ThreadManagerMetadata[];\n\n switchToThread(threadId: string): void;\n switchToNewThread(): void;\n\n // getLoadThreadsPromise(): Promise<void>;\n // getLoadArchivedThreadsPromise(): Promise<void>;\n // create(): Promise<ThreadMetadata>;\n rename(threadId: string, newTitle: string): Promise<void>;\n archive(threadId: string): Promise<void>;\n unarchive(threadId: string): Promise<void>;\n delete(threadId: string): Promise<void>;\n\n subscribe(callback: () => void): Unsubscribe;\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=ThreadManagerRuntimeCore.mjs.map
@@ -1,25 +0,0 @@
1
- import type { Unsubscribe } from "../../types";
2
- import { ExternalStoreThreadRuntimeCore } from "./ExternalStoreThreadRuntimeCore";
3
- import { ThreadManagerRuntimeCore } from "../core/ThreadManagerRuntimeCore";
4
- import { ExternalStoreThreadManagerAdapter } from "./ExternalStoreAdapter";
5
- export type ExternalStoreThreadFactory = (threadId: string) => ExternalStoreThreadRuntimeCore;
6
- export declare class ExternalStoreThreadManagerRuntimeCore implements ThreadManagerRuntimeCore {
7
- private adapter;
8
- private threadFactory;
9
- get threads(): readonly import("../core/ThreadManagerRuntimeCore").ThreadManagerMetadata[];
10
- get archivedThreads(): readonly import("../core/ThreadManagerRuntimeCore").ThreadManagerMetadata[];
11
- private _mainThread;
12
- get mainThread(): ExternalStoreThreadRuntimeCore;
13
- constructor(adapter: ExternalStoreThreadManagerAdapter | undefined, threadFactory: ExternalStoreThreadFactory);
14
- setAdapter(adapter: ExternalStoreThreadManagerAdapter): void;
15
- switchToThread(threadId: string): void;
16
- switchToNewThread(): void;
17
- rename(threadId: string, newTitle: string): Promise<void>;
18
- archive(threadId: string): Promise<void>;
19
- unarchive(threadId: string): Promise<void>;
20
- delete(threadId: string): Promise<void>;
21
- private _subscriptions;
22
- subscribe(callback: () => void): Unsubscribe;
23
- private _notifySubscribers;
24
- }
25
- //# sourceMappingURL=ExternalStoreThreadManagementAdapter.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ExternalStoreThreadManagementAdapter.d.ts","sourceRoot":"","sources":["../../../src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,8BAA8B,EAAE,MAAM,kCAAkC,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,MAAM,kCAAkC,CAAC;AAC5E,OAAO,EAAE,iCAAiC,EAAE,MAAM,wBAAwB,CAAC;AAE3E,MAAM,MAAM,0BAA0B,GAAG,CACvC,QAAQ,EAAE,MAAM,KACb,8BAA8B,CAAC;AAKpC,qBAAa,qCACX,YAAW,wBAAwB;IAiBjC,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,aAAa;IAhBvB,IAAW,OAAO,gFAEjB;IAED,IAAW,eAAe,gFAEzB;IAED,OAAO,CAAC,WAAW,CAAiC;IAEpD,IAAW,UAAU,mCAEpB;gBAGS,OAAO,EAAE,iCAAiC,YAAK,EAC/C,aAAa,EAAE,0BAA0B;IAK5C,UAAU,CAAC,OAAO,EAAE,iCAAiC;IAyBrD,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAUtC,iBAAiB,IAAI,IAAI;IAUnB,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQzD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQxC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ1C,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQpD,OAAO,CAAC,cAAc,CAAyB;IAExC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAKnD,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadManagerRuntimeCore } from \"../core/ThreadManagerRuntimeCore\";\nimport { ExternalStoreThreadManagerAdapter } from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = (\n threadId: string,\n) => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\n\nexport class ExternalStoreThreadManagerRuntimeCore\n implements ThreadManagerRuntimeCore\n{\n public get threads() {\n return this.adapter.threads ?? EMPTY_ARRAY;\n }\n\n public get archivedThreads() {\n return this.adapter.archivedThreads ?? EMPTY_ARRAY;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThread() {\n return this._mainThread;\n }\n\n constructor(\n private adapter: ExternalStoreThreadManagerAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory(DEFAULT_THREAD_ID);\n }\n\n public setAdapter(adapter: ExternalStoreThreadManagerAdapter) {\n const previousAdapter = this.adapter;\n this.adapter = adapter;\n\n const newThreadId = adapter.threadId ?? DEFAULT_THREAD_ID;\n const newThreads = adapter.threads ?? EMPTY_ARRAY;\n const newArchivedThreads = adapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousAdapter.threadId === newThreadId &&\n previousAdapter.threads === newThreads &&\n previousAdapter.archivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousAdapter.threadId !== newThreadId) {\n this._mainThread._notifyEventSubscribers(\"switched-away\");\n this._mainThread = this.threadFactory(newThreadId);\n this._mainThread._notifyEventSubscribers(\"switched-to\");\n }\n\n this._notifySubscribers();\n }\n\n public switchToThread(threadId: string): void {\n if (this._mainThread?.threadId === threadId) return;\n const onSwitchToThread = this.adapter.onSwitchToThread;\n if (!onSwitchToThread)\n throw new Error(\n \"External store adapter does not support switching to thread\",\n );\n onSwitchToThread(threadId);\n }\n\n public switchToNewThread(): void {\n const onSwitchToNewThread = this.adapter.onSwitchToNewThread;\n if (!onSwitchToNewThread)\n throw new Error(\n \"External store adapter does not support switching to new thread\",\n );\n\n onSwitchToNewThread();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const onRename = this.adapter.onRename;\n if (!onRename)\n throw new Error(\"External store adapter does not support renaming\");\n\n onRename(threadId, newTitle);\n }\n\n public async archive(threadId: string): Promise<void> {\n const onArchive = this.adapter.onArchive;\n if (!onArchive)\n throw new Error(\"External store adapter does not support archiving\");\n\n onArchive(threadId);\n }\n\n public async unarchive(threadId: string): Promise<void> {\n const onUnarchive = this.adapter.onUnarchive;\n if (!onUnarchive)\n throw new Error(\"External store adapter does not support unarchiving\");\n\n onUnarchive(threadId);\n }\n\n public async delete(threadId: string): Promise<void> {\n const onDelete = this.adapter.onDelete;\n if (!onDelete)\n throw new Error(\"External store adapter does not support deleting\");\n\n onDelete(threadId);\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AASA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAEnB,IAAM,wCAAN,MAEP;AAAA,EAeE,YACU,UAA6C,CAAC,GAC9C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc,iBAAiB;AAAA,EACzD;AAAA,EAnBA,IAAW,UAAU;AACnB,WAAO,KAAK,QAAQ,WAAW;AAAA,EACjC;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK,QAAQ,mBAAmB;AAAA,EACzC;AAAA,EAEQ;AAAA,EAER,IAAW,aAAa;AACtB,WAAO,KAAK;AAAA,EACd;AAAA,EASO,WAAW,SAA4C;AAC5D,UAAM,kBAAkB,KAAK;AAC7B,SAAK,UAAU;AAEf,UAAM,cAAc,QAAQ,YAAY;AACxC,UAAM,aAAa,QAAQ,WAAW;AACtC,UAAM,qBAAqB,QAAQ,mBAAmB;AAEtD,QACE,gBAAgB,aAAa,eAC7B,gBAAgB,YAAY,cAC5B,gBAAgB,oBAAoB,oBACpC;AACA;AAAA,IACF;AAEA,QAAI,gBAAgB,aAAa,aAAa;AAC5C,WAAK,YAAY,wBAAwB,eAAe;AACxD,WAAK,cAAc,KAAK,cAAc,WAAW;AACjD,WAAK,YAAY,wBAAwB,aAAa;AAAA,IACxD;AAEA,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEO,eAAe,UAAwB;AAC5C,QAAI,KAAK,aAAa,aAAa,SAAU;AAC7C,UAAM,mBAAmB,KAAK,QAAQ;AACtC,QAAI,CAAC;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AACF,qBAAiB,QAAQ;AAAA,EAC3B;AAAA,EAEO,oBAA0B;AAC/B,UAAM,sBAAsB,KAAK,QAAQ;AACzC,QAAI,CAAC;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AAEF,wBAAoB;AAAA,EACtB;AAAA,EAEA,MAAa,OAAO,UAAkB,UAAiC;AACrE,UAAM,WAAW,KAAK,QAAQ;AAC9B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,kDAAkD;AAEpE,aAAS,UAAU,QAAQ;AAAA,EAC7B;AAAA,EAEA,MAAa,QAAQ,UAAiC;AACpD,UAAM,YAAY,KAAK,QAAQ;AAC/B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,mDAAmD;AAErE,cAAU,QAAQ;AAAA,EACpB;AAAA,EAEA,MAAa,UAAU,UAAiC;AACtD,UAAM,cAAc,KAAK,QAAQ;AACjC,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,qDAAqD;AAEvE,gBAAY,QAAQ;AAAA,EACtB;AAAA,EAEA,MAAa,OAAO,UAAiC;AACnD,UAAM,WAAW,KAAK,QAAQ;AAC9B,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,kDAAkD;AAEpE,aAAS,QAAQ;AAAA,EACnB;AAAA,EAEQ,iBAAiB,oBAAI,IAAgB;AAAA,EAEtC,UAAU,UAAmC;AAClD,SAAK,eAAe,IAAI,QAAQ;AAChC,WAAO,MAAM,KAAK,eAAe,OAAO,QAAQ;AAAA,EAClD;AAAA,EAEQ,qBAAqB;AAC3B,eAAW,YAAY,KAAK,eAAgB,UAAS;AAAA,EACvD;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadManagementAdapter.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadManagerRuntimeCore } from \"../core/ThreadManagerRuntimeCore\";\nimport { ExternalStoreThreadManagerAdapter } from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = (\n threadId: string,\n) => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\n\nexport class ExternalStoreThreadManagerRuntimeCore\n implements ThreadManagerRuntimeCore\n{\n public get threads() {\n return this.adapter.threads ?? EMPTY_ARRAY;\n }\n\n public get archivedThreads() {\n return this.adapter.archivedThreads ?? EMPTY_ARRAY;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThread() {\n return this._mainThread;\n }\n\n constructor(\n private adapter: ExternalStoreThreadManagerAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory(DEFAULT_THREAD_ID);\n }\n\n public setAdapter(adapter: ExternalStoreThreadManagerAdapter) {\n const previousAdapter = this.adapter;\n this.adapter = adapter;\n\n const newThreadId = adapter.threadId ?? DEFAULT_THREAD_ID;\n const newThreads = adapter.threads ?? EMPTY_ARRAY;\n const newArchivedThreads = adapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousAdapter.threadId === newThreadId &&\n previousAdapter.threads === newThreads &&\n previousAdapter.archivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousAdapter.threadId !== newThreadId) {\n this._mainThread._notifyEventSubscribers(\"switched-away\");\n this._mainThread = this.threadFactory(newThreadId);\n this._mainThread._notifyEventSubscribers(\"switched-to\");\n }\n\n this._notifySubscribers();\n }\n\n public switchToThread(threadId: string): void {\n if (this._mainThread?.threadId === threadId) return;\n const onSwitchToThread = this.adapter.onSwitchToThread;\n if (!onSwitchToThread)\n throw new Error(\n \"External store adapter does not support switching to thread\",\n );\n onSwitchToThread(threadId);\n }\n\n public switchToNewThread(): void {\n const onSwitchToNewThread = this.adapter.onSwitchToNewThread;\n if (!onSwitchToNewThread)\n throw new Error(\n \"External store adapter does not support switching to new thread\",\n );\n\n onSwitchToNewThread();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const onRename = this.adapter.onRename;\n if (!onRename)\n throw new Error(\"External store adapter does not support renaming\");\n\n onRename(threadId, newTitle);\n }\n\n public async archive(threadId: string): Promise<void> {\n const onArchive = this.adapter.onArchive;\n if (!onArchive)\n throw new Error(\"External store adapter does not support archiving\");\n\n onArchive(threadId);\n }\n\n public async unarchive(threadId: string): Promise<void> {\n const onUnarchive = this.adapter.onUnarchive;\n if (!onUnarchive)\n throw new Error(\"External store adapter does not support unarchiving\");\n\n onUnarchive(threadId);\n }\n\n public async delete(threadId: string): Promise<void> {\n const onDelete = this.adapter.onDelete;\n if (!onDelete)\n throw new Error(\"External store adapter does not support deleting\");\n\n onDelete(threadId);\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";AASA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAEnB,IAAM,wCAAN,MAEP;AAAA,EAeE,YACU,UAA6C,CAAC,GAC9C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc,iBAAiB;AAAA,EACzD;AAAA,EAnBA,IAAW,UAAU;AACnB,WAAO,KAAK,QAAQ,WAAW;AAAA,EACjC;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK,QAAQ,mBAAmB;AAAA,EACzC;AAAA,EAEQ;AAAA,EAER,IAAW,aAAa;AACtB,WAAO,KAAK;AAAA,EACd;AAAA,EASO,WAAW,SAA4C;AAC5D,UAAM,kBAAkB,KAAK;AAC7B,SAAK,UAAU;AAEf,UAAM,cAAc,QAAQ,YAAY;AACxC,UAAM,aAAa,QAAQ,WAAW;AACtC,UAAM,qBAAqB,QAAQ,mBAAmB;AAEtD,QACE,gBAAgB,aAAa,eAC7B,gBAAgB,YAAY,cAC5B,gBAAgB,oBAAoB,oBACpC;AACA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AM,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBzD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI1C,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpD,OAAO,CAAC,cAAc,CAAyB;IAExC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAKnD,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/LocalThreadManagerRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport {\n ThreadManagerMetadata,\n ThreadManagerRuntimeCore,\n} from \"../core/ThreadManagerRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type LocalThreadData = {\n data: ExportedMessageRepository;\n metadata: ThreadManagerMetadata;\n isArchived: boolean;\n};\n\nexport type LocalThreadFactory = (\n threadId: string,\n data: ExportedMessageRepository,\n) => LocalThreadRuntimeCore;\n\nexport class LocalThreadManagerRuntimeCore implements ThreadManagerRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n\n private _threads: readonly ThreadManagerMetadata[] = [];\n private _archivedThreads: readonly ThreadManagerMetadata[] = [];\n\n public get threads() {\n return this._threads;\n }\n\n public get archivedThreads() {\n return this._archivedThreads;\n }\n\n private _mainThread: LocalThreadRuntimeCore;\n\n public get mainThread(): LocalThreadRuntimeCore {\n return this._mainThread;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n const threadId = generateId();\n this._threadData.set(threadId, {\n data: { messages: [] },\n metadata: { threadId },\n isArchived: false,\n });\n this._threads = [{ threadId }];\n this._mainThread = this._threadFactory(threadId, { messages: [] });\n }\n\n public switchToThread(threadId: string): void {\n if (this._mainThread.threadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const thread = this._threadFactory(threadId, data.data);\n this._performThreadSwitch(thread);\n }\n\n public switchToNewThread(): void {\n const threadId = generateId();\n this._threadData.set(threadId, {\n data: { messages: [] },\n metadata: { threadId },\n isArchived: false,\n });\n this._threads = [{ threadId }];\n const thread = this._threadFactory(threadId, { messages: [] });\n this._performThreadSwitch(thread);\n }\n\n private _performThreadSwitch(newThreadCore: LocalThreadRuntimeCore) {\n const data = this._threadData.get(this._mainThread.threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const exprt = this._mainThread.export();\n data.data = exprt;\n\n this._mainThread._notifyEventSubscribers(\"switched-away\");\n this._mainThread = newThreadCore;\n newThreadCore._notifyEventSubscribers(\"switched-to\");\n\n this._notifySubscribers();\n }\n\n private _performMoveOp(\n threadId: string,\n operation: \"archive\" | \"unarchive\" | \"delete\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (operation === \"archive\" && data.isArchived) return;\n if (operation === \"unarchive\" && !data.isArchived) return;\n\n if (operation === \"archive\") {\n data.isArchived = true;\n this._archivedThreads = [...this._archivedThreads, data.metadata];\n }\n if (operation === \"unarchive\") {\n data.isArchived = false;\n this._threads = [...this._threads, data.metadata];\n }\n if (operation === \"delete\") {\n this._threadData.delete(threadId);\n }\n\n if (\n operation === \"archive\" ||\n (operation === \"delete\" && data.isArchived)\n ) {\n this._archivedThreads = this._archivedThreads.filter(\n (t) => t.threadId !== threadId,\n );\n }\n\n if (\n operation === \"unarchive\" ||\n (operation === \"delete\" && !data.isArchived)\n ) {\n this._threads = this._threads.filter((t) => t.threadId !== threadId);\n }\n\n this._notifySubscribers();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n data.metadata = {\n ...data.metadata,\n title: newTitle,\n };\n\n const threadList = data.isArchived ? this.archivedThreads : this.threads;\n const idx = threadList.findIndex((t) => t.threadId === threadId);\n const updatedThreadList = threadList.toSpliced(idx, 1, data.metadata);\n if (data.isArchived) {\n this._archivedThreads = updatedThreadList;\n } else {\n this._threads = updatedThreadList;\n }\n this._notifySubscribers();\n }\n\n public async archive(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"archive\");\n }\n\n public async unarchive(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"unarchive\");\n }\n\n public async delete(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"delete\");\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAMA,qBAA2B;AAcpB,IAAM,gCAAN,MAAwE;AAAA,EAoB7E,YAAoB,gBAAoC;AAApC;AAClB,UAAM,eAAW,2BAAW;AAC5B,SAAK,YAAY,IAAI,UAAU;AAAA,MAC7B,MAAM,EAAE,UAAU,CAAC,EAAE;AAAA,MACrB,UAAU,EAAE,SAAS;AAAA,MACrB,YAAY;AAAA,IACd,CAAC;AACD,SAAK,WAAW,CAAC,EAAE,SAAS,CAAC;AAC7B,SAAK,cAAc,KAAK,eAAe,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;AAAA,EACnE;AAAA,EA5BQ,cAAc,oBAAI,IAA6B;AAAA,EAE/C,WAA6C,CAAC;AAAA,EAC9C,mBAAqD,CAAC;AAAA,EAE9D,IAAW,UAAU;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EAER,IAAW,aAAqC;AAC9C,WAAO,KAAK;AAAA,EACd;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UAAmC;AAClD,SAAK,eAAe,IAAI,QAAQ;AAChC,WAAO,MAAM,KAAK,eAAe,OAAO,QAAQ;AAAA,EAClD;AAAA,EAEQ,qBAAqB;AAC3B,eAAW,YAAY,KAAK,eAAgB,UAAS;AAAA,EACvD;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/LocalThreadManagerRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport {\n ThreadManagerMetadata,\n ThreadManagerRuntimeCore,\n} from \"../core/ThreadManagerRuntimeCore\";\nimport { ExportedMessageRepository } from \"../utils/MessageRepository\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type LocalThreadData = {\n data: ExportedMessageRepository;\n metadata: ThreadManagerMetadata;\n isArchived: boolean;\n};\n\nexport type LocalThreadFactory = (\n threadId: string,\n data: ExportedMessageRepository,\n) => LocalThreadRuntimeCore;\n\nexport class LocalThreadManagerRuntimeCore implements ThreadManagerRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n\n private _threads: readonly ThreadManagerMetadata[] = [];\n private _archivedThreads: readonly ThreadManagerMetadata[] = [];\n\n public get threads() {\n return this._threads;\n }\n\n public get archivedThreads() {\n return this._archivedThreads;\n }\n\n private _mainThread: LocalThreadRuntimeCore;\n\n public get mainThread(): LocalThreadRuntimeCore {\n return this._mainThread;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n const threadId = generateId();\n this._threadData.set(threadId, {\n data: { messages: [] },\n metadata: { threadId },\n isArchived: false,\n });\n this._threads = [{ threadId }];\n this._mainThread = this._threadFactory(threadId, { messages: [] });\n }\n\n public switchToThread(threadId: string): void {\n if (this._mainThread.threadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const thread = this._threadFactory(threadId, data.data);\n this._performThreadSwitch(thread);\n }\n\n public switchToNewThread(): void {\n const threadId = generateId();\n this._threadData.set(threadId, {\n data: { messages: [] },\n metadata: { threadId },\n isArchived: false,\n });\n this._threads = [{ threadId }];\n const thread = this._threadFactory(threadId, { messages: [] });\n this._performThreadSwitch(thread);\n }\n\n private _performThreadSwitch(newThreadCore: LocalThreadRuntimeCore) {\n const data = this._threadData.get(this._mainThread.threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const exprt = this._mainThread.export();\n data.data = exprt;\n\n this._mainThread._notifyEventSubscribers(\"switched-away\");\n this._mainThread = newThreadCore;\n newThreadCore._notifyEventSubscribers(\"switched-to\");\n\n this._notifySubscribers();\n }\n\n private _performMoveOp(\n threadId: string,\n operation: \"archive\" | \"unarchive\" | \"delete\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (operation === \"archive\" && data.isArchived) return;\n if (operation === \"unarchive\" && !data.isArchived) return;\n\n if (operation === \"archive\") {\n data.isArchived = true;\n this._archivedThreads = [...this._archivedThreads, data.metadata];\n }\n if (operation === \"unarchive\") {\n data.isArchived = false;\n this._threads = [...this._threads, data.metadata];\n }\n if (operation === \"delete\") {\n this._threadData.delete(threadId);\n }\n\n if (\n operation === \"archive\" ||\n (operation === \"delete\" && data.isArchived)\n ) {\n this._archivedThreads = this._archivedThreads.filter(\n (t) => t.threadId !== threadId,\n );\n }\n\n if (\n operation === \"unarchive\" ||\n (operation === \"delete\" && !data.isArchived)\n ) {\n this._threads = this._threads.filter((t) => t.threadId !== threadId);\n }\n\n this._notifySubscribers();\n }\n\n public async rename(threadId: string, newTitle: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n data.metadata = {\n ...data.metadata,\n title: newTitle,\n };\n\n const threadList = data.isArchived ? this.archivedThreads : this.threads;\n const idx = threadList.findIndex((t) => t.threadId === threadId);\n const updatedThreadList = threadList.toSpliced(idx, 1, data.metadata);\n if (data.isArchived) {\n this._archivedThreads = updatedThreadList;\n } else {\n this._threads = updatedThreadList;\n }\n this._notifySubscribers();\n }\n\n public async archive(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"archive\");\n }\n\n public async unarchive(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"unarchive\");\n }\n\n public async delete(threadId: string): Promise<void> {\n this._performMoveOp(threadId, \"delete\");\n }\n\n private _subscriptions = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscriptions.add(callback);\n return () => this._subscriptions.delete(callback);\n }\n\n private _notifySubscribers() {\n for (const callback of this._subscriptions) callback();\n }\n}\n"],"mappings":";AAMA,SAAS,kBAAkB;AAcpB,IAAM,gCAAN,MAAwE;AAAA,EAoB7E,YAAoB,gBAAoC;AAApC;AAClB,UAAM,WAAW,WAAW;AAC5B,SAAK,YAAY,IAAI,UAAU;AAAA,MAC7B,MAAM,EAAE,UAAU,CAAC,EAAE;AAAA,MACrB,UAAU,EAAE,SAAS;AAAA,MACrB,YAAY;AAAA,IACd,CAAC;AACD,SAAK,WAAW,CAAC,EAAE,SAAS,CAAC;AAC7B,SAAK,cAAc,KAAK,eAAe,UAAU,EAAE,UAAU,CAAC,EAAE,CAAC;AAAA,EACnE;AAAA,EA5BQ,cAAc,oBAAI,IAA6B;AAAA,EAE/C,WAA6C,CAAC;AAAA,EAC9C,mBAAqD,CAAC;AAAA,EAE9D,IAAW,UAAU;AACnB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,kBAAkB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EAER,IAAW,aAAqC;AAC9C,WAAO,KAAK;AAAA,EACd;AAAA,EAaO,eAAe,UAAwB;AAC5C,QAAI,KAAK,YAAY,aAAa,SAAU;AAE5C,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAE7C,UAAM,SAAS,KAAK,eAAe,UAAU,KAAK,IAAI;AACtD,SAAK,qBAAqB,MAAM;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izeSubject";
2
- import {
3
- ThreadManagerMetadata,
4
- ThreadManagerRuntimeCore,
5
- } from "../runtimes/core/ThreadManagerRuntimeCore";
6
- import { Unsubscribe } from "../types";
7
- import { ThreadManagerRuntimePath } from "./RuntimePathTypes";
8
-
9
- export type ThreadManagerState = Readonly<{
10
- threads: readonly ThreadManagerMetadata[];
11
- archivedThreads: readonly ThreadManagerMetadata[];
12
- }>;
13
-
14
- export type ThreadManagerRuntime = Readonly<{
15
- path: ThreadManagerRuntimePath;
16
- getState(): ThreadManagerState;
17
-
18
- rename(threadId: string, newTitle: string): Promise<void>;
19
- archive(threadId: string): Promise<void>;
20
- unarchive(threadId: string): Promise<void>;
21
- delete(threadId: string): Promise<void>;
22
-
23
- subscribe(callback: () => void): Unsubscribe;
24
- }>;
25
-
26
- const getThreadManagerState = (
27
- threadManager: ThreadManagerRuntimeCore,
28
- ): ThreadManagerState => {
29
- return {
30
- threads: threadManager.threads,
31
- archivedThreads: threadManager.archivedThreads,
32
- };
33
- };
34
-
35
- const THREAD_MANAGER_PATH = {
36
- ref: "threadManager",
37
- };
38
-
39
- export type ThreadManagerRuntimeCoreBinding = ThreadManagerRuntimeCore;
40
-
41
- export class ThreadManagerRuntimeImpl implements ThreadManagerRuntime {
42
- public get path() {
43
- return THREAD_MANAGER_PATH;
44
- }
45
-
46
- private _getState;
47
- constructor(private _core: ThreadManagerRuntimeCoreBinding) {
48
- const stateBinding = new LazyMemoizeSubject({
49
- path: THREAD_MANAGER_PATH,
50
- getState: () => getThreadManagerState(_core),
51
- subscribe: (callback) => _core.subscribe(callback),
52
- });
53
-
54
- this._getState = stateBinding.getState.bind(stateBinding);
55
- }
56
-
57
- public getState(): ThreadManagerState {
58
- return this._getState();
59
- }
60
-
61
- public rename(threadId: string, newTitle: string): Promise<void> {
62
- return this._core.rename(threadId, newTitle);
63
- }
64
-
65
- public archive(threadId: string): Promise<void> {
66
- return this._core.archive(threadId);
67
- }
68
-
69
- public unarchive(threadId: string): Promise<void> {
70
- return this._core.unarchive(threadId);
71
- }
72
-
73
- public delete(threadId: string): Promise<void> {
74
- return this._core.delete(threadId);
75
- }
76
-
77
- public subscribe(callback: () => void): Unsubscribe {
78
- return this._core.subscribe(callback);
79
- }
80
- }