@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
@@ -11,6 +11,13 @@ import type { ActionDef } from './types';
11
11
  import { commonFields } from './shared';
12
12
  import { analyzePage } from './dom-analyze';
13
13
  import { resolveWritePath } from '../paths';
14
+ import {
15
+ DEFAULT_JPEG_QUALITY,
16
+ type CapturedScreenshot,
17
+ type ScreenshotTarget
18
+ } from '$backend/preview/browser/browser-screenshot';
19
+ import { gitIgnoreState } from '$backend/preview/browser/screenshot-files';
20
+ import type { FrameSpec } from '$shared/utils/device-frame';
14
21
 
15
22
  export const find: ActionDef = {
16
23
  type: 'find',
@@ -90,18 +97,48 @@ export const analyzeDom: ActionDef = {
90
97
  }
91
98
  };
92
99
 
100
+ const DEVICES = ['mobile', 'tablet', 'laptop', 'desktop'] as const;
101
+
102
+ /** `shots/home.png` → `shots/home-mobile.png`, one file per device. */
103
+ function perDevicePath(saveTo: string, device: string, extension: string): string {
104
+ const dot = saveTo.lastIndexOf('.');
105
+ const stem = dot > saveTo.lastIndexOf('/') ? saveTo.slice(0, dot) : saveTo;
106
+ return `${stem}-${device}.${extension}`;
107
+ }
108
+
93
109
  export const screenshot: ActionDef = {
94
110
  type: 'screenshot',
95
111
  kind: 'control',
96
112
  activity: 'Taking a screenshot',
97
- doc: `screenshot {fullPage?, selector?, format?, quality?, saveTo?, return?} — capture the page.
113
+ doc: `screenshot {fullPage?, selector?, point?, region?, devices?, deviceFrame?, format?, quality?, saveTo?, return?} — capture the page.
98
114
  Needed for what the DOM cannot express: canvases, charts, iframes, captchas, and any visual check of layout or styling.
99
- saveTo writes a file under the project directory; with return:"file" the image is not sent back at all, which is what makes "capture twenty pages" affordable.
115
+ What to capture — at most one of: fullPage (whole scrollable page), selector (one element), point {x,y,depth?} (the element under a viewport point, depth ancestors up), region {x,y,width,height} (a viewport rectangle), devices (the page laid out on each listed device — mobile, tablet, laptop, desktop — in a hidden page, without touching the tab). Default: the visible viewport.
116
+ deviceFrame draws the device mockup around a viewport or devices capture, as the user's preview shows it.
117
+ saveTo writes a file under the project directory (with devices, one file per device: name-mobile.png …); with return:"file" the image is not sent back at all, which is what makes "capture twenty pages" affordable.
100
118
  format:"jpeg" with quality is much smaller than the default PNG when only the gist matters.`,
101
119
  schema: z.object({
102
120
  type: z.literal('screenshot'),
103
121
  fullPage: z.boolean().optional().describe('Capture the whole scrollable page instead of the viewport.'),
104
122
  selector: z.string().optional().describe('Capture just this element.'),
123
+ point: z
124
+ .object({
125
+ x: z.number(),
126
+ y: z.number(),
127
+ depth: z.number().int().min(0).optional().describe('Ancestors to step up from the innermost element (default 0).')
128
+ })
129
+ .optional()
130
+ .describe('Capture the element under this viewport point.'),
131
+ region: z
132
+ .object({ x: z.number(), y: z.number(), width: z.number().positive(), height: z.number().positive() })
133
+ .optional()
134
+ .describe('Capture this rectangle of the viewport, in CSS pixels.'),
135
+ devices: z
136
+ .array(z.enum(DEVICES))
137
+ .min(1)
138
+ .max(4)
139
+ .optional()
140
+ .describe('Capture the page as laid out on each of these devices.'),
141
+ deviceFrame: z.boolean().optional().describe('Draw the device mockup around a viewport or devices capture.'),
105
142
  format: z.enum(['png', 'jpeg']).optional().describe('Image format (default: png).'),
106
143
  quality: z.number().int().min(1).max(100).optional().describe('JPEG quality (default: 80). Ignored for PNG.'),
107
144
  saveTo: z.string().optional().describe('Project-relative path to write the image to.'),
@@ -110,36 +147,85 @@ export const screenshot: ActionDef = {
110
147
  }),
111
148
  run: async (args, ctx) => {
112
149
  const format = args.format ?? 'png';
150
+ const options = { format, quality: args.quality ?? DEFAULT_JPEG_QUALITY } as const;
113
151
  const mode = args.return ?? (args.saveTo ? 'both' : 'inline');
114
152
 
115
153
  if (mode !== 'inline' && !args.saveTo) throw new Error('return:"file"/"both" needs saveTo');
116
154
 
117
- const options = {
118
- type: format,
119
- fullPage: !!args.fullPage,
120
- ...(format === 'jpeg' ? { quality: args.quality ?? 80 } : {})
121
- } as const;
122
-
123
- let buffer: Uint8Array;
124
- if (args.selector) {
125
- const element = await ctx.tab.page.$(args.selector);
126
- if (!element) throw new Error(`No element matched "${args.selector}"`);
127
- try {
128
- buffer = await element.screenshot(options);
129
- } finally {
130
- await element.dispose().catch(() => {});
131
- }
155
+ const targets = [args.fullPage, args.selector, args.point, args.region, args.devices].filter((value) => value !== undefined && value !== false);
156
+ if (targets.length > 1) throw new Error('Use at most one of fullPage, selector, point, region and devices');
157
+ if (args.deviceFrame && (args.fullPage || args.selector || args.point || args.region)) {
158
+ throw new Error('deviceFrame only applies to a viewport or devices capture — the frame holds a whole screen');
159
+ }
160
+
161
+ // Each capture with what it is called and the device it can be framed in.
162
+ let shots: Array<{ image: CapturedScreenshot; label: string; device?: string; spec: FrameSpec | null }>;
163
+
164
+ if (args.devices) {
165
+ // The tab's own colours are the best guess for how the page frames on another device.
166
+ const pageColors = ctx.service.screenshotFrameSpec(ctx.tab.id)?.pageColors;
167
+ const taken = await ctx.service.takeResponsiveScreenshots(ctx.tab.id, [...args.devices], args.deviceFrame ? { format: 'png' } : options);
168
+ shots = taken.map((shot) => ({
169
+ image: shot.image,
170
+ label: `${shot.deviceSize} (${shot.viewport.width}×${shot.viewport.height})`,
171
+ device: shot.deviceSize,
172
+ spec: { deviceSize: shot.deviceSize, viewport: shot.viewport, deviceModel: shot.deviceModel, pageColors }
173
+ }));
132
174
  } else {
133
- buffer = await ctx.tab.page.screenshot(options);
175
+ // The same capture the viewer's screenshot button uses, so every viewer
176
+ // of the tab sees the shutter when the agent takes one too.
177
+ const target: ScreenshotTarget = args.selector
178
+ ? { kind: 'selector', selector: args.selector }
179
+ : args.point
180
+ ? { kind: 'element', x: args.point.x, y: args.point.y, depth: args.point.depth }
181
+ : args.region
182
+ ? { kind: 'region', ...args.region }
183
+ : args.fullPage
184
+ ? { kind: 'fullPage' }
185
+ : { kind: 'viewport' };
186
+ const image = await ctx.service.takeScreenshot(ctx.tab.id, target, args.deviceFrame ? { format: 'png' } : options, 'agent');
187
+ const label = args.selector
188
+ ? `screenshot of ${args.selector}`
189
+ : args.point
190
+ ? 'screenshot of the element at the point'
191
+ : args.region
192
+ ? 'screenshot of the region'
193
+ : 'screenshot';
194
+ shots = [{ image, label, spec: ctx.service.screenshotFrameSpec(ctx.tab.id) }];
195
+ }
196
+
197
+ if (args.deviceFrame) {
198
+ // Captured lossless above; the format asked for is applied once, after framing.
199
+ const framed = await ctx.service.frameScreenshots(
200
+ shots.map((shot) => {
201
+ if (!shot.spec) throw new Error('That tab is no longer open');
202
+ return { image: shot.image, spec: shot.spec };
203
+ }),
204
+ options
205
+ );
206
+ shots = shots.map((shot, index) => ({ ...shot, image: framed[index], label: `${shot.label}, framed` }));
134
207
  }
135
208
 
136
- const parts: string[] = [`${format}, ${Math.round(buffer.byteLength / 1024)}KB${args.fullPage ? ', full page' : ''}`];
209
+ const parts: string[] = [];
210
+ const root = args.saveTo ? projectQueries.getById(ctx.projectId)?.path : undefined;
211
+ let tracked = 0;
137
212
 
138
- if (args.saveTo) {
139
- const absolute = await resolveWritePath(args.saveTo, ctx.projectId);
140
- await writeFile(absolute, buffer);
141
- const root = projectQueries.getById(ctx.projectId)?.path;
142
- parts.push(`saved to ${root ? relative(root, absolute) : absolute}`);
213
+ for (const shot of shots) {
214
+ const { image } = shot;
215
+ const line = `${shot.device ? `${shot.device}: ` : ''}${format}, ${image.width}×${image.height}, ${Math.round(image.data.byteLength / 1024)}KB`;
216
+ if (!args.saveTo) {
217
+ parts.push(line);
218
+ continue;
219
+ }
220
+ const target = shot.device ? perDevicePath(args.saveTo, shot.device, format === 'jpeg' ? 'jpg' : 'png') : args.saveTo;
221
+ const absolute = await resolveWritePath(target, ctx.projectId);
222
+ await writeFile(absolute, image.data);
223
+ if (root && (await gitIgnoreState(root, absolute)) === 'not-ignored') tracked += 1;
224
+ parts.push(`${line} saved to ${root ? relative(root, absolute) : absolute}`);
225
+ }
226
+ if (args.fullPage) parts[0] += ', full page';
227
+ if (tracked > 0) {
228
+ parts.push(`git will track ${tracked === 1 ? 'this file' : 'these files'} — keep screenshots in an ignored folder unless they belong in the repository`);
143
229
  }
144
230
 
145
231
  return {
@@ -147,13 +233,11 @@ export const screenshot: ActionDef = {
147
233
  images:
148
234
  mode === 'file'
149
235
  ? undefined
150
- : [
151
- {
152
- data: Buffer.from(buffer).toString('base64'),
153
- mimeType: format === 'jpeg' ? 'image/jpeg' : 'image/png',
154
- label: args.selector ? `screenshot of ${args.selector}` : 'screenshot'
155
- }
156
- ]
236
+ : shots.map((shot) => ({
237
+ data: Buffer.from(shot.image.data).toString('base64'),
238
+ mimeType: shot.image.mimeType,
239
+ label: shot.label
240
+ }))
157
241
  };
158
242
  }
159
243
  };
@@ -39,6 +39,11 @@ Fill a form
39
39
  Check a layout on mobile
40
40
  [{set_viewport, device:"iphone-16"}, {wait_for, state:"networkIdle"}, {screenshot}]
41
41
  Same page on Android in dark mode: [{set_viewport, device:"galaxy-s24", colorScheme:"dark"}, {screenshot}]
42
+ Every device at once, without changing the tab: [{screenshot, devices:["mobile","tablet","laptop","desktop"]}]
43
+
44
+ Screenshots to show the user
45
+ [{screenshot, deviceFrame:true, saveTo:"screenshots/home.png"}] — the page inside its device mockup.
46
+ One part of the page: {screenshot, selector:"#pricing"}, or what is under a point: {screenshot, point:{x:640, y:300}}.
42
47
 
43
48
  Debug a page that misbehaves
44
49
  [{clear_console}, {click, selector:"#save"}, {wait, ms:500}, {console_logs, level:"error"}]`;
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Unified diffs of two texts, for snapshots that are not in git — the
3
+ * checkpoint blobs the AI-changes view reads.
4
+ */
5
+
6
+ import { diffSequencesAsync, splitLines, type DiffOp } from '$shared/utils/diff-calculator';
7
+
8
+ const CONTEXT = 3;
9
+
10
+ /** A `diff -u` style diff of `before` → `after`, or '' when they are the same. */
11
+ export async function unifiedDiff(path: string, before: string, after: string): Promise<string> {
12
+ if (before === after) return '';
13
+ const a = splitLines(before);
14
+ const b = splitLines(after);
15
+ const ops = await diffSequencesAsync(a, b);
16
+
17
+ // Lines of the edit script, each with where it sits on either side.
18
+ type Line = { op: DiffOp['type']; text: string; oldLine: number; newLine: number };
19
+ const lines: Line[] = [];
20
+ let oldLine = 0;
21
+ let newLine = 0;
22
+ for (const op of ops) {
23
+ if (op.type === 'keep') lines.push({ op: 'keep', text: a[op.oldIndex], oldLine: ++oldLine, newLine: ++newLine });
24
+ else if (op.type === 'delete') lines.push({ op: 'delete', text: a[op.oldIndex], oldLine: ++oldLine, newLine });
25
+ else lines.push({ op: 'insert', text: b[op.newIndex], oldLine, newLine: ++newLine });
26
+ }
27
+
28
+ const header = [`--- ${before ? `a/${path}` : '/dev/null'}`, `+++ ${after ? `b/${path}` : '/dev/null'}`];
29
+ const hunks: string[] = [];
30
+ let i = 0;
31
+ while (i < lines.length) {
32
+ if (lines[i].op === 'keep') {
33
+ i++;
34
+ continue;
35
+ }
36
+ const start = Math.max(0, i - CONTEXT);
37
+ let end = i;
38
+ // Extend while changes are within two contexts of each other.
39
+ while (end < lines.length) {
40
+ if (lines[end].op !== 'keep') {
41
+ end++;
42
+ continue;
43
+ }
44
+ let next = end;
45
+ while (next < lines.length && lines[next].op === 'keep') next++;
46
+ if (next < lines.length && next - end <= CONTEXT * 2) end = next;
47
+ else break;
48
+ }
49
+ const stop = Math.min(lines.length, end + CONTEXT);
50
+ const slice = lines.slice(start, stop);
51
+ const first = slice[0];
52
+ const oldStart = first.op === 'insert' ? first.oldLine + 1 : first.oldLine;
53
+ const newStart = first.op === 'delete' ? first.newLine + 1 : first.newLine;
54
+ const oldCount = slice.filter((line) => line.op !== 'insert').length;
55
+ const newCount = slice.filter((line) => line.op !== 'delete').length;
56
+ hunks.push(
57
+ `@@ -${oldCount ? oldStart : oldStart - 1},${oldCount} +${newCount ? newStart : newStart - 1},${newCount} @@`,
58
+ ...slice.map((line) => `${line.op === 'keep' ? ' ' : line.op === 'delete' ? '-' : '+'}${line.text}`)
59
+ );
60
+ i = stop;
61
+ }
62
+ return [...header, ...hunks].join('\n');
63
+ }
@@ -0,0 +1,109 @@
1
+ /**
2
+ * The `@` picker's server side: every mention source, searched together, and
3
+ * the snapshot of whatever is picked.
4
+ *
5
+ * Adding a source is adding it to `SOURCES` — the composer, the prompt and
6
+ * the timeline already know what to do with whatever it captures.
7
+ */
8
+
9
+ import type { CapturedAttachment, ContextKind, MentionCandidate, MentionRef } from '$shared/types/mentions';
10
+ import { CONTEXT_MEDIA_TYPE } from '$shared/utils/context-document';
11
+ import { MAX_ATTACHMENT_BYTES } from '$shared/constants/attachments';
12
+ import { debug } from '$shared/utils/logger';
13
+ import { bestFuzzyScore } from '$shared/utils/fuzzy';
14
+ import { filesSource } from './sources/files';
15
+ import { gitSource } from './sources/git';
16
+ import { terminalSource } from './sources/terminal';
17
+ import { previewSource } from './sources/preview';
18
+ import { chatsSource } from './sources/chats';
19
+ import { aiChangesSource } from './sources/ai-changes';
20
+ import { projectsSource } from './sources/projects';
21
+ import { notesMemorySource } from './sources/notes-memory';
22
+ import { databaseSource } from './sources/database';
23
+ import { containersSource, deploymentsSource } from './sources/ops';
24
+ import { systemSource } from './sources/system';
25
+ import { within } from './shared';
26
+ import type { MentionCategory, MentionContext, MentionSource } from './types';
27
+
28
+ export type { MentionContext, MentionCategory } from './types';
29
+
30
+ /** In the order their rows are listed. */
31
+ const SOURCES: MentionSource[] = [
32
+ filesSource,
33
+ gitSource,
34
+ previewSource,
35
+ terminalSource,
36
+ chatsSource,
37
+ aiChangesSource,
38
+ projectsSource,
39
+ notesMemorySource,
40
+ databaseSource,
41
+ deploymentsSource,
42
+ containersSource,
43
+ systemSource
44
+ ];
45
+
46
+ /** How long one source may take at the root before the picker answers without it. */
47
+ const ROOT_BUDGET_MS = 1500;
48
+ /** Opening a category waits longer: that list is all the picker shows. */
49
+ const CATEGORY_BUDGET_MS = 20_000;
50
+
51
+ export interface MentionSearch {
52
+ category?: string;
53
+ query: string;
54
+ limit?: number;
55
+ }
56
+
57
+ export async function searchMentions(
58
+ ctx: MentionContext,
59
+ search: MentionSearch
60
+ ): Promise<{ items: MentionCandidate[]; categories: MentionCategory[] }> {
61
+ const query = search.query.trim();
62
+ const limit = Math.min(Math.max(search.limit ?? 50, 1), 200);
63
+ const budget = search.category ? CATEGORY_BUDGET_MS : ROOT_BUDGET_MS;
64
+
65
+ const answer = async <T>(source: MentionSource, work: () => Promise<T> | T, fallback: T): Promise<T> => {
66
+ try {
67
+ return await within(Promise.resolve(work()), budget, fallback);
68
+ } catch (error) {
69
+ debug.warn('chat', `A mention source failed (${source.kinds[0]}):`, error);
70
+ return fallback;
71
+ }
72
+ };
73
+
74
+ const lists = await Promise.all(
75
+ SOURCES.map((source) => answer(source, () => source.list(ctx, { category: search.category, query, limit }), [] as MentionCandidate[]))
76
+ );
77
+ const items = lists.flat();
78
+
79
+ if (search.category) return { items: items.slice(0, limit), categories: [] };
80
+
81
+ const all = (await Promise.all(SOURCES.map((source) => answer(source, () => source.categories(ctx), [] as MentionCategory[])))).flat();
82
+ const categories = query
83
+ ? all.filter((category) => bestFuzzyScore(query, [category.label, category.detail]) > 0)
84
+ : all;
85
+ return { items, categories };
86
+ }
87
+
88
+ /** Take the snapshot of what was picked: its documents, then its pictures. */
89
+ export async function captureMention(ctx: MentionContext, kind: ContextKind, ref: MentionRef): Promise<CapturedAttachment[]> {
90
+ const source = SOURCES.find((entry) => entry.kinds.includes(kind));
91
+ if (!source) throw new Error(`Nothing can be mentioned as ${kind}`);
92
+ const captured = await source.capture(ctx, kind, ref);
93
+ return [
94
+ ...captured.documents.map((document) => ({
95
+ fileName: document.fileName,
96
+ mediaType: CONTEXT_MEDIA_TYPE,
97
+ data: withinLimit(document.text).toString('base64')
98
+ })),
99
+ ...(captured.images ?? [])
100
+ ];
101
+ }
102
+
103
+ /** The document's bytes, cut to what an attachment may hold — the header always survives. */
104
+ function withinLimit(text: string): Buffer {
105
+ const bytes = Buffer.from(text, 'utf8');
106
+ if (bytes.length <= MAX_ATTACHMENT_BYTES) return bytes;
107
+ const note = Buffer.from(`\n\n… cut here: the snapshot was larger than ${Math.round(MAX_ATTACHMENT_BYTES / (1024 * 1024))} MB.\n`, 'utf8');
108
+ return Buffer.concat([bytes.subarray(0, MAX_ATTACHMENT_BYTES - note.length), note]);
109
+ }
@@ -0,0 +1,27 @@
1
+ import { describe, expect, it } from 'bun:test';
2
+ import { unifiedDiff } from './diff';
3
+ import { rank, stripAnsi } from './shared';
4
+ import { terminalText } from './sources/terminal';
5
+
6
+ describe('mention helpers', () => {
7
+ it('write a unified diff with context around each change', async () => {
8
+ const before = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'].join('\n');
9
+ const after = ['a', 'b', 'C', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k'].join('\n');
10
+ expect(await unifiedDiff('x.txt', before, after)).toBe(
11
+ ['--- a/x.txt', '+++ b/x.txt', '@@ -1,6 +1,6 @@', ' a', ' b', '-c', '+C', ' d', ' e', ' f', '@@ -8,3 +8,4 @@', ' h', ' i', ' j', '+k'].join('\n')
12
+ );
13
+ expect(await unifiedDiff('x.txt', 'same', 'same')).toBe('');
14
+ expect(await unifiedDiff('new.txt', '', 'hello')).toBe(['--- /dev/null', '+++ b/new.txt', '@@ -0,0 +1,1 @@', '+hello'].join('\n'));
15
+ });
16
+
17
+ it('turn a terminal screen into the text a person saw', () => {
18
+ expect(stripAnsi('\u001b[1;31merror\u001b[0m: \u001b]0;title\u0007done')).toBe('error: done');
19
+ expect(terminalText('$ ls \r\nfile\r\n\r\n\r\n\r\n$ \u001b[K ')).toBe('$ ls\nfile\n\n$');
20
+ });
21
+
22
+ it('rank by match, keeping the given order with no query', () => {
23
+ const items = ['readme.md', 'src/app.ts', 'src/apple.ts'];
24
+ expect(rank(items, '', (item) => [item], 2)).toEqual(['readme.md', 'src/app.ts']);
25
+ expect(rank(items, 'app', (item) => [item], 5)).toEqual(['src/app.ts', 'src/apple.ts']);
26
+ });
27
+ });
@@ -0,0 +1,82 @@
1
+ /**
2
+ * Helpers the mention sources share.
3
+ */
4
+
5
+ import { bestFuzzyScore } from '$shared/utils/fuzzy';
6
+ import { execGit } from '$backend/git/git-executor';
7
+
8
+ /**
9
+ * Keep what matches `query`, best first, at most `limit`. With no query the
10
+ * order given is kept — sources list most recent or most relevant first.
11
+ */
12
+ export function rank<T>(items: T[], query: string, texts: (item: T) => Array<string | undefined | null>, limit: number): T[] {
13
+ if (!query.trim()) return items.slice(0, limit);
14
+ return items
15
+ .map((item, order) => ({ item, order, score: bestFuzzyScore(query, texts(item)) }))
16
+ .filter((entry) => entry.score > 0)
17
+ .sort((a, b) => b.score - a.score || a.order - b.order)
18
+ .slice(0, limit)
19
+ .map((entry) => entry.item);
20
+ }
21
+
22
+ /** Whether `category` is the one asked for, or the root is. */
23
+ export function wants(category: string | undefined, own: string): 'root' | 'own' | null {
24
+ if (!category) return 'root';
25
+ return category === own ? 'own' : null;
26
+ }
27
+
28
+ /** Resolve within `ms`, or with `fallback`. A slow source must not hold the picker. */
29
+ export async function within<T>(work: Promise<T>, ms: number, fallback: T): Promise<T> {
30
+ let timer: ReturnType<typeof setTimeout> | undefined;
31
+ try {
32
+ return await Promise.race([
33
+ work,
34
+ new Promise<T>((resolve) => {
35
+ timer = setTimeout(() => resolve(fallback), ms);
36
+ })
37
+ ]);
38
+ } finally {
39
+ if (timer) clearTimeout(timer);
40
+ }
41
+ }
42
+
43
+ /** A git command's output, or null when it fails (not a repo, no git, bad ref). */
44
+ export async function gitText(args: string[], cwd: string, timeout = 20_000, okExitCodes: number[] = []): Promise<string | null> {
45
+ try {
46
+ const result = await execGit(args, cwd, { timeout, okExitCodes });
47
+ return result.stdout;
48
+ } catch {
49
+ return null;
50
+ }
51
+ }
52
+
53
+ /** "3 minutes ago" for a timestamp, for a row's detail line. */
54
+ export function ago(value: string | number | Date | null | undefined): string {
55
+ if (value === null || value === undefined || value === '') return '';
56
+ const time = new Date(value).getTime();
57
+ if (!Number.isFinite(time)) return '';
58
+ const seconds = Math.max(0, Math.round((Date.now() - time) / 1000));
59
+ if (seconds < 60) return 'just now';
60
+ const minutes = Math.round(seconds / 60);
61
+ if (minutes < 60) return `${minutes} min ago`;
62
+ const hours = Math.round(minutes / 60);
63
+ if (hours < 24) return `${hours} h ago`;
64
+ const days = Math.round(hours / 24);
65
+ if (days < 30) return `${days} d ago`;
66
+ return new Date(time).toISOString().slice(0, 10);
67
+ }
68
+
69
+ /** Remove terminal escape sequences, leaving the text a person saw. */
70
+ export function stripAnsi(text: string): string {
71
+ return (
72
+ text
73
+ // OSC (titles, hyperlinks), ended by BEL or ST.
74
+ .replace(/\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)/g, '')
75
+ // CSI sequences: colours, cursor moves, erases.
76
+ .replace(/\u001b\[[0-?]*[ -/]*[@-~]/g, '')
77
+ // Other two-character escapes.
78
+ .replace(/\u001b[@-Z\\-_]/g, '')
79
+ // Lone control characters except tab and newline.
80
+ .replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, '')
81
+ );
82
+ }
@@ -0,0 +1,140 @@
1
+ /**
2
+ * What the AI changed in this chat: one turn, or the whole chat net.
3
+ *
4
+ * Read from checkpoint snapshots — the same record the AI-changes panel shows
5
+ * — so a change made by a shell command counts as much as one made by an edit
6
+ * tool. Only turns still on the active branch are offered: a restored-away
7
+ * turn describes nothing on disk.
8
+ */
9
+
10
+ import type { MentionCandidate } from '$shared/types/mentions';
11
+ import type { SessionScopedChanges } from '$shared/types/database/schema';
12
+ import { buildContextDocument, type ContextSection } from '$shared/utils/context-document';
13
+ import { loadMessage } from '$shared/utils/message-formatter';
14
+ import { snapshotQueries } from '$backend/database/queries';
15
+ import { extractMessageText } from '$backend/snapshot/helpers';
16
+ import { excerptPrompt, statusOf } from '$backend/snapshot/turn-changes';
17
+ import { activeCheckpoints, parseSessionChanges, readTextBlob } from '$backend/ws/snapshot/changes';
18
+ import { unifiedDiff } from '../diff';
19
+ import { ago, rank, wants } from '../shared';
20
+ import { type MentionContext, type MentionSource } from '../types';
21
+
22
+ const CATEGORY = 'ai-changes';
23
+
24
+ interface Turn {
25
+ checkpointId: string;
26
+ index: number;
27
+ prompt: string;
28
+ at: string;
29
+ changes: SessionScopedChanges;
30
+ }
31
+
32
+ /** How long a chat's turn list is reused: the picker asks on every keystroke. */
33
+ const TURNS_TTL_MS = 10_000;
34
+ const turnsCache = new Map<string, { at: number; turns: Turn[] }>();
35
+
36
+ /** The turns that changed something, oldest first — read once per few keystrokes. */
37
+ function turnsOf(chatSessionId: string | null): Turn[] {
38
+ if (!chatSessionId) return [];
39
+ const hit = turnsCache.get(chatSessionId);
40
+ if (hit && Date.now() - hit.at < TURNS_TTL_MS) return hit.turns;
41
+ const turns = readTurns(chatSessionId);
42
+ turnsCache.set(chatSessionId, { at: Date.now(), turns });
43
+ if (turnsCache.size > 50) turnsCache.delete(turnsCache.keys().next().value!);
44
+ return turns;
45
+ }
46
+
47
+ function readTurns(chatSessionId: string): Turn[] {
48
+ return activeCheckpoints(chatSessionId)
49
+ .map((checkpoint, i) => ({
50
+ checkpointId: checkpoint.id,
51
+ index: i + 1,
52
+ prompt: excerptPrompt(extractMessageText(loadMessage(checkpoint)).replace(/\s+/g, ' ').trim(), 120),
53
+ at: checkpoint.created_at,
54
+ changes: parseSessionChanges(snapshotQueries.getByMessageId(checkpoint.id)?.session_changes)
55
+ }))
56
+ .filter((turn) => Object.keys(turn.changes).length > 0);
57
+ }
58
+
59
+ function rows(ctx: MentionContext): MentionCandidate[] {
60
+ const turns = turnsOf(ctx.chatSessionId);
61
+ if (turns.length === 0) return [];
62
+ const files = new Set(turns.flatMap((turn) => Object.keys(turn.changes)));
63
+ return [
64
+ {
65
+ key: 'ai-changes:all', kind: 'ai-changes', group: 'AI changes', label: 'Everything this chat changed',
66
+ detail: `${files.size} ${files.size === 1 ? 'file' : 'files'} over ${turns.length} ${turns.length === 1 ? 'turn' : 'turns'}`,
67
+ icon: 'lucide:sparkles', ref: {}
68
+ },
69
+ ...[...turns].reverse().map((turn) => {
70
+ const count = Object.keys(turn.changes).length;
71
+ return {
72
+ key: `ai-changes:${turn.checkpointId}`, kind: 'ai-changes' as const, group: 'AI changes',
73
+ label: `Turn ${turn.index}: ${turn.prompt || '(no text)'}`,
74
+ detail: `${count} ${count === 1 ? 'file' : 'files'} · ${ago(turn.at)}`, icon: 'lucide:sparkles' as const,
75
+ ref: { checkpointId: turn.checkpointId }
76
+ };
77
+ })
78
+ ];
79
+ }
80
+
81
+ export const aiChangesSource: MentionSource = {
82
+ kinds: ['ai-changes'],
83
+
84
+ categories(ctx) {
85
+ const turns = turnsOf(ctx.chatSessionId);
86
+ if (turns.length === 0) return [];
87
+ return [{ id: CATEGORY, label: 'AI changes', detail: `${turns.length} ${turns.length === 1 ? 'turn' : 'turns'} in this chat`, icon: 'lucide:sparkles', group: 'Chats' }];
88
+ },
89
+
90
+ async list(ctx, request) {
91
+ const mode = wants(request.category, CATEGORY);
92
+ if (!mode) return [];
93
+ const all = rows(ctx);
94
+ if (mode === 'root') return request.query.trim() ? rank(all, request.query, (row) => [row.label, 'ai changes'], 2) : [];
95
+ return rank(all, request.query, (row) => [row.label], request.limit);
96
+ },
97
+
98
+ async capture(ctx, _kind, ref) {
99
+ // A capture reads the chat as it is now, not as it was a few seconds ago.
100
+ const turns = ctx.chatSessionId ? readTurns(ctx.chatSessionId) : [];
101
+ const checkpointId = typeof ref.checkpointId === 'string' ? ref.checkpointId : null;
102
+ const chosen = checkpointId ? turns.filter((turn) => turn.checkpointId === checkpointId) : turns;
103
+ if (chosen.length === 0) throw new Error('Those changes are no longer on this branch');
104
+
105
+ // Net over the turns: the first "before" and the last "after" of each file.
106
+ const net = new Map<string, { oldHash: string; newHash: string }>();
107
+ for (const turn of chosen) {
108
+ for (const [path, change] of Object.entries(turn.changes)) {
109
+ const known = net.get(path);
110
+ net.set(path, { oldHash: known ? known.oldHash : change.oldHash, newHash: change.newHash });
111
+ }
112
+ }
113
+
114
+ const sections: ContextSection[] = [];
115
+ const summary: string[] = [];
116
+ for (const [path, change] of net) {
117
+ if (change.oldHash === change.newHash) continue;
118
+ const status = statusOf(change.oldHash, change.newHash);
119
+ summary.push(`${status.padEnd(8)} ${path}`);
120
+ const before = change.oldHash ? await readTextBlob(change.oldHash) : '';
121
+ const after = change.newHash ? await readTextBlob(change.newHash) : '';
122
+ if (before === null || after === null) {
123
+ sections.push({ title: path, body: `Binary file ${status}.` });
124
+ continue;
125
+ }
126
+ sections.push({ title: path, body: await unifiedDiff(path, before, after), fence: 'diff' });
127
+ }
128
+
129
+ const label = checkpointId ? `Turn ${chosen[0].index}: ${chosen[0].prompt || '(no text)'}` : 'Everything this chat changed';
130
+ return {
131
+ documents: [buildContextDocument({
132
+ kind: 'ai-changes',
133
+ label,
134
+ detail: `${summary.length} ${summary.length === 1 ? 'file' : 'files'}`,
135
+ facts: [['Turns', chosen.map((turn) => turn.index).join(', ')]],
136
+ sections: [{ title: 'Files', body: summary.join('\n') || 'Nothing left changed.', fence: '' }, ...sections]
137
+ })]
138
+ };
139
+ }
140
+ };