parasor 0.1.0

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 (633) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +208 -0
  3. package/THIRD-PARTY-NOTICES.md +138 -0
  4. package/bin/parasor.mjs +3 -0
  5. package/node_modules/@parasor/shared/dist/client.d.ts +8 -0
  6. package/node_modules/@parasor/shared/dist/client.d.ts.map +1 -0
  7. package/node_modules/@parasor/shared/dist/client.js +2 -0
  8. package/node_modules/@parasor/shared/dist/client.js.map +1 -0
  9. package/node_modules/@parasor/shared/dist/drops.d.ts +24 -0
  10. package/node_modules/@parasor/shared/dist/drops.d.ts.map +1 -0
  11. package/node_modules/@parasor/shared/dist/drops.js +2 -0
  12. package/node_modules/@parasor/shared/dist/drops.js.map +1 -0
  13. package/node_modules/@parasor/shared/dist/file-uploads.d.ts +56 -0
  14. package/node_modules/@parasor/shared/dist/file-uploads.d.ts.map +1 -0
  15. package/node_modules/@parasor/shared/dist/file-uploads.js +13 -0
  16. package/node_modules/@parasor/shared/dist/file-uploads.js.map +1 -0
  17. package/node_modules/@parasor/shared/dist/ide-commands.d.ts +8 -0
  18. package/node_modules/@parasor/shared/dist/ide-commands.d.ts.map +1 -0
  19. package/node_modules/@parasor/shared/dist/ide-commands.js +59 -0
  20. package/node_modules/@parasor/shared/dist/ide-commands.js.map +1 -0
  21. package/node_modules/@parasor/shared/dist/pane-commands.d.ts +7 -0
  22. package/node_modules/@parasor/shared/dist/pane-commands.d.ts.map +1 -0
  23. package/node_modules/@parasor/shared/dist/pane-commands.js +47 -0
  24. package/node_modules/@parasor/shared/dist/pane-commands.js.map +1 -0
  25. package/node_modules/@parasor/shared/dist/pane-model.d.ts +63 -0
  26. package/node_modules/@parasor/shared/dist/pane-model.d.ts.map +1 -0
  27. package/node_modules/@parasor/shared/dist/pane-model.js +89 -0
  28. package/node_modules/@parasor/shared/dist/pane-model.js.map +1 -0
  29. package/node_modules/@parasor/shared/dist/panes.d.ts +33 -0
  30. package/node_modules/@parasor/shared/dist/panes.d.ts.map +1 -0
  31. package/node_modules/@parasor/shared/dist/panes.js +2 -0
  32. package/node_modules/@parasor/shared/dist/panes.js.map +1 -0
  33. package/node_modules/@parasor/shared/dist/runtime.d.ts +180 -0
  34. package/node_modules/@parasor/shared/dist/runtime.d.ts.map +1 -0
  35. package/node_modules/@parasor/shared/dist/runtime.js +2 -0
  36. package/node_modules/@parasor/shared/dist/runtime.js.map +1 -0
  37. package/node_modules/@parasor/shared/dist/state.d.ts +192 -0
  38. package/node_modules/@parasor/shared/dist/state.d.ts.map +1 -0
  39. package/node_modules/@parasor/shared/dist/state.js +10 -0
  40. package/node_modules/@parasor/shared/dist/state.js.map +1 -0
  41. package/node_modules/@parasor/shared/dist/terminal.d.ts +191 -0
  42. package/node_modules/@parasor/shared/dist/terminal.d.ts.map +1 -0
  43. package/node_modules/@parasor/shared/dist/terminal.js +174 -0
  44. package/node_modules/@parasor/shared/dist/terminal.js.map +1 -0
  45. package/node_modules/@parasor/shared/dist/types.d.ts +13 -0
  46. package/node_modules/@parasor/shared/dist/types.d.ts.map +1 -0
  47. package/node_modules/@parasor/shared/dist/types.js +13 -0
  48. package/node_modules/@parasor/shared/dist/types.js.map +1 -0
  49. package/node_modules/@parasor/shared/dist/worktree-local-files.d.ts +14 -0
  50. package/node_modules/@parasor/shared/dist/worktree-local-files.d.ts.map +1 -0
  51. package/node_modules/@parasor/shared/dist/worktree-local-files.js +41 -0
  52. package/node_modules/@parasor/shared/dist/worktree-local-files.js.map +1 -0
  53. package/node_modules/@parasor/shared/dist/ws-events.d.ts +152 -0
  54. package/node_modules/@parasor/shared/dist/ws-events.d.ts.map +1 -0
  55. package/node_modules/@parasor/shared/dist/ws-events.js +2 -0
  56. package/node_modules/@parasor/shared/dist/ws-events.js.map +1 -0
  57. package/node_modules/@parasor/shared/package.json +13 -0
  58. package/package.json +61 -0
  59. package/server/agent-detector/agent-state-store.d.ts +23 -0
  60. package/server/agent-detector/agent-state-store.d.ts.map +1 -0
  61. package/server/agent-detector/agent-state-store.js +110 -0
  62. package/server/agent-detector/agent-state-store.js.map +1 -0
  63. package/server/agent-detector/detector.d.ts +80 -0
  64. package/server/agent-detector/detector.d.ts.map +1 -0
  65. package/server/agent-detector/detector.js +219 -0
  66. package/server/agent-detector/detector.js.map +1 -0
  67. package/server/agent-detector/event-map.d.ts +25 -0
  68. package/server/agent-detector/event-map.d.ts.map +1 -0
  69. package/server/agent-detector/event-map.js +136 -0
  70. package/server/agent-detector/event-map.js.map +1 -0
  71. package/server/agent-detector/manual-agent-tracker.d.ts +19 -0
  72. package/server/agent-detector/manual-agent-tracker.d.ts.map +1 -0
  73. package/server/agent-detector/manual-agent-tracker.js +123 -0
  74. package/server/agent-detector/manual-agent-tracker.js.map +1 -0
  75. package/server/agent-detector/output-eligibility.d.ts +3 -0
  76. package/server/agent-detector/output-eligibility.d.ts.map +1 -0
  77. package/server/agent-detector/output-eligibility.js +39 -0
  78. package/server/agent-detector/output-eligibility.js.map +1 -0
  79. package/server/application/files/errors.d.ts +28 -0
  80. package/server/application/files/errors.d.ts.map +1 -0
  81. package/server/application/files/errors.js +55 -0
  82. package/server/application/files/errors.js.map +1 -0
  83. package/server/application/files/local-filesystem.d.ts +36 -0
  84. package/server/application/files/local-filesystem.d.ts.map +1 -0
  85. package/server/application/files/local-filesystem.js +171 -0
  86. package/server/application/files/local-filesystem.js.map +1 -0
  87. package/server/application/files/project-file-queries.d.ts +16 -0
  88. package/server/application/files/project-file-queries.d.ts.map +1 -0
  89. package/server/application/files/project-file-queries.js +126 -0
  90. package/server/application/files/project-file-queries.js.map +1 -0
  91. package/server/application/integrations/errors.d.ts +16 -0
  92. package/server/application/integrations/errors.d.ts.map +1 -0
  93. package/server/application/integrations/errors.js +31 -0
  94. package/server/application/integrations/errors.js.map +1 -0
  95. package/server/application/integrations/hook-notify.d.ts +32 -0
  96. package/server/application/integrations/hook-notify.d.ts.map +1 -0
  97. package/server/application/integrations/hook-notify.js +118 -0
  98. package/server/application/integrations/hook-notify.js.map +1 -0
  99. package/server/application/integrations/open-url.d.ts +11 -0
  100. package/server/application/integrations/open-url.d.ts.map +1 -0
  101. package/server/application/integrations/open-url.js +23 -0
  102. package/server/application/integrations/open-url.js.map +1 -0
  103. package/server/application/ports.d.ts +11 -0
  104. package/server/application/ports.d.ts.map +1 -0
  105. package/server/application/ports.js +2 -0
  106. package/server/application/ports.js.map +1 -0
  107. package/server/application/workspace/errors.d.ts +21 -0
  108. package/server/application/workspace/errors.d.ts.map +1 -0
  109. package/server/application/workspace/errors.js +21 -0
  110. package/server/application/workspace/errors.js.map +1 -0
  111. package/server/application/workspace/pane-commands.d.ts +47 -0
  112. package/server/application/workspace/pane-commands.d.ts.map +1 -0
  113. package/server/application/workspace/pane-commands.js +193 -0
  114. package/server/application/workspace/pane-commands.js.map +1 -0
  115. package/server/application/workspace/project-commands.d.ts +34 -0
  116. package/server/application/workspace/project-commands.d.ts.map +1 -0
  117. package/server/application/workspace/project-commands.js +81 -0
  118. package/server/application/workspace/project-commands.js.map +1 -0
  119. package/server/application/workspace/project-queries.d.ts +21 -0
  120. package/server/application/workspace/project-queries.d.ts.map +1 -0
  121. package/server/application/workspace/project-queries.js +216 -0
  122. package/server/application/workspace/project-queries.js.map +1 -0
  123. package/server/application/workspace/session-commands.d.ts +24 -0
  124. package/server/application/workspace/session-commands.d.ts.map +1 -0
  125. package/server/application/workspace/session-commands.js +123 -0
  126. package/server/application/workspace/session-commands.js.map +1 -0
  127. package/server/application/workspace/session-queries.d.ts +14 -0
  128. package/server/application/workspace/session-queries.d.ts.map +1 -0
  129. package/server/application/workspace/session-queries.js +47 -0
  130. package/server/application/workspace/session-queries.js.map +1 -0
  131. package/server/application/workspace/worktree-commands.d.ts +98 -0
  132. package/server/application/workspace/worktree-commands.d.ts.map +1 -0
  133. package/server/application/workspace/worktree-commands.js +323 -0
  134. package/server/application/workspace/worktree-commands.js.map +1 -0
  135. package/server/application/workspace/worktree-local-files.d.ts +11 -0
  136. package/server/application/workspace/worktree-local-files.d.ts.map +1 -0
  137. package/server/application/workspace/worktree-local-files.js +223 -0
  138. package/server/application/workspace/worktree-local-files.js.map +1 -0
  139. package/server/application/workspace/worktree-reconcile.d.ts +21 -0
  140. package/server/application/workspace/worktree-reconcile.d.ts.map +1 -0
  141. package/server/application/workspace/worktree-reconcile.js +49 -0
  142. package/server/application/workspace/worktree-reconcile.js.map +1 -0
  143. package/server/auth/origin.d.ts +17 -0
  144. package/server/auth/origin.d.ts.map +1 -0
  145. package/server/auth/origin.js +93 -0
  146. package/server/auth/origin.js.map +1 -0
  147. package/server/auth/pairing-token.d.ts +28 -0
  148. package/server/auth/pairing-token.d.ts.map +1 -0
  149. package/server/auth/pairing-token.js +46 -0
  150. package/server/auth/pairing-token.js.map +1 -0
  151. package/server/auth/token-exchange.d.ts +11 -0
  152. package/server/auth/token-exchange.d.ts.map +1 -0
  153. package/server/auth/token-exchange.js +27 -0
  154. package/server/auth/token-exchange.js.map +1 -0
  155. package/server/auth/token.d.ts +18 -0
  156. package/server/auth/token.d.ts.map +1 -0
  157. package/server/auth/token.js +115 -0
  158. package/server/auth/token.js.map +1 -0
  159. package/server/bootstrap/create-app-server.d.ts +49 -0
  160. package/server/bootstrap/create-app-server.d.ts.map +1 -0
  161. package/server/bootstrap/create-app-server.js +154 -0
  162. package/server/bootstrap/create-app-server.js.map +1 -0
  163. package/server/bootstrap/project-runtime.d.ts +29 -0
  164. package/server/bootstrap/project-runtime.d.ts.map +1 -0
  165. package/server/bootstrap/project-runtime.js +253 -0
  166. package/server/bootstrap/project-runtime.js.map +1 -0
  167. package/server/bootstrap/pty-env.d.ts +3 -0
  168. package/server/bootstrap/pty-env.d.ts.map +1 -0
  169. package/server/bootstrap/pty-env.js +15 -0
  170. package/server/bootstrap/pty-env.js.map +1 -0
  171. package/server/bootstrap/reconcile-state.d.ts +16 -0
  172. package/server/bootstrap/reconcile-state.d.ts.map +1 -0
  173. package/server/bootstrap/reconcile-state.js +73 -0
  174. package/server/bootstrap/reconcile-state.js.map +1 -0
  175. package/server/bootstrap/runtime-loops.d.ts +51 -0
  176. package/server/bootstrap/runtime-loops.d.ts.map +1 -0
  177. package/server/bootstrap/runtime-loops.js +189 -0
  178. package/server/bootstrap/runtime-loops.js.map +1 -0
  179. package/server/bootstrap/runtime-port.d.ts +4 -0
  180. package/server/bootstrap/runtime-port.d.ts.map +1 -0
  181. package/server/bootstrap/runtime-port.js +52 -0
  182. package/server/bootstrap/runtime-port.js.map +1 -0
  183. package/server/bootstrap/safety-gate.d.ts +22 -0
  184. package/server/bootstrap/safety-gate.d.ts.map +1 -0
  185. package/server/bootstrap/safety-gate.js +43 -0
  186. package/server/bootstrap/safety-gate.js.map +1 -0
  187. package/server/bootstrap/shutdown-marker.d.ts +35 -0
  188. package/server/bootstrap/shutdown-marker.d.ts.map +1 -0
  189. package/server/bootstrap/shutdown-marker.js +100 -0
  190. package/server/bootstrap/shutdown-marker.js.map +1 -0
  191. package/server/bootstrap/shutdown-runtime.d.ts +62 -0
  192. package/server/bootstrap/shutdown-runtime.d.ts.map +1 -0
  193. package/server/bootstrap/shutdown-runtime.js +66 -0
  194. package/server/bootstrap/shutdown-runtime.js.map +1 -0
  195. package/server/bootstrap/startup-banner.d.ts +34 -0
  196. package/server/bootstrap/startup-banner.d.ts.map +1 -0
  197. package/server/bootstrap/startup-banner.js +114 -0
  198. package/server/bootstrap/startup-banner.js.map +1 -0
  199. package/server/bootstrap/wire-runtime.d.ts +42 -0
  200. package/server/bootstrap/wire-runtime.d.ts.map +1 -0
  201. package/server/bootstrap/wire-runtime.js +205 -0
  202. package/server/bootstrap/wire-runtime.js.map +1 -0
  203. package/server/cli/help.d.ts +3 -0
  204. package/server/cli/help.d.ts.map +1 -0
  205. package/server/cli/help.js +39 -0
  206. package/server/cli/help.js.map +1 -0
  207. package/server/cli/hook-client.d.ts +12 -0
  208. package/server/cli/hook-client.d.ts.map +1 -0
  209. package/server/cli/hook-client.js +81 -0
  210. package/server/cli/hook-client.js.map +1 -0
  211. package/server/cli/hook.d.ts +3 -0
  212. package/server/cli/hook.d.ts.map +1 -0
  213. package/server/cli/hook.js +152 -0
  214. package/server/cli/hook.js.map +1 -0
  215. package/server/cli/main.d.ts +2 -0
  216. package/server/cli/main.d.ts.map +1 -0
  217. package/server/cli/main.js +133 -0
  218. package/server/cli/main.js.map +1 -0
  219. package/server/cli/notify.d.ts +19 -0
  220. package/server/cli/notify.d.ts.map +1 -0
  221. package/server/cli/notify.js +77 -0
  222. package/server/cli/notify.js.map +1 -0
  223. package/server/cli/open.d.ts +2 -0
  224. package/server/cli/open.d.ts.map +1 -0
  225. package/server/cli/open.js +47 -0
  226. package/server/cli/open.js.map +1 -0
  227. package/server/cli/probe-daemon-version.d.ts +46 -0
  228. package/server/cli/probe-daemon-version.d.ts.map +1 -0
  229. package/server/cli/probe-daemon-version.js +167 -0
  230. package/server/cli/probe-daemon-version.js.map +1 -0
  231. package/server/cli/pty-host.d.ts +36 -0
  232. package/server/cli/pty-host.d.ts.map +1 -0
  233. package/server/cli/pty-host.js +390 -0
  234. package/server/cli/pty-host.js.map +1 -0
  235. package/server/cli/qr.d.ts +2 -0
  236. package/server/cli/qr.d.ts.map +1 -0
  237. package/server/cli/qr.js +70 -0
  238. package/server/cli/qr.js.map +1 -0
  239. package/server/cli/restart-confirm.d.ts +33 -0
  240. package/server/cli/restart-confirm.d.ts.map +1 -0
  241. package/server/cli/restart-confirm.js +107 -0
  242. package/server/cli/restart-confirm.js.map +1 -0
  243. package/server/cli/restart.d.ts +17 -0
  244. package/server/cli/restart.d.ts.map +1 -0
  245. package/server/cli/restart.js +145 -0
  246. package/server/cli/restart.js.map +1 -0
  247. package/server/cli/service-darwin.d.ts +70 -0
  248. package/server/cli/service-darwin.d.ts.map +1 -0
  249. package/server/cli/service-darwin.js +562 -0
  250. package/server/cli/service-darwin.js.map +1 -0
  251. package/server/cli/service-linux.d.ts +81 -0
  252. package/server/cli/service-linux.d.ts.map +1 -0
  253. package/server/cli/service-linux.js +412 -0
  254. package/server/cli/service-linux.js.map +1 -0
  255. package/server/cli/service.d.ts +33 -0
  256. package/server/cli/service.d.ts.map +1 -0
  257. package/server/cli/service.js +133 -0
  258. package/server/cli/service.js.map +1 -0
  259. package/server/cli/shim-installer.d.ts +35 -0
  260. package/server/cli/shim-installer.d.ts.map +1 -0
  261. package/server/cli/shim-installer.js +662 -0
  262. package/server/cli/shim-installer.js.map +1 -0
  263. package/server/cli/shim-open.d.ts +2 -0
  264. package/server/cli/shim-open.d.ts.map +1 -0
  265. package/server/cli/shim-open.js +128 -0
  266. package/server/cli/shim-open.js.map +1 -0
  267. package/server/cli/shutdown-deps.d.ts +41 -0
  268. package/server/cli/shutdown-deps.d.ts.map +1 -0
  269. package/server/cli/shutdown-deps.js +158 -0
  270. package/server/cli/shutdown-deps.js.map +1 -0
  271. package/server/cli/stop.d.ts +11 -0
  272. package/server/cli/stop.d.ts.map +1 -0
  273. package/server/cli/stop.js +123 -0
  274. package/server/cli/stop.js.map +1 -0
  275. package/server/cli/unknown-command.d.ts +8 -0
  276. package/server/cli/unknown-command.d.ts.map +1 -0
  277. package/server/cli/unknown-command.js +14 -0
  278. package/server/cli/unknown-command.js.map +1 -0
  279. package/server/debug/agent-status-recorder.d.ts +57 -0
  280. package/server/debug/agent-status-recorder.d.ts.map +1 -0
  281. package/server/debug/agent-status-recorder.js +209 -0
  282. package/server/debug/agent-status-recorder.js.map +1 -0
  283. package/server/debug/terminal-trace-recorder.d.ts +41 -0
  284. package/server/debug/terminal-trace-recorder.d.ts.map +1 -0
  285. package/server/debug/terminal-trace-recorder.js +112 -0
  286. package/server/debug/terminal-trace-recorder.js.map +1 -0
  287. package/server/fonts/catalog.d.ts +35 -0
  288. package/server/fonts/catalog.d.ts.map +1 -0
  289. package/server/fonts/catalog.js +76 -0
  290. package/server/fonts/catalog.js.map +1 -0
  291. package/server/fonts/installer.d.ts +45 -0
  292. package/server/fonts/installer.d.ts.map +1 -0
  293. package/server/fonts/installer.js +201 -0
  294. package/server/fonts/installer.js.map +1 -0
  295. package/server/fonts/routes.d.ts +4 -0
  296. package/server/fonts/routes.d.ts.map +1 -0
  297. package/server/fonts/routes.js +91 -0
  298. package/server/fonts/routes.js.map +1 -0
  299. package/server/fs/drops.d.ts +50 -0
  300. package/server/fs/drops.d.ts.map +1 -0
  301. package/server/fs/drops.js +137 -0
  302. package/server/fs/drops.js.map +1 -0
  303. package/server/fs/file-uploads.d.ts +57 -0
  304. package/server/fs/file-uploads.d.ts.map +1 -0
  305. package/server/fs/file-uploads.js +214 -0
  306. package/server/fs/file-uploads.js.map +1 -0
  307. package/server/fs/file-watcher.d.ts +22 -0
  308. package/server/fs/file-watcher.d.ts.map +1 -0
  309. package/server/fs/file-watcher.js +105 -0
  310. package/server/fs/file-watcher.js.map +1 -0
  311. package/server/fs/git-watcher.d.ts +76 -0
  312. package/server/fs/git-watcher.d.ts.map +1 -0
  313. package/server/fs/git-watcher.js +356 -0
  314. package/server/fs/git-watcher.js.map +1 -0
  315. package/server/fs/media.d.ts +35 -0
  316. package/server/fs/media.d.ts.map +1 -0
  317. package/server/fs/media.js +271 -0
  318. package/server/fs/media.js.map +1 -0
  319. package/server/fs/service.d.ts +97 -0
  320. package/server/fs/service.d.ts.map +1 -0
  321. package/server/fs/service.js +306 -0
  322. package/server/fs/service.js.map +1 -0
  323. package/server/fs/upload-staging.d.ts +76 -0
  324. package/server/fs/upload-staging.d.ts.map +1 -0
  325. package/server/fs/upload-staging.js +283 -0
  326. package/server/fs/upload-staging.js.map +1 -0
  327. package/server/fs/watcher-lifecycle.d.ts +24 -0
  328. package/server/fs/watcher-lifecycle.d.ts.map +1 -0
  329. package/server/fs/watcher-lifecycle.js +105 -0
  330. package/server/fs/watcher-lifecycle.js.map +1 -0
  331. package/server/index.d.ts +17 -0
  332. package/server/index.d.ts.map +1 -0
  333. package/server/index.js +510 -0
  334. package/server/index.js.map +1 -0
  335. package/server/ipc/socket-server.d.ts +28 -0
  336. package/server/ipc/socket-server.d.ts.map +1 -0
  337. package/server/ipc/socket-server.js +206 -0
  338. package/server/ipc/socket-server.js.map +1 -0
  339. package/server/lib/git-exec.d.ts +38 -0
  340. package/server/lib/git-exec.d.ts.map +1 -0
  341. package/server/lib/git-exec.js +96 -0
  342. package/server/lib/git-exec.js.map +1 -0
  343. package/server/lib/open-in-ide.d.ts +22 -0
  344. package/server/lib/open-in-ide.d.ts.map +1 -0
  345. package/server/lib/open-in-ide.js +90 -0
  346. package/server/lib/open-in-ide.js.map +1 -0
  347. package/server/lib/open-in-os.d.ts +20 -0
  348. package/server/lib/open-in-os.d.ts.map +1 -0
  349. package/server/lib/open-in-os.js +51 -0
  350. package/server/lib/open-in-os.js.map +1 -0
  351. package/server/lib/path.d.ts +2 -0
  352. package/server/lib/path.d.ts.map +1 -0
  353. package/server/lib/path.js +10 -0
  354. package/server/lib/path.js.map +1 -0
  355. package/server/lib/promise-mutex.d.ts +7 -0
  356. package/server/lib/promise-mutex.d.ts.map +1 -0
  357. package/server/lib/promise-mutex.js +26 -0
  358. package/server/lib/promise-mutex.js.map +1 -0
  359. package/server/lib/sd-notify.d.ts +8 -0
  360. package/server/lib/sd-notify.d.ts.map +1 -0
  361. package/server/lib/sd-notify.js +27 -0
  362. package/server/lib/sd-notify.js.map +1 -0
  363. package/server/net/local-machine.d.ts +7 -0
  364. package/server/net/local-machine.d.ts.map +1 -0
  365. package/server/net/local-machine.js +79 -0
  366. package/server/net/local-machine.js.map +1 -0
  367. package/server/net/reachable-host.d.ts +12 -0
  368. package/server/net/reachable-host.d.ts.map +1 -0
  369. package/server/net/reachable-host.js +25 -0
  370. package/server/net/reachable-host.js.map +1 -0
  371. package/server/network/endpoints.d.ts +14 -0
  372. package/server/network/endpoints.d.ts.map +1 -0
  373. package/server/network/endpoints.js +104 -0
  374. package/server/network/endpoints.js.map +1 -0
  375. package/server/network/qr.d.ts +16 -0
  376. package/server/network/qr.d.ts.map +1 -0
  377. package/server/network/qr.js +89 -0
  378. package/server/network/qr.js.map +1 -0
  379. package/server/port-forwarder/forwarder.d.ts +47 -0
  380. package/server/port-forwarder/forwarder.d.ts.map +1 -0
  381. package/server/port-forwarder/forwarder.js +159 -0
  382. package/server/port-forwarder/forwarder.js.map +1 -0
  383. package/server/port-scanner/scanner.d.ts +24 -0
  384. package/server/port-scanner/scanner.d.ts.map +1 -0
  385. package/server/port-scanner/scanner.js +193 -0
  386. package/server/port-scanner/scanner.js.map +1 -0
  387. package/server/pty/connection-lifecycle.d.ts +50 -0
  388. package/server/pty/connection-lifecycle.d.ts.map +1 -0
  389. package/server/pty/connection-lifecycle.js +113 -0
  390. package/server/pty/connection-lifecycle.js.map +1 -0
  391. package/server/pty/daemon-connect.d.ts +52 -0
  392. package/server/pty/daemon-connect.d.ts.map +1 -0
  393. package/server/pty/daemon-connect.js +62 -0
  394. package/server/pty/daemon-connect.js.map +1 -0
  395. package/server/pty/handshake-timeout-race.d.ts +22 -0
  396. package/server/pty/handshake-timeout-race.d.ts.map +1 -0
  397. package/server/pty/handshake-timeout-race.js +23 -0
  398. package/server/pty/handshake-timeout-race.js.map +1 -0
  399. package/server/pty/headless-replay-snapshot.d.ts +28 -0
  400. package/server/pty/headless-replay-snapshot.d.ts.map +1 -0
  401. package/server/pty/headless-replay-snapshot.js +285 -0
  402. package/server/pty/headless-replay-snapshot.js.map +1 -0
  403. package/server/pty/headless-terminal-state-cache.d.ts +31 -0
  404. package/server/pty/headless-terminal-state-cache.d.ts.map +1 -0
  405. package/server/pty/headless-terminal-state-cache.js +119 -0
  406. package/server/pty/headless-terminal-state-cache.js.map +1 -0
  407. package/server/pty/hello-ack-validator.d.ts +15 -0
  408. package/server/pty/hello-ack-validator.d.ts.map +1 -0
  409. package/server/pty/hello-ack-validator.js +30 -0
  410. package/server/pty/hello-ack-validator.js.map +1 -0
  411. package/server/pty/host-daemon/bootstrap.d.ts +100 -0
  412. package/server/pty/host-daemon/bootstrap.d.ts.map +1 -0
  413. package/server/pty/host-daemon/bootstrap.js +611 -0
  414. package/server/pty/host-daemon/bootstrap.js.map +1 -0
  415. package/server/pty/host-daemon/daemon.d.ts +111 -0
  416. package/server/pty/host-daemon/daemon.d.ts.map +1 -0
  417. package/server/pty/host-daemon/daemon.js +648 -0
  418. package/server/pty/host-daemon/daemon.js.map +1 -0
  419. package/server/pty/host-daemon/entry.d.ts +3 -0
  420. package/server/pty/host-daemon/entry.d.ts.map +1 -0
  421. package/server/pty/host-daemon/entry.js +72 -0
  422. package/server/pty/host-daemon/entry.js.map +1 -0
  423. package/server/pty/host-daemon/lockfile.d.ts +12 -0
  424. package/server/pty/host-daemon/lockfile.d.ts.map +1 -0
  425. package/server/pty/host-daemon/lockfile.js +120 -0
  426. package/server/pty/host-daemon/lockfile.js.map +1 -0
  427. package/server/pty/host-daemon/mode-marker.d.ts +77 -0
  428. package/server/pty/host-daemon/mode-marker.d.ts.map +1 -0
  429. package/server/pty/host-daemon/mode-marker.js +228 -0
  430. package/server/pty/host-daemon/mode-marker.js.map +1 -0
  431. package/server/pty/host-daemon/orphan-cleanup.d.ts +42 -0
  432. package/server/pty/host-daemon/orphan-cleanup.d.ts.map +1 -0
  433. package/server/pty/host-daemon/orphan-cleanup.js +84 -0
  434. package/server/pty/host-daemon/orphan-cleanup.js.map +1 -0
  435. package/server/pty/host-daemon/paths.d.ts +10 -0
  436. package/server/pty/host-daemon/paths.d.ts.map +1 -0
  437. package/server/pty/host-daemon/paths.js +56 -0
  438. package/server/pty/host-daemon/paths.js.map +1 -0
  439. package/server/pty/host-daemon/server-connection.d.ts +44 -0
  440. package/server/pty/host-daemon/server-connection.d.ts.map +1 -0
  441. package/server/pty/host-daemon/server-connection.js +100 -0
  442. package/server/pty/host-daemon/server-connection.js.map +1 -0
  443. package/server/pty/host-daemon/service-detection.d.ts +24 -0
  444. package/server/pty/host-daemon/service-detection.d.ts.map +1 -0
  445. package/server/pty/host-daemon/service-detection.js +16 -0
  446. package/server/pty/host-daemon/service-detection.js.map +1 -0
  447. package/server/pty/host-daemon/socket-ready.d.ts +22 -0
  448. package/server/pty/host-daemon/socket-ready.d.ts.map +1 -0
  449. package/server/pty/host-daemon/socket-ready.js +33 -0
  450. package/server/pty/host-daemon/socket-ready.js.map +1 -0
  451. package/server/pty/host-daemon/spawn-daemon.d.ts +45 -0
  452. package/server/pty/host-daemon/spawn-daemon.d.ts.map +1 -0
  453. package/server/pty/host-daemon/spawn-daemon.js +155 -0
  454. package/server/pty/host-daemon/spawn-daemon.js.map +1 -0
  455. package/server/pty/host-daemon/terminate-daemon.d.ts +16 -0
  456. package/server/pty/host-daemon/terminate-daemon.d.ts.map +1 -0
  457. package/server/pty/host-daemon/terminate-daemon.js +128 -0
  458. package/server/pty/host-daemon/terminate-daemon.js.map +1 -0
  459. package/server/pty/host-protocol/frames.d.ts +110 -0
  460. package/server/pty/host-protocol/frames.d.ts.map +1 -0
  461. package/server/pty/host-protocol/frames.js +255 -0
  462. package/server/pty/host-protocol/frames.js.map +1 -0
  463. package/server/pty/host-protocol/messages.d.ts +140 -0
  464. package/server/pty/host-protocol/messages.d.ts.map +1 -0
  465. package/server/pty/host-protocol/messages.js +117 -0
  466. package/server/pty/host-protocol/messages.js.map +1 -0
  467. package/server/pty/host.d.ts +273 -0
  468. package/server/pty/host.d.ts.map +1 -0
  469. package/server/pty/host.js +184 -0
  470. package/server/pty/host.js.map +1 -0
  471. package/server/pty/in-process-host.d.ts +224 -0
  472. package/server/pty/in-process-host.d.ts.map +1 -0
  473. package/server/pty/in-process-host.js +1183 -0
  474. package/server/pty/in-process-host.js.map +1 -0
  475. package/server/pty/osc7-lifecycle.d.ts +8 -0
  476. package/server/pty/osc7-lifecycle.d.ts.map +1 -0
  477. package/server/pty/osc7-lifecycle.js +22 -0
  478. package/server/pty/osc7-lifecycle.js.map +1 -0
  479. package/server/pty/osc7-parser.d.ts +23 -0
  480. package/server/pty/osc7-parser.d.ts.map +1 -0
  481. package/server/pty/osc7-parser.js +91 -0
  482. package/server/pty/osc7-parser.js.map +1 -0
  483. package/server/pty/remote-host.d.ts +188 -0
  484. package/server/pty/remote-host.d.ts.map +1 -0
  485. package/server/pty/remote-host.js +810 -0
  486. package/server/pty/remote-host.js.map +1 -0
  487. package/server/pty/request-correlator.d.ts +59 -0
  488. package/server/pty/request-correlator.d.ts.map +1 -0
  489. package/server/pty/request-correlator.js +75 -0
  490. package/server/pty/request-correlator.js.map +1 -0
  491. package/server/pty/scrollback-log.d.ts +130 -0
  492. package/server/pty/scrollback-log.d.ts.map +1 -0
  493. package/server/pty/scrollback-log.js +344 -0
  494. package/server/pty/scrollback-log.js.map +1 -0
  495. package/server/pty/scrollback-sanitize.d.ts +2 -0
  496. package/server/pty/scrollback-sanitize.d.ts.map +1 -0
  497. package/server/pty/scrollback-sanitize.js +54 -0
  498. package/server/pty/scrollback-sanitize.js.map +1 -0
  499. package/server/pty/session-mirror.d.ts +67 -0
  500. package/server/pty/session-mirror.d.ts.map +1 -0
  501. package/server/pty/session-mirror.js +112 -0
  502. package/server/pty/session-mirror.js.map +1 -0
  503. package/server/pty/session-policy.d.ts +85 -0
  504. package/server/pty/session-policy.d.ts.map +1 -0
  505. package/server/pty/session-policy.js +186 -0
  506. package/server/pty/session-policy.js.map +1 -0
  507. package/server/pty/version-mismatch-recovery.d.ts +71 -0
  508. package/server/pty/version-mismatch-recovery.d.ts.map +1 -0
  509. package/server/pty/version-mismatch-recovery.js +63 -0
  510. package/server/pty/version-mismatch-recovery.js.map +1 -0
  511. package/server/routes/debug-agent-status.d.ts +5 -0
  512. package/server/routes/debug-agent-status.d.ts.map +1 -0
  513. package/server/routes/debug-agent-status.js +22 -0
  514. package/server/routes/debug-agent-status.js.map +1 -0
  515. package/server/routes/debug-diagnostics.d.ts +8 -0
  516. package/server/routes/debug-diagnostics.d.ts.map +1 -0
  517. package/server/routes/debug-diagnostics.js +34 -0
  518. package/server/routes/debug-diagnostics.js.map +1 -0
  519. package/server/routes/debug-terminal-trace.d.ts +16 -0
  520. package/server/routes/debug-terminal-trace.d.ts.map +1 -0
  521. package/server/routes/debug-terminal-trace.js +545 -0
  522. package/server/routes/debug-terminal-trace.js.map +1 -0
  523. package/server/routes/drops.d.ts +13 -0
  524. package/server/routes/drops.d.ts.map +1 -0
  525. package/server/routes/drops.js +126 -0
  526. package/server/routes/drops.js.map +1 -0
  527. package/server/routes/file-uploads.d.ts +9 -0
  528. package/server/routes/file-uploads.d.ts.map +1 -0
  529. package/server/routes/file-uploads.js +119 -0
  530. package/server/routes/file-uploads.js.map +1 -0
  531. package/server/routes/files.d.ts +9 -0
  532. package/server/routes/files.d.ts.map +1 -0
  533. package/server/routes/files.js +441 -0
  534. package/server/routes/files.js.map +1 -0
  535. package/server/routes/filesystem.d.ts +6 -0
  536. package/server/routes/filesystem.d.ts.map +1 -0
  537. package/server/routes/filesystem.js +76 -0
  538. package/server/routes/filesystem.js.map +1 -0
  539. package/server/routes/git.d.ts +38 -0
  540. package/server/routes/git.d.ts.map +1 -0
  541. package/server/routes/git.js +585 -0
  542. package/server/routes/git.js.map +1 -0
  543. package/server/routes/healthz.d.ts +8 -0
  544. package/server/routes/healthz.d.ts.map +1 -0
  545. package/server/routes/healthz.js +24 -0
  546. package/server/routes/healthz.js.map +1 -0
  547. package/server/routes/hook.d.ts +14 -0
  548. package/server/routes/hook.d.ts.map +1 -0
  549. package/server/routes/hook.js +86 -0
  550. package/server/routes/hook.js.map +1 -0
  551. package/server/routes/ide-commands.d.ts +9 -0
  552. package/server/routes/ide-commands.d.ts.map +1 -0
  553. package/server/routes/ide-commands.js +23 -0
  554. package/server/routes/ide-commands.js.map +1 -0
  555. package/server/routes/lib/resolve-worktree.d.ts +30 -0
  556. package/server/routes/lib/resolve-worktree.d.ts.map +1 -0
  557. package/server/routes/lib/resolve-worktree.js +35 -0
  558. package/server/routes/lib/resolve-worktree.js.map +1 -0
  559. package/server/routes/open.d.ts +4 -0
  560. package/server/routes/open.d.ts.map +1 -0
  561. package/server/routes/open.js +21 -0
  562. package/server/routes/open.js.map +1 -0
  563. package/server/routes/pane-commands.d.ts +9 -0
  564. package/server/routes/pane-commands.d.ts.map +1 -0
  565. package/server/routes/pane-commands.js +23 -0
  566. package/server/routes/pane-commands.js.map +1 -0
  567. package/server/routes/projects.d.ts +15 -0
  568. package/server/routes/projects.d.ts.map +1 -0
  569. package/server/routes/projects.js +363 -0
  570. package/server/routes/projects.js.map +1 -0
  571. package/server/routes/server-notices.d.ts +4 -0
  572. package/server/routes/server-notices.d.ts.map +1 -0
  573. package/server/routes/server-notices.js +29 -0
  574. package/server/routes/server-notices.js.map +1 -0
  575. package/server/routes/service-config.d.ts +11 -0
  576. package/server/routes/service-config.d.ts.map +1 -0
  577. package/server/routes/service-config.js +64 -0
  578. package/server/routes/service-config.js.map +1 -0
  579. package/server/routes/sessions.d.ts +7 -0
  580. package/server/routes/sessions.d.ts.map +1 -0
  581. package/server/routes/sessions.js +218 -0
  582. package/server/routes/sessions.js.map +1 -0
  583. package/server/service/caffeinate.d.ts +33 -0
  584. package/server/service/caffeinate.d.ts.map +1 -0
  585. package/server/service/caffeinate.js +72 -0
  586. package/server/service/caffeinate.js.map +1 -0
  587. package/server/state/app-state.d.ts +167 -0
  588. package/server/state/app-state.d.ts.map +1 -0
  589. package/server/state/app-state.js +335 -0
  590. package/server/state/app-state.js.map +1 -0
  591. package/server/state/project-manager.d.ts +30 -0
  592. package/server/state/project-manager.d.ts.map +1 -0
  593. package/server/state/project-manager.js +128 -0
  594. package/server/state/project-manager.js.map +1 -0
  595. package/server/state/server-notices.d.ts +12 -0
  596. package/server/state/server-notices.d.ts.map +1 -0
  597. package/server/state/server-notices.js +32 -0
  598. package/server/state/server-notices.js.map +1 -0
  599. package/server/state/worktree-cache.d.ts +25 -0
  600. package/server/state/worktree-cache.d.ts.map +1 -0
  601. package/server/state/worktree-cache.js +53 -0
  602. package/server/state/worktree-cache.js.map +1 -0
  603. package/server/ws/events.d.ts +45 -0
  604. package/server/ws/events.d.ts.map +1 -0
  605. package/server/ws/events.js +134 -0
  606. package/server/ws/events.js.map +1 -0
  607. package/server/ws/keepalive.d.ts +27 -0
  608. package/server/ws/keepalive.d.ts.map +1 -0
  609. package/server/ws/keepalive.js +63 -0
  610. package/server/ws/keepalive.js.map +1 -0
  611. package/server/ws/terminal-attach.d.ts +13 -0
  612. package/server/ws/terminal-attach.d.ts.map +1 -0
  613. package/server/ws/terminal-attach.js +233 -0
  614. package/server/ws/terminal-attach.js.map +1 -0
  615. package/server/ws/terminal-flow.d.ts +17 -0
  616. package/server/ws/terminal-flow.d.ts.map +1 -0
  617. package/server/ws/terminal-flow.js +64 -0
  618. package/server/ws/terminal-flow.js.map +1 -0
  619. package/server/ws/terminal.d.ts +69 -0
  620. package/server/ws/terminal.d.ts.map +1 -0
  621. package/server/ws/terminal.js +311 -0
  622. package/server/ws/terminal.js.map +1 -0
  623. package/web/assets/EditorPane-CzzT3iYY.js +123 -0
  624. package/web/assets/SymbolsNerdFontMono-Regular-CwEZqMeU.woff2 +0 -0
  625. package/web/assets/TerminalPane-CjbYzePr.js +68 -0
  626. package/web/assets/TerminalPane-DkTCHfhq.css +1 -0
  627. package/web/assets/file-icons-JBi09j0r.js +6 -0
  628. package/web/assets/index-CTTkRpnn.css +2 -0
  629. package/web/assets/index-CmhewzMp.js +34 -0
  630. package/web/assets/session-resume-7f-tB-ZU.js +2 -0
  631. package/web/assets/terminal-trace-PuuFRybC.js +2803 -0
  632. package/web/assets/useVirtualKeyboard-DgJb9u9d.js +1 -0
  633. package/web/index.html +52 -0
