@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,24 @@
1
+ import { describe, expect, test } from 'bun:test';
2
+ import { systemNoteToEvent } from './adapter';
3
+
4
+ const note = (body: string) => ({ id: 1, body, author: { id: 1, username: 'octocat' }, created_at: '2026-01-01T00:00:00Z' });
5
+
6
+ describe('systemNoteToEvent', () => {
7
+ test('labels, assignments and renames become events with their subject', () => {
8
+ expect(systemNoteToEvent(note('added ~bug label'))).toMatchObject({ kind: 'labeled', subject: 'bug' });
9
+ expect(systemNoteToEvent(note('added ~"needs review" label'))).toMatchObject({ kind: 'labeled', subject: 'needs review' });
10
+ expect(systemNoteToEvent(note('assigned to @mona'))).toMatchObject({ kind: 'assigned', subject: 'mona' });
11
+ expect(systemNoteToEvent(note('changed title from **old** to **New title**'))).toMatchObject({ kind: 'renamed', subject: 'New title' });
12
+ });
13
+
14
+ test('state changes', () => {
15
+ expect(systemNoteToEvent(note('closed'))?.kind).toBe('closed');
16
+ expect(systemNoteToEvent(note('reopened'))?.kind).toBe('reopened');
17
+ expect(systemNoteToEvent(note('merged'))?.kind).toBe('merged');
18
+ });
19
+
20
+ test('bookkeeping notes are dropped rather than drawn vaguely', () => {
21
+ expect(systemNoteToEvent(note('changed the description'))).toBeNull();
22
+ expect(systemNoteToEvent(note('added 3 commits'))).toBeNull();
23
+ });
24
+ });
@@ -42,6 +42,7 @@ import type {
42
42
  import { getWorkAdapter } from './registry';
43
43
  import { readBinding, resolveBinding, suggestLocators, toBindingInfo } from './bindings';
44
44
  import type { WorkContext, WorkProviderAdapter } from './types';
45
+ import { credentialsForUse } from '$backend/git-hosts/credentials';
45
46
  import { debug } from '$shared/utils/logger';
46
47
 
47
48
  /**
@@ -66,15 +67,19 @@ function accountsFor(projectId: string): { account: IntegrationAccountRow; adapt
66
67
  });
67
68
  }
68
69
 
69
- function contextOf(
70
+ /**
71
+ * The adapter context, with a credential that is current — re-read from a
72
+ * linked CLI, or refreshed when an OAuth token is about to expire.
73
+ */
74
+ async function contextOf(
70
75
  account: IntegrationAccountRow,
71
76
  projectId: string,
72
77
  binding: NonNullable<ReturnType<typeof readBinding>>
73
- ): WorkContext {
78
+ ): Promise<WorkContext> {
74
79
  return {
75
80
  projectId,
76
81
  account,
77
- credentials: integrationAccountQueries.credentialsOf(account),
82
+ credentials: await credentialsForUse(account),
78
83
  binding
79
84
  };
80
85
  }
@@ -93,7 +98,7 @@ export const workService = {
93
98
 
94
99
  for (const { account, adapter } of accountsFor(projectId)) {
95
100
  const provider = getProvider(account.provider);
96
- const credentials = integrationAccountQueries.credentialsOf(account);
101
+ const credentials = await credentialsForUse(account).catch(() => integrationAccountQueries.credentialsOf(account));
97
102
 
98
103
  let binding = readBinding(projectId, account.id);
99
104
  if (!binding) {
@@ -132,7 +137,7 @@ export const workService = {
132
137
  * "Not bound" is separated from "not connected" because they need different
133
138
  * answers: one is a repository picker, the other is a connect dialog.
134
139
  */
135
- require(projectId: string, accountId: string): { adapter: WorkProviderAdapter; context: WorkContext } {
140
+ async require(projectId: string, accountId: string): Promise<{ adapter: WorkProviderAdapter; context: WorkContext }> {
136
141
  const account = integrationAccountQueries.getById(accountId);
137
142
  if (!account) throw new Error('That integration account is no longer connected');
138
143
  if (account.is_enabled !== 1) throw new Error(`${account.label} is switched off in Settings → Integrations`);
@@ -143,7 +148,7 @@ export const workService = {
143
148
  const binding = readBinding(projectId, account.id);
144
149
  if (!binding) throw new Error('This project is not pointed at a repository yet');
145
150
 
146
- return { adapter, context: contextOf(account, projectId, binding) };
151
+ return { adapter, context: await contextOf(account, projectId, binding) };
147
152
  },
148
153
 
149
154
  /** How to print the bound remote project, for prompts and headings. */
@@ -156,17 +161,17 @@ export const workService = {
156
161
  },
157
162
 
158
163
  async list(projectId: string, accountId: string, query: WorkItemQuery): Promise<WorkItemPage> {
159
- const { adapter, context } = this.require(projectId, accountId);
164
+ const { adapter, context } = await this.require(projectId, accountId);
160
165
  return adapter.list(context, query);
161
166
  },
162
167
 
163
168
  async get(projectId: string, accountId: string, kind: WorkItemKind, id: string): Promise<WorkItemDetail> {
164
- const { adapter, context } = this.require(projectId, accountId);
169
+ const { adapter, context } = await this.require(projectId, accountId);
165
170
  return adapter.get(context, kind, id);
166
171
  },
167
172
 
168
173
  async listStates(projectId: string, accountId: string, kind: WorkItemKind): Promise<WorkItemStateOption[]> {
169
- const { adapter, context } = this.require(projectId, accountId);
174
+ const { adapter, context } = await this.require(projectId, accountId);
170
175
  return adapter.listStates(context, kind);
171
176
  },
172
177
 
@@ -177,7 +182,7 @@ export const workService = {
177
182
  id: string,
178
183
  body: string
179
184
  ): Promise<WorkItemComment> {
180
- const { adapter, context } = this.require(projectId, accountId);
185
+ const { adapter, context } = await this.require(projectId, accountId);
181
186
  if (!adapter.capabilities.comments) throw new Error('This provider does not accept comments');
182
187
  return adapter.comment(context, kind, id, body);
183
188
  },
@@ -189,19 +194,19 @@ export const workService = {
189
194
  id: string,
190
195
  state: string
191
196
  ): Promise<void> {
192
- const { adapter, context } = this.require(projectId, accountId);
197
+ const { adapter, context } = await this.require(projectId, accountId);
193
198
  if (!adapter.capabilities.transitions) throw new Error('This provider does not support state changes');
194
199
  await adapter.transition(context, kind, id, state);
195
200
  },
196
201
 
197
202
  async listChecks(projectId: string, accountId: string, branch: string): Promise<CheckRun[]> {
198
- const { adapter, context } = this.require(projectId, accountId);
203
+ const { adapter, context } = await this.require(projectId, accountId);
199
204
  if (!adapter.listChecks) return [];
200
205
  return adapter.listChecks(context, branch);
201
206
  },
202
207
 
203
208
  async fetchCheckLogs(projectId: string, accountId: string, runId: string): Promise<CheckLogBundle> {
204
- const { adapter, context } = this.require(projectId, accountId);
209
+ const { adapter, context } = await this.require(projectId, accountId);
205
210
  if (!adapter.fetchCheckLogs) throw new Error('This provider does not expose CI logs');
206
211
  return adapter.fetchCheckLogs(context, runId);
207
212
  },
@@ -213,13 +218,13 @@ export const workService = {
213
218
  id: string,
214
219
  patch: { title?: string; body?: string }
215
220
  ): Promise<void> {
216
- const { adapter, context } = this.require(projectId, accountId);
221
+ const { adapter, context } = await this.require(projectId, accountId);
217
222
  if (!adapter.updateItem) throw new Error('This provider cannot edit items');
218
223
  await adapter.updateItem(context, kind, id, patch);
219
224
  },
220
225
 
221
226
  async listLabels(projectId: string, accountId: string): Promise<string[]> {
222
- const { adapter, context } = this.require(projectId, accountId);
227
+ const { adapter, context } = await this.require(projectId, accountId);
223
228
  if (!adapter.listLabels) return [];
224
229
  return adapter.listLabels(context);
225
230
  },
@@ -230,7 +235,7 @@ export const workService = {
230
235
  comment: { id: string; source: CommentSource },
231
236
  body: string
232
237
  ): Promise<WorkItemComment> {
233
- const { adapter, context } = this.require(projectId, accountId);
238
+ const { adapter, context } = await this.require(projectId, accountId);
234
239
  if (!adapter.updateComment) throw new Error('This provider cannot edit comments');
235
240
  return adapter.updateComment(context, comment, body);
236
241
  },
@@ -240,7 +245,7 @@ export const workService = {
240
245
  accountId: string,
241
246
  comment: { id: string; source: CommentSource }
242
247
  ): Promise<void> {
243
- const { adapter, context } = this.require(projectId, accountId);
248
+ const { adapter, context } = await this.require(projectId, accountId);
244
249
  if (!adapter.deleteComment) throw new Error('This provider cannot delete comments');
245
250
  await adapter.deleteComment(context, comment);
246
251
  },
@@ -251,25 +256,25 @@ export const workService = {
251
256
  id: string,
252
257
  options: { method: MergeMethod; title?: string; message?: string }
253
258
  ): Promise<void> {
254
- const { adapter, context } = this.require(projectId, accountId);
259
+ const { adapter, context } = await this.require(projectId, accountId);
255
260
  if (!adapter.mergePullRequest) throw new Error('This provider cannot merge pull requests');
256
261
  await adapter.mergePullRequest(context, id, options);
257
262
  },
258
263
 
259
264
  async listCommits(projectId: string, accountId: string, id: string): Promise<CommitRef[]> {
260
- const { adapter, context } = this.require(projectId, accountId);
265
+ const { adapter, context } = await this.require(projectId, accountId);
261
266
  if (!adapter.listCommits) return [];
262
267
  return adapter.listCommits(context, id);
263
268
  },
264
269
 
265
270
  async listFiles(projectId: string, accountId: string, id: string): Promise<FileChange[]> {
266
- const { adapter, context } = this.require(projectId, accountId);
271
+ const { adapter, context } = await this.require(projectId, accountId);
267
272
  if (!adapter.listFiles) return [];
268
273
  return adapter.listFiles(context, id);
269
274
  },
270
275
 
271
276
  async commitDetail(projectId: string, accountId: string, sha: string): Promise<CommitDetail> {
272
- const { adapter, context } = this.require(projectId, accountId);
277
+ const { adapter, context } = await this.require(projectId, accountId);
273
278
  if (!adapter.commitDetail) throw new Error('This provider cannot open a commit');
274
279
  return adapter.commitDetail(context, sha);
275
280
  },
@@ -281,13 +286,13 @@ export const workService = {
281
286
  ref: string,
282
287
  blobSha?: string
283
288
  ): Promise<FileContent> {
284
- const { adapter, context } = this.require(projectId, accountId);
289
+ const { adapter, context } = await this.require(projectId, accountId);
285
290
  if (!adapter.fetchFileContent) throw new Error('This provider cannot read file contents');
286
291
  return adapter.fetchFileContent(context, path, ref, blobSha);
287
292
  },
288
293
 
289
294
  async listAssignees(projectId: string, accountId: string): Promise<string[]> {
290
- const { adapter, context } = this.require(projectId, accountId);
295
+ const { adapter, context } = await this.require(projectId, accountId);
291
296
  if (!adapter.listAssignees) return [];
292
297
  return adapter.listAssignees(context);
293
298
  },
@@ -299,17 +304,35 @@ export const workService = {
299
304
  id: string,
300
305
  logins: string[]
301
306
  ): Promise<void> {
302
- const { adapter, context } = this.require(projectId, accountId);
307
+ const { adapter, context } = await this.require(projectId, accountId);
303
308
  if (!adapter.setAssignees) throw new Error('This provider cannot change assignees');
304
309
  await adapter.setAssignees(context, kind, id, logins);
305
310
  },
306
311
 
312
+ async setLabels(
313
+ projectId: string,
314
+ accountId: string,
315
+ kind: WorkItemKind,
316
+ id: string,
317
+ labels: string[]
318
+ ): Promise<void> {
319
+ const { adapter, context } = await this.require(projectId, accountId);
320
+ if (!adapter.setLabels) throw new Error('This provider cannot change labels');
321
+ await adapter.setLabels(context, kind, id, labels);
322
+ },
323
+
324
+ async setReviewers(projectId: string, accountId: string, id: string, logins: string[]): Promise<void> {
325
+ const { adapter, context } = await this.require(projectId, accountId);
326
+ if (!adapter.setReviewers) throw new Error('This provider cannot request reviewers');
327
+ await adapter.setReviewers(context, id, logins);
328
+ },
329
+
307
330
  async createIssue(
308
331
  projectId: string,
309
332
  accountId: string,
310
333
  draft: { title: string; body: string; assignees: string[]; labels: string[] }
311
334
  ): Promise<WorkItem> {
312
- const { adapter, context } = this.require(projectId, accountId);
335
+ const { adapter, context } = await this.require(projectId, accountId);
313
336
  if (!adapter.createIssue) throw new Error('This provider cannot create issues');
314
337
  return adapter.createIssue(context, draft);
315
338
  },
@@ -319,7 +342,7 @@ export const workService = {
319
342
  accountId: string,
320
343
  draft: PullRequestDraft
321
344
  ): Promise<WorkItem> {
322
- const { adapter, context } = this.require(projectId, accountId);
345
+ const { adapter, context } = await this.require(projectId, accountId);
323
346
  if (!adapter.createPullRequest) throw new Error('This provider cannot open pull requests');
324
347
 
325
348
  const created = await adapter.createPullRequest(context, draft);
@@ -344,7 +367,7 @@ export const workService = {
344
367
  accountId: string,
345
368
  branch: string
346
369
  ): Promise<WorkItem | null> {
347
- const { adapter, context } = this.require(projectId, accountId);
370
+ const { adapter, context } = await this.require(projectId, accountId);
348
371
  if (!adapter.findPullRequestForBranch) return null;
349
372
  return adapter.findPullRequestForBranch(context, branch);
350
373
  },
@@ -358,7 +381,7 @@ export const workService = {
358
381
  * rate limit.
359
382
  */
360
383
  async defaultBranch(projectId: string, accountId: string): Promise<string> {
361
- const { adapter, context } = this.require(projectId, accountId);
384
+ const { adapter, context } = await this.require(projectId, accountId);
362
385
  if (context.binding.defaultBranch) return context.binding.defaultBranch;
363
386
 
364
387
  const branch = await adapter.defaultBranch(context);
@@ -424,13 +447,14 @@ export const workService = {
424
447
  // An account bound to a project probes against that project's repository;
425
448
  // an unbound one can only prove the credential itself is good.
426
449
  const binding = projectId ? readBinding(projectId, accountId) : null;
427
- return adapter.probe(
428
- {
429
- projectId: projectId ?? '',
430
- account,
431
- credentials: integrationAccountQueries.credentialsOf(account)
432
- },
433
- binding
434
- );
450
+ let credentials: Record<string, string>;
451
+ try {
452
+ credentials = await credentialsForUse(account);
453
+ } catch (error) {
454
+ // A linked CLI that logged out, or an OAuth token that could not be
455
+ // renewed, is exactly a sign-in problem — say so, not "error".
456
+ return { status: 'needs_auth', detail: error instanceof Error ? error.message : String(error) };
457
+ }
458
+ return adapter.probe({ projectId: projectId ?? '', account, credentials }, binding);
435
459
  }
436
460
  };
@@ -84,7 +84,7 @@ export async function startWork(input: {
84
84
  engine: EngineType;
85
85
  userId: string;
86
86
  }): Promise<StartWorkResult> {
87
- const { adapter, context } = workService.require(input.projectId, input.accountId);
87
+ const { adapter, context } = await workService.require(input.projectId, input.accountId);
88
88
 
89
89
  const item: WorkItemDetail = await adapter.get(context, input.kind, input.itemId);
90
90
 
@@ -172,6 +172,10 @@ export interface WorkProviderAdapter {
172
172
  /** People this item can be assigned to. */
173
173
  listAssignees?(context: WorkContext): Promise<string[]>;
174
174
  setAssignees?(context: WorkContext, kind: WorkItemKind, id: string, logins: string[]): Promise<void>;
175
+ /** Replace an item's labels with exactly these. */
176
+ setLabels?(context: WorkContext, kind: WorkItemKind, id: string, labels: string[]): Promise<void>;
177
+ /** Make these exactly the pull request's requested reviewers. Candidates come from `listAssignees`. */
178
+ setReviewers?(context: WorkContext, id: string, logins: string[]): Promise<void>;
175
179
 
176
180
  createIssue?(
177
181
  context: WorkContext,
@@ -9,6 +9,7 @@
9
9
  export {
10
10
  createWorktree,
11
11
  countPendingChanges,
12
+ pendingChangeCountOrNull,
12
13
  executeTransfer,
13
14
  getWorktreeDiskUsage,
14
15
  previewTransfer,
@@ -11,7 +11,7 @@ import { projectQueries, worktreeQueries } from '../database/queries';
11
11
  import { fileWatcher } from '../files/file-watcher';
12
12
  import { debug } from '$shared/utils/logger';
13
13
  import { cleanupWorktreeSessions } from '../terminal/ptykit';
14
- import { browserPreviewServiceManager } from '../preview';
14
+ import { browserPool, browserPreviewServiceManager } from '../preview';
15
15
  import { makeScopeKey } from '$shared/utils/workspace-scope';
16
16
  import { cloneTree } from './clone';
17
17
  import {
@@ -189,7 +189,12 @@ function releaseWorkspaceScope(projectId: string, worktreeId: string): void {
189
189
  const scopeKey = makeScopeKey(projectId, worktreeId);
190
190
  try {
191
191
  cleanupWorktreeSessions(projectId, worktreeId);
192
- void browserPreviewServiceManager.removeService(scopeKey);
192
+ // Tabs first, then the profile: a worktree's Chrome profile (cookies,
193
+ // storage, cache) belongs to the worktree and would otherwise stay on
194
+ // disk forever under a name nothing can reach again.
195
+ void browserPreviewServiceManager.removeService(scopeKey)
196
+ .catch(() => {})
197
+ .finally(() => browserPool.clearBrowsingData(scopeKey).catch(() => false));
193
198
  fileWatcher.releaseProject(scopeKey);
194
199
  } catch (error) {
195
200
  debug.warn('worktree', `Scope cleanup failed for ${scopeKey}: ${error}`);
@@ -328,6 +333,22 @@ export async function countPendingChanges(worktreeId: string): Promise<number> {
328
333
  }
329
334
  }
330
335
 
336
+ /**
337
+ * Like `countPendingChanges`, but null when the count cannot be taken. For
338
+ * callers deciding whether a worktree may be removed, where "could not tell"
339
+ * must never read as "nothing to lose".
340
+ */
341
+ export async function pendingChangeCountOrNull(worktreeId: string): Promise<number | null> {
342
+ const worktree = worktreeQueries.getById(worktreeId);
343
+ if (!worktree) return null;
344
+ try {
345
+ const { plan } = await buildPlan(worktree, 'apply');
346
+ return plan.entries.length;
347
+ } catch {
348
+ return null;
349
+ }
350
+ }
351
+
331
352
  function requireWorktree(worktreeId: string): Worktree {
332
353
  const worktree = worktreeQueries.getById(worktreeId);
333
354
  if (!worktree) throw new Error('Worktree not found');
@@ -67,6 +67,14 @@ interface QueuedMessage {
67
67
 
68
68
  /** chatSessionId → its draft. */
69
69
  const drafts = new Map<string, Draft>();
70
+ /**
71
+ * chatSessionId → attachment id → its bytes. A save sends the bytes of a file
72
+ * once, then names it by id; the draft is rebuilt from here. Kept a moment
73
+ * past the draft that dropped them, because another tab's write that lost the
74
+ * revision race may still be followed by one that names them.
75
+ */
76
+ const draftBytes = new Map<string, Map<string, { base64: string; receivedAt: number }>>();
77
+ const DRAFT_BYTES_GRACE_MS = 60_000;
70
78
  /** chatSessionId → the message being edited. */
71
79
  const edits = new Map<string, EditState>();
72
80
  /** chatSessionId → messages waiting for the current turn to finish, in order. */
@@ -244,6 +252,7 @@ streamManager.on('session:turn-started', (chatSessionId: string) => {
244
252
  // Deleting a session drops everything its composer was holding.
245
253
  streamManager.on('session:cleanup', (chatSessionId: string) => {
246
254
  drafts.delete(chatSessionId);
255
+ draftBytes.delete(chatSessionId);
247
256
  edits.delete(chatSessionId);
248
257
  queues.delete(chatSessionId);
249
258
  });
@@ -260,6 +269,15 @@ const attachmentSchema = t.Object({
260
269
  base64: t.String()
261
270
  });
262
271
 
272
+ /** An attachment in a save: its bytes the first time, its id alone after that. */
273
+ const savedAttachmentSchema = t.Object({
274
+ id: t.String(),
275
+ fileName: t.String(),
276
+ type: t.String(),
277
+ mediaType: t.String(),
278
+ base64: t.Optional(t.String())
279
+ });
280
+
263
281
  const engineSchema = t.Object({
264
282
  type: t.Union([t.Literal('claude-code'), t.Literal('opencode'), t.Literal('copilot'), t.Literal('codex'), t.Literal('qwen'), t.Literal('pi'), t.Literal('cline'), t.Literal('cursor')]),
265
283
  provider: t.String(),
@@ -317,14 +335,15 @@ export const composerHandler = createRouter()
317
335
  })
318
336
 
319
337
  // Save the draft. Omitted fields are left as they are, so typing
320
- // sends text only and attachments travel only when they change. A part is
321
- // only replaced by a write newer than the one it holds.
338
+ // sends text only and attachments travel only when they change — and then
339
+ // only the bytes of files the server hasn't had yet. A part is only
340
+ // replaced by a write newer than the one it holds.
322
341
  .on('chat:draft-save', {
323
342
  data: t.Object({
324
343
  chatSessionId: t.String(),
325
344
  revision: t.Number(),
326
345
  text: t.Optional(t.String()),
327
- attachments: t.Optional(t.Array(attachmentSchema))
346
+ attachments: t.Optional(t.Array(savedAttachmentSchema))
328
347
  })
329
348
  }, ({ data }) => {
330
349
  requireSessionAccess(data.chatSessionId);
@@ -333,9 +352,31 @@ export const composerHandler = createRouter()
333
352
  draft.text = data.text;
334
353
  draft.textRevision = data.revision;
335
354
  }
336
- if (data.attachments !== undefined && data.revision > draft.attachmentsRevision) {
337
- draft.attachments = data.attachments;
338
- draft.attachmentsRevision = data.revision;
355
+ if (data.attachments !== undefined) {
356
+ const bytes = draftBytes.get(data.chatSessionId) ?? new Map<string, { base64: string; receivedAt: number }>();
357
+ const now = Date.now();
358
+ for (const attachment of data.attachments) {
359
+ if (attachment.base64 !== undefined) bytes.set(attachment.id, { base64: attachment.base64, receivedAt: now });
360
+ }
361
+ if (data.revision > draft.attachmentsRevision) {
362
+ const attachments: DraftAttachment[] = [];
363
+ for (const attachment of data.attachments) {
364
+ const base64 = attachment.base64 ?? bytes.get(attachment.id)?.base64;
365
+ if (base64 === undefined) {
366
+ debug.warn('chat', `Draft attachment ${attachment.id} was named before its bytes arrived; left out`);
367
+ continue;
368
+ }
369
+ attachments.push({ ...attachment, base64 });
370
+ }
371
+ draft.attachments = attachments;
372
+ draft.attachmentsRevision = data.revision;
373
+ const kept = new Set(attachments.map((attachment) => attachment.id));
374
+ for (const [id, entry] of bytes) {
375
+ if (!kept.has(id) && now - entry.receivedAt > DRAFT_BYTES_GRACE_MS) bytes.delete(id);
376
+ }
377
+ }
378
+ if (bytes.size > 0) draftBytes.set(data.chatSessionId, bytes);
379
+ else draftBytes.delete(data.chatSessionId);
339
380
  }
340
381
  drafts.set(data.chatSessionId, draft);
341
382
  })
@@ -55,7 +55,7 @@ export function createSafeRegex(pattern: string, flags: string): RegExp | null {
55
55
  }
56
56
 
57
57
  // Directories to skip during search
58
- const SKIP_DIRS = new Set([
58
+ export const SKIP_DIRS = new Set([
59
59
  'node_modules', '.git', '.svelte-kit', 'build', 'dist', 'coverage',
60
60
  '.next', '.nuxt', 'target', '.cache', '.output', '__pycache__',
61
61
  '.venv', 'venv', '.tox', '.eggs', '.mypy_cache', 'vendor',
@@ -25,6 +25,9 @@ import {
25
25
  import { createArchiveOperation, extractArchiveOperation } from '../../files/file-archive';
26
26
  import { stat as fsStat, readdir as fsReaddir, rename as fsRename } from 'node:fs/promises';
27
27
  import { resolveFilePath } from './path-access';
28
+ import { projectAtFolder, protectedFolderReason } from '../../projects/folder-guard';
29
+ import { moveProject } from '../../projects/move';
30
+ import { basename, dirname } from 'node:path';
28
31
 
29
32
  export const writeHandler = createRouter()
30
33
  // Write file operation
@@ -218,6 +221,8 @@ export const writeHandler = createRouter()
218
221
  if (!stats.isDirectory()) {
219
222
  throw new Error('Path is not a directory');
220
223
  }
224
+ const reason = protectedFolderReason(dirPath);
225
+ if (reason) throw new Error(`This folder cannot be deleted: ${reason}.`);
221
226
  const entries = await fsReaddir(dirPath);
222
227
  if (entries.length > 0) {
223
228
  throw new Error('Directory is not empty');
@@ -231,6 +236,11 @@ export const writeHandler = createRouter()
231
236
  // fs.rename directly
232
237
  // because Bun.file(...).exists() returns false for directories, which
233
238
  // makes the generic renameOperation unusable here.
239
+ //
240
+ // A folder that is a project moves WITH its project (the picker sends a
241
+ // listed project through projects:rename; one removed from the list but
242
+ // kept for restoring lands here). A folder holding a project, the home
243
+ // folder and Clopen's data never move.
234
244
  .http('files:rename-directory', {
235
245
  data: t.Object({
236
246
  oldPath: t.String(),
@@ -256,6 +266,23 @@ export const writeHandler = createRouter()
256
266
  throw new Error('Source path is not a directory');
257
267
  }
258
268
 
269
+ const project = projectAtFolder(oldPath);
270
+ if (project) {
271
+ if (dirname(newPath) !== dirname(oldPath)) throw new Error('A project folder can only be renamed in place.');
272
+ const outcome = await moveProject(project.id, { kind: 'rename', name: basename(newPath) });
273
+ if (outcome.status === 'busy') {
274
+ throw new Error('This folder is a project with chats or terminals still running. Stop them and try again.');
275
+ }
276
+ return {
277
+ message: 'Directory renamed successfully',
278
+ oldPath,
279
+ newPath: outcome.project.path,
280
+ modified: (await fsStat(outcome.project.path)).mtime.toISOString()
281
+ };
282
+ }
283
+ const reason = protectedFolderReason(oldPath);
284
+ if (reason) throw new Error(`This folder cannot be renamed: ${reason}.`);
285
+
259
286
  // Reject only when the destination is a genuinely different entry. On
260
287
  // case-insensitive filesystems (default on macOS and Windows) a
261
288
  // case-only rename like "Foo" -> "foo" makes the destination resolve to