@myrialabs/clopen 0.4.47 → 0.4.49

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 (390) hide show
  1. package/README.md +11 -11
  2. package/backend/artifacts/project/sources.ts +1 -1
  3. package/backend/auth/auth-service.ts +52 -358
  4. package/backend/auth/onboarding.test.ts +2 -3
  5. package/backend/auth/permissions.test.ts +10 -20
  6. package/backend/auth/permissions.ts +4 -290
  7. package/backend/auth/rate-limiter.test.ts +8 -9
  8. package/backend/auth/rate-limiter.ts +0 -2
  9. package/backend/auth/tokens.ts +1 -8
  10. package/backend/bootstrap.ts +7 -0
  11. package/backend/chat/attachments.test.ts +88 -0
  12. package/backend/chat/attachments.ts +159 -0
  13. package/backend/chat/engine-handoff.test.ts +0 -2
  14. package/backend/chat/message-pages.test.ts +163 -0
  15. package/backend/chat/message-pages.ts +233 -0
  16. package/backend/chat/stream-manager.ts +91 -67
  17. package/backend/chat/turn-answer.test.ts +64 -0
  18. package/backend/chat/turn-answer.ts +125 -0
  19. package/backend/chat-apps/awaiting.test.ts +39 -0
  20. package/backend/chat-apps/awaiting.ts +49 -0
  21. package/backend/chat-apps/conversation.ts +746 -0
  22. package/backend/chat-apps/inbound.ts +324 -0
  23. package/backend/chat-apps/index.ts +309 -0
  24. package/backend/chat-apps/link-events.ts +20 -0
  25. package/backend/chat-apps/media.test.ts +62 -0
  26. package/backend/chat-apps/media.ts +208 -0
  27. package/backend/chat-apps/messages.test.ts +229 -0
  28. package/backend/chat-apps/messages.ts +365 -0
  29. package/backend/chat-apps/outbound.ts +243 -0
  30. package/backend/chat-apps/pairing.test.ts +45 -0
  31. package/backend/chat-apps/pairing.ts +74 -0
  32. package/backend/chat-apps/platforms/index.ts +20 -0
  33. package/backend/chat-apps/platforms/telegram.test.ts +35 -0
  34. package/backend/chat-apps/platforms/telegram.ts +191 -0
  35. package/backend/chat-apps/platforms/types.ts +114 -0
  36. package/backend/chat-apps/questions.ts +133 -0
  37. package/backend/chat-apps/runtime.ts +572 -0
  38. package/backend/chat-apps/storage.test.ts +201 -0
  39. package/backend/chat-apps/turns.test.ts +45 -0
  40. package/backend/chat-apps/turns.ts +208 -0
  41. package/backend/containers/pty.ts +3 -11
  42. package/backend/control/actions/accounts.ts +89 -0
  43. package/backend/control/actions/files.ts +116 -0
  44. package/backend/control/actions/models.ts +188 -0
  45. package/backend/control/actions/projects.ts +272 -0
  46. package/backend/control/actions/sessions.ts +280 -0
  47. package/backend/control/actions/skills.ts +111 -0
  48. package/backend/control/control.test.ts +169 -0
  49. package/backend/control/define.ts +20 -0
  50. package/backend/control/folders.test.ts +67 -0
  51. package/backend/control/index.ts +213 -0
  52. package/backend/control/invoke.ts +44 -0
  53. package/backend/control/links.ts +35 -0
  54. package/backend/control/paging.ts +26 -0
  55. package/backend/control/types.ts +117 -0
  56. package/backend/control/workspace.ts +127 -0
  57. package/backend/database/migrations/084_create_channel_links.ts +71 -0
  58. package/backend/database/migrations/085_add_home_projects.ts +36 -0
  59. package/backend/database/migrations/086_single_owner.ts +418 -0
  60. package/backend/database/migrations/087_create_blob_line_stats.ts +37 -0
  61. package/backend/database/migrations/index.ts +28 -0
  62. package/backend/database/queries/auth-queries.ts +7 -85
  63. package/backend/database/queries/blob-line-stats-queries.ts +48 -0
  64. package/backend/database/queries/channel-queries.ts +270 -0
  65. package/backend/database/queries/db-client-connection-queries.ts +18 -56
  66. package/backend/database/queries/file-share-queries.ts +5 -23
  67. package/backend/database/queries/git-identity-queries.ts +31 -42
  68. package/backend/database/queries/graph-queries.ts +1 -1
  69. package/backend/database/queries/index.ts +15 -1
  70. package/backend/database/queries/message-queries.test.ts +146 -0
  71. package/backend/database/queries/message-queries.ts +42 -1
  72. package/backend/database/queries/permission-set-queries.ts +1 -1
  73. package/backend/database/queries/profile-queries.ts +1 -1
  74. package/backend/database/queries/project-mcp-trust-queries.ts +1 -1
  75. package/backend/database/queries/project-queries.ts +50 -63
  76. package/backend/database/queries/session-queries.ts +28 -56
  77. package/backend/database/queries/ssh-connection-queries.ts +18 -41
  78. package/backend/db-client/env/diff.ts +9 -33
  79. package/backend/db-client/env/env.test.ts +8 -8
  80. package/backend/db-client/env/service.ts +1 -1
  81. package/backend/db-client/integrations/projector.ts +0 -5
  82. package/backend/engine/adapters/claude/message-converter.test.ts +47 -0
  83. package/backend/engine/adapters/claude/message-converter.ts +25 -2
  84. package/backend/engine/adapters/cline/message-converter.ts +0 -1
  85. package/backend/engine/adapters/cline/stream.ts +11 -15
  86. package/backend/engine/adapters/codex/message-converter.ts +0 -2
  87. package/backend/engine/adapters/copilot/message-converter.ts +1 -2
  88. package/backend/engine/adapters/cursor/message-converter.ts +0 -1
  89. package/backend/engine/adapters/opencode/message-converter.ts +2 -4
  90. package/backend/engine/adapters/opencode/stream.ts +11 -0
  91. package/backend/engine/adapters/parent-scope.test.ts +38 -0
  92. package/backend/engine/adapters/parent-scope.ts +44 -0
  93. package/backend/engine/adapters/pi/message-converter.ts +0 -1
  94. package/backend/engine/adapters/pi/stream.ts +4 -5
  95. package/backend/engine/adapters/qwen/message-converter.ts +0 -2
  96. package/backend/engine/bootstrap-default-engine.ts +2 -2
  97. package/backend/engine/docs/adapter-contract.md +8 -1
  98. package/backend/engine/install-runner.ts +8 -17
  99. package/backend/files/file-shares.ts +20 -44
  100. package/backend/files/file-size-limit.ts +3 -3
  101. package/backend/files/file-watcher.ts +19 -0
  102. package/backend/files/image-processing.ts +1 -1
  103. package/backend/files/os-clipboard.ts +2 -2
  104. package/backend/git/contributors.test.ts +35 -0
  105. package/backend/git/contributors.ts +46 -0
  106. package/backend/git/git-executor.ts +25 -5
  107. package/backend/git/git-service.ts +420 -19
  108. package/backend/git/identity/credential-helper.test.ts +2 -7
  109. package/backend/git/identity/import-local.test.ts +11 -16
  110. package/backend/git/identity/import-local.ts +12 -12
  111. package/backend/git/identity/index.ts +10 -24
  112. package/backend/git/identity/resolve.ts +13 -14
  113. package/backend/git/identity/scope-config.ts +33 -28
  114. package/backend/git/identity/service.ts +44 -47
  115. package/backend/git/op-lock.test.ts +111 -0
  116. package/backend/git/op-lock.ts +180 -0
  117. package/backend/git/remote-sync.test.ts +249 -0
  118. package/backend/host/metrics.ts +1 -1
  119. package/backend/http/bearer-auth.ts +1 -2
  120. package/backend/http/files-download.test.ts +8 -9
  121. package/backend/http/files-download.ts +2 -2
  122. package/backend/http/files-shared.test.ts +62 -89
  123. package/backend/http/files-shared.ts +2 -2
  124. package/backend/http/files-upload.test.ts +3 -7
  125. package/backend/http/files-upload.ts +3 -3
  126. package/backend/http/notes-images.test.ts +15 -38
  127. package/backend/http/notes-images.ts +6 -8
  128. package/backend/http/ssh-sftp.ts +5 -10
  129. package/backend/http/static-assets.test.ts +78 -0
  130. package/backend/http/static-assets.ts +104 -0
  131. package/backend/index.ts +32 -16
  132. package/backend/integrations/accounts.ts +61 -3
  133. package/backend/integrations/index.ts +2 -2
  134. package/backend/integrations/registry/define.ts +15 -0
  135. package/backend/integrations/registry/index.ts +2 -0
  136. package/backend/integrations/registry/providers/telegram.ts +54 -0
  137. package/backend/integrations/registry/types.ts +21 -1
  138. package/backend/integrations/webhooks/gateway.ts +7 -6
  139. package/backend/integrations/webhooks/verify.test.ts +30 -0
  140. package/backend/integrations/webhooks/verify.ts +4 -0
  141. package/backend/mcp/external/project.ts +1 -1
  142. package/backend/mcp/internal/remote-server.test.ts +1 -3
  143. package/backend/mcp/internal/remote-server.ts +4 -4
  144. package/backend/mcp/internal/servers/browser-automation/actions/dialogs.ts +67 -0
  145. package/backend/mcp/internal/servers/browser-automation/actions/index.ts +3 -1
  146. package/backend/mcp/internal/servers/browser-automation/actions/input.ts +5 -5
  147. package/backend/mcp/internal/servers/browser-automation/actions/tabs.ts +157 -28
  148. package/backend/mcp/internal/servers/browser-automation/context.ts +1 -0
  149. package/backend/mcp/internal/servers/browser-automation/description.ts +5 -2
  150. package/backend/mcp/internal/servers/browser-automation/format.ts +24 -1
  151. package/backend/mcp/internal/servers/browser-automation/runner.ts +68 -3
  152. package/backend/memory/redact.ts +1 -1
  153. package/backend/notes/access.test.ts +28 -29
  154. package/backend/notes/access.ts +6 -11
  155. package/backend/permissions/service.ts +1 -1
  156. package/backend/preview/browser/browser-clipboard.test.ts +46 -0
  157. package/backend/preview/browser/browser-clipboard.ts +67 -0
  158. package/backend/preview/browser/browser-dialog-handler.ts +95 -6
  159. package/backend/preview/browser/browser-host-bridge.ts +9 -0
  160. package/backend/preview/browser/browser-interaction-handler.ts +316 -86
  161. package/backend/preview/browser/browser-mcp-control.ts +34 -0
  162. package/backend/preview/browser/browser-pool.ts +67 -6
  163. package/backend/preview/browser/browser-preview-service.ts +383 -29
  164. package/backend/preview/browser/browser-tab-manager.ts +66 -23
  165. package/backend/preview/browser/browser-video-capture.ts +92 -5
  166. package/backend/preview/browser/element-locator.ts +190 -17
  167. package/backend/preview/browser/keyboard-chords.test.ts +68 -0
  168. package/backend/preview/browser/keyboard-chords.ts +132 -0
  169. package/backend/preview/browser/paste.ts +81 -0
  170. package/backend/preview/browser/process-usage.ts +142 -0
  171. package/backend/preview/browser/profile-lock.ts +209 -0
  172. package/backend/preview/browser/scripts/host-bridge.ts +59 -0
  173. package/backend/preview/browser/scripts/video-stream.ts +58 -0
  174. package/backend/preview/browser/types.ts +40 -2
  175. package/backend/preview/browser/viewport.test.ts +45 -0
  176. package/backend/preview/browser/viewport.ts +96 -0
  177. package/backend/profiles/service.ts +2 -2
  178. package/backend/project/status-manager.ts +43 -172
  179. package/backend/projects/home.ts +61 -0
  180. package/backend/projects/project-cleanup.integration.test.ts +2 -2
  181. package/backend/projects/project-cleanup.ts +0 -8
  182. package/backend/skills/service.ts +2 -3
  183. package/backend/snapshot/blob-store.ts +9 -1
  184. package/backend/snapshot/helpers.ts +3 -11
  185. package/backend/snapshot/line-stats.test.ts +80 -0
  186. package/backend/snapshot/line-stats.ts +64 -0
  187. package/backend/snapshot/restore.ts +252 -0
  188. package/backend/snapshot/snapshot-service.ts +14 -27
  189. package/backend/snapshot/turn-changes.test.ts +10 -5
  190. package/backend/snapshot/turn-changes.ts +78 -40
  191. package/backend/ssh/ptykit.ts +1 -2
  192. package/backend/terminal/ptykit.ts +10 -8
  193. package/backend/tunnel/public-origin.ts +31 -20
  194. package/backend/utils/user-helpers.ts +0 -55
  195. package/backend/utils/ws-wire.test.ts +87 -0
  196. package/backend/utils/ws-wire.ts +189 -0
  197. package/backend/utils/ws.ts +101 -192
  198. package/backend/worktrees/branching/engine.ts +3 -16
  199. package/backend/worktrees/branching/index.ts +1 -1
  200. package/backend/worktrees/branching/projector.ts +1 -1
  201. package/backend/worktrees/branching/service.ts +13 -25
  202. package/backend/ws/access.ts +12 -21
  203. package/backend/ws/artifacts/generate.ts +2 -2
  204. package/backend/ws/auth/device.ts +16 -71
  205. package/backend/ws/auth/index.ts +4 -22
  206. package/backend/ws/auth/login.test.ts +14 -60
  207. package/backend/ws/auth/login.ts +24 -124
  208. package/backend/ws/auth/status.ts +0 -1
  209. package/backend/ws/chat/composer.ts +118 -118
  210. package/backend/ws/chat/stream.ts +105 -57
  211. package/backend/ws/chat-apps/index.ts +117 -0
  212. package/backend/ws/containers/actions.ts +11 -25
  213. package/backend/ws/containers/index.ts +3 -4
  214. package/backend/ws/containers/list.ts +10 -36
  215. package/backend/ws/containers/logs.ts +2 -2
  216. package/backend/ws/containers/tunnel.ts +1 -2
  217. package/backend/ws/db-client/access.ts +2 -16
  218. package/backend/ws/db-client/accounts.ts +5 -15
  219. package/backend/ws/db-client/connections.ts +17 -25
  220. package/backend/ws/db-client/context.ts +1 -1
  221. package/backend/ws/db-client/env.ts +7 -10
  222. package/backend/ws/db-client/index.ts +2 -2
  223. package/backend/ws/db-client/io.ts +5 -5
  224. package/backend/ws/db-client/query-history-retention.test.ts +8 -8
  225. package/backend/ws/db-client/query.ts +18 -17
  226. package/backend/ws/db-client/schema.ts +13 -13
  227. package/backend/ws/db-client/structure.ts +35 -35
  228. package/backend/ws/db-client/supabase.ts +4 -21
  229. package/backend/ws/deployments/context.ts +1 -1
  230. package/backend/ws/deployments/crud.ts +0 -5
  231. package/backend/ws/engine/access.ts +7 -20
  232. package/backend/ws/engine/claude/accounts.ts +4 -4
  233. package/backend/ws/engine/cline/accounts.ts +5 -5
  234. package/backend/ws/engine/codex/accounts.ts +3 -3
  235. package/backend/ws/engine/pi/accounts.ts +5 -5
  236. package/backend/ws/files/clipboard.ts +8 -27
  237. package/backend/ws/files/image-edit.ts +6 -6
  238. package/backend/ws/files/index.ts +1 -1
  239. package/backend/ws/files/path-access.test.ts +32 -131
  240. package/backend/ws/files/path-access.ts +8 -87
  241. package/backend/ws/files/read.ts +45 -19
  242. package/backend/ws/files/reveal.ts +3 -3
  243. package/backend/ws/files/search.ts +7 -7
  244. package/backend/ws/files/share.ts +9 -13
  245. package/backend/ws/files/state.ts +9 -12
  246. package/backend/ws/files/watch.ts +3 -3
  247. package/backend/ws/files/write.ts +30 -31
  248. package/backend/ws/git/branch.ts +80 -59
  249. package/backend/ws/git/commit.ts +63 -44
  250. package/backend/ws/git/conflict.ts +16 -18
  251. package/backend/ws/git/identity-context.ts +8 -17
  252. package/backend/ws/git/identity.ts +17 -27
  253. package/backend/ws/git/index.ts +3 -1
  254. package/backend/ws/git/log.ts +52 -0
  255. package/backend/ws/git/op-state.ts +139 -0
  256. package/backend/ws/git/remote.ts +241 -141
  257. package/backend/ws/git/repo-context.ts +67 -0
  258. package/backend/ws/git/staging.ts +18 -28
  259. package/backend/ws/git/status.ts +5 -2
  260. package/backend/ws/index.ts +5 -1
  261. package/backend/ws/instructions/crud.ts +1 -1
  262. package/backend/ws/integrations/crud.ts +1 -3
  263. package/backend/ws/mcp/crud.ts +3 -5
  264. package/backend/ws/mcp/tools.ts +1 -1
  265. package/backend/ws/memory/crud.ts +14 -46
  266. package/backend/ws/memory/index.ts +2 -2
  267. package/backend/ws/messages/crud.ts +78 -8
  268. package/backend/ws/notes/index.ts +33 -39
  269. package/backend/ws/permissions/crud.ts +3 -4
  270. package/backend/ws/ports/index.ts +1 -2
  271. package/backend/ws/ports/kill.ts +5 -10
  272. package/backend/ws/ports/list.ts +4 -10
  273. package/backend/ws/preview/access.ts +1 -1
  274. package/backend/ws/preview/browser/interact.ts +52 -79
  275. package/backend/ws/preview/browser/native-ui.ts +24 -0
  276. package/backend/ws/preview/browser/stats.ts +98 -1
  277. package/backend/ws/preview/browser/tab-info.ts +15 -0
  278. package/backend/ws/preview/browser/tab.ts +19 -4
  279. package/backend/ws/preview/index.ts +29 -0
  280. package/backend/ws/preview/watchers.ts +84 -0
  281. package/backend/ws/profiles/crud.ts +6 -8
  282. package/backend/ws/project-artifacts/index.ts +30 -31
  283. package/backend/ws/projects/crud.ts +33 -35
  284. package/backend/ws/projects/index.ts +3 -8
  285. package/backend/ws/projects/info.ts +3 -3
  286. package/backend/ws/projects/overview.ts +19 -30
  287. package/backend/ws/projects/status.ts +17 -57
  288. package/backend/ws/sessions/crud.ts +42 -57
  289. package/backend/ws/sessions/index.ts +1 -1
  290. package/backend/ws/settings/crud.ts +1 -1
  291. package/backend/ws/skills/crud.ts +3 -4
  292. package/backend/ws/skills/index.ts +1 -1
  293. package/backend/ws/snapshot/changes.ts +12 -13
  294. package/backend/ws/snapshot/restore.ts +11 -295
  295. package/backend/ws/snapshot/timeline.ts +2 -4
  296. package/backend/ws/ssh/access.ts +6 -21
  297. package/backend/ws/ssh/connections.ts +21 -31
  298. package/backend/ws/ssh/forwards.ts +12 -12
  299. package/backend/ws/ssh/sftp.ts +34 -34
  300. package/backend/ws/ssh/tunnel.ts +1 -2
  301. package/backend/ws/stack/install.ts +7 -17
  302. package/backend/ws/subagents/crud.ts +1 -1
  303. package/backend/ws/terminal/tunnel.ts +2 -2
  304. package/backend/ws/tunnel/share.ts +0 -2
  305. package/backend/ws/user/crud.ts +1 -59
  306. package/backend/ws/user/index.ts +1 -1
  307. package/backend/ws/work/context.ts +1 -1
  308. package/backend/ws/work/crud.ts +0 -5
  309. package/backend/ws/workspace/state.ts +10 -13
  310. package/backend/ws/worktrees/branching.ts +7 -36
  311. package/backend/ws/worktrees/crud.ts +2 -2
  312. package/bin/clopen.ts +46 -41
  313. package/dist/assets/addon-clipboard-wHJhZAA4.js.br +0 -0
  314. package/dist/assets/addon-clipboard-wHJhZAA4.js.gz +0 -0
  315. package/dist/assets/addon-fit-DX4qG4td.js.br +1 -0
  316. package/dist/assets/addon-fit-DX4qG4td.js.gz +0 -0
  317. package/dist/assets/addon-ligatures-DpDY8N_X.js.br +0 -0
  318. package/dist/assets/addon-ligatures-DpDY8N_X.js.gz +0 -0
  319. package/dist/assets/addon-unicode11-Bt8F3D7-.js.br +0 -0
  320. package/dist/assets/addon-unicode11-Bt8F3D7-.js.gz +0 -0
  321. package/dist/assets/addon-web-links-DIbG5aQx.js.br +0 -0
  322. package/dist/assets/addon-web-links-DIbG5aQx.js.gz +0 -0
  323. package/dist/assets/diff.worker-BoHLxmr2.js +7 -0
  324. package/dist/assets/diff.worker-BoHLxmr2.js.br +0 -0
  325. package/dist/assets/diff.worker-BoHLxmr2.js.gz +0 -0
  326. package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.br +0 -0
  327. package/dist/assets/graph-layout.worker-CRFqN7ZQ.js.gz +0 -0
  328. package/dist/assets/{index-CwuKQelV.js → index-CrVWZH_D.js} +1 -1
  329. package/dist/assets/index-CrVWZH_D.js.br +0 -0
  330. package/dist/assets/index-CrVWZH_D.js.gz +0 -0
  331. package/dist/assets/{index-BTcR1byF.js → index-DD0-3EWg.js} +1 -1
  332. package/dist/assets/index-DD0-3EWg.js.br +0 -0
  333. package/dist/assets/index-DD0-3EWg.js.gz +0 -0
  334. package/dist/assets/main-D2_TmcwQ.js +1240 -0
  335. package/dist/assets/main-D2_TmcwQ.js.br +0 -0
  336. package/dist/assets/main-D2_TmcwQ.js.gz +0 -0
  337. package/dist/assets/main-Yucigcmf.css +1 -0
  338. package/dist/assets/main-Yucigcmf.css.br +0 -0
  339. package/dist/assets/main-Yucigcmf.css.gz +0 -0
  340. package/dist/assets/preview-video.worker-DcpDhCWL.js.br +0 -0
  341. package/dist/assets/preview-video.worker-DcpDhCWL.js.gz +0 -0
  342. package/dist/assets/xterm-B-qIQCd3.js.br +0 -0
  343. package/dist/assets/xterm-B-qIQCd3.js.gz +0 -0
  344. package/dist/assets/zipkit-engine-CaR0t_Uy.wasm.br +0 -0
  345. package/dist/assets/zipkit-engine-CaR0t_Uy.wasm.gz +0 -0
  346. package/dist/fonts/dm-sans.css.br +0 -0
  347. package/dist/fonts/dm-sans.css.gz +0 -0
  348. package/dist/index.html +2 -2
  349. package/dist/index.html.br +0 -0
  350. package/dist/index.html.gz +0 -0
  351. package/dist/sw.js.br +0 -0
  352. package/dist/sw.js.gz +0 -0
  353. package/package.json +3 -3
  354. package/shared/constants/attachments.ts +14 -0
  355. package/shared/constants/engine-tools.ts +1 -1
  356. package/shared/constants/preview.test.ts +259 -0
  357. package/shared/constants/preview.ts +1018 -57
  358. package/shared/constants/tool-icons.ts +5 -0
  359. package/shared/types/containers/container.ts +1 -1
  360. package/shared/types/database/schema.ts +9 -6
  361. package/shared/types/git-identity.ts +1 -1
  362. package/shared/types/git.ts +116 -0
  363. package/shared/types/integrations.ts +7 -0
  364. package/shared/types/stores/settings.ts +1 -1
  365. package/shared/types/unified/index.ts +1 -1
  366. package/shared/types/unified/message.ts +0 -7
  367. package/shared/types/unified/stream.ts +13 -5
  368. package/shared/types/unified/tool.ts +15 -1
  369. package/shared/utils/ask-user-question.test.ts +319 -0
  370. package/shared/utils/ask-user-question.ts +154 -0
  371. package/shared/utils/diff-calculator.test.ts +178 -41
  372. package/shared/utils/diff-calculator.ts +383 -100
  373. package/shared/utils/home-project.ts +25 -0
  374. package/shared/utils/logger.ts +2 -0
  375. package/shared/utils/process-supervisor.test.ts +172 -0
  376. package/shared/utils/process-supervisor.ts +251 -0
  377. package/shared/utils/ws-chunk.test.ts +33 -0
  378. package/shared/utils/ws-chunk.ts +73 -0
  379. package/shared/utils/ws-client-chunks.test.ts +45 -0
  380. package/shared/utils/ws-client.ts +43 -0
  381. package/shared/utils/ws-server.ts +49 -21
  382. package/backend/auth/session-invalidation.test.ts +0 -112
  383. package/backend/auth/session-invalidation.ts +0 -77
  384. package/backend/project/status-manager.test.ts +0 -32
  385. package/backend/ws/auth/invites.ts +0 -94
  386. package/backend/ws/auth/users.ts +0 -112
  387. package/backend/ws/projects/presence.ts +0 -46
  388. package/backend/ws/stack/access.ts +0 -31
  389. package/dist/assets/main-BiDNMWb3.css +0 -1
  390. package/dist/assets/main-BlhKWz2B.js +0 -1241