@@ -0,0 +1,100 @@
1
+ import { closeSync, existsSync, fsyncSync, mkdirSync, openSync, unlinkSync, writeSync, } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ const SERVER_MARKER_FILENAME = "shutdown.marker";
4
+ const DAEMON_MARKER_FILENAME = "daemon-shutdown.marker";
5
+ /**
6
+ * Write a marker file at the end of a graceful shutdown. On next startup
7
+ * the absence of this file means the previous run crashed, which in turn
8
+ * means child PTY processes may be orphaned and unsafe to respawn with
9
+ * the same command (potential double-run).
10
+ *
11
+ * The default filename `shutdown.marker` belongs to the in-process
12
+ * server. Daemon-mode passes `daemon-shutdown.marker` so the two writers
13
+ * never collide on the same `state.json` directory -- a graceful
14
+ * server-side shutdown does not imply the daemon (which owns the PTY
15
+ * children in remote mode) also exited gracefully.
16
+ *
17
+ * The write is open->write->fsync(file)->close->fsync(dir) so a kernel
18
+ * panic between the graceful-exit code path and the next boot does not
19
+ * let the marker "exist" only in dirty page-cache while the post-panic
20
+ * boot reads its absence as graceful. The directory fsync is essential
21
+ * because the marker's *existence* (not its content) is what subsequent
22
+ * boots check -- without it, the directory entry created by `openSync`
23
+ * may live in dirty inode cache only (). Both fsyncs
24
+ * are best-effort: if either fails we still close the fd; worst case the
25
+ * marker is read as absent on the next boot, which is the conservative
26
+ * "treat as crash" side.
27
+ */
28
+ export function writeShutdownMarker(configDir, filename = SERVER_MARKER_FILENAME) {
29
+ const path = join(configDir, filename);
30
+ const dir = dirname(path);
31
+ try {
32
+ mkdirSync(dir, { recursive: true });
33
+ const fd = openSync(path, "w");
34
+ try {
35
+ writeSync(fd, String(Date.now()));
36
+ try {
37
+ fsyncSync(fd);
38
+ }
39
+ catch {
40
+ // fsync may fail on filesystems that do not support it (tmpfs on
41
+ // some Linux configurations). The data is still committed to the
42
+ // page cache; on a clean shutdown that is sufficient. Falling
43
+ // through to close keeps the marker in the conservative state.
44
+ }
45
+ }
46
+ finally {
47
+ closeSync(fd);
48
+ }
49
+ // fsync the parent directory so the new directory entry survives a
50
+ // kernel panic. On Linux this guarantees the marker file is visible
51
+ // post-reboot; on macOS HFS+/APFS it is also durable. F_FULLFSYNC
52
+ // would be stronger but is not exposed by node's stdlib.
53
+ try {
54
+ const dirFd = openSync(dir, "r");
55
+ try {
56
+ fsyncSync(dirFd);
57
+ }
58
+ finally {
59
+ closeSync(dirFd);
60
+ }
61
+ }
62
+ catch {
63
+ // Some platforms (notably Windows) reject fsync on a directory
64
+ // handle. Skip silently -- the file fsync above is the best we can
65
+ // do, and the conservative "treat absent as crash" rule still
66
+ // catches a missing marker on the next boot.
67
+ }
68
+ }
69
+ catch {
70
+ // best-effort: failing to write the marker degrades to "treat as crash"
71
+ // which is the conservative side and not catastrophic.
72
+ }
73
+ }
74
+ /**
75
+ * Read the marker on startup. Returns true if the previous shutdown was
76
+ * graceful. The marker is always cleared so that a subsequent crash is
77
+ * correctly detected.
78
+ */
79
+ export function readAndClearShutdownMarker(configDir, filename = SERVER_MARKER_FILENAME) {
80
+ const path = join(configDir, filename);
81
+ const present = existsSync(path);
82
+ if (present) {
83
+ try {
84
+ unlinkSync(path);
85
+ }
86
+ catch {
87
+ // ignore -- stale marker is harmless; it will be overwritten next shutdown
88
+ }
89
+ }
90
+ return present;
91
+ }
92
+ /** Convenience wrappers -- daemon-side callers should prefer these to keep
93
+ * the marker filename centralised here. */
94
+ export function writeDaemonShutdownMarker(stateDir) {
95
+ writeShutdownMarker(stateDir, DAEMON_MARKER_FILENAME);
96
+ }
97
+ export function readAndClearDaemonShutdownMarker(stateDir) {
98
+ return readAndClearShutdownMarker(stateDir, DAEMON_MARKER_FILENAME);
99
+ }
100
+ //# sourceMappingURL=shutdown-marker.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown-marker.js","sourceRoot":"","sources":["../../src/bootstrap/shutdown-marker.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,SAAS,EACT,QAAQ,EACR,UAAU,EACV,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,sBAAsB,GAAG,iBAAiB,CAAC;AACjD,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAExD;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,MAAM,UAAU,mBAAmB,CACjC,SAAiB,EACjB,WAAmB,sBAAsB;IAEzC,MAAM,IAAI,GAAG,I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IACjC,IAAI,OAAO,EAAE,CAAC;QACZ,IAAI,CAAC;YACH,UAAU,CAAC,IAAI,CAAC,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,2EAA2E;QAC7E,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;4CAC4C;AAC5C,MAAM,UAAU,yBAAyB,CAAC,QAAgB;IACxD,mBAAmB,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,gCAAgC,CAAC,QAAgB;IAC/D,OAAO,0BAA0B,CAAC,QAAQ,EAAE,sBAAsB,CAAC,CAAC;AACtE,CAAC"}
@@ -0,0 +1,62 @@
1
+ interface RuntimeLoops {
2
+ stop(): void;
3
+ }
4
+ interface FlushableStateStore {
5
+ flush(): Promise<void>;
6
+ /**
7
+ * daemon state ownership -- true ⇒ remote daemon mode (daemon owns session-domain
8
+ * writes; server is a mirror). Used by the shutdown handler to
9
+ * decide whether the post-shutdownAll flush is needed: remote =
10
+ * skip (delegate dead post-detach + nothing to flush, daemon owns
11
+ * sessions), in-process = required (must persist server-graceful
12
+ * endReasons; failures must propagate so a stale state.json never
13
+ * pairs with a graceful marker).
14
+ */
15
+ isSessionsReadOnly(): boolean;
16
+ }
17
+ interface DisposableProjectRuntime {
18
+ dispose(): Promise<void>;
19
+ }
20
+ /**
21
+ * Server SIGTERM handler dependency. Today the in-process PtyHost's
22
+ * `shutdownAll()` kills every PTY and persists `server-graceful` end
23
+ * reasons (see comment at the call site below).
24
+ *
25
+ * In daemon mode, `RemotePtyHost.shutdownAll()` MUST detach from the daemon
26
+ * socket only -- not kill daemon-side PTYs. The intent is server graceful
27
+ * shutdown WITHOUT taking the agent processes down. The dedicated
28
+ * `parasor pty-host terminate-all` CLI does the destructive operation.
29
+ */
30
+ interface DisposablePtyHost {
31
+ shutdownAll(): Promise<void>;
32
+ }
33
+ interface StoppableIpcServer {
34
+ stop(): Promise<void>;
35
+ }
36
+ interface ShutdownableService {
37
+ shutdown(): void;
38
+ }
39
+ interface CreateShutdownHandlerDeps {
40
+ appStateStore: FlushableStateStore;
41
+ caffeinate?: ShutdownableService;
42
+ configDir: string;
43
+ ipcServer: StoppableIpcServer;
44
+ processExit?: (code: number) => void;
45
+ projectRuntime: DisposableProjectRuntime;
46
+ ptyManager: DisposablePtyHost;
47
+ removeRuntime?: (runtimeFile: string) => void;
48
+ runtimeFile: string;
49
+ runtimeLoops: RuntimeLoops;
50
+ writeMarker?: (configDir: string) => void;
51
+ /**
52
+ * -- release the in-process AppState owner
53
+ * (proper-lockfile + marker body) on graceful shutdown. Optional
54
+ * because daemon mode (where the daemon owns the marker) and tests
55
+ * pass `undefined`. Best-effort -- failures are swallowed.
56
+ */
57
+ releaseModeMarker?: () => Promise<void> | void;
58
+ }
59
+ export declare function createShutdownHandler({ appStateStore, caffeinate, configDir, ipcServer, processExit, projectRuntime, ptyManager, removeRuntime, runtimeFile, runtimeLoops, writeMarker, releaseModeMarker, }: CreateShutdownHandlerDeps): () => Promise<void>;
60
+ export declare function registerShutdownSignals(shutdown: () => Promise<void>, register?: typeof process.on): void;
61
+ export {};
62
+ //# sourceMappingURL=shutdown-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown-runtime.d.ts","sourceRoot":"","sources":["../../src/bootstrap/shutdown-runtime.ts"],"names":[],"mappings":"AAGA,UAAU,YAAY;IACpB,IAAI,IAAI,IAAI,CAAC;CACd;AAED,UAAU,mBAAmB;IAC3B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB;;;;;;;;OAQG;IACH,kBAAkB,IAAI,OAAO,CAAC;CAC/B;AAED,UAAU,wBAAwB;IAChC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED;;;;;;;;;GASG;AACH,UAAU,iBAAiB;IACzB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,UAAU,kBAAkB;IAC1B,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,UAAU,mBAAmB;IAC3B,QAAQ,IAAI,IAAI,CAAC;CAClB;AAED,UAAU,yBAAyB;IACjC,aAAa,EAAE,mBAAmB,CAAC;IACnC,UAAU,CAAC,EAAE,mBAAmB,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,kBAAkB,CAAC;IAC9B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACrC,cAAc,EAAE,wBAAwB,CAAC;IACzC,UAAU,EAAE,iBAAiB,CAAC;IAC9B,aAAa,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,KAAK,IAAI,CAAC;IAC9C,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,YAAY,CAAC;IAC3B,WAAW,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAC1C;;;;;OAKG;IACH,iBAAiB,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAChD;AAED,wBAAgB,qBAAqB,CAAC,EACpC,aAAa,EACb,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAA0B,EAC1B,cAAc,EACd,UAAU,EACV,aAAiC,EACjC,WAAW,EACX,YAAY,EACZ,WAAiC,EACjC,iBAAiB,GAClB,EAAE,yBAAyB,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAuDjD;AAED,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,EAC7B,QAAQ,GAAE,OAAO,OAAO,CAAC,EAA6B,GACrD,IAAI,CAON"}
@@ -0,0 +1,66 @@
1
+ import { removeRuntimeFile } from "./runtime-port.js";
2
+ import { writeShutdownMarker } from "./shutdown-marker.js";
3
+ export function createShutdownHandler({ appStateStore, caffeinate, configDir, ipcServer, processExit = process.exit, projectRuntime, ptyManager, removeRuntime = removeRuntimeFile, runtimeFile, runtimeLoops, writeMarker = writeShutdownMarker, releaseModeMarker, }) {
4
+ let inFlight = null;
5
+ return () => {
6
+ if (inFlight)
7
+ return inFlight;
8
+ inFlight = (async () => {
9
+ runtimeLoops.stop();
10
+ caffeinate?.shutdown();
11
+ await projectRuntime.dispose();
12
+ /*
13
+ * -- flush server-owned domains (projects /
14
+ * projectStates / serviceConfig) BEFORE shutdownAll detaches the
15
+ * IPC delegate. In remote mode `appStateStore.flush()` ships the
16
+ * latest snapshot through the live RemotePtyHost connection so
17
+ * the daemon persists it before the socket goes away. Skipping
18
+ * this step lets in-flight project / config writes evaporate on
19
+ * SIGTERM. In in-process mode this is a no-op aside from draining
20
+ * the debounce timer, harmless.
21
+ */
22
+ await appStateStore.flush();
23
+ // Kill PTYs and mark each session as server-graceful (in-process
24
+ // only -- RemotePtyHost.shutdownAll is detach-only because the
25
+ // daemon owns session state). disposeAll() (which deletes
26
+ // sessions outright) is NOT used here -- we want the sessions to
27
+ // come back with scrollback on next start.
28
+ await ptyManager.shutdownAll();
29
+ /*
30
+ * -- the post-shutdownAll flush is
31
+ * REQUIRED in in-process mode (must persist server-graceful
32
+ * endReasons before the marker; a swallowed failure pairs a
33
+ * stale state.json with a graceful marker, mis-classifying
34
+ * sessions as cleanly-ended on next boot). In remote mode the
35
+ * IPC delegate is dead post-detach AND the daemon already owns
36
+ * session-domain persistence -- so we skip the flush entirely
37
+ * rather than catching a guaranteed-fail call.
38
+ */
39
+ if (!appStateStore.isSessionsReadOnly()) {
40
+ await appStateStore.flush();
41
+ }
42
+ writeMarker(configDir);
43
+ await ipcServer.stop();
44
+ removeRuntime(runtimeFile);
45
+ if (releaseModeMarker) {
46
+ try {
47
+ await releaseModeMarker();
48
+ }
49
+ catch {
50
+ /* best-effort */
51
+ }
52
+ }
53
+ processExit(0);
54
+ })();
55
+ return inFlight;
56
+ };
57
+ }
58
+ export function registerShutdownSignals(shutdown, register = process.on.bind(process)) {
59
+ register("SIGTERM", shutdown);
60
+ register("SIGINT", shutdown);
61
+ // Terminal close / parent shell exit. Without this, SIGHUP terminates
62
+ // node before `releaseModeMarker()` runs and leaks
63
+ // `appstate.mode.lock/` for up to the proper-lockfile stale window.
64
+ register("SIGHUP", shutdown);
65
+ }
66
+ //# sourceMappingURL=shutdown-runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shutdown-runtime.js","sourceRoot":"","sources":["../../src/bootstrap/shutdown-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAmE3D,MAAM,UAAU,qBAAqB,CAAC,EACpC,aAAa,EACb,UAAU,EACV,SAAS,EACT,SAAS,EACT,WAAW,GAAG,OAAO,CAAC,IAAI,EAC1B,cAAc,EACd,UAAU,EACV,aAAa,GAAG,iBAAiB,EACjC,WAAW,EACX,YAAY,EACZ,WAAW,GAAG,mBAAmB,EACjC,iBAAiB,GACS;IAC1B,IAAI,QAAQ,GAAyB,IAAI,CAAC;IAE1C,OAAO,GAAG,EAAE;QACV,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAE9B,QAAQ,GAAG,CAAC,KAAK,IAAI,EAAE;YACrB,YAAY,CAAC,IAAI,EAAE,CAAC;YACpB,UAAU,EAAE,QAAQ,EAAE,CAAC;YACvB,MAAM,cAAc,CAAC,OAAO,EAAE,CAAC;YAC/B;;;;;;;;;eASG;YACH,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;YAC5B,iEAAiE;YACjE,+DAA+D;YAC/D,0DAA0D;YAC1D,iEAAiE;YACjE,2CAA2C;YAC3C,MAAM,UAAU,CAAC,WAAW,EAAE,CAAC;YAC/B;;;;;;;;;eASG;YACH,IAAI,CAAC,aAAa,CAAC,kBAAkB,EAAE,EAAE,CAAC;gBACxC,MAAM,aAAa,CAAC,KAAK,EAAE,CAAC;YAC9B,CAAC;YACD,WAAW,CAAC,SAAS,CAAC,CAAC;YACvB,MAAM,SAAS,CAAC,IAAI,EAAE,CAAC;YACvB,aAAa,CAAC,WAAW,CAAC,CAAC;YAC3B,IAAI,iBAAiB,EAAE,CAAC;gBACtB,IAAI,CAAC;oBACH,MAAM,iBAAiB,EAAE,CAAC;gBAC5B,CAAC;gBAAC,MAAM,CAAC;oBACP,iBAAiB;gBACnB,CAAC;YACH,CAAC;YACD,WAAW,CAAC,CAAC,CAAC,CAAC;QACjB,CAAC,CAAC,EAAE,CAAC;QAEL,OAAO,QAAQ,CAAC;IAClB,CAAC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,uBAAuB,CACrC,QAA6B,EAC7B,WAA8B,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC;IAEtD,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC7B,sEAAsE;IACtE,mDAAmD;IACnD,oEAAoE;IACpE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,34 @@
1
+ import type { NetworkEndpoint, TailscaleStatus } from "../network/endpoints.js";
2
+ import type { AuthMode } from "./create-app-server.js";
3
+ export interface QrOptions {
4
+ enabled: boolean;
5
+ iface?: string;
6
+ }
7
+ export interface BindInfo {
8
+ /** True when the user passed `--host` (or `HOST=`); false on the default. */
9
+ explicit: boolean;
10
+ host: string;
11
+ }
12
+ interface BuildStartupBannerOptions {
13
+ authMode: AuthMode;
14
+ configDir: string;
15
+ endpoints: NetworkEndpoint[];
16
+ port: number;
17
+ tailscaleStatus: TailscaleStatus;
18
+ token?: string;
19
+ makeAccessUrl?: (endpoint: NetworkEndpoint) => string;
20
+ qr?: QrOptions;
21
+ bind?: BindInfo;
22
+ /**
23
+ * When true, wrap URLs in OSC 8 hyperlinks so terminals that support it
24
+ * render them as a single clickable region -- even after the line wraps.
25
+ * `right click -> Copy link` then yields the full URL without injected
26
+ * newlines, which is the failure mode that makes a wrapped `?t=<token>`
27
+ * URL useless to copy/paste.
28
+ */
29
+ clickable?: boolean;
30
+ }
31
+ export declare function buildStartupBanner({ authMode, configDir, endpoints, port, tailscaleStatus, token, makeAccessUrl, qr, bind, clickable, }: BuildStartupBannerOptions): string[];
32
+ export declare function printStartupBanner(options: BuildStartupBannerOptions, log?: (line: string) => void): void;
33
+ export {};
34
+ //# sourceMappingURL=startup-banner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-banner.d.ts","sourceRoot":"","sources":["../../src/bootstrap/startup-banner.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAEhF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,UAAU,yBAAyB;IACjC,QAAQ,EAAE,QAAQ,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,eAAe,EAAE,CAAC;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,eAAe,CAAC;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,eAAe,KAAK,MAAM,CAAC;IACtD,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,IAAI,CAAC,EAAE,QAAQ,CAAC;IAChB;;;;;;OAMG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AA8DD,wBAAgB,kBAAkB,CAAC,EACjC,QAAQ,EACR,SAAS,EACT,SAAS,EACT,IAAI,EACJ,eAAe,EACf,KAAK,EACL,aAAa,EACb,EAAE,EACF,IAAI,EACJ,SAAiB,GAClB,EAAE,yBAAyB,GAAG,MAAM,EAAE,CA6DtC;AAED,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,yBAAyB,EAClC,GAAG,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAkB,GACxC,IAAI,CAYN"}
@@ -0,0 +1,114 @@
1
+ import { join } from "node:path";
2
+ import { buildAuthUrl, buildQrSection } from "../network/qr.js";
3
+ const OSC8_START = "\x1b]8;;";
4
+ const OSC8_DELIM = "\x1b\\";
5
+ const OSC8_END = "\x1b]8;;\x1b\\";
6
+ /*
7
+ * OSC 8 hyperlinks delimit the URL with `ESC \` (ST) and start with `ESC ]
8
+ * 8 ;;`. Any control character in the URL or label can break or hijack the
9
+ * sequence, so refuse to wrap when one is present and emit the plain text
10
+ * instead. `NetworkEndpoint.address` is OS-sourced today and unlikely to
11
+ * carry such bytes, but the function is exported and re-used for QR
12
+ * fallback paths, so the check stays defensive.
13
+ */
14
+ // biome-ignore lint/suspicious/noControlCharactersInRegex: OSC8 labels/URLs must reject terminal control bytes.
15
+ const TERMINAL_CONTROL_RE = /[\x00-\x1f\x7f]/;
16
+ function hyperlink(url, label, clickable) {
17
+ if (!clickable)
18
+ return label;
19
+ if (TERMINAL_CONTROL_RE.test(url) || TERMINAL_CONTROL_RE.test(label)) {
20
+ return label;
21
+ }
22
+ return `${OSC8_START}${url}${OSC8_DELIM}${label}${OSC8_END}`;
23
+ }
24
+ /**
25
+ * Filter endpoints to those actually reachable given the bind host.
26
+ *
27
+ * `0.0.0.0` / `::` (the default) listens on every interface, so all endpoints
28
+ * stay. A specific host (loopback, LAN IP, Tailscale CGNAT) is single-bind --
29
+ * only that address is reachable. MagicDNS rides along when the bind matches
30
+ * the Tailscale endpoint, since the friendly hostname resolves to it.
31
+ */
32
+ function filterReachableEndpoints(endpoints, bind) {
33
+ if (!bind)
34
+ return endpoints;
35
+ const { host } = bind;
36
+ if (host === "0.0.0.0" || host === "::" || host === "::0")
37
+ return endpoints;
38
+ const tailscaleHostMatch = endpoints.some((e) => e.address === host && e.category === "Tailscale");
39
+ return endpoints.filter((e) => {
40
+ if (e.address === host)
41
+ return true;
42
+ if (e.iface === "MagicDNS" && tailscaleHostMatch)
43
+ return true;
44
+ return false;
45
+ });
46
+ }
47
+ function buildDefaultAccessUrl(endpoint, port, authMode, token) {
48
+ if (authMode === "token" && !token) {
49
+ throw new Error("token or makeAccessUrl is required for token auth URLs");
50
+ }
51
+ return buildAuthUrl(endpoint.address, port, authMode, token ?? "");
52
+ }
53
+ export function buildStartupBanner({ authMode, configDir, endpoints, port, tailscaleStatus, token, makeAccessUrl, qr, bind, clickable = false, }) {
54
+ const lines = [];
55
+ lines.push(``, `parasor running on port ${port}`, ``, "Access URLs:");
56
+ const visibleEndpoints = filterReachableEndpoints(endpoints, bind);
57
+ for (const endpoint of visibleEndpoints) {
58
+ const authUrl = makeAccessUrl?.(endpoint) ??
59
+ buildDefaultAccessUrl(endpoint, port, authMode, token);
60
+ const label = endpoint.iface
61
+ ? `${endpoint.category} (${endpoint.iface})`
62
+ : endpoint.category;
63
+ /*
64
+ * URL goes on its own line so a terminal that wraps a long
65
+ * `?t=<64-hex>` URL still puts the whole token on a single visual row
66
+ * (or at least a wrap that the OS clipboard can handle). Inline
67
+ * `label url` was prone to copy-paste truncation when the URL wrapped
68
+ * across two terminal columns.
69
+ */
70
+ lines.push(` ${label}`);
71
+ lines.push(` ${hyperlink(authUrl, authUrl, clickable)}`);
72
+ }
73
+ if (tailscaleStatus.state === "stopped") {
74
+ lines.push("", " Tailscale is installed but not running. Run `tailscale up` for remote access.");
75
+ }
76
+ if (authMode === "token") {
77
+ lines.push("", `Auth: token (saved to ${join(configDir, "token")})`);
78
+ }
79
+ else if (authMode === "none") {
80
+ lines.push("", "Auth: none (trusted network mode)");
81
+ }
82
+ if (bind && !bind.explicit && bind.host === "0.0.0.0") {
83
+ lines.push("", "Tip: bind to loopback only with `parasor --host 127.0.0.1`");
84
+ }
85
+ if (qr?.enabled) {
86
+ lines.push("");
87
+ for (const row of buildQrSection({
88
+ endpoints: visibleEndpoints,
89
+ port,
90
+ authMode,
91
+ token,
92
+ makeAccessUrl,
93
+ iface: qr.iface,
94
+ clickable,
95
+ })) {
96
+ lines.push(row);
97
+ }
98
+ }
99
+ lines.push("");
100
+ return lines;
101
+ }
102
+ export function printStartupBanner(options, log = console.log) {
103
+ /*
104
+ * Default `clickable` to TTY detection so OSC 8 escape sequences only go
105
+ * to interactive terminals -- log files / piped output stay plain text.
106
+ */
107
+ const resolved = options.clickable === undefined
108
+ ? { ...options, clickable: process.stdout.isTTY === true }
109
+ : options;
110
+ for (const line of buildStartupBanner(resolved)) {
111
+ log(line);
112
+ }
113
+ }
114
+ //# sourceMappingURL=startup-banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"startup-banner.js","sourceRoot":"","sources":["../../src/bootstrap/startup-banner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAkChE,MAAM,UAAU,GAAG,UAAU,CAAC;AAC9B,MAAM,UAAU,GAAG,QAAQ,CAAC;AAC5B,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAElC;;;;;;;GAOG;AACH,gHAAgH;AAChH,MAAM,mBAAmB,GAAG,iBAAiB,CAAC;AAE9C,SAAS,SAAS,CAAC,GAAW,EAAE,KAAa,EAAE,SAAkB;IAC/D,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,IAAI,mBAAmB,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrE,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,GAAG,UAAU,GAAG,GAAG,GAAG,UAAU,GAAG,KAAK,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KAAK,CAAC,IAAI,CACR,EAAE,EACF,4DAA4D,CAC7D,CAAC;IACJ,CAAC;IAED,IAAI,EAAE,EAAE,OAAO,EAAE,CAAC;QAChB,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACf,KAAK,MAAM,GAAG,IAAI,cAAc,CAAC;YAC/B,SAAS,EAAE,gBAAgB;YAC3B,IAAI;YACJ,QAAQ;YACR,KAAK;YACL,aAAa;YACb,KAAK,EAAE,EAAE,CAAC,KAAK;YACf,SAAS;SACV,CAAC,EAAE,CAAC;YACH,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAClB,CAAC;IACH,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACf,OAAO,KAAK,CAAC;AACf,CAAC;AAED,MAAM,UAAU,kBAAkB,CAChC,OAAkC,EAClC,MAA8B,OAAO,CAAC,GAAG;IAEzC;;;OAGG;IACH,MAAM,QAAQ,GACZ,OAAO,CAAC,SAAS,KAAK,SAAS;QAC7B,CAAC,CAAC,EAAE,GAAG,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,EAAE;QAC1D,CAAC,CAAC,OAAO,CAAC;IACd,KAAK,MAAM,IAAI,IAAI,kBAAkB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAChD,GAAG,CAAC,IAAI,CAAC,CAAC;IACZ,CAAC;AACH,CAAC"}
@@ -0,0 +1,42 @@
1
+ import type { AppState, Notification } from "@parasor/shared";
2
+ import type { AgentStateStore } from "../agent-detector/agent-state-store.js";
3
+ import type { AgentDetector } from "../agent-detector/detector.js";
4
+ import type { AgentStatusRecorder } from "../debug/agent-status-recorder.js";
5
+ import type { UploadStaging } from "../fs/upload-staging.js";
6
+ import type { IpcServer } from "../ipc/socket-server.js";
7
+ import type { PortForwarder } from "../port-forwarder/forwarder.js";
8
+ import type { PortScanner } from "../port-scanner/scanner.js";
9
+ import type { PtyHost } from "../pty/host.js";
10
+ import type { AppStateStore } from "../state/app-state.js";
11
+ import type { ProjectManager } from "../state/project-manager.js";
12
+ import type { WorktreeCache } from "../state/worktree-cache.js";
13
+ import type { EventBus } from "../ws/events.js";
14
+ import type { ProjectRuntime } from "./project-runtime.js";
15
+ export interface WireRuntimeDeps {
16
+ appStateStore: AppStateStore;
17
+ eventBus: EventBus;
18
+ portScanner: PortScanner;
19
+ /**
20
+ * The shared per-port TCP forwarder (same instance handed to
21
+ * `startRuntimeLoops`). Used to enrich the hydration snapshot's ports with
22
+ * `reachable`/`reachablePort` so a reloaded/reconnected client can resolve
23
+ * already-open browser panes without waiting for the next port-set change.
24
+ */
25
+ portForwarder: PortForwarder;
26
+ ptyManager: PtyHost;
27
+ agentDetector: AgentDetector;
28
+ agentStateStore: AgentStateStore;
29
+ debugRecorder?: AgentStatusRecorder;
30
+ ipcServer: IpcServer;
31
+ projectManager: ProjectManager;
32
+ projectRuntime: ProjectRuntime;
33
+ worktreeCache: WorktreeCache;
34
+ uploadStaging: UploadStaging;
35
+ }
36
+ export declare function createWaitingNotification(sessionId: string, projectId: string, now?: number): Notification;
37
+ export declare function buildHydrationStateSnapshot({ appStateStore, ptyManager, }: {
38
+ appStateStore: AppStateStore;
39
+ ptyManager: PtyHost;
40
+ }): AppState;
41
+ export declare function wireRuntime({ appStateStore, eventBus, portScanner, portForwarder, ptyManager, agentDetector, agentStateStore, debugRecorder, ipcServer, projectManager, projectRuntime, worktreeCache, uploadStaging, }: WireRuntimeDeps): void;
42
+ //# sourceMappingURL=wire-runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wire-runtime.d.ts","sourceRoot":"","sources":["../../src/bootstrap/wire-runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAY,MAAM,iBAAiB,CAAC;AACxE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AAC9E,OAAO,KAAK,EAAE,aAAa,EAAE,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A2B,CAAC,EAC1C,aAAa,EACb,UAAU,GACX,EAAE;IACD,aAAa,EAAE,aAAa,CAAC;IAC7B,UAAU,EAAE,OAAO,CAAC;CACrB,GAAG,QAAQ,CAMX;AAED,wBAAgB,WAAW,CAAC,EAC1B,aAAa,EACb,QAAQ,EACR,WAAW,EACX,aAAa,EACb,UAAU,EACV,aAAa,EACb,eAAe,EACf,aAAa,EACb,SAAS,EACT,cAAc,EACd,cAAc,EACd,aAAa,EACb,aAAa,GACd,EAAE,eAAe,GAAG,IAAI,CAiMxB"}
@@ -0,0 +1,205 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { ManualAgentTracker } from "../agent-detector/manual-agent-tracker.js";
3
+ import { shouldObserveAgentOutput } from "../agent-detector/output-eligibility.js";
4
+ import { createProjectQueries } from "../application/workspace/project-queries.js";
5
+ import { Osc7Lifecycle } from "../pty/osc7-lifecycle.js";
6
+ import { enrichPorts } from "./runtime-loops.js";
7
+ export function createWaitingNotification(sessionId, projectId, now = Date.now()) {
8
+ return {
9
+ id: randomUUID(),
10
+ projectId,
11
+ sessionId,
12
+ type: "agent-waiting",
13
+ title: "Agent waiting",
14
+ message: "Agent is waiting for input",
15
+ timestamp: now,
16
+ read: false,
17
+ };
18
+ }
19
+ export function buildHydrationStateSnapshot({ appStateStore, ptyManager, }) {
20
+ const state = appStateStore.get();
21
+ return {
22
+ ...state,
23
+ sessions: ptyManager.list(),
24
+ };
25
+ }
26
+ export function wireRuntime({ appStateStore, eventBus, portScanner, portForwarder, ptyManager, agentDetector, agentStateStore, debugRecorder, ipcServer, projectManager, projectRuntime, worktreeCache, uploadStaging, }) {
27
+ const projectQueries = createProjectQueries({ projectManager });
28
+ const getLiveSessionIds = () => ptyManager
29
+ .list()
30
+ .flatMap((session) => (session.state === "ended" ? [] : [session.id]));
31
+ eventBus.setHydrationSources({
32
+ getState: () => buildHydrationStateSnapshot({ appStateStore, ptyManager }),
33
+ getAgentStates: () => agentStateStore.getStates({ liveSessionIds: getLiveSessionIds() }),
34
+ getNotifications: () => eventBus.getNotifications(),
35
+ getPorts: () => {
36
+ const out = {};
37
+ for (const [projectId, ports] of Object.entries(portScanner.getAllPorts())) {
38
+ out[projectId] = enrichPorts(ports, projectId, portForwarder);
39
+ }
40
+ return out;
41
+ },
42
+ getGitStates: () => projectRuntime.getGitStates(),
43
+ getWorktrees: () => worktreeCache.get(),
44
+ });
45
+ const osc7Lifecycle = new Osc7Lifecycle();
46
+ const manualAgentTracker = new ManualAgentTracker({
47
+ onDebug: (sessionId, message) => {
48
+ debugRecorder?.record("manual-tracker", { message }, sessionId);
49
+ },
50
+ });
51
+ const originalBroadcast = eventBus.broadcast.bind(eventBus);
52
+ eventBus.broadcast = (message) => {
53
+ // Cache mutations must happen BEFORE broadcast so that a client
54
+ // hydrating in the same tick (post-broadcast addClient) reads the
55
+ // updated cache. Snapshot is sync inside `addClient`, so a
56
+ // broadcast-then-snapshot ordering is consistent only when cache is
57
+ // already updated by the broadcast wrapper here.
58
+ if (message.type === "worktree-created") {
59
+ worktreeCache.appendWorktree(message.projectId, message.worktree);
60
+ }
61
+ else if (message.type === "worktree-removed") {
62
+ worktreeCache.removeWorktree(message.projectId, message.worktreePath);
63
+ }
64
+ else if (message.type === "project-deleted") {
65
+ worktreeCache.removeProject(message.projectId);
66
+ }
67
+ else if (message.type === "project-created") {
68
+ // Refresh asynchronously: a freshly imported project may already
69
+ // have linked worktrees on disk that the cache has never seen.
70
+ // Each discovered worktree is re-broadcast so live clients update
71
+ // their store; new clients will hydrate the cache directly.
72
+ const projectId = message.project.id;
73
+ void projectQueries
74
+ .getProjectWorktrees(projectId)
75
+ .then((worktrees) => {
76
+ // Race guard: a project-deleted may have arrived during the
77
+ // git enumeration. Skip the cache update + re-broadcast so
78
+ // orphan worktrees do not resurface server- or client-side.
79
+ if (!projectManager.get(projectId))
80
+ return;
81
+ worktreeCache.setProject(projectId, worktrees);
82
+ for (const worktree of worktrees) {
83
+ eventBus.broadcast({
84
+ type: "worktree-created",
85
+ projectId,
86
+ worktree,
87
+ });
88
+ }
89
+ })
90
+ .catch(() => {
91
+ /* getProjectWorktrees swallows git errors -> empty list */
92
+ });
93
+ }
94
+ originalBroadcast(message);
95
+ if (message.type === "session-closed") {
96
+ osc7Lifecycle.removeSession(message.sessionId);
97
+ agentDetector.removeSession(message.sessionId);
98
+ agentStateStore.remove(message.sessionId);
99
+ manualAgentTracker.removeSession(message.sessionId);
100
+ }
101
+ projectRuntime.handleBroadcast(message);
102
+ };
103
+ ptyManager.onSessionInput((sessionId, data) => {
104
+ manualAgentTracker.observeInput(sessionId, data);
105
+ });
106
+ ptyManager.onSessionData((sessionId, data, generation) => {
107
+ const detectorSession = ptyManager.get(sessionId);
108
+ /*
109
+ * PTY generation gate: drop stale-gen DATA at the listener boundary.
110
+ * After auto-resume, an old PTY can still emit a residual OSC7 cwd
111
+ * report or agent-output marker. The per-client / scrollback fanout
112
+ * already gates on generation, but every onSessionData listener used
113
+ * to be invoked with stale bytes -- corrupting agent detection state
114
+ * and broadcasting `session-cwd-changed` for the new shell with the
115
+ * old PTY's cwd. Skip every derived state mutation when the chunk's
116
+ * emit-time generation no longer matches the live session.
117
+ */
118
+ if (detectorSession && generation < detectorSession.generation) {
119
+ return;
120
+ }
121
+ const foregroundProcess = ptyManager.getForegroundProcess(sessionId);
122
+ const observeOutput = shouldObserveAgentOutput(detectorSession, foregroundProcess) ||
123
+ manualAgentTracker.shouldObserve(sessionId);
124
+ agentDetector.feed(sessionId, data, {
125
+ observeOutput,
126
+ });
127
+ manualAgentTracker.observeOutput(sessionId, data);
128
+ const newCwd = osc7Lifecycle.feed(sessionId, data);
129
+ if (!newCwd)
130
+ return;
131
+ const session = ptyManager.get(sessionId);
132
+ if (!session || session.cwd === newCwd)
133
+ return;
134
+ /*
135
+ * In remote daemon mode the session domain is owned by the daemon
136
+ * (daemon state ownership). The server's `state.sessions` is empty/stale
137
+ * -- sessions live in `RemotePtyHost.mirror` -- so the in-process
138
+ * persistence path doesn't apply. The daemon does not currently run
139
+ * osc7 detection on its side; the cwd-change broadcast is still
140
+ * useful for live UI even without persistence, so emit it
141
+ * unconditionally and skip the mutate when the session domain is
142
+ * read-only.
143
+ */
144
+ if (!appStateStore.isSessionsReadOnly()) {
145
+ appStateStore.mutateSessions((state) => {
146
+ const target = state.sessions.find((candidate) => candidate.id === sessionId);
147
+ if (target)
148
+ target.cwd = newCwd;
149
+ });
150
+ }
151
+ eventBus.broadcast({
152
+ type: "session-cwd-changed",
153
+ sessionId,
154
+ cwd: newCwd,
155
+ });
156
+ });
157
+ ptyManager.onSessionExit = (sessionId, generation, endReason) => {
158
+ eventBus.broadcast({
159
+ type: "session-ended",
160
+ sessionId,
161
+ generation,
162
+ endReason,
163
+ });
164
+ osc7Lifecycle.removeSession(sessionId);
165
+ agentDetector.removeSession(sessionId);
166
+ agentStateStore.remove(sessionId);
167
+ manualAgentTracker.removeSession(sessionId);
168
+ const session = ptyManager.get(sessionId);
169
+ if (session) {
170
+ projectRuntime.handleSessionEnded(session.projectId);
171
+ }
172
+ // L1 GC for upload staging isolation -- drop the session's upload staging dir
173
+ // immediately on PTY exit. Best-effort: a failure here is logged
174
+ // and the L2/L3 sweep will reap it later.
175
+ uploadStaging.releaseSession(sessionId).catch((err) => {
176
+ console.error(`[upload-staging] releaseSession(${sessionId}) failed:`, err);
177
+ });
178
+ };
179
+ agentDetector.onStateChange((state) => {
180
+ agentStateStore.set(state);
181
+ debugRecorder?.recordState(state);
182
+ eventBus.broadcast({
183
+ type: "agent-state",
184
+ state,
185
+ });
186
+ if (state.lifecycle !== "waiting" || state.confidence !== "high")
187
+ return;
188
+ const session = ptyManager.get(state.sessionId);
189
+ const notification = createWaitingNotification(state.sessionId, session?.projectId ?? "");
190
+ eventBus.addNotification(notification);
191
+ eventBus.broadcast({ type: "notification", notification });
192
+ });
193
+ ipcServer.onCommand("open", (args) => {
194
+ const url = args.url;
195
+ if (!url)
196
+ return { ok: false, error: "url required" };
197
+ eventBus.broadcast({
198
+ type: "browser-url-changed",
199
+ paneId: "__route_open__",
200
+ url,
201
+ });
202
+ return { ok: true };
203
+ });
204
+ }
205
+ //# sourceMappingURL=wire-runtime.js.map