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,84 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* - daemon startup orphan reconciliation.
|
|
3
|
+
*
|
|
4
|
+
* On startup the daemon reads `appState.sessionRecords` and decides what
|
|
5
|
+
* to do with each record whose `state === "running"` (we ignore already-
|
|
6
|
+
* terminal "exited"/"lost"/"orphaned" records -- they only need cleanup
|
|
7
|
+
* via `pty-host doctor`, not on every boot):
|
|
8
|
+
*
|
|
9
|
+
* - alive + recorded `daemonPid` matches *this* daemon: keep as
|
|
10
|
+
* "running" (rare; happens after a fast restart that didn't change
|
|
11
|
+
* the PID -- possible under exec-replace).
|
|
12
|
+
* - alive + recorded `daemonPid` belongs to a different generation:
|
|
13
|
+
* transition to "orphaned". The PTY survived the previous daemon
|
|
14
|
+
* so it is still consuming a slot, but we no longer own its master
|
|
15
|
+
* fd; only `pty-host doctor` can reap it.
|
|
16
|
+
* - dead (kill(pid,0) -> ESRCH/ENOENT): transition to "lost". The PID
|
|
17
|
+
* vanished without a recorded exit (SIGKILL, parent crash, OOM).
|
|
18
|
+
* - record has no PID (create-stub that never spawned): transition
|
|
19
|
+
* to "lost" -- the previous daemon never observed `node-pty.spawn`
|
|
20
|
+
* completing, so the underlying child cannot exist.
|
|
21
|
+
*
|
|
22
|
+
* The decision is *local to the record*: we never call `ps -ef | grep`
|
|
23
|
+
* to rediscover untracked PTYs. Records are the source of truth; an
|
|
24
|
+
* untracked alive PID matching one of our argv signatures is out of
|
|
25
|
+
* scope here (handled by `pty-host doctor` re-verification).
|
|
26
|
+
*
|
|
27
|
+
* Side effect: returns a list of `SessionRecord` snapshots reflecting
|
|
28
|
+
* the post-reconciliation state. Callers persist them via
|
|
29
|
+
* `AppStateStore.internalMutate` so the read-only mirror guard is
|
|
30
|
+
* bypassed (the daemon owns the writer side).
|
|
31
|
+
*/
|
|
32
|
+
function defaultIsPidAlive(pid) {
|
|
33
|
+
if (!Number.isFinite(pid) || pid <= 0)
|
|
34
|
+
return false;
|
|
35
|
+
try {
|
|
36
|
+
process.kill(pid, 0);
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
return err.code === "EPERM";
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Pure function -- no side effects. Caller is responsible for persisting
|
|
45
|
+
* the resulting array via `AppStateStore.internalMutate`.
|
|
46
|
+
*
|
|
47
|
+
* Already-terminal records (state in {exited,lost,orphaned}) are passed
|
|
48
|
+
* through unchanged. Only `state === "running"` records are evaluated.
|
|
49
|
+
*/
|
|
50
|
+
export function reconcileSessionRecords(input, opts) {
|
|
51
|
+
const isAlive = opts.isPidAlive ?? defaultIsPidAlive;
|
|
52
|
+
const out = [];
|
|
53
|
+
const transitions = [];
|
|
54
|
+
for (const rec of input) {
|
|
55
|
+
if (rec.state !== "running") {
|
|
56
|
+
out.push(rec);
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (rec.pid === null || rec.pid === undefined) {
|
|
60
|
+
out.push({ ...rec, state: "lost" });
|
|
61
|
+
transitions.push({ type: "lost", id: rec.id, reason: "no-pid" });
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
if (!isAlive(rec.pid)) {
|
|
65
|
+
out.push({ ...rec, state: "lost" });
|
|
66
|
+
transitions.push({ type: "lost", id: rec.id, reason: "dead-pid" });
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
if (rec.daemonPid === opts.currentDaemonPid &&
|
|
70
|
+
rec.daemonStartedAt === opts.currentDaemonStartedAt) {
|
|
71
|
+
out.push(rec);
|
|
72
|
+
transitions.push({ type: "kept", id: rec.id });
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
out.push({ ...rec, state: "orphaned" });
|
|
76
|
+
transitions.push({
|
|
77
|
+
type: "orphaned",
|
|
78
|
+
id: rec.id,
|
|
79
|
+
previousDaemonPid: rec.daemonPid,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
return { records: out, transitions };
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=orphan-cleanup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"orphan-cleanup.js","sourceRoot":"","sources":["../../../src/pty/host-daemon/orphan-cleanup.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AA+BH,SAAS,iBAAiB,CAAC,GAAW;IACpC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;QAAE,OAAO,KAAK,CAAC;IACpD,IAAI,CAAC;QACH,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAQ,GAA6B,CAAC,IAAI,KAAK,OAAO,CAAC;IACzD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,uBAAuB,CACrC,KAA+B,EAC/B,IAAmB;IAEnB,MAAM,OAAO,GAAG,IAAI,CAAC,UAAU,IAAI,iBAAiB,CAAC;IACrD,MAAM,GAAG,GAAoB,EAAE,CAAC;IAChC,MAAM,WAAW,GAAgC,EAAE,CAAC;IAEpD,KAAK,MAAM,GAAG,IAAI,KAAK,EAAE,CAAC;QACxB,IAAI,GAAG,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YAC5B,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACd,SAAS;QACX,CAAC;QAED,IAAI,GAAG,CAAC,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;YAC9C,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACpC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAC;YACjE,SAAS;QACX,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACtB,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC;YACpC,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,CAAC,CAAC;YACnE,SAAS;QACX,CAAC;QAED,IACE,GAAG,CAAC,SAAS,KAAK,IAAI,CAAC,gBAAgB;YACvC,GAAG,CAAC,eAAe,KAAK,IAAI,CAAC,sBAAsB,EACnD,CAAC;YACD,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACd,WAAW,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;YAC/C,SAAS;QACX,CAAC;QAED,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,UAAU,EAAE,CAAC,CAAC;QACxC,WAAW,CAAC,IAAI,CAAC;YACf,IAAI,EAAE,UAAU;YAChB,EAAE,EAAE,GAAG,CAAC,EAAE;YACV,iBAAiB,EAAE,GAAG,CAAC,SAAS;SACjC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface DaemonPaths {
|
|
2
|
+
runtimeDir: string;
|
|
3
|
+
socketPath: string;
|
|
4
|
+
pidFile: string;
|
|
5
|
+
lockFile: string;
|
|
6
|
+
logFile: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function resolveDaemonPaths(env?: NodeJS.ProcessEnv, pid?: number): DaemonPaths;
|
|
9
|
+
export declare function ensureRuntimeDir(dir: string): void;
|
|
10
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../../../src/pty/host-daemon/paths.ts"],"names":[],"mappings":"AAuBA,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,wBAAgB,kBAAkB,CAChC,GAAG,GAAE,MAAM,CAAC,UAAwB,EACpC,GAAG,GAAE,MAAoB,GACxB,WAAW,CA4Bb;AAED,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAOlD"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* -- daemon runtime path resolution.
|
|
3
|
+
*
|
|
4
|
+
* Resolution order:
|
|
5
|
+
* 1. `PARASOR_PTY_SOCK` env override (test / sandbox bypass)
|
|
6
|
+
* 2. `XDG_RUNTIME_DIR/parasor` (Linux session runtime)
|
|
7
|
+
* 3. `~/.parasor/run` (default fallback)
|
|
8
|
+
*
|
|
9
|
+
* The socket directory is created `0700` so only the spawning user can
|
|
10
|
+
* connect. `PARASOR_PTY_SOCK` overrides keep the same `<sock>.pid`,
|
|
11
|
+
* `<sock>.lock`, `<sock>.log` neighbours so all bookkeeping files travel
|
|
12
|
+
* with the socket override.
|
|
13
|
+
*
|
|
14
|
+
* R5 -- `PARASOR_PTY_SOCK_PER_PID=1` opt-in suffixes
|
|
15
|
+
* `-${pid}` to all canonical basenames so foreground daemons and
|
|
16
|
+
* installed daemons can coexist without socket collision. Ignored when
|
|
17
|
+
* `PARASOR_PTY_SOCK` is set (explicit override always wins).
|
|
18
|
+
*/
|
|
19
|
+
import { mkdirSync } from "node:fs";
|
|
20
|
+
import { homedir } from "node:os";
|
|
21
|
+
import { dirname, join } from "node:path";
|
|
22
|
+
export function resolveDaemonPaths(env = process.env, pid = process.pid) {
|
|
23
|
+
const override = env.PARASOR_PTY_SOCK;
|
|
24
|
+
if (override && override.length > 0) {
|
|
25
|
+
return {
|
|
26
|
+
runtimeDir: dirname(override),
|
|
27
|
+
socketPath: override,
|
|
28
|
+
pidFile: `${override}.pid`,
|
|
29
|
+
lockFile: `${override}.lock`,
|
|
30
|
+
logFile: `${override}.log`,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const xdg = env.XDG_RUNTIME_DIR;
|
|
34
|
+
const runtimeDir = xdg && xdg.length > 0
|
|
35
|
+
? join(xdg, "parasor")
|
|
36
|
+
: join(homedir(), ".parasor", "run");
|
|
37
|
+
const perPid = env.PARASOR_PTY_SOCK_PER_PID === "1";
|
|
38
|
+
const stem = perPid ? `parasor-pty-${pid}` : "parasor-pty";
|
|
39
|
+
return {
|
|
40
|
+
runtimeDir,
|
|
41
|
+
socketPath: join(runtimeDir, `${stem}.sock`),
|
|
42
|
+
pidFile: join(runtimeDir, `${stem}.pid`),
|
|
43
|
+
lockFile: join(runtimeDir, `${stem}.lock`),
|
|
44
|
+
logFile: join(runtimeDir, `${stem}.log`),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
export function ensureRuntimeDir(dir) {
|
|
48
|
+
const prevMask = process.umask(0o077);
|
|
49
|
+
try {
|
|
50
|
+
mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
process.umask(prevMask);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../../../src/pty/host-daemon/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAU1C,MAAM,UAAU,kBAAkB,CAChC,MAAyB,OAAO,CAAC,GAAG,EACpC,MAAc,OAAO,CAAC,GAAG;IAEzB,MAAM,QAAQ,GAAG,GAAG,CAAC,gBAAgB,CAAC;IACtC,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACpC,OAAO;YACL,UAAU,EAAE,OAAO,CAAC,QAAQ,CAAC;YAC7B,UAAU,EAAE,QAAQ;YACpB,OAAO,EAAE,GAAG,QAAQ,MAAM;YAC1B,QAAQ,EAAE,GAAG,QAAQ,OAAO;YAC5B,OAAO,EAAE,GAAG,QAAQ,MAAM;SAC3B,CAAC;IACJ,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC;IAChC,MAAM,UAAU,GACd,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC;QACnB,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,CAAC;QACtB,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;IAEzC,MAAM,MAAM,GAAG,GAAG,CAAC,wBAAwB,KAAK,GAAG,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,CAAC,CAAC,CAAC,eAAe,GAAG,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;IAE3D,OAAO;QACL,UAAU;QACV,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,OAAO,CAAC;QAC5C,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,MAAM,CAAC;QACxC,QAAQ,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,OAAO,CAAC;QAC1C,OAAO,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,IAAI,MAAM,CAAC;KACzC,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,GAAW;IAC1C,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtC,IAAI,CAAC;QACH,SAAS,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACnD,CAAC;YAAS,CAAC;QACT,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC1B,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Duplex } from "node:stream";
|
|
2
|
+
import { type Frame } from "../host-protocol/frames.js";
|
|
3
|
+
import { type NackCode } from "../host-protocol/messages.js";
|
|
4
|
+
export type ServerConnectionState = "awaiting-hello" | "ready" | "evicted" | "closed";
|
|
5
|
+
export interface ServerConnectionDeps {
|
|
6
|
+
socket: Duplex;
|
|
7
|
+
/** Initial id; daemon may reassign on HELLO_ACK if it wants different ids. */
|
|
8
|
+
connectionId: number;
|
|
9
|
+
generation: bigint;
|
|
10
|
+
onFrame: (conn: ServerConnection, frame: Frame) => void;
|
|
11
|
+
onClose: (conn: ServerConnection) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class ServerConnection {
|
|
14
|
+
readonly connectionId: number;
|
|
15
|
+
generation: bigint;
|
|
16
|
+
private readonly socket;
|
|
17
|
+
private readonly parser;
|
|
18
|
+
private state;
|
|
19
|
+
private readonly onFrame;
|
|
20
|
+
private readonly onClose;
|
|
21
|
+
constructor(deps: ServerConnectionDeps);
|
|
22
|
+
getState(): ServerConnectionState;
|
|
23
|
+
markReady(): void;
|
|
24
|
+
/**
|
|
25
|
+
* Send a frame, auto-filling the (connectionId, generation) header.
|
|
26
|
+
* No-op once the connection is closed/evicted -- late callbacks from
|
|
27
|
+
* the daemon are common during eviction races and shouldn't crash.
|
|
28
|
+
*/
|
|
29
|
+
send(frame: {
|
|
30
|
+
type: number;
|
|
31
|
+
requestId: number;
|
|
32
|
+
payload: Buffer;
|
|
33
|
+
}): void;
|
|
34
|
+
/**
|
|
35
|
+
* Eviction protocol per the protocol: send a NACK telling the peer it has
|
|
36
|
+
* been superseded, then `end()` the socket so the kernel flushes the
|
|
37
|
+
* NACK before FIN. We do NOT call `destroy()` -- that drops in-flight
|
|
38
|
+
* bytes and would race the NACK delivery.
|
|
39
|
+
*/
|
|
40
|
+
evict(code: NackCode, message: string): void;
|
|
41
|
+
private handleChunk;
|
|
42
|
+
private handleClose;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=server-connection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-connection.d.ts","sourceRoot":"","sources":["../../../src/pty/host-daemon/server-connection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,KAAK,KAAK,EAIX,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAEL,KAAK,QAAQ,EAEd,MAAM,8BAA8B,CAAC;AAmBtC,MAAM,MAAM,qBAAqB,GAC7B,gBAAgB,GAChB,OAAO,GACP,SAAS,GACT,QAAQ,CAAC;AAEb,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,8EAA8E;IAC9E,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACxD,OAAO,EAAE,CAAC,IAAI,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC3C;AAED,qBAAa,gBAAgB;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqB;IAC5C,OAAO,CAAC,KAAK,CAA2C;IACxD,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;IAC1D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAkC;gBAE9C,IAAI,EAAE,oBAAoB;IAYtC,QAAQ,IAAI,qBAAqB;IAIjC,SAAS,IAAI,IAAI;IAIjB;;;;OAIG;IACH,IAAI,CAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI;IAiBvE;;;;;OAKG;IACH,KAAK,CAAC,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAY5C,OAAO,CAAC,WAAW;IAyBnB,OAAO,CAAC,WAAW;CAKpB"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { encodeFrame, FrameError, FrameParser, FrameType, } from "../host-protocol/frames.js";
|
|
2
|
+
import { encodeJsonPayload, } from "../host-protocol/messages.js";
|
|
3
|
+
export class ServerConnection {
|
|
4
|
+
connectionId;
|
|
5
|
+
generation;
|
|
6
|
+
socket;
|
|
7
|
+
parser = new FrameParser();
|
|
8
|
+
state = "awaiting-hello";
|
|
9
|
+
onFrame;
|
|
10
|
+
onClose;
|
|
11
|
+
constructor(deps) {
|
|
12
|
+
this.socket = deps.socket;
|
|
13
|
+
this.connectionId = deps.connectionId;
|
|
14
|
+
this.generation = deps.generation;
|
|
15
|
+
this.onFrame = deps.onFrame;
|
|
16
|
+
this.onClose = deps.onClose;
|
|
17
|
+
this.socket.on("data", (chunk) => this.handleChunk(chunk));
|
|
18
|
+
this.socket.on("close", () => this.handleClose());
|
|
19
|
+
this.socket.on("error", () => this.handleClose());
|
|
20
|
+
}
|
|
21
|
+
getState() {
|
|
22
|
+
return this.state;
|
|
23
|
+
}
|
|
24
|
+
markReady() {
|
|
25
|
+
if (this.state === "awaiting-hello")
|
|
26
|
+
this.state = "ready";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Send a frame, auto-filling the (connectionId, generation) header.
|
|
30
|
+
* No-op once the connection is closed/evicted -- late callbacks from
|
|
31
|
+
* the daemon are common during eviction races and shouldn't crash.
|
|
32
|
+
*/
|
|
33
|
+
send(frame) {
|
|
34
|
+
if (this.state === "closed" || this.state === "evicted")
|
|
35
|
+
return;
|
|
36
|
+
try {
|
|
37
|
+
const buf = encodeFrame({
|
|
38
|
+
type: frame.type,
|
|
39
|
+
connectionId: this.connectionId,
|
|
40
|
+
generation: this.generation,
|
|
41
|
+
requestId: frame.requestId,
|
|
42
|
+
payload: frame.payload,
|
|
43
|
+
});
|
|
44
|
+
this.socket.write(buf);
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
// Socket may have been destroyed mid-write; falling back to close.
|
|
48
|
+
this.handleClose();
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Eviction protocol per the protocol: send a NACK telling the peer it has
|
|
53
|
+
* been superseded, then `end()` the socket so the kernel flushes the
|
|
54
|
+
* NACK before FIN. We do NOT call `destroy()` -- that drops in-flight
|
|
55
|
+
* bytes and would race the NACK delivery.
|
|
56
|
+
*/
|
|
57
|
+
evict(code, message) {
|
|
58
|
+
if (this.state === "evicted" || this.state === "closed")
|
|
59
|
+
return;
|
|
60
|
+
const payload = { code, message };
|
|
61
|
+
this.send({
|
|
62
|
+
type: FrameType.NACK,
|
|
63
|
+
requestId: 0,
|
|
64
|
+
payload: encodeJsonPayload(payload),
|
|
65
|
+
});
|
|
66
|
+
this.state = "evicted";
|
|
67
|
+
this.socket.end();
|
|
68
|
+
}
|
|
69
|
+
handleChunk(chunk) {
|
|
70
|
+
if (this.state === "evicted" || this.state === "closed")
|
|
71
|
+
return;
|
|
72
|
+
let frames;
|
|
73
|
+
try {
|
|
74
|
+
frames = this.parser.push(chunk);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
if (err instanceof FrameError) {
|
|
78
|
+
this.evict(err.code === "FRAME_TOO_LARGE" ? "frame-too-large" : "frame-invalid", err.message);
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
this.evict("internal-error", "parser failure");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
for (const frame of frames) {
|
|
85
|
+
// onFrame callback may synchronously transition state via evict();
|
|
86
|
+
// re-read through getState() so TS doesn't carry the narrowing
|
|
87
|
+
// from the top-of-method guard across the callback boundary.
|
|
88
|
+
if (this.getState() === "evicted" || this.getState() === "closed")
|
|
89
|
+
return;
|
|
90
|
+
this.onFrame(this, frame);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
handleClose() {
|
|
94
|
+
if (this.state === "closed")
|
|
95
|
+
return;
|
|
96
|
+
this.state = "closed";
|
|
97
|
+
this.onClose(this);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=server-connection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-connection.js","sourceRoot":"","sources":["../../../src/pty/host-daemon/server-connection.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EAEX,UAAU,EACV,WAAW,EACX,SAAS,GACV,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,iBAAiB,GAGlB,MAAM,8BAA8B,CAAC;AAkCtC,MAAM,OAAO,gBAAgB;IAClB,YAAY,CAAS;IAC9B,UAAU,CAAS;IACF,MAAM,CAAS;IACf,MAAM,GAAG,IAAI,WAAW,EAAE,CAAC;IACpC,KAAK,GAA0B,gBAAgB,CAAC;IACvC,OAAO,CAAkC;IACzC,OAAO,CAAkC;IAE1D,YAAY,IAA0B;QACpC,IAAI,CAAC,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QAC1B,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC;QACtC,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAClC,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAE5B,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;QACnE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IACpD,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED,SAAS;QACP,IAAI,IAAI,CAAC,KAAK,KAAK,gBAAgB;YAAE,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,KAA2D;QAC9D,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS;YAAE,OAAO;QAChE,IAAI,CAAC;YACH,MAAM,GAAG,GAAG,WAAW,CAAC;gBACtB,IAAI,EAAE,KAAK,CAAC,IAAI;gBAChB,YAAY,EAAE,IAAI,CAAC,YAAY;gBAC/B,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;aACvB,CAAC,CAAC;YACH,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACzB,CAAC;QAAC,MAAM,CAAC;YACP,mEAAmE;YACnE,IAAI,CAAC,WAAW,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAc,EAAE,OAAe;QACnC,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO;QAChE,MAAM,OAAO,GAAgB,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;QAC/C,IAAI,CAAC,IAAI,CAAC;YACR,IAAI,EAAE,SAAS,CAAC,IAAI;YACpB,SAAS,EAAE,CAAC;YACZ,OAAO,EAAE,iBAAiB,CAAC,OAAO,CAAC;SACpC,CAAC,CAAC;QACH,IAAI,CAAC,KAAK,GAAG,SAAS,CAAC;QACvB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;IAEO,WAAW,CAAC,KAAa;QAC/B,IAAI,IAAI,CAAC,KAAK,KAAK,SAAS,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO;QAChE,IAAI,MAAe,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,UAAU,EAAE,CAAC;gBAC9B,IAAI,CAAC,KAAK,CACR,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,eAAe,EACpE,GAAG,CAAC,OAAO,CACZ,CAAC;gBACF,OAAO;YACT,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;YAC/C,OAAO;QACT,CAAC;QACD,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,mEAAmE;YACnE,+DAA+D;YAC/D,6DAA6D;YAC7D,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,SAAS,IAAI,IAAI,CAAC,QAAQ,EAAE,KAAK,QAAQ;gBAAE,OAAO;YAC1E,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;IAEO,WAAW;QACjB,IAAI,IAAI,CAAC,KAAK,KAAK,QAAQ;YAAE,OAAO;QACpC,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns true when a service-managed PTY-host unit is installed for the
|
|
3
|
+
* current user -- `~/Library/LaunchAgents/com.parasor.pty-host.plist` on
|
|
4
|
+
* macOS, `~/.config/systemd/user/parasor-pty-host.service` on linux.
|
|
5
|
+
*
|
|
6
|
+
* Filesystem-only: presence of the unit file is the "this machine has a
|
|
7
|
+
* canonical daemon owner" signal. We deliberately do NOT probe whether
|
|
8
|
+
* the unit is loaded or running -- a stopped service is still the
|
|
9
|
+
* canonical owner, and a manual `parasor` invocation must defer to it
|
|
10
|
+
* rather than spawn a competing daemon and fight over the canonical
|
|
11
|
+
* socket. `service restart --all` is the user's lever to bring it back.
|
|
12
|
+
*
|
|
13
|
+
* Used by host.ts to flip the `PARASOR_PTY_AUTOSTART` default off when
|
|
14
|
+
* a service unit exists; this prevents the unmanaged-daemon
|
|
15
|
+
* inconsistency that `service install` and `service restart --all`
|
|
16
|
+
* exist to heal.
|
|
17
|
+
*/
|
|
18
|
+
export interface ServiceDetectionDeps {
|
|
19
|
+
platform?: NodeJS.Platform;
|
|
20
|
+
home?: string;
|
|
21
|
+
existsSync?: (path: string) => boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare function isServiceManagedDaemonInstalled(deps?: ServiceDetectionDeps): boolean;
|
|
24
|
+
//# sourceMappingURL=service-detection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-detection.d.ts","sourceRoot":"","sources":["../../../src/pty/host-daemon/service-detection.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC;IAC3B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;CACxC;AAED,wBAAgB,+BAA+B,CAC7C,IAAI,GAAE,oBAAyB,GAC9B,OAAO,CAeT"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { existsSync } from "node:fs";
|
|
2
|
+
import { homedir, platform } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
export function isServiceManagedDaemonInstalled(deps = {}) {
|
|
5
|
+
const p = deps.platform ?? platform();
|
|
6
|
+
const h = deps.home ?? homedir();
|
|
7
|
+
const exists = deps.existsSync ?? existsSync;
|
|
8
|
+
if (p === "darwin") {
|
|
9
|
+
return exists(join(h, "Library", "LaunchAgents", "com.parasor.pty-host.plist"));
|
|
10
|
+
}
|
|
11
|
+
if (p === "linux") {
|
|
12
|
+
return exists(join(h, ".config", "systemd", "user", "parasor-pty-host.service"));
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=service-detection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-detection.js","sourceRoot":"","sources":["../../../src/pty/host-daemon/service-detection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAyBjC,MAAM,UAAU,+BAA+B,CAC7C,OAA6B,EAAE;IAE/B,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,IAAI,QAAQ,EAAE,CAAC;IACtC,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;IACjC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC;IAC7C,IAAI,CAAC,KAAK,QAAQ,EAAE,CAAC;QACnB,OAAO,MAAM,CACX,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,cAAc,EAAE,4BAA4B,CAAC,CACjE,CAAC;IACJ,CAAC;IACD,IAAI,CAAC,KAAK,OAAO,EAAE,CAAC;QAClB,OAAO,MAAM,CACX,IAAI,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,0BAA0B,CAAC,CAClE,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface WaitForDaemonSocketOpts {
|
|
2
|
+
/** Milliseconds before timeout (default 5000). */
|
|
3
|
+
timeoutMs?: number;
|
|
4
|
+
/** Poll interval in milliseconds (default 100). */
|
|
5
|
+
intervalMs?: number;
|
|
6
|
+
/**
|
|
7
|
+
* Probe function -- returns true when the socket is accepting connections.
|
|
8
|
+
* Defaults to `isSocketActive(path, 200)`. Injected in tests.
|
|
9
|
+
*/
|
|
10
|
+
probeFn?: (path: string) => Promise<boolean>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Polls `socketPath` until a daemon is listening or `timeoutMs` elapses.
|
|
14
|
+
*
|
|
15
|
+
* On timeout throws:
|
|
16
|
+
* Error: daemon socket did not become ready within ${timeoutMs}ms (path=${socketPath})
|
|
17
|
+
*
|
|
18
|
+
* Reuses `bootstrap.ts#isSocketActive` for the default probe so the
|
|
19
|
+
* same kernel-level socket-connect check is shared across both layers.
|
|
20
|
+
*/
|
|
21
|
+
export declare function waitForDaemonSocket(socketPath: string, opts?: WaitForDaemonSocketOpts): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=socket-ready.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-ready.d.ts","sourceRoot":"","sources":["../../../src/pty/host-daemon/socket-ready.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,uBAAuB;IACtC,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,mDAAmD;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,uBAA4B,GACjC,OAAO,CAAC,IAAI,CAAC,CA0Bf"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { isSocketActive } from "./bootstrap.js";
|
|
2
|
+
/**
|
|
3
|
+
* Polls `socketPath` until a daemon is listening or `timeoutMs` elapses.
|
|
4
|
+
*
|
|
5
|
+
* On timeout throws:
|
|
6
|
+
* Error: daemon socket did not become ready within ${timeoutMs}ms (path=${socketPath})
|
|
7
|
+
*
|
|
8
|
+
* Reuses `bootstrap.ts#isSocketActive` for the default probe so the
|
|
9
|
+
* same kernel-level socket-connect check is shared across both layers.
|
|
10
|
+
*/
|
|
11
|
+
export async function waitForDaemonSocket(socketPath, opts = {}) {
|
|
12
|
+
const timeoutMs = opts.timeoutMs ?? 5000;
|
|
13
|
+
const intervalMs = opts.intervalMs ?? 100;
|
|
14
|
+
const probeFn = opts.probeFn ?? ((p) => isSocketActive(p, 200));
|
|
15
|
+
const deadline = Date.now() + timeoutMs;
|
|
16
|
+
while (true) {
|
|
17
|
+
const ready = await probeFn(socketPath);
|
|
18
|
+
if (ready)
|
|
19
|
+
return;
|
|
20
|
+
const remaining = deadline - Date.now();
|
|
21
|
+
if (remaining <= 0) {
|
|
22
|
+
throw new Error(`daemon socket did not become ready within ${timeoutMs}ms (path=${socketPath})`);
|
|
23
|
+
}
|
|
24
|
+
await sleep(Math.min(intervalMs, remaining));
|
|
25
|
+
if (Date.now() >= deadline) {
|
|
26
|
+
throw new Error(`daemon socket did not become ready within ${timeoutMs}ms (path=${socketPath})`);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function sleep(ms) {
|
|
31
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=socket-ready.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket-ready.js","sourceRoot":"","sources":["../../../src/pty/host-daemon/socket-ready.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAchD;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,UAAkB,EAClB,OAAgC,EAAE;IAElC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC;IACzC,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,IAAI,GAAG,CAAC;IAC1C,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,CAAC,CAAC,CAAS,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,CAAC;IAExE,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;IAExC,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;QACxC,IAAI,KAAK;YAAE,OAAO;QAElB,MAAM,SAAS,GAAG,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACxC,IAAI,SAAS,IAAI,CAAC,EAAE,CAAC;YACnB,MAAM,IAAI,KAAK,CACb,6CAA6C,SAAS,YAAY,UAAU,GAAG,CAChF,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC,CAAC;QAE7C,IAAI,IAAI,CAAC,GAAG,EAAE,IAAI,QAAQ,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CACb,6CAA6C,SAAS,YAAY,UAAU,GAAG,CAChF,CAAC;QACJ,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AACjE,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import type { DaemonPaths } from "./paths.js";
|
|
3
|
+
export interface SpawnDaemonOptions {
|
|
4
|
+
paths: DaemonPaths;
|
|
5
|
+
/**
|
|
6
|
+
* Cap how long we wait for the daemon to start accepting connections.
|
|
7
|
+
* Tests may shrink this; production keeps the configured 5s ceiling.
|
|
8
|
+
*/
|
|
9
|
+
startupTimeoutMs?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Override how the entry script is located. Defaults to the bundled
|
|
12
|
+
* dist path resolved from this module's URL -- covers both `tsc` build
|
|
13
|
+
* output and `tsx` dev runtime.
|
|
14
|
+
*/
|
|
15
|
+
entryScriptPath?: string;
|
|
16
|
+
/**
|
|
17
|
+
* Test seam -- replaces `child_process.spawn`. Production passes the
|
|
18
|
+
* real spawn so the daemon goes detached; tests pass a stub that
|
|
19
|
+
* simulates the side-effects without forking.
|
|
20
|
+
*/
|
|
21
|
+
spawnFn?: typeof spawn;
|
|
22
|
+
/** Test seam for the connect probe. Defaults to net.connect. */
|
|
23
|
+
probeFn?: (path: string) => Promise<boolean>;
|
|
24
|
+
/** Test seam for the polling sleep. Defaults to setTimeout. */
|
|
25
|
+
sleepFn?: (ms: number) => Promise<void>;
|
|
26
|
+
/** Inherit env so the child sees PARASOR_PTY_SOCK / DEBUG flags. */
|
|
27
|
+
env?: NodeJS.ProcessEnv;
|
|
28
|
+
}
|
|
29
|
+
export declare class DaemonSpawnError extends Error {
|
|
30
|
+
readonly cause?: Error | undefined;
|
|
31
|
+
constructor(message: string, cause?: Error | undefined);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Attempt to start the `parasor-pty-host` daemon and wait until its
|
|
35
|
+
* socket is ready. Throws `DaemonSpawnError` on:
|
|
36
|
+
* - entry script missing (clearer than node's "ENOENT" exec error)
|
|
37
|
+
* - spawn() throws synchronously (permissions, exec format)
|
|
38
|
+
* - timeout waiting for socket (caller should treat as fatal:
|
|
39
|
+
* daemon may have crashed during boot, see paths.logFile)
|
|
40
|
+
*
|
|
41
|
+
* The returned Promise resolves once the socket *passes* a connect
|
|
42
|
+
* probe. Caller is expected to retry its own connect() afterwards.
|
|
43
|
+
*/
|
|
44
|
+
export declare function spawnDaemon(opts: SpawnDaemonOptions): Promise<void>;
|
|
45
|
+
//# sourceMappingURL=spawn-daemon.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spawn-daemon.d.ts","sourceRoot":"","sources":["../../../src/pty/host-daemon/spawn-daemon.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAM3C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,WAAW,CAAC;IACnB;;;OAGG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;OAIG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,OAAO,CAAC,EAAE,OAAO,KAAK,CAAC;IACvB,gEAAgE;IAChE,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC7C,+DAA+D;IAC/D,OAAO,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxC,oEAAoE;IACpE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED,qBAAa,gBAAiB,SAAQ,KAAK;IAGvC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK;gBADtB,OAAO,EAAE,MAAM,EACN,KAAK,CAAC,EAAE,KAAK,YAAA;CAKzB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,WAAW,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAkFzE"}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* -- best-effort daemon auto-spawn for the
|
|
3
|
+
* `createPtyHost("remote")` factory path. When the server is configured
|
|
4
|
+
* for daemon mode but `connect(socketPath)` fails with ECONNREFUSED /
|
|
5
|
+
* ENOENT, we fork a detached `parasor-pty-host` child, wait for the
|
|
6
|
+
* socket to become connectable (capped at ~5s), then let the caller
|
|
7
|
+
* retry the original connect().
|
|
8
|
+
*
|
|
9
|
+
* Auto-spawn is *opt-out* via `PARASOR_PTY_AUTOSTART=0` for ops who
|
|
10
|
+
* prefer a dedicated supervisor (launchd / systemd). The exit
|
|
11
|
+
* code from the daemon entry script is *not* awaited -- once the socket
|
|
12
|
+
* accepts connections, the supervisor relationship is over (detached +
|
|
13
|
+
* unref + stdio:"ignore"). If the daemon prints diagnostics they go to
|
|
14
|
+
* its own log file via the entry script.
|
|
15
|
+
*
|
|
16
|
+
* Why not retry inside the connect() loop? Because startup should attempt
|
|
17
|
+
* auto-spawn at most once per process boot. If the spawn fails (binary
|
|
18
|
+
* missing, permission denied), we surface the error rather than thrashing
|
|
19
|
+
* the lockfile.
|
|
20
|
+
*/
|
|
21
|
+
import { spawn } from "node:child_process";
|
|
22
|
+
import { existsSync } from "node:fs";
|
|
23
|
+
import * as net from "node:net";
|
|
24
|
+
import { dirname, resolve } from "node:path";
|
|
25
|
+
import { fileURLToPath } from "node:url";
|
|
26
|
+
export class DaemonSpawnError extends Error {
|
|
27
|
+
cause;
|
|
28
|
+
constructor(message, cause) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.cause = cause;
|
|
31
|
+
this.name = "DaemonSpawnError";
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Attempt to start the `parasor-pty-host` daemon and wait until its
|
|
36
|
+
* socket is ready. Throws `DaemonSpawnError` on:
|
|
37
|
+
* - entry script missing (clearer than node's "ENOENT" exec error)
|
|
38
|
+
* - spawn() throws synchronously (permissions, exec format)
|
|
39
|
+
* - timeout waiting for socket (caller should treat as fatal:
|
|
40
|
+
* daemon may have crashed during boot, see paths.logFile)
|
|
41
|
+
*
|
|
42
|
+
* The returned Promise resolves once the socket *passes* a connect
|
|
43
|
+
* probe. Caller is expected to retry its own connect() afterwards.
|
|
44
|
+
*/
|
|
45
|
+
export async function spawnDaemon(opts) {
|
|
46
|
+
const timeoutMs = opts.startupTimeoutMs ?? 5_000;
|
|
47
|
+
const entry = opts.entryScriptPath ?? defaultEntryScriptPath();
|
|
48
|
+
const spawnFn = opts.spawnFn ?? spawn;
|
|
49
|
+
const probe = opts.probeFn ?? probeSocket;
|
|
50
|
+
const sleep = opts.sleepFn ?? ((ms) => new Promise((r) => setTimeout(r, ms)));
|
|
51
|
+
/*
|
|
52
|
+
* production runs after `pnpm build`, but the
|
|
53
|
+
* dev/test path (`tsx --watch`) never produces `entry.js`. Resolve
|
|
54
|
+
* to `entry.ts` and prepend `--import tsx` to the node args so the
|
|
55
|
+
* tsx loader handles the TypeScript transparently. We pick the
|
|
56
|
+
* fallback only when `entry.js` is genuinely missing -- this keeps
|
|
57
|
+
* production unchanged.
|
|
58
|
+
*/
|
|
59
|
+
const tsFallback = entry.endsWith(".js") ? `${entry.slice(0, -3)}.ts` : null;
|
|
60
|
+
let resolvedEntry = entry;
|
|
61
|
+
let nodeArgs;
|
|
62
|
+
if (existsSync(entry)) {
|
|
63
|
+
nodeArgs = [entry];
|
|
64
|
+
}
|
|
65
|
+
else if (tsFallback && existsSync(tsFallback)) {
|
|
66
|
+
resolvedEntry = tsFallback;
|
|
67
|
+
nodeArgs = ["--import", "tsx", tsFallback];
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
throw new DaemonSpawnError(`parasor-pty-host entry script not found at ${entry} ` +
|
|
71
|
+
`(also tried ${tsFallback ?? "(no .ts fallback)"}). ` +
|
|
72
|
+
"Run `pnpm --filter @parasor/server build` to produce dist/, " +
|
|
73
|
+
"set PARASOR_PTY_AUTOSTART=0 and start the daemon manually, " +
|
|
74
|
+
"or rebuild @parasor/server.");
|
|
75
|
+
}
|
|
76
|
+
let child = null;
|
|
77
|
+
try {
|
|
78
|
+
child = spawnFn(process.execPath, nodeArgs, {
|
|
79
|
+
detached: true,
|
|
80
|
+
stdio: "ignore",
|
|
81
|
+
env: opts.env ?? process.env,
|
|
82
|
+
});
|
|
83
|
+
// detached spawn() can emit `error` asynchronously
|
|
84
|
+
// for ENOENT / EACCES / exec format. Without a listener it becomes
|
|
85
|
+
// an unhandled error event in the parent. We swallow here because
|
|
86
|
+
// the probe loop below is the authoritative readiness signal -- a
|
|
87
|
+
// dead child surfaces as a startup-timeout error instead of a
|
|
88
|
+
// parent crash.
|
|
89
|
+
child.once("error", () => {
|
|
90
|
+
/* swallow -- startup-timeout path reports the failure */
|
|
91
|
+
});
|
|
92
|
+
child.unref();
|
|
93
|
+
}
|
|
94
|
+
catch (err) {
|
|
95
|
+
throw new DaemonSpawnError(`failed to spawn parasor-pty-host (entry=${resolvedEntry}): ${err.message}`, err);
|
|
96
|
+
}
|
|
97
|
+
const deadline = Date.now() + timeoutMs;
|
|
98
|
+
const pollMs = 100;
|
|
99
|
+
while (Date.now() < deadline) {
|
|
100
|
+
if (await probe(opts.paths.socketPath))
|
|
101
|
+
return;
|
|
102
|
+
await sleep(pollMs);
|
|
103
|
+
}
|
|
104
|
+
// timeout means our spawned child either never
|
|
105
|
+
// bound the socket or is hung mid-startup. Sending SIGTERM to the
|
|
106
|
+
// child's pid (only one we have -- pgid is unknown to the parent)
|
|
107
|
+
// prevents an orphan daemon process from sitting around eating fds.
|
|
108
|
+
// Best-effort: child may have exited normally just before we hit
|
|
109
|
+
// the deadline (race), or may not yet have setsid'd; either way the
|
|
110
|
+
// signal is harmless.
|
|
111
|
+
if (child && typeof child.pid === "number") {
|
|
112
|
+
try {
|
|
113
|
+
process.kill(child.pid, "SIGTERM");
|
|
114
|
+
}
|
|
115
|
+
catch {
|
|
116
|
+
/* already gone */
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
throw new DaemonSpawnError(`parasor-pty-host did not become ready within ${timeoutMs}ms (socket=${opts.paths.socketPath}). ` +
|
|
120
|
+
`Check ${opts.paths.logFile} for daemon-side errors.`);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Non-blocking connect probe -- the same shape as
|
|
124
|
+
* `bootstrap.ts#isSocketActive` but with a tighter timeout suitable
|
|
125
|
+
* for tight polling. Returns true on `connect`, false on every error.
|
|
126
|
+
*/
|
|
127
|
+
function probeSocket(path) {
|
|
128
|
+
return new Promise((resolve) => {
|
|
129
|
+
const sock = net.connect(path);
|
|
130
|
+
const cleanup = (ok) => {
|
|
131
|
+
sock.removeAllListeners();
|
|
132
|
+
try {
|
|
133
|
+
sock.destroy();
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
/* ignore */
|
|
137
|
+
}
|
|
138
|
+
resolve(ok);
|
|
139
|
+
};
|
|
140
|
+
sock.once("connect", () => cleanup(true));
|
|
141
|
+
sock.once("error", () => cleanup(false));
|
|
142
|
+
sock.setTimeout(250, () => cleanup(false));
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Resolve the bundled daemon entry script path. Production points at
|
|
147
|
+
* `dist/pty/host-daemon/entry.js`. The dev/test runtime (`tsx --watch`)
|
|
148
|
+
* skips the build step entirely; spawnDaemon() handles that by falling
|
|
149
|
+
* back to `entry.ts` with a `--import tsx` node-arg prefix when the .js
|
|
150
|
+
* file is missing. */
|
|
151
|
+
function defaultEntryScriptPath() {
|
|
152
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
153
|
+
return resolve(here, "entry.js");
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=spawn-daemon.js.map
|