@@ -4,25 +4,17 @@
4
4
  * Two-phase restore:
5
5
  * 1. Check conflicts: detect files modified by other sessions
6
6
  * 2. Execute restore: undo session-scoped changes, respecting conflict resolutions
7
+ *
8
+ * The logic lives in `backend/snapshot/restore.ts` so a chat channel can go
9
+ * back to a checkpoint exactly as the web UI does; these routes only check
10
+ * access and delegate.
7
11
  */
8
12
 
9
13
  import { t } from 'elysia';
10
14
  import { createRouter } from '$shared/utils/ws-server';
11
- import { messageQueries, sessionQueries, checkpointQueries } from '../../database/queries';
12
- import { snapshotService } from '../../snapshot/snapshot-service';
13
- import { streamManager } from '../../chat/stream-manager';
14
15
  import { debug } from '$shared/utils/logger';
15
- import type { UnifiedMessage } from '$shared/types/unified';
16
- import {
17
- buildCheckpointTree,
18
- getCheckpointPathToRoot,
19
- findCheckpointForHead,
20
- findSessionEnd,
21
- INITIAL_NODE_ID
22
- } from '../../snapshot/helpers';
23
- import { ws } from '$backend/utils/ws';
16
+ import { checkSessionRestoreConflicts, restoreSessionTo } from '../../snapshot/restore';
24
17
  import { requireSessionAccess } from '../access';
