@myrialabs/clopen 0.4.49 → 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 (486) 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/background-wait.test.ts +28 -0
  5. package/backend/chat/engine-handoff.ts +42 -6
  6. package/backend/chat/message-pages.test.ts +17 -0
  7. package/backend/chat/message-pages.ts +6 -2
  8. package/backend/chat/stream-manager.ts +114 -19
  9. package/backend/containers/actions.ts +22 -0
  10. package/backend/control/actions/projects.ts +93 -37
  11. package/backend/control/folders.test.ts +27 -2
  12. package/backend/control/index.ts +2 -1
  13. package/backend/database/migrations/056_support_mssql_driver.ts +7 -0
  14. package/backend/database/migrations/077_create_integration_db_links.ts +7 -0
  15. package/backend/database/migrations/086_single_owner.ts +66 -73
  16. package/backend/database/migrations/088_create_messages_fts_map.ts +52 -0
  17. package/backend/database/migrations/089_add_memory_layout_tiles.ts +58 -0
  18. package/backend/database/migrations/090_create_storage_tables.ts +83 -0
  19. package/backend/database/migrations/index.ts +25 -2
  20. package/backend/database/queries/graph-queries.ts +392 -135
  21. package/backend/database/queries/integration-queries.ts +10 -0
  22. package/backend/database/queries/memory-queue-queries.ts +11 -0
  23. package/backend/database/queries/message-fts.test.ts +120 -0
  24. package/backend/database/queries/message-queries.ts +45 -9
  25. package/backend/database/queries/project-queries.ts +6 -0
  26. package/backend/database/queries/session-queries.ts +6 -2
  27. package/backend/database/queries/utils-queries.ts +3 -0
  28. package/backend/database/utils/migration-runner.test.ts +196 -0
  29. package/backend/database/utils/migration-runner.ts +61 -16
  30. package/backend/database/utils/seeder-runner.ts +22 -16
  31. package/backend/engine/adapters/claude/environment.ts +4 -0
  32. package/backend/engine/adapters/claude/input-gate.test.ts +59 -0
  33. package/backend/engine/adapters/claude/input-gate.ts +74 -0
  34. package/backend/engine/adapters/claude/message-converter.test.ts +16 -0
  35. package/backend/engine/adapters/claude/message-converter.ts +8 -0
  36. package/backend/engine/adapters/claude/stream.ts +20 -0
  37. package/backend/engine/adapters/cursor/environment.ts +1 -1
  38. package/backend/engine/adapters/qwen/session-store.ts +10 -1
  39. package/backend/engine/types.ts +7 -0
  40. package/backend/git/identity/cli.ts +35 -0
  41. package/backend/git/identity/env.test.ts +52 -1
  42. package/backend/git/identity/env.ts +69 -10
  43. package/backend/git/identity/index.ts +25 -6
  44. package/backend/git/identity/resolve.ts +2 -1
  45. package/backend/git/identity/scope-config.test.ts +7 -4
  46. package/backend/git/identity/scope-config.ts +13 -7
  47. package/backend/git-hosts/accounts.ts +106 -0
  48. package/backend/git-hosts/auth/client-ids.ts +34 -0
  49. package/backend/git-hosts/auth/connect.ts +110 -0
  50. package/backend/git-hosts/auth/endpoints.ts +130 -0
  51. package/backend/git-hosts/auth/flows.ts +355 -0
  52. package/backend/git-hosts/auth/local.ts +152 -0
  53. package/backend/git-hosts/ci.ts +18 -0
  54. package/backend/git-hosts/cli.test.ts +82 -0
  55. package/backend/git-hosts/cli.ts +342 -0
  56. package/backend/git-hosts/credentials.ts +173 -0
  57. package/backend/git-hosts/git-credential.ts +30 -0
  58. package/backend/git-hosts/health.ts +39 -0
  59. package/backend/git-hosts/http.ts +174 -0
  60. package/backend/git-hosts/index.ts +34 -0
  61. package/backend/git-hosts/providers/bitbucket.ts +186 -0
  62. package/backend/git-hosts/providers/gitea.ts +208 -0
  63. package/backend/git-hosts/providers/github.ts +270 -0
  64. package/backend/git-hosts/providers/gitlab-client.ts +70 -0
  65. package/backend/git-hosts/providers/gitlab.ts +285 -0
  66. package/backend/git-hosts/providers/locators.test.ts +68 -0
  67. package/backend/git-hosts/registry.ts +50 -0
  68. package/backend/git-hosts/service.ts +432 -0
  69. package/backend/git-hosts/types.ts +82 -0
  70. package/backend/git-hosts/urls.test.ts +42 -0
  71. package/backend/git-hosts/urls.ts +69 -0
  72. package/backend/index.ts +84 -17
  73. package/backend/integrations/accounts.ts +50 -3
  74. package/backend/integrations/registry/define.ts +9 -0
  75. package/backend/integrations/registry/index.ts +11 -0
  76. package/backend/integrations/registry/providers/bitbucket.ts +51 -0
  77. package/backend/integrations/registry/providers/gitea.ts +53 -0
  78. package/backend/integrations/registry/providers/github.ts +24 -7
  79. package/backend/integrations/registry/providers/gitlab.ts +57 -0
  80. package/backend/integrations/registry/types.ts +13 -1
  81. package/backend/mcp/internal/servers/browser-automation/actions/inspect.ts +115 -31
  82. package/backend/mcp/internal/servers/browser-automation/description.ts +5 -0
  83. package/backend/memory/README.md +7 -4
  84. package/backend/memory/layout.test.ts +377 -0
  85. package/backend/memory/layout.ts +1029 -265
  86. package/backend/memory/view.ts +257 -386
  87. package/backend/mentions/diff.ts +63 -0
  88. package/backend/mentions/index.ts +109 -0
  89. package/backend/mentions/mentions.test.ts +27 -0
  90. package/backend/mentions/shared.ts +82 -0
  91. package/backend/mentions/sources/ai-changes.ts +140 -0
  92. package/backend/mentions/sources/chats.ts +122 -0
  93. package/backend/mentions/sources/database.ts +211 -0
  94. package/backend/mentions/sources/files.ts +240 -0
  95. package/backend/mentions/sources/git.ts +308 -0
  96. package/backend/mentions/sources/notes-memory.ts +121 -0
  97. package/backend/mentions/sources/ops.ts +125 -0
  98. package/backend/mentions/sources/preview.ts +153 -0
  99. package/backend/mentions/sources/projects.ts +114 -0
  100. package/backend/mentions/sources/system.ts +135 -0
  101. package/backend/mentions/sources/terminal.ts +50 -0
  102. package/backend/mentions/types.ts +75 -0
  103. package/backend/preview/browser/bot-check-frames.test.ts +49 -0
  104. package/backend/preview/browser/bot-check-frames.ts +66 -0
  105. package/backend/preview/browser/browser-dialog-handler.ts +6 -5
  106. package/backend/preview/browser/browser-host-bridge.ts +4 -2
  107. package/backend/preview/browser/browser-native-ui-handler.ts +21 -0
  108. package/backend/preview/browser/browser-pool.ts +26 -17
  109. package/backend/preview/browser/browser-preview-service.ts +164 -2
  110. package/backend/preview/browser/browser-screenshot.test.ts +113 -0
  111. package/backend/preview/browser/browser-screenshot.ts +396 -0
  112. package/backend/preview/browser/browser-tab-manager.ts +35 -186
  113. package/backend/preview/browser/browser-video-capture.ts +12 -17
  114. package/backend/preview/browser/element-describe.ts +125 -0
  115. package/backend/preview/browser/page-binding.ts +141 -0
  116. package/backend/preview/browser/screenshot-files.test.ts +117 -0
  117. package/backend/preview/browser/screenshot-files.ts +134 -0
  118. package/backend/preview/browser/user-agent.test.ts +25 -0
  119. package/backend/preview/browser/user-agent.ts +100 -0
  120. package/backend/project/status-manager.ts +4 -2
  121. package/backend/projects/engine-transcripts.ts +153 -0
  122. package/backend/projects/folder-guard.ts +55 -0
  123. package/backend/projects/move.test.ts +208 -0
  124. package/backend/projects/move.ts +277 -0
  125. package/backend/projects/project-cleanup.integration.test.ts +3 -1
  126. package/backend/projects/project-cleanup.ts +10 -0
  127. package/backend/storage/actions.ts +260 -0
  128. package/backend/storage/chats.test.ts +57 -0
  129. package/backend/storage/chats.ts +170 -0
  130. package/backend/storage/database.ts +105 -0
  131. package/backend/storage/engine-homes.ts +145 -0
  132. package/backend/storage/fs-size.ts +111 -0
  133. package/backend/storage/history.ts +39 -0
  134. package/backend/storage/policy.ts +156 -0
  135. package/backend/storage/preview-profiles.ts +169 -0
  136. package/backend/storage/purge.ts +158 -0
  137. package/backend/storage/scanner.ts +339 -0
  138. package/backend/storage/session-index.ts +208 -0
  139. package/backend/storage/snapshots.ts +99 -0
  140. package/backend/storage/storage-flow.test.ts +137 -0
  141. package/backend/storage/transcripts/aliases.ts +75 -0
  142. package/backend/storage/transcripts/claude-dedupe.test.ts +101 -0
  143. package/backend/storage/transcripts/claude-dedupe.ts +152 -0
  144. package/backend/storage/transcripts/claude.ts +155 -0
  145. package/backend/storage/transcripts/cursor.ts +165 -0
  146. package/backend/storage/transcripts/file-stores.ts +224 -0
  147. package/backend/storage/transcripts/index.ts +207 -0
  148. package/backend/storage/transcripts/opencode.ts +124 -0
  149. package/backend/storage/transcripts/references.ts +42 -0
  150. package/backend/storage/transcripts/types.ts +58 -0
  151. package/backend/storage/worktrees.ts +114 -0
  152. package/backend/terminal/ptykit.ts +25 -0
  153. package/backend/update/registry.ts +24 -0
  154. package/backend/update/release-notes.test.ts +110 -0
  155. package/backend/update/release-notes.ts +132 -0
  156. package/backend/update/restart.ts +159 -0
  157. package/backend/utils/env.test.ts +64 -0
  158. package/backend/utils/env.ts +23 -55
  159. package/backend/utils/port-utils.ts +13 -0
  160. package/backend/work/index.ts +13 -2
  161. package/backend/work/providers/github/actions-logs.ts +1 -1
  162. package/backend/work/providers/github/adapter.ts +32 -1
  163. package/backend/work/providers/github/client.ts +7 -3
  164. package/backend/work/providers/gitlab/adapter.ts +770 -0
  165. package/backend/work/providers/gitlab/system-notes.test.ts +24 -0
  166. package/backend/work/service.ts +60 -36
  167. package/backend/work/start-work.ts +1 -1
  168. package/backend/work/types.ts +4 -0
  169. package/backend/worktrees/index.ts +1 -0
  170. package/backend/worktrees/service.ts +23 -2
  171. package/backend/ws/chat/composer.ts +47 -6
  172. package/backend/ws/chat/stream.ts +19 -10
  173. package/backend/ws/files/search.ts +1 -1
  174. package/backend/ws/files/write.ts +27 -0
  175. package/backend/ws/hosting/index.ts +231 -0
  176. package/backend/ws/index.ts +12 -2
  177. package/backend/ws/integrations/crud.ts +31 -5
  178. package/backend/ws/integrations/hosting-auth.ts +227 -0
  179. package/backend/ws/integrations/index.ts +2 -0
  180. package/backend/ws/memory/crud.ts +118 -81
  181. package/backend/ws/mentions/index.ts +81 -0
  182. package/backend/ws/messages/crud.ts +3 -1
  183. package/backend/ws/preview/browser/screenshot.ts +184 -0
  184. package/backend/ws/preview/index.ts +23 -0
  185. package/backend/ws/projects/crud.ts +66 -58
  186. package/backend/ws/sessions/crud.ts +7 -95
  187. package/backend/ws/snapshot/changes.ts +3 -3
  188. package/backend/ws/storage/index.ts +102 -0
  189. package/backend/ws/system/index.ts +7 -0
  190. package/backend/ws/system/operations.ts +125 -69
  191. package/backend/ws/work/context.ts +3 -4
  192. package/backend/ws/work/crud.ts +33 -0
  193. package/backend/ws/work/schemas.ts +4 -1
  194. package/bin/clopen.ts +18 -18
  195. package/dist/assets/{index-DD0-3EWg.js → index-B9rHDvjg.js} +1 -1
  196. package/dist/assets/index-B9rHDvjg.js.br +0 -0
  197. package/dist/assets/index-B9rHDvjg.js.gz +0 -0
  198. package/dist/assets/{index-CrVWZH_D.js → index-DFlwOd7k.js} +1 -1
  199. package/dist/assets/index-DFlwOd7k.js.br +0 -0
  200. package/dist/assets/index-DFlwOd7k.js.gz +0 -0
  201. package/dist/assets/main-Bz_brxxS.css +1 -0
  202. package/dist/assets/main-Bz_brxxS.css.br +0 -0
  203. package/dist/assets/main-Bz_brxxS.css.gz +0 -0
  204. package/dist/assets/main-DRcX9SHx.js +1273 -0
  205. package/dist/assets/main-DRcX9SHx.js.br +0 -0
  206. package/dist/assets/main-DRcX9SHx.js.gz +0 -0
  207. package/dist/assets/pdf-DfwfQPLy.js +57 -0
  208. package/dist/assets/pdf-DfwfQPLy.js.br +0 -0
  209. package/dist/assets/pdf-DfwfQPLy.js.gz +0 -0
  210. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs +27 -0
  211. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.br +0 -0
  212. package/dist/assets/pdf.worker.min-B5Yc7dP4.mjs.gz +0 -0
  213. package/dist/assets/pdf.worker.min-BOrSNwfp.js +1 -0
  214. package/dist/index.html +2 -2
  215. package/dist/index.html.br +0 -0
  216. package/dist/index.html.gz +0 -0
  217. package/dist/vendor/pdfjs/cmaps/78-EUC-H.bcmap +0 -0
  218. package/dist/vendor/pdfjs/cmaps/78-EUC-V.bcmap +0 -0
  219. package/dist/vendor/pdfjs/cmaps/78-H.bcmap +0 -0
  220. package/dist/vendor/pdfjs/cmaps/78-RKSJ-H.bcmap +0 -0
  221. package/dist/vendor/pdfjs/cmaps/78-RKSJ-V.bcmap +0 -0
  222. package/dist/vendor/pdfjs/cmaps/78-V.bcmap +0 -0
  223. package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-H.bcmap +0 -0
  224. package/dist/vendor/pdfjs/cmaps/78ms-RKSJ-V.bcmap +0 -0
  225. package/dist/vendor/pdfjs/cmaps/83pv-RKSJ-H.bcmap +0 -0
  226. package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-H.bcmap +0 -0
  227. package/dist/vendor/pdfjs/cmaps/90ms-RKSJ-V.bcmap +0 -0
  228. package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-H.bcmap +0 -0
  229. package/dist/vendor/pdfjs/cmaps/90msp-RKSJ-V.bcmap +0 -0
  230. package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-H.bcmap +0 -0
  231. package/dist/vendor/pdfjs/cmaps/90pv-RKSJ-V.bcmap +0 -0
  232. package/dist/vendor/pdfjs/cmaps/Add-H.bcmap +0 -0
  233. package/dist/vendor/pdfjs/cmaps/Add-RKSJ-H.bcmap +0 -0
  234. package/dist/vendor/pdfjs/cmaps/Add-RKSJ-V.bcmap +0 -0
  235. package/dist/vendor/pdfjs/cmaps/Add-V.bcmap +0 -0
  236. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-0.bcmap +0 -0
  237. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-1.bcmap +0 -0
  238. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-2.bcmap +0 -0
  239. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-3.bcmap +0 -0
  240. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-4.bcmap +0 -0
  241. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-5.bcmap +0 -0
  242. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-6.bcmap +0 -0
  243. package/dist/vendor/pdfjs/cmaps/Adobe-CNS1-UCS2.bcmap +0 -0
  244. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-0.bcmap +0 -0
  245. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-1.bcmap +0 -0
  246. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-2.bcmap +0 -0
  247. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-3.bcmap +0 -0
  248. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-4.bcmap +0 -0
  249. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-5.bcmap +0 -0
  250. package/dist/vendor/pdfjs/cmaps/Adobe-GB1-UCS2.bcmap +0 -0
  251. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-0.bcmap +0 -0
  252. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-1.bcmap +0 -0
  253. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-2.bcmap +0 -0
  254. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-3.bcmap +0 -0
  255. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-4.bcmap +0 -0
  256. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-5.bcmap +0 -0
  257. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-6.bcmap +0 -0
  258. package/dist/vendor/pdfjs/cmaps/Adobe-Japan1-UCS2.bcmap +0 -0
  259. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-0.bcmap +0 -0
  260. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-1.bcmap +0 -0
  261. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-2.bcmap +0 -0
  262. package/dist/vendor/pdfjs/cmaps/Adobe-Korea1-UCS2.bcmap +0 -0
  263. package/dist/vendor/pdfjs/cmaps/B5-H.bcmap +0 -0
  264. package/dist/vendor/pdfjs/cmaps/B5-V.bcmap +0 -0
  265. package/dist/vendor/pdfjs/cmaps/B5pc-H.bcmap +0 -0
  266. package/dist/vendor/pdfjs/cmaps/B5pc-V.bcmap +0 -0
  267. package/dist/vendor/pdfjs/cmaps/CNS-EUC-H.bcmap +0 -0
  268. package/dist/vendor/pdfjs/cmaps/CNS-EUC-V.bcmap +0 -0
  269. package/dist/vendor/pdfjs/cmaps/CNS1-H.bcmap +0 -0
  270. package/dist/vendor/pdfjs/cmaps/CNS1-V.bcmap +0 -0
  271. package/dist/vendor/pdfjs/cmaps/CNS2-H.bcmap +0 -0
  272. package/dist/vendor/pdfjs/cmaps/CNS2-V.bcmap +3 -0
  273. package/dist/vendor/pdfjs/cmaps/ETHK-B5-H.bcmap +0 -0
  274. package/dist/vendor/pdfjs/cmaps/ETHK-B5-V.bcmap +0 -0
  275. package/dist/vendor/pdfjs/cmaps/ETen-B5-H.bcmap +0 -0
  276. package/dist/vendor/pdfjs/cmaps/ETen-B5-V.bcmap +0 -0
  277. package/dist/vendor/pdfjs/cmaps/ETenms-B5-H.bcmap +3 -0
  278. package/dist/vendor/pdfjs/cmaps/ETenms-B5-V.bcmap +0 -0
  279. package/dist/vendor/pdfjs/cmaps/EUC-H.bcmap +0 -0
  280. package/dist/vendor/pdfjs/cmaps/EUC-V.bcmap +0 -0
  281. package/dist/vendor/pdfjs/cmaps/Ext-H.bcmap +0 -0
  282. package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-H.bcmap +0 -0
  283. package/dist/vendor/pdfjs/cmaps/Ext-RKSJ-V.bcmap +0 -0
  284. package/dist/vendor/pdfjs/cmaps/Ext-V.bcmap +0 -0
  285. package/dist/vendor/pdfjs/cmaps/GB-EUC-H.bcmap +0 -0
  286. package/dist/vendor/pdfjs/cmaps/GB-EUC-V.bcmap +0 -0
  287. package/dist/vendor/pdfjs/cmaps/GB-H.bcmap +6 -0
  288. package/dist/vendor/pdfjs/cmaps/GB-V.bcmap +0 -0
  289. package/dist/vendor/pdfjs/cmaps/GBK-EUC-H.bcmap +0 -0
  290. package/dist/vendor/pdfjs/cmaps/GBK-EUC-V.bcmap +0 -0
  291. package/dist/vendor/pdfjs/cmaps/GBK2K-H.bcmap +0 -0
  292. package/dist/vendor/pdfjs/cmaps/GBK2K-V.bcmap +0 -0
  293. package/dist/vendor/pdfjs/cmaps/GBKp-EUC-H.bcmap +0 -0
  294. package/dist/vendor/pdfjs/cmaps/GBKp-EUC-V.bcmap +0 -0
  295. package/dist/vendor/pdfjs/cmaps/GBT-EUC-H.bcmap +0 -0
  296. package/dist/vendor/pdfjs/cmaps/GBT-EUC-V.bcmap +0 -0
  297. package/dist/vendor/pdfjs/cmaps/GBT-H.bcmap +0 -0
  298. package/dist/vendor/pdfjs/cmaps/GBT-V.bcmap +0 -0
  299. package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-H.bcmap +0 -0
  300. package/dist/vendor/pdfjs/cmaps/GBTpc-EUC-V.bcmap +0 -0
  301. package/dist/vendor/pdfjs/cmaps/GBpc-EUC-H.bcmap +0 -0
  302. package/dist/vendor/pdfjs/cmaps/GBpc-EUC-V.bcmap +0 -0
  303. package/dist/vendor/pdfjs/cmaps/H.bcmap +0 -0
  304. package/dist/vendor/pdfjs/cmaps/HKdla-B5-H.bcmap +0 -0
  305. package/dist/vendor/pdfjs/cmaps/HKdla-B5-V.bcmap +0 -0
  306. package/dist/vendor/pdfjs/cmaps/HKdlb-B5-H.bcmap +0 -0
  307. package/dist/vendor/pdfjs/cmaps/HKdlb-B5-V.bcmap +0 -0
  308. package/dist/vendor/pdfjs/cmaps/HKgccs-B5-H.bcmap +0 -0
  309. package/dist/vendor/pdfjs/cmaps/HKgccs-B5-V.bcmap +0 -0
  310. package/dist/vendor/pdfjs/cmaps/HKm314-B5-H.bcmap +0 -0
  311. package/dist/vendor/pdfjs/cmaps/HKm314-B5-V.bcmap +0 -0
  312. package/dist/vendor/pdfjs/cmaps/HKm471-B5-H.bcmap +0 -0
  313. package/dist/vendor/pdfjs/cmaps/HKm471-B5-V.bcmap +0 -0
  314. package/dist/vendor/pdfjs/cmaps/HKscs-B5-H.bcmap +0 -0
  315. package/dist/vendor/pdfjs/cmaps/HKscs-B5-V.bcmap +0 -0
  316. package/dist/vendor/pdfjs/cmaps/Hankaku.bcmap +0 -0
  317. package/dist/vendor/pdfjs/cmaps/Hiragana.bcmap +0 -0
  318. package/dist/vendor/pdfjs/cmaps/KSC-EUC-H.bcmap +0 -0
  319. package/dist/vendor/pdfjs/cmaps/KSC-EUC-V.bcmap +0 -0
  320. package/dist/vendor/pdfjs/cmaps/KSC-H.bcmap +0 -0
  321. package/dist/vendor/pdfjs/cmaps/KSC-Johab-H.bcmap +0 -0
  322. package/dist/vendor/pdfjs/cmaps/KSC-Johab-V.bcmap +0 -0
  323. package/dist/vendor/pdfjs/cmaps/KSC-V.bcmap +0 -0
  324. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-H.bcmap +0 -0
  325. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-H.bcmap +0 -0
  326. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-HW-V.bcmap +0 -0
  327. package/dist/vendor/pdfjs/cmaps/KSCms-UHC-V.bcmap +0 -0
  328. package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-H.bcmap +0 -0
  329. package/dist/vendor/pdfjs/cmaps/KSCpc-EUC-V.bcmap +0 -0
  330. package/dist/vendor/pdfjs/cmaps/Katakana.bcmap +0 -0
  331. package/dist/vendor/pdfjs/cmaps/LICENSE +36 -0
  332. package/dist/vendor/pdfjs/cmaps/NWP-H.bcmap +0 -0
  333. package/dist/vendor/pdfjs/cmaps/NWP-V.bcmap +0 -0
  334. package/dist/vendor/pdfjs/cmaps/RKSJ-H.bcmap +0 -0
  335. package/dist/vendor/pdfjs/cmaps/RKSJ-V.bcmap +0 -0
  336. package/dist/vendor/pdfjs/cmaps/Roman.bcmap +0 -0
  337. package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-H.bcmap +0 -0
  338. package/dist/vendor/pdfjs/cmaps/UniCNS-UCS2-V.bcmap +0 -0
  339. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-H.bcmap +0 -0
  340. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF16-V.bcmap +0 -0
  341. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-H.bcmap +0 -0
  342. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF32-V.bcmap +0 -0
  343. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-H.bcmap +0 -0
  344. package/dist/vendor/pdfjs/cmaps/UniCNS-UTF8-V.bcmap +0 -0
  345. package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-H.bcmap +0 -0
  346. package/dist/vendor/pdfjs/cmaps/UniGB-UCS2-V.bcmap +0 -0
  347. package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-H.bcmap +0 -0
  348. package/dist/vendor/pdfjs/cmaps/UniGB-UTF16-V.bcmap +0 -0
  349. package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-H.bcmap +0 -0
  350. package/dist/vendor/pdfjs/cmaps/UniGB-UTF32-V.bcmap +0 -0
  351. package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-H.bcmap +0 -0
  352. package/dist/vendor/pdfjs/cmaps/UniGB-UTF8-V.bcmap +0 -0
  353. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-H.bcmap +0 -0
  354. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-H.bcmap +0 -0
  355. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-HW-V.bcmap +0 -0
  356. package/dist/vendor/pdfjs/cmaps/UniJIS-UCS2-V.bcmap +0 -0
  357. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-H.bcmap +0 -0
  358. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF16-V.bcmap +0 -0
  359. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-H.bcmap +0 -0
  360. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF32-V.bcmap +0 -0
  361. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-H.bcmap +0 -0
  362. package/dist/vendor/pdfjs/cmaps/UniJIS-UTF8-V.bcmap +0 -0
  363. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-H.bcmap +0 -0
  364. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF16-V.bcmap +0 -0
  365. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-H.bcmap +0 -0
  366. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF32-V.bcmap +0 -0
  367. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-H.bcmap +0 -0
  368. package/dist/vendor/pdfjs/cmaps/UniJIS2004-UTF8-V.bcmap +0 -0
  369. package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-HW-V.bcmap +0 -0
  370. package/dist/vendor/pdfjs/cmaps/UniJISPro-UCS2-V.bcmap +0 -0
  371. package/dist/vendor/pdfjs/cmaps/UniJISPro-UTF8-V.bcmap +0 -0
  372. package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-H.bcmap +0 -0
  373. package/dist/vendor/pdfjs/cmaps/UniJISX0213-UTF32-V.bcmap +0 -0
  374. package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-H.bcmap +0 -0
  375. package/dist/vendor/pdfjs/cmaps/UniJISX02132004-UTF32-V.bcmap +0 -0
  376. package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-H.bcmap +0 -0
  377. package/dist/vendor/pdfjs/cmaps/UniKS-UCS2-V.bcmap +0 -0
  378. package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-H.bcmap +0 -0
  379. package/dist/vendor/pdfjs/cmaps/UniKS-UTF16-V.bcmap +0 -0
  380. package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-H.bcmap +0 -0
  381. package/dist/vendor/pdfjs/cmaps/UniKS-UTF32-V.bcmap +0 -0
  382. package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-H.bcmap +0 -0
  383. package/dist/vendor/pdfjs/cmaps/UniKS-UTF8-V.bcmap +0 -0
  384. package/dist/vendor/pdfjs/cmaps/V.bcmap +0 -0
  385. package/dist/vendor/pdfjs/cmaps/WP-Symbol.bcmap +0 -0
  386. package/dist/vendor/pdfjs/iccs/CGATS001Compat-v2-micro.icc +0 -0
  387. package/dist/vendor/pdfjs/iccs/LICENSE +116 -0
  388. package/dist/vendor/pdfjs/standard_fonts/FoxitDingbats.pfb +0 -0
  389. package/dist/vendor/pdfjs/standard_fonts/FoxitFixed.pfb +0 -0
  390. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBold.pfb +0 -0
  391. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedBoldItalic.pfb +0 -0
  392. package/dist/vendor/pdfjs/standard_fonts/FoxitFixedItalic.pfb +0 -0
  393. package/dist/vendor/pdfjs/standard_fonts/FoxitSerif.pfb +0 -0
  394. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBold.pfb +0 -0
  395. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifBoldItalic.pfb +0 -0
  396. package/dist/vendor/pdfjs/standard_fonts/FoxitSerifItalic.pfb +0 -0
  397. package/dist/vendor/pdfjs/standard_fonts/FoxitSymbol.pfb +0 -0
  398. package/dist/vendor/pdfjs/standard_fonts/LICENSE_FOXIT +27 -0
  399. package/dist/vendor/pdfjs/standard_fonts/LICENSE_LIBERATION +363 -0
  400. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Bold.ttf +0 -0
  401. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-BoldItalic.ttf +0 -0
  402. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Italic.ttf +0 -0
  403. package/dist/vendor/pdfjs/standard_fonts/LiberationSans-Regular.ttf +0 -0
  404. package/dist/vendor/pdfjs/wasm/LICENSE_JBIG2 +196 -0
  405. package/dist/vendor/pdfjs/wasm/LICENSE_OPENJPEG +39 -0
  406. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_JBIG2 +13 -0
  407. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_OPENJPEG +22 -0
  408. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QCMS +19 -0
  409. package/dist/vendor/pdfjs/wasm/LICENSE_PDFJS_QUICKJS +21 -0
  410. package/dist/vendor/pdfjs/wasm/LICENSE_QCMS +21 -0
  411. package/dist/vendor/pdfjs/wasm/LICENSE_QUICKJS +22 -0
  412. package/dist/vendor/pdfjs/wasm/jbig2.wasm +0 -0
  413. package/dist/vendor/pdfjs/wasm/jbig2.wasm.br +0 -0
  414. package/dist/vendor/pdfjs/wasm/jbig2.wasm.gz +0 -0
  415. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js +2 -0
  416. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.br +0 -0
  417. package/dist/vendor/pdfjs/wasm/jbig2_nowasm_fallback.js.gz +0 -0
  418. package/dist/vendor/pdfjs/wasm/openjpeg.wasm +0 -0
  419. package/dist/vendor/pdfjs/wasm/openjpeg.wasm.br +0 -0
  420. package/dist/vendor/pdfjs/wasm/openjpeg.wasm.gz +0 -0
  421. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js +2 -0
  422. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.br +0 -0
  423. package/dist/vendor/pdfjs/wasm/openjpeg_nowasm_fallback.js.gz +0 -0
  424. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm +0 -0
  425. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.br +0 -0
  426. package/dist/vendor/pdfjs/wasm/qcms_bg.wasm.gz +0 -0
  427. package/dist/vendor/pdfjs/wasm/quickjs-eval.js +16 -0
  428. package/dist/vendor/pdfjs/wasm/quickjs-eval.js.br +0 -0
  429. package/dist/vendor/pdfjs/wasm/quickjs-eval.js.gz +0 -0
  430. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm +0 -0
  431. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.br +0 -0
  432. package/dist/vendor/pdfjs/wasm/quickjs-eval.wasm.gz +0 -0
  433. package/package.json +8 -9
  434. package/scripts/start.ts +21 -4
  435. package/shared/constants/binary-extensions.ts +20 -4
  436. package/shared/constants/support.test.ts +27 -0
  437. package/shared/constants/support.ts +79 -0
  438. package/shared/constants/tool-icons.ts +7 -1
  439. package/shared/types/database/schema.ts +6 -0
  440. package/shared/types/git-hosting.ts +241 -0
  441. package/shared/types/integrations.ts +51 -1
  442. package/shared/types/memory.ts +96 -73
  443. package/shared/types/mentions.ts +96 -0
  444. package/shared/types/release-notes.ts +31 -0
  445. package/shared/types/storage.ts +175 -0
  446. package/shared/types/stores/settings.ts +16 -0
  447. package/shared/types/unified/index.ts +2 -0
  448. package/shared/types/unified/message.ts +26 -1
  449. package/shared/types/unified/stream.ts +22 -1
  450. package/shared/types/unified/tool.ts +4 -0
  451. package/shared/types/work.ts +6 -0
  452. package/shared/utils/attachment-mentions.test.ts +39 -0
  453. package/shared/utils/attachment-mentions.ts +100 -0
  454. package/shared/utils/context-document.test.ts +53 -0
  455. package/shared/utils/context-document.ts +226 -0
  456. package/shared/utils/device-frame.test.ts +73 -0
  457. package/shared/utils/device-frame.ts +320 -0
  458. package/shared/utils/fuzzy.ts +79 -0
  459. package/shared/utils/launcher-fingerprint.test.ts +73 -0
  460. package/shared/utils/launcher-fingerprint.ts +108 -0
  461. package/shared/utils/logger.ts +2 -0
  462. package/shared/utils/page-colors.test.ts +17 -0
  463. package/shared/utils/page-colors.ts +24 -0
  464. package/shared/utils/process-supervisor.test.ts +88 -1
  465. package/shared/utils/process-supervisor.ts +123 -29
  466. package/shared/utils/process-tree.ts +99 -0
  467. package/shared/utils/restart-intent.test.ts +57 -0
  468. package/shared/utils/restart-intent.ts +80 -0
  469. package/shared/utils/semver.test.ts +33 -0
  470. package/shared/utils/semver.ts +35 -0
  471. package/shared/utils/supervised-child.ts +44 -0
  472. package/shared/utils/supervisor-protocol.ts +20 -0
  473. package/.env.example +0 -9
  474. package/dist/assets/graph-layout.worker-CRFqN7ZQ.js +0 -1
  475. package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
  476. package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
  477. package/dist/assets/index-CrVWZH_D.js.br +0 -0
  478. package/dist/assets/index-CrVWZH_D.js.gz +0 -0
  479. package/dist/assets/index-DD0-3EWg.js.br +0 -0
  480. package/dist/assets/index-DD0-3EWg.js.gz +0 -0
  481. package/dist/assets/main-D2_TmcwQ.js +0 -1240
  482. package/dist/assets/main-D2_TmcwQ.js.br +0 -0
  483. package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
  484. package/dist/assets/main-Yucigcmf.css +0 -1
  485. package/dist/assets/main-Yucigcmf.css.br +0 -0
  486. package/dist/assets/main-Yucigcmf.css.gz +0 -0
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Open Code sessions: rows in `pool/<scope>/opencode/opencode.db`, one database
3
+ * per Profile scope.
4
+ *
5
+ * Read with a read-only connection. Removed only through Open Code's own API
6
+ * (`DELETE /session/{id}`), never by writing to its database: the schema is Open
7
+ * Code's, it migrates it, and a running server holds it open. A session's bytes
8
+ * are not apportioned — that would mean grouping every row of a gigabyte table
9
+ * on the server's thread — so the store reports its database size as a whole and
10
+ * sessions by count. The database does not shrink when rows go; Open Code reuses
11
+ * the space.
12
+ */
13
+
14
+ import { Database } from 'bun:sqlite';
15
+ import fs from 'node:fs/promises';
16
+ import { join } from 'node:path';
17
+ import { getEngineUserConfigDir } from '$backend/utils/paths';
18
+ import { debug } from '$shared/utils/logger';
19
+ import type { TranscriptEntry, TranscriptRemoval, TranscriptStore } from './types';
20
+
21
+ const poolRoot = () => join(getEngineUserConfigDir('opencode'), 'pool');
22
+ /** Base64url of `DEFAULT_SCOPE_KEY` in the Open Code adapter. */
23
+ const DEFAULT_SCOPE_DIR = Buffer.from('mcp:*|agents:*').toString('base64url');
24
+
25
+ export async function openCodeDatabases(): Promise<{ scopeDir: string; file: string }[]> {
26
+ try {
27
+ const scopes = await fs.readdir(poolRoot());
28
+ const found: { scopeDir: string; file: string }[] = [];
29
+ for (const scope of scopes) {
30
+ const file = join(poolRoot(), scope, 'opencode', 'opencode.db');
31
+ try {
32
+ await fs.access(file);
33
+ found.push({ scopeDir: scope, file });
34
+ } catch { /* scope without a database yet */ }
35
+ }
36
+ return found;
37
+ } catch {
38
+ return [];
39
+ }
40
+ }
41
+
42
+ function readSessions(file: string): { id: string; parent_id: string | null; directory: string | null; time_updated: number | null }[] {
43
+ let db: Database | null = null;
44
+ try {
45
+ db = new Database(file, { readonly: true });
46
+ return db.prepare('SELECT id, parent_id, directory, time_updated FROM session').all() as {
47
+ id: string; parent_id: string | null; directory: string | null; time_updated: number | null;
48
+ }[];
49
+ } catch (error) {
50
+ debug.warn('storage', `Could not read Open Code sessions from ${file}:`, error);
51
+ return [];
52
+ } finally {
53
+ db?.close();
54
+ }
55
+ }
56
+
57
+ export const openCodeTranscripts: TranscriptStore = {
58
+ engine: 'opencode',
59
+ roots: () => [poolRoot()],
60
+
61
+ async list() {
62
+ const entries: TranscriptEntry[] = [];
63
+ for (const { scopeDir, file } of await openCodeDatabases()) {
64
+ for (const row of readSessions(file)) {
65
+ entries.push({
66
+ engine: 'opencode',
67
+ id: row.id,
68
+ paths: [],
69
+ bytes: 0,
70
+ mtimeMs: row.time_updated ?? 0,
71
+ projectKey: scopeDir,
72
+ projectPath: row.directory,
73
+ parentId: row.parent_id
74
+ });
75
+ }
76
+ }
77
+ return entries;
78
+ },
79
+
80
+ async exists(id) {
81
+ for (const { file } of await openCodeDatabases()) {
82
+ if (readSessions(file).some(row => row.id === id)) return true;
83
+ }
84
+ return false;
85
+ },
86
+
87
+ async remove(entries) {
88
+ const result: TranscriptRemoval = { freedBytes: 0, removed: 0, errors: [] };
89
+ const removable = entries.filter(entry => entry.projectKey === DEFAULT_SCOPE_DIR);
90
+ if (removable.length === 0) return result;
91
+
92
+ try {
93
+ const { ensureClient } = await import('$backend/engine/adapters/opencode/server');
94
+ const client = await ensureClient();
95
+ // Children first, so a parent is never deleted while a child that is
96
+ // being removed in the same pass still points at it.
97
+ const ids = new Set(removable.map(entry => entry.id));
98
+ const depth = (entry: TranscriptEntry): number => {
99
+ let d = 0;
100
+ let parent = entry.parentId;
101
+ while (parent && ids.has(parent) && d < 64) {
102
+ d++;
103
+ parent = removable.find(e => e.id === parent)?.parentId ?? null;
104
+ }
105
+ return d;
106
+ };
107
+ const ordered = [...removable].sort((a, b) => depth(b) - depth(a));
108
+ for (const entry of ordered) {
109
+ try {
110
+ await client.session.delete({
111
+ path: { id: entry.id },
112
+ ...(entry.projectPath && { query: { directory: entry.projectPath } })
113
+ });
114
+ result.removed++;
115
+ } catch (error) {
116
+ result.errors.push(`${entry.id}: ${error instanceof Error ? error.message : String(error)}`);
117
+ }
118
+ }
119
+ } catch (error) {
120
+ result.errors.push(`Open Code is unavailable: ${error instanceof Error ? error.message : String(error)}`);
121
+ }
122
+ return result;
123
+ }
124
+ };
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Which of a set of ids appear anywhere in a set of files.
3
+ *
4
+ * Streams each file once and searches every chunk for every id still unseen,
5
+ * keeping the tail of the previous chunk so an id split across a chunk boundary
6
+ * is still found. Stops reading as soon as every id has been found.
7
+ */
8
+
9
+ import { readFileChunks, yieldToEventLoop } from '../fs-size';
10
+
11
+ export async function findReferencedIds(files: string[], ids: Iterable<string>): Promise<Set<string>> {
12
+ const pending = new Set(ids);
13
+ const found = new Set<string>();
14
+ if (pending.size === 0) return found;
15
+ const overlap = Math.max(...[...pending].map(id => id.length));
16
+ const decoder = new TextDecoder();
17
+
18
+ for (const file of files) {
19
+ if (pending.size === 0) break;
20
+ let tail = '';
21
+ try {
22
+ for await (const chunk of readFileChunks(file)) {
23
+ const text = tail + decoder.decode(chunk, { stream: true });
24
+ for (const id of pending) {
25
+ if (text.includes(id)) {
26
+ found.add(id);
27
+ pending.delete(id);
28
+ }
29
+ }
30
+ if (pending.size === 0) break;
31
+ tail = text.slice(-overlap);
32
+ }
33
+ } catch {
34
+ // An unreadable file cannot prove an id unused. Treat everything still
35
+ // pending as referenced rather than delete what it might point at.
36
+ for (const id of pending) found.add(id);
37
+ pending.clear();
38
+ }
39
+ await yieldToEventLoop();
40
+ }
41
+ return found;
42
+ }
@@ -0,0 +1,58 @@
1
+ import type { EngineType } from '$shared/types/unified';
2
+
3
+ /**
4
+ * One engine session as it sits on disk.
5
+ *
6
+ * `id` is the id Clopen stores on messages (`UnifiedMessage.sessionId`) and
7
+ * passes back as `resume`, so "is this transcript in use" is a lookup of `id`
8
+ * in the chats' engine references.
9
+ */
10
+ export interface TranscriptEntry {
11
+ engine: EngineType;
12
+ id: string;
13
+ /** What removing this entry deletes. */
14
+ paths: string[];
15
+ bytes: number;
16
+ mtimeMs: number;
17
+ /**
18
+ * The engine's own name for the project directory the transcript belongs to
19
+ * (Claude/Qwen/Pi/Cursor encode the project path into a folder name). Used to
20
+ * group entries; null when the store does not partition by project.
21
+ */
22
+ projectKey: string | null;
23
+ /** The project path when the store records it (Codex, Pi, OpenCode). */
24
+ projectPath: string | null;
25
+ /**
26
+ * Claude keeps per-session side files (`<id>/tool-results`, `<id>/subagents`)
27
+ * that LATER forks point at by path. Never removed with the transcript; only
28
+ * once no transcript left in the folder mentions the id.
29
+ */
30
+ sidecar?: { path: string; bytes: number } | null;
31
+ /** A Claude side folder whose transcript is already gone. */
32
+ sidecarOnly?: boolean;
33
+ /** OpenCode: the session this one was forked or spawned from. */
34
+ parentId?: string | null;
35
+ }
36
+
37
+ export interface TranscriptRemoval {
38
+ freedBytes: number;
39
+ removed: number;
40
+ errors: string[];
41
+ }
42
+
43
+ export interface TranscriptStore {
44
+ engine: EngineType;
45
+ /** Every transcript on disk. Missing stores list nothing. */
46
+ list(signal?: AbortSignal): Promise<TranscriptEntry[]>;
47
+ /** Whether `id` can still be resumed. */
48
+ exists(id: string, projectPath: string): Promise<boolean>;
49
+ /** Delete entries previously returned by `list()`. */
50
+ remove(entries: TranscriptEntry[]): Promise<TranscriptRemoval>;
51
+ /**
52
+ * The directory the whole store lives in. Anything under the engine home
53
+ * outside it is cache, config or logs.
54
+ */
55
+ roots(): string[];
56
+ }
57
+
58
+ export const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
@@ -0,0 +1,114 @@
1
+ /**
2
+ * Worktrees: full copies of a project under `worktrees/<project id>/<slug>`.
3
+ *
4
+ * Folders with no worktree row are leftovers (a removal interrupted half-way, or
5
+ * a project folder emptied of worktrees) and nothing can open them again. A
6
+ * worktree that has a row is the user's work and is only ever removed through
7
+ * `removeWorktree`, and only when nothing in it differs from the main tree —
8
+ * a worktree with changes not yet applied is never a cleanup candidate,
9
+ * whatever its age.
10
+ */
11
+
12
+ import fs from 'node:fs/promises';
13
+ import { join } from 'node:path';
14
+ import { projectQueries, worktreeQueries } from '$backend/database/queries';
15
+ import { getWorktreesRootDir, pendingChangeCountOrNull, removeWorktree } from '$backend/worktrees';
16
+ import type { Worktree } from '$shared/types/database/schema';
17
+ import { measurePath, removePath } from './fs-size';
18
+
19
+ const DAY_MS = 24 * 60 * 60_000;
20
+
21
+ export interface WorktreeDir {
22
+ path: string;
23
+ bytes: number;
24
+ worktree: Worktree | null;
25
+ projectId: string | null;
26
+ }
27
+
28
+ export async function listWorktreeDirs(signal?: AbortSignal): Promise<WorktreeDir[]> {
29
+ const root = getWorktreesRootDir();
30
+ const byPath = new Map<string, Worktree>();
31
+ for (const project of projectQueries.getAll()) {
32
+ for (const worktree of worktreeQueries.getByProjectId(project.id)) byPath.set(worktree.path, worktree);
33
+ }
34
+
35
+ const dirs: WorktreeDir[] = [];
36
+ let projectDirs: import('node:fs').Dirent[];
37
+ try {
38
+ projectDirs = await fs.readdir(root, { withFileTypes: true });
39
+ } catch {
40
+ return dirs;
41
+ }
42
+ for (const projectDir of projectDirs) {
43
+ if (signal?.aborted) break;
44
+ if (!projectDir.isDirectory()) continue;
45
+ const projectPath = join(root, projectDir.name);
46
+ const children = await fs.readdir(projectPath, { withFileTypes: true }).catch(() => []);
47
+ if (children.length === 0) {
48
+ dirs.push({ path: projectPath, bytes: (await measurePath(projectPath)).bytes, worktree: null, projectId: null });
49
+ continue;
50
+ }
51
+ for (const child of children) {
52
+ if (!child.isDirectory()) continue;
53
+ const path = join(projectPath, child.name);
54
+ const worktree = byPath.get(path) ?? null;
55
+ dirs.push({
56
+ path,
57
+ bytes: (await measurePath(path, signal)).bytes,
58
+ worktree,
59
+ projectId: worktree?.project_id ?? null
60
+ });
61
+ }
62
+ }
63
+ return dirs;
64
+ }
65
+
66
+ export function orphanWorktreeDirs(dirs: WorktreeDir[]): WorktreeDir[] {
67
+ return dirs.filter(dir => !dir.worktree);
68
+ }
69
+
70
+ export async function removeWorktreeDirs(dirs: WorktreeDir[]): Promise<{ freedBytes: number; removed: number }> {
71
+ let freedBytes = 0;
72
+ let removed = 0;
73
+ for (const dir of dirs) {
74
+ if (dir.worktree) continue;
75
+ freedBytes += await removePath(dir.path);
76
+ removed++;
77
+ }
78
+ return { freedBytes, removed };
79
+ }
80
+
81
+ /**
82
+ * Worktrees unopened for `olderThanDays` with nothing left to apply, and no chat
83
+ * of theirs running.
84
+ */
85
+ export async function staleWorktrees(
86
+ dirs: WorktreeDir[],
87
+ options: { olderThanDays: number; projectId?: string | null; activeChatWorktrees: Set<string> }
88
+ ): Promise<WorktreeDir[]> {
89
+ const cutoff = Date.now() - options.olderThanDays * DAY_MS;
90
+ const stale: WorktreeDir[] = [];
91
+ for (const dir of dirs) {
92
+ const worktree = dir.worktree;
93
+ if (!worktree) continue;
94
+ if (options.projectId && worktree.project_id !== options.projectId) continue;
95
+ if (options.activeChatWorktrees.has(worktree.id)) continue;
96
+ const lastUsed = Date.parse(worktree.last_opened_at ?? worktree.created_at);
97
+ if (!Number.isFinite(lastUsed) || lastUsed >= cutoff) continue;
98
+ if (await pendingChangeCountOrNull(worktree.id) !== 0) continue;
99
+ stale.push(dir);
100
+ }
101
+ return stale;
102
+ }
103
+
104
+ export async function removeWorktrees(dirs: WorktreeDir[]): Promise<{ freedBytes: number; removed: number }> {
105
+ let freedBytes = 0;
106
+ let removed = 0;
107
+ for (const dir of dirs) {
108
+ if (!dir.worktree) continue;
109
+ await removeWorktree(dir.worktree.id);
110
+ freedBytes += dir.bytes;
111
+ removed++;
112
+ }
113
+ return { freedBytes, removed };
114
+ }
@@ -110,6 +110,31 @@ export function cleanupProjectSessions(projectId: string): number {
110
110
  return killed;
111
111
  }
