@assistant-ui/react 0.7.23 → 0.7.25

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 (231) hide show
  1. package/dist/api/AssistantRuntime.d.ts +1 -1
  2. package/dist/api/AssistantRuntime.d.ts.map +1 -1
  3. package/dist/api/AssistantRuntime.js +1 -1
  4. package/dist/api/AssistantRuntime.js.map +1 -1
  5. package/dist/api/AssistantRuntime.mjs +1 -1
  6. package/dist/api/AssistantRuntime.mjs.map +1 -1
  7. package/dist/api/ComposerRuntime.d.ts +4 -2
  8. package/dist/api/ComposerRuntime.d.ts.map +1 -1
  9. package/dist/api/ComposerRuntime.js +6 -1
  10. package/dist/api/ComposerRuntime.js.map +1 -1
  11. package/dist/api/ComposerRuntime.mjs +6 -1
  12. package/dist/api/ComposerRuntime.mjs.map +1 -1
  13. package/dist/api/ThreadListItemRuntime.d.ts +3 -1
  14. package/dist/api/ThreadListItemRuntime.d.ts.map +1 -1
  15. package/dist/api/ThreadListItemRuntime.js.map +1 -1
  16. package/dist/api/ThreadListItemRuntime.mjs.map +1 -1
  17. package/dist/api/ThreadListRuntime.d.ts +8 -8
  18. package/dist/api/ThreadListRuntime.d.ts.map +1 -1
  19. package/dist/api/ThreadListRuntime.js +7 -5
  20. package/dist/api/ThreadListRuntime.js.map +1 -1
  21. package/dist/api/ThreadListRuntime.mjs +7 -5
  22. package/dist/api/ThreadListRuntime.mjs.map +1 -1
  23. package/dist/api/ThreadRuntime.d.ts +59 -32
  24. package/dist/api/ThreadRuntime.d.ts.map +1 -1
  25. package/dist/api/ThreadRuntime.js +2 -2
  26. package/dist/api/ThreadRuntime.js.map +1 -1
  27. package/dist/api/ThreadRuntime.mjs +2 -2
  28. package/dist/api/ThreadRuntime.mjs.map +1 -1
  29. package/dist/context/providers/AssistantRuntimeProvider.d.ts.map +1 -1
  30. package/dist/context/providers/AssistantRuntimeProvider.js +8 -3
  31. package/dist/context/providers/AssistantRuntimeProvider.js.map +1 -1
  32. package/dist/context/providers/AssistantRuntimeProvider.mjs +8 -3
  33. package/dist/context/providers/AssistantRuntimeProvider.mjs.map +1 -1
  34. package/dist/primitives/threadList/ThreadListItems.d.ts.map +1 -1
  35. package/dist/primitives/threadList/ThreadListItems.js +2 -4
  36. package/dist/primitives/threadList/ThreadListItems.js.map +1 -1
  37. package/dist/primitives/threadList/ThreadListItems.mjs +2 -4
  38. package/dist/primitives/threadList/ThreadListItems.mjs.map +1 -1
  39. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts +6 -6
  40. package/dist/runtimes/composer/BaseComposerRuntimeCore.d.ts.map +1 -1
  41. package/dist/runtimes/composer/BaseComposerRuntimeCore.js +29 -20
  42. package/dist/runtimes/composer/BaseComposerRuntimeCore.js.map +1 -1
  43. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs +29 -20
  44. package/dist/runtimes/composer/BaseComposerRuntimeCore.mjs.map +1 -1
  45. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.d.ts.map +1 -1
  46. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js +2 -3
  47. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.js.map +1 -1
  48. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs +2 -3
  49. package/dist/runtimes/composer/DefaultEditComposerRuntimeCore.mjs.map +1 -1
  50. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js +1 -1
  51. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.js.map +1 -1
  52. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs +1 -1
  53. package/dist/runtimes/composer/DefaultThreadComposerRuntimeCore.mjs.map +1 -1
  54. package/dist/runtimes/core/AssistantRuntimeCore.d.ts +2 -0
  55. package/dist/runtimes/core/AssistantRuntimeCore.d.ts.map +1 -1
  56. package/dist/runtimes/core/AssistantRuntimeCore.js.map +1 -1
  57. package/dist/runtimes/core/ComposerRuntimeCore.d.ts +2 -1
  58. package/dist/runtimes/core/ComposerRuntimeCore.d.ts.map +1 -1
  59. package/dist/runtimes/core/ComposerRuntimeCore.js.map +1 -1
  60. package/dist/runtimes/core/ThreadListRuntimeCore.d.ts +4 -1
  61. package/dist/runtimes/core/ThreadListRuntimeCore.d.ts.map +1 -1
  62. package/dist/runtimes/core/ThreadListRuntimeCore.js.map +1 -1
  63. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts +1 -1
  64. package/dist/runtimes/external-store/ExternalStoreAdapter.d.ts.map +1 -1
  65. package/dist/runtimes/external-store/ExternalStoreAdapter.js.map +1 -1
  66. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts +1 -0
  67. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.d.ts.map +1 -1
  68. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js +5 -1
  69. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.js.map +1 -1
  70. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs +5 -1
  71. package/dist/runtimes/external-store/ExternalStoreThreadListRuntimeCore.mjs.map +1 -1
  72. package/dist/runtimes/index.d.ts +5 -4
  73. package/dist/runtimes/index.d.ts.map +1 -1
  74. package/dist/runtimes/index.js +11 -9
  75. package/dist/runtimes/index.js.map +1 -1
  76. package/dist/runtimes/index.mjs +5 -4
  77. package/dist/runtimes/index.mjs.map +1 -1
  78. package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts +2 -1
  79. package/dist/runtimes/local/LocalThreadListRuntimeCore.d.ts.map +1 -1
  80. package/dist/runtimes/local/LocalThreadListRuntimeCore.js +12 -8
  81. package/dist/runtimes/local/LocalThreadListRuntimeCore.js.map +1 -1
  82. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs +12 -8
  83. package/dist/runtimes/local/LocalThreadListRuntimeCore.mjs.map +1 -1
  84. package/dist/runtimes/remote-thread-list/BaseSubscribable.d.ts +8 -0
  85. package/dist/runtimes/remote-thread-list/BaseSubscribable.d.ts.map +1 -0
  86. package/dist/runtimes/remote-thread-list/BaseSubscribable.js +62 -0
  87. package/dist/runtimes/remote-thread-list/BaseSubscribable.js.map +1 -0
  88. package/dist/runtimes/remote-thread-list/BaseSubscribable.mjs +37 -0
  89. package/dist/runtimes/remote-thread-list/BaseSubscribable.mjs.map +1 -0
  90. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.d.ts +3 -0
  91. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.d.ts.map +1 -0
  92. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js +150 -0
  93. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.js.map +1 -0
  94. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.mjs +125 -0
  95. package/dist/runtimes/remote-thread-list/EMPTY_THREAD_CORE.mjs.map +1 -0
  96. package/dist/runtimes/remote-thread-list/OptimisticState.d.ts +23 -0
  97. package/dist/runtimes/remote-thread-list/OptimisticState.d.ts.map +1 -0
  98. package/dist/runtimes/remote-thread-list/OptimisticState.js +83 -0
  99. package/dist/runtimes/remote-thread-list/OptimisticState.js.map +1 -0
  100. package/dist/runtimes/remote-thread-list/OptimisticState.mjs +58 -0
  101. package/dist/runtimes/remote-thread-list/OptimisticState.mjs.map +1 -0
  102. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts +75 -0
  103. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.d.ts.map +1 -0
  104. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js +127 -0
  105. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.js.map +1 -0
  106. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs +102 -0
  107. package/dist/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.mjs.map +1 -0
  108. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts +76 -0
  109. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -0
  110. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +396 -0
  111. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -0
  112. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs +371 -0
  113. package/dist/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.mjs.map +1 -0
  114. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts +7 -0
  115. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.d.ts.map +1 -0
  116. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js +39 -0
  117. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.js.map +1 -0
  118. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs +14 -0
  119. package/dist/runtimes/remote-thread-list/cloud/AssistantCloud.mjs.map +1 -0
  120. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts +19 -0
  121. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.d.ts.map +1 -0
  122. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js +79 -0
  123. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.js.map +1 -0
  124. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs +57 -0
  125. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAPI.mjs.map +1 -0
  126. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts +20 -0
  127. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.d.ts.map +1 -0
  128. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js +95 -0
  129. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.js.map +1 -0
  130. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs +69 -0
  131. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.mjs.map +1 -0
  132. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.d.ts +46 -0
  133. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.d.ts.map +1 -0
  134. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.js +50 -0
  135. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.js.map +1 -0
  136. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.mjs +25 -0
  137. package/dist/runtimes/remote-thread-list/cloud/AssistantCloudThreads.mjs.map +1 -0
  138. package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts +10 -0
  139. package/dist/runtimes/remote-thread-list/cloud/CloudContext.d.ts.map +1 -0
  140. package/dist/runtimes/remote-thread-list/cloud/CloudContext.js +32 -0
  141. package/dist/runtimes/remote-thread-list/cloud/CloudContext.js.map +1 -0
  142. package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs +7 -0
  143. package/dist/runtimes/remote-thread-list/cloud/CloudContext.mjs.map +1 -0
  144. package/dist/runtimes/remote-thread-list/cloud/index.d.ts +4 -0
  145. package/dist/runtimes/remote-thread-list/cloud/index.d.ts.map +1 -0
  146. package/dist/runtimes/remote-thread-list/cloud/index.js +37 -0
  147. package/dist/runtimes/remote-thread-list/cloud/index.js.map +1 -0
  148. package/dist/runtimes/remote-thread-list/cloud/index.mjs +10 -0
  149. package/dist/runtimes/remote-thread-list/cloud/index.mjs.map +1 -0
  150. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts +4 -0
  151. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.d.ts.map +1 -0
  152. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js +46 -0
  153. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.js.map +1 -0
  154. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs +22 -0
  155. package/dist/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.mjs.map +1 -0
  156. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts +14 -0
  157. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.d.ts.map +1 -0
  158. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js +103 -0
  159. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.js.map +1 -0
  160. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs +79 -0
  161. package/dist/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.mjs.map +1 -0
  162. package/dist/runtimes/remote-thread-list/index.d.ts +2 -0
  163. package/dist/runtimes/remote-thread-list/index.d.ts.map +1 -0
  164. package/dist/runtimes/remote-thread-list/index.js +25 -0
  165. package/dist/runtimes/remote-thread-list/index.js.map +1 -0
  166. package/dist/runtimes/remote-thread-list/index.mjs +3 -0
  167. package/dist/runtimes/remote-thread-list/index.mjs.map +1 -0
  168. package/dist/runtimes/remote-thread-list/types.d.ts +25 -0
  169. package/dist/runtimes/remote-thread-list/types.d.ts.map +1 -0
  170. package/dist/runtimes/remote-thread-list/types.js +19 -0
  171. package/dist/runtimes/remote-thread-list/types.js.map +1 -0
  172. package/dist/runtimes/remote-thread-list/types.mjs +1 -0
  173. package/dist/runtimes/remote-thread-list/types.mjs.map +1 -0
  174. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts +3 -0
  175. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.d.ts.map +1 -0
  176. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js +51 -0
  177. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.js.map +1 -0
  178. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs +26 -0
  179. package/dist/runtimes/remote-thread-list/useRemoteThreadListRuntime.mjs.map +1 -0
  180. package/dist/styles/index.css +2 -0
  181. package/dist/styles/index.css.map +1 -1
  182. package/dist/styles/tailwindcss/thread.css +5 -1
  183. package/dist/styles/tailwindcss/thread.css.json +4 -1
  184. package/dist/ui/attachment-ui.d.ts.map +1 -1
  185. package/dist/ui/attachment-ui.js +12 -7
  186. package/dist/ui/attachment-ui.js.map +1 -1
  187. package/dist/ui/attachment-ui.mjs +12 -7
  188. package/dist/ui/attachment-ui.mjs.map +1 -1
  189. package/dist/utils/createActionButton.d.ts +2 -2
  190. package/dist/utils/createActionButton.d.ts.map +1 -1
  191. package/dist/utils/createActionButton.js +2 -4
  192. package/dist/utils/createActionButton.js.map +1 -1
  193. package/dist/utils/createActionButton.mjs +5 -5
  194. package/dist/utils/createActionButton.mjs.map +1 -1
  195. package/package.json +3 -3
  196. package/src/api/AssistantRuntime.ts +2 -6
  197. package/src/api/ComposerRuntime.ts +10 -2
  198. package/src/api/ThreadListItemRuntime.ts +3 -1
  199. package/src/api/ThreadListRuntime.ts +11 -9
  200. package/src/api/ThreadRuntime.ts +3 -3
  201. package/src/context/providers/AssistantRuntimeProvider.tsx +21 -6
  202. package/src/primitives/threadList/ThreadListItems.tsx +3 -5
  203. package/src/runtimes/composer/BaseComposerRuntimeCore.tsx +43 -25
  204. package/src/runtimes/composer/DefaultEditComposerRuntimeCore.tsx +2 -3
  205. package/src/runtimes/composer/DefaultThreadComposerRuntimeCore.tsx +1 -1
  206. package/src/runtimes/core/AssistantRuntimeCore.tsx +3 -0
  207. package/src/runtimes/core/ComposerRuntimeCore.tsx +2 -1
  208. package/src/runtimes/core/ThreadListRuntimeCore.tsx +5 -2
  209. package/src/runtimes/external-store/ExternalStoreAdapter.tsx +1 -1
  210. package/src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx +6 -1
  211. package/src/runtimes/index.ts +5 -4
  212. package/src/runtimes/local/LocalThreadListRuntimeCore.tsx +14 -9
  213. package/src/runtimes/remote-thread-list/BaseSubscribable.tsx +38 -0
  214. package/src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx +158 -0
  215. package/src/runtimes/remote-thread-list/OptimisticState.ts +82 -0
  216. package/src/runtimes/remote-thread-list/RemoteThreadListHookInstanceManager.tsx +132 -0
  217. package/src/runtimes/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +486 -0
  218. package/src/runtimes/remote-thread-list/cloud/AssistantCloud.tsx +11 -0
  219. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAPI.tsx +81 -0
  220. package/src/runtimes/remote-thread-list/cloud/AssistantCloudAuthStrategy.tsx +95 -0
  221. package/src/runtimes/remote-thread-list/cloud/AssistantCloudThreads.tsx +72 -0
  222. package/src/runtimes/remote-thread-list/cloud/CloudContext.tsx +12 -0
  223. package/src/runtimes/remote-thread-list/cloud/index.ts +3 -0
  224. package/src/runtimes/remote-thread-list/cloud/useCloudGetOrCreateThread.tsx +19 -0
  225. package/src/runtimes/remote-thread-list/cloud/useCloudThreadListRuntime.tsx +100 -0
  226. package/src/runtimes/remote-thread-list/index.ts +2 -0
  227. package/src/runtimes/remote-thread-list/types.tsx +34 -0
  228. package/src/runtimes/remote-thread-list/useRemoteThreadListRuntime.tsx +28 -0
  229. package/src/styles/tailwindcss/thread.css +5 -1
  230. package/src/ui/attachment-ui.tsx +20 -14
  231. package/src/utils/createActionButton.tsx +11 -6
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n state: \"regular\",\n});\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\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 const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === 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 async switchToNewThread(): Promise<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;AAUA,IAAM,cAAc,OAAO,OAAO,CAAC,CA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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
+ {"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n status: \"regular\",\n});\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n public getLoadThreadsPromise() {\n return RESOLVED_PROMISE;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\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 const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === 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 async switchToNewThread(): Promise<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;AAUA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB,OAAO,OAAO,CAAC,iBAAiB,CAAC;AACzD,IAAM,iBAAqD,OAAO,OAAO;AAAA,EACvE,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AACD,IAAM,mBAAmB,QAAQ,QAAQ;AAElC,IAAM,qCAAN,MAEP;AAAA,EA2BE,YACU,UAA0C,CAAC,GAC3C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc;AAAA,EACxC;AAAA,EA/BQ,gBAAwB;AAAA,EACxB,WAA8B;AAAA,EAC9B,mBAAsC;AAAA,EAE9C,IAAW,cAAc;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,YAAY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AULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);
5
5
  var DEFAULT_THREAD = Object.freeze({
6
6
  threadId: DEFAULT_THREAD_ID,
7
- state: "regular"
7
+ status: "regular"
8
8
  });
9
+ var RESOLVED_PROMISE = Promise.resolve();
9
10
  var ExternalStoreThreadListRuntimeCore = class {
10
11
  constructor(adapter = {}, threadFactory) {
11
12
  this.adapter = adapter;
@@ -24,6 +25,9 @@ var ExternalStoreThreadListRuntimeCore = class {
24
25
  get archivedThreadIds() {
25
26
  return this._archivedThreads;
26
27
  }
28
+ getLoadThreadsPromise() {
29
+ return RESOLVED_PROMISE;
30
+ }
27
31
  _mainThread;
28
32
  get mainThreadId() {
29
33
  return this._mainThreadId;
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n state: \"regular\",\n});\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\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 const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === 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 async switchToNewThread(): Promise<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":";AAUA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB,OAAO,OAAO,CAAC,iBAAiB,CAAC;AACzD,IAAM,iBAAqD,OAAO,OAAO;AAAA,EACvE,UAAU;AAAA,EACV,OAAO;AACT,CAAC;AAEM,IAAM,qCAAN,MAEP;AAAA,EAuBE,YACU,UAA0C,CAAC,GAC3C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc;AAAA,EACxC;AAAA,EA3BQ,gBAAwB;AAAA,EACxB,WAA8B;AAAA,EAC9B,mBAAsC;AAAA,EAE9C,IAAW,cAAc;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,YAAY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AK,kBAAkB,SAAU;AACrC,UAAM,mBAAmB,KAAK,QAAQ;AACtC,QAAI,CAAC;AACH,YAAM,IAAI;AAAA,QACR;AAAA,MACF;AACF,qBAAiB,QAAQ;AAAA,EAC3B;AAAA,EAEA,MAAa,oBAAmC;AAC9C,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
+ {"version":3,"sources":["../../../src/runtimes/external-store/ExternalStoreThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ExternalStoreThreadRuntimeCore } from \"./ExternalStoreThreadRuntimeCore\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport {\n ExternalStoreThreadData,\n ExternalStoreThreadListAdapter,\n} from \"./ExternalStoreAdapter\";\n\nexport type ExternalStoreThreadFactory = () => ExternalStoreThreadRuntimeCore;\n\nconst EMPTY_ARRAY = Object.freeze([]);\nconst DEFAULT_THREAD_ID = \"DEFAULT_THREAD_ID\";\nconst DEFAULT_THREADS = Object.freeze([DEFAULT_THREAD_ID]);\nconst DEFAULT_THREAD: ExternalStoreThreadData<\"regular\"> = Object.freeze({\n threadId: DEFAULT_THREAD_ID,\n status: \"regular\",\n});\nconst RESOLVED_PROMISE = Promise.resolve();\n\nexport class ExternalStoreThreadListRuntimeCore\n implements ThreadListRuntimeCore\n{\n private _mainThreadId: string = DEFAULT_THREAD_ID;\n private _threads: readonly string[] = DEFAULT_THREADS;\n private _archivedThreads: readonly string[] = EMPTY_ARRAY;\n\n public get newThreadId() {\n return undefined;\n }\n\n public get threadIds() {\n return this._threads;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreads;\n }\n\n public getLoadThreadsPromise() {\n return RESOLVED_PROMISE;\n }\n\n private _mainThread: ExternalStoreThreadRuntimeCore;\n\n public get mainThreadId() {\n return this._mainThreadId;\n }\n\n constructor(\n private adapter: ExternalStoreThreadListAdapter = {},\n private threadFactory: ExternalStoreThreadFactory,\n ) {\n this._mainThread = this.threadFactory();\n }\n\n public getMainThreadRuntimeCore() {\n return this._mainThread;\n }\n\n public getItemById(threadId: string) {\n for (const thread of this.adapter.threads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n for (const thread of this.adapter.archivedThreads ?? []) {\n if (thread.threadId === threadId) return thread;\n }\n if (threadId === DEFAULT_THREAD_ID) return DEFAULT_THREAD;\n return undefined;\n }\n\n public __internal_setAdapter(adapter: ExternalStoreThreadListAdapter) {\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 const previousThreadId = previousAdapter.threadId ?? DEFAULT_THREAD_ID;\n const previousThreads = previousAdapter.threads ?? EMPTY_ARRAY;\n const previousArchivedThreads =\n previousAdapter.archivedThreads ?? EMPTY_ARRAY;\n\n if (\n previousThreadId === newThreadId &&\n previousThreads === newThreads &&\n previousArchivedThreads === newArchivedThreads\n ) {\n return;\n }\n\n if (previousThreads !== newThreads) {\n this._threads =\n this.adapter.threads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousArchivedThreads !== newArchivedThreads) {\n this._archivedThreads =\n this.adapter.archivedThreads?.map((t) => t.threadId) ?? EMPTY_ARRAY;\n }\n\n if (previousThreadId !== newThreadId) {\n this._mainThreadId = newThreadId;\n this._mainThread = this.threadFactory();\n }\n\n this._notifySubscribers();\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === 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 async switchToNewThread(): Promise<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":";AAUA,IAAM,cAAc,OAAO,OAAO,CAAC,CAAC;AACpC,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB,OAAO,OAAO,CAAC,iBAAiB,CAAC;AACzD,IAAM,iBAAqD,OAAO,OAAO;AAAA,EACvE,UAAU;AAAA,EACV,QAAQ;AACV,CAAC;AACD,IAAM,mBAAmB,QAAQ,QAAQ;AAElC,IAAM,qCAAN,MAEP;AAAA,EA2BE,YACU,UAA0C,CAAC,GAC3C,eACR;AAFQ;AACA;AAER,SAAK,cAAc,KAAK,cAAc;AAAA,EACxC;AAAA,EA/BQ,gBAAwB;AAAA,EACxB,WAA8B;AAAA,EAC9B,mBAAsC;AAAA,EAE9C,IAAW,cAAc;AACvB,WAAO;AAAA,EACT;AAAA,EAEA,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,oBAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,wBAAwB;AAC7B,WAAO;AAAA,EACT;AAAA,EAEQ;AAAA,EAER,IAAW,eAAe;AACxB,WAAO,KAAK;AAAA,EACd;AAAA,EASO,2BAA2B;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAEO,YAAY,UAAkB;AACnC,eAAW,UAAU,KAAK,QAAQ,WAAW,CAAC,GAAG;AAC/C,UAAI,OAAO,aAAa,SAAU,QAAO;AAAA,IAC3C;AACA,eAAW,UAAU,KAAK,QAAQ,mBAAmB,CAAC,GAAG;AACvD,UAAI,OAAO,aAAa,SAAU,QAAO;AAAA,IAC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AAU,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,9 +1,10 @@
1
+ export * from "./attachment";
1
2
  export * from "./core";
2
- export * from "./local";
3
+ export * from "./dangerous-in-browser";
3
4
  export * from "./edge";
4
5
  export * from "./external-store";
5
- export * from "./dangerous-in-browser";
6
- export * from "./speech";
7
- export * from "./attachment";
8
6
  export * from "./feedback";
7
+ export * from "./local";
8
+ export * from "./remote-thread-list";
9
+ export * from "./speech";
9
10
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtimes/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/runtimes/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,QAAQ,CAAC;AACvB,cAAc,wBAAwB,CAAC;AACvC,cAAc,QAAQ,CAAC;AACvB,cAAc,kBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,sBAAsB,CAAC;AACrC,cAAc,UAAU,CAAC"}
@@ -17,23 +17,25 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
17
17
  // src/runtimes/index.ts
18
18
  var runtimes_exports = {};
19
19
  module.exports = __toCommonJS(runtimes_exports);
20
+ __reExport(runtimes_exports, require("./attachment/index.js"), module.exports);
20
21
  __reExport(runtimes_exports, require("./core/index.js"), module.exports);
21
- __reExport(runtimes_exports, require("./local/index.js"), module.exports);
22
+ __reExport(runtimes_exports, require("./dangerous-in-browser/index.js"), module.exports);
22
23
  __reExport(runtimes_exports, require("./edge/index.js"), module.exports);
23
24
  __reExport(runtimes_exports, require("./external-store/index.js"), module.exports);
24
- __reExport(runtimes_exports, require("./dangerous-in-browser/index.js"), module.exports);
25
- __reExport(runtimes_exports, require("./speech/index.js"), module.exports);
26
- __reExport(runtimes_exports, require("./attachment/index.js"), module.exports);
27
25
  __reExport(runtimes_exports, require("./feedback/index.js"), module.exports);
26
+ __reExport(runtimes_exports, require("./local/index.js"), module.exports);
27
+ __reExport(runtimes_exports, require("./remote-thread-list/index.js"), module.exports);
28
+ __reExport(runtimes_exports, require("./speech/index.js"), module.exports);
28
29
  // Annotate the CommonJS export names for ESM import in node:
29
30
  0 && (module.exports = {
31
+ ...require("./attachment/index.js"),
30
32
  ...require("./core/index.js"),
31
- ...require("./local/index.js"),
33
+ ...require("./dangerous-in-browser/index.js"),
32
34
  ...require("./edge/index.js"),
33
35
  ...require("./external-store/index.js"),
34
- ...require("./dangerous-in-browser/index.js"),
35
- ...require("./speech/index.js"),
36
- ...require("./attachment/index.js"),
37
- ...require("./feedback/index.js")
36
+ ...require("./feedback/index.js"),
37
+ ...require("./local/index.js"),
38
+ ...require("./remote-thread-list/index.js"),
39
+ ...require("./speech/index.js")
38
40
  });
39
41
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./core\";\nexport * from \"./local\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./speech\";\nexport * from \"./attachment\";\nexport * from \"./feedback\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,4BAAd;AACA,6BAAc,6BADd;AAEA,6BAAc,4BAFd;AAGA,6BAAc,sCAHd;AAIA,6BAAc,4CAJd;AAKA,6BAAc,8BALd;AAMA,6BAAc,kCANd;AAOA,6BAAc,gCAPd;","names":[]}
1
+ {"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./attachment\";\nexport * from \"./core\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./feedback\";\nexport * from \"./local\";\nexport * from \"./remote-thread-list\";\nexport * from \"./speech\";\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,6BAAc,kCAAd;AACA,6BAAc,4BADd;AAEA,6BAAc,4CAFd;AAGA,6BAAc,4BAHd;AAIA,6BAAc,sCAJd;AAKA,6BAAc,gCALd;AAMA,6BAAc,6BANd;AAOA,6BAAc,0CAPd;AAQA,6BAAc,8BARd;","names":[]}
@@ -1,10 +1,11 @@
1
1
  // src/runtimes/index.ts
2
+ export * from "./attachment/index.mjs";
2
3
  export * from "./core/index.mjs";
3
- export * from "./local/index.mjs";
4
+ export * from "./dangerous-in-browser/index.mjs";
4
5
  export * from "./edge/index.mjs";
5
6
  export * from "./external-store/index.mjs";
6
- export * from "./dangerous-in-browser/index.mjs";
7
- export * from "./speech/index.mjs";
8
- export * from "./attachment/index.mjs";
9
7
  export * from "./feedback/index.mjs";
8
+ export * from "./local/index.mjs";
9
+ export * from "./remote-thread-list/index.mjs";
10
+ export * from "./speech/index.mjs";
10
11
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./core\";\nexport * from \"./local\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./speech\";\nexport * from \"./attachment\";\nexport * from \"./feedback\";\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
1
+ {"version":3,"sources":["../../src/runtimes/index.ts"],"sourcesContent":["export * from \"./attachment\";\nexport * from \"./core\";\nexport * from \"./dangerous-in-browser\";\nexport * from \"./edge\";\nexport * from \"./external-store\";\nexport * from \"./feedback\";\nexport * from \"./local\";\nexport * from \"./remote-thread-list\";\nexport * from \"./speech\";\n"],"mappings":";AAAA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;","names":[]}
@@ -6,7 +6,7 @@ export type ThreadListAdapter = {
6
6
  };
7
7
  export type LocalThreadData = {
8
8
  readonly runtime: LocalThreadRuntimeCore;
9
- readonly state: "new" | "regular" | "archived";
9
+ readonly status: "new" | "regular" | "archived";
10
10
  readonly threadId: string;
11
11
  readonly title?: string | undefined;
12
12
  };
@@ -24,6 +24,7 @@ export declare class LocalThreadListRuntimeCore implements ThreadListRuntimeCore
24
24
  get mainThreadId(): string;
25
25
  constructor(_threadFactory: LocalThreadFactory);
26
26
  getMainThreadRuntimeCore(): LocalThreadRuntimeCore;
27
+ getLoadThreadsPromise(): Promise<void>;
27
28
  getItemById(threadId: string): LocalThreadData | undefined;
28
29
  switchToThread(threadId: string): Promise<void>;
29
30
  switchToNewThread(): Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"LocalThreadListRuntimeCore.d.ts","sourceRoot":"","sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAEtE,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC;CAC9C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,CAAC,OAAO,EAAE,sBAAsB,CAAC;IACzC,QAAQ,CAAC,KAAK,EAAE,KAAK,GAAG,SAAS,GAAG,UAAU,CAAC;IAC/C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,kBAAkB,GAAG,MAAM,sBAAsB,CAAC;AAE9D,qBAAa,0BAA2B,YAAW,qBAAqB;IAwB1D,OAAO,CAAC,cAAc;IAvBlC,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,YAAY,CAAqB;IAEzC,IAAW,WAAW,uBAErB;IAED,IAAW,SAAS,sBAEnB;IAED,IAAW,iBAAiB,sBAE3B;IAED,OAAO,CAAC,aAAa,CAAU;IAE/B,IAAW,YAAY,IAAI,MAAM,CAEhC;gBAEmB,cAAc,EAAE,kBAAkB;IAI/C,wBAAwB;IAOxB,WAAW,CAAC,QAAQ,EAAE,MAAM;IAItB,cAAc,CAAC,QAAQ,EAAE,MAAM,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B,YAAW,qBAAqB;IAwB1D,OAAO,CAAC,cAAc;IAvBlC,OAAO,CAAC,WAAW,CAAsC;IACzD,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,kBAAkB,CAAyB;IACnD,OAAO,CAAC,YAAY,CAAqB;IAEzC,IAAW,WAAW,uBAErB;IAED,IAAW,SAAS,sBAEnB;IAED,IAAW,iBAAiB,sBAE3B;IAED,OAAO,CAAC,aAAa,CAAU;IAE/B,IAAW,YAAY,IAAI,MAAM,CAEhC;gBAEmB,cAAc,EAAE,kBAAkB;IAI/C,wBAAwB;IAOxB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAItC,WAAW,CAAC,QAAQ,EAAE,MAAM;IAItB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYrD,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC;YA2B3B,QAAQ;IAwEf,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzD,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxC,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAS1C,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU9C,OAAO,CAAC,cAAc,CAAyB;IAExC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAKnD,OAAO,CAAC,kBAAkB;CAG3B"}
@@ -24,6 +24,7 @@ __export(LocalThreadListRuntimeCore_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(LocalThreadListRuntimeCore_exports);
26
26
  var import_idUtils = require("../../utils/idUtils.js");
27
+ var RESOLVED_PROMISE = Promise.resolve();
27
28
  var LocalThreadListRuntimeCore = class {
28
29
  constructor(_threadFactory) {
29
30
  this._threadFactory = _threadFactory;
@@ -52,6 +53,9 @@ var LocalThreadListRuntimeCore = class {
52
53
  throw new Error("Main thread not found. This is a bug in assistant-ui.");
53
54
  return result;
54
55
  }
56
+ getLoadThreadsPromise() {
57
+ return RESOLVED_PROMISE;
58
+ }
55
59
  getItemById(threadId) {
56
60
  return this._threadData.get(threadId);
57
61
  }
@@ -59,7 +63,7 @@ var LocalThreadListRuntimeCore = class {
59
63
  if (this._mainThreadId === threadId) return;
60
64
  const data = this._threadData.get(threadId);
61
65
  if (!data) throw new Error("Thread not found");
62
- if (data.state === "archived") await this.unarchive(threadId);
66
+ if (data.status === "archived") await this.unarchive(threadId);
63
67
  this._mainThreadId = data.threadId;
64
68
  this._notifySubscribers();
65
69
  }
@@ -78,7 +82,7 @@ var LocalThreadListRuntimeCore = class {
78
82
  });
79
83
  this._threadData.set(threadId, {
80
84
  runtime,
81
- state: "new",
85
+ status: "new",
82
86
  threadId
83
87
  });
84
88
  this._newThreadId = threadId;
@@ -89,7 +93,7 @@ var LocalThreadListRuntimeCore = class {
89
93
  async _stateOp(threadId, newState) {
90
94
  const data = this._threadData.get(threadId);
91
95
  if (!data) throw new Error("Thread not found");
92
- const { state: lastState } = data;
96
+ const { status: lastState } = data;
93
97
  if (lastState === newState) return;
94
98
  switch (lastState) {
95
99
  case "new":
@@ -126,7 +130,7 @@ var LocalThreadListRuntimeCore = class {
126
130
  if (newState !== "deleted") {
127
131
  this._threadData.set(threadId, {
128
132
  ...data,
129
- state: newState
133
+ status: newState
130
134
  });
131
135
  }
132
136
  if (threadId === this._mainThreadId && (newState === "archived" || newState === "deleted")) {
@@ -153,7 +157,7 @@ var LocalThreadListRuntimeCore = class {
153
157
  archive(threadId) {
154
158
  const data = this._threadData.get(threadId);
155
159
  if (!data) throw new Error("Thread not found");
156
- if (data.state !== "regular")
160
+ if (data.status !== "regular")
157
161
  throw new Error("Thread is not yet initialized or already archived");
158
162
  this._stateOp(threadId, "archived");
159
163
  return Promise.resolve();
@@ -161,15 +165,15 @@ var LocalThreadListRuntimeCore = class {
161
165
  unarchive(threadId) {
162
166
  const data = this._threadData.get(threadId);
163
167
  if (!data) throw new Error("Thread not found");
164
- if (data.state !== "archived") throw new Error("Thread is not archived");
168
+ if (data.status !== "archived") throw new Error("Thread is not archived");
165
169
  this._stateOp(threadId, "regular");
166
170
  return Promise.resolve();
167
171
  }
168
172
  delete(threadId) {
169
173
  const data = this._threadData.get(threadId);
170
174
  if (!data) throw new Error("Thread not found");
171
- if (data.state !== "regular" && data.state !== "archived")
172
- throw new Error("Thread is not yet initalized");
175
+ if (data.status !== "regular" && data.status !== "archived")
176
+ throw new Error("Thread is not yet initialized");
173
177
  this._stateOp(threadId, "deleted");
174
178
  return Promise.resolve();
175
179
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type ThreadListAdapter = {\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type LocalThreadData = {\n readonly runtime: LocalThreadRuntimeCore;\n readonly state: \"new\" | \"regular\" | \"archived\";\n readonly threadId: string;\n readonly title?: string | undefined;\n};\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n private _threadIds: readonly string[] = [];\n private _archivedThreadIds: readonly string[] = [];\n private _newThreadId: string | undefined;\n\n public get newThreadId() {\n return this._newThreadId;\n }\n\n public get threadIds() {\n return this._threadIds;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreadIds;\n }\n\n private _mainThreadId!: string;\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n this.switchToNewThread();\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._threadData.get(this._mainThreadId)?.runtime;\n if (!result)\n throw new Error(\"Main thread not found. This is a bug in assistant-ui.\");\n return result;\n }\n\n public getItemById(threadId: string) {\n return this._threadData.get(threadId);\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (data.state === \"archived\") await this.unarchive(threadId);\n\n this._mainThreadId = data.threadId;\n this._notifySubscribers();\n }\n\n public switchToNewThread(): Promise<void> {\n if (this._newThreadId === undefined) {\n let threadId: string;\n do {\n threadId = generateId();\n } while (this._threadData.has(threadId));\n\n const runtime = this._threadFactory();\n const dispose = runtime.unstable_on(\"initialize\", () => {\n dispose();\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._stateOp(threadId, \"regular\");\n });\n this._threadData.set(threadId, {\n runtime,\n state: \"new\",\n threadId,\n });\n this._newThreadId = threadId;\n }\n\n this.switchToThread(this._newThreadId);\n return Promise.resolve();\n }\n\n private async _stateOp(\n threadId: string,\n newState: \"regular\" | \"archived\" | \"deleted\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const { state: lastState } = data;\n if (lastState === newState) return;\n\n // lastState\n switch (lastState) {\n case \"new\":\n this._newThreadId = undefined;\n break;\n case \"regular\":\n this._threadIds = this._threadIds.filter((t) => t !== threadId);\n break;\n case \"archived\":\n this._archivedThreadIds = this._archivedThreadIds.filter(\n (t) => t !== threadId,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newState\n switch (newState) {\n case \"regular\":\n this._threadIds = [...this._threadIds, data.threadId];\n break;\n\n case \"archived\":\n this._archivedThreadIds = [...this._archivedThreadIds, data.threadId];\n break;\n\n case \"deleted\":\n this._threadData.delete(threadId);\n break;\n\n default: {\n const _exhaustiveCheck: never = newState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newState !== \"deleted\") {\n this._threadData.set(threadId, {\n ...data,\n state: newState,\n });\n }\n\n if (\n threadId === this._mainThreadId &&\n (newState === \"archived\" || newState === \"deleted\")\n ) {\n const lastThreadId = this._threadIds[0];\n if (lastThreadId) {\n await this.switchToThread(lastThreadId);\n } else {\n await this.switchToNewThread();\n }\n } else {\n this._notifySubscribers();\n }\n }\n\n public 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 this._threadData.set(threadId, {\n ...data,\n title: newTitle,\n });\n this._notifySubscribers();\n return Promise.resolve();\n }\n\n public archive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.state !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n this._stateOp(threadId, \"archived\");\n return Promise.resolve();\n }\n\n public unarchive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.state !== \"archived\") throw new Error(\"Thread is not archived\");\n\n this._stateOp(threadId, \"regular\");\n return Promise.resolve();\n }\n\n public delete(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.state !== \"regular\" && data.state !== \"archived\")\n throw new Error(\"Thread is not yet initalized\");\n\n this._stateOp(threadId, \"deleted\");\n return Promise.resolve();\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;AAEA,qBAA2B;AAgBpB,IAAM,6BAAN,MAAkE;AAAA,EAwBvE,YAAoB,gBAAoC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QAAQ;AAAA,EACzB;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
+ {"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type ThreadListAdapter = {\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type LocalThreadData = {\n readonly runtime: LocalThreadRuntimeCore;\n readonly status: \"new\" | \"regular\" | \"archived\";\n readonly threadId: string;\n readonly title?: string | undefined;\n};\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst RESOLVED_PROMISE = Promise.resolve();\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n private _threadIds: readonly string[] = [];\n private _archivedThreadIds: readonly string[] = [];\n private _newThreadId: string | undefined;\n\n public get newThreadId() {\n return this._newThreadId;\n }\n\n public get threadIds() {\n return this._threadIds;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreadIds;\n }\n\n private _mainThreadId!: string;\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n this.switchToNewThread();\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._threadData.get(this._mainThreadId)?.runtime;\n if (!result)\n throw new Error(\"Main thread not found. This is a bug in assistant-ui.\");\n return result;\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n return RESOLVED_PROMISE;\n }\n\n public getItemById(threadId: string) {\n return this._threadData.get(threadId);\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (data.status === \"archived\") await this.unarchive(threadId);\n\n this._mainThreadId = data.threadId;\n this._notifySubscribers();\n }\n\n public switchToNewThread(): Promise<void> {\n if (this._newThreadId === undefined) {\n let threadId: string;\n do {\n threadId = generateId();\n } while (this._threadData.has(threadId));\n\n const runtime = this._threadFactory();\n const dispose = runtime.unstable_on(\"initialize\", () => {\n dispose();\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._stateOp(threadId, \"regular\");\n });\n this._threadData.set(threadId, {\n runtime,\n status: \"new\",\n threadId,\n });\n this._newThreadId = threadId;\n }\n\n this.switchToThread(this._newThreadId);\n return Promise.resolve();\n }\n\n private async _stateOp(\n threadId: string,\n newState: \"regular\" | \"archived\" | \"deleted\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const { status: lastState } = data;\n if (lastState === newState) return;\n\n // lastState\n switch (lastState) {\n case \"new\":\n this._newThreadId = undefined;\n break;\n case \"regular\":\n this._threadIds = this._threadIds.filter((t) => t !== threadId);\n break;\n case \"archived\":\n this._archivedThreadIds = this._archivedThreadIds.filter(\n (t) => t !== threadId,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newState\n switch (newState) {\n case \"regular\":\n this._threadIds = [...this._threadIds, data.threadId];\n break;\n\n case \"archived\":\n this._archivedThreadIds = [...this._archivedThreadIds, data.threadId];\n break;\n\n case \"deleted\":\n this._threadData.delete(threadId);\n break;\n\n default: {\n const _exhaustiveCheck: never = newState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newState !== \"deleted\") {\n this._threadData.set(threadId, {\n ...data,\n status: newState,\n });\n }\n\n if (\n threadId === this._mainThreadId &&\n (newState === \"archived\" || newState === \"deleted\")\n ) {\n const lastThreadId = this._threadIds[0];\n if (lastThreadId) {\n await this.switchToThread(lastThreadId);\n } else {\n await this.switchToNewThread();\n }\n } else {\n this._notifySubscribers();\n }\n }\n\n public 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 this._threadData.set(threadId, {\n ...data,\n title: newTitle,\n });\n this._notifySubscribers();\n return Promise.resolve();\n }\n\n public archive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n this._stateOp(threadId, \"archived\");\n return Promise.resolve();\n }\n\n public unarchive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"archived\") throw new Error(\"Thread is not archived\");\n\n this._stateOp(threadId, \"regular\");\n return Promise.resolve();\n }\n\n public delete(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n this._stateOp(threadId, \"deleted\");\n return Promise.resolve();\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;AAEA,qBAA2B;AAgB3B,IAAM,mBAAmB,QAAQ,QAAQ;AAClC,IAAM,6BAAN,MAAkE;AAAA,EAwBvE,YAAoB,gBAAoC;AAApC;AAClB,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAzBQ,cAAc,oBAAI,IAA6B;AAAA,EAC/C,aAAgC,CAAC;A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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,5 +1,6 @@
1
1
  // src/runtimes/local/LocalThreadListRuntimeCore.tsx
2
2
  import { generateId } from "../../utils/idUtils.mjs";
3
+ var RESOLVED_PROMISE = Promise.resolve();
3
4
  var LocalThreadListRuntimeCore = class {
4
5
  constructor(_threadFactory) {
5
6
  this._threadFactory = _threadFactory;
@@ -28,6 +29,9 @@ var LocalThreadListRuntimeCore = class {
28
29
  throw new Error("Main thread not found. This is a bug in assistant-ui.");
29
30
  return result;
30
31
  }
32
+ getLoadThreadsPromise() {
33
+ return RESOLVED_PROMISE;
34
+ }
31
35
  getItemById(threadId) {
32
36
  return this._threadData.get(threadId);
33
37
  }
@@ -35,7 +39,7 @@ var LocalThreadListRuntimeCore = class {
35
39
  if (this._mainThreadId === threadId) return;
36
40
  const data = this._threadData.get(threadId);
37
41
  if (!data) throw new Error("Thread not found");
38
- if (data.state === "archived") await this.unarchive(threadId);
42
+ if (data.status === "archived") await this.unarchive(threadId);
39
43
  this._mainThreadId = data.threadId;
40
44
  this._notifySubscribers();
41
45
  }
@@ -54,7 +58,7 @@ var LocalThreadListRuntimeCore = class {
54
58
  });
55
59
  this._threadData.set(threadId, {
56
60
  runtime,
57
- state: "new",
61
+ status: "new",
58
62
  threadId
59
63
  });
60
64
  this._newThreadId = threadId;
@@ -65,7 +69,7 @@ var LocalThreadListRuntimeCore = class {
65
69
  async _stateOp(threadId, newState) {
66
70
  const data = this._threadData.get(threadId);
67
71
  if (!data) throw new Error("Thread not found");
68
- const { state: lastState } = data;
72
+ const { status: lastState } = data;
69
73
  if (lastState === newState) return;
70
74
  switch (lastState) {
71
75
  case "new":
@@ -102,7 +106,7 @@ var LocalThreadListRuntimeCore = class {
102
106
  if (newState !== "deleted") {
103
107
  this._threadData.set(threadId, {
104
108
  ...data,
105
- state: newState
109
+ status: newState
106
110
  });
107
111
  }
108
112
  if (threadId === this._mainThreadId && (newState === "archived" || newState === "deleted")) {
@@ -129,7 +133,7 @@ var LocalThreadListRuntimeCore = class {
129
133
  archive(threadId) {
130
134
  const data = this._threadData.get(threadId);
131
135
  if (!data) throw new Error("Thread not found");
132
- if (data.state !== "regular")
136
+ if (data.status !== "regular")
133
137
  throw new Error("Thread is not yet initialized or already archived");
134
138
  this._stateOp(threadId, "archived");
135
139
  return Promise.resolve();
@@ -137,15 +141,15 @@ var LocalThreadListRuntimeCore = class {
137
141
  unarchive(threadId) {
138
142
  const data = this._threadData.get(threadId);
139
143
  if (!data) throw new Error("Thread not found");
140
- if (data.state !== "archived") throw new Error("Thread is not archived");
144
+ if (data.status !== "archived") throw new Error("Thread is not archived");
141
145
  this._stateOp(threadId, "regular");
142
146
  return Promise.resolve();
143
147
  }
144
148
  delete(threadId) {
145
149
  const data = this._threadData.get(threadId);
146
150
  if (!data) throw new Error("Thread not found");
147
- if (data.state !== "regular" && data.state !== "archived")
148
- throw new Error("Thread is not yet initalized");
151
+ if (data.status !== "regular" && data.status !== "archived")
152
+ throw new Error("Thread is not yet initialized");
149
153
  this._stateOp(threadId, "deleted");
150
154
  return Promise.resolve();
151
155
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type ThreadListAdapter = {\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type LocalThreadData = {\n readonly runtime: LocalThreadRuntimeCore;\n readonly state: \"new\" | \"regular\" | \"archived\";\n readonly threadId: string;\n readonly title?: string | undefined;\n};\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n private _threadIds: readonly string[] = [];\n private _archivedThreadIds: readonly string[] = [];\n private _newThreadId: string | undefined;\n\n public get newThreadId() {\n return this._newThreadId;\n }\n\n public get threadIds() {\n return this._threadIds;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreadIds;\n }\n\n private _mainThreadId!: string;\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n this.switchToNewThread();\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._threadData.get(this._mainThreadId)?.runtime;\n if (!result)\n throw new Error(\"Main thread not found. This is a bug in assistant-ui.\");\n return result;\n }\n\n public getItemById(threadId: string) {\n return this._threadData.get(threadId);\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (data.state === \"archived\") await this.unarchive(threadId);\n\n this._mainThreadId = data.threadId;\n this._notifySubscribers();\n }\n\n public switchToNewThread(): Promise<void> {\n if (this._newThreadId === undefined) {\n let threadId: string;\n do {\n threadId = generateId();\n } while (this._threadData.has(threadId));\n\n const runtime = this._threadFactory();\n const dispose = runtime.unstable_on(\"initialize\", () => {\n dispose();\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._stateOp(threadId, \"regular\");\n });\n this._threadData.set(threadId, {\n runtime,\n state: \"new\",\n threadId,\n });\n this._newThreadId = threadId;\n }\n\n this.switchToThread(this._newThreadId);\n return Promise.resolve();\n }\n\n private async _stateOp(\n threadId: string,\n newState: \"regular\" | \"archived\" | \"deleted\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const { state: lastState } = data;\n if (lastState === newState) return;\n\n // lastState\n switch (lastState) {\n case \"new\":\n this._newThreadId = undefined;\n break;\n case \"regular\":\n this._threadIds = this._threadIds.filter((t) => t !== threadId);\n break;\n case \"archived\":\n this._archivedThreadIds = this._archivedThreadIds.filter(\n (t) => t !== threadId,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newState\n switch (newState) {\n case \"regular\":\n this._threadIds = [...this._threadIds, data.threadId];\n break;\n\n case \"archived\":\n this._archivedThreadIds = [...this._archivedThreadIds, data.threadId];\n break;\n\n case \"deleted\":\n this._threadData.delete(threadId);\n break;\n\n default: {\n const _exhaustiveCheck: never = newState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newState !== \"deleted\") {\n this._threadData.set(threadId, {\n ...data,\n state: newState,\n });\n }\n\n if (\n threadId === this._mainThreadId &&\n (newState === \"archived\" || newState === \"deleted\")\n ) {\n const lastThreadId = this._threadIds[0];\n if (lastThreadId) {\n await this.switchToThread(lastThreadId);\n } else {\n await this.switchToNewThread();\n }\n } else {\n this._notifySubscribers();\n }\n }\n\n public 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 this._threadData.set(threadId, {\n ...data,\n title: newTitle,\n });\n this._notifySubscribers();\n return Promise.resolve();\n }\n\n public archive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.state !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n this._stateOp(threadId, \"archived\");\n return Promise.resolve();\n }\n\n public unarchive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.state !== \"archived\") throw new Error(\"Thread is not archived\");\n\n this._stateOp(threadId, \"regular\");\n return Promise.resolve();\n }\n\n public delete(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.state !== \"regular\" && data.state !== \"archived\")\n throw new Error(\"Thread is not yet initalized\");\n\n this._stateOp(threadId, \"deleted\");\n return Promise.resolve();\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":";AAEA,SAAS,kBAAkB;AAgBpB,IAAM,6BAAN,MAAkE;AAAA,EAwBvE,YAAoB,gBAAoC;AAApC;AAClB,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAzBQ,cAAc,oBAAI,IAA6B;AAAA,EAC/C,aAAgC,CAAC;AAAA,EACjC,qBAAwC,CAAC;AAAA,EACzC;AAAA,EAER,IAAW,cAAc;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,oBAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EAER,IAAW,eAAuB;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAMO,2BAA2B;AAChC,UAAM,SAAS,KAAK,YAAY,IAAI,KAAK,aAAa,GAAG;AACzD,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,uDAAuD;AACzE,WAAO;AAAA,EACT;AAAA,EAEO,YAAY,UAAkB;AACnC,WAAO,KAAK,YAAY,IAAI,QAAQ;AAAA,EACtC;AAAA,EAEA,MAAa,eAAe,UAAiC;AAC3D,QAAI,KAAK,kBAAkB,SAAU;AAErC,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAE7C,QAAI,KAAK,UAAU,WAAY,OAAM,KAAK,UAAU,QAAQ;AAE5D,SAAK,gBAAgB,KAAK;AAC1B,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEO,oBAAmC;AAC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,IAAI,MAAM,wBAAwB;AAEvE,SAAK,SAAS,UAAU,SAAS;AACjC,WAAO,QAAQ,QAAQ;AAAA,EACzB;AAAA,EAEO,OAAO,UAAiC;AAC7C,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAC7C,QAAI,KAAK,UAAU,aAAa,KAAK,UAAU;AAC7C,YAAM,IAAI,MAAM,8BAA8B;AAEhD,SAAK,SAAS,UAAU,SAAS;AACjC,WAAO,QAAQ,QAAQ;AAAA,EACzB;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
+ {"version":3,"sources":["../../../src/runtimes/local/LocalThreadListRuntimeCore.tsx"],"sourcesContent":["import type { Unsubscribe } from \"../../types\";\nimport { ThreadListRuntimeCore } from \"../core/ThreadListRuntimeCore\";\nimport { generateId } from \"../../utils/idUtils\";\nimport { LocalThreadRuntimeCore } from \"./LocalThreadRuntimeCore\";\n\nexport type ThreadListAdapter = {\n subscribe(callback: () => void): Unsubscribe;\n};\n\nexport type LocalThreadData = {\n readonly runtime: LocalThreadRuntimeCore;\n readonly status: \"new\" | \"regular\" | \"archived\";\n readonly threadId: string;\n readonly title?: string | undefined;\n};\n\nexport type LocalThreadFactory = () => LocalThreadRuntimeCore;\n\nconst RESOLVED_PROMISE = Promise.resolve();\nexport class LocalThreadListRuntimeCore implements ThreadListRuntimeCore {\n private _threadData = new Map<string, LocalThreadData>();\n private _threadIds: readonly string[] = [];\n private _archivedThreadIds: readonly string[] = [];\n private _newThreadId: string | undefined;\n\n public get newThreadId() {\n return this._newThreadId;\n }\n\n public get threadIds() {\n return this._threadIds;\n }\n\n public get archivedThreadIds() {\n return this._archivedThreadIds;\n }\n\n private _mainThreadId!: string;\n\n public get mainThreadId(): string {\n return this._mainThreadId;\n }\n\n constructor(private _threadFactory: LocalThreadFactory) {\n this.switchToNewThread();\n }\n\n public getMainThreadRuntimeCore() {\n const result = this._threadData.get(this._mainThreadId)?.runtime;\n if (!result)\n throw new Error(\"Main thread not found. This is a bug in assistant-ui.\");\n return result;\n }\n\n public getLoadThreadsPromise(): Promise<void> {\n return RESOLVED_PROMISE;\n }\n\n public getItemById(threadId: string) {\n return this._threadData.get(threadId);\n }\n\n public async switchToThread(threadId: string): Promise<void> {\n if (this._mainThreadId === threadId) return;\n\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n if (data.status === \"archived\") await this.unarchive(threadId);\n\n this._mainThreadId = data.threadId;\n this._notifySubscribers();\n }\n\n public switchToNewThread(): Promise<void> {\n if (this._newThreadId === undefined) {\n let threadId: string;\n do {\n threadId = generateId();\n } while (this._threadData.has(threadId));\n\n const runtime = this._threadFactory();\n const dispose = runtime.unstable_on(\"initialize\", () => {\n dispose();\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n this._stateOp(threadId, \"regular\");\n });\n this._threadData.set(threadId, {\n runtime,\n status: \"new\",\n threadId,\n });\n this._newThreadId = threadId;\n }\n\n this.switchToThread(this._newThreadId);\n return Promise.resolve();\n }\n\n private async _stateOp(\n threadId: string,\n newState: \"regular\" | \"archived\" | \"deleted\",\n ) {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n\n const { status: lastState } = data;\n if (lastState === newState) return;\n\n // lastState\n switch (lastState) {\n case \"new\":\n this._newThreadId = undefined;\n break;\n case \"regular\":\n this._threadIds = this._threadIds.filter((t) => t !== threadId);\n break;\n case \"archived\":\n this._archivedThreadIds = this._archivedThreadIds.filter(\n (t) => t !== threadId,\n );\n break;\n\n default: {\n const _exhaustiveCheck: never = lastState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n // newState\n switch (newState) {\n case \"regular\":\n this._threadIds = [...this._threadIds, data.threadId];\n break;\n\n case \"archived\":\n this._archivedThreadIds = [...this._archivedThreadIds, data.threadId];\n break;\n\n case \"deleted\":\n this._threadData.delete(threadId);\n break;\n\n default: {\n const _exhaustiveCheck: never = newState;\n throw new Error(`Unsupported state: ${_exhaustiveCheck}`);\n }\n }\n\n if (newState !== \"deleted\") {\n this._threadData.set(threadId, {\n ...data,\n status: newState,\n });\n }\n\n if (\n threadId === this._mainThreadId &&\n (newState === \"archived\" || newState === \"deleted\")\n ) {\n const lastThreadId = this._threadIds[0];\n if (lastThreadId) {\n await this.switchToThread(lastThreadId);\n } else {\n await this.switchToNewThread();\n }\n } else {\n this._notifySubscribers();\n }\n }\n\n public 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 this._threadData.set(threadId, {\n ...data,\n title: newTitle,\n });\n this._notifySubscribers();\n return Promise.resolve();\n }\n\n public archive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\")\n throw new Error(\"Thread is not yet initialized or already archived\");\n\n this._stateOp(threadId, \"archived\");\n return Promise.resolve();\n }\n\n public unarchive(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"archived\") throw new Error(\"Thread is not archived\");\n\n this._stateOp(threadId, \"regular\");\n return Promise.resolve();\n }\n\n public delete(threadId: string): Promise<void> {\n const data = this._threadData.get(threadId);\n if (!data) throw new Error(\"Thread not found\");\n if (data.status !== \"regular\" && data.status !== \"archived\")\n throw new Error(\"Thread is not yet initialized\");\n\n this._stateOp(threadId, \"deleted\");\n return Promise.resolve();\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":";AAEA,SAAS,kBAAkB;AAgB3B,IAAM,mBAAmB,QAAQ,QAAQ;AAClC,IAAM,6BAAN,MAAkE;AAAA,EAwBvE,YAAoB,gBAAoC;AAApC;AAClB,SAAK,kBAAkB;AAAA,EACzB;AAAA,EAzBQ,cAAc,oBAAI,IAA6B;AAAA,EAC/C,aAAgC,CAAC;AAAA,EACjC,qBAAwC,CAAC;AAAA,EACzC;AAAA,EAER,IAAW,cAAc;AACvB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,YAAY;AACrB,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,IAAW,oBAAoB;AAC7B,WAAO,KAAK;AAAA,EACd;AAAA,EAEQ;AAAA,EAER,IAAW,eAAuB;AAChC,WAAO,KAAK;AAAA,EACd;AAAA,EAMO,2BAA2B;AAChC,UAAM,SAAS,KAAK,YAAY,IAAI,KAAK,aAAa,GAAG;AACzD,QAAI,CAAC;AACH,YAAM,IAAI,MAAM,uDAAuD;AACzE,WAAO;AAAA,EACT;AAAA,EAEO,wBAAuC;AAC5C,WAAO;AAAA,EACT;AAAA,EAEO,YAAY,UAAkB;AACnC,WAAO,KAAK,YAAY,IAAI,QAAQ;AAAA,EACtC;AAAA,EAEA,MAAa,eAAe,UAAiC;AAC3D,QAAI,KAAK,kBAAkB,SAAU;AAErC,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAE7C,QAAI,KAAK,WAAW,WAAY,OAAM,KAAK,UAAU,QAAQ;AAE7D,SAAK,gBAAgB,KAAK;AAC1B,SAAK,mBAAmB;AAAA,EAC1B;AAAA,EAEO,oBAAmC;AACxC,QAAI,KAAK,iBAAiB,QAAW;AACnC,UAAI;AACJ,SAAG;AACD,mBAAW,WAAW;AAAA,MACxB,SAAS,KAAK,YAAY,IAA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OAAO,UAAiC;AAC7C,UAAM,OAAO,KAAK,YAAY,IAAI,QAAQ;AAC1C,QAAI,CAAC,KAAM,OAAM,IAAI,MAAM,kBAAkB;AAC7C,QAAI,KAAK,WAAW,aAAa,KAAK,WAAW;AAC/C,YAAM,IAAI,MAAM,+BAA+B;AAEjD,SAAK,SAAS,UAAU,SAAS;AACjC,WAAO,QAAQ,QAAQ;AAAA,EACzB;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":[]}
@@ -0,0 +1,8 @@
1
+ import { Unsubscribe } from "../../types";
2
+ export declare class BaseSubscribable {
3
+ private _subscribers;
4
+ subscribe(callback: () => void): Unsubscribe;
5
+ waitForUpdate(): Promise<void>;
6
+ protected _notifySubscribers(): void;
7
+ }
8
+ //# sourceMappingURL=BaseSubscribable.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BaseSubscribable.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/BaseSubscribable.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,YAAY,CAAyB;IAEtC,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,WAAW;IAK5C,aAAa;IASpB,SAAS,CAAC,kBAAkB;CAkB7B"}
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/runtimes/remote-thread-list/BaseSubscribable.tsx
21
+ var BaseSubscribable_exports = {};
22
+ __export(BaseSubscribable_exports, {
23
+ BaseSubscribable: () => BaseSubscribable
24
+ });
25
+ module.exports = __toCommonJS(BaseSubscribable_exports);
26
+ var BaseSubscribable = class {
27
+ _subscribers = /* @__PURE__ */ new Set();
28
+ subscribe(callback) {
29
+ this._subscribers.add(callback);
30
+ return () => this._subscribers.delete(callback);
31
+ }
32
+ waitForUpdate() {
33
+ return new Promise((resolve) => {
34
+ const unsubscribe = this.subscribe(() => {
35
+ unsubscribe();
36
+ resolve();
37
+ });
38
+ });
39
+ }
40
+ _notifySubscribers() {
41
+ const errors = [];
42
+ for (const callback of this._subscribers) {
43
+ try {
44
+ callback();
45
+ } catch (error) {
46
+ errors.push(error);
47
+ }
48
+ }
49
+ if (errors.length > 0) {
50
+ if (errors.length === 1) {
51
+ throw errors[0];
52
+ } else {
53
+ throw new AggregateError(errors);
54
+ }
55
+ }
56
+ }
57
+ };
58
+ // Annotate the CommonJS export names for ESM import in node:
59
+ 0 && (module.exports = {
60
+ BaseSubscribable
61
+ });
62
+ //# sourceMappingURL=BaseSubscribable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/runtimes/remote-thread-list/BaseSubscribable.tsx"],"sourcesContent":["import { Unsubscribe } from \"../../types\";\n\nexport class BaseSubscribable {\n private _subscribers = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscribers.add(callback);\n return () => this._subscribers.delete(callback);\n }\n\n public waitForUpdate() {\n return new Promise<void>((resolve) => {\n const unsubscribe = this.subscribe(() => {\n unsubscribe();\n resolve();\n });\n });\n }\n\n protected _notifySubscribers() {\n const errors = [];\n for (const callback of this._subscribers) {\n try {\n callback();\n } catch (error) {\n errors.push(error);\n }\n }\n\n if (errors.length > 0) {\n if (errors.length === 1) {\n throw errors[0];\n } else {\n throw new AggregateError(errors);\n }\n }\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEO,IAAM,mBAAN,MAAuB;AAAA,EACpB,eAAe,oBAAI,IAAgB;AAAA,EAEpC,UAAU,UAAmC;AAClD,SAAK,aAAa,IAAI,QAAQ;AAC9B,WAAO,MAAM,KAAK,aAAa,OAAO,QAAQ;AAAA,EAChD;AAAA,EAEO,gBAAgB;AACrB,WAAO,IAAI,QAAc,CAAC,YAAY;AACpC,YAAM,cAAc,KAAK,UAAU,MAAM;AACvC,oBAAY;AACZ,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEU,qBAAqB;AAC7B,UAAM,SAAS,CAAC;AAChB,eAAW,YAAY,KAAK,cAAc;AACxC,UAAI;AACF,iBAAS;AAAA,MACX,SAAS,OAAO;AACd,eAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,SAAS,GAAG;AACrB,UAAI,OAAO,WAAW,GAAG;AACvB,cAAM,OAAO,CAAC;AAAA,MAChB,OAAO;AACL,cAAM,IAAI,eAAe,MAAM;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,37 @@
1
+ // src/runtimes/remote-thread-list/BaseSubscribable.tsx
2
+ var BaseSubscribable = class {
3
+ _subscribers = /* @__PURE__ */ new Set();
4
+ subscribe(callback) {
5
+ this._subscribers.add(callback);
6
+ return () => this._subscribers.delete(callback);
7
+ }
8
+ waitForUpdate() {
9
+ return new Promise((resolve) => {
10
+ const unsubscribe = this.subscribe(() => {
11
+ unsubscribe();
12
+ resolve();
13
+ });
14
+ });
15
+ }
16
+ _notifySubscribers() {
17
+ const errors = [];
18
+ for (const callback of this._subscribers) {
19
+ try {
20
+ callback();
21
+ } catch (error) {
22
+ errors.push(error);
23
+ }
24
+ }
25
+ if (errors.length > 0) {
26
+ if (errors.length === 1) {
27
+ throw errors[0];
28
+ } else {
29
+ throw new AggregateError(errors);
30
+ }
31
+ }
32
+ }
33
+ };
34
+ export {
35
+ BaseSubscribable
36
+ };
37
+ //# sourceMappingURL=BaseSubscribable.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../src/runtimes/remote-thread-list/BaseSubscribable.tsx"],"sourcesContent":["import { Unsubscribe } from \"../../types\";\n\nexport class BaseSubscribable {\n private _subscribers = new Set<() => void>();\n\n public subscribe(callback: () => void): Unsubscribe {\n this._subscribers.add(callback);\n return () => this._subscribers.delete(callback);\n }\n\n public waitForUpdate() {\n return new Promise<void>((resolve) => {\n const unsubscribe = this.subscribe(() => {\n unsubscribe();\n resolve();\n });\n });\n }\n\n protected _notifySubscribers() {\n const errors = [];\n for (const callback of this._subscribers) {\n try {\n callback();\n } catch (error) {\n errors.push(error);\n }\n }\n\n if (errors.length > 0) {\n if (errors.length === 1) {\n throw errors[0];\n } else {\n throw new AggregateError(errors);\n }\n }\n }\n}\n"],"mappings":";AAEO,IAAM,mBAAN,MAAuB;AAAA,EACpB,eAAe,oBAAI,IAAgB;AAAA,EAEpC,UAAU,UAAmC;AAClD,SAAK,aAAa,IAAI,QAAQ;AAC9B,WAAO,MAAM,KAAK,aAAa,OAAO,QAAQ;AAAA,EAChD;AAAA,EAEO,gBAAgB;AACrB,WAAO,IAAI,QAAc,CAAC,YAAY;AACpC,YAAM,cAAc,KAAK,UAAU,MAAM;AACvC,oBAAY;AACZ,gBAAQ;AAAA,MACV,CAAC;AAAA,IACH,CAAC;AAAA,EACH;AAAA,EAEU,qBAAqB;AAC7B,UAAM,SAAS,CAAC;AAChB,eAAW,YAAY,KAAK,cAAc;AACxC,UAAI;AACF,iBAAS;AAAA,MACX,SAAS,OAAO;AACd,eAAO,KAAK,KAAK;AAAA,MACnB;AAAA,IACF;AAEA,QAAI,OAAO,SAAS,GAAG;AACrB,UAAI,OAAO,WAAW,GAAG;AACvB,cAAM,OAAO,CAAC;AAAA,MAChB,OAAO;AACL,cAAM,IAAI,eAAe,MAAM;AAAA,MACjC;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
@@ -0,0 +1,3 @@
1
+ import { ThreadRuntimeCore } from "../../internal";
2
+ export declare const EMPTY_THREAD_CORE: ThreadRuntimeCore;
3
+ //# sourceMappingURL=EMPTY_THREAD_CORE.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EMPTY_THREAD_CORE.d.ts","sourceRoot":"","sources":["../../../src/runtimes/remote-thread-list/EMPTY_THREAD_CORE.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAKnD,eAAO,MAAM,iBAAiB,EAAE,iBAwJ/B,CAAC"}