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,11 @@
1
+ import { copyFile } from "node:fs/promises";
2
+ import { type WorktreeLocalFileCandidate, type WorktreeLocalFileCopyResult } from "@parasor/shared";
3
+ export interface ListWorktreeLocalFileCandidatesDeps {
4
+ isIgnored?: (projectPath: string, relativePath: string) => Promise<boolean>;
5
+ }
6
+ export interface CopyWorktreeLocalFilesDeps extends ListWorktreeLocalFileCandidatesDeps {
7
+ copyFile?: typeof copyFile;
8
+ }
9
+ export declare function listWorktreeLocalFileCandidates(projectPath: string, deps?: ListWorktreeLocalFileCandidatesDeps): Promise<WorktreeLocalFileCandidate[]>;
10
+ export declare function copyWorktreeLocalFiles(projectPath: string, worktreePath: string, selectedPaths: unknown, deps?: CopyWorktreeLocalFilesDeps): Promise<WorktreeLocalFileCopyResult[]>;
11
+ //# sourceMappingURL=worktree-local-files.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-local-files.d.ts","sourceRoot":"","sources":["../../../src/application/workspace/worktree-local-files.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,QAAQ,EAAyB,MAAM,kBAAkB,CAAC;AAG9E,OAAO,EAEL,KAAK,0BAA0B,EAC/B,KAAK,2BAA2B,EACjC,MAAM,iBAAiB,CAAC;AAoCzB,MAAM,WAAW,mCAAmC;IAClD,SAAS,CAAC,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC7E;AAED,MAAM,WAAW,0BACf,SAAQ,mCAAmC;IAC3C,QAAQ,CAAC,EAAE,OAAO,QAAQ,CAAC;CAC5B;AAED,wBAAsB,+BAA+B,CACnD,WAAW,EAAE,MAAM,EACnB,IAAI,GAAE,mCAAwC,GAC7C,OAAO,CAAC,0BAA0B,EAAE,CAAC,CA6CvC;AAED,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,YAAY,EAAE,MAAM,EACpB,aAAa,EAAE,OAAO,EACtB,IAAI,GAAE,0BAA+B,GACpC,OAAO,CAAC,2BAA2B,EAAE,CAAC,CA2ExC"}
@@ -0,0 +1,223 @@
1
+ import { execFile } from "node:child_process";
2
+ import { constants, copyFile, lstat, mkdir, readdir } from "node:fs/promises";
3
+ import path from "node:path";
4
+ import { promisify } from "node:util";
5
+ import { normalizeWorktreeLocalFilePath, } from "@parasor/shared";
6
+ const execFileAsync = promisify(execFile);
7
+ const MAX_CANDIDATES = 200;
8
+ const MAX_SCAN_ENTRIES = 5000;
9
+ const MAX_FILE_SIZE_BYTES = 256 * 1024;
10
+ const MAX_TOTAL_COPY_BYTES = 2 * 1024 * 1024;
11
+ const EXCLUDED_DIRS = new Set([
12
+ ".git",
13
+ ".next",
14
+ ".nuxt",
15
+ ".parcel-cache",
16
+ ".svelte-kit",
17
+ ".turbo",
18
+ ".vite",
19
+ "build",
20
+ "coverage",
21
+ "dist",
22
+ "node_modules",
23
+ "target",
24
+ "tmp",
25
+ ]);
26
+ const CANDIDATE_BASENAMES = new Set([
27
+ ".env",
28
+ ".envrc",
29
+ ".npmrc",
30
+ ".nvmrc",
31
+ ".pnpmrc",
32
+ ".python-version",
33
+ ".ruby-version",
34
+ ".tool-versions",
35
+ ".yarnrc",
36
+ ".yarnrc.yml",
37
+ ]);
38
+ export async function listWorktreeLocalFileCandidates(projectPath, deps = {}) {
39
+ const candidates = [];
40
+ const isIgnored = deps.isIgnored ?? isGitIgnored;
41
+ let scanned = 0;
42
+ async function visit(dir, relDir) {
43
+ if (candidates.length >= MAX_CANDIDATES || scanned >= MAX_SCAN_ENTRIES) {
44
+ return;
45
+ }
46
+ let entries;
47
+ try {
48
+ entries = await readdir(dir, { withFileTypes: true });
49
+ }
50
+ catch {
51
+ return;
52
+ }
53
+ for (const entry of entries) {
54
+ if (candidates.length >= MAX_CANDIDATES || scanned >= MAX_SCAN_ENTRIES) {
55
+ return;
56
+ }
57
+ scanned += 1;
58
+ const rel = relDir ? `${relDir}/${entry.name}` : entry.name;
59
+ if (entry.isDirectory()) {
60
+ if (!EXCLUDED_DIRS.has(entry.name)) {
61
+ await visit(path.join(dir, entry.name), rel);
62
+ }
63
+ continue;
64
+ }
65
+ if (!entry.isFile())
66
+ continue;
67
+ if (!isLikelyLocalConfigFile(rel))
68
+ continue;
69
+ const file = await describeLocalFile(projectPath, rel, isIgnored);
70
+ if (file)
71
+ candidates.push(file);
72
+ }
73
+ }
74
+ await visit(projectPath, "");
75
+ candidates.sort((a, b) => a.path.localeCompare(b.path));
76
+ return candidates;
77
+ }
78
+ export async function copyWorktreeLocalFiles(projectPath, worktreePath, selectedPaths, deps = {}) {
79
+ const paths = normalizeSelectedPaths(selectedPaths);
80
+ const isIgnored = deps.isIgnored ?? isGitIgnored;
81
+ const copyFileImpl = deps.copyFile ?? copyFile;
82
+ const results = [];
83
+ let totalBytes = 0;
84
+ for (const { input, normalized: relativePath } of paths) {
85
+ if (!relativePath) {
86
+ results.push({
87
+ path: input,
88
+ status: "skipped",
89
+ reason: "invalid path",
90
+ });
91
+ continue;
92
+ }
93
+ const source = await describeLocalFile(projectPath, relativePath, isIgnored);
94
+ if (!source) {
95
+ results.push({
96
+ path: relativePath,
97
+ status: "skipped",
98
+ reason: "not an ignored regular file",
99
+ });
100
+ continue;
101
+ }
102
+ if (totalBytes + source.size > MAX_TOTAL_COPY_BYTES) {
103
+ results.push({
104
+ path: relativePath,
105
+ status: "skipped",
106
+ reason: "copy size limit exceeded",
107
+ size: source.size,
108
+ });
109
+ continue;
110
+ }
111
+ const from = resolveUnder(projectPath, relativePath);
112
+ const to = resolveUnder(worktreePath, relativePath);
113
+ if (!from || !to) {
114
+ results.push({
115
+ path: relativePath,
116
+ status: "skipped",
117
+ reason: "invalid path",
118
+ size: source.size,
119
+ });
120
+ continue;
121
+ }
122
+ try {
123
+ await mkdir(path.dirname(to), { recursive: true });
124
+ await copyFileImpl(from, to, constants.COPYFILE_EXCL);
125
+ totalBytes += source.size;
126
+ results.push({ ...source, status: "copied" });
127
+ }
128
+ catch (error) {
129
+ if (isNodeError(error) && error.code === "EEXIST") {
130
+ results.push({
131
+ ...source,
132
+ status: "skipped",
133
+ reason: "destination exists",
134
+ });
135
+ continue;
136
+ }
137
+ results.push({
138
+ ...source,
139
+ status: "failed",
140
+ reason: error instanceof Error ? error.message : "copy failed",
141
+ });
142
+ }
143
+ }
144
+ return results;
145
+ }
146
+ async function describeLocalFile(projectPath, relativePath, isIgnored) {
147
+ const normalized = normalizeWorktreeLocalFilePath(relativePath);
148
+ if (!normalized)
149
+ return null;
150
+ const absolutePath = resolveUnder(projectPath, normalized);
151
+ if (!absolutePath)
152
+ return null;
153
+ let info;
154
+ try {
155
+ info = await lstat(absolutePath);
156
+ }
157
+ catch {
158
+ return null;
159
+ }
160
+ if (!info.isFile() || info.isSymbolicLink())
161
+ return null;
162
+ if (info.size > MAX_FILE_SIZE_BYTES)
163
+ return null;
164
+ if (!(await isIgnored(projectPath, normalized)))
165
+ return null;
166
+ return { path: normalized, size: info.size };
167
+ }
168
+ function normalizeSelectedPaths(value) {
169
+ if (!Array.isArray(value))
170
+ return [];
171
+ const out = [];
172
+ const seen = new Set();
173
+ for (const item of value) {
174
+ if (typeof item !== "string")
175
+ continue;
176
+ const normalized = normalizeWorktreeLocalFilePath(item);
177
+ const input = item.slice(0, 500);
178
+ if (!normalized) {
179
+ out.push({ input, normalized: null });
180
+ continue;
181
+ }
182
+ if (seen.has(normalized))
183
+ continue;
184
+ seen.add(normalized);
185
+ out.push({ input, normalized });
186
+ }
187
+ return out;
188
+ }
189
+ function isLikelyLocalConfigFile(relativePath) {
190
+ const base = path.posix.basename(relativePath);
191
+ if (CANDIDATE_BASENAMES.has(base))
192
+ return true;
193
+ if (base.startsWith(".env."))
194
+ return true;
195
+ if (base.endsWith(".local"))
196
+ return true;
197
+ return false;
198
+ }
199
+ async function isGitIgnored(projectPath, relativePath) {
200
+ try {
201
+ await execFileAsync("git", ["-C", projectPath, "check-ignore", "--quiet", "--", relativePath], { timeout: 3000, maxBuffer: 1024 * 1024 });
202
+ return true;
203
+ }
204
+ catch {
205
+ return false;
206
+ }
207
+ }
208
+ function resolveUnder(root, relativePath) {
209
+ const normalized = normalizeWorktreeLocalFilePath(relativePath);
210
+ if (!normalized)
211
+ return null;
212
+ const rootPath = path.resolve(root);
213
+ const candidate = path.resolve(rootPath, ...normalized.split("/"));
214
+ const rel = path.relative(rootPath, candidate);
215
+ if (rel === "" || rel.startsWith("..") || path.isAbsolute(rel)) {
216
+ return null;
217
+ }
218
+ return candidate;
219
+ }
220
+ function isNodeError(error) {
221
+ return error instanceof Error && "code" in error;
222
+ }
223
+ //# sourceMappingURL=worktree-local-files.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-local-files.js","sourceRoot":"","sources":["../../../src/application/workspace/worktree-local-files.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EACL,8BAA8B,GAG/B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;AAE1C,MAAM,cAAc,GAAG,GAAG,CAAC;AAC3B,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAC9B,MAAM,mBAAmB,GAAG,GAAG,GAAG,IAAI,CAAC;AACvC,MAAM,oBAAoB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAC7C,MAAM,aAAa,GAAG,IAAI,GAAG,CAAC;IAC5B,MAAM;IACN,OAAO;IACP,OAAO;IACP,eAAe;IACf,aAAa;IACb,QAAQ;IACR,OAAO;IACP,OAAO;IACP,UAAU;IACV,MAAM;IACN,cAAc;IACd,QAAQ;IACR,KAAK;CACN,CAAC,CAAC;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ;IACR,SAAS;IACT,iBAAiB;IACjB,eAAe;IACf,gBAAgB;IAChB,SAAS;IACT,aAAa;CACd,CAAC,CAAC;AAWH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACnD,WAAmB,EACnB,OAA4C,EAAE;IAE9C,MAAM,UAAU,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C;QACF,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC;AAED,SAAS,YAAY,CAAC,IAAY,EAAE,YAAoB;IACtD,MAAM,UAAU,GAAG,8BAA8B,CAAC,YAAY,CAAC,CAAC;IAChE,IAAI,CAAC,UAAU;QAAE,OAAO,IAAI,CAAC;IAC7B,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;IACnE,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC;IAC/C,IAAI,GAAG,KAAK,EAAE,IAAI,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC/D,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,WAAW,CAAC,KAAc;IACjC,OAAO,KAAK,YAAY,KAAK,IAAI,MAAM,IAAI,KAAK,CAAC;AACnD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { Worktree } from "@parasor/shared";
2
+ import type { ProjectManager } from "../../state/project-manager.js";
3
+ import type { WorktreeCache } from "../../state/worktree-cache.js";
4
+ import type { EventPublisher } from "../ports.js";
5
+ export interface CreateWorktreeReconcilerDeps {
6
+ projectManager: ProjectManager;
7
+ worktreeCache: WorktreeCache;
8
+ eventBus: EventPublisher;
9
+ liveList: (projectId: string) => Promise<Worktree[] | null>;
10
+ }
11
+ export interface WorktreeReconciler {
12
+ /**
13
+ * Broadcasts cache-vs-live deltas; cache mutation happens in the broadcast
14
+ * wrapper. Pass `prefetched` when the caller has already enumerated worktrees
15
+ * in the same request -- this avoids a second `git worktree list` + N-way
16
+ * `git status` fan-out per call.
17
+ */
18
+ reconcile(projectId: string, prefetched?: Worktree[]): Promise<void>;
19
+ }
20
+ export declare function createWorktreeReconciler({ projectManager, worktreeCache, eventBus, liveList, }: CreateWorktreeReconcilerDeps): WorktreeReconciler;
21
+ //# sourceMappingURL=worktree-reconcile.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-reconcile.d.ts","sourceRoot":"","sources":["../../../src/application/workspace/worktree-reconcile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,WAAW,4BAA4B;IAC3C,cAAc,EAAE,cAAc,CAAC;IAC/B,aAAa,EAAE,aAAa,CAAC;IAC7B,QAAQ,EAAE,cAAc,CAAC;IAEzB,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,CAAC;CAC7D;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;;OAKG;IACH,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACtE;AAoBD,wBAAgB,wBAAwB,CAAC,EACvC,cAAc,EACd,aAAa,EACb,QAAQ,EACR,QAAQ,GACT,EAAE,4BAA4B,GAAG,kBAAkB,CA+BnD"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Fields whose change for an already-known path should re-broadcast a
3
+ * `worktree-created` so the client overlays fresh metadata. The reducer
4
+ * upserts by path with `{ ...prev, ...incoming }`, so re-emitting an
5
+ * existing entry is the canonical "update" channel.
6
+ */
7
+ function metaDiffers(a, b) {
8
+ return (a.head !== b.head ||
9
+ a.branch !== b.branch ||
10
+ a.ahead !== b.ahead ||
11
+ a.behind !== b.behind ||
12
+ a.dirtyCount !== b.dirtyCount ||
13
+ a.origin !== b.origin ||
14
+ Boolean(a.orphan) !== Boolean(b.orphan));
15
+ }
16
+ export function createWorktreeReconciler({ projectManager, worktreeCache, eventBus, liveList, }) {
17
+ return {
18
+ async reconcile(projectId, prefetched) {
19
+ if (!projectManager.get(projectId))
20
+ return;
21
+ const live = prefetched ?? (await liveList(projectId));
22
+ if (live === null)
23
+ return;
24
+ const cached = worktreeCache.get()[projectId] ?? [];
25
+ const livePaths = new Set(live.map((w) => w.path));
26
+ const cachedByPath = new Map(cached.map((w) => [w.path, w]));
27
+ for (const w of cached) {
28
+ if (livePaths.has(w.path))
29
+ continue;
30
+ eventBus.broadcast({
31
+ type: "worktree-removed",
32
+ projectId,
33
+ worktreePath: w.path,
34
+ });
35
+ }
36
+ for (const w of live) {
37
+ const prev = cachedByPath.get(w.path);
38
+ if (prev && !metaDiffers(prev, w))
39
+ continue;
40
+ eventBus.broadcast({
41
+ type: "worktree-created",
42
+ projectId,
43
+ worktree: w,
44
+ });
45
+ }
46
+ },
47
+ };
48
+ }
49
+ //# sourceMappingURL=worktree-reconcile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"worktree-reconcile.js","sourceRoot":"","sources":["../../../src/application/workspace/worktree-reconcile.ts"],"names":[],"mappings":"AAuBA;;;;;GAKG;AACH,SAAS,WAAW,CAAC,CAAW,EAAE,CAAW;IAC3C,OAAO,CACL,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI;QACjB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,KAAK,KAAK,CAAC,CAAC,KAAK;QACnB,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC,MAAM;QACrB,CAAC,CAAC,UAAU,KAAK,CAAC,CAAC,UAAU;QAC7B,CAAC,CA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IAAI,CAAC,CAAC;gBACtC,IAAI,IAAI,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;oBAAE,SAAS;gBAC5C,QAAQ,CAAC,SAAS,CAAC;oBACjB,IAAI,EAAE,kBAAkB;oBACxB,SAAS;oBACT,QAAQ,EAAE,CAAC;iBACZ,CAAC,CAAC;YACL,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import type { NetworkInterfaceInfo } from "node:os";
2
+ import type { MiddlewareHandler } from "hono";
3
+ export declare function normalizeOrigin(raw: string): string | null;
4
+ export declare function parseAllowedOriginsEnv(raw: string | undefined): string[];
5
+ export interface BuildAllowedOriginsOptions {
6
+ bindHost: string;
7
+ port: number;
8
+ extra: string[];
9
+ protocol?: "http" | "https";
10
+ ifaces?: Record<string, NetworkInterfaceInfo[] | undefined>;
11
+ }
12
+ export declare function buildAllowedOrigins({ bindHost, port, extra, protocol, ifaces, }: BuildAllowedOriginsOptions): Set<string>;
13
+ export interface OriginMiddlewareOptions {
14
+ allowed: Set<string>;
15
+ }
16
+ export declare function originMiddleware({ allowed, }: OriginMiddlewareOptions): MiddlewareHandler;
17
+ //# sourceMappingURL=origin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin.d.ts","sourceRoot":"","sources":["../../src/auth/origin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAE9C,wBAAgB,eAAe,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAa1D;AAED,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,EAAE,CAUxE;AAID,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,EAAE,GAAG,SAAS,CAAC,CAAC;CAC7D;AAWD,wBAAgB,mBAAmB,CAAC,EAClC,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,QAAiB,EACjB,MAAM,GACP,EAAE,0BAA0B,GAAG,GAAG,CAAC,MAAM,CAAC,CAgC1C;AAED,MAAM,WAAW,uBAAuB;IACtC,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,GACR,EAAE,uBAAuB,GAAG,iBAAiB,CAU7C"}
@@ -0,0 +1,93 @@
1
+ import { networkInterfaces } from "node:os";
2
+ export function normalizeOrigin(raw) {
3
+ try {
4
+ const url = new URL(raw);
5
+ if (url.protocol !== "http:" && url.protocol !== "https:")
6
+ return null;
7
+ const scheme = url.protocol.replace(":", "");
8
+ let host = url.hostname.toLowerCase();
9
+ if (host.includes(":") && !host.startsWith("["))
10
+ host = `[${host}]`;
11
+ const defaultPort = scheme === "http" ? "80" : "443";
12
+ const port = url.port && url.port !== defaultPort ? `:${url.port}` : "";
13
+ return `${scheme}://${host}${port}`;
14
+ }
15
+ catch {
16
+ return null;
17
+ }
18
+ }
19
+ export function parseAllowedOriginsEnv(raw) {
20
+ if (!raw)
21
+ return [];
22
+ const out = [];
23
+ for (const part of raw.split(",")) {
24
+ const trimmed = part.trim();
25
+ if (!trimmed)
26
+ continue;
27
+ const normalized = normalizeOrigin(trimmed);
28
+ if (normalized)
29
+ out.push(normalized);
30
+ }
31
+ return out;
32
+ }
33
+ const WILDCARD_HOSTS = new Set(["0.0.0.0", "::", "[::]"]);
34
+ function isIPv6LinkLocal(addr) {
35
+ return addr.toLowerCase().startsWith("fe80:");
36
+ }
37
+ function formatHost(address, family) {
38
+ if (family === "IPv6")
39
+ return `[${address}]`;
40
+ return address;
41
+ }
42
+ export function buildAllowedOrigins({ bindHost, port, extra, protocol = "http", ifaces, }) {
43
+ const set = new Set();
44
+ const add = (raw) => {
45
+ const n = normalizeOrigin(raw);
46
+ if (n)
47
+ set.add(n);
48
+ };
49
+ add(`${protocol}://127.0.0.1:${port}`);
50
+ add(`${protocol}://localhost:${port}`);
51
+ add(`${protocol}://[::1]:${port}`);
52
+ if (WILDCARD_HOSTS.has(bindHost)) {
53
+ // Wildcard bind reaches every non-internal interface address. Seed each
54
+ // into the allowlist so browser Origin headers from LAN/VPN/Tailscale
55
+ // clients are accepted without forcing users to set PARASOR_ALLOWED_ORIGINS.
56
+ const raw = ifaces ?? networkInterfaces();
57
+ for (const addrs of Object.values(raw)) {
58
+ if (!addrs)
59
+ continue;
60
+ for (const info of addrs) {
61
+ if (info.internal)
62
+ continue;
63
+ if (info.family !== "IPv4" && info.family !== "IPv6")
64
+ continue;
65
+ if (info.family === "IPv6" && isIPv6LinkLocal(info.address))
66
+ continue;
67
+ add(`${protocol}://${formatHost(info.address, info.family)}:${port}`);
68
+ }
69
+ }
70
+ }
71
+ else {
72
+ const host = bindHost.includes(":") && !bindHost.startsWith("[")
73
+ ? `[${bindHost}]`
74
+ : bindHost;
75
+ add(`${protocol}://${host}:${port}`);
76
+ }
77
+ for (const e of extra)
78
+ add(e);
79
+ return set;
80
+ }
81
+ export function originMiddleware({ allowed, }) {
82
+ return async (c, next) => {
83
+ const origin = c.req.header("origin") ?? c.req.header("Origin");
84
+ if (!origin)
85
+ return next();
86
+ const normalized = normalizeOrigin(origin);
87
+ if (!normalized || !allowed.has(normalized)) {
88
+ return c.text("Forbidden", 403);
89
+ }
90
+ return next();
91
+ };
92
+ }
93
+ //# sourceMappingURL=origin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"origin.js","sourceRoot":"","sources":["../../src/auth/origin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AA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CAAC,MAAM,CAAC,CAAC;QAC3C,IAAI,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,EAAE,CAAC;YAC5C,OAAO,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QACD,OAAO,IAAI,EAAE,CAAC;IAChB,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,28 @@
1
+ export declare const DEFAULT_PAIRING_TOKEN_TTL_MS: number;
2
+ export type PairingConsumeResult = {
3
+ ok: true;
4
+ expiresAt: number;
5
+ } | {
6
+ ok: false;
7
+ reason: "missing" | "expired" | "used";
8
+ };
9
+ export interface PairingTokenStoreOptions {
10
+ defaultTtlMs?: number;
11
+ now?: () => number;
12
+ }
13
+ export interface IssuePairingTokenOptions {
14
+ ttlMs?: number;
15
+ }
16
+ export declare class PairingTokenStore {
17
+ private readonly entries;
18
+ private readonly defaultTtlMs;
19
+ private readonly now;
20
+ constructor(opts?: PairingTokenStoreOptions);
21
+ issue(opts?: IssuePairingTokenOptions): {
22
+ token: string;
23
+ expiresAt: number;
24
+ };
25
+ consume(token: string | null | undefined): PairingConsumeResult;
26
+ private cleanupExpired;
27
+ }
28
+ //# sourceMappingURL=pairing-token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing-token.d.ts","sourceRoot":"","sources":["../../src/auth/pairing-token.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,4BAA4B,QAAgB,CAAC;AAE1D,MAAM,MAAM,oBAAoB,GAC5B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAC/B;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,MAAM,CAAA;CAAE,CAAC;AAO1D,MAAM,WAAW,wBAAwB;IACvC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAmC;IAC3D,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;gBAEvB,IAAI,GAAE,wBAA6B;IAK/C,KAAK,CAAC,IAAI,GAAE,wBAA6B,GAAG;QAC1C,KAAK,EAAE,MAAM,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;KACnB;IASD,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,oBAAoB;IAc/D,OAAO,CAAC,cAAc;CAMvB"}
@@ -0,0 +1,46 @@
1
+ import { createHash, randomBytes } from "node:crypto";
2
+ export const DEFAULT_PAIRING_TOKEN_TTL_MS = 5 * 60 * 1000;
3
+ export class PairingTokenStore {
4
+ entries = new Map();
5
+ defaultTtlMs;
6
+ now;
7
+ constructor(opts = {}) {
8
+ this.defaultTtlMs = opts.defaultTtlMs ?? DEFAULT_PAIRING_TOKEN_TTL_MS;
9
+ this.now = opts.now ?? Date.now;
10
+ }
11
+ issue(opts = {}) {
12
+ this.cleanupExpired();
13
+ const token = randomBytes(32).toString("base64url");
14
+ const ttlMs = opts.ttlMs ?? this.defaultTtlMs;
15
+ const expiresAt = this.now() + ttlMs;
16
+ this.entries.set(hashToken(token), { expiresAt, used: false });
17
+ return { token, expiresAt };
18
+ }
19
+ consume(token) {
20
+ if (!token)
21
+ return { ok: false, reason: "missing" };
22
+ const key = hashToken(token);
23
+ const entry = this.entries.get(key);
24
+ if (!entry)
25
+ return { ok: false, reason: "missing" };
26
+ if (entry.expiresAt <= this.now()) {
27
+ this.entries.delete(key);
28
+ return { ok: false, reason: "expired" };
29
+ }
30
+ if (entry.used)
31
+ return { ok: false, reason: "used" };
32
+ entry.used = true;
33
+ return { ok: true, expiresAt: entry.expiresAt };
34
+ }
35
+ cleanupExpired() {
36
+ const now = this.now();
37
+ for (const [key, entry] of this.entries) {
38
+ if (entry.expiresAt <= now)
39
+ this.entries.delete(key);
40
+ }
41
+ }
42
+ }
43
+ function hashToken(token) {
44
+ return createHash("sha256").update(token).digest("base64url");
45
+ }
46
+ //# sourceMappingURL=pairing-token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pairing-token.js","sourceRoot":"","sources":["../../src/auth/pairing-token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD,MAAM,CAAC,MAAM,4BAA4B,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC;AAoB1D,MAAM,OAAO,iBAAiB;IACX,OAAO,GAAG,IAAI,GAAG,EAAwB,CAAC;IAC1C,YAAY,CAAS;IACrB,GAAG,CAAe;IAEnC,YAAY,OAAiC,EAAE;QAC7C,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,IAAI,4BAA4B,CAAC;QACtE,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IAClC,CAAC;IAED,KAAK,CAAC,OAAiC,EAAE;QAIvC,IAAI,CAAC,cAAc,EAAE,CAAC;QACtB,MAAM,KAAK,GAAG,WAAW,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;QACpD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,CAAC;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,CAAC;QACrC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QAC/D,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;IAC9B,CAAC;IA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}
@@ -0,0 +1,11 @@
1
+ import type { MiddlewareHandler } from "hono";
2
+ import type { PairingTokenStore } from "./pairing-token.js";
3
+ import { type TokenAuth } from "./token.js";
4
+ export type TokenExchangeAuthMode = "token" | "allowlist" | "none";
5
+ export interface TokenExchangeOptions {
6
+ mode: TokenExchangeAuthMode;
7
+ tokenAuth: TokenAuth;
8
+ pairingTokens?: PairingTokenStore;
9
+ }
10
+ export declare function createTokenExchangeMiddleware({ mode, tokenAuth, pairingTokens, }: TokenExchangeOptions): MiddlewareHandler;
11
+ //# sourceMappingURL=token-exchange.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-exchange.d.ts","sourceRoot":"","sources":["../../src/auth/token-exchange.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAC9C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAwB,KAAK,SAAS,EAAE,MAAM,YAAY,CAAC;AAElE,MAAM,MAAM,qBAAqB,GAAG,OAAO,GAAG,WAAW,GAAG,MAAM,CAAC;AAEnE,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,SAAS,EAAE,SAAS,CAAC;IACrB,aAAa,CAAC,EAAE,iBAAiB,CAAC;CACnC;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,IAAI,EACJ,SAAS,EACT,aAAa,GACd,EAAE,oBAAoB,GAAG,iBAAiB,CA6B1C"}
@@ -0,0 +1,27 @@
1
+ import { setParasorAuthCookie } from "./token.js";
2
+ export function createTokenExchangeMiddleware({ mode, tokenAuth, pairingTokens, }) {
3
+ return async (c, next) => {
4
+ if (mode !== "token")
5
+ return next();
6
+ const url = new URL(c.req.url);
7
+ const token = url.searchParams.get("t");
8
+ if (!token)
9
+ return next();
10
+ if (tokenAuth.verify(token)) {
11
+ setParasorAuthCookie(c, tokenAuth.token, url);
12
+ url.searchParams.delete("t");
13
+ return c.redirect(url.pathname + (url.search || ""));
14
+ }
15
+ const pairingResult = pairingTokens?.consume(token);
16
+ if (pairingResult?.ok) {
17
+ setParasorAuthCookie(c, tokenAuth.token, url);
18
+ url.searchParams.delete("t");
19
+ return c.redirect(url.pathname + (url.search || ""));
20
+ }
21
+ if (pairingResult && pairingResult.reason !== "missing") {
22
+ return c.json({ error: "Pairing token rejected", reason: pairingResult.reason }, 401);
23
+ }
24
+ return c.json({ error: "Unauthorized" }, 401);
25
+ };
26
+ }
27
+ //# sourceMappingURL=token-exchange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token-exchange.js","sourceRoot":"","sources":["../../src/auth/token-exchange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAkB,MAAM,YAAY,CAAC;AAUlE,MAAM,UAAU,6BAA6B,CAAC,EAC5C,IAAI,EACJ,SAAS,EACT,aAAa,GACQ;IACrB,OAAO,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE;QACvB,IAAI,IAAI,KAAK,OAAO;YAAE,OAAO,IAAI,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACxC,IAAI,CAAC,KAAK;YAAE,OAAO,IAAI,EAAE,CAAC;QAE1B,IAAI,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YAC5B,oBAAoB,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC9C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC;QAED,MAAM,aAAa,GAAG,aAAa,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC;QACpD,IAAI,aAAa,EAAE,EAAE,EAAE,CAAC;YACtB,oBAAoB,CAAC,CAAC,EAAE,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC9C,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC7B,OAAO,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,GAAG,CAAC,GAAG,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC;QACvD,CAAC;QAED,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACxD,OAAO,CAAC,CAAC,IAAI,CACX,EAAE,KAAK,EAAE,wBAAwB,EAAE,MAAM,EAAE,aAAa,CAAC,MAAM,EAAE,EACjE,GAAG,CACJ,CAAC;QACJ,CAAC;QAED,OAAO,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,cAAc,EAAE,EAAE,GAAG,CAAC,CAAC;IAChD,CAAC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,18 @@
1
+ import type { Context, MiddlewareHandler } from "hono";
2
+ export declare const COOKIE_MAX_AGE_SECONDS: number;
3
+ export declare function setParasorAuthCookie(c: Context, token: string, url: URL): void;
4
+ export interface TokenAuthOpts {
5
+ dir: string;
6
+ ephemeral?: boolean;
7
+ }
8
+ export declare class TokenAuth {
9
+ readonly token: string;
10
+ private readonly tokenPath;
11
+ constructor(opts: TokenAuthOpts);
12
+ verify(candidate: string): boolean;
13
+ extractToken(search: string, cookieHeader: string | undefined): string | null;
14
+ middleware(mode: "token" | "allowlist" | "none", allowedCidrs?: string[], trustProxy?: boolean): MiddlewareHandler;
15
+ private loadOrGenerate;
16
+ private generate;
17
+ }
18
+ //# sourceMappingURL=token.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../src/auth/token.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,OAAO,EAAE,iBAAiB,EAAE,MAAM,MAAM,CAAC;AAGvD,eAAO,MAAM,sBAAsB,QAAoB,CAAC;AAExD,wBAAgB,oBAAoB,CAClC,CAAC,EAAE,OAAO,EACV,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,GAAG,GACP,IAAI,CAQN;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,qBAAa,SAAS;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;gBAEvB,IAAI,EAAE,aAAa;IAK/B,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO;IAOlC,YAAY,CACV,MAAM,EAAE,MAAM,EACd,YAAY,EAAE,MAAM,GAAG,SAAS,GAC/B,MAAM,GAAG,IAAI;IAchB,UAAU,CACR,IAAI,EAAE,OAAO,GAAG,WAAW,GAAG,MAAM,EACpC,YAAY,CAAC,EAAE,MAAM,EAAE,EACvB,UAAU,UAAQ,GACjB,iBAAiB;IAmDpB,OAAO,CAAC,cAAc;IAUtB,OAAO,CAAC,QAAQ;CAQjB"}