25
- import { resolveSessionRoot } from '../../worktrees';
26
18
 
27
19
  export const restoreHandler = createRouter()
28
20
  /**
@@ -47,44 +39,12 @@ export const restoreHandler = createRouter()
47
39
  })),
48
40
  checkpointsToUndo: t.Array(t.String())
49
41
  })
50
- }, async ({ data, conn }) => {
42
+ }, async ({ data }) => {
51
43
  const { messageId, sessionId } = data;
52
- requireSessionAccess(conn, sessionId);
53
-
54
- debug.log('snapshot', `Checking restore conflicts for checkpoint ${messageId} in session ${sessionId}`);
55
-
56
- // Read file contents from the tree this session actually runs in —
57
- // its worktree when it has one, the project otherwise.
58
- const projectPath = resolveSessionRoot(sessionId)?.path || undefined;
59
-
60
- // Build checkpoint path for branch-aware conflict detection
61
- let targetPath: string[] | undefined;
62
- let resolvedMessageId: string | null = messageId === INITIAL_NODE_ID ? null : messageId;
63
-
64
- if (messageId !== INITIAL_NODE_ID) {
65
- const allMessages = messageQueries.getAllBySessionId(sessionId);
66
- const { checkpoints, parentMap } = buildCheckpointTree(allMessages);
67
- const checkpointIdSet = new Set(checkpoints.map(c => c.id));
68
-
69
- const resolvedId = checkpointIdSet.has(messageId)
70
- ? messageId
71
- : findCheckpointForHead(messageId, allMessages, checkpointIdSet);
72
-
73
- if (resolvedId) {
74
- resolvedMessageId = resolvedId;
75
- targetPath = getCheckpointPathToRoot(resolvedId, parentMap);
76
- }
77
- }
78
-
79
- const result = await snapshotService.checkRestoreConflicts(
80
- sessionId,
81
- resolvedMessageId,
82
- projectPath,
83
- targetPath
84
- );
44
+ requireSessionAccess(sessionId);
85
45
 
46
+ const result = await checkSessionRestoreConflicts(sessionId, messageId);
86
47
  debug.log('snapshot', `Conflict check: ${result.conflicts.length} conflicts, ${result.checkpointsToUndo.length} checkpoints to undo`);
87
-
88
48
  return result;
89
49
  })
90
50
 
@@ -108,252 +68,8 @@ export const restoreHandler = createRouter()
108
68
  filesRestored: t.Optional(t.Number()),
109
69
  filesSkipped: t.Optional(t.Number())
110
70
  })
111
- }, async ({ data, conn }) => {
71
+ }, async ({ data }) => {
112
72
  const { messageId, sessionId, conflictResolutions } = data;
113
- const session = requireSessionAccess(conn, sessionId);
114
-
115
- // Refuse to restore while this session is still generating. Restore rewrites
116
- // the working tree and resets the in-memory baseline; doing that mid-stream
117
- // would corrupt the end-of-turn snapshot and race the engine's own writes.
118
- const activeStream = streamManager.getSessionStream(sessionId, session.project_id);
119
- if (activeStream?.status === 'active') {
120
- throw new Error('Cannot restore while the chat is still generating. Stop the stream first, then try again.');
121
- }
122
-
123
- const isInitialRestore = messageId === INITIAL_NODE_ID;
124
-
125
- debug.log('snapshot', `RESTORE - ${isInitialRestore ? 'Restoring to initial state' : 'Moving HEAD to checkpoint'}`);
126
- debug.log('snapshot', `Target: ${messageId}`);
127
- debug.log('snapshot', `Session: ${sessionId}`);
128
-
129
- // Handle restore to initial state (before any messages)
130
- if (isInitialRestore) {
131
- // Clear HEAD (no messages active)
132
- sessionQueries.clearHead(sessionId);
133
- sessionQueries.rederiveHeadSnapshot(sessionId);
134
- debug.log('snapshot', 'HEAD cleared (initial state)');
135
-
136
- // Clear head_session_id so next chat starts fresh
137
- const db = (await import('../../database')).getDatabase();
138
- db.prepare(`UPDATE chat_sessions SET head_session_id = NULL WHERE id = ?`).run(sessionId);
139
-
140
- // Clear checkpoint_tree_state
141
- checkpointQueries.deleteForSession(sessionId);
142
-
143
- // Restore file system: revert ALL session changes
144
- let filesRestored = 0;
145
- let filesSkipped = 0;
146
-
147
- const sessionRoot = resolveSessionRoot(sessionId);
148
- if (sessionRoot?.path) {
149
- const result = await snapshotService.restoreSessionScoped(
150
- sessionRoot.path,
151
- sessionId,
152
- null, // null = restore to initial (before all snapshots)
153
- conflictResolutions
154
- );
155
- filesRestored = result.restoredFiles;
156
- filesSkipped = result.skippedFiles;
157
- }
158
-
159
- // Broadcast messages-changed
160
- try {
161
- ws.emit.chatSession(sessionId, 'chat:messages-changed', {
162
- sessionId,
163
- reason: 'restore',
164
- timestamp: new Date().toISOString()
165
- });
166
- } catch (err) {
167
- debug.error('snapshot', 'Failed to broadcast messages-changed:', err);
168
- }
169
-
170
- return {
171
- restoredTo: {
172
- messageId: INITIAL_NODE_ID,
173
- timestamp: new Date().toISOString()
174
- },
175
- filesRestored,
176
- filesSkipped
177
- };
178
- }
179
-
180
- // Regular checkpoint restore
181
- // 1. Get the target message
182
- const checkpointMessage = messageQueries.getById(messageId);
183
- if (!checkpointMessage) {
184
- throw new Error('Checkpoint message not found');
185
- }
186
-
187
- // 2. Get current HEAD
188
- const currentHead = sessionQueries.getHead(sessionId);
189
- debug.log('snapshot', `Current HEAD: ${currentHead}`);
190
-
191
- // 3. Get all messages and build checkpoint tree
192
- const allMessages = messageQueries.getAllBySessionId(sessionId);
193
- const { checkpoints, parentMap } = buildCheckpointTree(allMessages);
194
-
195
- // 3b. Resolve the correct checkpoint for snapshot/tree operations
196
- // The target message may be a non-checkpoint (e.g., assistant response)
197
- // when called from edit mode. Walk back to find the nearest ancestor checkpoint.
198
- const checkpointIdSet = new Set(checkpoints.map(c => c.id));
199
- const resolvedCheckpointId = checkpointIdSet.has(messageId)
200
- ? messageId
201
- : findCheckpointForHead(messageId, allMessages, checkpointIdSet);
202
-
203
- debug.log('snapshot', `Resolved checkpoint: ${resolvedCheckpointId} (target was ${messageId})`);
204
-
205
- // 4. Find session end (last message of target's session)
206
- const sessionEnd = findSessionEnd(checkpointMessage, allMessages);
207
- debug.log('snapshot', `Session end: ${sessionEnd.id}`);
208
-
209
- // 5. Update HEAD to session end
210
- sessionQueries.updateHead(sessionId, sessionEnd.id);
211
- sessionQueries.rederiveHeadSnapshot(sessionId);
212
- debug.log('snapshot', `HEAD updated to: ${sessionEnd.id}`);
213
-
214
- // 5b. Update head_session_id so resume works correctly.
215
- // Claude Code: skip cancelled fork session_ids (partial messages from cancelStream).
216
- // OpenCode: simple walk — any session_id is valid (sessions created synchronously).
217
- //
218
- // Engine is read PER MESSAGE, not from `chat_sessions.engine`: a session can
219
- // now switch engine mid-conversation, so the session column only names the
220
- // currently selected engine. Restoring into a region driven by a different
221
- // engine must apply that region's semantics, and must not adopt an SDK
222
- // session id belonging to some other engine's store.
223
- {
224
- let foundSdkSessionId: string | null = null;
225
- const msgLookup = new Map(allMessages.map(m => [m.id, m]));
226
-
227
- const engineOf = (msg: UnifiedMessage): string | null => msg.engine?.type ?? null;
228
-
229
- // The engine that owns the restored branch head — the only engine whose
230
- // session ids are meaningful for a subsequent resume.
231
- let branchEngine: string | null = null;
232
- {
233
- let probeId: string | null = sessionEnd.id;
234
- while (probeId) {
235
- const probeMsg = msgLookup.get(probeId);
236
- if (!probeMsg) break;
237
- try {
238
- const msg = JSON.parse(probeMsg.data) as UnifiedMessage;
239
- if (msg.type !== 'user') {
240
- const type = engineOf(msg);
241
- if (type) { branchEngine = type; break; }
242
- }
243
- } catch { /* skip */ }
244
- probeId = probeMsg.parent_message_id || null;
245
- }
246
- if (!branchEngine) {
247
- branchEngine = sessionQueries.getById(sessionId)?.engine ?? null;
248
- }
249
- }
250
-
251
- const isClaudeCode = branchEngine === 'claude-code';
252
-
253
- // Claude Code only: detect cancelled stream by stopReason on sessionEnd
254
- let cancelledSessionId: string | null = null;
255
- if (isClaudeCode) {
256
- try {
257
- const endMsg = msgLookup.get(sessionEnd.id);
258
- if (endMsg) {
259
- const endParsed = JSON.parse(endMsg.data) as UnifiedMessage;
260
- if (endParsed.type === 'assistant' && endParsed.stopReason === 'interrupted') {
261
- cancelledSessionId = endParsed.sessionId || null;
262
- }
263
- }
264
- } catch { /* skip */ }
265
- }
266
-
267
- let walkId: string | null = sessionEnd.id;
268
- while (walkId) {
269
- const walkMsg = msgLookup.get(walkId);
270
- if (!walkMsg) break;
271
-
272
- try {
273
- const msg = JSON.parse(walkMsg.data) as UnifiedMessage;
274
-
275
- // Claude Code only: skip interrupted messages (from cancelled streams)
276
- if (isClaudeCode && msg.type === 'assistant' && msg.stopReason === 'interrupted') {
277
- walkId = walkMsg.parent_message_id || null;
278
- continue;
279
- }
280
-
281
- // Claude Code only: skip messages from the same cancelled fork
282
- if (isClaudeCode && cancelledSessionId && msg.sessionId === cancelledSessionId) {
283
- walkId = walkMsg.parent_message_id || null;
284
- continue;
285
- }
286
-
287
- // Any engine: message with sessionId, but only from the branch's own
288
- // engine. Crossing that line would store a foreign store's id.
289
- // A message with no engine block is pre-migration: it cannot be
290
- // proven foreign, so keep the old behaviour and accept it.
291
- const msgEngine = engineOf(msg);
292
- if (msg.sessionId && (!branchEngine || !msgEngine || msgEngine === branchEngine)) {
293
- foundSdkSessionId = msg.sessionId;
294
- break;
295
- }
296
- } catch { /* skip */ }
297
-
298
- walkId = walkMsg.parent_message_id || null;
299
- }
300
-
301
- if (foundSdkSessionId) {
302
- sessionQueries.updateSessionId(sessionId, foundSdkSessionId);
303
- debug.log('snapshot', `head_session_id updated to: ${foundSdkSessionId}`);
304
- } else {
305
- sessionQueries.clearSessionId(sessionId);
306
- debug.log('snapshot', 'head_session_id cleared (no valid session found in restored chain)');
307
- }
308
- }
309
-
310
- // 6. Update checkpoint_tree_state for ancestors
311
- // Use resolved checkpoint ID (not raw messageId which may be a non-checkpoint)
312
- // Also compute checkpointPath for branch-aware file restore
313
- let checkpointPath: string[] = [];
314
- if (resolvedCheckpointId) {
315
- checkpointPath = getCheckpointPathToRoot(resolvedCheckpointId, parentMap);
316
- if (checkpointPath.length > 1) {
317
- checkpointQueries.updateActiveChildrenAlongPath(sessionId, checkpointPath);
318
- }
319
- }
320
-
321
- // 7. Restore file system state using session-scoped restore
322
- // Use resolved checkpoint ID so the snapshot lookup matches correctly
323
- // (snapshots are keyed by checkpoint user message IDs, not assistant messages)
324
- let filesRestored = 0;
325
- let filesSkipped = 0;
326
-
327
- const sessionRoot = resolveSessionRoot(sessionId);
328
- if (sessionRoot?.path) {
329
- const result = await snapshotService.restoreSessionScoped(
330
- sessionRoot.path,
331
- sessionId,
332
- resolvedCheckpointId,
333
- conflictResolutions,
334
- checkpointPath.length > 0 ? checkpointPath : undefined
335
- );
336
- filesRestored = result.restoredFiles;
337
- filesSkipped = result.skippedFiles;
338
- }
339
-
340
- // 8. Broadcast messages-changed
341
- try {
342
- ws.emit.chatSession(sessionId, 'chat:messages-changed', {
343
- sessionId,
344
- reason: 'restore',
345
- timestamp: new Date().toISOString()
346
- });
347
- } catch (err) {
348
- debug.error('snapshot', 'Failed to broadcast messages-changed:', err);
349
- }
350
-
351
- return {
352
- restoredTo: {
353
- messageId: sessionEnd.id,
354
- timestamp: sessionEnd.created_at
355
- },
356
- filesRestored,
357
- filesSkipped
358
- };
73
+ requireSessionAccess(sessionId);
74
+ return restoreSessionTo(sessionId, messageId, conflictResolutions);
359
75
  });
