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.
- package/LICENSE +21 -0
- package/README.md +208 -0
- package/THIRD-PARTY-NOTICES.md +138 -0
- package/bin/parasor.mjs +3 -0
- package/node_modules/@parasor/shared/dist/client.d.ts +8 -0
- package/node_modules/@parasor/shared/dist/client.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/client.js +2 -0
- package/node_modules/@parasor/shared/dist/client.js.map +1 -0
- package/node_modules/@parasor/shared/dist/drops.d.ts +24 -0
- package/node_modules/@parasor/shared/dist/drops.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/drops.js +2 -0
- package/node_modules/@parasor/shared/dist/drops.js.map +1 -0
- package/node_modules/@parasor/shared/dist/file-uploads.d.ts +56 -0
- package/node_modules/@parasor/shared/dist/file-uploads.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/file-uploads.js +13 -0
- package/node_modules/@parasor/shared/dist/file-uploads.js.map +1 -0
- package/node_modules/@parasor/shared/dist/ide-commands.d.ts +8 -0
- package/node_modules/@parasor/shared/dist/ide-commands.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/ide-commands.js +59 -0
- package/node_modules/@parasor/shared/dist/ide-commands.js.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-commands.d.ts +7 -0
- package/node_modules/@parasor/shared/dist/pane-commands.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-commands.js +47 -0
- package/node_modules/@parasor/shared/dist/pane-commands.js.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-model.d.ts +63 -0
- package/node_modules/@parasor/shared/dist/pane-model.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/pane-model.js +89 -0
- package/node_modules/@parasor/shared/dist/pane-model.js.map +1 -0
- package/node_modules/@parasor/shared/dist/panes.d.ts +33 -0
- package/node_modules/@parasor/shared/dist/panes.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/panes.js +2 -0
- package/node_modules/@parasor/shared/dist/panes.js.map +1 -0
- package/node_modules/@parasor/shared/dist/runtime.d.ts +180 -0
- package/node_modules/@parasor/shared/dist/runtime.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/runtime.js +2 -0
- package/node_modules/@parasor/shared/dist/runtime.js.map +1 -0
- package/node_modules/@parasor/shared/dist/state.d.ts +192 -0
- package/node_modules/@parasor/shared/dist/state.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/state.js +10 -0
- package/node_modules/@parasor/shared/dist/state.js.map +1 -0
- package/node_modules/@parasor/shared/dist/terminal.d.ts +191 -0
- package/node_modules/@parasor/shared/dist/terminal.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/terminal.js +174 -0
- package/node_modules/@parasor/shared/dist/terminal.js.map +1 -0
- package/node_modules/@parasor/shared/dist/types.d.ts +13 -0
- package/node_modules/@parasor/shared/dist/types.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/types.js +13 -0
- package/node_modules/@parasor/shared/dist/types.js.map +1 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.d.ts +14 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.js +41 -0
- package/node_modules/@parasor/shared/dist/worktree-local-files.js.map +1 -0
- package/node_modules/@parasor/shared/dist/ws-events.d.ts +152 -0
- package/node_modules/@parasor/shared/dist/ws-events.d.ts.map +1 -0
- package/node_modules/@parasor/shared/dist/ws-events.js +2 -0
- package/node_modules/@parasor/shared/dist/ws-events.js.map +1 -0
- package/node_modules/@parasor/shared/package.json +13 -0
- package/package.json +61 -0
- package/server/agent-detector/agent-state-store.d.ts +23 -0
- package/server/agent-detector/agent-state-store.d.ts.map +1 -0
- package/server/agent-detector/agent-state-store.js +110 -0
- package/server/agent-detector/agent-state-store.js.map +1 -0
- package/server/agent-detector/detector.d.ts +80 -0
- package/server/agent-detector/detector.d.ts.map +1 -0
- package/server/agent-detector/detector.js +219 -0
- package/server/agent-detector/detector.js.map +1 -0
- package/server/agent-detector/event-map.d.ts +25 -0
- package/server/agent-detector/event-map.d.ts.map +1 -0
- package/server/agent-detector/event-map.js +136 -0
- package/server/agent-detector/event-map.js.map +1 -0
- package/server/agent-detector/manual-agent-tracker.d.ts +19 -0
- package/server/agent-detector/manual-agent-tracker.d.ts.map +1 -0
- package/server/agent-detector/manual-agent-tracker.js +123 -0
- package/server/agent-detector/manual-agent-tracker.js.map +1 -0
- package/server/agent-detector/output-eligibility.d.ts +3 -0
- package/server/agent-detector/output-eligibility.d.ts.map +1 -0
- package/server/agent-detector/output-eligibility.js +39 -0
- package/server/agent-detector/output-eligibility.js.map +1 -0
- package/server/application/files/errors.d.ts +28 -0
- package/server/application/files/errors.d.ts.map +1 -0
- package/server/application/files/errors.js +55 -0
- package/server/application/files/errors.js.map +1 -0
- package/server/application/files/local-filesystem.d.ts +36 -0
- package/server/application/files/local-filesystem.d.ts.map +1 -0
- package/server/application/files/local-filesystem.js +171 -0
- package/server/application/files/local-filesystem.js.map +1 -0
- package/server/application/files/project-file-queries.d.ts +16 -0
- package/server/application/files/project-file-queries.d.ts.map +1 -0
- package/server/application/files/project-file-queries.js +126 -0
- package/server/application/files/project-file-queries.js.map +1 -0
- package/server/application/integrations/errors.d.ts +16 -0
- package/server/application/integrations/errors.d.ts.map +1 -0
- package/server/application/integrations/errors.js +31 -0
- package/server/application/integrations/errors.js.map +1 -0
- package/server/application/integrations/hook-notify.d.ts +32 -0
- package/server/application/integrations/hook-notify.d.ts.map +1 -0
- package/server/application/integrations/hook-notify.js +118 -0
- package/server/application/integrations/hook-notify.js.map +1 -0
- package/server/application/integrations/open-url.d.ts +11 -0
- package/server/application/integrations/open-url.d.ts.map +1 -0
- package/server/application/integrations/open-url.js +23 -0
- package/server/application/integrations/open-url.js.map +1 -0
- package/server/application/ports.d.ts +11 -0
- package/server/application/ports.d.ts.map +1 -0
- package/server/application/ports.js +2 -0
- package/server/application/ports.js.map +1 -0
- package/server/application/workspace/errors.d.ts +21 -0
- package/server/application/workspace/errors.d.ts.map +1 -0
- package/server/application/workspace/errors.js +21 -0
- package/server/application/workspace/errors.js.map +1 -0
- package/server/application/workspace/pane-commands.d.ts +47 -0
- package/server/application/workspace/pane-commands.d.ts.map +1 -0
- package/server/application/workspace/pane-commands.js +193 -0
- package/server/application/workspace/pane-commands.js.map +1 -0
- package/server/application/workspace/project-commands.d.ts +34 -0
- package/server/application/workspace/project-commands.d.ts.map +1 -0
- package/server/application/workspace/project-commands.js +81 -0
- package/server/application/workspace/project-commands.js.map +1 -0
- package/server/application/workspace/project-queries.d.ts +21 -0
- package/server/application/workspace/project-queries.d.ts.map +1 -0
- package/server/application/workspace/project-queries.js +216 -0
- package/server/application/workspace/project-queries.js.map +1 -0
- package/server/application/workspace/session-commands.d.ts +24 -0
- package/server/application/workspace/session-commands.d.ts.map +1 -0
- package/server/application/workspace/session-commands.js +123 -0
- package/server/application/workspace/session-commands.js.map +1 -0
- package/server/application/workspace/session-queries.d.ts +14 -0
- package/server/application/workspace/session-queries.d.ts.map +1 -0
- package/server/application/workspace/session-queries.js +47 -0
- package/server/application/workspace/session-queries.js.map +1 -0
- package/server/application/workspace/worktree-commands.d.ts +98 -0
- package/server/application/workspace/worktree-commands.d.ts.map +1 -0
- package/server/application/workspace/worktree-commands.js +323 -0
- package/server/application/workspace/worktree-commands.js.map +1 -0
- package/server/application/workspace/worktree-local-files.d.ts +11 -0
- package/server/application/workspace/worktree-local-files.d.ts.map +1 -0
- package/server/application/workspace/worktree-local-files.js +223 -0
- package/server/application/workspace/worktree-local-files.js.map +1 -0
- package/server/application/workspace/worktree-reconcile.d.ts +21 -0
- package/server/application/workspace/worktree-reconcile.d.ts.map +1 -0
- package/server/application/workspace/worktree-reconcile.js +49 -0
- package/server/application/workspace/worktree-reconcile.js.map +1 -0
- package/server/auth/origin.d.ts +17 -0
- package/server/auth/origin.d.ts.map +1 -0
- package/server/auth/origin.js +93 -0
- package/server/auth/origin.js.map +1 -0
- package/server/auth/pairing-token.d.ts +28 -0
- package/server/auth/pairing-token.d.ts.map +1 -0
- package/server/auth/pairing-token.js +46 -0
- package/server/auth/pairing-token.js.map +1 -0
- package/server/auth/token-exchange.d.ts +11 -0
- package/server/auth/token-exchange.d.ts.map +1 -0
- package/server/auth/token-exchange.js +27 -0
- package/server/auth/token-exchange.js.map +1 -0
- package/server/auth/token.d.ts +18 -0
- package/server/auth/token.d.ts.map +1 -0
- package/server/auth/token.js +115 -0
- package/server/auth/token.js.map +1 -0
- package/server/bootstrap/create-app-server.d.ts +49 -0
- package/server/bootstrap/create-app-server.d.ts.map +1 -0
- package/server/bootstrap/create-app-server.js +154 -0
- package/server/bootstrap/create-app-server.js.map +1 -0
- package/server/bootstrap/project-runtime.d.ts +29 -0
- package/server/bootstrap/project-runtime.d.ts.map +1 -0
- package/server/bootstrap/project-runtime.js +253 -0
- package/server/bootstrap/project-runtime.js.map +1 -0
- package/server/bootstrap/pty-env.d.ts +3 -0
- package/server/bootstrap/pty-env.d.ts.map +1 -0
- package/server/bootstrap/pty-env.js +15 -0
- package/server/bootstrap/pty-env.js.map +1 -0
- package/server/bootstrap/reconcile-state.d.ts +16 -0
- package/server/bootstrap/reconcile-state.d.ts.map +1 -0
- package/server/bootstrap/reconcile-state.js +73 -0
- package/server/bootstrap/reconcile-state.js.map +1 -0
- package/server/bootstrap/runtime-loops.d.ts +51 -0
- package/server/bootstrap/runtime-loops.d.ts.map +1 -0
- package/server/bootstrap/runtime-loops.js +189 -0
- package/server/bootstrap/runtime-loops.js.map +1 -0
- package/server/bootstrap/runtime-port.d.ts +4 -0
- package/server/bootstrap/runtime-port.d.ts.map +1 -0
- package/server/bootstrap/runtime-port.js +52 -0
- package/server/bootstrap/runtime-port.js.map +1 -0
- package/server/bootstrap/safety-gate.d.ts +22 -0
- package/server/bootstrap/safety-gate.d.ts.map +1 -0
- package/server/bootstrap/safety-gate.js +43 -0
- package/server/bootstrap/safety-gate.js.map +1 -0
- package/server/bootstrap/shutdown-marker.d.ts +35 -0
- package/server/bootstrap/shutdown-marker.d.ts.map +1 -0
- package/server/bootstrap/shutdown-marker.js +100 -0
- package/server/bootstrap/shutdown-marker.js.map +1 -0
- package/server/bootstrap/shutdown-runtime.d.ts +62 -0
- package/server/bootstrap/shutdown-runtime.d.ts.map +1 -0
- package/server/bootstrap/shutdown-runtime.js +66 -0
- package/server/bootstrap/shutdown-runtime.js.map +1 -0
- package/server/bootstrap/startup-banner.d.ts +34 -0
- package/server/bootstrap/startup-banner.d.ts.map +1 -0
- package/server/bootstrap/startup-banner.js +114 -0
- package/server/bootstrap/startup-banner.js.map +1 -0
- package/server/bootstrap/wire-runtime.d.ts +42 -0
- package/server/bootstrap/wire-runtime.d.ts.map +1 -0
- package/server/bootstrap/wire-runtime.js +205 -0
- package/server/bootstrap/wire-runtime.js.map +1 -0
- package/server/cli/help.d.ts +3 -0
- package/server/cli/help.d.ts.map +1 -0
- package/server/cli/help.js +39 -0
- package/server/cli/help.js.map +1 -0
- package/server/cli/hook-client.d.ts +12 -0
- package/server/cli/hook-client.d.ts.map +1 -0
- package/server/cli/hook-client.js +81 -0
- package/server/cli/hook-client.js.map +1 -0
- package/server/cli/hook.d.ts +3 -0
- package/server/cli/hook.d.ts.map +1 -0
- package/server/cli/hook.js +152 -0
- package/server/cli/hook.js.map +1 -0
- package/server/cli/main.d.ts +2 -0
- package/server/cli/main.d.ts.map +1 -0
- package/server/cli/main.js +133 -0
- package/server/cli/main.js.map +1 -0
- package/server/cli/notify.d.ts +19 -0
- package/server/cli/notify.d.ts.map +1 -0
- package/server/cli/notify.js +77 -0
- package/server/cli/notify.js.map +1 -0
- package/server/cli/open.d.ts +2 -0
- package/server/cli/open.d.ts.map +1 -0
- package/server/cli/open.js +47 -0
- package/server/cli/open.js.map +1 -0
- package/server/cli/probe-daemon-version.d.ts +46 -0
- package/server/cli/probe-daemon-version.d.ts.map +1 -0
- package/server/cli/probe-daemon-version.js +167 -0
- package/server/cli/probe-daemon-version.js.map +1 -0
- package/server/cli/pty-host.d.ts +36 -0
- package/server/cli/pty-host.d.ts.map +1 -0
- package/server/cli/pty-host.js +390 -0
- package/server/cli/pty-host.js.map +1 -0
- package/server/cli/qr.d.ts +2 -0
- package/server/cli/qr.d.ts.map +1 -0
- package/server/cli/qr.js +70 -0
- package/server/cli/qr.js.map +1 -0
- package/server/cli/restart-confirm.d.ts +33 -0
- package/server/cli/restart-confirm.d.ts.map +1 -0
- package/server/cli/restart-confirm.js +107 -0
- package/server/cli/restart-confirm.js.map +1 -0
- package/server/cli/restart.d.ts +17 -0
- package/server/cli/restart.d.ts.map +1 -0
- package/server/cli/restart.js +145 -0
- package/server/cli/restart.js.map +1 -0
- package/server/cli/service-darwin.d.ts +70 -0
- package/server/cli/service-darwin.d.ts.map +1 -0
- package/server/cli/service-darwin.js +562 -0
- package/server/cli/service-darwin.js.map +1 -0
- package/server/cli/service-linux.d.ts +81 -0
- package/server/cli/service-linux.d.ts.map +1 -0
- package/server/cli/service-linux.js +412 -0
- package/server/cli/service-linux.js.map +1 -0
- package/server/cli/service.d.ts +33 -0
- package/server/cli/service.d.ts.map +1 -0
- package/server/cli/service.js +133 -0
- package/server/cli/service.js.map +1 -0
- package/server/cli/shim-installer.d.ts +35 -0
- package/server/cli/shim-installer.d.ts.map +1 -0
- package/server/cli/shim-installer.js +662 -0
- package/server/cli/shim-installer.js.map +1 -0
- package/server/cli/shim-open.d.ts +2 -0
- package/server/cli/shim-open.d.ts.map +1 -0
- package/server/cli/shim-open.js +128 -0
- package/server/cli/shim-open.js.map +1 -0
- package/server/cli/shutdown-deps.d.ts +41 -0
- package/server/cli/shutdown-deps.d.ts.map +1 -0
- package/server/cli/shutdown-deps.js +158 -0
- package/server/cli/shutdown-deps.js.map +1 -0
- package/server/cli/stop.d.ts +11 -0
- package/server/cli/stop.d.ts.map +1 -0
- package/server/cli/stop.js +123 -0
- package/server/cli/stop.js.map +1 -0
- package/server/cli/unknown-command.d.ts +8 -0
- package/server/cli/unknown-command.d.ts.map +1 -0
- package/server/cli/unknown-command.js +14 -0
- package/server/cli/unknown-command.js.map +1 -0
- package/server/debug/agent-status-recorder.d.ts +57 -0
- package/server/debug/agent-status-recorder.d.ts.map +1 -0
- package/server/debug/agent-status-recorder.js +209 -0
- package/server/debug/agent-status-recorder.js.map +1 -0
- package/server/debug/terminal-trace-recorder.d.ts +41 -0
- package/server/debug/terminal-trace-recorder.d.ts.map +1 -0
- package/server/debug/terminal-trace-recorder.js +112 -0
- package/server/debug/terminal-trace-recorder.js.map +1 -0
- package/server/fonts/catalog.d.ts +35 -0
- package/server/fonts/catalog.d.ts.map +1 -0
- package/server/fonts/catalog.js +76 -0
- package/server/fonts/catalog.js.map +1 -0
- package/server/fonts/installer.d.ts +45 -0
- package/server/fonts/installer.d.ts.map +1 -0
- package/server/fonts/installer.js +201 -0
- package/server/fonts/installer.js.map +1 -0
- package/server/fonts/routes.d.ts +4 -0
- package/server/fonts/routes.d.ts.map +1 -0
- package/server/fonts/routes.js +91 -0
- package/server/fonts/routes.js.map +1 -0
- package/server/fs/drops.d.ts +50 -0
- package/server/fs/drops.d.ts.map +1 -0
- package/server/fs/drops.js +137 -0
- package/server/fs/drops.js.map +1 -0
- package/server/fs/file-uploads.d.ts +57 -0
- package/server/fs/file-uploads.d.ts.map +1 -0
- package/server/fs/file-uploads.js +214 -0
- package/server/fs/file-uploads.js.map +1 -0
- package/server/fs/file-watcher.d.ts +22 -0
- package/server/fs/file-watcher.d.ts.map +1 -0
- package/server/fs/file-watcher.js +105 -0
- package/server/fs/file-watcher.js.map +1 -0
- package/server/fs/git-watcher.d.ts +76 -0
- package/server/fs/git-watcher.d.ts.map +1 -0
- package/server/fs/git-watcher.js +356 -0
- package/server/fs/git-watcher.js.map +1 -0
- package/server/fs/media.d.ts +35 -0
- package/server/fs/media.d.ts.map +1 -0
- package/server/fs/media.js +271 -0
- package/server/fs/media.js.map +1 -0
- package/server/fs/service.d.ts +97 -0
- package/server/fs/service.d.ts.map +1 -0
- package/server/fs/service.js +306 -0
- package/server/fs/service.js.map +1 -0
- package/server/fs/upload-staging.d.ts +76 -0
- package/server/fs/upload-staging.d.ts.map +1 -0
- package/server/fs/upload-staging.js +283 -0
- package/server/fs/upload-staging.js.map +1 -0
- package/server/fs/watcher-lifecycle.d.ts +24 -0
- package/server/fs/watcher-lifecycle.d.ts.map +1 -0
- package/server/fs/watcher-lifecycle.js +105 -0
- package/server/fs/watcher-lifecycle.js.map +1 -0
- package/server/index.d.ts +17 -0
- package/server/index.d.ts.map +1 -0
- package/server/index.js +510 -0
- package/server/index.js.map +1 -0
- package/server/ipc/socket-server.d.ts +28 -0
- package/server/ipc/socket-server.d.ts.map +1 -0
- package/server/ipc/socket-server.js +206 -0
- package/server/ipc/socket-server.js.map +1 -0
- package/server/lib/git-exec.d.ts +38 -0
- package/server/lib/git-exec.d.ts.map +1 -0
- package/server/lib/git-exec.js +96 -0
- package/server/lib/git-exec.js.map +1 -0
- package/server/lib/open-in-ide.d.ts +22 -0
- package/server/lib/open-in-ide.d.ts.map +1 -0
- package/server/lib/open-in-ide.js +90 -0
- package/server/lib/open-in-ide.js.map +1 -0
- package/server/lib/open-in-os.d.ts +20 -0
- package/server/lib/open-in-os.d.ts.map +1 -0
- package/server/lib/open-in-os.js +51 -0
- package/server/lib/open-in-os.js.map +1 -0
- package/server/lib/path.d.ts +2 -0
- package/server/lib/path.d.ts.map +1 -0
- package/server/lib/path.js +10 -0
- package/server/lib/path.js.map +1 -0
- package/server/lib/promise-mutex.d.ts +7 -0
- package/server/lib/promise-mutex.d.ts.map +1 -0
- package/server/lib/promise-mutex.js +26 -0
- package/server/lib/promise-mutex.js.map +1 -0
- package/server/lib/sd-notify.d.ts +8 -0
- package/server/lib/sd-notify.d.ts.map +1 -0
- package/server/lib/sd-notify.js +27 -0
- package/server/lib/sd-notify.js.map +1 -0
- package/server/net/local-machine.d.ts +7 -0
- package/server/net/local-machine.d.ts.map +1 -0
- package/server/net/local-machine.js +79 -0
- package/server/net/local-machine.js.map +1 -0
- package/server/net/reachable-host.d.ts +12 -0
- package/server/net/reachable-host.d.ts.map +1 -0
- package/server/net/reachable-host.js +25 -0
- package/server/net/reachable-host.js.map +1 -0
- package/server/network/endpoints.d.ts +14 -0
- package/server/network/endpoints.d.ts.map +1 -0
- package/server/network/endpoints.js +104 -0
- package/server/network/endpoints.js.map +1 -0
- package/server/network/qr.d.ts +16 -0
- package/server/network/qr.d.ts.map +1 -0
- package/server/network/qr.js +89 -0
- package/server/network/qr.js.map +1 -0
- package/server/port-forwarder/forwarder.d.ts +47 -0
- package/server/port-forwarder/forwarder.d.ts.map +1 -0
- package/server/port-forwarder/forwarder.js +159 -0
- package/server/port-forwarder/forwarder.js.map +1 -0
- package/server/port-scanner/scanner.d.ts +24 -0
- package/server/port-scanner/scanner.d.ts.map +1 -0
- package/server/port-scanner/scanner.js +193 -0
- package/server/port-scanner/scanner.js.map +1 -0
- package/server/pty/connection-lifecycle.d.ts +50 -0
- package/server/pty/connection-lifecycle.d.ts.map +1 -0
- package/server/pty/connection-lifecycle.js +113 -0
- package/server/pty/connection-lifecycle.js.map +1 -0
- package/server/pty/daemon-connect.d.ts +52 -0
- package/server/pty/daemon-connect.d.ts.map +1 -0
- package/server/pty/daemon-connect.js +62 -0
- package/server/pty/daemon-connect.js.map +1 -0
- package/server/pty/handshake-timeout-race.d.ts +22 -0
- package/server/pty/handshake-timeout-race.d.ts.map +1 -0
- package/server/pty/handshake-timeout-race.js +23 -0
- package/server/pty/handshake-timeout-race.js.map +1 -0
- package/server/pty/headless-replay-snapshot.d.ts +28 -0
- package/server/pty/headless-replay-snapshot.d.ts.map +1 -0
- package/server/pty/headless-replay-snapshot.js +285 -0
- package/server/pty/headless-replay-snapshot.js.map +1 -0
- package/server/pty/headless-terminal-state-cache.d.ts +31 -0
- package/server/pty/headless-terminal-state-cache.d.ts.map +1 -0
- package/server/pty/headless-terminal-state-cache.js +119 -0
- package/server/pty/headless-terminal-state-cache.js.map +1 -0
- package/server/pty/hello-ack-validator.d.ts +15 -0
- package/server/pty/hello-ack-validator.d.ts.map +1 -0
- package/server/pty/hello-ack-validator.js +30 -0
- package/server/pty/hello-ack-validator.js.map +1 -0
- package/server/pty/host-daemon/bootstrap.d.ts +100 -0
- package/server/pty/host-daemon/bootstrap.d.ts.map +1 -0
- package/server/pty/host-daemon/bootstrap.js +611 -0
- package/server/pty/host-daemon/bootstrap.js.map +1 -0
- package/server/pty/host-daemon/daemon.d.ts +111 -0
- package/server/pty/host-daemon/daemon.d.ts.map +1 -0
- package/server/pty/host-daemon/daemon.js +648 -0
- package/server/pty/host-daemon/daemon.js.map +1 -0
- package/server/pty/host-daemon/entry.d.ts +3 -0
- package/server/pty/host-daemon/entry.d.ts.map +1 -0
- package/server/pty/host-daemon/entry.js +72 -0
- package/server/pty/host-daemon/entry.js.map +1 -0
- package/server/pty/host-daemon/lockfile.d.ts +12 -0
- package/server/pty/host-daemon/lockfile.d.ts.map +1 -0
- package/server/pty/host-daemon/lockfile.js +120 -0
- package/server/pty/host-daemon/lockfile.js.map +1 -0
- package/server/pty/host-daemon/mode-marker.d.ts +77 -0
- package/server/pty/host-daemon/mode-marker.d.ts.map +1 -0
- package/server/pty/host-daemon/mode-marker.js +228 -0
- package/server/pty/host-daemon/mode-marker.js.map +1 -0
- package/server/pty/host-daemon/orphan-cleanup.d.ts +42 -0
- package/server/pty/host-daemon/orphan-cleanup.d.ts.map +1 -0
- package/server/pty/host-daemon/orphan-cleanup.js +84 -0
- package/server/pty/host-daemon/orphan-cleanup.js.map +1 -0
- package/server/pty/host-daemon/paths.d.ts +10 -0
- package/server/pty/host-daemon/paths.d.ts.map +1 -0
- package/server/pty/host-daemon/paths.js +56 -0
- package/server/pty/host-daemon/paths.js.map +1 -0
- package/server/pty/host-daemon/server-connection.d.ts +44 -0
- package/server/pty/host-daemon/server-connection.d.ts.map +1 -0
- package/server/pty/host-daemon/server-connection.js +100 -0
- package/server/pty/host-daemon/server-connection.js.map +1 -0
- package/server/pty/host-daemon/service-detection.d.ts +24 -0
- package/server/pty/host-daemon/service-detection.d.ts.map +1 -0
- package/server/pty/host-daemon/service-detection.js +16 -0
- package/server/pty/host-daemon/service-detection.js.map +1 -0
- package/server/pty/host-daemon/socket-ready.d.ts +22 -0
- package/server/pty/host-daemon/socket-ready.d.ts.map +1 -0
- package/server/pty/host-daemon/socket-ready.js +33 -0
- package/server/pty/host-daemon/socket-ready.js.map +1 -0
- package/server/pty/host-daemon/spawn-daemon.d.ts +45 -0
- package/server/pty/host-daemon/spawn-daemon.d.ts.map +1 -0
- package/server/pty/host-daemon/spawn-daemon.js +155 -0
- package/server/pty/host-daemon/spawn-daemon.js.map +1 -0
- package/server/pty/host-daemon/terminate-daemon.d.ts +16 -0
- package/server/pty/host-daemon/terminate-daemon.d.ts.map +1 -0
- package/server/pty/host-daemon/terminate-daemon.js +128 -0
- package/server/pty/host-daemon/terminate-daemon.js.map +1 -0
- package/server/pty/host-protocol/frames.d.ts +110 -0
- package/server/pty/host-protocol/frames.d.ts.map +1 -0
- package/server/pty/host-protocol/frames.js +255 -0
- package/server/pty/host-protocol/frames.js.map +1 -0
- package/server/pty/host-protocol/messages.d.ts +140 -0
- package/server/pty/host-protocol/messages.d.ts.map +1 -0
- package/server/pty/host-protocol/messages.js +117 -0
- package/server/pty/host-protocol/messages.js.map +1 -0
- package/server/pty/host.d.ts +273 -0
- package/server/pty/host.d.ts.map +1 -0
- package/server/pty/host.js +184 -0
- package/server/pty/host.js.map +1 -0
- package/server/pty/in-process-host.d.ts +224 -0
- package/server/pty/in-process-host.d.ts.map +1 -0
- package/server/pty/in-process-host.js +1183 -0
- package/server/pty/in-process-host.js.map +1 -0
- package/server/pty/osc7-lifecycle.d.ts +8 -0
- package/server/pty/osc7-lifecycle.d.ts.map +1 -0
- package/server/pty/osc7-lifecycle.js +22 -0
- package/server/pty/osc7-lifecycle.js.map +1 -0
- package/server/pty/osc7-parser.d.ts +23 -0
- package/server/pty/osc7-parser.d.ts.map +1 -0
- package/server/pty/osc7-parser.js +91 -0
- package/server/pty/osc7-parser.js.map +1 -0
- package/server/pty/remote-host.d.ts +188 -0
- package/server/pty/remote-host.d.ts.map +1 -0
- package/server/pty/remote-host.js +810 -0
- package/server/pty/remote-host.js.map +1 -0
- package/server/pty/request-correlator.d.ts +59 -0
- package/server/pty/request-correlator.d.ts.map +1 -0
- package/server/pty/request-correlator.js +75 -0
- package/server/pty/request-correlator.js.map +1 -0
- package/server/pty/scrollback-log.d.ts +130 -0
- package/server/pty/scrollback-log.d.ts.map +1 -0
- package/server/pty/scrollback-log.js +344 -0
- package/server/pty/scrollback-log.js.map +1 -0
- package/server/pty/scrollback-sanitize.d.ts +2 -0
- package/server/pty/scrollback-sanitize.d.ts.map +1 -0
- package/server/pty/scrollback-sanitize.js +54 -0
- package/server/pty/scrollback-sanitize.js.map +1 -0
- package/server/pty/session-mirror.d.ts +67 -0
- package/server/pty/session-mirror.d.ts.map +1 -0
- package/server/pty/session-mirror.js +112 -0
- package/server/pty/session-mirror.js.map +1 -0
- package/server/pty/session-policy.d.ts +85 -0
- package/server/pty/session-policy.d.ts.map +1 -0
- package/server/pty/session-policy.js +186 -0
- package/server/pty/session-policy.js.map +1 -0
- package/server/pty/version-mismatch-recovery.d.ts +71 -0
- package/server/pty/version-mismatch-recovery.d.ts.map +1 -0
- package/server/pty/version-mismatch-recovery.js +63 -0
- package/server/pty/version-mismatch-recovery.js.map +1 -0
- package/server/routes/debug-agent-status.d.ts +5 -0
- package/server/routes/debug-agent-status.d.ts.map +1 -0
- package/server/routes/debug-agent-status.js +22 -0
- package/server/routes/debug-agent-status.js.map +1 -0
- package/server/routes/debug-diagnostics.d.ts +8 -0
- package/server/routes/debug-diagnostics.d.ts.map +1 -0
- package/server/routes/debug-diagnostics.js +34 -0
- package/server/routes/debug-diagnostics.js.map +1 -0
- package/server/routes/debug-terminal-trace.d.ts +16 -0
- package/server/routes/debug-terminal-trace.d.ts.map +1 -0
- package/server/routes/debug-terminal-trace.js +545 -0
- package/server/routes/debug-terminal-trace.js.map +1 -0
- package/server/routes/drops.d.ts +13 -0
- package/server/routes/drops.d.ts.map +1 -0
- package/server/routes/drops.js +126 -0
- package/server/routes/drops.js.map +1 -0
- package/server/routes/file-uploads.d.ts +9 -0
- package/server/routes/file-uploads.d.ts.map +1 -0
- package/server/routes/file-uploads.js +119 -0
- package/server/routes/file-uploads.js.map +1 -0
- package/server/routes/files.d.ts +9 -0
- package/server/routes/files.d.ts.map +1 -0
- package/server/routes/files.js +441 -0
- package/server/routes/files.js.map +1 -0
- package/server/routes/filesystem.d.ts +6 -0
- package/server/routes/filesystem.d.ts.map +1 -0
- package/server/routes/filesystem.js +76 -0
- package/server/routes/filesystem.js.map +1 -0
- package/server/routes/git.d.ts +38 -0
- package/server/routes/git.d.ts.map +1 -0
- package/server/routes/git.js +585 -0
- package/server/routes/git.js.map +1 -0
- package/server/routes/healthz.d.ts +8 -0
- package/server/routes/healthz.d.ts.map +1 -0
- package/server/routes/healthz.js +24 -0
- package/server/routes/healthz.js.map +1 -0
- package/server/routes/hook.d.ts +14 -0
- package/server/routes/hook.d.ts.map +1 -0
- package/server/routes/hook.js +86 -0
- package/server/routes/hook.js.map +1 -0
- package/server/routes/ide-commands.d.ts +9 -0
- package/server/routes/ide-commands.d.ts.map +1 -0
- package/server/routes/ide-commands.js +23 -0
- package/server/routes/ide-commands.js.map +1 -0
- package/server/routes/lib/resolve-worktree.d.ts +30 -0
- package/server/routes/lib/resolve-worktree.d.ts.map +1 -0
- package/server/routes/lib/resolve-worktree.js +35 -0
- package/server/routes/lib/resolve-worktree.js.map +1 -0
- package/server/routes/open.d.ts +4 -0
- package/server/routes/open.d.ts.map +1 -0
- package/server/routes/open.js +21 -0
- package/server/routes/open.js.map +1 -0
- package/server/routes/pane-commands.d.ts +9 -0
- package/server/routes/pane-commands.d.ts.map +1 -0
- package/server/routes/pane-commands.js +23 -0
- package/server/routes/pane-commands.js.map +1 -0
- package/server/routes/projects.d.ts +15 -0
- package/server/routes/projects.d.ts.map +1 -0
- package/server/routes/projects.js +363 -0
- package/server/routes/projects.js.map +1 -0
- package/server/routes/server-notices.d.ts +4 -0
- package/server/routes/server-notices.d.ts.map +1 -0
- package/server/routes/server-notices.js +29 -0
- package/server/routes/server-notices.js.map +1 -0
- package/server/routes/service-config.d.ts +11 -0
- package/server/routes/service-config.d.ts.map +1 -0
- package/server/routes/service-config.js +64 -0
- package/server/routes/service-config.js.map +1 -0
- package/server/routes/sessions.d.ts +7 -0
- package/server/routes/sessions.d.ts.map +1 -0
- package/server/routes/sessions.js +218 -0
- package/server/routes/sessions.js.map +1 -0
- package/server/service/caffeinate.d.ts +33 -0
- package/server/service/caffeinate.d.ts.map +1 -0
- package/server/service/caffeinate.js +72 -0
- package/server/service/caffeinate.js.map +1 -0
- package/server/state/app-state.d.ts +167 -0
- package/server/state/app-state.d.ts.map +1 -0
- package/server/state/app-state.js +335 -0
- package/server/state/app-state.js.map +1 -0
- package/server/state/project-manager.d.ts +30 -0
- package/server/state/project-manager.d.ts.map +1 -0
- package/server/state/project-manager.js +128 -0
- package/server/state/project-manager.js.map +1 -0
- package/server/state/server-notices.d.ts +12 -0
- package/server/state/server-notices.d.ts.map +1 -0
- package/server/state/server-notices.js +32 -0
- package/server/state/server-notices.js.map +1 -0
- package/server/state/worktree-cache.d.ts +25 -0
- package/server/state/worktree-cache.d.ts.map +1 -0
- package/server/state/worktree-cache.js +53 -0
- package/server/state/worktree-cache.js.map +1 -0
- package/server/ws/events.d.ts +45 -0
- package/server/ws/events.d.ts.map +1 -0
- package/server/ws/events.js +134 -0
- package/server/ws/events.js.map +1 -0
- package/server/ws/keepalive.d.ts +27 -0
- package/server/ws/keepalive.d.ts.map +1 -0
- package/server/ws/keepalive.js +63 -0
- package/server/ws/keepalive.js.map +1 -0
- package/server/ws/terminal-attach.d.ts +13 -0
- package/server/ws/terminal-attach.d.ts.map +1 -0
- package/server/ws/terminal-attach.js +233 -0
- package/server/ws/terminal-attach.js.map +1 -0
- package/server/ws/terminal-flow.d.ts +17 -0
- package/server/ws/terminal-flow.d.ts.map +1 -0
- package/server/ws/terminal-flow.js +64 -0
- package/server/ws/terminal-flow.js.map +1 -0
- package/server/ws/terminal.d.ts +69 -0
- package/server/ws/terminal.d.ts.map +1 -0
- package/server/ws/terminal.js +311 -0
- package/server/ws/terminal.js.map +1 -0
- package/web/assets/EditorPane-CzzT3iYY.js +123 -0
- package/web/assets/SymbolsNerdFontMono-Regular-CwEZqMeU.woff2 +0 -0
- package/web/assets/TerminalPane-CjbYzePr.js +68 -0
- package/web/assets/TerminalPane-DkTCHfhq.css +1 -0
- package/web/assets/file-icons-JBi09j0r.js +6 -0
- package/web/assets/index-CTTkRpnn.css +2 -0
- package/web/assets/index-CmhewzMp.js +34 -0
- package/web/assets/session-resume-7f-tB-ZU.js +2 -0
- package/web/assets/terminal-trace-PuuFRybC.js +2803 -0
- package/web/assets/useVirtualKeyboard-DgJb9u9d.js +1 -0
- package/web/index.html +52 -0
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { randomBytes, timingSafeEqual } from "node:crypto";
|
|
2
|
+
import { chmodSync, readFileSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { setCookie } from "hono/cookie";
|
|
5
|
+
export const COOKIE_MAX_AGE_SECONDS = 60 * 60 * 24 * 30;
|
|
6
|
+
export function setParasorAuthCookie(c, token, url) {
|
|
7
|
+
setCookie(c, "parasor_token", token, {
|
|
8
|
+
httpOnly: true,
|
|
9
|
+
sameSite: "Strict",
|
|
10
|
+
path: "/",
|
|
11
|
+
maxAge: COOKIE_MAX_AGE_SECONDS,
|
|
12
|
+
secure: url.protocol === "https:",
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
export class TokenAuth {
|
|
16
|
+
token;
|
|
17
|
+
tokenPath;
|
|
18
|
+
constructor(opts) {
|
|
19
|
+
this.tokenPath = join(opts.dir, "token");
|
|
20
|
+
this.token = opts.ephemeral ? this.generate(false) : this.loadOrGenerate();
|
|
21
|
+
}
|
|
22
|
+
verify(candidate) {
|
|
23
|
+
const a = Buffer.from(candidate, "utf-8");
|
|
24
|
+
const b = Buffer.from(this.token, "utf-8");
|
|
25
|
+
if (a.length !== b.length)
|
|
26
|
+
return false;
|
|
27
|
+
return timingSafeEqual(a, b);
|
|
28
|
+
}
|
|
29
|
+
extractToken(search, cookieHeader) {
|
|
30
|
+
const query = search.startsWith("?") ? search : `?${search}`;
|
|
31
|
+
const url = new URL(`http://localhost${query}`);
|
|
32
|
+
const queryToken = url.searchParams.get("t");
|
|
33
|
+
if (queryToken)
|
|
34
|
+
return queryToken;
|
|
35
|
+
if (cookieHeader) {
|
|
36
|
+
const match = cookieHeader.match(/parasor_token=([^;]+)/);
|
|
37
|
+
if (match)
|
|
38
|
+
return match[1];
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
middleware(mode, allowedCidrs, trustProxy = false) {
|
|
43
|
+
return async (c, next) => {
|
|
44
|
+
if (mode === "none")
|
|
45
|
+
return next();
|
|
46
|
+
if (c.req.path === "/api/health")
|
|
47
|
+
return next();
|
|
48
|
+
if (mode === "allowlist") {
|
|
49
|
+
const remoteAddress = c.env
|
|
50
|
+
?.remoteAddress;
|
|
51
|
+
// `x-forwarded-for` is set by the client and is trivially spoofable;
|
|
52
|
+
// honoring it on a direct connection lets anyone forge an allowed IP
|
|
53
|
+
// and bypass the CIDR allowlist. Only trust it when explicitly behind
|
|
54
|
+
// a known reverse proxy; otherwise use the real socket address, and
|
|
55
|
+
// deny when no address is available (never fall back to a wildcard).
|
|
56
|
+
const clientIp = trustProxy
|
|
57
|
+
? (c.req.header("x-forwarded-for")?.split(",")[0]?.trim() ??
|
|
58
|
+
remoteAddress)
|
|
59
|
+
: remoteAddress;
|
|
60
|
+
if (clientIp &&
|
|
61
|
+
allowedCidrs?.some((cidr) => isInCidr(clientIp, cidr))) {
|
|
62
|
+
return next();
|
|
63
|
+
}
|
|
64
|
+
return c.json({ error: "Forbidden" }, 403);
|
|
65
|
+
}
|
|
66
|
+
const reqUrl = new URL(c.req.url);
|
|
67
|
+
const cookieHeader = c.req.header("cookie");
|
|
68
|
+
const candidate = this.extractToken(reqUrl.search, cookieHeader);
|
|
69
|
+
if (candidate && this.verify(candidate)) {
|
|
70
|
+
// Only swap to cookie + redirect when `t` is an actual query
|
|
71
|
+
// parameter, not when "t=" merely appears as a substring in any
|
|
72
|
+
// other parameter name (e.g. `limit=`, `worktreePath=`,
|
|
73
|
+
// `set=`). The previous `search.includes("t=")` produced an
|
|
74
|
+
// infinite ERR_TOO_MANY_REDIRECTS loop on /api/projects/:id/git/log
|
|
75
|
+
// because the `?worktreePath=...&limit=50` query string contains
|
|
76
|
+
// `t=` inside `limit=`, but `searchParams.delete("t")` had nothing
|
|
77
|
+
// to remove, so the redirect target equaled the source URL.
|
|
78
|
+
if (reqUrl.searchParams.has("t")) {
|
|
79
|
+
setParasorAuthCookie(c, this.token, reqUrl);
|
|
80
|
+
reqUrl.searchParams.delete("t");
|
|
81
|
+
return c.redirect(reqUrl.pathname + (reqUrl.search || ""));
|
|
82
|
+
}
|
|
83
|
+
return next();
|
|
84
|
+
}
|
|
85
|
+
return c.json({ error: "Unauthorized" }, 401);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
loadOrGenerate() {
|
|
89
|
+
try {
|
|
90
|
+
const existing = readFileSync(this.tokenPath, "utf-8").trim();
|
|
91
|
+
if (existing.length >= 32)
|
|
92
|
+
return existing;
|
|
93
|
+
}
|
|
94
|
+
catch {
|
|
95
|
+
// File doesn't exist or can't be read
|
|
96
|
+
}
|
|
97
|
+
return this.generate();
|
|
98
|
+
}
|
|
99
|
+
generate(persist = true) {
|
|
100
|
+
const token = randomBytes(32).toString("hex");
|
|
101
|
+
if (persist) {
|
|
102
|
+
writeFileSync(this.tokenPath, token, { mode: 0o600 });
|
|
103
|
+
chmodSync(this.tokenPath, 0o600);
|
|
104
|
+
}
|
|
105
|
+
return token;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
function isInCidr(ip, cidr) {
|
|
109
|
+
const [cidrIp, bits] = cidr.includes("/") ? cidr.split("/") : [cidr, "32"];
|
|
110
|
+
const mask = ~(2 ** (32 - Number(bits)) - 1) >>> 0;
|
|
111
|
+
const ipNum = ip.split(".").reduce((acc, oct) => (acc << 8) | Number(oct), 0) >>> 0;
|
|
112
|
+
const cidrNum = cidrIp.split(".").reduce((acc, oct) => (acc << 8) | Number(oct), 0) >>> 0;
|
|
113
|
+
return (ipNum & mask) === (cidrNum & mask);
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"token.js","sourceRoot":"","sources":["../../src/auth/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;AAExD,MAAM,UAAU,oBAAoB,CAClC,CAAU,EACV,KAAa,EACb,GAAQ;IAER,SAAS,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE;QACnC,QAAQ,EAAE,IAAI;QACd,QAAQ,EAAE,QAAQ;QAClB,IAAI,EAAE,GAAG;QACT,MAAM,EAAE,sBAAsB;QAC9B,MAAM,EAAE,GAAG,CAAC,QAAQ,KAAK,QAAQ;KAClC,CAAC,CAAC;AACL,CAAC;AAOD,MAAM,OAAO,SAAS;IACX,KAAK,CAAS;IACN,SAAS,CAAS;IAEnC,YAAY,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AC,CAAC;QACnC,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,EAAU,EAAE,IAAY;IACxC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC3E,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,KAAK,GACT,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IACxE,MAAM,OAAO,GACX,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5E,OAAO,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { AgentState } from "@parasor/shared";
|
|
2
|
+
import { Hono } from "hono";
|
|
3
|
+
import type { AgentDetector } from "../agent-detector/detector.js";
|
|
4
|
+
import type { PairingTokenStore } from "../auth/pairing-token.js";
|
|
5
|
+
import type { TokenAuth } from "../auth/token.js";
|
|
6
|
+
import type { AgentStatusRecorder } from "../debug/agent-status-recorder.js";
|
|
7
|
+
import type { TerminalTraceRecorder } from "../debug/terminal-trace-recorder.js";
|
|
8
|
+
import type { FilesystemService } from "../fs/service.js";
|
|
9
|
+
import type { UploadStaging } from "../fs/upload-staging.js";
|
|
10
|
+
import type { PtyHost } from "../pty/host.js";
|
|
11
|
+
import type { AppStateStore } from "../state/app-state.js";
|
|
12
|
+
import type { ProjectManager } from "../state/project-manager.js";
|
|
13
|
+
import type { ServerNoticesStore } from "../state/server-notices.js";
|
|
14
|
+
import type { WorktreeCache } from "../state/worktree-cache.js";
|
|
15
|
+
import { type EventBus } from "../ws/events.js";
|
|
16
|
+
import type { ProjectRuntime } from "./project-runtime.js";
|
|
17
|
+
export type AuthMode = "token" | "allowlist" | "none";
|
|
18
|
+
export interface WsKeepaliveConfig {
|
|
19
|
+
pingIntervalMs: number;
|
|
20
|
+
pongTimeoutMs: number;
|
|
21
|
+
}
|
|
22
|
+
export interface CreateAppServerDeps {
|
|
23
|
+
authMode: AuthMode;
|
|
24
|
+
tokenAuth: TokenAuth;
|
|
25
|
+
pairingTokens: PairingTokenStore;
|
|
26
|
+
ptyManager: PtyHost;
|
|
27
|
+
agentDetector: AgentDetector;
|
|
28
|
+
getAgentStates: () => Record<string, AgentState>;
|
|
29
|
+
debugRecorder: AgentStatusRecorder;
|
|
30
|
+
terminalTraceRecorder: TerminalTraceRecorder;
|
|
31
|
+
eventBus: EventBus;
|
|
32
|
+
projectManager: ProjectManager;
|
|
33
|
+
appStateStore: AppStateStore;
|
|
34
|
+
serverNoticesStore: ServerNoticesStore;
|
|
35
|
+
worktreeCache: WorktreeCache;
|
|
36
|
+
projectRuntime: ProjectRuntime;
|
|
37
|
+
uploadStaging: UploadStaging;
|
|
38
|
+
reconcileWorktrees?: (projectId: string, prefetched?: import("@parasor/shared").Worktree[]) => Promise<void>;
|
|
39
|
+
getFilesystemService: (projectId: string, worktreePath?: string) => FilesystemService | null;
|
|
40
|
+
webDistPath: string;
|
|
41
|
+
allowedOrigins: Set<string>;
|
|
42
|
+
wsKeepalive?: WsKeepaliveConfig;
|
|
43
|
+
onServiceConfigChanged: (config: import("@parasor/shared").ServiceConfig) => void;
|
|
44
|
+
}
|
|
45
|
+
export declare function createAppServer({ authMode, tokenAuth, pairingTokens, ptyManager, agentDetector, getAgentStates, debugRecorder, terminalTraceRecorder, eventBus, projectManager, appStateStore, serverNoticesStore, worktreeCache, projectRuntime, uploadStaging, reconcileWorktrees, getFilesystemService, webDistPath, allowedOrigins, wsKeepalive, onServiceConfigChanged, }: CreateAppServerDeps): {
|
|
46
|
+
app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
47
|
+
injectWebSocket: (server: import("node:http").Server | import("node:http2").Http2Server | import("node:http2").Http2SecureServer) => void;
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=create-app-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-app-server.d.ts","sourceRoot":"","sources":["../../src/bootstrap/create-app-server.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAgB,IAAI,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAC7E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qCAAqC,CAAC;AAGjF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAkB9C,OAAO,KAAK,EAAE,aAA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AE,MAAM,KAClB,iBAAiB,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,WAAW,CAAC,EAAE,iBAAiB,CAAC;IAChC,sBAAsB,EAAE,CACtB,MAAM,EAAE,OAAO,iBAAiB,EAAE,aAAa,KAC5C,IAAI,CAAC;CACX;AAED,wBAAgB,eAAe,CAAC,EAC9B,QAAQ,EACR,SAAS,EACT,aAAa,EACb,UAAU,EACV,aAAa,EACb,cAAc,EACd,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,WAAW,EACX,sBAAsB,GACvB,EAAE,mBAAmB;;;EAkNrB"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { serveStatic } from "@hono/node-server/serve-static";
|
|
5
|
+
import { createNodeWebSocket } from "@hono/node-ws";
|
|
6
|
+
import { Hono } from "hono";
|
|
7
|
+
import { originMiddleware } from "../auth/origin.js";
|
|
8
|
+
import { createTokenExchangeMiddleware } from "../auth/token-exchange.js";
|
|
9
|
+
import { FontInstaller } from "../fonts/installer.js";
|
|
10
|
+
import { createFontRoutes } from "../fonts/routes.js";
|
|
11
|
+
import { createDebugAgentStatusRoute } from "../routes/debug-agent-status.js";
|
|
12
|
+
import { createDebugDiagnosticsRoute } from "../routes/debug-diagnostics.js";
|
|
13
|
+
import { createDebugTerminalTraceRoute } from "../routes/debug-terminal-trace.js";
|
|
14
|
+
import { createDropRoutes } from "../routes/drops.js";
|
|
15
|
+
import { createFileUploadRoutes } from "../routes/file-uploads.js";
|
|
16
|
+
import { createFileRoutes } from "../routes/files.js";
|
|
17
|
+
import { createFilesystemRoutes } from "../routes/filesystem.js";
|
|
18
|
+
import { createGitRoutes } from "../routes/git.js";
|
|
19
|
+
import { createHealthzRoute } from "../routes/healthz.js";
|
|
20
|
+
import { createHookRoute } from "../routes/hook.js";
|
|
21
|
+
import { createIdeCommandRoutes } from "../routes/ide-commands.js";
|
|
22
|
+
import { createOpenRoute } from "../routes/open.js";
|
|
23
|
+
import { createPaneCommandRoutes } from "../routes/pane-commands.js";
|
|
24
|
+
import { createProjectRoutes } from "../routes/projects.js";
|
|
25
|
+
import { createServerNoticesRoutes } from "../routes/server-notices.js";
|
|
26
|
+
import { createServiceConfigRoutes } from "../routes/service-config.js";
|
|
27
|
+
import { createSessionRoutes } from "../routes/sessions.js";
|
|
28
|
+
import { handleEventClientMessage } from "../ws/events.js";
|
|
29
|
+
import { attachKeepalive } from "../ws/keepalive.js";
|
|
30
|
+
import { cleanupTerminalRelay, handleTerminalMessage, setupTerminalRelay, } from "../ws/terminal.js";
|
|
31
|
+
export function createAppServer({ authMode, tokenAuth, pairingTokens, ptyManager, agentDetector, getAgentStates, debugRecorder, terminalTraceRecorder, eventBus, projectManager, appStateStore, serverNoticesStore, worktreeCache, projectRuntime, uploadStaging, reconcileWorktrees, getFilesystemService, webDistPath, allowedOrigins, wsKeepalive, onServiceConfigChanged, }) {
|
|
32
|
+
const app = new Hono();
|
|
33
|
+
const { injectWebSocket, upgradeWebSocket } = createNodeWebSocket({ app });
|
|
34
|
+
const keepaliveConfig = wsKeepalive ?? {
|
|
35
|
+
pingIntervalMs: 20_000,
|
|
36
|
+
pongTimeoutMs: 10_000,
|
|
37
|
+
};
|
|
38
|
+
app.use("*", createTokenExchangeMiddleware({
|
|
39
|
+
mode: authMode,
|
|
40
|
+
tokenAuth,
|
|
41
|
+
pairingTokens,
|
|
42
|
+
}));
|
|
43
|
+
app.route("/healthz", createHealthzRoute());
|
|
44
|
+
app.route("/hook", createHookRoute({ ptyManager, agentDetector, debugRecorder }));
|
|
45
|
+
app.use("/api/*", tokenAuth.middleware(authMode));
|
|
46
|
+
app.use("/ws/*", originMiddleware({ allowed: allowedOrigins }));
|
|
47
|
+
app.use("/ws/*", tokenAuth.middleware(authMode));
|
|
48
|
+
app.use("/api/*", async (c, next) => {
|
|
49
|
+
await next();
|
|
50
|
+
c.header("X-Content-Type-Options", "nosniff");
|
|
51
|
+
c.header("X-Frame-Options", "DENY");
|
|
52
|
+
});
|
|
53
|
+
app.route("/api/projects", createProjectRoutes(projectManager, eventBus, ptyManager, appStateStore, worktreeCache, reconcileWorktrees));
|
|
54
|
+
app.route("/api/projects", createDropRoutes({
|
|
55
|
+
projectManager,
|
|
56
|
+
appStateStore,
|
|
57
|
+
ptyManager,
|
|
58
|
+
uploadStaging,
|
|
59
|
+
}));
|
|
60
|
+
app.route("/api/projects", createFileUploadRoutes({ projectManager, appStateStore }));
|
|
61
|
+
app.route("/api/projects", createGitRoutes({ projectManager, worktreeCache, projectRuntime }));
|
|
62
|
+
app.route("/api/sessions", createSessionRoutes(ptyManager, eventBus, appStateStore, terminalTraceRecorder));
|
|
63
|
+
app.route("/api/fs", createFilesystemRoutes());
|
|
64
|
+
app.route("/api/open", createOpenRoute(eventBus));
|
|
65
|
+
app.route("/api/pane-commands", createPaneCommandRoutes({ appStateStore, eventBus }));
|
|
66
|
+
app.route("/api/ide-commands", createIdeCommandRoutes({ appStateStore, eventBus }));
|
|
67
|
+
app.route("/api/debug/agent-status", createDebugAgentStatusRoute(debugRecorder, getAgentStates));
|
|
68
|
+
app.route("/api/debug/diagnostics", createDebugDiagnosticsRoute({
|
|
69
|
+
terminalTraceRecorder,
|
|
70
|
+
}));
|
|
71
|
+
app.route("/api/debug/terminal-trace", createDebugTerminalTraceRoute({
|
|
72
|
+
recorder: terminalTraceRecorder,
|
|
73
|
+
ptyManager,
|
|
74
|
+
eventBus,
|
|
75
|
+
appStateStore,
|
|
76
|
+
projectManager,
|
|
77
|
+
}));
|
|
78
|
+
app.route("/api/files", createFileRoutes(projectManager, getFilesystemService, {
|
|
79
|
+
isWritable: (projectId) => !projectManager.get(projectId)?.readOnly,
|
|
80
|
+
}));
|
|
81
|
+
app.route("/api/fonts", createFontRoutes(new FontInstaller()));
|
|
82
|
+
app.route("/api/service-config", createServiceConfigRoutes({
|
|
83
|
+
appStateStore,
|
|
84
|
+
eventBus,
|
|
85
|
+
onConfigChanged: onServiceConfigChanged,
|
|
86
|
+
}));
|
|
87
|
+
app.route("/api/notices", createServerNoticesRoutes(serverNoticesStore));
|
|
88
|
+
app.get("/api/health", (c) => c.json({ status: "ok" }));
|
|
89
|
+
app.get("/api/auth/verify", (c) => c.json({ ok: true }));
|
|
90
|
+
app.get("/ws/terminal/:id", upgradeWebSocket((c) => {
|
|
91
|
+
const sessionId = c.req.param("id");
|
|
92
|
+
if (!sessionId)
|
|
93
|
+
throw new Error("missing terminal session id");
|
|
94
|
+
const clientId = c.req.query("clientId") ?? randomUUID();
|
|
95
|
+
let wsInstance;
|
|
96
|
+
let disposeKeepalive = null;
|
|
97
|
+
return {
|
|
98
|
+
onOpen(_event, ws) {
|
|
99
|
+
wsInstance = ws;
|
|
100
|
+
const raw = ws.raw;
|
|
101
|
+
if (raw)
|
|
102
|
+
disposeKeepalive = attachKeepalive(raw, keepaliveConfig);
|
|
103
|
+
setupTerminalRelay(ws, sessionId, clientId, ptyManager, terminalTraceRecorder);
|
|
104
|
+
},
|
|
105
|
+
onMessage(event, ws) {
|
|
106
|
+
void handleTerminalMessage(ws, sessionId, clientId, ptyManager, event, terminalTraceRecorder);
|
|
107
|
+
},
|
|
108
|
+
onClose() {
|
|
109
|
+
disposeKeepalive?.();
|
|
110
|
+
disposeKeepalive = null;
|
|
111
|
+
if (wsInstance) {
|
|
112
|
+
cleanupTerminalRelay(wsInstance, sessionId, clientId, ptyManager, terminalTraceRecorder);
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
}));
|
|
117
|
+
app.get("/ws/events", upgradeWebSocket(() => {
|
|
118
|
+
let disposeKeepalive = null;
|
|
119
|
+
return {
|
|
120
|
+
async onOpen(_event, ws) {
|
|
121
|
+
const raw = ws.raw;
|
|
122
|
+
if (raw)
|
|
123
|
+
disposeKeepalive = attachKeepalive(raw, keepaliveConfig);
|
|
124
|
+
await eventBus.addClient(ws);
|
|
125
|
+
},
|
|
126
|
+
onMessage(event, ws) {
|
|
127
|
+
handleEventClientMessage(ws, event.data);
|
|
128
|
+
},
|
|
129
|
+
onClose(_event, ws) {
|
|
130
|
+
disposeKeepalive?.();
|
|
131
|
+
disposeKeepalive = null;
|
|
132
|
+
eventBus.removeClient(ws);
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}));
|
|
136
|
+
const serveIndex = async (c) => {
|
|
137
|
+
const html = await readFile(join(webDistPath, "index.html"), "utf8");
|
|
138
|
+
// Clickjacking defense for the app shell. sameSite=Strict already stops a
|
|
139
|
+
// cross-site frame from carrying the token, but deny framing outright too.
|
|
140
|
+
// `frame-ancestors 'none'` is the only CSP directive set here, so it does
|
|
141
|
+
// not constrain the app's own script/style/font/WebGL loading.
|
|
142
|
+
c.header("X-Frame-Options", "DENY");
|
|
143
|
+
c.header("Content-Security-Policy", "frame-ancestors 'none'");
|
|
144
|
+
return c.html(html);
|
|
145
|
+
};
|
|
146
|
+
app.get("/", serveIndex);
|
|
147
|
+
app.get("/monitor", serveIndex);
|
|
148
|
+
app.get("/sessions/*", serveIndex);
|
|
149
|
+
app.get("/panes/*", serveIndex);
|
|
150
|
+
app.get("/worktree", serveIndex);
|
|
151
|
+
app.use("/*", serveStatic({ root: webDistPath }));
|
|
152
|
+
return { app, injectWebSocket };
|
|
153
|
+
}
|
|
154
|
+
//# sourceMappingURL=create-app-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-app-server.js","sourceRoot":"","sources":["../../src/bootstrap/create-app-server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC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AAC,aAAa,EAAE,UAAU,CAAC,CAAC;IACnC,GAAG,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAChC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAEjC,GAAG,CAAC,GAAG,CAAC,IAAI,EAAE,WAAW,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC;IAElD,OAAO,EAAE,GAAG,EAAE,eAAe,EAAE,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { GitState, WsEventMessage } from "@parasor/shared";
|
|
2
|
+
import { FilesystemService } from "../fs/service.js";
|
|
3
|
+
import type { ProjectManager } from "../state/project-manager.js";
|
|
4
|
+
import type { WorktreeCache } from "../state/worktree-cache.js";
|
|
5
|
+
import type { EventBus } from "../ws/events.js";
|
|
6
|
+
export interface ProjectRuntime {
|
|
7
|
+
/**
|
|
8
|
+
* Returns the filesystem service for the project's main checkout, or for a
|
|
9
|
+
* specific linked worktree when `worktreePath` is supplied. Worktree paths
|
|
10
|
+
* are validated against {@link WorktreeCache} so callers can route untrusted
|
|
11
|
+
* query input here without separate fence checks. `null` when the project
|
|
12
|
+
* does not exist or the worktree is not registered for that project.
|
|
13
|
+
*/
|
|
14
|
+
getFilesystemService(projectId: string, worktreePath?: string): FilesystemService | null;
|
|
15
|
+
getGitStates(): Record<string, Record<string, GitState | null>>;
|
|
16
|
+
activatePersistedProjects(projectIds: Iterable<string>): void;
|
|
17
|
+
handleBroadcast(message: WsEventMessage): void;
|
|
18
|
+
handleSessionEnded(projectId: string): void;
|
|
19
|
+
pollGitChanges(): Promise<void>;
|
|
20
|
+
refreshGitState(projectId: string, worktreePath: string): Promise<void>;
|
|
21
|
+
dispose(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export interface CreateProjectRuntimeDeps {
|
|
24
|
+
projectManager: ProjectManager;
|
|
25
|
+
eventBus: EventBus;
|
|
26
|
+
worktreeCache: WorktreeCache;
|
|
27
|
+
}
|
|
28
|
+
export declare function createProjectRuntime({ projectManager, eventBus, worktreeCache, }: CreateProjectRuntimeDeps): ProjectRuntime;
|
|
29
|
+
//# sourceMappingURL=project-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-runtime.d.ts","sourceRoot":"","sources":["../../src/bootstrap/project-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAGhE,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,oBAAoB,CAClB,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,iBAAiB,GAAG,IAAI,CAAC;IAC5B,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC;IAChE,yBAAyB,CAAC,UAAU,EAAE,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;IAC9D,eAAe,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/C,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5C,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAChC,eAAe,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B;AAED,MAAM,WAAW,wBAAwB;IACvC,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,EAAE,QAAQ,CAAC;IACnB,aAAa,EAAE,aAAa,CAAC;CAC9B;AAMD,wBAAgB,oBAAoB,CAAC,EACnC,cAAc,EACd,QAAQ,EACR,aAAa,GACd,EAAE,wBAAwB,GAAG,cAAc,CAuR3C"}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import { FileWatcher } from "../fs/file-watcher.js";
|
|
2
|
+
import { GitWatcher } from "../fs/git-watcher.js";
|
|
3
|
+
import { FilesystemService } from "../fs/service.js";
|
|
4
|
+
import { WatcherLifecycle } from "../fs/watcher-lifecycle.js";
|
|
5
|
+
function watcherKey(projectId, worktreePath) {
|
|
6
|
+
return `${projectId}|${worktreePath}`;
|
|
7
|
+
}
|
|
8
|
+
export function createProjectRuntime({ projectManager, eventBus, worktreeCache, }) {
|
|
9
|
+
const fsServices = new Map();
|
|
10
|
+
// Per-worktree FS service cache, keyed by `${projectId}|${worktreePath}`.
|
|
11
|
+
// Kept separate from `fsServices` so the project-root service (used by
|
|
12
|
+
// FileWatcher's `.gitignore` reload + isIgnored callback) keeps its
|
|
13
|
+
// simple `projectId`-only key and existing semantics.
|
|
14
|
+
const worktreeFsServices = new Map();
|
|
15
|
+
const fileWatchers = new Map();
|
|
16
|
+
const gitWatcher = new GitWatcher();
|
|
17
|
+
// Per-key serialization for watcher start/stop. `worktree-created` and
|
|
18
|
+
// `worktree-removed` can land in either order, even back-to-back for the
|
|
19
|
+
// same path. Without serialization a removal that arrives mid-`start()`
|
|
20
|
+
// would miss the map entry, and a re-creation that arrives mid-`stop()`
|
|
21
|
+
// would spawn a second native subscription before the old one shuts down.
|
|
22
|
+
// Chaining ops by key gives both events a consistent view of the watcher
|
|
23
|
+
// state.
|
|
24
|
+
const watcherOps = new Map();
|
|
25
|
+
function chainWatcherOp(key, op) {
|
|
26
|
+
const prev = watcherOps.get(key) ?? Promise.resolve();
|
|
27
|
+
const next = prev.catch(() => undefined).then(op);
|
|
28
|
+
watcherOps.set(key, next);
|
|
29
|
+
void next.finally(() => {
|
|
30
|
+
if (watcherOps.get(key) === next)
|
|
31
|
+
watcherOps.delete(key);
|
|
32
|
+
});
|
|
33
|
+
return next;
|
|
34
|
+
}
|
|
35
|
+
// Debounced per-worktree git-state recompute on regular file changes.
|
|
36
|
+
// FileWatcher only triggers `broadcastGitState` for `.git/HEAD/index/refs`
|
|
37
|
+
// edits, but a plain save (e.g. README.md) also flips dirtyCount and the
|
|
38
|
+
// user expects the counter to update sub-second -- not on the next 10s poll.
|
|
39
|
+
const pendingGitDiff = new Map();
|
|
40
|
+
const GIT_DIFF_DEBOUNCE_MS = 200;
|
|
41
|
+
function scheduleGitDiff(projectId, worktreePath) {
|
|
42
|
+
const key = watcherKey(projectId, worktreePath);
|
|
43
|
+
const existing = pendingGitDiff.get(key);
|
|
44
|
+
if (existing)
|
|
45
|
+
clearTimeout(existing);
|
|
46
|
+
pendingGitDiff.set(key, setTimeout(() => {
|
|
47
|
+
pendingGitDiff.delete(key);
|
|
48
|
+
void broadcastGitState(projectId, worktreePath);
|
|
49
|
+
}, GIT_DIFF_DEBOUNCE_MS));
|
|
50
|
+
}
|
|
51
|
+
function getFilesystemService(projectId, worktreePath) {
|
|
52
|
+
const project = projectManager.get(projectId);
|
|
53
|
+
if (!project)
|
|
54
|
+
return null;
|
|
55
|
+
// No worktree override (or matches project root) -> return the cached
|
|
56
|
+
// project-root service. This is also the watcher-facing path so its
|
|
57
|
+
// `.gitignore` instance is preserved across calls.
|
|
58
|
+
if (!worktreePath || worktreePath === project.path) {
|
|
59
|
+
const cached = fsServices.get(projectId);
|
|
60
|
+
if (cached)
|
|
61
|
+
return cached;
|
|
62
|
+
const service = new FilesystemService(project.path);
|
|
63
|
+
fsServices.set(projectId, service);
|
|
64
|
+
return service;
|
|
65
|
+
}
|
|
66
|
+
// Untrusted input fence: only resolve to a worktree when it is
|
|
67
|
+
// currently registered for this project. Unknown paths fall back to
|
|
68
|
+
// the project root rather than spawning an arbitrary FS service.
|
|
69
|
+
const worktrees = worktreeCache.get()[projectId] ?? [];
|
|
70
|
+
if (!worktrees.some((w) => w.path === worktreePath)) {
|
|
71
|
+
return getFilesystemService(projectId);
|
|
72
|
+
}
|
|
73
|
+
const key = `${projectId}|${worktreePath}`;
|
|
74
|
+
const cached = worktreeFsServices.get(key);
|
|
75
|
+
if (cached)
|
|
76
|
+
return cached;
|
|
77
|
+
const service = new FilesystemService(worktreePath);
|
|
78
|
+
worktreeFsServices.set(key, service);
|
|
79
|
+
return service;
|
|
80
|
+
}
|
|
81
|
+
async function broadcastGitState(projectId, worktreePath) {
|
|
82
|
+
const { state, changed } = await gitWatcher.checkAndDiff(projectId, worktreePath);
|
|
83
|
+
if (changed) {
|
|
84
|
+
eventBus.broadcast({ type: "git-state", projectId, worktreePath, state });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns every worktree path that should be watched for `projectId`. The
|
|
89
|
+
* project's main checkout path is always included, even when the worktree
|
|
90
|
+
* cache only lists linked worktrees.
|
|
91
|
+
*/
|
|
92
|
+
function projectWorktreePaths(projectId) {
|
|
93
|
+
const project = projectManager.get(projectId);
|
|
94
|
+
if (!project)
|
|
95
|
+
return [];
|
|
96
|
+
const paths = new Set([project.path]);
|
|
97
|
+
for (const wt of worktreeCache.get()[projectId] ?? []) {
|
|
98
|
+
paths.add(wt.path);
|
|
99
|
+
}
|
|
100
|
+
return [...paths];
|
|
101
|
+
}
|
|
102
|
+
function spawnWatcher(projectId, worktreePath) {
|
|
103
|
+
const key = watcherKey(projectId, worktreePath);
|
|
104
|
+
return chainWatcherOp(key, async () => {
|
|
105
|
+
if (fileWatchers.has(key))
|
|
106
|
+
return;
|
|
107
|
+
// Filesystem ignore rules live on the project's main worktree (the
|
|
108
|
+
// only one that owns `.gitignore` semantics for parasor's filetree).
|
|
109
|
+
// Linked worktrees share the same FilesystemService instance.
|
|
110
|
+
const fsService = getFilesystemService(projectId);
|
|
111
|
+
const watcher = new FileWatcher(worktreePath, (event, path) => {
|
|
112
|
+
eventBus.broadcast({ type: "file-change", projectId, event, path });
|
|
113
|
+
scheduleGitDiff(projectId, worktreePath);
|
|
114
|
+
}, () => {
|
|
115
|
+
const service = fsServices.get(projectId);
|
|
116
|
+
service?.reloadIgnore();
|
|
117
|
+
eventBus.broadcast({ type: "gitignore-updated", projectId });
|
|
118
|
+
}, async () => {
|
|
119
|
+
await broadcastGitState(projectId, worktreePath);
|
|
120
|
+
}, (relPath, isDir) => fsService?.isIgnored(relPath, isDir) ?? false);
|
|
121
|
+
await watcher.start();
|
|
122
|
+
fileWatchers.set(key, watcher);
|
|
123
|
+
await broadcastGitState(projectId, worktreePath);
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
function teardownWatcher(projectId, worktreePath) {
|
|
127
|
+
const key = watcherKey(projectId, worktreePath);
|
|
128
|
+
return chainWatcherOp(key, async () => {
|
|
129
|
+
const watcher = fileWatchers.get(key);
|
|
130
|
+
if (watcher) {
|
|
131
|
+
fileWatchers.delete(key);
|
|
132
|
+
await watcher.stop();
|
|
133
|
+
}
|
|
134
|
+
const pending = pendingGitDiff.get(key);
|
|
135
|
+
if (pending) {
|
|
136
|
+
clearTimeout(pending);
|
|
137
|
+
pendingGitDiff.delete(key);
|
|
138
|
+
}
|
|
139
|
+
worktreeFsServices.delete(key);
|
|
140
|
+
gitWatcher.clearWorktree(projectId, worktreePath);
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
async function tearDownWatchers(projectId) {
|
|
144
|
+
const prefix = `${projectId}|`;
|
|
145
|
+
for (const [key, timer] of pendingGitDiff) {
|
|
146
|
+
if (!key.startsWith(prefix))
|
|
147
|
+
continue;
|
|
148
|
+
clearTimeout(timer);
|
|
149
|
+
pendingGitDiff.delete(key);
|
|
150
|
+
}
|
|
151
|
+
const tasks = [];
|
|
152
|
+
for (const [key, watcher] of fileWatchers) {
|
|
153
|
+
if (!key.startsWith(prefix))
|
|
154
|
+
continue;
|
|
155
|
+
tasks.push(watcher.stop().finally(() => {
|
|
156
|
+
fileWatchers.delete(key);
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
await Promise.all(tasks);
|
|
160
|
+
gitWatcher.clearProject(projectId);
|
|
161
|
+
}
|
|
162
|
+
const watcherLifecycle = new WatcherLifecycle({
|
|
163
|
+
onActivate: async (projectId) => {
|
|
164
|
+
const project = projectManager.get(projectId);
|
|
165
|
+
if (!project)
|
|
166
|
+
return;
|
|
167
|
+
for (const worktreePath of projectWorktreePaths(projectId)) {
|
|
168
|
+
await spawnWatcher(projectId, worktreePath);
|
|
169
|
+
}
|
|
170
|
+
},
|
|
171
|
+
onSuspend: async (projectId) => {
|
|
172
|
+
await tearDownWatchers(projectId);
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
return {
|
|
176
|
+
getFilesystemService,
|
|
177
|
+
getGitStates: () => gitWatcher.getAllCached(),
|
|
178
|
+
activatePersistedProjects(projectIds) {
|
|
179
|
+
for (const projectId of projectIds) {
|
|
180
|
+
void watcherLifecycle.ensureActive(projectId);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
handleBroadcast(message) {
|
|
184
|
+
if (message.type === "project-created") {
|
|
185
|
+
void watcherLifecycle.ensureActive(message.project.id);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
if (message.type === "worktree-created") {
|
|
189
|
+
if (watcherLifecycle.isActive(message.projectId)) {
|
|
190
|
+
void spawnWatcher(message.projectId, message.worktree.path);
|
|
191
|
+
}
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
if (message.type === "worktree-removed") {
|
|
195
|
+
// Stop the watcher and drop the per-worktree FS service so deleted
|
|
196
|
+
// worktrees do not leak parcel-watcher native handles or cached
|
|
197
|
+
// FilesystemService instances across the daemon's lifetime. The
|
|
198
|
+
// teardown is serialized with any in-flight spawn so a removal
|
|
199
|
+
// landing mid-`watcher.start()` still cleans up after start returns.
|
|
200
|
+
void teardownWatcher(message.projectId, message.worktreePath);
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
if (message.type === "session-created" ||
|
|
204
|
+
message.type === "session-restarted") {
|
|
205
|
+
void watcherLifecycle.onSessionCreated(message.session.projectId);
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
208
|
+
if (message.type === "session-closed") {
|
|
209
|
+
void watcherLifecycle.onSessionEnded(message.projectId);
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
if (message.type === "project-deleted") {
|
|
213
|
+
void watcherLifecycle.onProjectDeleted(message.projectId);
|
|
214
|
+
fsServices.delete(message.projectId);
|
|
215
|
+
const prefix = `${message.projectId}|`;
|
|
216
|
+
for (const key of worktreeFsServices.keys()) {
|
|
217
|
+
if (key.startsWith(prefix))
|
|
218
|
+
worktreeFsServices.delete(key);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
handleSessionEnded(projectId) {
|
|
223
|
+
void watcherLifecycle.onSessionEnded(projectId);
|
|
224
|
+
},
|
|
225
|
+
async pollGitChanges() {
|
|
226
|
+
for (const project of projectManager.list()) {
|
|
227
|
+
if (!watcherLifecycle.isActive(project.id))
|
|
228
|
+
continue;
|
|
229
|
+
for (const worktreePath of projectWorktreePaths(project.id)) {
|
|
230
|
+
await broadcastGitState(project.id, worktreePath);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
},
|
|
234
|
+
async refreshGitState(projectId, worktreePath) {
|
|
235
|
+
await broadcastGitState(projectId, worktreePath);
|
|
236
|
+
},
|
|
237
|
+
async dispose() {
|
|
238
|
+
watcherLifecycle.dispose();
|
|
239
|
+
for (const timer of pendingGitDiff.values())
|
|
240
|
+
clearTimeout(timer);
|
|
241
|
+
pendingGitDiff.clear();
|
|
242
|
+
const tasks = [];
|
|
243
|
+
for (const watcher of fileWatchers.values()) {
|
|
244
|
+
tasks.push(watcher.stop());
|
|
245
|
+
}
|
|
246
|
+
await Promise.all(tasks);
|
|
247
|
+
fileWatchers.clear();
|
|
248
|
+
fsServices.clear();
|
|
249
|
+
worktreeFsServices.clear();
|
|
250
|
+
},
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=project-runtime.js.map
|