@myrialabs/clopen 0.4.50 → 0.4.51

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 (457) hide show
  1. package/README.md +2 -1
  2. package/backend/chat/attachments.test.ts +106 -17
  3. package/backend/chat/attachments.ts +131 -34
  4. package/backend/chat/engine-handoff.ts +42 -6
  5. package/backend/chat/stream-manager.ts +41 -5
  6. package/backend/containers/actions.ts +22 -0
  7. package/backend/control/actions/projects.ts +93 -37
  8. package/backend/control/folders.test.ts +27 -2
  9. package/backend/control/index.ts +2 -1
  10. package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
  11. package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
  12. package/backend/database/migrations/086_single_owner.ts +66 -73
  13. package/backend/database/migrations/090_create_storage_tables.ts +83 -0
  14. package/backend/database/migrations/index.ts +11 -2
  15. package/backend/database/queries/integration-queries.ts +10 -0
  16. package/backend/database/queries/memory-queue-queries.ts +11 -0
  17. package/backend/database/queries/project-queries.ts +6 -0
  18. package/backend/database/queries/session-queries.ts +3 -0
  19. package/backend/database/utils/migration-runner.test.ts +196 -0
  20. package/backend/database/utils/migration-runner.ts +61 -16
  21. package/backend/database/utils/seeder-runner.ts +22 -16
  22. package/backend/engine/adapters/claude/stream.ts +5 -0
  23. package/backend/engine/adapters/cursor/environment.ts +1 -1
  24. package/backend/engine/adapters/qwen/session-store.ts +10 -1
  25. package/backend/engine/types.ts +7 -0
  26. package/backend/git/identity/cli.ts +35 -0
  27. package/backend/git/identity/env.test.ts +52 -1
  28. package/backend/git/identity/env.ts +69 -10
  29. package/backend/git/identity/index.ts +25 -6
  30. package/backend/git/identity/resolve.ts +2 -1
  31. package/backend/git/identity/scope-config.ts +13 -7
  32. package/backend/git-hosts/accounts.ts +106 -0
  33. package/backend/git-hosts/auth/client-ids.ts +34 -0
  34. package/backend/git-hosts/auth/connect.ts +110 -0
  35. package/backend/git-hosts/auth/endpoints.ts +130 -0
  36. package/backend/git-hosts/auth/flows.ts +355 -0
  37. package/backend/git-hosts/auth/local.ts +152 -0
  38. package/backend/git-hosts/ci.ts +18 -0
  39. package/backend/git-hosts/cli.test.ts +82 -0
  40. package/backend/git-hosts/cli.ts +342 -0
  41. package/backend/git-hosts/credentials.ts +173 -0
  42. package/backend/git-hosts/git-credential.ts +30 -0
  43. package/backend/git-hosts/health.ts +39 -0
  44. package/backend/git-hosts/http.ts +174 -0
  45. package/backend/git-hosts/index.ts +34 -0
  46. package/backend/git-hosts/providers/bitbucket.ts +186 -0
  47. package/backend/git-hosts/providers/gitea.ts +208 -0
  48. package/backend/git-hosts/providers/github.ts +270 -0
  49. package/backend/git-hosts/providers/gitlab-client.ts +70 -0
  50. package/backend/git-hosts/providers/gitlab.ts +285 -0
  51. package/backend/git-hosts/providers/locators.test.ts +68 -0
  52. package/backend/git-hosts/registry.ts +50 -0
  53. package/backend/git-hosts/service.ts +432 -0
  54. package/backend/git-hosts/types.ts +82 -0
  55. package/backend/git-hosts/urls.test.ts +42 -0
  56. package/backend/git-hosts/urls.ts +69 -0
  57. package/backend/index.ts +50 -10
  58. package/backend/integrations/accounts.ts +50 -3
  59. package/backend/integrations/registry/define.ts +9 -0
  60. package/backend/integrations/registry/index.ts +11 -0
  61. package/backend/integrations/registry/providers/bitbucket.ts +51 -0
  62. package/backend/integrations/registry/providers/gitea.ts +53 -0
  63. package/backend/integrations/registry/providers/github.ts +24 -7
  64. package/backend/integrations/registry/providers/gitlab.ts +57 -0
  65. package/backend/integrations/registry/types.ts +13 -1
  66. package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
  67. package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
  68. package/backend/mentions/diff.ts +63 -0
  69. package/backend/mentions/index.ts +109 -0
  70. package/backend/mentions/mentions.test.ts +27 -0
  71. package/backend/mentions/shared.ts +82 -0
  72. package/backend/mentions/sources/ai-changes.ts +140 -0
  73. package/backend/mentions/sources/chats.ts +122 -0
  74. package/backend/mentions/sources/database.ts +211 -0
  75. package/backend/mentions/sources/files.ts +240 -0
  76. package/backend/mentions/sources/git.ts +308 -0
  77. package/backend/mentions/sources/notes-memory.ts +121 -0
  78. package/backend/mentions/sources/ops.ts +125 -0
  79. package/backend/mentions/sources/preview.ts +153 -0
  80. package/backend/mentions/sources/projects.ts +114 -0
  81. package/backend/mentions/sources/system.ts +135 -0
  82. package/backend/mentions/sources/terminal.ts +50 -0
  83. package/backend/mentions/types.ts +75 -0
  84. package/backend/preview/browser/bot-check-frames.test.ts +49 -0
  85. package/backend/preview/browser/bot-check-frames.ts +66 -0
  86. package/backend/preview/browser/browser-dialog-handler.ts +6 -5
  87. package/backend/preview/browser/browser-host-bridge.ts +4 -2
  88. package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
  89. package/backend/preview/browser/browser-pool.ts +26 -17
  90. package/backend/preview/browser/browser-preview-service.ts +164 -2
  91. package/backend/preview/browser/browser-screenshot.test.ts +113 -0
  92. package/backend/preview/browser/browser-screenshot.ts +396 -0
  93. package/backend/preview/browser/browser-tab-manager.ts +35 -186
  94. package/backend/preview/browser/browser-video-capture.ts +12 -17
  95. package/backend/preview/browser/element-describe.ts +125 -0
  96. package/backend/preview/browser/page-binding.ts +141 -0
  97. package/backend/preview/browser/screenshot-files.test.ts +117 -0
  98. package/backend/preview/browser/screenshot-files.ts +134 -0
  99. package/backend/preview/browser/user-agent.test.ts +25 -0
  100. package/backend/preview/browser/user-agent.ts +100 -0
  101. package/backend/projects/engine-transcripts.ts +153 -0
  102. package/backend/projects/folder-guard.ts +55 -0
  103. package/backend/projects/move.test.ts +208 -0
  104. package/backend/projects/move.ts +277 -0
  105. package/backend/projects/project-cleanup.integration.test.ts +3 -1
  106. package/backend/projects/project-cleanup.ts +10 -0
  107. package/backend/storage/actions.ts +260 -0
  108. package/backend/storage/chats.test.ts +57 -0
  109. package/backend/storage/chats.ts +170 -0
  110. package/backend/storage/database.ts +105 -0
  111. package/backend/storage/engine-homes.ts +145 -0
  112. package/backend/storage/fs-size.ts +111 -0
  113. package/backend/storage/history.ts +39 -0
  114. package/backend/storage/policy.ts +156 -0
  115. package/backend/storage/preview-profiles.ts +169 -0
  116. package/backend/storage/purge.ts +158 -0
  117. package/backend/storage/scanner.ts +339 -0
  118. package/backend/storage/session-index.ts +208 -0
  119. package/backend/storage/snapshots.ts +99 -0
  120. package/backend/storage/storage-flow.test.ts +137 -0
  121. package/backend/storage/transcripts/aliases.ts +75 -0
  122. package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
  123. package/backend/storage/transcripts/claude-dedupe.ts +152 -0
  124. package/backend/storage/transcripts/claude.ts +155 -0
  125. package/backend/storage/transcripts/cursor.ts +165 -0
  126. package/backend/storage/transcripts/file-stores.ts +224 -0
  127. package/backend/storage/transcripts/index.ts +207 -0
  128. package/backend/storage/transcripts/opencode.ts +124 -0
  129. package/backend/storage/transcripts/references.ts +42 -0
  130. package/backend/storage/transcripts/types.ts +58 -0
  131. package/backend/storage/worktrees.ts +114 -0
  132. package/backend/terminal/ptykit.ts +25 -0
  133. package/backend/update/registry.ts +24 -0
  134. package/backend/update/release-notes.test.ts +110 -0
  135. package/backend/update/release-notes.ts +132 -0
  136. package/backend/update/restart.ts +159 -0
  137. package/backend/utils/env.test.ts +64 -0
  138. package/backend/utils/env.ts +23 -55
  139. package/backend/utils/port-utils.ts +13 -0
  140. package/backend/work/index.ts +13 -2
  141. package/backend/work/providers/github/actions-logs.ts +1 -1
  142. package/backend/work/providers/github/adapter.ts +32 -1
  143. package/backend/work/providers/github/client.ts +7 -3
  144. package/backend/work/providers/gitlab/adapter.ts +770 -0
  145. package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
  146. package/backend/work/service.ts +60 -36
  147. package/backend/work/start-work.ts +1 -1
  148. package/backend/work/types.ts +4 -0
  149. package/backend/worktrees/index.ts +1 -0
  150. package/backend/worktrees/service.ts +23 -2
  151. package/backend/ws/chat/composer.ts +47 -6
  152. package/backend/ws/files/search.ts +1 -1
  153. package/backend/ws/files/write.ts +27 -0
  154. package/backend/ws/hosting/index.ts +231 -0
  155. package/backend/ws/index.ts +12 -2
  156. package/backend/ws/integrations/crud.ts +31 -5
  157. package/backend/ws/integrations/hosting-auth.ts +227 -0
  158. package/backend/ws/integrations/index.ts +2 -0
  159. package/backend/ws/mentions/index.ts +81 -0
  160. package/backend/ws/preview/browser/screenshot.ts +184 -0
  161. package/backend/ws/preview/index.ts +23 -0
  162. package/backend/ws/projects/crud.ts +66 -58
  163. package/backend/ws/sessions/crud.ts +7 -95
  164. package/backend/ws/snapshot/changes.ts +3 -3
  165. package/backend/ws/storage/index.ts +102 -0
  166. package/backend/ws/system/index.ts +7 -0
  167. package/backend/ws/system/operations.ts +125 -69
  168. package/backend/ws/work/context.ts +3 -4
  169. package/backend/ws/work/crud.ts +33 -0
  170. package/backend/ws/work/schemas.ts +4 -1
  171. package/bin/clopen.ts +15 -16
  172. package/dist/assets/{index-By6KdSLT.js → index-B9rHDvjg.js} +1 -1
  173. package/dist/assets/index-B9rHDvjg.js.br +0 -0
  174. package/dist/assets/index-B9rHDvjg.js.gz +0 -0
  175. package/dist/assets/{index-DV4TiDn1.js → index-DFlwOd7k.js} +1 -1
  176. package/dist/assets/index-DFlwOd7k.js.br +0 -0
  177. package/dist/assets/index-DFlwOd7k.js.gz +0 -0
  178. package/dist/assets/main-Bz_brxxS.css +1 -0
  179. package/dist/assets/main-Bz_brxxS.css.br +0 -0
  180. package/dist/assets/main-Bz_brxxS.css.gz +0 -0
  181. package/dist/assets/main-DRcX9SHx.js +1273 -0
  182. package/dist/assets/main-DRcX9SHx.js.br +0 -0
  183. package/dist/assets/main-DRcX9SHx.js.gz +0 -0
  184. package/dist/assets/pdf-DfwfQPLy.js +57 -0
  185. package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
  186. package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
  187. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
  188. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
  189. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
  190. package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
  191. package/dist/index.html +2 -2
  192. package/dist/index.html.br +0 -0
  193. package/dist/index.html.gz +0 -0
  194. package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  195. package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  196. package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  197. package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  198. package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  199. package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  200. package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  201. package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  202. package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  203. package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  204. package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  205. package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  206. package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  207. package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  208. package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  209. package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  210. package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  211. package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  212. package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  213. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  214. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  215. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  216. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  217. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  218. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  219. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  220. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  221. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  222. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  223. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  224. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  225. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  226. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  227. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  228. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  229. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  230. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  231. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  232. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  233. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  234. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  235. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  236. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  237. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  238. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  239. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  240. package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  241. package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  242. package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  243. package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  244. package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  245. package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  246. package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  247. package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  248. package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  249. package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  250. package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  251. package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  252. package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  253. package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  254. package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  255. package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  256. package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  257. package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  258. package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  259. package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  260. package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  261. package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  262. package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  263. package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  264. package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
  265. package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  266. package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  267. package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  268. package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  269. package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  270. package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  271. package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  272. package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  273. package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  274. package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  275. package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  276. package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  277. package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  278. package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  279. package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  280. package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
  281. package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  282. package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  283. package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  284. package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  285. package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  286. package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  287. package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  288. package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  289. package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  290. package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  291. package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  292. package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  293. package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  294. package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  295. package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  296. package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  297. package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  298. package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  299. package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  300. package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  301. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  302. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  303. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  304. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  305. package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  306. package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  307. package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  308. package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
  309. package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  310. package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  311. package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  312. package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  313. package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  314. package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  315. package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  316. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  317. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  318. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  319. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  320. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  321. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  322. package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  323. package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  324. package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  325. package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  326. package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  327. package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  328. package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  329. package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  330. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  331. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  332. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  333. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  334. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  335. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  336. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  337. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  338. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  339. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  340. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  341. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  342. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  343. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  344. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  345. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  346. package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  347. package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  348. package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  349. package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  350. package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  351. package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  352. package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  353. package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  354. package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  355. package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  356. package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  357. package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  358. package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  359. package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  360. package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  361. package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
  362. package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  363. package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  364. package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
  365. package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  366. package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  367. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  368. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  369. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  370. package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  371. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  372. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  373. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  374. package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  375. package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  376. package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  377. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  378. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  379. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  380. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  381. package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  382. package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  383. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  384. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  385. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  386. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
  387. package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  388. package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
  389. package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  390. package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
  391. package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
  392. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
  393. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
  394. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
  395. package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  396. package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
  397. package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
  398. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
  399. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
  400. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
  401. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  402. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
  403. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
  404. package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
  405. package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
  406. package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
  407. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
  408. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
  409. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
  410. package/package.json +6 -7
  411. package/scripts/start.ts +21 -4
  412. package/shared/constants/binary-extensions.ts +20 -4
  413. package/shared/constants/support.test.ts +27 -0
  414. package/shared/constants/support.ts +79 -0
  415. package/shared/constants/tool-icons.ts +7 -1
  416. package/shared/types/database/schema.ts +6 -0
  417. package/shared/types/git-hosting.ts +241 -0
  418. package/shared/types/integrations.ts +51 -1
  419. package/shared/types/mentions.ts +96 -0
  420. package/shared/types/release-notes.ts +31 -0
  421. package/shared/types/storage.ts +175 -0
  422. package/shared/types/stores/settings.ts +16 -0
  423. package/shared/types/unified/index.ts +1 -0
  424. package/shared/types/unified/message.ts +26 -1
  425. package/shared/types/unified/tool.ts +4 -0
  426. package/shared/types/work.ts +6 -0
  427. package/shared/utils/attachment-mentions.test.ts +39 -0
  428. package/shared/utils/attachment-mentions.ts +100 -0
  429. package/shared/utils/context-document.test.ts +53 -0
  430. package/shared/utils/context-document.ts +226 -0
  431. package/shared/utils/device-frame.test.ts +73 -0
  432. package/shared/utils/device-frame.ts +320 -0
  433. package/shared/utils/fuzzy.ts +79 -0
  434. package/shared/utils/launcher-fingerprint.test.ts +73 -0
  435. package/shared/utils/launcher-fingerprint.ts +108 -0
  436. package/shared/utils/logger.ts +2 -0
  437. package/shared/utils/page-colors.test.ts +17 -0
  438. package/shared/utils/page-colors.ts +24 -0
  439. package/shared/utils/process-supervisor.test.ts +18 -1
  440. package/shared/utils/process-supervisor.ts +12 -23
  441. package/shared/utils/restart-intent.test.ts +57 -0
  442. package/shared/utils/restart-intent.ts +80 -0
  443. package/shared/utils/semver.test.ts +33 -0
  444. package/shared/utils/semver.ts +35 -0
  445. package/shared/utils/supervised-child.ts +44 -0
  446. package/shared/utils/supervisor-protocol.ts +20 -0
  447. package/.env.example +0 -9
  448. package/dist/assets/index-By6KdSLT.js.br +0 -0
  449. package/dist/assets/index-By6KdSLT.js.gz +0 -0
  450. package/dist/assets/index-DV4TiDn1.js.br +0 -0
  451. package/dist/assets/index-DV4TiDn1.js.gz +0 -0
  452. package/dist/assets/main-DIESTGTD.css +0 -1
  453. package/dist/assets/main-DIESTGTD.css.br +0 -0
  454. package/dist/assets/main-DIESTGTD.css.gz +0 -0
  455. package/dist/assets/main-Da3JKoua.js +0 -1240
  456. package/dist/assets/main-Da3JKoua.js.br +0 -0
  457. package/dist/assets/main-Da3JKoua.js.gz +0 -0
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Cursor agents: one `JsonlLocalAgentStore` per project under
3
+ * `{clopenDir}/engine/cursor/user/agents/<encoded cwd>/`, four NDJSON files
4
+ * shared by every agent in the project.
5
+ *
6
+ * Sizes are apportioned per agent from the lines that belong to it (run events
7
+ * through their run). Removal goes through the SDK's own store API so the files
8
+ * stay in the shape the SDK expects; when every agent of a store goes, the store
9
+ * folder goes with them and the SDK is not needed at all.
10
+ *
11
+ * The store API treats an EMPTY filter as "everything". Every call here passes a
12
+ * non-empty id list and is skipped otherwise.
13
+ */
14
+
15
+ import fs from 'node:fs/promises';
16
+ import { join } from 'node:path';
17
+ import { getEngineUserConfigDir } from '$backend/utils/paths';
18
+ import { loadEngineSdk } from '$backend/engine/sdk-loader';
19
+ import { measurePath, removePath } from '../fs-size';
20
+ import type { TranscriptEntry, TranscriptRemoval, TranscriptStore } from './types';
21
+
22
+ const root = () => join(getEngineUserConfigDir('cursor'), 'agents');
23
+
24
+ async function readLines(file: string): Promise<string[]> {
25
+ try {
26
+ return (await fs.readFile(file, 'utf8')).split('\n').filter(Boolean);
27
+ } catch {
28
+ return [];
29
+ }
30
+ }
31
+
32
+ function field(line: string, name: string): string | null {
33
+ try {
34
+ const value = (JSON.parse(line) as Record<string, unknown>)[name];
35
+ return typeof value === 'string' ? value : null;
36
+ } catch {
37
+ return null;
38
+ }
39
+ }
40
+
41
+ interface StoreAgents {
42
+ dir: string;
43
+ agents: Map<string, { bytes: number; cwd: string | null; updatedAt: number }>;
44
+ }
45
+
46
+ async function readStore(dir: string): Promise<StoreAgents> {
47
+ const agents = new Map<string, { bytes: number; cwd: string | null; updatedAt: number }>();
48
+ const credit = (agentId: string | null, bytes: number) => {
49
+ if (!agentId) return;
50
+ const agent = agents.get(agentId);
51
+ if (agent) agent.bytes += bytes;
52
+ };
53
+
54
+ for (const line of await readLines(join(dir, 'agents.ndjson'))) {
55
+ try {
56
+ const doc = JSON.parse(line) as { agentId?: string; cwd?: string; updatedAt?: number };
57
+ if (!doc.agentId) continue;
58
+ agents.set(doc.agentId, { bytes: line.length, cwd: doc.cwd ?? null, updatedAt: doc.updatedAt ?? 0 });
59
+ } catch { /* skip */ }
60
+ }
61
+
62
+ const runOwner = new Map<string, string>();
63
+ for (const line of await readLines(join(dir, 'runs.ndjson'))) {
64
+ const agentId = field(line, 'agentId');
65
+ const runId = field(line, 'runId');
66
+ if (agentId && runId) runOwner.set(runId, agentId);
67
+ credit(agentId, line.length);
68
+ }
69
+ for (const line of await readLines(join(dir, 'run_events.ndjson'))) {
70
+ const runId = field(line, 'runId');
71
+ credit(runId ? runOwner.get(runId) ?? null : null, line.length);
72
+ }
73
+ for (const line of await readLines(join(dir, 'checkpoints.ndjson'))) {
74
+ credit(field(line, 'agentId'), line.length);
75
+ }
76
+ return { dir, agents };
77
+ }
78
+
79
+ async function storeDirs(): Promise<string[]> {
80
+ try {
81
+ return (await fs.readdir(root(), { withFileTypes: true }))
82
+ .filter(entry => entry.isDirectory())
83
+ .map(entry => join(root(), entry.name));
84
+ } catch {
85
+ return [];
86
+ }
87
+ }
88
+
89
+ export const cursorTranscripts: TranscriptStore = {
90
+ engine: 'cursor',
91
+ roots: () => [root()],
92
+
93
+ async list(signal) {
94
+ const entries: TranscriptEntry[] = [];
95
+ for (const dir of await storeDirs()) {
96
+ if (signal?.aborted) break;
97
+ const { agents } = await readStore(dir);
98
+ const projectKey = dir.slice(root().length + 1);
99
+ for (const [agentId, agent] of agents) {
100
+ entries.push({
101
+ engine: 'cursor',
102
+ id: agentId,
103
+ paths: [dir],
104
+ bytes: agent.bytes,
105
+ mtimeMs: agent.updatedAt,
106
+ projectKey,
107
+ projectPath: agent.cwd
108
+ });
109
+ }
110
+ }
111
+ return entries;
112
+ },
113
+
114
+ async exists(id) {
115
+ for (const dir of await storeDirs()) {
116
+ if ((await readStore(dir)).agents.has(id)) return true;
117
+ }
118
+ return false;
119
+ },
120
+
121
+ async remove(entries) {
122
+ const result: TranscriptRemoval = { freedBytes: 0, removed: 0, errors: [] };
123
+ const byStore = new Map<string, TranscriptEntry[]>();
124
+ for (const entry of entries) {
125
+ const dir = entry.paths[0];
126
+ let list = byStore.get(dir);
127
+ if (!list) byStore.set(dir, list = []);
128
+ list.push(entry);
129
+ }
130
+
131
+ for (const [dir, list] of byStore) {
132
+ const store = await readStore(dir);
133
+ const ids = list.map(entry => entry.id).filter(id => store.agents.has(id));
134
+ if (ids.length === 0) continue;
135
+
136
+ if (ids.length === store.agents.size) {
137
+ result.freedBytes += await removePath(dir);
138
+ result.removed += ids.length;
139
+ continue;
140
+ }
141
+
142
+ try {
143
+ const before = (await measurePath(dir)).bytes;
144
+ const { JsonlLocalAgentStore } = await loadEngineSdk<typeof import('@cursor/sdk')>('cursor', '@cursor/sdk');
145
+ const sdkStore = new JsonlLocalAgentStore(dir);
146
+ const runIds: string[] = [];
147
+ let cursor: string | undefined;
148
+ do {
149
+ const page = await sdkStore.runs.list({ filter: { agentIds: ids, ...(cursor && { cursor }) } });
150
+ runIds.push(...page.items.map(run => run.runId));
151
+ cursor = page.nextCursor;
152
+ } while (cursor);
153
+ if (runIds.length > 0) await sdkStore.runEvents.delete({ filter: { runIds } });
154
+ await sdkStore.runs.delete({ filter: { agentIds: ids } });
155
+ await sdkStore.checkpoints.delete({ filter: { agentIds: ids } });
156
+ await sdkStore.agents.delete({ filter: { agentIds: ids } });
157
+ result.freedBytes += Math.max(0, before - (await measurePath(dir)).bytes);
158
+ result.removed += ids.length;
159
+ } catch (error) {
160
+ result.errors.push(`Cursor store ${dir}: ${error instanceof Error ? error.message : String(error)}`);
161
+ }
162
+ }
163
+ return result;
164
+ }
165
+ };
@@ -0,0 +1,224 @@
1
+ /**
2
+ * Engines whose sessions are plain files or folders, one per session id.
3
+ *
4
+ * - Codex: `{CODEX_HOME}/sessions/YYYY/MM/DD/rollout-<ts>-<id>.jsonl`, cwd in
5
+ * the first line's `payload.cwd`
6
+ * - Qwen: `{QWEN_RUNTIME_DIR}/projects/<encoded cwd>/chats/<id>.jsonl`
7
+ * - Copilot: `{COPILOT_HOME}/session-state/<id>/`
8
+ * - Pi: `{pi agent dir}/sessions/<encoded cwd>/<timestamp>_<id>.jsonl`, cwd in
9
+ * the header line
10
+ */
11
+
12
+ import fs from 'node:fs/promises';
13
+ import { join } from 'node:path';
14
+ import { getEngineUserConfigDir } from '$backend/utils/paths';
15
+ import { measurePath, removePath } from '../fs-size';
16
+ import type { TranscriptEntry, TranscriptRemoval, TranscriptStore } from './types';
17
+ import { UUID_PATTERN } from './types';
18
+ import type { EngineType } from '$shared/types/unified';
19
+
20
+ async function listDir(dir: string): Promise<import('node:fs').Dirent[]> {
21
+ try {
22
+ return await fs.readdir(dir, { withFileTypes: true });
23
+ } catch {
24
+ return [];
25
+ }
26
+ }
27
+
28
+ /** First line of a file, read without loading the rest. */
29
+ async function readFirstLine(file: string, limit = 65_536): Promise<string | null> {
30
+ try {
31
+ const handle = await fs.open(file, 'r');
32
+ try {
33
+ const buffer = Buffer.alloc(limit);
34
+ const { bytesRead } = await handle.read(buffer, 0, limit, 0);
35
+ const text = buffer.subarray(0, bytesRead).toString('utf8');
36
+ const newline = text.indexOf('\n');
37
+ return newline === -1 ? text : text.slice(0, newline);
38
+ } finally {
39
+ await handle.close();
40
+ }
41
+ } catch {
42
+ return null;
43
+ }
44
+ }
45
+
46
+ function cwdFromHeader(line: string | null): string | null {
47
+ if (!line) return null;
48
+ try {
49
+ const parsed = JSON.parse(line) as { cwd?: unknown; payload?: { cwd?: unknown } };
50
+ const cwd = parsed.payload?.cwd ?? parsed.cwd;
51
+ return typeof cwd === 'string' ? cwd : null;
52
+ } catch {
53
+ return null;
54
+ }
55
+ }
56
+
57
+ async function removeEntries(entries: TranscriptEntry[]): Promise<TranscriptRemoval> {
58
+ const result: TranscriptRemoval = { freedBytes: 0, removed: 0, errors: [] };
59
+ for (const entry of entries) {
60
+ try {
61
+ for (const target of entry.paths) result.freedBytes += await removePath(target);
62
+ result.removed++;
63
+ } catch (error) {
64
+ result.errors.push(`${entry.id}: ${error instanceof Error ? error.message : String(error)}`);
65
+ }
66
+ }
67
+ return result;
68
+ }
69
+
70
+ async function fileEntry(
71
+ engine: EngineType,
72
+ id: string,
73
+ file: string,
74
+ projectKey: string | null,
75
+ projectPath: string | null
76
+ ): Promise<TranscriptEntry | null> {
77
+ const stat = await fs.stat(file).catch(() => null);
78
+ if (!stat) return null;
79
+ return {
80
+ engine,
81
+ id,
82
+ paths: [file],
83
+ bytes: stat.isDirectory() ? (await measurePath(file)).bytes : stat.size,
84
+ mtimeMs: stat.mtimeMs,
85
+ projectKey,
86
+ projectPath
87
+ };
88
+ }
89
+
90
+ // ── Codex ────────────────────────────────────────────────────────────────────
91
+
92
+ const codexRoot = () => join(getEngineUserConfigDir('codex'), 'sessions');
93
+ const CODEX_ROLLOUT = /-([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i;
94
+
95
+ async function codexFiles(signal?: AbortSignal): Promise<{ id: string; file: string }[]> {
96
+ const files: { id: string; file: string }[] = [];
97
+ const stack = [codexRoot()];
98
+ while (stack.length > 0) {
99
+ if (signal?.aborted) break;
100
+ const dir = stack.pop()!;
101
+ for (const entry of await listDir(dir)) {
102
+ const full = join(dir, entry.name);
103
+ if (entry.isDirectory()) stack.push(full);
104
+ else {
105
+ const match = CODEX_ROLLOUT.exec(entry.name);
106
+ if (match) files.push({ id: match[1], file: full });
107
+ }
108
+ }
109
+ }
110
+ return files;
111
+ }
112
+
113
+ export const codexTranscripts: TranscriptStore = {
114
+ engine: 'codex',
115
+ roots: () => [codexRoot()],
116
+ async list(signal) {
117
+ const entries: TranscriptEntry[] = [];
118
+ for (const { id, file } of await codexFiles(signal)) {
119
+ const entry = await fileEntry('codex', id, file, null, cwdFromHeader(await readFirstLine(file)));
120
+ if (entry) entries.push(entry);
121
+ }
122
+ return entries;
123
+ },
124
+ async exists(id) {
125
+ return (await codexFiles()).some(file => file.id === id);
126
+ },
127
+ remove: removeEntries
128
+ };
129
+
130
+ // ── Qwen ─────────────────────────────────────────────────────────────────────
131
+
132
+ const qwenRoot = () => join(getEngineUserConfigDir('qwen'), 'projects');
133
+
134
+ export const qwenTranscripts: TranscriptStore = {
135
+ engine: 'qwen',
136
+ roots: () => [qwenRoot()],
137
+ async list(signal) {
138
+ const entries: TranscriptEntry[] = [];
139
+ for (const project of await listDir(qwenRoot())) {
140
+ if (signal?.aborted) break;
141
+ if (!project.isDirectory()) continue;
142
+ const chats = join(qwenRoot(), project.name, 'chats');
143
+ for (const chat of await listDir(chats)) {
144
+ if (!chat.isFile() || !chat.name.endsWith('.jsonl')) continue;
145
+ const entry = await fileEntry('qwen', chat.name.slice(0, -6), join(chats, chat.name), project.name, null);
146
+ if (entry) entries.push(entry);
147
+ }
148
+ }
149
+ return entries;
150
+ },
151
+ async exists(id) {
152
+ for (const project of await listDir(qwenRoot())) {
153
+ try {
154
+ await fs.access(join(qwenRoot(), project.name, 'chats', `${id}.jsonl`));
155
+ return true;
156
+ } catch { /* not here */ }
157
+ }
158
+ return false;
159
+ },
160
+ remove: removeEntries
161
+ };
162
+
163
+ // ── Copilot ──────────────────────────────────────────────────────────────────
164
+
165
+ const copilotRoot = () => join(getEngineUserConfigDir('copilot'), 'session-state');
166
+
167
+ export const copilotTranscripts: TranscriptStore = {
168
+ engine: 'copilot',
169
+ roots: () => [copilotRoot()],
170
+ async list(signal) {
171
+ const entries: TranscriptEntry[] = [];
172
+ for (const session of await listDir(copilotRoot())) {
173
+ if (signal?.aborted) break;
174
+ if (!session.isDirectory() || !UUID_PATTERN.test(session.name)) continue;
175
+ const entry = await fileEntry('copilot', session.name, join(copilotRoot(), session.name), null, null);
176
+ if (entry) entries.push(entry);
177
+ }
178
+ return entries;
179
+ },
180
+ async exists(id) {
181
+ try {
182
+ await fs.access(join(copilotRoot(), id));
183
+ return true;
184
+ } catch {
185
+ return false;
186
+ }
187
+ },
188
+ remove: removeEntries
189
+ };
190
+
191
+ // ── Pi ───────────────────────────────────────────────────────────────────────
192
+
193
+ const piRoot = () => join(getEngineUserConfigDir('pi'), 'sessions');
194
+ const PI_SESSION = /^[^_]+_(.+)\.jsonl$/;
195
+
196
+ export const piTranscripts: TranscriptStore = {
197
+ engine: 'pi',
198
+ roots: () => [piRoot()],
199
+ async list(signal) {
200
+ const entries: TranscriptEntry[] = [];
201
+ for (const project of await listDir(piRoot())) {
202
+ if (signal?.aborted) break;
203
+ if (!project.isDirectory()) continue;
204
+ const dir = join(piRoot(), project.name);
205
+ for (const file of await listDir(dir)) {
206
+ const match = file.isFile() ? PI_SESSION.exec(file.name) : null;
207
+ if (!match) continue;
208
+ const full = join(dir, file.name);
209
+ const entry = await fileEntry('pi', match[1], full, project.name, cwdFromHeader(await readFirstLine(full)));
210
+ if (entry) entries.push(entry);
211
+ }
212
+ }
213
+ return entries;
214
+ },
215
+ async exists(id) {
216
+ for (const project of await listDir(piRoot())) {
217
+ if (!project.isDirectory()) continue;
218
+ const files = await listDir(join(piRoot(), project.name));
219
+ if (files.some(file => file.name.endsWith(`_${id}.jsonl`))) return true;
220
+ }
221
+ return false;
222
+ },
223
+ remove: removeEntries
224
+ };
@@ -0,0 +1,207 @@
1
+ /**
2
+ * Engine transcript stores, and the two questions asked of them all: which
3
+ * transcripts no chat uses (orphans), and which are copies of another (Claude
4
+ * forks). Cline keeps its sessions in memory only, so it has no store here.
5
+ */
6
+
7
+ import type { EngineType } from '$shared/types/unified';
8
+ import { debug } from '$shared/utils/logger';
9
+ import { claudeTranscripts } from './claude';
10
+ import { cursorTranscripts } from './cursor';
11
+ import { codexTranscripts, copilotTranscripts, piTranscripts, qwenTranscripts } from './file-stores';
12
+ import { openCodeTranscripts } from './opencode';
13
+ import { findContained, groupByOwner, readChain, type ChainSummary, type RedundantTranscript } from './claude-dedupe';
14
+ import { pruneTranscriptAliases, recordTranscriptAlias, transcriptAliasTargets } from './aliases';
15
+ import type { TranscriptEntry, TranscriptRemoval, TranscriptStore } from './types';
16
+
17
+ export type { TranscriptEntry, TranscriptRemoval, TranscriptStore } from './types';
18
+ export { resolveTranscriptAlias } from './aliases';
19
+
20
+ export const transcriptStores: TranscriptStore[] = [
21
+ claudeTranscripts,
22
+ codexTranscripts,
23
+ qwenTranscripts,
24
+ copilotTranscripts,
25
+ piTranscripts,
26
+ cursorTranscripts,
27
+ openCodeTranscripts
28
+ ];
29
+
30
+ export function transcriptStoreFor(engine: EngineType): TranscriptStore | null {
31
+ return transcriptStores.find(store => store.engine === engine) ?? null;
32
+ }
33
+
34
+ /**
35
+ * Whether a resume target still exists. Engines without a store (Cline) and any
36
+ * failure to check answer true: the caller falls back to replaying the chat when
37
+ * this says false, so a false negative would cost a needlessly long prompt.
38
+ */
39
+ export async function transcriptExists(engine: EngineType, id: string, projectPath: string): Promise<boolean> {
40
+ const store = transcriptStoreFor(engine);
41
+ if (!store) return true;
42
+ try {
43
+ return await store.exists(id, projectPath);
44
+ } catch (error) {
45
+ debug.warn('storage', `Could not check ${engine} transcript ${id}:`, error);
46
+ return true;
47
+ }
48
+ }
49
+
50
+ /**
51
+ * Transcripts touched this recently are never treated as unused. The engine
52
+ * writes a new session's file before Clopen has saved the first message that
53
+ * names it, and a parked turn can sit idle for a long time.
54
+ */
55
+ export const TRANSCRIPT_GRACE_MS = 6 * 60 * 60_000;
56
+
57
+ export interface TranscriptUsage {
58
+ /** Engine session ids chats refer to, per engine. */
59
+ refs: Map<EngineType, Set<string>>;
60
+ /** For each engine session id, the chats that refer to it. */
61
+ owners: Map<string, Set<string>>;
62
+ /** Engine session ids a running stream is using. */
63
+ active: Set<string>;
64
+ }
65
+
66
+ function referencedFor(engine: EngineType, usage: TranscriptUsage): Set<string> {
67
+ const referenced = new Set(usage.refs.get(engine) ?? []);
68
+ for (const id of usage.active) referenced.add(id);
69
+ for (const id of transcriptAliasTargets(engine)) referenced.add(id);
70
+ return referenced;
71
+ }
72
+
73
+ /** Transcripts no chat refers to. */
74
+ export function selectOrphans(entries: TranscriptEntry[], usage: TranscriptUsage, now = Date.now()): TranscriptEntry[] {
75
+ const byEngine = new Map<EngineType, TranscriptEntry[]>();
76
+ for (const entry of entries) {
77
+ let list = byEngine.get(entry.engine);
78
+ if (!list) byEngine.set(entry.engine, list = []);
79
+ list.push(entry);
80
+ }
81
+
82
+ const orphans: TranscriptEntry[] = [];
83
+ for (const [engine, list] of byEngine) {
84
+ const referenced = referencedFor(engine, usage);
85
+ const kept = new Set(list.filter(entry =>
86
+ referenced.has(entry.id) || now - entry.mtimeMs < TRANSCRIPT_GRACE_MS
87
+ ).map(entry => entry.id));
88
+
89
+ // A session's parent goes with it in Open Code (subagent sessions hang off
90
+ // the session that spawned them), so anything above a kept one is kept.
91
+ const byId = new Map(list.map(entry => [entry.id, entry]));
92
+ for (const id of [...kept]) {
93
+ let parent = byId.get(id)?.parentId;
94
+ for (let hops = 0; parent && hops < 64; hops++) {
95
+ kept.add(parent);
96
+ parent = byId.get(parent)?.parentId;
97
+ }
98
+ }
99
+
100
+ for (const entry of list) if (!kept.has(entry.id)) orphans.push(entry);
101
+ }
102
+ return orphans;
103
+ }
104
+
105
+ // ── Claude fork deduplication ───────────────────────────────────────────────
106
+
107
+ /**
108
+ * Per-file chain summaries are large (every entry uuid), so they are not kept;
109
+ * what is kept is the VERDICT for a group, keyed by the exact files in it. A
110
+ * rescan re-reads only groups that gained or changed a file.
111
+ */
112
+ const verdictCache = new Map<string, RedundantTranscript[]>();
113
+
114
+ function groupKey(group: TranscriptEntry[]): string {
115
+ return group.map(entry => `${entry.id}:${entry.bytes}:${Math.trunc(entry.mtimeMs)}`).sort().join('|');
116
+ }
117
+
118
+ /** Claude transcripts fully contained in a later fork of the same chat. */
119
+ export async function selectRedundant(
120
+ entries: TranscriptEntry[],
121
+ usage: TranscriptUsage,
122
+ options: { signal?: AbortSignal; now?: number } = {}
123
+ ): Promise<RedundantTranscript[]> {
124
+ const now = options.now ?? Date.now();
125
+ const candidates = entries.filter(entry =>
126
+ entry.engine === 'claude-code' &&
127
+ !entry.sidecarOnly &&
128
+ !usage.active.has(entry.id) &&
129
+ now - entry.mtimeMs >= TRANSCRIPT_GRACE_MS
130
+ );
131
+
132
+ const live = new Set<string>();
133
+ const redundant: RedundantTranscript[] = [];
134
+ for (const group of groupByOwner(candidates, usage.owners)) {
135
+ if (options.signal?.aborted) break;
136
+ const key = groupKey(group);
137
+ live.add(key);
138
+ const cached = verdictCache.get(key);
139
+ if (cached) {
140
+ redundant.push(...cached);
141
+ continue;
142
+ }
143
+ const members: { entry: TranscriptEntry; chain: ChainSummary }[] = [];
144
+ for (const entry of group) {
145
+ const chain = await readChain(entry.paths[0]);
146
+ if (chain) members.push({ entry, chain });
147
+ }
148
+ const verdict = findContained(members);
149
+ verdictCache.set(key, verdict);
150
+ redundant.push(...verdict);
151
+ }
152
+ for (const key of verdictCache.keys()) if (!live.has(key)) verdictCache.delete(key);
153
+ return redundant;
154
+ }
155
+
156
+ /** Replace each redundant transcript by an alias to its container, then delete it. */
157
+ export async function applyDedupe(redundant: RedundantTranscript[]): Promise<TranscriptRemoval> {
158
+ const removable: TranscriptEntry[] = [];
159
+ for (const item of redundant) {
160
+ try {
161
+ // Alias first: if the delete then fails, resuming through the alias is
162
+ // still the same conversation, so the order can never strand a chat.
163
+ recordTranscriptAlias('claude-code', item.entry.id, item.target.id, item.resumeAt);
164
+ removable.push(item.entry);
165
+ } catch (error) {
166
+ debug.warn('storage', `Could not alias ${item.entry.id}:`, error);
167
+ }
168
+ }
169
+ verdictCache.clear();
170
+ return claudeTranscripts.remove(removable);
171
+ }
172
+
173
+ /** Delete orphaned transcripts and forget aliases nothing refers to. */
174
+ export async function removeOrphans(orphans: TranscriptEntry[], usage: TranscriptUsage): Promise<TranscriptRemoval> {
175
+ const total: TranscriptRemoval = { freedBytes: 0, removed: 0, errors: [] };
176
+ const byEngine = new Map<EngineType, TranscriptEntry[]>();
177
+ for (const entry of orphans) {
178
+ let list = byEngine.get(entry.engine);
179
+ if (!list) byEngine.set(entry.engine, list = []);
180
+ list.push(entry);
181
+ }
182
+ for (const [engine, list] of byEngine) {
183
+ const store = transcriptStoreFor(engine);
184
+ if (!store) continue;
185
+ const result = await store.remove(list);
186
+ total.freedBytes += result.freedBytes;
187
+ total.removed += result.removed;
188
+ total.errors.push(...result.errors);
189
+ }
190
+ pruneTranscriptAliases('claude-code', new Set(usage.refs.get('claude-code') ?? []));
191
+ verdictCache.clear();
192
+ return total;
193
+ }
194
+
195
+ /** Every transcript of every engine. */
196
+ export async function listAllTranscripts(signal?: AbortSignal): Promise<TranscriptEntry[]> {
197
+ const all: TranscriptEntry[] = [];
198
+ for (const store of transcriptStores) {
199
+ if (signal?.aborted) break;
200
+ try {
201
+ all.push(...await store.list(signal));
202
+ } catch (error) {
203
+ debug.warn('storage', `Could not list ${store.engine} transcripts:`, error);
204
+ }
205
+ }
206
+ return all;
207
+ }