@@ -31,9 +31,9 @@ export const timelineHandler = createRouter()
31
31
  nodes: t.Array(t.Any()),
32
32
  currentHeadId: t.Union([t.String(), t.Null()])
33
33
  })
34
- }, async ({ data, conn }) => {
34
+ }, async ({ data }) => {
35
35
  const { sessionId } = data;
36
- requireSessionAccess(conn, sessionId);
36
+ requireSessionAccess(sessionId);
37
37
 
38
38
  debug.log('snapshot', 'TIMELINE - Building tree view');
39
39
 
@@ -114,7 +114,6 @@ export const timelineHandler = createRouter()
114
114
  isCurrent: isAtInitialState,
115
115
  hasSnapshot: false,
116
116
  isInitial: true,
117
- senderName: null,
118
117
  filesChanged: 0,
119
118
  insertions: 0,
120
119
  deletions: 0
@@ -155,7 +154,6 @@ export const timelineHandler = createRouter()
155
154
  isOrphaned,
156
155
  isCurrent,
157
156
  hasSnapshot: !!snapshot,
158
- senderName: msg.type === 'user' ? msg.sender?.name || null : null,
159
157
  filesChanged: stats.filesChanged,
160
158
  insertions: stats.insertions,
161
159
  deletions: stats.deletions
@@ -1,31 +1,16 @@
1
- import type { WSConnection } from '$shared/utils/ws-server';
2
- import { ws } from '$backend/utils/ws';
3
1
  import { sshConnectionQueries } from '../../database/queries';
4
2
  import { sshPortForwardQueries } from '../../database/queries';
5
3
  import type { SshConnection, SshForward } from '$shared/types/ssh';
6
4
 
7
- export interface SshPrincipal {
8
- userId: string;
9
- isAdmin: boolean;
5
+ /** Full connection including secrets, or an error when it does not exist. */
6
+ export function requireSshConnection(connectionId: string): SshConnection {
7
+ return sshConnectionQueries.require(connectionId);
10
8
  }
11
9
 
12
- export function getSshPrincipal(conn: WSConnection): SshPrincipal {
13
- return { userId: ws.getUserId(conn), isAdmin: ws.getRole(conn) === 'admin' };
14
- }
15
-
16
- /** Full connection including secrets, after checking the caller owns it. */
17
- export function requireSshConnection(conn: WSConnection, connectionId: string): SshConnection {
18
- const { userId, isAdmin } = getSshPrincipal(conn);
19
- return sshConnectionQueries.ensureAccess(connectionId, userId, isAdmin);
20
- }
21
-
22
- /**
23
- * A forward is reachable exactly when its connection is, so resolve the forward
24
- * and check the owner of the host it belongs to.
25
- */
26
- export function requireSshForward(conn: WSConnection, forwardId: string): SshForward {
10
+ /** A forward, after checking the host it belongs to still exists. */
11
+ export function requireSshForward(forwardId: string): SshForward {
27
12
  const forward = sshPortForwardQueries.get(forwardId);
28
13
  if (!forward) throw new Error('ssh port forward not found');
29
- requireSshConnection(conn, forward.connectionId);
14
+ requireSshConnection(forward.connectionId);
30
15
  return forward;
31
16
  }
@@ -15,7 +15,7 @@ import { killContainerSessionsForHost } from '../../containers/pty';
15
15
  import { stopLogStreamsForHost } from '../../containers/logs';
16
16
  import type { SshConnectionInput } from '$shared/types/ssh';
17
17
  import { debug } from '$shared/utils/logger';
18
- import { getSshPrincipal, requireSshConnection } from './access';
18
+ import { requireSshConnection } from './access';
19
19
 
20
20
  const authMethodSchema = t.Union([
21
21
  t.Literal('password'),
@@ -98,18 +98,16 @@ export const sshConnectionsHandler = createRouter()
98
98
  .http('ssh:list', {
99
99
  data: t.Object({}),
100
100
  response: t.Array(t.Any())
101
- }, async ({ conn }) => {
101
+ }, async () => {
102
102
  await initializeDatabase();
103
- const { userId, isAdmin } = getSshPrincipal(conn);
104
- return sshConnectionQueries.listForUser(userId, isAdmin);
103
+ return sshConnectionQueries.listRedacted();
105
104
  })
106
105
 
107
106
  .http('ssh:get', {
108
107
  data: t.Object({ id: t.String({ minLength: 1 }) }),
109
108
  response: t.Any()
110
- }, async ({ data, conn }) => {
111
- const { userId, isAdmin } = getSshPrincipal(conn);
112
- const connection = sshConnectionQueries.getForUser(data.id, userId, isAdmin);
109
+ }, async ({ data }) => {
110
+ const connection = sshConnectionQueries.getRedacted(data.id);
113
111
  if (!connection) throw new Error('ssh connection not found');
114
112
  return connection;
115
113
  })
@@ -117,10 +115,9 @@ export const sshConnectionsHandler = createRouter()
117
115
  .http('ssh:create', {
118
116
  data: connectionInputSchema,
119
117
  response: t.Any()
120
- }, async ({ data, conn }) => {
118
+ }, async ({ data }) => {
121
119
  await initializeDatabase();
122
- const { userId } = getSshPrincipal(conn);
123
- const created = sshConnectionQueries.createForUser(data as SshConnectionInput, userId);
120
+ const created = sshConnectionQueries.createRedacted(data as SshConnectionInput);
124
121
  debug.log('ssh', `created connection ${created.id} (${created.host})`);
125
122
  return created;
126
123
  })
@@ -128,39 +125,32 @@ export const sshConnectionsHandler = createRouter()
128
125
  .http('ssh:update', {
129
126
  data: t.Object({ id: t.String({ minLength: 1 }), patch: connectionPatchSchema }),
130
127
  response: t.Any()
131
- }, async ({ data, conn }) => {
132
- const { userId, isAdmin } = getSshPrincipal(conn);
133
- requireSshConnection(conn, data.id);
128
+ }, async ({ data }) => {
129
+ requireSshConnection(data.id);
134
130
  await tearDownConnection(data.id);
135
- return sshConnectionQueries.updateForUser(
136
- data.id,
137
- data.patch as Partial<SshConnectionInput>,
138
- userId,
139
- isAdmin
140
- );
131
+ return sshConnectionQueries.updateRedacted(data.id, data.patch as Partial<SshConnectionInput>);
141
132
  })
142
133
 
143
134
  .http('ssh:delete', {
144
135
  data: t.Object({ id: t.String({ minLength: 1 }) }),
145
136
  response: t.Object({ ok: t.Boolean() })
146
- }, async ({ data, conn }) => {
147
- const { userId, isAdmin } = getSshPrincipal(conn);
148
- requireSshConnection(conn, data.id);
137
+ }, async ({ data }) => {
138
+ requireSshConnection(data.id);
149
139
  await tearDownConnection(data.id);
150
- sshConnectionQueries.deleteForUser(data.id, userId, isAdmin);
140
+ sshConnectionQueries.delete(data.id);
151
141
  return { ok: true };
152
142
  })
153
143
 
154
144
  .http('ssh:test', {
155
145
  data: connectionTestSchema,
156
146
  response: healthSchema
157
- }, async ({ data, conn }) => {
147
+ }, async ({ data }) => {
158
148
  await initializeDatabase();
159
149
  if (isInput(data)) {
160
150
  return sshHealthService.testInput(data as SshConnectionInput);
161
151
  }
162
152
  const id = (data as { id: string }).id;
163
- requireSshConnection(conn, id);
153
+ requireSshConnection(id);
164
154
  return sshHealthService.testSaved(id);
165
155
  })
166
156
 
@@ -172,8 +162,8 @@ export const sshConnectionsHandler = createRouter()
172
162
  .http('ssh:activate', {
173
163
  data: t.Object({ id: t.String({ minLength: 1 }) }),
174
164
  response: healthSchema
175
- }, async ({ data, conn }) => {
176
- requireSshConnection(conn, data.id);
165
+ }, async ({ data }) => {
166
+ requireSshConnection(data.id);
177
167
  sshClientPool.resume(data.id);
178
168
  const health = await sshHealthService.testSaved(data.id);
179
169
  if (health.ok) {
@@ -190,8 +180,8 @@ export const sshConnectionsHandler = createRouter()
190
180
  .http('ssh:disconnect', {
191
181
  data: t.Object({ id: t.String({ minLength: 1 }) }),
192
182
  response: healthSchema
193
- }, async ({ data, conn }) => {
194
- requireSshConnection(conn, data.id);
183
+ }, async ({ data }) => {
184
+ requireSshConnection(data.id);
195
185
  killSessionsForConnection(data.id);
196
186
  killContainerSessionsForHost(data.id);
197
187
  stopLogStreamsForHost(data.id);
@@ -216,8 +206,8 @@ export const sshConnectionsHandler = createRouter()
216
206
  .http('ssh:trust-host-key', {
217
207
  data: t.Object({ id: t.String({ minLength: 1 }) }),
218
208
  response: healthSchema
219
- }, async ({ data, conn }) => {
220
- const connection = requireSshConnection(conn, data.id);
209
+ }, async ({ data }) => {
210
+ const connection = requireSshConnection(data.id);
221
211
  knownHosts.forget(connection.host, connection.port);
222
212
  await tearDownConnection(data.id);
223
213
  return sshHealthService.testSaved(data.id);
@@ -43,8 +43,8 @@ export const sshForwardsHandler = createRouter()
43
43
  .http('ssh:forward-list', {
44
44
  data: t.Object({ connectionId: t.String({ minLength: 1 }) }),
45
45
  response: t.Any()
46
- }, async ({ data, conn }) => {
47
- requireSshConnection(conn, data.connectionId);
46
+ }, async ({ data }) => {
47
+ requireSshConnection(data.connectionId);
48
48
  return {
49
49
  forwards: sshPortForwardQueries.listForConnection(data.connectionId),
50
50
  statuses: sshForwardManager.statusesForConnection(data.connectionId)
@@ -57,8 +57,8 @@ export const sshForwardsHandler = createRouter()
57
57
  input: forwardInputSchema
58
58
  }),
59
59
  response: t.Any()
60
- }, async ({ data, conn }) => {
61
- requireSshConnection(conn, data.connectionId);
60
+ }, async ({ data }) => {
61
+ requireSshConnection(data.connectionId);
62
62
  const input = data.input as SshForwardInput;
63
63
  requireDestination(input.type, input.destHost, input.destPort);
64
64
  return sshPortForwardQueries.create(data.connectionId, input);
@@ -67,8 +67,8 @@ export const sshForwardsHandler = createRouter()
67
67
  .http('ssh:forward-update', {
68
68
  data: t.Object({ id: t.String({ minLength: 1 }), patch: forwardPatchSchema }),
69
69
  response: t.Any()
70
- }, async ({ data, conn }) => {
71
- const existing = requireSshForward(conn, data.id);
70
+ }, async ({ data }) => {
71
+ const existing = requireSshForward(data.id);
72
72
  const patch = data.patch as Partial<SshForwardInput>;
73
73
  requireDestination(
74
74
  patch.type ?? existing.type,
@@ -84,8 +84,8 @@ export const sshForwardsHandler = createRouter()
84
84
  .http('ssh:forward-delete', {
85
85
  data: t.Object({ id: t.String({ minLength: 1 }) }),
86
86
  response: t.Object({ ok: t.Boolean() })
87
- }, async ({ data, conn }) => {
88
- requireSshForward(conn, data.id);
87
+ }, async ({ data }) => {
88
+ requireSshForward(data.id);
89
89
  await sshForwardManager.stop(data.id);
90
90
  sshPortForwardQueries.delete(data.id);
91
91
  return { ok: true };
@@ -94,16 +94,16 @@ export const sshForwardsHandler = createRouter()
94
94
  .http('ssh:forward-start', {
95
95
  data: t.Object({ id: t.String({ minLength: 1 }) }),
96
96
  response: t.Any()
97
- }, async ({ data, conn }) => {
98
- const forward = requireSshForward(conn, data.id);
97
+ }, async ({ data }) => {
98
+ const forward = requireSshForward(data.id);
99
99
  return sshForwardManager.start(forward);
100
100
  })
101
101
 
102
102
  .http('ssh:forward-stop', {
103
103
  data: t.Object({ id: t.String({ minLength: 1 }) }),
104
104
  response: t.Any()
105
- }, async ({ data, conn }) => {
106
- const forward = requireSshForward(conn, data.id);
105
+ }, async ({ data }) => {
106
+ const forward = requireSshForward(data.id);
107
107
  await sshForwardManager.stop(data.id);
108
108
  return sshForwardManager.status(forward);
109
109
  });