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 @@
1
+ {"version":3,"file":"scrollback-log.js","sourceRoot":"","sources":["../../src/pty/scrollback-log.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,UAAU,EACV,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAA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YAAC,MAAM,CAAC;gBACP,SAAS;YACX,CAAC;QACH,CAAC;gBAAS,CAAC;YACT,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBACnB,IAAI,CAAC;oBACH,SAAS,CAAC,KAAK,CAAC,CAAC;gBACnB,CAAC;gBAAC,MAAM,CAAC;oBACP,SAAS;gBACX,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export declare function stripQueryEscapes(data: string): string;
2
+ //# sourceMappingURL=scrollback-sanitize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollback-sanitize.d.ts","sourceRoot":"","sources":["../../src/pty/scrollback-sanitize.ts"],"names":[],"mappings":"AAuDA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAEtD"}
@@ -0,0 +1,54 @@
1
+ /*
2
+ * Terminal query escape sequences that solicit a response from xterm.js
3
+ * back to the host. xterm sends the response via its `onData` hook, which
4
+ * we forward straight to the PTY stdin. During live operation the shell
5
+ * is usually mid-command and discards the response silently.
6
+ *
7
+ * On re-attach, the server replays accumulated scrollback to the new
8
+ * client's xterm. Any query escape inside that history gets re-parsed,
9
+ * xterm emits the response again, it lands in the shell's readline
10
+ * buffer this time -- because the shell is now idle at a prompt -- and
11
+ * the user sees garbage like `>|xterm.js(6.1.0-beta.197)1;2c` appear
12
+ * on their command line.
13
+ *
14
+ * Strip the known query sequences from replayed scrollback so xterm
15
+ * has nothing to respond to. Live output is left untouched (single
16
+ * legitimate response per query is the protocol).
17
+ *
18
+ * Stripped patterns:
19
+ * CSI [priv]? [params] c Device Attributes (DA1/DA2/DA3). The
20
+ * final byte 'c' is exclusively DA in
21
+ * standard terminals.
22
+ * CSI [?]? [params] n Device Status Report family (CSI 5n,
23
+ * 6n, ?15n, ?25n, ?26n, ?55n, ?56n, ?62n,
24
+ * ?63n). Final 'n' is DSR-only.
25
+ * CSI > [params] q XTVERSION query. DECSCUSR uses 'q' too
26
+ * but without the '>' prefix -- kept.
27
+ * CSI (11-21) [;params]? t Window manipulation queries. 1-10 are
28
+ * commands (iconify/resize/etc.), 22-23
29
+ * are stack ops -- kept.
30
+ * CSI ? [params] u Kitty keyboard protocol query. Plain
31
+ * 'CSI u' (restore cursor) and 'CSI >/<'
32
+ * variants (push/pop state) -- kept.
33
+ * OSC 10-19 ; ? [; 10-19 ; ?]*
34
+ * ST/BEL Dynamic color queries (foreground,
35
+ * background, cursor, etc.).
36
+ * OSC 4 ; idx ; ? ST/BEL Palette color queries.
37
+ * DCS $ q ... ST DECRQSS (request selection or setting).
38
+ */
39
+ const OSC_TERMINATOR_RE = String.raw `(?:\x07|\x1b\\)`;
40
+ const OSC_DYNAMIC_COLOR_QUERY_RE = String.raw `(?:1[0-9];\?)(?:;1[0-9];\?)*`;
41
+ const OSC_PALETTE_COLOR_QUERY_RE = String.raw `4;[0-9]{1,3};\?(?:;[0-9]{1,3};\?)*`;
42
+ const QUERY_ESCAPE_RE = new RegExp([
43
+ String.raw `\x1b\[[?=>]?[0-9;]*c`,
44
+ String.raw `\x1b\[\??[0-9;]*n`,
45
+ String.raw `\x1b\[>[0-9;]*q`,
46
+ String.raw `\x1b\[(?:1[1-9]|2[01])(?:;[0-9]+)*t`,
47
+ String.raw `\x1b\[\?[0-9;]*u`,
48
+ String.raw `\x1b\](?:${OSC_DYNAMIC_COLOR_QUERY_RE}|${OSC_PALETTE_COLOR_QUERY_RE})${OSC_TERMINATOR_RE}`,
49
+ String.raw `\x1bP\$q[\s\S]*?\x1b\\`,
50
+ ].join("|"), "g");
51
+ export function stripQueryEscapes(data) {
52
+ return data.replace(QUERY_ESCAPE_RE, "");
53
+ }
54
+ //# sourceMappingURL=scrollback-sanitize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrollback-sanitize.js","sourceRoot":"","sources":["../../src/pty/scrollback-sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,MAAM,iBAAiB,GAAG,MAAM,CAAC,GAAG,CAAA,iBAAiB,CAAC;AACtD,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAA,8BAA8B,CAAC;AAC5E,MAAM,0BAA0B,GAAG,MAAM,CAAC,GAAG,CAAA,oCAAoC,CAAC;AAElF,MAAM,eAAe,GAAG,IAAI,MAAM,CAChC;IACE,MAAM,CAAC,GAAG,CAAA,sBAAsB;IAChC,MAAM,CAAC,GAAG,CAAA,mBAAmB;IAC7B,MAAM,CAAC,GAAG,CAAA,iBAAiB;IAC3B,MAAM,CAAC,GAAG,CAAA,qCAAqC;IAC/C,MAAM,CAAC,GAAG,CAAA,kBAAkB;IAC5B,MAAM,CAAC,GAAG,CAAA,YAAY,0BAA0B,IAAI,0BAA0B,IAAI,iBAAiB,EAAE;IACrG,MAAM,CAAC,GAAG,CAAA,wBAAwB;CACnC,CAAC,IAAI,CAAC,GAAG,CAAC,EACX,GAAG,CACJ,CAAC;AAEF,MAAM,UAAU,iBAAiB,CAAC,IAAY;IAC5C,OAAO,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;AAC3C,CAAC"}
@@ -0,0 +1,67 @@
1
+ import type { Session, SessionEndReason } from "@parasor/shared";
2
+ /**
3
+ * Pure (I/O-free) local view-state mirror for {@link RemotePtyHost}. Owns the
4
+ * mirrored `Session` map and the per-session monotonic generation latch
5
+ * (PTY generation gate). Every transition is deterministic and socket-free: the IPC shell
6
+ * decodes wire frames, resolves the handshake, fans bytes out to listeners and
7
+ * persists scrollback -- then drives these methods. Holding the two maps here
8
+ * keeps the shell to a single field and makes the reconciliation unit-testable
9
+ * without a socket.
10
+ */
11
+ export declare class SessionMirror {
12
+ private readonly sessions;
13
+ /**
14
+ * PTY generation gate: highest generation observed per session. Seeded from
15
+ * authoritative `Session` snapshots and advanced by DATA frames; only ever
16
+ * moves forward so a late stale-generation chunk cannot rewind the latch.
17
+ */
18
+ private readonly latestGeneration;
19
+ /**
20
+ * Monotonic seed from an authoritative `Session` snapshot. Takes the max so
21
+ * a generation already observed via DATA is never overwritten by a stale
22
+ * snapshot. SESSION_LIST / SESSION_UPDATE land before the first DATA frame
23
+ * for a freshly-spawned (or just-auto-resumed) session, so seeding here is
24
+ * what lets `attachClient` report a non-zero `serverState.generation`; without
25
+ * it the latch stays 0 until the first OUTPUT byte and the client echoes
26
+ * `{generation: 0}` on every INPUT, defeating the PTY generation gate auto-resume input gate.
27
+ */
28
+ seedGeneration(session: Session): void;
29
+ /**
30
+ * Record a DATA-frame generation under the monotonic gate and report whether
31
+ * the chunk is stale (strictly older than the highest generation observed so
32
+ * far). The shell uses the verdict to decide client fan-out / scrollback
33
+ * persistence (PTY generation gate) while the latch advance stays here.
34
+ */
35
+ recordDataGeneration(sessionId: string, generation: number): {
36
+ stale: boolean;
37
+ };
38
+ /** Highest generation observed for a session (0 if never seen). */
39
+ generationOf(sessionId: string): number;
40
+ /**
41
+ * Insert/update an authoritative session snapshot and seed its generation.
42
+ * Used for SESSION_UPDATE broadcasts and CREATE/RESTART ACKs.
43
+ */
44
+ upsert(session: Session): void;
45
+ /**
46
+ * Replace a stored session object without touching the generation latch.
47
+ * Used for local optimistic patches (setTitle/setPinned) whose generation is
48
+ * unchanged from the already-mirrored value.
49
+ */
50
+ replace(session: Session): void;
51
+ /** SESSION_LIST: replace the entire mirror and seed each generation. */
52
+ applyList(sessions: readonly Session[]): void;
53
+ /**
54
+ * SESSION_EXIT: stamp an existing session `ended` with its end reason. No-op
55
+ * for unknown ids -- the shell still fires its `onSessionExit` callback
56
+ * regardless.
57
+ */
58
+ applyExit(sessionId: string, endReason: SessionEndReason): void;
59
+ /** DISPOSE: drop one session from the mirror and the generation latch. */
60
+ remove(sessionId: string): void;
61
+ /** DISPOSE_ALL: clear all mirror and generation state. */
62
+ clear(): void;
63
+ get(id: string): Session | undefined;
64
+ list(): Session[];
65
+ listByProject(projectId: string): Session[];
66
+ }
67
+ //# sourceMappingURL=session-mirror.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-mirror.d.ts","sourceRoot":"","sources":["../../src/pty/session-mirror.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;;;;;;;GAQG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAA8B;IACvD;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAA6B;IAI9D;;;;;;;;OAQG;IACH,cAAc,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAOtC;;;;;OAKG;IACH,oBAAoB,CAClB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE;IAQrB,mEAAmE;IACnE,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM;IAMvC;;;OAGG;IACH,MAAM,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAK9B;;;;OAIG;IACH,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAI/B,wEAAwE;IACxE,SAAS,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,GAAG,IAAI;IAQ7C;;;;OAIG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,GAAG,IAAI;IAW/D,0EAA0E;IAC1E,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAK/B,0DAA0D;IAC1D,KAAK,IAAI,IAAI;IAOb,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIpC,IAAI,IAAI,OAAO,EAAE;IAIjB,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE;CAG5C"}
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Pure (I/O-free) local view-state mirror for {@link RemotePtyHost}. Owns the
3
+ * mirrored `Session` map and the per-session monotonic generation latch
4
+ * (PTY generation gate). Every transition is deterministic and socket-free: the IPC shell
5
+ * decodes wire frames, resolves the handshake, fans bytes out to listeners and
6
+ * persists scrollback -- then drives these methods. Holding the two maps here
7
+ * keeps the shell to a single field and makes the reconciliation unit-testable
8
+ * without a socket.
9
+ */
10
+ export class SessionMirror {
11
+ sessions = new Map();
12
+ /**
13
+ * PTY generation gate: highest generation observed per session. Seeded from
14
+ * authoritative `Session` snapshots and advanced by DATA frames; only ever
15
+ * moves forward so a late stale-generation chunk cannot rewind the latch.
16
+ */
17
+ latestGeneration = new Map();
18
+ // --- generation latch (PTY generation gate) ---
19
+ /**
20
+ * Monotonic seed from an authoritative `Session` snapshot. Takes the max so
21
+ * a generation already observed via DATA is never overwritten by a stale
22
+ * snapshot. SESSION_LIST / SESSION_UPDATE land before the first DATA frame
23
+ * for a freshly-spawned (or just-auto-resumed) session, so seeding here is
24
+ * what lets `attachClient` report a non-zero `serverState.generation`; without
25
+ * it the latch stays 0 until the first OUTPUT byte and the client echoes
26
+ * `{generation: 0}` on every INPUT, defeating the PTY generation gate auto-resume input gate.
27
+ */
28
+ seedGeneration(session) {
29
+ const prev = this.latestGeneration.get(session.id) ?? 0;
30
+ if (session.generation > prev) {
31
+ this.latestGeneration.set(session.id, session.generation);
32
+ }
33
+ }
34
+ /**
35
+ * Record a DATA-frame generation under the monotonic gate and report whether
36
+ * the chunk is stale (strictly older than the highest generation observed so
37
+ * far). The shell uses the verdict to decide client fan-out / scrollback
38
+ * persistence (PTY generation gate) while the latch advance stays here.
39
+ */
40
+ recordDataGeneration(sessionId, generation) {
41
+ const prev = this.latestGeneration.get(sessionId) ?? 0;
42
+ if (generation > prev) {
43
+ this.latestGeneration.set(sessionId, generation);
44
+ }
45
+ return { stale: generation < prev };
46
+ }
47
+ /** Highest generation observed for a session (0 if never seen). */
48
+ generationOf(sessionId) {
49
+ return this.latestGeneration.get(sessionId) ?? 0;
50
+ }
51
+ // --- reconciliation ---
52
+ /**
53
+ * Insert/update an authoritative session snapshot and seed its generation.
54
+ * Used for SESSION_UPDATE broadcasts and CREATE/RESTART ACKs.
55
+ */
56
+ upsert(session) {
57
+ this.sessions.set(session.id, session);
58
+ this.seedGeneration(session);
59
+ }
60
+ /**
61
+ * Replace a stored session object without touching the generation latch.
62
+ * Used for local optimistic patches (setTitle/setPinned) whose generation is
63
+ * unchanged from the already-mirrored value.
64
+ */
65
+ replace(session) {
66
+ this.sessions.set(session.id, session);
67
+ }
68
+ /** SESSION_LIST: replace the entire mirror and seed each generation. */
69
+ applyList(sessions) {
70
+ this.sessions.clear();
71
+ for (const session of sessions) {
72
+ this.sessions.set(session.id, session);
73
+ this.seedGeneration(session);
74
+ }
75
+ }
76
+ /**
77
+ * SESSION_EXIT: stamp an existing session `ended` with its end reason. No-op
78
+ * for unknown ids -- the shell still fires its `onSessionExit` callback
79
+ * regardless.
80
+ */
81
+ applyExit(sessionId, endReason) {
82
+ const existing = this.sessions.get(sessionId);
83
+ if (existing) {
84
+ this.sessions.set(sessionId, {
85
+ ...existing,
86
+ state: "ended",
87
+ endReason,
88
+ });
89
+ }
90
+ }
91
+ /** DISPOSE: drop one session from the mirror and the generation latch. */
92
+ remove(sessionId) {
93
+ this.sessions.delete(sessionId);
94
+ this.latestGeneration.delete(sessionId);
95
+ }
96
+ /** DISPOSE_ALL: clear all mirror and generation state. */
97
+ clear() {
98
+ this.sessions.clear();
99
+ this.latestGeneration.clear();
100
+ }
101
+ // --- read accessors (mirror-served sync queries) ---
102
+ get(id) {
103
+ return this.sessions.get(id);
104
+ }
105
+ list() {
106
+ return Array.from(this.sessions.values());
107
+ }
108
+ listByProject(projectId) {
109
+ return this.list().filter((s) => s.projectId === projectId);
110
+ }
111
+ }
112
+ //# sourceMappingURL=session-mirror.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-mirror.js","sourceRoot":"","sources":["../../src/pty/session-mirror.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AACH,M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,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC;IAC9D,CAAC;CACF"}
@@ -0,0 +1,85 @@
1
+ import type { SessionCommand, SessionEndReason } from "@parasor/shared";
2
+ /**
3
+ * Pure session policy & spawn-spec for the PTY hosts (Pure Core, see
4
+ * `docs/architecture.md` ). No I/O: every function here is a
5
+ * deterministic decision or derivation over its arguments, so they are
6
+ * unit-testable without spawning a real PTY. The imperative shells
7
+ * (`in-process-host.ts`, `remote-host.ts`) own node-pty / fs / IPC and
8
+ * call into these.
9
+ */
10
+ /**
11
+ * PTY generation gate generation gate. Returns true when WS input tagged with a stale
12
+ * `generation` must be dropped -- happens when a previous PTY's TUI sent a
13
+ * DECRQM-style query and the terminal's reply is in-flight while we
14
+ * auto-resume a new shell. `0` and `undefined` are both "no gating"
15
+ * sentinels (legacy non-WS taps, pre-init-ack queued web INPUT, and the
16
+ * daemon-IPC path when the legacy WRITE codec lacked a generation field).
17
+ */
18
+ export declare function shouldDropStaleInput(generation: number | undefined, currentGeneration: number): boolean;
19
+ /**
20
+ * Single-client flow-pause rule: pause the PTY only when exactly one
21
+ * client is attached and it is flow-paused. With multiple clients we
22
+ * never pause (one slow client must not starve the others); with none we
23
+ * never pause. `flowPausedFlags` is the `flowPaused` bit of each attached
24
+ * client.
25
+ */
26
+ export declare function shouldPauseOutputForClients(flowPausedFlags: boolean[]): boolean;
27
+ /**
28
+ * Returns true when a session that has ended may be silently re-spawned
29
+ * with the same command -- no risk of running alongside an orphaned child
30
+ * from a crashed server, and the command has no user-visible side-effects
31
+ * warranting confirmation. Safe: shell / claude with natural exit,
32
+ * signal, or graceful shutdown (server or daemon). Unsafe: any crash
33
+ * (orphan risk) or a custom command (side-effects).
34
+ */
35
+ export declare function isAutoResumable(command: SessionCommand, endReason: SessionEndReason | undefined): boolean;
36
+ /**
37
+ * Derive the WS-facing `SessionEndReason` from a node-pty exit event.
38
+ * A non-zero numeric `signal` means the child was killed by a signal;
39
+ * otherwise it exited normally with `exitCode`.
40
+ */
41
+ export declare function deriveEndReason(signal: number | undefined, exitCode: number): SessionEndReason;
42
+ /**
43
+ * End-reason to assume for a session rehydrated from `state.json` that
44
+ * carries no explicit `endReason` (crash, or pre-existing record). The
45
+ * label distinguishes the writer generation (daemon vs in-process server)
46
+ * and whether the prior shutdown was graceful.
47
+ */
48
+ export declare function deriveLoadFallbackEndReason(isDaemon: boolean, wasGracefulShutdown: boolean): SessionEndReason;
49
+ /**
50
+ * Coerce a node-pty exit event into the `SessionRecord` exit fields
51
+ * (schema: `exitCode: number | null`, `exitSignal: string | null`).
52
+ * `exitCode` is null when the child died from a signal (non-finite /
53
+ * absent code); `exitSignal` is the POSIX signal *name* (the doctor CLI
54
+ * renders it verbatim) or null when the child exited normally.
55
+ */
56
+ export declare function deriveRecordExit(exitCode: number | undefined, signal: number | undefined): {
57
+ exitCode: number | null;
58
+ exitSignal: string | null;
59
+ };
60
+ /** Map a numeric POSIX signal to its name, falling back to `SIG<n>`. */
61
+ export declare function signalName(n: number): string;
62
+ /**
63
+ * Parse the wire-side `lastSeen.seq` (decimal string, BigInt JSON
64
+ * encoding per `TerminalLastSeen`) into the BigInt the chunk ring
65
+ * compares against. Returns `undefined` for absent/malformed input so
66
+ * `readSince` falls back to "no cursor" -- the WS handler validates
67
+ * structure but a defensive parse here keeps ring lookups total.
68
+ */
69
+ export declare function parseLastSeen(lastSeen: {
70
+ generation: number;
71
+ seq: string;
72
+ } | undefined): {
73
+ generation: number;
74
+ seq: bigint;
75
+ } | undefined;
76
+ export interface ResolveSessionCommandOptions {
77
+ bashRcPath?: string;
78
+ defaultShell?: string;
79
+ }
80
+ export declare function buildRestartSeparator(now?: Date): string;
81
+ export declare function resolveSessionCommand(command: SessionCommand, options?: ResolveSessionCommandOptions): {
82
+ spawnCmd: string;
83
+ spawnArgs: string[];
84
+ };
85
+ //# sourceMappingURL=session-policy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-policy.d.ts","sourceRoot":"","sources":["../../src/pty/session-policy.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAExE;;;;;;;GAOG;AAIH;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,GAAG,SAAS,EAC9B,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAMT;AAID;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,eAAe,EAAE,OAAO,EAAE,GACzB,OAAO,CAET;AAID;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,cAAc,EACvB,SAAS,EAAE,gBAAgB,GAAG,SAAS,GACtC,OAAO,CAST;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAIlB;AAED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,OAAO,EACjB,mBAAmB,EAAE,OAAO,GAC3B,gBAAgB,CASlB;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,MAAM,EAAE,MAAM,GAAG,SAAS,GACzB;IAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CASxD;AAeD,wEAAwE;AACxE,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE5C;AAID;;;;;;GAMG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,GACxD;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAQjD;AAID,MAAM,WAAW,4BAA4B;IAC3C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,qBAAqB,CAAC,GAAG,OAAa,GAAG,MAAM,CA0C9D;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,cAAc,EACvB,OAAO,GAAE,4BAAiC,GACzC;IACD,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB,CAgBA"}
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Pure session policy & spawn-spec for the PTY hosts (Pure Core, see
3
+ * `docs/architecture.md` ). No I/O: every function here is a
4
+ * deterministic decision or derivation over its arguments, so they are
5
+ * unit-testable without spawning a real PTY. The imperative shells
6
+ * (`in-process-host.ts`, `remote-host.ts`) own node-pty / fs / IPC and
7
+ * call into these.
8
+ */
9
+ // --- Input gating -----------------------------------------------------
10
+ /**
11
+ * PTY generation gate generation gate. Returns true when WS input tagged with a stale
12
+ * `generation` must be dropped -- happens when a previous PTY's TUI sent a
13
+ * DECRQM-style query and the terminal's reply is in-flight while we
14
+ * auto-resume a new shell. `0` and `undefined` are both "no gating"
15
+ * sentinels (legacy non-WS taps, pre-init-ack queued web INPUT, and the
16
+ * daemon-IPC path when the legacy WRITE codec lacked a generation field).
17
+ */
18
+ export function shouldDropStaleInput(generation, currentGeneration) {
19
+ return (generation !== undefined &&
20
+ generation !== 0 &&
21
+ generation !== currentGeneration);
22
+ }
23
+ // --- Output flow ------------------------------------------------------
24
+ /**
25
+ * Single-client flow-pause rule: pause the PTY only when exactly one
26
+ * client is attached and it is flow-paused. With multiple clients we
27
+ * never pause (one slow client must not starve the others); with none we
28
+ * never pause. `flowPausedFlags` is the `flowPaused` bit of each attached
29
+ * client.
30
+ */
31
+ export function shouldPauseOutputForClients(flowPausedFlags) {
32
+ return flowPausedFlags.length === 1 && flowPausedFlags[0] === true;
33
+ }
34
+ // --- Lifecycle --------------------------------------------------------
35
+ /**
36
+ * Returns true when a session that has ended may be silently re-spawned
37
+ * with the same command -- no risk of running alongside an orphaned child
38
+ * from a crashed server, and the command has no user-visible side-effects
39
+ * warranting confirmation. Safe: shell / claude with natural exit,
40
+ * signal, or graceful shutdown (server or daemon). Unsafe: any crash
41
+ * (orphan risk) or a custom command (side-effects).
42
+ */
43
+ export function isAutoResumable(command, endReason) {
44
+ if (command.type !== "shell" && command.type !== "claude")
45
+ return false;
46
+ if (!endReason)
47
+ return false;
48
+ return (endReason.type === "exit" ||
49
+ endReason.type === "signal" ||
50
+ endReason.type === "server-graceful" ||
51
+ endReason.type === "daemon-graceful");
52
+ }
53
+ /**
54
+ * Derive the WS-facing `SessionEndReason` from a node-pty exit event.
55
+ * A non-zero numeric `signal` means the child was killed by a signal;
56
+ * otherwise it exited normally with `exitCode`.
57
+ */
58
+ export function deriveEndReason(signal, exitCode) {
59
+ return signal !== undefined && signal !== 0
60
+ ? { type: "signal", signal }
61
+ : { type: "exit", code: exitCode };
62
+ }
63
+ /**
64
+ * End-reason to assume for a session rehydrated from `state.json` that
65
+ * carries no explicit `endReason` (crash, or pre-existing record). The
66
+ * label distinguishes the writer generation (daemon vs in-process server)
67
+ * and whether the prior shutdown was graceful.
68
+ */
69
+ export function deriveLoadFallbackEndReason(isDaemon, wasGracefulShutdown) {
70
+ if (isDaemon) {
71
+ return wasGracefulShutdown
72
+ ? { type: "daemon-graceful" }
73
+ : { type: "daemon-crash" };
74
+ }
75
+ return wasGracefulShutdown
76
+ ? { type: "server-graceful" }
77
+ : { type: "server-crash" };
78
+ }
79
+ /**
80
+ * Coerce a node-pty exit event into the `SessionRecord` exit fields
81
+ * (schema: `exitCode: number | null`, `exitSignal: string | null`).
82
+ * `exitCode` is null when the child died from a signal (non-finite /
83
+ * absent code); `exitSignal` is the POSIX signal *name* (the doctor CLI
84
+ * renders it verbatim) or null when the child exited normally.
85
+ */
86
+ export function deriveRecordExit(exitCode, signal) {
87
+ return {
88
+ exitCode: typeof exitCode === "number" && Number.isFinite(exitCode)
89
+ ? exitCode
90
+ : null,
91
+ exitSignal: typeof signal === "number" && signal > 0 ? signalName(signal) : null,
92
+ };
93
+ }
94
+ // --- Signal naming ----------------------------------------------------
95
+ const POSIX_SIGNAL_NAMES = {
96
+ 1: "SIGHUP",
97
+ 2: "SIGINT",
98
+ 3: "SIGQUIT",
99
+ 6: "SIGABRT",
100
+ 9: "SIGKILL",
101
+ 13: "SIGPIPE",
102
+ 14: "SIGALRM",
103
+ 15: "SIGTERM",
104
+ };
105
+ /** Map a numeric POSIX signal to its name, falling back to `SIG<n>`. */
106
+ export function signalName(n) {
107
+ return POSIX_SIGNAL_NAMES[n] ?? `SIG${n}`;
108
+ }
109
+ // --- Cursor parsing ---------------------------------------------------
110
+ /**
111
+ * Parse the wire-side `lastSeen.seq` (decimal string, BigInt JSON
112
+ * encoding per `TerminalLastSeen`) into the BigInt the chunk ring
113
+ * compares against. Returns `undefined` for absent/malformed input so
114
+ * `readSince` falls back to "no cursor" -- the WS handler validates
115
+ * structure but a defensive parse here keeps ring lookups total.
116
+ */
117
+ export function parseLastSeen(lastSeen) {
118
+ if (!lastSeen)
119
+ return undefined;
120
+ if (!/^\d+$/.test(lastSeen.seq))
121
+ return undefined;
122
+ try {
123
+ return { generation: lastSeen.generation, seq: BigInt(lastSeen.seq) };
124
+ }
125
+ catch {
126
+ return undefined;
127
+ }
128
+ }
129
+ export function buildRestartSeparator(now = new Date()) {
130
+ const pad = (n) => String(n).padStart(2, "0");
131
+ const ts = `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}`;
132
+ /*
133
+ * Reset the terminal modes that a previous TUI (vim / htop / Claude
134
+ * Code CLI / etc.) may have left enabled in the replayed scrollback.
135
+ * Without this, auto-resume respawns a plain shell but the xterm
136
+ * still has e.g. mouse tracking on from the prior TUI's DECSET --
137
+ * the shell doesn't consume mouse reports, so every cursor move
138
+ * becomes stray readline input (`35;9;11M35;29;15M...`) that the
139
+ * user sees as garbage on the prompt line.
140
+ *
141
+ * Modes reset here (DEC private mode reset = CSI ? N l):
142
+ * 1 -- DECCKM application cursor (claude code etc.)
143
+ * 9 -- X10 mouse (legacy but still xterm.js-supported)
144
+ * 1000 / 1001 / 1002 / 1003 -- X11 mouse / highlight / cell-motion / all-motion
145
+ * 1004 -- focus reporting (vim / neovim / tmux arm this)
146
+ * 1005 / 1006 / 1015 / 1016 -- UTF-8 / SGR / urxvt / SGR-pixels mouse encodings
147
+ * 2004 -- bracketed paste
148
+ * 47 / 1047 / 1049 -- alternate screen (plus 1049 saves cursor)
149
+ * 25 -- cursor visibility (ensure cursor re-shown)
150
+ *
151
+ * Plus two non-DEC mode resets that DEC private reset cannot reach:
152
+ * `\x1b>` -- DECPNM: reset application keypad to numeric mode
153
+ * `\x1b[>4;0m` -- modifyOtherKeys 0: disable xterm extended key encoding.
154
+ * claude code etc. enable level 1/2 to receive Shift+Enter
155
+ * and friends as `\x1b[27;...~`; if not reset, the new
156
+ * shell sees those long literal sequences when the user
157
+ * presses arrow keys.
158
+ */
159
+ const resetModes = "\x1b[?1;9;1000;1001;1002;1003;1004;1005;1006;1015;1016l" +
160
+ "\x1b[?2004l" +
161
+ "\x1b[?47l\x1b[?1047l\x1b[?1049l" +
162
+ "\x1b[?25h" +
163
+ "\x1b>" +
164
+ "\x1b[>4;0m";
165
+ // ANSI dim (\x1b[2m) -> reset (\x1b[0m). Leading CRLF ensures the marker
166
+ // starts on its own line even if the prior output did not end with one.
167
+ return `${resetModes}\r\n\x1b[2m─── session restarted ${ts} ───\x1b[0m\r\n`;
168
+ }
169
+ export function resolveSessionCommand(command, options = {}) {
170
+ switch (command.type) {
171
+ case "shell": {
172
+ const shell = options.defaultShell ?? process.env.SHELL ?? "bash";
173
+ const args = shell.endsWith("zsh")
174
+ ? ["-o", "nopromptsp"]
175
+ : shell.endsWith("bash") && options.bashRcPath
176
+ ? ["--rcfile", options.bashRcPath, "-i"]
177
+ : [];
178
+ return { spawnCmd: shell, spawnArgs: args };
179
+ }
180
+ case "claude":
181
+ return { spawnCmd: "claude", spawnArgs: [] };
182
+ case "custom":
183
+ return { spawnCmd: command.command, spawnArgs: command.args };
184
+ }
185
+ }
186
+ //# sourceMappingURL=session-policy.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-policy.js","sourceRoot":"","sources":["../../src/pty/session-policy.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,yEAAyE;AAEzE;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,UAA8B,EAC9B,iBAAyB;IAEzB,OAAO,CACL,UAAU,KAAK,SAAS;QACxB,UAAU,KAAK,CAAC;QAChB,UAAU,KAAK,iBAAiB,CACjC,CAAC;AACJ,CAAC;AAED,yEAAyE;AAEzE;;;;;;GAMG;AACH,MAAM,UAAU,2BAA2B,CACzC,eAA0B;IAE1B,OAAO,eAAe,CAAC,MAAM,KAAK,CAAC,IAAI,eAAe,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC;AACrE,CAAC;AAED,yEAAyE;AAEzE;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAuB,EACvB,SAAuC;IAEvC,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IACxE,IAAI,CAAC,SAAS;QAAE,OAAO,KAAK,CAAC;IAC7B,OAAO,CACL,SAAS,CAAC,IAAI,KAAK,MAAM;QACzB,SAAS,CAAC,IAAI,KAAK,QAAQ;QAC3B,SAAS,CAAC,IAAI,KAAK,iBAAiB;QACpC,SAAS,CAAC,IAAI,KAAK,iBAAiB,CACrC,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,eAAe,CAC7B,MAA0B,EAC1B,QAAgB;IAEhB,OAAO,MAAM,KAA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AAuB,EACvB,UAAwC,EAAE;IAK1C,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,OAAO,CAAC,CAAC,CAAC;YACb,MAAM,KAAK,GAAG,OAAO,CAAC,YAAY,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,MAAM,CAAC;YAClE,MAAM,IAAI,GAAG,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC;gBAChC,CAAC,CAAC,CAAC,IAAI,EAAE,YAAY,CAAC;gBACtB,CAAC,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,UAAU;oBAC5C,CAAC,CAAC,CAAC,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC;oBACxC,CAAC,CAAC,EAAE,CAAC;YACT,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;QAC9C,CAAC;QACD,KAAK,QAAQ;YACX,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QAC/C,KAAK,QAAQ;YACX,OAAO,EAAE,QAAQ,EAAE,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;IAClE,CAAC;AACH,CAAC"}
@@ -0,0 +1,71 @@
1
+ import type * as net from "node:net";
2
+ import type { DaemonPaths } from "./host-daemon/paths.js";
3
+ import type { ScrollbackLog } from "./scrollback-log.js";
4
+ export interface VersionMismatchRecoveryInput {
5
+ /** The original `RemotePtyHost.connect()` rejection with
6
+ * `code === "version-mismatch"`. Its `.message` feeds the first
7
+ * stderr line and {@link parseVersionMismatch}. */
8
+ originalError: Error;
9
+ /** Resolved daemon paths -- `socketPath` for the recovery connect and
10
+ * `logFile` for the operator-facing error tails. `terminateDaemon`
11
+ * / `spawnDaemon` receive the whole struct. */
12
+ paths: DaemonPaths;
13
+ /** Server-side `PROTOCOL_VERSION` constant, surfaced on
14
+ * {@link VersionMismatchRecoveryInput.onDaemonAutoRestarted}. */
15
+ protocolVersion: string;
16
+ /** Forwarded to `connectHost` for the replacement handshake. */
17
+ scrollbackLog: ScrollbackLog | null;
18
+ /** daemon protocol mismatch recovery -- invoked once on the success path so the caller (index.ts)
19
+ * can route the upgrade notice to ServerNoticesStore. Optional so
20
+ * tests / pure callers can omit it. */
21
+ onDaemonAutoRestarted?: (detail: {
22
+ serverProtocolVersion: string;
23
+ daemonProtocolVersion: string;
24
+ }) => void;
25
+ }
26
+ export interface VersionMismatchRecoveryDeps<H> {
27
+ /** Force-terminate the running daemon. `still-alive` short-circuits
28
+ * the orchestrator with the `stop --force` guidance error. */
29
+ terminateDaemon: (paths: DaemonPaths) => Promise<{
30
+ outcome: "no-pidfile" | "already-dead" | "stopped" | "killed-after-timeout" | "still-alive";
31
+ pid: number | null;
32
+ }>;
33
+ /** Fork the replacement daemon. Wrapped error preserves the
34
+ * "terminated old daemon but failed to start replacement" wording. */
35
+ spawnDaemon: (opts: {
36
+ paths: DaemonPaths;
37
+ }) => Promise<void>;
38
+ /** Open a fresh Unix-domain socket to the replacement daemon. */
39
+ connectSocket: (socketPath: string) => Promise<net.Socket>;
40
+ /** Run the HELLO/HELLO_ACK handshake on the replacement socket. On
41
+ * rejection the orchestrator `socket.destroy()`s the recovery
42
+ * socket (try/catch wrapped -- already-errored sockets are no-ops). */
43
+ connectHost: (opts: {
44
+ socket: net.Socket;
45
+ scrollbackLog: ScrollbackLog | null;
46
+ }) => Promise<H>;
47
+ /** Extract the daemon-reported protocol version from the NACK
48
+ * message. `null` -> the callback reports `"unknown"`. */
49
+ parseVersionMismatch: (msg: string) => {
50
+ server: string;
51
+ daemon: string;
52
+ } | null;
53
+ /** Operator-facing stderr sink. Production wires `process.stderr.write`;
54
+ * tests can capture invocations to assert ordering. */
55
+ logStderr: (line: string) => void;
56
+ }
57
+ /**
58
+ * Recover from a `version-mismatch` HELLO NACK by terminating the
59
+ * incompatible daemon, spawning a fresh one, and re-running the
60
+ * handshake. Generic over the host shape so the orchestrator does not
61
+ * depend on `RemotePtyHost` directly -- the caller passes
62
+ * `connectHost: (opts) => RemotePtyHost.connect(opts)`.
63
+ *
64
+ * The four wrapped error branches surface the original `Check
65
+ * ${paths.logFile}.` tail so operators can immediately reach for the
66
+ * daemon log; the `still-alive` branch instead points at `parasor
67
+ * pty-host stop --force` since the failure is process-level, not log-
68
+ * level.
69
+ */
70
+ export declare function recoverFromVersionMismatch<H>(input: VersionMismatchRecoveryInput, deps: VersionMismatchRecoveryDeps<H>): Promise<H>;
71
+ //# sourceMappingURL=version-mismatch-recovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version-mismatch-recovery.d.ts","sourceRoot":"","sources":["../../src/pty/version-mismatch-recovery.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,UAAU,CAAC;AACrC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AA2BzD,MAAM,WAAW,4BAA4B;IAC3C;;wDAEoD;IACpD,aAAa,EAAE,KAAK,CAAC;IACrB;;oDAEgD;IAChD,KAAK,EAAE,WAAW,CAAC;IACnB;sEACkE;IAClE,eAAe,EAAE,MAAM,CAAC;IACxB,gEAAgE;IAChE,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC;;4CAEwC;IACxC,qBAAqB,CAAC,EAAE,CAAC,MAAM,EAAE;QAC/B,qBAAqB,EAAE,MAAM,CAAC;QAC9B,qBAAqB,EAAE,MAAM,CAAC;KAC/B,KAAK,IAAI,CAAC;CACZ;AAED,MAAM,WAAW,2BAA2B,CAAC,CAAC;IAC5C;mEAC+D;IAC/D,eAAe,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC;QAC/C,OAAO,EACH,YAAY,GACZ,cAAc,GACd,SAAS,GACT,sBAAsB,GACtB,aAA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