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,335 @@
|
|
|
1
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { DEFAULT_DROP_SIZE_HARD_MAX_BYTES, DEFAULT_DROP_SIZE_MAX_BYTES, normalizeIdeCommands, normalizePaneCommands, normalizeWorktreeLocalFileAllowlist, } from "@parasor/shared";
|
|
5
|
+
const EMPTY_STATE = {
|
|
6
|
+
version: 1,
|
|
7
|
+
projects: [],
|
|
8
|
+
projectStates: {},
|
|
9
|
+
sessions: [],
|
|
10
|
+
sessionRecords: [],
|
|
11
|
+
ideCommands: [],
|
|
12
|
+
paneCommands: [],
|
|
13
|
+
serviceConfig: {
|
|
14
|
+
preventIdleSleep: false,
|
|
15
|
+
portDetection: "all-interfaces",
|
|
16
|
+
dropSizeMaxBytes: DEFAULT_DROP_SIZE_MAX_BYTES,
|
|
17
|
+
dropSizeHardMaxBytes: DEFAULT_DROP_SIZE_HARD_MAX_BYTES,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
function normalizePortDetection(value) {
|
|
21
|
+
// Legacy "all" mode (every loopback port, retired in local notify-mode cleanup) folds back to
|
|
22
|
+
// "all-interfaces" -- closer to the user's original intent than silently
|
|
23
|
+
// disabling notifications for someone who had explicitly opted in.
|
|
24
|
+
if (value === "all-interfaces" || value === "off")
|
|
25
|
+
return value;
|
|
26
|
+
return "all-interfaces";
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Accept either missing fields or non-positive / non-finite junk. The
|
|
30
|
+
* hard cap also bounds the soft cap to guard a hand-edited state.json
|
|
31
|
+
* that set `dropSizeMaxBytes > dropSizeHardMaxBytes`.
|
|
32
|
+
*/
|
|
33
|
+
function normalizeDropCap(value, fallback, ceiling) {
|
|
34
|
+
if (typeof value !== "number" || !Number.isFinite(value) || value <= 0) {
|
|
35
|
+
return fallback;
|
|
36
|
+
}
|
|
37
|
+
return Math.min(value, ceiling);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Backfill fields added after v1 shipped. Existing state.json files
|
|
41
|
+
* predate these fields and would otherwise surface `undefined` to
|
|
42
|
+
* consumers that treat them as required.
|
|
43
|
+
*/
|
|
44
|
+
function migrate(raw) {
|
|
45
|
+
const serviceConfig = raw.serviceConfig ?? {};
|
|
46
|
+
const hardMax = normalizeDropCap(serviceConfig.dropSizeHardMaxBytes, DEFAULT_DROP_SIZE_HARD_MAX_BYTES, Number.POSITIVE_INFINITY);
|
|
47
|
+
const softMax = normalizeDropCap(serviceConfig.dropSizeMaxBytes, DEFAULT_DROP_SIZE_MAX_BYTES, hardMax);
|
|
48
|
+
return {
|
|
49
|
+
...structuredClone(EMPTY_STATE),
|
|
50
|
+
...raw,
|
|
51
|
+
projects: Array.isArray(raw.projects)
|
|
52
|
+
? raw.projects.map((project) => {
|
|
53
|
+
const worktreeLocalFileAllowlist = normalizeWorktreeLocalFileAllowlist(project.worktreeLocalFileAllowlist);
|
|
54
|
+
return {
|
|
55
|
+
...project,
|
|
56
|
+
...(worktreeLocalFileAllowlist.length > 0 && {
|
|
57
|
+
worktreeLocalFileAllowlist,
|
|
58
|
+
}),
|
|
59
|
+
};
|
|
60
|
+
})
|
|
61
|
+
: [],
|
|
62
|
+
sessionRecords: Array.isArray(raw.sessionRecords) ? raw.sessionRecords : [],
|
|
63
|
+
ideCommands: normalizeIdeCommands(raw.ideCommands),
|
|
64
|
+
paneCommands: normalizePaneCommands(raw.paneCommands),
|
|
65
|
+
serviceConfig: {
|
|
66
|
+
preventIdleSleep: serviceConfig.preventIdleSleep ?? false,
|
|
67
|
+
portDetection: normalizePortDetection(serviceConfig.portDetection),
|
|
68
|
+
dropSizeMaxBytes: softMax,
|
|
69
|
+
dropSizeHardMaxBytes: hardMax,
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
export class AppStateReadOnlyError extends Error {
|
|
74
|
+
constructor() {
|
|
75
|
+
super("AppStateStore session domain is read-only in remote daemon mode (daemon owns sessions/sessionRecords); use internalMutate() for daemon-IPC reconciliation, or mutateProjects()/mutateServiceConfig()/mutatePaneCommands()/mutateIdeCommands() for server-owned domains");
|
|
76
|
+
this.name = "AppStateReadOnlyError";
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
export class AppStateStore {
|
|
80
|
+
state;
|
|
81
|
+
dir;
|
|
82
|
+
filePath;
|
|
83
|
+
tmpPath;
|
|
84
|
+
debounceMs;
|
|
85
|
+
timer = null;
|
|
86
|
+
destroyed = false;
|
|
87
|
+
/**
|
|
88
|
+
* Daemon-mode mirror guard.
|
|
89
|
+
* When true, only the **session domain** (`sessions`, `sessionRecords`)
|
|
90
|
+
* is read-only -- the daemon owns those writes. Project / projectStates
|
|
91
|
+
* / serviceConfig stay writable in both modes (the daemon never touches
|
|
92
|
+
* them; their only writer is the server). The daemon-IPC reconciler
|
|
93
|
+
* applies session-domain broadcasts via `internalMutate()` to bypass
|
|
94
|
+
* this guard. Default false (in-process mode owns all writes).
|
|
95
|
+
*/
|
|
96
|
+
sessionsReadOnly = false;
|
|
97
|
+
/**
|
|
98
|
+
* daemon state ownership -- when set, write() routes the in-memory state through the
|
|
99
|
+
* delegate instead of writing state.json directly. The remote-mode
|
|
100
|
+
* server installs an IPC delegate so the daemon (sole file writer)
|
|
101
|
+
* persists the server-owned domains. Mirror updates (internalMutate)
|
|
102
|
+
* skip the delegate because they reflect domain the writer already
|
|
103
|
+
* persisted.
|
|
104
|
+
*/
|
|
105
|
+
persistenceDelegate = null;
|
|
106
|
+
/**
|
|
107
|
+
* Tracks the most recent debounced-write promise. `flush()` awaits
|
|
108
|
+
* it BEFORE issuing its own write so a shutdown-time flush surfaces
|
|
109
|
+
* any in-flight failure (codex MED daemon state ownership/round 2). The promise resolves
|
|
110
|
+
* whether the underlying write succeeded or rejected -- failures are
|
|
111
|
+
* routed through `onPersistError` and then silenced here so awaiting
|
|
112
|
+
* never throws on a shutdown path.
|
|
113
|
+
*/
|
|
114
|
+
lastWrite = Promise.resolve();
|
|
115
|
+
onPersistError;
|
|
116
|
+
constructor(opts = {}) {
|
|
117
|
+
const dir = opts.dir ?? join(homedir(), ".config", "parasor");
|
|
118
|
+
this.debounceMs = opts.debounceMs ?? 300;
|
|
119
|
+
this.filePath = join(dir, "state.json");
|
|
120
|
+
this.tmpPath = join(dir, "state.json.tmp");
|
|
121
|
+
this.onPersistError =
|
|
122
|
+
opts.onPersistError === undefined
|
|
123
|
+
? (err) => console.error("AppStateStore: debounced persist failed (state.json may be stale):", err)
|
|
124
|
+
: (opts.onPersistError ?? (() => undefined));
|
|
125
|
+
mkdirSync(dir, { recursive: true });
|
|
126
|
+
this.dir = dir;
|
|
127
|
+
this.state = this.load();
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Directory containing `state.json`. Used by the mode-marker subsystem
|
|
131
|
+
* so the cross-mode mutex collides on the
|
|
132
|
+
* same directory the store persists into, regardless of overrides.
|
|
133
|
+
*/
|
|
134
|
+
getDir() {
|
|
135
|
+
return this.dir;
|
|
136
|
+
}
|
|
137
|
+
load() {
|
|
138
|
+
try {
|
|
139
|
+
const raw = readFileSync(this.filePath, "utf-8");
|
|
140
|
+
return migrate(JSON.parse(raw));
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
if (isNodeError(err) && err.code === "ENOENT") {
|
|
144
|
+
return structuredClone(EMPTY_STATE);
|
|
145
|
+
}
|
|
146
|
+
// Corrupted -- rename and start fresh
|
|
147
|
+
const timestamp = Date.now();
|
|
148
|
+
try {
|
|
149
|
+
renameSync(this.filePath, `${this.filePath}.corrupted-${timestamp}`);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
// ignore rename failure (file may not exist)
|
|
153
|
+
}
|
|
154
|
+
return structuredClone(EMPTY_STATE);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
get() {
|
|
158
|
+
return this.state;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Server-owned domain: project records (`projects` array). Always
|
|
162
|
+
* writable, even in remote daemon mode -- the daemon never touches
|
|
163
|
+
* project records, so the server is unconditionally authoritative.
|
|
164
|
+
*
|
|
165
|
+
* The callback may also touch `projectStates` since both fields move
|
|
166
|
+
* together (project create/delete must keep the per-project state map
|
|
167
|
+
* in lock-step). Use `mutateProjectStates` for pure projectStates
|
|
168
|
+
* writes (panes, layout, focus) without project-record changes.
|
|
169
|
+
*/
|
|
170
|
+
mutateProjects(fn) {
|
|
171
|
+
if (this.destroyed)
|
|
172
|
+
return;
|
|
173
|
+
fn(this.state);
|
|
174
|
+
this.scheduleFlush();
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Server-owned domain: per-project UI state (`projectStates`). Always
|
|
178
|
+
* writable. Pane layout, focus, file-tree state, etc. -- none of which
|
|
179
|
+
* the daemon knows about. `projects` and `sessions` are exposed
|
|
180
|
+
* read-only so reconciliation logic can compute orphan sets without
|
|
181
|
+
* being able to write into either domain.
|
|
182
|
+
*/
|
|
183
|
+
mutateProjectStates(fn) {
|
|
184
|
+
if (this.destroyed)
|
|
185
|
+
return;
|
|
186
|
+
fn(this.state);
|
|
187
|
+
this.scheduleFlush();
|
|
188
|
+
}
|
|
189
|
+
/**
|
|
190
|
+
* Server-owned domain: `serviceConfig`. Always writable. Daemon does
|
|
191
|
+
* not consume serviceConfig; only the server reads it.
|
|
192
|
+
*/
|
|
193
|
+
mutateServiceConfig(fn) {
|
|
194
|
+
if (this.destroyed)
|
|
195
|
+
return;
|
|
196
|
+
fn(this.state);
|
|
197
|
+
this.scheduleFlush();
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Server-owned domain: terminal launcher commands. Always writable; the
|
|
201
|
+
* daemon only owns PTY sessions/sessionRecords.
|
|
202
|
+
*/
|
|
203
|
+
mutatePaneCommands(fn) {
|
|
204
|
+
if (this.destroyed)
|
|
205
|
+
return;
|
|
206
|
+
fn(this.state);
|
|
207
|
+
this.scheduleFlush();
|
|
208
|
+
}
|
|
209
|
+
mutateIdeCommands(fn) {
|
|
210
|
+
if (this.destroyed)
|
|
211
|
+
return;
|
|
212
|
+
fn(this.state);
|
|
213
|
+
this.scheduleFlush();
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Daemon-owned domain: `sessions` + `sessionRecords`. In remote mode
|
|
217
|
+
* the server is a mirror -- server-side writes throw to surface the
|
|
218
|
+
* ownership violation. The daemon-IPC reconciler uses `internalMutate`
|
|
219
|
+
* to apply broadcasts without tripping this guard. `projects` is
|
|
220
|
+
* exposed read-only for project-membership filters used during
|
|
221
|
+
* startup reconciliation.
|
|
222
|
+
*/
|
|
223
|
+
mutateSessions(fn) {
|
|
224
|
+
if (this.destroyed)
|
|
225
|
+
return;
|
|
226
|
+
if (this.sessionsReadOnly) {
|
|
227
|
+
throw new AppStateReadOnlyError();
|
|
228
|
+
}
|
|
229
|
+
fn(this.state);
|
|
230
|
+
this.scheduleFlush();
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Bypass the session-domain guard. Reserved for the daemon-IPC
|
|
234
|
+
* reconciler on the server side: SESSION_UPDATE / SESSION_LIST
|
|
235
|
+
* broadcasts apply here without tripping `mutateSessions`. In
|
|
236
|
+
* delegate mode the mutation is mirror-only -- the daemon already
|
|
237
|
+
* persisted these domains before broadcasting, so the server
|
|
238
|
+
* skips the IPC round-trip. Without a delegate (in-process / daemon
|
|
239
|
+
* itself), the call schedules a normal file flush so the local
|
|
240
|
+
* state.json stays coherent for UI reload.
|
|
241
|
+
*/
|
|
242
|
+
internalMutate(fn) {
|
|
243
|
+
if (this.destroyed)
|
|
244
|
+
return;
|
|
245
|
+
fn(this.state);
|
|
246
|
+
if (!this.persistenceDelegate) {
|
|
247
|
+
this.scheduleFlush();
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Toggle the session-domain guard (narrowed by daemon state ownership). Idempotent.
|
|
252
|
+
* Called once at factory-time after the PtyHost mode is decided
|
|
253
|
+
* (in-process -> false, remote -> true) -- runtime flipping is not
|
|
254
|
+
* supported (by design).
|
|
255
|
+
*/
|
|
256
|
+
setSessionsReadOnly(readOnly) {
|
|
257
|
+
this.sessionsReadOnly = readOnly;
|
|
258
|
+
}
|
|
259
|
+
isSessionsReadOnly() {
|
|
260
|
+
return this.sessionsReadOnly;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* daemon state ownership -- install/uninstall the IPC persistence delegate. In remote
|
|
264
|
+
* mode the server installs the delegate after RemotePtyHost.connect
|
|
265
|
+
* succeeds. Idempotent; pass null to fall back to direct file writes
|
|
266
|
+
* (e.g. when host factory recreates an in-process host). Setting the
|
|
267
|
+
* delegate does not flush -- callers do that explicitly if the next
|
|
268
|
+
* snapshot needs to land on disk before further work.
|
|
269
|
+
*/
|
|
270
|
+
setPersistenceDelegate(delegate) {
|
|
271
|
+
this.persistenceDelegate = delegate;
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Force a flush *now* and await the underlying persistence (file
|
|
275
|
+
* write or IPC ACK). Used by shutdown paths that must observe IO
|
|
276
|
+
* errors before deciding whether to write the daemon-graceful
|
|
277
|
+
* marker. Synchronous in spirit (cancels the debounce timer); the
|
|
278
|
+
* Promise reflects the persist step.
|
|
279
|
+
*/
|
|
280
|
+
async flush() {
|
|
281
|
+
if (this.timer !== null) {
|
|
282
|
+
clearTimeout(this.timer);
|
|
283
|
+
this.timer = null;
|
|
284
|
+
}
|
|
285
|
+
if (this.destroyed)
|
|
286
|
+
return;
|
|
287
|
+
/*
|
|
288
|
+
* -- first drain any debounce-scheduled
|
|
289
|
+
* write that already fired, so the shutdown path observes its
|
|
290
|
+
* outcome (errors are surfaced through onPersistError; the
|
|
291
|
+
* Promise itself never rejects). Then perform a fresh synchronous-
|
|
292
|
+
* in-spirit write so the in-memory snapshot reaches disk / the
|
|
293
|
+
* IPC peer.
|
|
294
|
+
*/
|
|
295
|
+
await this.lastWrite;
|
|
296
|
+
await this.write();
|
|
297
|
+
}
|
|
298
|
+
/** Cancel pending timer and ignore future mutate calls (for test teardown). */
|
|
299
|
+
destroy() {
|
|
300
|
+
if (this.timer !== null) {
|
|
301
|
+
clearTimeout(this.timer);
|
|
302
|
+
this.timer = null;
|
|
303
|
+
}
|
|
304
|
+
this.destroyed = true;
|
|
305
|
+
}
|
|
306
|
+
scheduleFlush() {
|
|
307
|
+
if (this.timer !== null) {
|
|
308
|
+
clearTimeout(this.timer);
|
|
309
|
+
}
|
|
310
|
+
this.timer = setTimeout(() => {
|
|
311
|
+
this.timer = null;
|
|
312
|
+
// Track the chain so flush() can await the latest in-flight
|
|
313
|
+
// write. -- route failures through
|
|
314
|
+
// onPersistError so a debounced delegate.persist() reject (IPC
|
|
315
|
+
// NACK / disk EIO) does not silently lose project / projectStates
|
|
316
|
+
// / serviceConfig changes. The catch returns void so awaiting
|
|
317
|
+
// lastWrite never rejects on shutdown paths.
|
|
318
|
+
this.lastWrite = this.write().catch((err) => {
|
|
319
|
+
this.onPersistError(err);
|
|
320
|
+
});
|
|
321
|
+
}, this.debounceMs);
|
|
322
|
+
}
|
|
323
|
+
async write() {
|
|
324
|
+
if (this.persistenceDelegate) {
|
|
325
|
+
await this.persistenceDelegate.persist(this.state);
|
|
326
|
+
return;
|
|
327
|
+
}
|
|
328
|
+
writeFileSync(this.tmpPath, JSON.stringify(this.state), "utf-8");
|
|
329
|
+
renameSync(this.tmpPath, this.filePath);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
function isNodeError(err) {
|
|
333
|
+
return err instanceof Error && "code" in err;
|
|
334
|
+
}
|
|
335
|
+
//# sourceMappingURL=app-state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app-state.js","sourceRoot":"","sources":["../../src/state/app-state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAEL,gCAAgC,EAChC,2BAA2B,EAC3B,oBAAoB,EACpB,qBAAqB,EACrB,mCAAmC,GAKpC,MAAM,iBAAiB,CAAC;AAEzB,MAAM,WAAW,GAAa;IAC5B,OAAO,EAAE,CAAC;IACV,QAAQ,EAAE,EAAE;IACZ,aAAa,EAAE,EAAE;IACjB,QAAQ,EAAE,EAAE;IACZ,cAAc,EAAE,EAAE;IAClB,WAAW,EAAE,EAAE;IACf,YAAY,EAAE,EAAE;IAChB,aAAa,EAAE;QACb,gBAAgB,EAAE,KAAK;QACvB,aAAa,EAAE,gBAAgB;QAC/B,gBAAgB,EAAE,2BAA2B;QAC7C,oBAAoB,EAAE,gCAAgC;KACvD;CACF,C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AAE,CAAC;YACxB,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;QACD,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC3B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;YAClB,4DAA4D;YAC5D,mCAAmC;YACnC,+DAA+D;YAC/D,kEAAkE;YAClE,8DAA8D;YAC9D,6CAA6C;YAC7C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBAC1C,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;YAC3B,CAAC,CAAC,CAAC;QACL,CAAC,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,KAAK;QACjB,IAAI,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAC7B,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACnD,OAAO;QACT,CAAC;QACD,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC,CAAC;QACjE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1C,CAAC;CACF;AAED,SAAS,WAAW,CAAC,GAAY;IAC/B,OAAO,GAAG,YAAY,KAAK,IAAI,MAAM,IAAI,GAAG,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type Project, type Session } from "@parasor/shared";
|
|
2
|
+
import type { AppStateStore } from "./app-state.js";
|
|
3
|
+
export interface CreateProjectOpts {
|
|
4
|
+
path: string;
|
|
5
|
+
name?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface UpdateProjectOpts {
|
|
8
|
+
name?: string;
|
|
9
|
+
pinned?: boolean;
|
|
10
|
+
readOnly?: boolean;
|
|
11
|
+
worktreeLocalFileAllowlist?: string[];
|
|
12
|
+
}
|
|
13
|
+
export declare class ProjectManager {
|
|
14
|
+
private readonly store;
|
|
15
|
+
constructor(store: AppStateStore);
|
|
16
|
+
create(opts: CreateProjectOpts): Project;
|
|
17
|
+
list(): Project[];
|
|
18
|
+
get(id: string): Project | undefined;
|
|
19
|
+
update(id: string, opts: UpdateProjectOpts): Project | undefined;
|
|
20
|
+
delete(id: string, force?: boolean): boolean;
|
|
21
|
+
getProjectSessions(projectId: string): Session[];
|
|
22
|
+
touchProject(id: string): void;
|
|
23
|
+
/**
|
|
24
|
+
* Apply a manual sort order via DnD reorder. `ids` must contain every
|
|
25
|
+
* existing project id exactly once. Assigns `order` = index for each.
|
|
26
|
+
* Returns the new project list, or `undefined` when the id set mismatches.
|
|
27
|
+
*/
|
|
28
|
+
reorder(ids: string[]): Project[] | undefined;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=project-manager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-manager.d.ts","sourceRoot":"","sources":["../../src/state/project-manager.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,OAAO,EACZ,KAAK,OAAO,EACb,MAAM,iBAAiB,CAAC;AAEzB,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAiB;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,0BAA0B,CAAC,EAAE,MAAM,EAAE,CAAC;CACvC;AAED,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,KAAK;gBAAL,KAAK,EAAE,aAAa;IAEjD,MAAM,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO;IA8BxC,IAAI,IAAI,OAAO,EAAE;IAIjB,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS;IAIpC,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,GAAG,SAAS;IAsBhE,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO;IAuB1C,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,EAAE;IAIhD,YAAY,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAU9B;;;;OAIG;IACH,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,GAAG,SAAS;CAkB9C"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { basename } from "node:path";
|
|
3
|
+
import { normalizeWorktreeLocalFileAllowlist, } from "@parasor/shared";
|
|
4
|
+
import { expandUserHome } from "../lib/path.js";
|
|
5
|
+
export class ProjectManager {
|
|
6
|
+
store;
|
|
7
|
+
constructor(store) {
|
|
8
|
+
this.store = store;
|
|
9
|
+
}
|
|
10
|
+
create(opts) {
|
|
11
|
+
const path = expandUserHome(opts.path);
|
|
12
|
+
const existing = this.store.get().projects.find((p) => p.path === path);
|
|
13
|
+
if (existing)
|
|
14
|
+
return existing;
|
|
15
|
+
const now = Date.now();
|
|
16
|
+
const project = {
|
|
17
|
+
id: randomUUID(),
|
|
18
|
+
name: opts.name ?? basename(path),
|
|
19
|
+
path,
|
|
20
|
+
createdAt: now,
|
|
21
|
+
lastAccessedAt: now,
|
|
22
|
+
};
|
|
23
|
+
this.store.mutateProjects((s) => {
|
|
24
|
+
s.projects.push(project);
|
|
25
|
+
s.projectStates[project.id] = {
|
|
26
|
+
projectId: project.id,
|
|
27
|
+
layout: null,
|
|
28
|
+
worktrees: [],
|
|
29
|
+
openFiles: [],
|
|
30
|
+
lastFocusedPaneId: null,
|
|
31
|
+
focusedPaneId: null,
|
|
32
|
+
lastAccessedAt: now,
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return project;
|
|
36
|
+
}
|
|
37
|
+
list() {
|
|
38
|
+
return [...this.store.get().projects];
|
|
39
|
+
}
|
|
40
|
+
get(id) {
|
|
41
|
+
return this.store.get().projects.find((p) => p.id === id);
|
|
42
|
+
}
|
|
43
|
+
update(id, opts) {
|
|
44
|
+
let result;
|
|
45
|
+
this.store.mutateProjects((s) => {
|
|
46
|
+
const idx = s.projects.findIndex((p) => p.id === id);
|
|
47
|
+
if (idx === -1)
|
|
48
|
+
return;
|
|
49
|
+
const project = s.projects[idx];
|
|
50
|
+
if (opts.name !== undefined)
|
|
51
|
+
project.name = opts.name;
|
|
52
|
+
if (opts.pinned !== undefined)
|
|
53
|
+
project.pinned = opts.pinned;
|
|
54
|
+
if (opts.readOnly !== undefined)
|
|
55
|
+
project.readOnly = opts.readOnly;
|
|
56
|
+
if (opts.worktreeLocalFileAllowlist !== undefined) {
|
|
57
|
+
project.worktreeLocalFileAllowlist =
|
|
58
|
+
normalizeWorktreeLocalFileAllowlist(opts.worktreeLocalFileAllowlist);
|
|
59
|
+
}
|
|
60
|
+
result = project;
|
|
61
|
+
});
|
|
62
|
+
return result;
|
|
63
|
+
}
|
|
64
|
+
delete(id, force = false) {
|
|
65
|
+
const project = this.get(id);
|
|
66
|
+
if (!project)
|
|
67
|
+
return false;
|
|
68
|
+
if (project.pinned && !force)
|
|
69
|
+
return false;
|
|
70
|
+
this.store.mutateProjects((s) => {
|
|
71
|
+
s.projects = s.projects.filter((p) => p.id !== id);
|
|
72
|
+
delete s.projectStates[id];
|
|
73
|
+
});
|
|
74
|
+
/*
|
|
75
|
+
* daemon state ownership -- orphan-session cleanup is cross-domain (sessions are
|
|
76
|
+
* daemon-owned in remote mode). Use internalMutate so the call
|
|
77
|
+
* succeeds in both modes: in-process flushes the filtered list,
|
|
78
|
+
* remote applies mirror-only (daemon's own SESSION_LIST broadcast
|
|
79
|
+
* is the source of truth there).
|
|
80
|
+
*/
|
|
81
|
+
this.store.internalMutate((s) => {
|
|
82
|
+
s.sessions = s.sessions.filter((sess) => sess.projectId !== id);
|
|
83
|
+
});
|
|
84
|
+
return true;
|
|
85
|
+
}
|
|
86
|
+
getProjectSessions(projectId) {
|
|
87
|
+
return this.store.get().sessions.filter((s) => s.projectId === projectId);
|
|
88
|
+
}
|
|
89
|
+
touchProject(id) {
|
|
90
|
+
const now = Date.now();
|
|
91
|
+
this.store.mutateProjects((s) => {
|
|
92
|
+
const project = s.projects.find((p) => p.id === id);
|
|
93
|
+
if (project)
|
|
94
|
+
project.lastAccessedAt = now;
|
|
95
|
+
const ps = s.projectStates[id];
|
|
96
|
+
if (ps)
|
|
97
|
+
ps.lastAccessedAt = now;
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Apply a manual sort order via DnD reorder. `ids` must contain every
|
|
102
|
+
* existing project id exactly once. Assigns `order` = index for each.
|
|
103
|
+
* Returns the new project list, or `undefined` when the id set mismatches.
|
|
104
|
+
*/
|
|
105
|
+
reorder(ids) {
|
|
106
|
+
const current = this.store.get().projects;
|
|
107
|
+
if (ids.length !== current.length)
|
|
108
|
+
return undefined;
|
|
109
|
+
const idSet = new Set(ids);
|
|
110
|
+
if (idSet.size !== ids.length)
|
|
111
|
+
return undefined;
|
|
112
|
+
for (const p of current)
|
|
113
|
+
if (!idSet.has(p.id))
|
|
114
|
+
return undefined;
|
|
115
|
+
let result = [];
|
|
116
|
+
this.store.mutateProjects((s) => {
|
|
117
|
+
const byId = new Map(s.projects.map((p) => [p.id, p]));
|
|
118
|
+
ids.forEach((id, idx) => {
|
|
119
|
+
const project = byId.get(id);
|
|
120
|
+
if (project)
|
|
121
|
+
project.order = idx;
|
|
122
|
+
});
|
|
123
|
+
result = [...s.projects];
|
|
124
|
+
});
|
|
125
|
+
return result;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
//# sourceMappingURL=project-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project-manager.js","sourceRoot":"","sources":["../../src/state/project-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EACL,mCAAmC,GAGpC,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAehD,MAAM,OAAO,cAAc;IACI;IAA7B,YAA6B,KAAoB;QAApB,UAAK,GAAL,KAAK,CAAe;IAAG,CAAC;IAErD,MAAM,CAAC,IAAuB;QAC5B,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC;QACxE,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAE9B,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAY;YACvB,EAAE,EAAE,UAAU,EAAE;YAChB,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,QAAQ,CAAC,IAAI,CAAC;YACjC,IAAI;YACJ,SAAS,EAAE,GAAG;YACd,cAAc,EAAE,GAAG;SACpB,CAAC;QAEF,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,EAAE;YAC9B,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;YACzB,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,EAAE,CAAC,GAAG;gBAC5B,SAAS,EAAE,OAAO,C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GAAG,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE;gBACtB,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBAC7B,IAAI,OAAO;oBAAE,OAAO,CAAC,KAAK,GAAG,GAAG,CAAC;YACnC,CAAC,CAAC,CAAC;YACH,MAAM,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;QAC3B,CAAC,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ServerNotice, ServerNoticeKind } from "@parasor/shared";
|
|
2
|
+
export declare class ServerNoticesStore {
|
|
3
|
+
private byKind;
|
|
4
|
+
recordDaemonAutoRestarted(detail: {
|
|
5
|
+
serverProtocolVersion?: string;
|
|
6
|
+
daemonProtocolVersion?: string;
|
|
7
|
+
}): void;
|
|
8
|
+
list(): ServerNotice[];
|
|
9
|
+
has(kind: ServerNoticeKind): boolean;
|
|
10
|
+
dismiss(kind: ServerNoticeKind): boolean;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=server-notices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-notices.d.ts","sourceRoot":"","sources":["../../src/state/server-notices.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAA6C;IAE3D,yBAAyB,CAAC,MAAM,EAAE;QAChC,qBAAqB,CAAC,EAAE,MAAM,CAAC;QAC/B,qBAAqB,CAAC,EAAE,MAAM,CAAC;KAChC,GAAG,IAAI;IASR,IAAI,IAAI,YAAY,EAAE;IAItB,GAAG,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO;IAIpC,OAAO,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO;CAGzC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* daemon protocol mismatch recovery -- in-memory store for server-lifetime notices surfaced to the web
|
|
3
|
+
* UI. Currently records `daemon-auto-restarted` events from the
|
|
4
|
+
* createPtyHost recovery path so the web banner can explain why the
|
|
5
|
+
* session list is empty after a daemon-protocol upgrade.
|
|
6
|
+
*
|
|
7
|
+
* Lifecycle: instance lives on the running server only; notices are not
|
|
8
|
+
* persisted across server restarts. Web dismisses per-kind via
|
|
9
|
+
* `DELETE /api/notices/:kind`. Re-occurrence (a second auto-restart in
|
|
10
|
+
* the same lifetime) overwrites -- at most one entry per kind.
|
|
11
|
+
*/
|
|
12
|
+
export class ServerNoticesStore {
|
|
13
|
+
byKind = new Map();
|
|
14
|
+
recordDaemonAutoRestarted(detail) {
|
|
15
|
+
this.byKind.set("daemon-auto-restarted", {
|
|
16
|
+
kind: "daemon-auto-restarted",
|
|
17
|
+
occurredAt: new Date().toISOString(),
|
|
18
|
+
serverProtocolVersion: detail.serverProtocolVersion,
|
|
19
|
+
daemonProtocolVersion: detail.daemonProtocolVersion,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
list() {
|
|
23
|
+
return [...this.byKind.values()];
|
|
24
|
+
}
|
|
25
|
+
has(kind) {
|
|
26
|
+
return this.byKind.has(kind);
|
|
27
|
+
}
|
|
28
|
+
dismiss(kind) {
|
|
29
|
+
return this.byKind.delete(kind);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=server-notices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server-notices.js","sourceRoot":"","sources":["../../src/state/server-notices.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAIH,MAAM,OAAO,kBAAkB;IACrB,MAAM,GAAG,IAAI,GAAG,EAAkC,CAAC;IAE3D,yBAAyB,CAAC,MAGzB;QACC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uBAAuB,EAAE;YACvC,IAAI,EAAE,uBAAuB;YAC7B,UAAU,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;YACpC,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;YACnD,qBAAqB,EAAE,MAAM,CAAC,qBAAqB;SACpD,CAAC,CAAC;IACL,CAAC;IAED,IAAI;QACF,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,IAAsB;QACxB,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,OAAO,CAAC,IAAsB;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;CACF"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Worktree } from "@parasor/shared";
|
|
2
|
+
/**
|
|
3
|
+
* In-memory cache of per-project worktrees, kept in sync by the
|
|
4
|
+
* runtime broadcast wrapper. Used to keep `EventBus.addClient` fully
|
|
5
|
+
* synchronous so the snapshot/seq capture stays atomic with the
|
|
6
|
+
* broadcast stream.
|
|
7
|
+
*/
|
|
8
|
+
export declare class WorktreeCache {
|
|
9
|
+
private cache;
|
|
10
|
+
get(): Record<string, Worktree[]>;
|
|
11
|
+
setAll(initial: Record<string, Worktree[]>): void;
|
|
12
|
+
setProject(projectId: string, worktrees: Worktree[]): void;
|
|
13
|
+
removeProject(projectId: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Idempotent upsert by `path`. A snapshot+broadcast race (cache primed
|
|
16
|
+
* AFTER worktree-created fires) must not double-count, but a re-broadcast
|
|
17
|
+
* carrying refreshed counters (ahead/behind/dirtyCount) MUST update the
|
|
18
|
+
* cached entry -- otherwise a worktree-created emitted before counter
|
|
19
|
+
* enrichment finishes leaves the entry stuck at 0 forever (no other
|
|
20
|
+
* code path updates this cache).
|
|
21
|
+
*/
|
|
22
|
+
appendWorktree(projectId: string, worktree: Worktree): void;
|
|
23
|
+
removeWorktree(projectId: string, worktreePath: string): void;
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=worktree-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-cache.d.ts","sourceRoot":"","sources":["../../src/state/worktree-cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD;;;;;GAKG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAkC;IAE/C,GAAG,IAAI,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC;IAIjC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,EAAE,CAAC,GAAG,IAAI;IAIjD,UAAU,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,IAAI;IAI1D,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAMtC;;;;;;;OAOG;IACH,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,GAAG,IAAI;IAY3D,cAAc,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI;CAO9D"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* In-memory cache of per-project worktrees, kept in sync by the
|
|
3
|
+
* runtime broadcast wrapper. Used to keep `EventBus.addClient` fully
|
|
4
|
+
* synchronous so the snapshot/seq capture stays atomic with the
|
|
5
|
+
* broadcast stream.
|
|
6
|
+
*/
|
|
7
|
+
export class WorktreeCache {
|
|
8
|
+
cache = {};
|
|
9
|
+
get() {
|
|
10
|
+
return this.cache;
|
|
11
|
+
}
|
|
12
|
+
setAll(initial) {
|
|
13
|
+
this.cache = { ...initial };
|
|
14
|
+
}
|
|
15
|
+
setProject(projectId, worktrees) {
|
|
16
|
+
this.cache = { ...this.cache, [projectId]: worktrees };
|
|
17
|
+
}
|
|
18
|
+
removeProject(projectId) {
|
|
19
|
+
if (!(projectId in this.cache))
|
|
20
|
+
return;
|
|
21
|
+
const { [projectId]: _drop, ...rest } = this.cache;
|
|
22
|
+
this.cache = rest;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Idempotent upsert by `path`. A snapshot+broadcast race (cache primed
|
|
26
|
+
* AFTER worktree-created fires) must not double-count, but a re-broadcast
|
|
27
|
+
* carrying refreshed counters (ahead/behind/dirtyCount) MUST update the
|
|
28
|
+
* cached entry -- otherwise a worktree-created emitted before counter
|
|
29
|
+
* enrichment finishes leaves the entry stuck at 0 forever (no other
|
|
30
|
+
* code path updates this cache).
|
|
31
|
+
*/
|
|
32
|
+
appendWorktree(projectId, worktree) {
|
|
33
|
+
const list = this.cache[projectId] ?? [];
|
|
34
|
+
const idx = list.findIndex((w) => w.path === worktree.path);
|
|
35
|
+
if (idx === -1) {
|
|
36
|
+
this.cache = { ...this.cache, [projectId]: [...list, worktree] };
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
const next = [...list];
|
|
40
|
+
next[idx] = { ...list[idx], ...worktree };
|
|
41
|
+
this.cache = { ...this.cache, [projectId]: next };
|
|
42
|
+
}
|
|
43
|
+
removeWorktree(projectId, worktreePath) {
|
|
44
|
+
const list = this.cache[projectId];
|
|
45
|
+
if (!list)
|
|
46
|
+
return;
|
|
47
|
+
const next = list.filter((w) => w.path !== worktreePath);
|
|
48
|
+
if (next.length === list.length)
|
|
49
|
+
return;
|
|
50
|
+
this.cache = { ...this.cache, [projectId]: next };
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=worktree-cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"worktree-cache.js","sourceRoot":"","sources":["../../src/state/worktree-cache.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,M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