112
112
 
113
+ /** Shells still running anywhere — what a server restart would end. */
114
+ export function countLiveSessions(): number {
115
+ let count = 0;
116
+ for (const namespace of knownNamespaces) {
117
+ count += ptyKitManager.list(namespace).filter((session) => session.status === 'active').length;
118
+ }
119
+ return count;
120
+ }
121
+
122
+ /**
123
+ * Shells still running in a project's main tree. Worktrees are left out: they
124
+ * live in their own folders, which a rename of the project folder never moves.
125
+ */
126
+ export function countLiveMainTreeSessions(projectId: string): number {
127
+ return ptyKitManager.list(makeScopeKey(projectId)).filter((session) => session.status === 'active').length;
128
+ }
129
+
130
+ /** Kill every PTY session in a project's main tree, leaving its worktrees alone. */
131
+ export function cleanupMainTreeSessions(projectId: string): number {
132
+ const namespace = makeScopeKey(projectId);
133
+ const killed = killNamespace(namespace);
134
+ knownNamespaces.delete(namespace);
135
+ return killed;
136
+ }
137
+
113
138
  /** Kill every PTY session inside one worktree — used when it is deleted. */
114
139
  export function cleanupWorktreeSessions(projectId: string, worktreeId: string): number {
115
140
  const namespace = makeScopeKey(projectId, worktreeId);
@@ -0,0 +1,24 @@
1
+ /**
2
+ * The latest published Clopen, as the npm registry describes it.
3
+ *
4
+ * The registry's `latest` document is the published package.json, so besides
5
+ * the version it carries what a restart needs to know before installing:
6
+ * the Bun range (`engines.bun`) and the launcher fingerprint stamped at
7
+ * publish time (scripts/stamp-launcher-fingerprint.ts).
8
+ */
9
+
10
+ export interface PackageManifest {
11
+ version: string;
12
+ engines?: { bun?: string };
13
+ clopenLauncherFingerprint?: string;
14
+ }
15
+
16
+ const LATEST_URL = 'https://registry.npmjs.org/@myrialabs/clopen/latest';
17
+
18
+ export async function fetchLatestManifest(): Promise<PackageManifest> {
19
+ const response = await fetch(LATEST_URL);
20
+ if (!response.ok) {
21
+ throw new Error(`npm registry returned ${response.status}`);
22
+ }
23
+ return await response.json() as PackageManifest;
24
+ }
@@ -0,0 +1,110 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+
3
+ import { isAppRelease, parseChangeLine, parseReleaseBody, toReleaseNote } from './release-notes';
4
+
5
+ const GENERATED_BODY = [
6
+ "## What's Changed",
7
+ '* fix(db): stop message saves from stalling the whole server by @someone in https://github.com/myrialabs/clopen/pull/582',
8
+ '* feat(chat): mention workspace context with @ by @someone in https://github.com/myrialabs/clopen/pull/595',
9
+ '* perf(preview): encode frames on the GPU by @someone in https://github.com/myrialabs/clopen/pull/590',
10
+ '* chore: bump dependencies by @some-bot in https://github.com/myrialabs/clopen/pull/591',
11
+ '* feat(api)!: drop the v1 endpoints by @someone in https://github.com/myrialabs/clopen/pull/592',
12
+ '',
13
+ '## New Contributors',
14
+ '* @newcomer made their first contribution in https://github.com/myrialabs/clopen/pull/590',
15
+ '',
16
+ '',
17
+ '**Full Changelog**: https://github.com/myrialabs/clopen/compare/v0.4.49...v0.4.50'
18
+ ].join('\r\n');
19
+
20
+ describe('parseChangeLine', () => {
21
+ test('reads type, scope, summary and pull request, dropping the author', () => {
22
+ expect(parseChangeLine('* fix(db): stop message saves by @someone in https://github.com/myrialabs/clopen/pull/582')).toEqual({
23
+ kind: 'fix',
24
+ scope: 'db',
25
+ summary: 'Stop message saves',
26
+ breaking: false,
27
+ pullUrl: 'https://github.com/myrialabs/clopen/pull/582',
28
+ pullNumber: 582
29
+ });
30
+ });
31
+
32
+ test('keeps a line without a conventional prefix as an "other" change', () => {
33
+ expect(parseChangeLine('- Update README by @someone in https://github.com/myrialabs/clopen/pull/7')).toEqual({
34
+ kind: 'other',
35
+ summary: 'Update README',
36
+ breaking: false,
37
+ pullUrl: 'https://github.com/myrialabs/clopen/pull/7',
38
+ pullNumber: 7
39
+ });
40
+ });
41
+
42
+ test('keeps a hand-written bullet with no author or link', () => {
43
+ expect(parseChangeLine('* feat: a faster start')).toEqual({ kind: 'feature', summary: 'A faster start', breaking: false });
44
+ });
45
+
46
+ test('marks breaking changes', () => {
47
+ expect(parseChangeLine('* feat(api)!: drop the v1 endpoints')?.breaking).toBe(true);
48
+ });
49
+
50
+ test('does not mistake a colon inside the summary for a type', () => {
51
+ expect(parseChangeLine('* Note: this is plain text')).toEqual({ kind: 'other', summary: 'Note: this is plain text', breaking: false });
52
+ });
53
+ });
54
+
55
+ describe('parseReleaseBody', () => {
56
+ test('turns a generated body into changes and contributors with nothing left over', () => {
57
+ const parsed = parseReleaseBody(GENERATED_BODY);
58
+ expect(parsed.changes.map(change => [change.kind, change.scope, change.pullNumber])).toEqual([
59
+ ['fix', 'db', 582],
60
+ ['feature', 'chat', 595],
61
+ ['improvement', 'preview', 590],
62
+ ['other', undefined, 591],
63
+ ['feature', 'api', 592]
64
+ ]);
65
+ expect(parsed.changes[1].summary).toBe('Mention workspace context with @');
66
+ expect(parsed.newContributors).toEqual(['newcomer']);
67
+ expect(parsed.notes).toBe('');
68
+ });
69
+
70
+ test('keeps hand-written sections as markdown notes', () => {
71
+ const parsed = parseReleaseBody([
72
+ '## Highlights',
73
+ 'Clopen now restarts itself after an update.',
74
+ '',
75
+ "## What's Changed",
76
+ '* fix(server): keep the port by @someone in https://github.com/myrialabs/clopen/pull/600'
77
+ ].join('\n'));
78
+ expect(parsed.notes).toBe('## Highlights\nClopen now restarts itself after an update.');
79
+ expect(parsed.changes).toHaveLength(1);
80
+ });
81
+
82
+ test('an empty body has no changes', () => {
83
+ expect(parseReleaseBody('')).toEqual({ changes: [], newContributors: [], notes: '' });
84
+ });
85
+ });
86
+
87
+ describe('toReleaseNote', () => {
88
+ test('strips the tag prefix into a plain version', () => {
89
+ const note = toReleaseNote({
90
+ tag_name: 'v0.4.50',
91
+ html_url: 'https://github.com/myrialabs/clopen/releases/tag/v0.4.50',
92
+ published_at: '2026-11-18T12:12:26Z',
93
+ body: null,
94
+ draft: false,
95
+ prerelease: false
96
+ });
97
+ expect(note.version).toBe('0.4.50');
98
+ expect(note.tagName).toBe('v0.4.50');
99
+ expect(note.changes).toEqual([]);
100
+ });
101
+ });
102
+
103
+ describe('isAppRelease', () => {
104
+ test('accepts app versions and rejects asset releases, drafts and pre-releases', () => {
105
+ expect(isAppRelease({ tag_name: 'v0.4.50', draft: false, prerelease: false })).toBe(true);
106
+ expect(isAppRelease({ tag_name: 'embedding-v0.0.1', draft: false, prerelease: false })).toBe(false);
107
+ expect(isAppRelease({ tag_name: 'v0.5.0', draft: true, prerelease: false })).toBe(false);
108
+ expect(isAppRelease({ tag_name: 'v0.5.0-beta.1', draft: false, prerelease: true })).toBe(false);
109
+ });
110
+ });
@@ -0,0 +1,132 @@
1
+ /**
2
+ * Clopen's GitHub releases, turned into something a user can read.
3
+ *
4
+ * Release bodies are GitHub's auto-generated notes — one line per pull
5
+ * request, `* fix(db): stop message saves stalling by @someone in <url>` —
6
+ * which is written for the people who build Clopen. Each line becomes a
7
+ * ReleaseChange: the commit type picks the group (New / Improved / Fixed),
8
+ * the scope becomes a tag, the author handle goes and the pull-request URL
9
+ * shrinks to its number. Anything hand-written that is not a change entry is
10
+ * kept as markdown so nothing a maintainer typed is lost.
11
+ */
12
+
13
+ import type { ReleaseChange, ReleaseChangeKind, ReleaseNote } from '$shared/types/release-notes';
14
+ import { stripVersionPrefix } from '$shared/utils/semver';
15
+
16
+ const RELEASES_URL = 'https://api.github.com/repos/myrialabs/clopen/releases?per_page=30';
17
+
18
+ const KIND_BY_TYPE: Record<string, ReleaseChangeKind> = {
19
+ feat: 'feature',
20
+ feature: 'feature',
21
+ perf: 'improvement',
22
+ fix: 'fix',
23
+ revert: 'fix'
24
+ };
25
+
26
+ /** `* type(scope)!: summary by @author in https://…/pull/123` — every part after the bullet optional. */
27
+ const CHANGE_LINE =
28
+ /^[*-]\s+(?:(?<type>[a-z]+)(?:\((?<scope>[^)]+)\))?(?<bang>!)?:\s+)?(?<summary>.+?)(?:\s+by\s+@[\w.-]+)?(?:\s+in\s+<?(?<url>https:\/\/github\.com\/\S+?\/pull\/(?<number>\d+))>?)?\s*$/;
29
+
30
+ /** `* @someone made their first contribution in https://…` */
31
+ const CONTRIBUTOR_LINE = /^[*-]\s+@(?<login>[\w.-]+)\s+made their first contribution/;
32
+
33
+ const FULL_CHANGELOG_LINE = /^\*\*Full Changelog\*\*:/;
34
+ const HEADING = /^#{1,6}\s+(?<title>.+?)\s*$/;
35
+
36
+ function capitalise(text: string): string {
37
+ return text.charAt(0).toUpperCase() + text.slice(1);
38
+ }
39
+
40
+ export function parseChangeLine(line: string): ReleaseChange | null {
41
+ const match = CHANGE_LINE.exec(line.trim());
42
+ if (!match?.groups) return null;
43
+ const { type, scope, bang, summary, url, number } = match.groups;
44
+ const kind = type ? (KIND_BY_TYPE[type] ?? 'other') : 'other';
45
+ return {
46
+ kind,
47
+ ...(scope ? { scope } : {}),
48
+ summary: capitalise(summary.trim()),
49
+ breaking: bang === '!',
50
+ ...(url ? { pullUrl: url, pullNumber: Number(number) } : {})
51
+ };
52
+ }
53
+
54
+ export function parseReleaseBody(body: string): Pick<ReleaseNote, 'changes' | 'newContributors' | 'notes'> {
55
+ const changes: ReleaseChange[] = [];
56
+ const newContributors: string[] = [];
57
+ const notes: string[] = [];
58
+ let section = '';
59
+
60
+ for (const raw of body.replace(/\r\n/g, '\n').split('\n')) {
61
+ const line = raw.trimEnd();
62
+ const heading = HEADING.exec(line.trim());
63
+ if (heading?.groups) {
64
+ section = heading.groups.title.toLowerCase();
65
+ // The generated headings are structure, not content — the UI draws its own.
66
+ if (section === "what's changed" || section === 'new contributors') continue;
67
+ notes.push(line);
68
+ continue;
69
+ }
70
+ if (FULL_CHANGELOG_LINE.test(line.trim())) continue;
71
+
72
+ if (section === 'new contributors') {
73
+ const contributor = CONTRIBUTOR_LINE.exec(line.trim());
74
+ if (contributor?.groups) {
75
+ newContributors.push(contributor.groups.login);
76
+ continue;
77
+ }
78
+ }
79
+
80
+ if (section === "what's changed" && /^[*-]\s/.test(line.trim())) {
81
+ const change = parseChangeLine(line);
82
+ if (change) {
83
+ changes.push(change);
84
+ continue;
85
+ }
86
+ }
87
+
88
+ notes.push(line);
89
+ }
90
+
91
+ return { changes, newContributors, notes: notes.join('\n').trim() };
92
+ }
93
+
94
+ interface GitHubRelease {
95
+ tag_name: string;
96
+ html_url: string;
97
+ published_at: string | null;
98
+ body: string | null;
99
+ draft: boolean;
100
+ prerelease: boolean;
101
+ }
102
+
103
+ export function toReleaseNote(release: GitHubRelease): ReleaseNote {
104
+ return {
105
+ version: stripVersionPrefix(release.tag_name),
106
+ tagName: release.tag_name,
107
+ url: release.html_url,
108
+ publishedAt: release.published_at ?? '',
109
+ ...parseReleaseBody(release.body ?? '')
110
+ };
111
+ }
112
+
113
+ /**
114
+ * The repository also publishes releases that are not Clopen versions — the
115
+ * Memory Graph's embedding model ships as `embedding-v0.0.1` — so only tags
116
+ * that are an app version count.
117
+ */
118
+ const APP_VERSION_TAG = /^v?\d+\.\d+\.\d+$/;
119
+
120
+ export function isAppRelease(release: Pick<GitHubRelease, 'tag_name' | 'draft' | 'prerelease'>): boolean {
121
+ return !release.draft && !release.prerelease && APP_VERSION_TAG.test(release.tag_name);
122
+ }
123
+
124
+ /** Newest first, published app releases only. */
125
+ export async function fetchReleaseNotes(): Promise<ReleaseNote[]> {
126
+ const response = await fetch(RELEASES_URL, { headers: { Accept: 'application/vnd.github+json' } });
127
+ if (!response.ok) {
128
+ throw new Error(`GitHub API returned ${response.status}`);
129
+ }
130
+ const releases = await response.json() as GitHubRelease[];
131
+ return releases.filter(isAppRelease).map(toReleaseNote);
132
+ }