home-hosted 0.13.1 → 0.20.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/README.md +117 -322
- package/bin/home-hosted.mjs +41 -0
- package/dist/chunks/account-DiLrSyww.js +359 -0
- package/dist/chunks/account-DiLrSyww.js.map +1 -0
- package/dist/chunks/add-DEIYVkNK.js +183 -0
- package/dist/chunks/add-DEIYVkNK.js.map +1 -0
- package/dist/chunks/{archive-DP-XQR8X.js → archive-DFi3qK1c.js} +25 -73
- package/dist/chunks/archive-DFi3qK1c.js.map +1 -0
- package/dist/chunks/{atomic-C1PfJpE7.js → atomic-SZUwDtGD.js} +3 -6
- package/dist/chunks/atomic-SZUwDtGD.js.map +1 -0
- package/dist/chunks/{backup-DeAJ3pbO.js → backup-DnyxIzw0.js} +110 -190
- package/dist/chunks/backup-DnyxIzw0.js.map +1 -0
- package/dist/chunks/backups-BrrN6cwW.js +2203 -0
- package/dist/chunks/backups-BrrN6cwW.js.map +1 -0
- package/dist/chunks/bind-DIxrnUst.js +43 -0
- package/dist/chunks/bind-DIxrnUst.js.map +1 -0
- package/dist/chunks/config-text-DxMOQQnk.js +34 -0
- package/dist/chunks/config-text-DxMOQQnk.js.map +1 -0
- package/dist/chunks/{contracts-CMBD1TF9.js → contracts-CxZ7u1L3.js} +1239 -1454
- package/dist/chunks/contracts-CxZ7u1L3.js.map +1 -0
- package/dist/chunks/daemon-BAAYUYQC.js +211 -0
- package/dist/chunks/daemon-BAAYUYQC.js.map +1 -0
- package/dist/chunks/daemon-log-Ccu-69vB.js +179 -0
- package/dist/chunks/daemon-log-Ccu-69vB.js.map +1 -0
- package/dist/chunks/deploy-CggSOEkq.js +144 -0
- package/dist/chunks/deploy-CggSOEkq.js.map +1 -0
- package/dist/chunks/{docker-Cy9Lyvda.js → docker--Un0uLfF.js} +32 -68
- package/dist/chunks/docker--Un0uLfF.js.map +1 -0
- package/dist/chunks/{down-C59ne5aM.js → down-CpIN7LEQ.js} +34 -94
- package/dist/chunks/down-CpIN7LEQ.js.map +1 -0
- package/dist/chunks/exposure-CDJNvOCK.js +229 -0
- package/dist/chunks/exposure-CDJNvOCK.js.map +1 -0
- package/dist/chunks/import-Bd4VZH0f.js +205 -0
- package/dist/chunks/import-Bd4VZH0f.js.map +1 -0
- package/dist/chunks/import-plan--fDS_l5r.js +147 -0
- package/dist/chunks/import-plan--fDS_l5r.js.map +1 -0
- package/dist/chunks/import-write-BTfbeV26.js +42 -0
- package/dist/chunks/import-write-BTfbeV26.js.map +1 -0
- package/dist/chunks/{init-BZ7hK9Vf.js → init-Bv3oH65x.js} +14 -50
- package/dist/chunks/init-Bv3oH65x.js.map +1 -0
- package/dist/chunks/job-CYOdN6Ub.js +341 -0
- package/dist/chunks/job-CYOdN6Ub.js.map +1 -0
- package/dist/chunks/jobs-BX4ahcfh.js +489 -0
- package/dist/chunks/jobs-BX4ahcfh.js.map +1 -0
- package/dist/chunks/last-stop-DD3lHwo_.js +42 -0
- package/dist/chunks/last-stop-DD3lHwo_.js.map +1 -0
- package/dist/chunks/layout-D0ysDNav.js +18 -0
- package/dist/chunks/layout-D0ysDNav.js.map +1 -0
- package/dist/chunks/lazy-kfcBNeqj.js +48 -0
- package/dist/chunks/lazy-kfcBNeqj.js.map +1 -0
- package/dist/chunks/log-buffer-B7jmn7ts.js +110 -0
- package/dist/chunks/log-buffer-B7jmn7ts.js.map +1 -0
- package/dist/chunks/log-files-CZL2UhuE.js +488 -0
- package/dist/chunks/log-files-CZL2UhuE.js.map +1 -0
- package/dist/chunks/{logger-B5U4GD3j.js → logger-BnrKTBHQ.js} +2 -6
- package/dist/chunks/logger-BnrKTBHQ.js.map +1 -0
- package/dist/chunks/{logs---TI_bxM.js → logs-DxKI6OW2.js} +23 -73
- package/dist/chunks/logs-DxKI6OW2.js.map +1 -0
- package/dist/chunks/ls-BseUHy_m.js +128 -0
- package/dist/chunks/ls-BseUHy_m.js.map +1 -0
- package/dist/chunks/migrate-D4w_dXDm.js +268 -0
- package/dist/chunks/migrate-D4w_dXDm.js.map +1 -0
- package/dist/chunks/{nanny-rewguyXg.js → nanny-BWh7nuvv.js} +21 -14
- package/dist/chunks/nanny-BWh7nuvv.js.map +1 -0
- package/dist/chunks/{nanny-Dnun3hVB.js → nanny-BjF2-1pv.js} +3 -3
- package/dist/chunks/{nanny-Dnun3hVB.js.map → nanny-BjF2-1pv.js.map} +1 -1
- package/dist/chunks/nanny-DGTXVq5d.js +806 -0
- package/dist/chunks/nanny-DGTXVq5d.js.map +1 -0
- package/dist/chunks/{nanny-sweep-ClVuNJRo.js → nanny-sweep-hjmZ_p7S.js} +14 -24
- package/dist/chunks/nanny-sweep-hjmZ_p7S.js.map +1 -0
- package/dist/chunks/{nearest-6KgQEDUe.js → nearest-DOx4jySJ.js} +2 -10
- package/dist/chunks/nearest-DOx4jySJ.js.map +1 -0
- package/dist/chunks/{parse-DhmG26fI.js → parse-DVMPLUDe.js} +47 -72
- package/dist/chunks/parse-DVMPLUDe.js.map +1 -0
- package/dist/chunks/password-policy-Clq6PGE-.js +9 -0
- package/dist/chunks/password-policy-Clq6PGE-.js.map +1 -0
- package/dist/chunks/{paths-CGlGDrOU.js → paths-C34-TJLh.js} +32 -56
- package/dist/chunks/paths-C34-TJLh.js.map +1 -0
- package/dist/chunks/{port-k5VBw8t9.js → port-CnsrxKNR.js} +23 -70
- package/dist/chunks/port-CnsrxKNR.js.map +1 -0
- package/dist/chunks/process-CboOFPU_.js +192 -0
- package/dist/chunks/process-CboOFPU_.js.map +1 -0
- package/dist/chunks/{restart-BYu_E7x5.js → restart-C0J8dZ2L.js} +11 -29
- package/dist/chunks/restart-C0J8dZ2L.js.map +1 -0
- package/dist/chunks/run-deploy-DoNDvwT4.js +91 -0
- package/dist/chunks/run-deploy-DoNDvwT4.js.map +1 -0
- package/dist/chunks/{schema-B240VXcV.js → schema-CZ6f-PHD.js} +7 -20
- package/dist/chunks/schema-CZ6f-PHD.js.map +1 -0
- package/dist/chunks/secret-MY397r90.js +219 -0
- package/dist/chunks/secret-MY397r90.js.map +1 -0
- package/dist/chunks/secrets-CG5N4lwY.js +1061 -0
- package/dist/chunks/secrets-CG5N4lwY.js.map +1 -0
- package/dist/chunks/server-Dm_dXfTW.js +255 -0
- package/dist/chunks/server-Dm_dXfTW.js.map +1 -0
- package/dist/chunks/server-attention-UQwYXqKe.js +10 -0
- package/dist/chunks/server-attention-UQwYXqKe.js.map +1 -0
- package/dist/chunks/server-create-D7nvhgBd.js +96 -0
- package/dist/chunks/server-create-D7nvhgBd.js.map +1 -0
- package/dist/chunks/server-ids-BEQD2rFz.js +23 -0
- package/dist/chunks/server-ids-BEQD2rFz.js.map +1 -0
- package/dist/chunks/server-vars-DMYmHutL.js +27 -0
- package/dist/chunks/server-vars-DMYmHutL.js.map +1 -0
- package/dist/chunks/service-C8l-ewNA.js +585 -0
- package/dist/chunks/service-C8l-ewNA.js.map +1 -0
- package/dist/chunks/{settings-xu-XTfWg.js → settings-CtYDs5PX.js} +62 -78
- package/dist/chunks/settings-CtYDs5PX.js.map +1 -0
- package/dist/chunks/{setup-temp-CAN4_bA-.js → setup-temp-TAtDmMMU.js} +43 -37
- package/dist/chunks/setup-temp-TAtDmMMU.js.map +1 -0
- package/dist/chunks/shape-CDGeYl_J.js +9 -0
- package/dist/chunks/shape-CDGeYl_J.js.map +1 -0
- package/dist/chunks/{src-BOBh9MBf.js → src-BnzkVy_M.js} +12547 -10578
- package/dist/chunks/src-BnzkVy_M.js.map +1 -0
- package/dist/chunks/{status-B6f2-qhs.js → status-efbbfYZQ.js} +53 -26
- package/dist/chunks/status-efbbfYZQ.js.map +1 -0
- package/dist/chunks/store-Bs_Lljjm.js +2082 -0
- package/dist/chunks/store-Bs_Lljjm.js.map +1 -0
- package/dist/chunks/template-xan58bJh.js +28 -0
- package/dist/chunks/template-xan58bJh.js.map +1 -0
- package/dist/chunks/token-DDeWfZA4.js +142 -0
- package/dist/chunks/token-DDeWfZA4.js.map +1 -0
- package/dist/chunks/{ui-D562aqw5.js → ui-BcIAtyxE.js} +68 -79
- package/dist/chunks/ui-BcIAtyxE.js.map +1 -0
- package/dist/chunks/{ui-dir-CsU3uLNV.js → ui-dir-ClCzVRc3.js} +3 -7
- package/dist/chunks/ui-dir-ClCzVRc3.js.map +1 -0
- package/dist/chunks/ui-format-CDvvqOoi.js +53 -0
- package/dist/chunks/ui-format-CDvvqOoi.js.map +1 -0
- package/dist/chunks/{ui-release-DKzVvlLd.js → ui-release-XbJ85pYI.js} +36 -38
- package/dist/chunks/ui-release-XbJ85pYI.js.map +1 -0
- package/dist/chunks/{ui-revert-EkBBwRTt.js → ui-revert-Dgawq7ze.js} +4 -4
- package/dist/chunks/ui-revert-Dgawq7ze.js.map +1 -0
- package/dist/chunks/{ui-switch-BnZTdMDd.js → ui-switch-CfQMbZ0g.js} +31 -38
- package/dist/chunks/ui-switch-CfQMbZ0g.js.map +1 -0
- package/dist/chunks/{ui-update-_xryLYxw.js → ui-update-B3PPivUm.js} +30 -48
- package/dist/chunks/ui-update-B3PPivUm.js.map +1 -0
- package/dist/chunks/ui-update-CAiH2tFb.js +109 -0
- package/dist/chunks/ui-update-CAiH2tFb.js.map +1 -0
- package/dist/chunks/{up-DNZuTi2q.js → up-BQSnYxYd.js} +47 -53
- package/dist/chunks/up-BQSnYxYd.js.map +1 -0
- package/dist/chunks/{usage-BrnDARNM.js → usage-KG8TeOio.js} +7 -20
- package/dist/chunks/usage-KG8TeOio.js.map +1 -0
- package/dist/chunks/{workspaces-DYcfvKV_.js → workspaces-D9akpzU8.js} +80 -68
- package/dist/chunks/workspaces-D9akpzU8.js.map +1 -0
- package/dist/chunks/{wsl-temperature-BiCI4iK6.js → wsl-temperature-D-_d4Yk1.js} +47 -42
- package/dist/chunks/wsl-temperature-D-_d4Yk1.js.map +1 -0
- package/dist/cli.js +306 -238
- package/dist/cli.js.map +1 -1
- package/dist/client.js +76 -29
- package/dist/client.js.map +1 -1
- package/dist/types/api/acme.d.ts +3 -7
- package/dist/types/api/auth/$.routes.d.ts +107 -16
- package/dist/types/api/backups.d.ts +5 -5
- package/dist/types/api/control.d.ts +747 -38
- package/dist/types/api/ddns.d.ts +13 -18
- package/dist/types/api/events.d.ts +9 -3
- package/dist/types/api/health.d.ts +2 -4
- package/dist/types/api/jobs.d.ts +438 -0
- package/dist/types/api/logs.d.ts +20 -0
- package/dist/types/api/metrics.d.ts +2 -5
- package/dist/types/api/notifications.d.ts +3 -6
- package/dist/types/api/proxy.d.ts +63 -23
- package/dist/types/api/server-ops.d.ts +17 -0
- package/dist/types/api/servers/$.routes.d.ts +418 -186
- package/dist/types/api/session-required.d.ts +16 -0
- package/dist/types/api/settings.d.ts +7 -7
- package/dist/types/api/state.d.ts +100 -10
- package/dist/types/api/static.d.ts +2 -2
- package/dist/types/api/tls.d.ts +2 -5
- package/dist/types/api/workspaces/$.routes.d.ts +186 -12
- package/dist/types/api/wsl-temperature.d.ts +4 -10
- package/dist/types/app.d.ts +4511 -2778
- package/dist/types/cli/account.d.ts +23 -0
- package/dist/types/cli/add.d.ts +96 -0
- package/dist/types/cli/args.d.ts +24 -35
- package/dist/types/cli/backup-offline.d.ts +2 -8
- package/dist/types/cli/backup.d.ts +12 -21
- package/dist/types/cli/down.d.ts +15 -41
- package/dist/types/cli/import-plan.d.ts +55 -0
- package/dist/types/cli/import-write.d.ts +5 -0
- package/dist/types/cli/import.d.ts +86 -0
- package/dist/types/cli/io.d.ts +26 -35
- package/dist/types/cli/job.d.ts +99 -0
- package/dist/types/cli/logs.d.ts +1 -10
- package/dist/types/cli/ls.d.ts +57 -0
- package/dist/types/cli/migrate.d.ts +31 -8
- package/dist/types/cli/nearest.d.ts +1 -9
- package/dist/types/cli/run-deploy.d.ts +36 -0
- package/dist/types/cli/secret.d.ts +90 -0
- package/dist/types/cli/server.d.ts +6 -15
- package/dist/types/cli/service.d.ts +135 -0
- package/dist/types/cli/setup-temp.d.ts +17 -13
- package/dist/types/cli/status.d.ts +7 -1
- package/dist/types/cli/token.d.ts +6 -0
- package/dist/types/cli/ui-switch.d.ts +3 -14
- package/dist/types/cli/ui-update.d.ts +3 -16
- package/dist/types/cli/up.d.ts +9 -22
- package/dist/types/cli/usage.d.ts +2 -6
- package/dist/types/cli.d.ts +1 -10
- package/dist/types/client.d.ts +4099 -1142
- package/dist/types/config/accounts.d.ts +16 -0
- package/dist/types/config/jobs.d.ts +68 -0
- package/dist/types/config/layout.d.ts +2 -8
- package/dist/types/config/migrations.d.ts +9 -41
- package/dist/types/config/parse.d.ts +8 -13
- package/dist/types/config/patch.d.ts +1 -6
- package/dist/types/config/schema.d.ts +16 -18
- package/dist/types/config/secret-parts.d.ts +6 -27
- package/dist/types/config/secrets.d.ts +167 -88
- package/dist/types/config/seed.d.ts +1 -6
- package/dist/types/config/server-ids.d.ts +2 -11
- package/dist/types/config/settings.d.ts +13 -49
- package/dist/types/config/store.d.ts +17 -54
- package/dist/types/config/workspaces.d.ts +24 -56
- package/dist/types/helpers/action-result.d.ts +18 -32
- package/dist/types/helpers/atomic.d.ts +1 -4
- package/dist/types/helpers/backoff.d.ts +0 -1
- package/dist/types/helpers/bind.d.ts +3 -11
- package/dist/types/helpers/config-text.d.ts +4 -19
- package/dist/types/helpers/cookies.d.ts +2 -7
- package/dist/types/helpers/copy-tree.d.ts +4 -12
- package/dist/types/helpers/daemon-log.d.ts +8 -33
- package/dist/types/helpers/daemon.d.ts +20 -70
- package/dist/types/helpers/deferred.d.ts +2 -4
- package/dist/types/helpers/env-file.d.ts +2 -7
- package/dist/types/helpers/error.d.ts +3 -14
- package/dist/types/helpers/event-stream.d.ts +18 -10
- package/dist/types/helpers/factory.d.ts +2 -3
- package/dist/types/helpers/last-stop.d.ts +5 -12
- package/dist/types/helpers/logger.d.ts +1 -5
- package/dist/types/helpers/open.d.ts +0 -1
- package/dist/types/helpers/openapi.d.ts +19 -5
- package/dist/types/helpers/paths.d.ts +18 -53
- package/dist/types/helpers/restore-lock.d.ts +2 -17
- package/dist/types/helpers/runtime.d.ts +3 -13
- package/dist/types/helpers/secret-compare.d.ts +2 -10
- package/dist/types/helpers/server-create.d.ts +15 -0
- package/dist/types/helpers/shell.d.ts +2 -16
- package/dist/types/helpers/sse.d.ts +8 -6
- package/dist/types/helpers/ui-dir.d.ts +1 -5
- package/dist/types/helpers/utf8-chunks.d.ts +2 -8
- package/dist/types/helpers/validate.d.ts +2 -4
- package/dist/types/helpers/validator.d.ts +8 -4
- package/dist/types/helpers/version.d.ts +1 -6
- package/dist/types/helpers/workspace.d.ts +24 -16
- package/dist/types/index.d.ts +2 -3
- package/dist/types/middleware/auth.d.ts +8 -27
- package/dist/types/middleware/body-limit.d.ts +10 -0
- package/dist/types/middleware/host.d.ts +4 -23
- package/dist/types/middleware/loopback.d.ts +1 -8
- package/dist/types/middleware/token-scope.d.ts +34 -0
- package/dist/types/node-compat.d.ts +43 -0
- package/dist/types/openapi-reference.d.ts +4 -19
- package/dist/types/openapi.d.ts +5 -8
- package/dist/types/providers/archive.d.ts +8 -25
- package/dist/types/providers/backup-hook.d.ts +4 -19
- package/dist/types/providers/ddns/dyndns2.d.ts +0 -3
- package/dist/types/providers/ddns/index.d.ts +2 -3
- package/dist/types/providers/ddns/ip.d.ts +2 -12
- package/dist/types/providers/ddns/namecheap-api.d.ts +3 -2
- package/dist/types/providers/ddns/types.d.ts +6 -32
- package/dist/types/providers/ddns/zone.d.ts +1 -4
- package/dist/types/providers/docker.d.ts +18 -45
- package/dist/types/providers/entry-state.d.ts +4 -9
- package/dist/types/providers/health-check.d.ts +1 -5
- package/dist/types/providers/host.d.ts +33 -108
- package/dist/types/providers/identity.d.ts +9 -34
- package/dist/types/providers/log-tail.d.ts +14 -24
- package/dist/types/providers/nanny-sweep.d.ts +8 -25
- package/dist/types/providers/nanny.d.ts +16 -58
- package/dist/types/providers/port.d.ts +28 -83
- package/dist/types/providers/proc.d.ts +22 -80
- package/dist/types/providers/process.d.ts +12 -36
- package/dist/types/providers/proxy/admin.d.ts +11 -0
- package/dist/types/providers/proxy/types.d.ts +4 -16
- package/dist/types/providers/telegram.d.ts +1 -17
- package/dist/types/providers/ui-release.d.ts +15 -25
- package/dist/types/providers/webhook.d.ts +8 -29
- package/dist/types/providers/wsl-temperature.d.ts +13 -22
- package/dist/types/services/acme-challenge.d.ts +2 -16
- package/dist/types/services/auth.d.ts +65 -80
- package/dist/types/services/backups/archive-safety.d.ts +30 -0
- package/dist/types/services/backups/paths.d.ts +31 -0
- package/dist/types/services/backups.d.ts +61 -271
- package/dist/types/services/config-watch.d.ts +3 -15
- package/dist/types/services/control-server.d.ts +6 -10
- package/dist/types/services/ddns.d.ts +12 -13
- package/dist/types/services/dependencies.d.ts +3 -14
- package/dist/types/services/deploy.d.ts +34 -0
- package/dist/types/services/events.d.ts +15 -9
- package/dist/types/services/exposure.d.ts +13 -63
- package/dist/types/services/history.d.ts +5 -14
- package/dist/types/services/host-monitor.d.ts +6 -11
- package/dist/types/services/init.d.ts +5 -35
- package/dist/types/services/job-ledger.d.ts +27 -0
- package/dist/types/services/jobs.d.ts +113 -0
- package/dist/types/services/log-buffer.d.ts +7 -8
- package/dist/types/services/log-files.d.ts +12 -42
- package/dist/types/services/log-relay.d.ts +3 -13
- package/dist/types/services/nanny.d.ts +3 -10
- package/dist/types/services/notifications.d.ts +31 -61
- package/dist/types/services/panel.d.ts +32 -78
- package/dist/types/services/proxy-certificates/certificates.d.ts +31 -69
- package/dist/types/services/proxy-config.d.ts +15 -36
- package/dist/types/services/proxy-dns01.d.ts +14 -0
- package/dist/types/services/proxy.d.ts +73 -254
- package/dist/types/services/scheduler.d.ts +46 -0
- package/dist/types/services/state.d.ts +17 -8
- package/dist/types/services/supervisor/compose.d.ts +2 -6
- package/dist/types/services/supervisor/entry.d.ts +29 -32
- package/dist/types/services/supervisor/health.d.ts +8 -31
- package/dist/types/services/supervisor/job-run.d.ts +36 -0
- package/dist/types/services/supervisor/output.d.ts +13 -77
- package/dist/types/services/supervisor/persistent.d.ts +5 -11
- package/dist/types/services/supervisor/port-preflight.d.ts +4 -10
- package/dist/types/services/supervisor/records.d.ts +27 -60
- package/dist/types/services/supervisor/restart-required.d.ts +13 -0
- package/dist/types/services/supervisor/spawn.d.ts +3 -5
- package/dist/types/services/supervisor/view.d.ts +3 -1
- package/dist/types/services/supervisor.d.ts +31 -43
- package/dist/types/services/tls.d.ts +6 -17
- package/dist/types/services/ui-update.d.ts +19 -17
- package/dist/types/services/ui.d.ts +10 -19
- package/dist/types/shared/action-outcome.d.ts +2 -7
- package/dist/types/shared/api-client.d.ts +133 -177
- package/dist/types/shared/api-scopes.d.ts +17 -0
- package/dist/types/shared/backup-scope.d.ts +16 -90
- package/dist/types/shared/clone.d.ts +2 -11
- package/dist/types/shared/contracts/accounts.d.ts +99 -0
- package/dist/types/shared/contracts/backups.d.ts +219 -0
- package/dist/types/shared/contracts/ddns.d.ts +208 -0
- package/dist/types/shared/contracts/frames.d.ts +1395 -0
- package/dist/types/shared/contracts/index.d.ts +3 -0
- package/dist/types/shared/contracts/logs.d.ts +107 -0
- package/dist/types/shared/contracts/proxy.d.ts +303 -0
- package/dist/types/shared/contracts.d.ts +852 -1982
- package/dist/types/shared/cpu-scale.d.ts +3 -19
- package/dist/types/shared/crash-cause.d.ts +8 -0
- package/dist/types/shared/cron.d.ts +70 -0
- package/dist/types/shared/ddns-form.d.ts +9 -43
- package/dist/types/shared/endpoint.d.ts +1 -7
- package/dist/types/shared/error-codes.d.ts +438 -0
- package/dist/types/shared/error-message.d.ts +1 -7
- package/dist/types/shared/fields.d.ts +7 -17
- package/dist/types/shared/form-repair.d.ts +1 -5
- package/dist/types/shared/generated.d.ts +3 -19
- package/dist/types/shared/host-readings.d.ts +25 -128
- package/dist/types/shared/lazy.d.ts +1 -1
- package/dist/types/shared/live-frames.d.ts +2 -8
- package/dist/types/shared/live-series.d.ts +2 -8
- package/dist/types/shared/live-store.d.ts +4 -8
- package/dist/types/shared/log-download.d.ts +6 -0
- package/dist/types/shared/meta.d.ts +6 -0
- package/dist/types/shared/password-policy.d.ts +10 -0
- package/dist/types/shared/patch-diff.d.ts +13 -72
- package/dist/types/shared/port-reading.d.ts +18 -0
- package/dist/types/shared/probe-latency.d.ts +3 -21
- package/dist/types/shared/proxy-form.d.ts +33 -74
- package/dist/types/shared/proxy-validate.d.ts +11 -0
- package/dist/types/shared/query-params.d.ts +8 -0
- package/dist/types/shared/server-attention.d.ts +2 -27
- package/dist/types/shared/server-form.d.ts +15 -54
- package/dist/types/shared/server-key.d.ts +1 -12
- package/dist/types/shared/server-readings.d.ts +7 -32
- package/dist/types/shared/server-url.d.ts +9 -31
- package/dist/types/shared/shape.d.ts +1 -16
- package/dist/types/shared/stream-access.d.ts +2 -8
- package/dist/types/shared/ui-format.d.ts +25 -65
- package/docs/API.md +315 -107
- package/docs/BACKUPS.md +61 -56
- package/docs/CLI.md +255 -49
- package/docs/DDNS.md +35 -49
- package/docs/JOBS.md +129 -0
- package/docs/NOTIFICATIONS.md +58 -90
- package/docs/REVERSE_PROXY.md +116 -188
- package/docs/SECURITY.md +126 -44
- package/docs/SERVERS.md +282 -409
- package/docs/UI_CREATION.md +90 -47
- package/docs/demo/blank-host-restore.sh +31 -7
- package/package.json +15 -6
- package/scripts/prepare.mjs +47 -0
- package/uis/stock/dist/assets/CopyButton-8mliL0xi.js +1 -0
- package/uis/stock/dist/assets/GlobalSettingsView-BINXY77E.js +1 -0
- package/uis/stock/dist/assets/LogViewer-kiSnTwdY.js +1 -0
- package/uis/stock/dist/assets/LogsView-DDXf_ONs.js +1 -0
- package/uis/stock/dist/assets/Modal-lrUuViF2.js +39 -0
- package/uis/stock/dist/assets/ProxyView-uXMaJdSQ.js +1 -0
- package/uis/stock/dist/assets/ServerDetailView-CW0Vb_c0.js +4 -0
- package/uis/stock/dist/assets/SettingsShell-B135xWjJ.js +1 -0
- package/uis/stock/dist/assets/SettingsView-BLtWxVkl.js +2 -0
- package/uis/stock/dist/assets/de-BIoTrHBQ.js +1 -0
- package/uis/stock/dist/assets/es-x4-ih8lH.js +1 -0
- package/uis/stock/dist/assets/fr-DatqBBkO.js +1 -0
- package/uis/stock/dist/assets/index-CnojaKcA.css +2 -0
- package/uis/stock/dist/assets/index-D-CiZReu.js +16 -0
- package/uis/stock/dist/assets/ja-CW1703Gw.js +1 -0
- package/uis/stock/dist/assets/ko-wFbT4XtK.js +1 -0
- package/uis/stock/dist/assets/ru-C1p5C4VN.js +1 -0
- package/uis/stock/dist/assets/useUnsavedGuard-BcsXsfCC.js +9 -0
- package/uis/stock/dist/assets/vi-CDqr0uie.js +1 -0
- package/uis/stock/dist/assets/zh-CN-BJ7iit-X.js +1 -0
- package/uis/stock/dist/index.html +4 -3
- package/uis/stock/dist/ui.json +3 -3
- package/dist/chunks/archive-DP-XQR8X.js.map +0 -1
- package/dist/chunks/atomic-C1PfJpE7.js.map +0 -1
- package/dist/chunks/backup-DeAJ3pbO.js.map +0 -1
- package/dist/chunks/backups-twva7x2n.js +0 -4691
- package/dist/chunks/backups-twva7x2n.js.map +0 -1
- package/dist/chunks/config-text-DifCHhnz.js +0 -50
- package/dist/chunks/config-text-DifCHhnz.js.map +0 -1
- package/dist/chunks/contracts-CMBD1TF9.js.map +0 -1
- package/dist/chunks/daemon-CofN9k6Q.js +0 -247
- package/dist/chunks/daemon-CofN9k6Q.js.map +0 -1
- package/dist/chunks/daemon-log-BVj8cDEo.js +0 -241
- package/dist/chunks/daemon-log-BVj8cDEo.js.map +0 -1
- package/dist/chunks/docker-Cy9Lyvda.js.map +0 -1
- package/dist/chunks/down-C59ne5aM.js.map +0 -1
- package/dist/chunks/init-BZ7hK9Vf.js.map +0 -1
- package/dist/chunks/last-stop-C-BXz_XI.js +0 -53
- package/dist/chunks/last-stop-C-BXz_XI.js.map +0 -1
- package/dist/chunks/layout-DwTtmund.js +0 -24
- package/dist/chunks/layout-DwTtmund.js.map +0 -1
- package/dist/chunks/lazy-Ce5zEAq1.js +0 -66
- package/dist/chunks/lazy-Ce5zEAq1.js.map +0 -1
- package/dist/chunks/log-buffer-Dy9HHDMD.js +0 -414
- package/dist/chunks/log-buffer-Dy9HHDMD.js.map +0 -1
- package/dist/chunks/logger-B5U4GD3j.js.map +0 -1
- package/dist/chunks/logs---TI_bxM.js.map +0 -1
- package/dist/chunks/migrate-Cfoq-Vgh.js +0 -155
- package/dist/chunks/migrate-Cfoq-Vgh.js.map +0 -1
- package/dist/chunks/nanny-COyCJXj9.js +0 -1172
- package/dist/chunks/nanny-COyCJXj9.js.map +0 -1
- package/dist/chunks/nanny-rewguyXg.js.map +0 -1
- package/dist/chunks/nanny-sweep-ClVuNJRo.js.map +0 -1
- package/dist/chunks/nearest-6KgQEDUe.js.map +0 -1
- package/dist/chunks/parse-DhmG26fI.js.map +0 -1
- package/dist/chunks/paths-CGlGDrOU.js.map +0 -1
- package/dist/chunks/port-k5VBw8t9.js.map +0 -1
- package/dist/chunks/restart-BYu_E7x5.js.map +0 -1
- package/dist/chunks/schema-B240VXcV.js.map +0 -1
- package/dist/chunks/secrets-BieELnZh.js +0 -562
- package/dist/chunks/secrets-BieELnZh.js.map +0 -1
- package/dist/chunks/server-By-zktjx.js +0 -169
- package/dist/chunks/server-By-zktjx.js.map +0 -1
- package/dist/chunks/server-ids-DRuNLVCV.js +0 -32
- package/dist/chunks/server-ids-DRuNLVCV.js.map +0 -1
- package/dist/chunks/set-password-D5vZqqSX.js +0 -43
- package/dist/chunks/set-password-D5vZqqSX.js.map +0 -1
- package/dist/chunks/set-token-xJkA1IZp.js +0 -78
- package/dist/chunks/set-token-xJkA1IZp.js.map +0 -1
- package/dist/chunks/settings-xu-XTfWg.js.map +0 -1
- package/dist/chunks/setup-temp-CAN4_bA-.js.map +0 -1
- package/dist/chunks/shape-DnTKzjQ2.js +0 -24
- package/dist/chunks/shape-DnTKzjQ2.js.map +0 -1
- package/dist/chunks/src-BOBh9MBf.js.map +0 -1
- package/dist/chunks/status-B6f2-qhs.js.map +0 -1
- package/dist/chunks/ui-D562aqw5.js.map +0 -1
- package/dist/chunks/ui-dir-CsU3uLNV.js.map +0 -1
- package/dist/chunks/ui-release-DKzVvlLd.js.map +0 -1
- package/dist/chunks/ui-revert-EkBBwRTt.js.map +0 -1
- package/dist/chunks/ui-switch-BnZTdMDd.js.map +0 -1
- package/dist/chunks/ui-update-_xryLYxw.js.map +0 -1
- package/dist/chunks/up-DNZuTi2q.js.map +0 -1
- package/dist/chunks/usage-BrnDARNM.js.map +0 -1
- package/dist/chunks/workspaces-DYcfvKV_.js.map +0 -1
- package/dist/chunks/wsl-temperature-BiCI4iK6.js.map +0 -1
- package/dist/types/cli/set-password.d.ts +0 -14
- package/dist/types/cli/set-token.d.ts +0 -21
- package/uis/stock/dist/assets/CopyButton-BUBKRJyY.js +0 -1
- package/uis/stock/dist/assets/GlobalSettingsView-yYMcRWvt.js +0 -1
- package/uis/stock/dist/assets/LogViewer-DIliXy62.js +0 -1
- package/uis/stock/dist/assets/LogsView-B7Z-7RNg.js +0 -1
- package/uis/stock/dist/assets/Modal-DmKa5Qpp.js +0 -39
- package/uis/stock/dist/assets/ProxyView-DvZiNkwb.js +0 -1
- package/uis/stock/dist/assets/ServerDetailView-6idGT_EX.js +0 -2
- package/uis/stock/dist/assets/SettingsShell-CeGtleYI.js +0 -1
- package/uis/stock/dist/assets/SettingsView-BrhJIrmk.js +0 -2
- package/uis/stock/dist/assets/de-BRITeb0H.js +0 -1
- package/uis/stock/dist/assets/es-B2zIEssV.js +0 -1
- package/uis/stock/dist/assets/fr-s0ZOBEqh.js +0 -1
- package/uis/stock/dist/assets/index-C1MehbKy.css +0 -2
- package/uis/stock/dist/assets/index-CnBN54wF.js +0 -15
- package/uis/stock/dist/assets/ja-CU7MR85V.js +0 -1
- package/uis/stock/dist/assets/ko-tL5Me6d-.js +0 -1
- package/uis/stock/dist/assets/ru-92yrvkNJ.js +0 -1
- package/uis/stock/dist/assets/vi-CzvY16k2.js +0 -1
- package/uis/stock/dist/assets/zh-CN-DDwFW_uW.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as rotateLog, r as tailLog } from "./daemon-log-
|
|
1
|
+
import { C as unrecordedFirstRunHint, T as buildDaemonArgv, _ as paint, d as delay, f as dim, g as invocation, h as green, l as bold, m as firstRunPasswordState, p as fail, r as versionMismatchNote, s as runtimeArgs } from "../cli.js";
|
|
2
|
+
import { n as rotateLog, r as tailLog } from "./daemon-log-Ccu-69vB.js";
|
|
3
3
|
import process from "node:process";
|
|
4
4
|
import { defineCommand } from "citty";
|
|
5
5
|
import path from "node:path";
|
|
@@ -32,7 +32,6 @@ var upArgs = {
|
|
|
32
32
|
description: "print the effective config and exit"
|
|
33
33
|
}
|
|
34
34
|
};
|
|
35
|
-
/** citty only parses; the port's range and the boolean defaults are decided here. */
|
|
36
35
|
function toUpFlags(args) {
|
|
37
36
|
let port;
|
|
38
37
|
if (args.port !== void 0) {
|
|
@@ -49,46 +48,23 @@ function toUpFlags(args) {
|
|
|
49
48
|
printConfig: args.printConfig === true
|
|
50
49
|
};
|
|
51
50
|
}
|
|
52
|
-
/**
|
|
53
|
-
* `toUpFlags`, plus the check of `--host` that only the panel's own boot used to make.
|
|
54
|
-
*
|
|
55
|
-
* Async because the bind parser lives with the schemas, which a detaching `up` otherwise never
|
|
56
|
-
* loads. Run before anything happens, so `up --host nope` is refused here rather than in a daemon
|
|
57
|
-
* log, and `restart --host nope` before the panel is stopped.
|
|
58
|
-
*/
|
|
51
|
+
/** `toUpFlags` plus a `--host` check, run before anything happens so a bad bind is refused here, not in a daemon log. */
|
|
59
52
|
async function checkedUpFlags(args) {
|
|
60
53
|
const flags = toUpFlags(args);
|
|
61
54
|
if (flags.host !== void 0) {
|
|
62
|
-
const { parseBind } = await import("./contracts-
|
|
55
|
+
const { parseBind } = await import("./contracts-CxZ7u1L3.js").then((n) => n.l);
|
|
63
56
|
if (parseBind(flags.host) === null) fail(`invalid control host: ${flags.host} (expected local, lan or an ipv4 address)`);
|
|
64
57
|
}
|
|
65
58
|
return flags;
|
|
66
59
|
}
|
|
67
|
-
/**
|
|
68
|
-
* A bind value as the address it resolves to.
|
|
69
|
-
*
|
|
70
|
-
* Deliberately local and dependency-free: this module must stay importable without a state graph
|
|
71
|
-
* (`test/cli/isolation`), and `helpers/bind.ts` caches `os.networkInterfaces()`, which a pure
|
|
72
|
-
* comparison has no business triggering.
|
|
73
|
-
*/
|
|
60
|
+
/** Dependency-free: this module must stay importable without a state graph (`test/cli/isolation`). */
|
|
74
61
|
function bindAddress(bind) {
|
|
75
62
|
return bind === "local" ? "127.0.0.1" : bind === "lan" ? "0.0.0.0" : bind;
|
|
76
63
|
}
|
|
77
64
|
/**
|
|
78
|
-
* Which `up` flags the live panel contradicts, as one sentence — or `null
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
* "make sure it is running". But it used to swallow `--port`, `--host` and `--open` on that path,
|
|
82
|
-
* so `up --port 4800` against a panel on 3999 printed a success line and exited 0 having changed
|
|
83
|
-
* nothing — a deploy script reading `$?` concluded the port move worked. AGENTS.md settles the
|
|
84
|
-
* direction: a flag the command cannot honour is refused, and `restart --workspace` without an id
|
|
85
|
-
* already exits 1 for the same reason. `--open` is refused too, because it is not "make sure it is
|
|
86
|
-
* running" either — it asks for a browser, and none opens on a panel this command did not start.
|
|
87
|
-
*
|
|
88
|
-
* `--no-autostart` is deliberately **not** here. It is not contradicted by the live panel: it
|
|
89
|
-
* expresses a wish about a boot this command is not performing, and the panel has already booted,
|
|
90
|
-
* so there is nothing to honour or refuse. Refusing it would break `up --no-autostart` in a retry
|
|
91
|
-
* loop, which is the one spelling a script uses to keep its hands off the entries.
|
|
65
|
+
* Which `up` flags the live panel contradicts, as one sentence — or `null`. A flag the command cannot
|
|
66
|
+
* honour is refused, not swallowed with exit 0. `--no-autostart` is deliberately absent: it concerns a
|
|
67
|
+
* boot this command is not performing, and scripts use it in retry loops.
|
|
92
68
|
*/
|
|
93
69
|
function alreadyRunningConflict(flags, runtime) {
|
|
94
70
|
const asked = [];
|
|
@@ -98,11 +74,32 @@ function alreadyRunningConflict(flags, runtime) {
|
|
|
98
74
|
if (asked.length === 0) return null;
|
|
99
75
|
const what = asked.join(" and ");
|
|
100
76
|
const clause = asked.length === 1 ? `${what} was not honoured` : `${what} were not honoured`;
|
|
101
|
-
return `home-hosted is already running at ${runtime.url} — ${clause}.
|
|
77
|
+
return `home-hosted is already running at ${runtime.url} — ${clause}. Use \`${invocation()} restart ${asked.join(" ")}\` to move it.`;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Why the panel would refuse this bind, asked before `restart` takes anything down. A missing password
|
|
81
|
+
* names the account to create; a config the daemon would refuse anyway answers `null`.
|
|
82
|
+
*/
|
|
83
|
+
async function exposureRefusal(host) {
|
|
84
|
+
const { GlobalSettingsStore } = await import("./settings-CtYDs5PX.js").then((n) => n.i);
|
|
85
|
+
const { SecretsStore } = await import("./secrets-CG5N4lwY.js").then((n) => n.o);
|
|
86
|
+
const { globalSecretsPath, globalSettingsPath } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
87
|
+
const { parseBind } = await import("./contracts-CxZ7u1L3.js").then((n) => n.l);
|
|
88
|
+
const { checkExposure } = await import("./exposure-CDJNvOCK.js");
|
|
89
|
+
const settings = new GlobalSettingsStore(globalSettingsPath);
|
|
90
|
+
settings.load({ write: false });
|
|
91
|
+
const secrets = new SecretsStore(globalSecretsPath, void 0, "global");
|
|
92
|
+
if (settings.configError !== null || secrets.configError !== null) return null;
|
|
93
|
+
const bind = host === void 0 ? settings.control.host : parseBind(host);
|
|
94
|
+
if (bind === null) return null;
|
|
95
|
+
return checkExposure({
|
|
96
|
+
...settings.control,
|
|
97
|
+
host: bind
|
|
98
|
+
}, secrets.passwordSet, secrets.usingDefaultPassword, secrets.passwordTooShort).blockedReason;
|
|
102
99
|
}
|
|
103
100
|
async function runUp(flags, entry) {
|
|
104
101
|
if (flags.foreground || flags.printConfig) {
|
|
105
|
-
const { runControlPlane } = await import("./src-
|
|
102
|
+
const { runControlPlane } = await import("./src-BnzkVy_M.js");
|
|
106
103
|
await runControlPlane({
|
|
107
104
|
port: flags.port,
|
|
108
105
|
host: flags.host,
|
|
@@ -112,8 +109,8 @@ async function runUp(flags, entry) {
|
|
|
112
109
|
});
|
|
113
110
|
return;
|
|
114
111
|
}
|
|
115
|
-
const { clearRuntime, readRuntime, runtimeIsAlive, runtimeIsGone } = await import("./daemon-
|
|
116
|
-
const { daemonLogPath, dataRoot, ensureStateDir, projectDir } = await import("./paths-
|
|
112
|
+
const { clearRuntime, readRuntime, runtimeIsAlive, runtimeIsGone } = await import("./daemon-BAAYUYQC.js");
|
|
113
|
+
const { daemonLogPath, dataRoot, ensureStateDir, projectDir } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
117
114
|
const existing = readRuntime();
|
|
118
115
|
if (existing !== null && await runtimeIsAlive(existing)) {
|
|
119
116
|
const conflict = alreadyRunningConflict(flags, existing);
|
|
@@ -125,6 +122,8 @@ async function runUp(flags, entry) {
|
|
|
125
122
|
return;
|
|
126
123
|
}
|
|
127
124
|
if (existing !== null && await runtimeIsGone(existing)) clearRuntime();
|
|
125
|
+
const exposure = await exposureRefusal(flags.host);
|
|
126
|
+
if (exposure !== null) fail(`refusing to start: ${exposure}`);
|
|
128
127
|
ensureStateDir(path.dirname(daemonLogPath));
|
|
129
128
|
rotateLog(daemonLogPath);
|
|
130
129
|
const log = fs.openSync(daemonLogPath, "a", 384);
|
|
@@ -161,31 +160,26 @@ async function runUp(flags, entry) {
|
|
|
161
160
|
process.stdout.write(` ${dim(`project ${runtime.projectDir}`)}\n`);
|
|
162
161
|
process.stdout.write(` ${dim(`state ${runtime.dataRoot}`)}\n`);
|
|
163
162
|
process.stdout.write(` ${dim(`log ${runtime.logFile}`)}\n`);
|
|
164
|
-
const initial = await
|
|
165
|
-
if (initial
|
|
163
|
+
const initial = await firstRunPasswordState();
|
|
164
|
+
if (initial?.kind === "recorded") {
|
|
165
|
+
process.stdout.write(`${paint("33", "sign in")} as ${bold(initial.account)} / ${bold(initial.password)}\n`);
|
|
166
|
+
process.stdout.write(` ${dim("the first-run secret — set your own in Global settings → Accounts")}\n`);
|
|
167
|
+
} else if (initial?.kind === "unrecorded") process.stdout.write(`${paint("33", "secret")} ${unrecordedFirstRunHint()}\n`);
|
|
166
168
|
await warnIfWslTemperatureMissing();
|
|
167
169
|
}
|
|
168
|
-
/**
|
|
169
|
-
* Say once, on `up`, that this box cannot read its own temperature and that it can be fixed.
|
|
170
|
-
*
|
|
171
|
-
* A WSL2 guest has no sensor the kernel exposes, so the Host vitals tile reads `n/a` and looks
|
|
172
|
-
* broken. Nothing tells a person why — the settings page has the button, but only if they go
|
|
173
|
-
* looking. This is the one line that turns "the panel is broken" into "run one command".
|
|
174
|
-
*
|
|
175
|
-
* Silent when a command is already configured, and on any platform that is not WSL.
|
|
176
|
-
*/
|
|
170
|
+
/** Say once, on `up`, that this WSL2 box cannot read its temperature and how to fix it. */
|
|
177
171
|
async function warnIfWslTemperatureMissing() {
|
|
178
|
-
const { isWsl } = await import("./wsl-temperature-
|
|
172
|
+
const { isWsl } = await import("./wsl-temperature-D-_d4Yk1.js").then((n) => n.d);
|
|
179
173
|
if (!isWsl()) return;
|
|
180
|
-
const { GlobalSettingsStore } = await import("./settings-
|
|
181
|
-
const { globalSettingsPath } = await import("./paths-
|
|
174
|
+
const { GlobalSettingsStore } = await import("./settings-CtYDs5PX.js").then((n) => n.i);
|
|
175
|
+
const { globalSettingsPath } = await import("./paths-C34-TJLh.js").then((n) => n.d);
|
|
182
176
|
const store = new GlobalSettingsStore(globalSettingsPath);
|
|
183
177
|
store.load();
|
|
184
178
|
if (store.host.tempCommand.trim().length > 0) return;
|
|
185
179
|
process.stdout.write(`${paint("33", "note")} WSL2 detected: the guest exposes no CPU temperature, so Host vitals shows n/a\n ${dim(`set it up with ${invocation()} setup-temp --wsl`)}\n`);
|
|
186
180
|
}
|
|
187
181
|
async function waitForStartup(child, timeoutMs = 2e4) {
|
|
188
|
-
const { readRuntime } = await import("./daemon-
|
|
182
|
+
const { readRuntime } = await import("./daemon-BAAYUYQC.js");
|
|
189
183
|
const deadline = Date.now() + timeoutMs;
|
|
190
184
|
for (;;) {
|
|
191
185
|
if (child.exitCode !== null || child.signalCode !== null) return null;
|
|
@@ -205,6 +199,6 @@ function upCommand(entry) {
|
|
|
205
199
|
});
|
|
206
200
|
}
|
|
207
201
|
//#endregion
|
|
208
|
-
export { checkedUpFlags, runUp, upArgs, upCommand };
|
|
202
|
+
export { checkedUpFlags, exposureRefusal, runUp, upArgs, upCommand };
|
|
209
203
|
|
|
210
|
-
//# sourceMappingURL=up-
|
|
204
|
+
//# sourceMappingURL=up-BQSnYxYd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"up-BQSnYxYd.js","names":[],"sources":["../../src/cli/up.ts"],"sourcesContent":["import type { ChildProcess } from 'node:child_process'\nimport type { UpFlags } from '#src/cli/args'\nimport { spawn } from 'node:child_process'\nimport fs from 'node:fs'\nimport path from 'node:path'\nimport process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { buildDaemonArgv } from '#src/cli/args'\nimport { bold, delay, dim, fail, firstRunPasswordState, green, invocation, paint, unrecordedFirstRunHint } from '#src/cli/io'\nimport { rotateLog, tailLog } from '#src/helpers/daemon-log'\nimport { runtimeArgs } from '#src/helpers/runtime'\nimport { versionMismatchNote } from '#src/helpers/version'\n\n/** `up` starts the panel; without `--foreground` it re-spawns itself detached. */\n\nconst DEFAULT_PORT = 3999\n\nexport const upArgs = {\n port: { type: 'string', alias: 'p', description: `control panel port (default: ${DEFAULT_PORT})` },\n host: { type: 'string', description: 'local | lan | an ipv4 address (default: local)' },\n // No `default: true`: `restart <id>` needs `undefined` to tell \"not given\" from `--no-autostart`.\n autostart: { type: 'boolean', negativeDescription: 'do not start the entries marked autostart' },\n open: { type: 'boolean', description: 'open the panel in a browser once it is up' },\n foreground: { type: 'boolean', description: 'run in this process instead of detaching (systemd/docker)' },\n printConfig: { type: 'boolean', description: 'print the effective config and exit' },\n} as const\n\ninterface RawUpArgs {\n port?: string\n host?: string\n autostart?: boolean\n open?: boolean\n foreground?: boolean\n printConfig?: boolean\n}\n\nexport function toUpFlags(args: RawUpArgs): UpFlags {\n let port: number | undefined\n if (args.port !== undefined) {\n // The whole argument must be decimal: `parseInt` takes a prefix, so `1e3` would bind port 1.\n const raw = args.port.trim()\n port = /^\\d+$/.test(raw) ? Number.parseInt(raw, 10) : Number.NaN\n if (!Number.isInteger(port) || port <= 0 || port > 65535)\n fail(`invalid port: ${args.port}`)\n }\n\n return {\n port,\n host: args.host,\n autostart: args.autostart !== false,\n open: args.open === true,\n foreground: args.foreground === true,\n printConfig: args.printConfig === true,\n }\n}\n\n/** `toUpFlags` plus a `--host` check, run before anything happens so a bad bind is refused here, not in a daemon log. */\nexport async function checkedUpFlags(args: RawUpArgs): Promise<UpFlags> {\n const flags = toUpFlags(args)\n if (flags.host !== undefined) {\n const { parseBind } = await import('#src/shared/contracts')\n if (parseBind(flags.host) === null)\n fail(`invalid control host: ${flags.host} (expected local, lan or an ipv4 address)`)\n }\n return flags\n}\n\n/** Dependency-free: this module must stay importable without a state graph (`test/cli/isolation`). */\nfunction bindAddress(bind: string): string {\n return bind === 'local' ? '127.0.0.1' : bind === 'lan' ? '0.0.0.0' : bind\n}\n\n/**\n * Which `up` flags the live panel contradicts, as one sentence — or `null`. A flag the command cannot\n * honour is refused, not swallowed with exit 0. `--no-autostart` is deliberately absent: it concerns a\n * boot this command is not performing, and scripts use it in retry loops.\n */\nexport function alreadyRunningConflict(flags: UpFlags, runtime: { url: string, port: number, bindHost: string }): string | null {\n const asked: string[] = []\n if (flags.port !== undefined && flags.port !== runtime.port)\n asked.push(`--port ${flags.port}`)\n // Compared as addresses: the record stores what was bound (`--host lan` reads `0.0.0.0`).\n if (flags.host !== undefined && bindAddress(flags.host) !== runtime.bindHost)\n asked.push(`--host ${flags.host}`)\n if (flags.open)\n asked.push('--open')\n\n if (asked.length === 0)\n return null\n\n const what = asked.join(' and ')\n const clause = asked.length === 1 ? `${what} was not honoured` : `${what} were not honoured`\n return `home-hosted is already running at ${runtime.url} — ${clause}. Use \\`${invocation()} restart ${asked.join(' ')}\\` to move it.`\n}\n\n/**\n * Why the panel would refuse this bind, asked before `restart` takes anything down. A missing password\n * names the account to create; a config the daemon would refuse anyway answers `null`.\n */\nexport async function exposureRefusal(host: string | undefined): Promise<string | null> {\n const { GlobalSettingsStore } = await import('#src/config/settings')\n const { SecretsStore } = await import('#src/config/secrets')\n const { globalSecretsPath, globalSettingsPath } = await import('#src/helpers/paths')\n const { parseBind } = await import('#src/shared/contracts')\n const { checkExposure } = await import('#src/services/exposure')\n\n const settings = new GlobalSettingsStore(globalSettingsPath)\n settings.load({ write: false })\n const secrets = new SecretsStore(globalSecretsPath, undefined, 'global')\n if (settings.configError !== null || secrets.configError !== null)\n return null\n const bind = host === undefined ? settings.control.host : parseBind(host)\n if (bind === null)\n return null\n return checkExposure({ ...settings.control, host: bind }, secrets.passwordSet, secrets.usingDefaultPassword, secrets.passwordTooShort).blockedReason\n}\n\nexport async function runUp(flags: UpFlags, entry: string): Promise<void> {\n // `--print-config` never detaches: a daemon would be left with nothing to serve.\n if (flags.foreground || flags.printConfig) {\n // Imported here: detaching does not need the daemon's graph, which is slow to load.\n const { runControlPlane } = await import('#src/index')\n await runControlPlane({\n port: flags.port,\n host: flags.host,\n autostart: flags.autostart,\n open: flags.open,\n printConfig: flags.printConfig,\n })\n return\n }\n\n const { clearRuntime, readRuntime, runtimeIsAlive, runtimeIsGone } = await import('#src/helpers/daemon')\n const { daemonLogPath, dataRoot, ensureStateDir, projectDir } = await import('#src/helpers/paths')\n\n const existing = readRuntime()\n if (existing !== null && await runtimeIsAlive(existing)) {\n // A refusal is one message on stderr, so stdout carries no success line for a move that did not happen.\n const conflict = alreadyRunningConflict(flags, existing)\n if (conflict !== null)\n fail(conflict)\n\n process.stdout.write(`${green('already running')} home-hosted ${existing.version} (pid ${existing.pid}) at ${existing.url}\\n`)\n const note = versionMismatchNote(existing.version)\n if (note !== null)\n process.stdout.write(`${dim(note)}\\n`)\n // `npx` leaves no `home-hosted` on PATH.\n process.stdout.write(`${dim(`stop it with \\`${invocation()} down\\``)}\\n`)\n return\n }\n // Only a record with nothing behind its pid is deleted: a clock step can make a live panel look recycled.\n if (existing !== null && await runtimeIsGone(existing))\n clearRuntime()\n\n const exposure = await exposureRefusal(flags.host)\n if (exposure !== null)\n fail(`refusing to start: ${exposure}`)\n\n ensureStateDir(path.dirname(daemonLogPath))\n rotateLog(daemonLogPath)\n // `0600`: on a first boot the daemon's stderr carries the generated secret.\n const log = fs.openSync(daemonLogPath, 'a', 0o600)\n\n const child = spawn(process.execPath, [...runtimeArgs(), entry, ...buildDaemonArgv(flags)], {\n detached: true,\n cwd: projectDir,\n env: { ...process.env, HHOSTED_HOME: dataRoot, HHOSTED_PROJECT: projectDir },\n stdio: ['ignore', log, log],\n windowsHide: true,\n })\n child.unref()\n fs.closeSync(log)\n\n const runtime = await waitForStartup(child)\n if (runtime === null) {\n const output = tailLog(daemonLogPath)\n process.stderr.write(`${paint('31', 'error')} the control panel did not start\\n`)\n if (output.length > 0)\n process.stderr.write(`${dim(`${daemonLogPath}:`)}\\n${output}\\n`)\n process.exit(1)\n }\n\n process.stdout.write(`${green(`home-hosted ${runtime.version} is up`)} (pid ${runtime.pid})\\n`)\n process.stdout.write(` ${bold(runtime.url)}\\n`)\n process.stdout.write(` ${dim(`project ${runtime.projectDir}`)}\\n`)\n process.stdout.write(` ${dim(`state ${runtime.dataRoot}`)}\\n`)\n process.stdout.write(` ${dim(`log ${runtime.logFile}`)}\\n`)\n const initial = await firstRunPasswordState()\n if (initial?.kind === 'recorded') {\n process.stdout.write(`${paint('33', 'sign in')} as ${bold(initial.account)} / ${bold(initial.password)}\\n`)\n process.stdout.write(` ${dim('the first-run secret — set your own in Global settings → Accounts')}\\n`)\n }\n else if (initial?.kind === 'unrecorded') {\n process.stdout.write(`${paint('33', 'secret')} ${unrecordedFirstRunHint()}\\n`)\n }\n await warnIfWslTemperatureMissing()\n}\n\n/** Say once, on `up`, that this WSL2 box cannot read its temperature and how to fix it. */\nasync function warnIfWslTemperatureMissing(): Promise<void> {\n const { isWsl } = await import('#src/providers/wsl-temperature')\n if (!isWsl())\n return\n const { GlobalSettingsStore } = await import('#src/config/settings')\n const { globalSettingsPath } = await import('#src/helpers/paths')\n const store = new GlobalSettingsStore(globalSettingsPath)\n store.load()\n if (store.host.tempCommand.trim().length > 0)\n return\n process.stdout.write(\n `${paint('33', 'note')} WSL2 detected: the guest exposes no CPU temperature, so Host vitals shows n/a\\n`\n + ` ${dim(`set it up with ${invocation()} setup-temp --wsl`)}\\n`,\n )\n}\n\nasync function waitForStartup(child: ChildProcess, timeoutMs = 20000) {\n const { readRuntime } = await import('#src/helpers/daemon')\n const deadline = Date.now() + timeoutMs\n\n for (;;) {\n if (child.exitCode !== null || child.signalCode !== null)\n return null\n\n const runtime = readRuntime()\n if (runtime !== null && runtime.pid === child.pid)\n return runtime\n\n if (Date.now() > deadline)\n return null\n await delay(150)\n }\n}\n\nexport function upCommand(entry: string) {\n return defineCommand({\n meta: { name: 'up' },\n args: upArgs,\n run: async ({ args }) => {\n await runUp(await checkedUpFlags(args), entry)\n },\n })\n}\n"],"mappings":";;;;;;;AAiBA,IAAa,SAAS;CACpB,MAAM;EAAE,MAAM;EAAU,OAAO;EAAK,aAAa;CAAgD;CACjG,MAAM;EAAE,MAAM;EAAU,aAAa;CAAiD;CAEtF,WAAW;EAAE,MAAM;EAAW,qBAAqB;CAA4C;CAC/F,MAAM;EAAE,MAAM;EAAW,aAAa;CAA4C;CAClF,YAAY;EAAE,MAAM;EAAW,aAAa;CAA4D;CACxG,aAAa;EAAE,MAAM;EAAW,aAAa;CAAsC;AACrF;AAWA,SAAgB,UAAU,MAA0B;CAClD,IAAI;CACJ,IAAI,KAAK,SAAS,KAAA,GAAW;EAE3B,MAAM,MAAM,KAAK,KAAK,KAAK;EAC3B,O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,kBAAkB,WAAW,EAAE,kBAAkB,EAAE,GAChE;AACF;AAEA,eAAe,eAAe,OAAqB,YAAY,KAAO;CACpE,MAAM,EAAE,gBAAgB,MAAM,OAAO;CACrC,MAAM,WAAW,KAAK,IAAI,IAAI;CAE9B,SAAS;EACP,IAAI,MAAM,aAAa,QAAQ,MAAM,eAAe,MAClD,OAAO;EAET,MAAM,UAAU,YAAY;EAC5B,IAAI,YAAY,QAAQ,QAAQ,QAAQ,MAAM,KAC5C,OAAO;EAET,IAAI,KAAK,IAAI,IAAI,UACf,OAAO;EACT,MAAM,MAAM,GAAG;CACjB;AACF;AAEA,SAAgB,UAAU,OAAe;CACvC,OAAO,cAAc;EACnB,MAAM,EAAE,MAAM,KAAK;EACnB,MAAM;EACN,KAAK,OAAO,EAAE,WAAW;GACvB,MAAM,MAAM,MAAM,eAAe,IAAI,GAAG,KAAK;EAC/C;CACF,CAAC;AACH"}
|
|
@@ -1,40 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { E as errorMessage, _ as paint, f as dim, g as invocation, l as bold, p as fail, v as printJson } from "../cli.js";
|
|
2
2
|
import process from "node:process";
|
|
3
3
|
import { defineCommand } from "citty";
|
|
4
4
|
//#region src/cli/usage.ts
|
|
5
5
|
/**
|
|
6
|
-
* `usage`
|
|
7
|
-
*
|
|
8
|
-
* It reads one server's live CPU and memory from the panel it supervises, over the same local
|
|
9
|
-
* token-plus-loopback channel `down` uses — no session, no API token, and no new `/api` route. An
|
|
10
|
-
* entry with no sample says so instead of printing `0`, because a zero on a CPU column reads as
|
|
11
|
-
* "idle" and hides a server nobody is measuring.
|
|
6
|
+
* `usage` — each server's live CPU and memory, over the local `/_hh` channel. An entry with no sample
|
|
7
|
+
* prints a dash, never `0`.
|
|
12
8
|
*/
|
|
13
9
|
var usageArgs = { json: {
|
|
14
10
|
type: "boolean",
|
|
15
11
|
description: "print machine-readable JSON"
|
|
16
12
|
} };
|
|
17
|
-
/** Bytes as a short human figure; `MB`/`GB` with one decimal, the unit an operator reads. */
|
|
18
13
|
function formatBytes(bytes) {
|
|
19
14
|
const mb = bytes / 1024 / 1024;
|
|
20
15
|
if (mb < 1024) return `${mb.toFixed(1)} MB`;
|
|
21
16
|
return `${(mb / 1024).toFixed(2)} GB`;
|
|
22
17
|
}
|
|
23
|
-
/** One reading, or a dash — never `0` for something that was not measured. */
|
|
24
18
|
function cell(read, render) {
|
|
25
19
|
return read === void 0 ? dim("—") : render(read);
|
|
26
20
|
}
|
|
27
|
-
/**
|
|
28
|
-
* The number of starts in the history window, from whichever spelling the panel sent.
|
|
29
|
-
*
|
|
30
|
-
* A panel on this release or older sends `restarts` (its route copies `ServerView.history.restarts`,
|
|
31
|
-
* which counts `start` events); a panel that renames the field sends `starts`. Both are read so the
|
|
32
|
-
* table is right against either, and `--json` always reports it as `starts`.
|
|
33
|
-
*/
|
|
21
|
+
/** Either spelling the panel sent; `--json` always reports `starts`. */
|
|
34
22
|
function startsOf(entry) {
|
|
35
23
|
return entry.starts ?? entry.restarts;
|
|
36
24
|
}
|
|
37
|
-
/** The `--json` document, with the count named for what it counts rather than for the wire field. */
|
|
38
25
|
function toJson(body) {
|
|
39
26
|
const servers = (body.servers ?? []).map((entry) => {
|
|
40
27
|
const count = startsOf(entry);
|
|
@@ -49,7 +36,7 @@ function toJson(body) {
|
|
|
49
36
|
};
|
|
50
37
|
}
|
|
51
38
|
async function runUsage(input) {
|
|
52
|
-
const { readRuntime, requestControl, runtimeIsAlive, runtimeIsGone, clearRuntime } = await import("./daemon-
|
|
39
|
+
const { readRuntime, requestControl, runtimeIsAlive, runtimeIsGone, clearRuntime } = await import("./daemon-BAAYUYQC.js");
|
|
53
40
|
const runtime = readRuntime();
|
|
54
41
|
if (runtime === null || !await runtimeIsAlive(runtime)) {
|
|
55
42
|
if (runtime !== null && await runtimeIsGone(runtime)) clearRuntime();
|
|
@@ -61,7 +48,7 @@ async function runUsage(input) {
|
|
|
61
48
|
const body = answer.body ?? {};
|
|
62
49
|
const servers = body.servers ?? [];
|
|
63
50
|
if (input.json === true) {
|
|
64
|
-
|
|
51
|
+
printJson(toJson(body));
|
|
65
52
|
return;
|
|
66
53
|
}
|
|
67
54
|
if (servers.length === 0) {
|
|
@@ -108,4 +95,4 @@ var usageCommand = defineCommand({
|
|
|
108
95
|
//#endregion
|
|
109
96
|
export { usageCommand };
|
|
110
97
|
|
|
111
|
-
//# sourceMappingURL=usage-
|
|
98
|
+
//# sourceMappingURL=usage-KG8TeOio.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usage-KG8TeOio.js","names":[],"sources":["../../src/cli/usage.ts"],"sourcesContent":["import process from 'node:process'\nimport { defineCommand } from 'citty'\nimport { bold, dim, fail, invocation, paint, printJson } from '#src/cli/io'\nimport { errorMessage } from '#src/shared/error-message'\n\n/**\n * `usage` — each server's live CPU and memory, over the local `/_hh` channel. An entry with no sample\n * prints a dash, never `0`.\n */\n\nexport const usageArgs = {\n json: { type: 'boolean', description: 'print machine-readable JSON' },\n} as const\n\ninterface UsageEntry {\n id: string\n workspaceId: string\n label: string\n status: string\n cpuPercent?: number\n rssBytes?: number\n processes?: number\n /**\n * Starts inside the panel's history window. The wire field `restarts` counts the same thing, but the\n * API's `server.restarts` is the crash budget — a different quantity, hence the rename.\n */\n starts?: number\n restarts?: number\n crashes?: number\n uptimeRatio?: number\n}\n\nfunction formatBytes(bytes: number): string {\n const mb = bytes / 1024 / 1024\n if (mb < 1024)\n return `${mb.toFixed(1)} MB`\n return `${(mb / 1024).toFixed(2)} GB`\n}\n\nfunction cell(read: number | undefined, render: (value: number) => string): string {\n return read === undefined ? dim('—') : render(read)\n}\n\n/** Either spelling the panel sent; `--json` always reports `starts`. */\nfunction startsOf(entry: UsageEntry): number | undefined {\n return entry.starts ?? entry.restarts\n}\n\nfunction toJson(body: { servers?: UsageEntry[], sampledAt?: number }): Record<string, unknown> {\n const servers = (body.servers ?? []).map((entry) => {\n const count = startsOf(entry)\n const renamed: Record<string, unknown> = { ...entry }\n delete renamed.restarts\n if (count !== undefined)\n renamed.starts = count\n return renamed\n })\n return { ...(body.sampledAt === undefined ? {} : { sampledAt: body.sampledAt }), servers }\n}\n\nexport async function runUsage(input: { json?: boolean }): Promise<void> {\n const { readRuntime, requestControl, runtimeIsAlive, runtimeIsGone, clearRuntime } = await import('#src/helpers/daemon')\n\n const runtime = readRuntime()\n if (runtime === null || !await runtimeIsAlive(runtime)) {\n if (runtime !== null && await runtimeIsGone(runtime))\n clearRuntime()\n fail(`home-hosted is not running — start it with \\`${invocation()} up\\``)\n }\n\n const answer = await requestControl(runtime, '/_hh/usage', 15_000, 'GET')\n if (answer === null)\n fail(`the control panel is not answering on ${runtime.probeUrl}`)\n if (answer.status !== 200)\n fail(`the panel answered ${answer.status} — it may predate this command; restart it on this release`)\n\n const body = (answer.body ?? {}) as { servers?: UsageEntry[], sampledAt?: number }\n const servers = body.servers ?? []\n\n if (input.json === true) {\n printJson(toJson(body))\n return\n }\n\n if (servers.length === 0) {\n process.stdout.write(`${dim('no servers are configured in this panel')}\\n`)\n return\n }\n\n const ranked = [...servers].sort((a, b) => (b.rssBytes ?? 0) - (a.rssBytes ?? 0))\n const rows = ranked.map(entry => [\n entry.workspaceId === 'default' ? entry.id : `${entry.workspaceId}/${entry.id}`,\n entry.status,\n cell(entry.cpuPercent, value => `${value.toFixed(1)}%`),\n cell(entry.rssBytes, formatBytes),\n cell(entry.processes, value => String(value)),\n // Starts, not just crashes: a flapping entry uses little at any sample and counts no crash until the panel gives up.\n cell(startsOf(entry), value => (value === 0 ? dim('0') : String(value))),\n cell(entry.crashes, value => (value === 0 ? dim('0') : paint('31', String(value)))),\n cell(entry.uptimeRatio, value => `${Math.round(value * 100)}%`),\n ])\n\n const headers = ['SERVER', 'STATUS', 'CPU', 'MEMORY', 'PROCS', 'STARTS', 'CRASH', 'UP']\n const widths = headers.map((header, index) =>\n Math.max(header.length, ...rows.map(row => (row[index] ?? '').length)))\n const line = (columns: string[]): string =>\n columns.map((column, index) => column.padEnd(widths[index]!)).join(' ').trimEnd()\n\n process.stdout.write(`${bold(line(headers))}\\n`)\n for (const row of rows)\n process.stdout.write(`${line(row)}\\n`)\n\n if (body.sampledAt === undefined)\n process.stdout.write(`${dim('no host sample yet — readings appear once the panel has sampled')}\\n`)\n}\n\nexport const usageCommand = defineCommand({\n meta: { name: 'usage' },\n args: usageArgs,\n async run({ args }) {\n try {\n await runUsage({ json: args.json })\n }\n catch (error) {\n fail(errorMessage(error))\n }\n },\n})\n"],"mappings":";;;;;;;;AAUA,IAAa,YAAY,EACvB,MAAM;CAAE,MAAM;CAAW,aAAa;AAA8B,EACtE;AAoBA,SAAS,YAAY,OAAuB;CAC1C,MAAM,KAAK,QAAQ,OAAO;CAC1B,IAAI,KAAK,MACP,OAAO,GAAG,GAAG,QAAQ,CAAC,EAAE;CAC1B,OAAO,IAAI,KAAK,KAAA,CAAM,QAAQ,CAAC,EAAE;AACnC;AAEA,SAAS,KAAK,MAA0B,QAA2C;CACjF,OAAO,SAAS,KAAA,IAAY,IAAI,GAAG,IAAI,OAAO,IAAI;AACpD;;AAGA,SAAS,SAAS,OAAuC;CACvD,OAAO,MAAM,UAAU,MAAM;AAC/B;AAEA,SAAS,OAAO,MAA+E;CAC7F,MAAM,WAAW,KAAK,WAAW,CAAC,EAAA,CAAG,KAAK,UAAU;EAClD,MAAM,QAAQ,SAAS,KAAK;EAC5B,MAAM,UAAmC,EAAE,GAAG,MAAM;EACpD,OAAO,QAAQ;EACf,IAAI,UAAU,KAAA,GACZ,QAAQ,SAAS;EACnB,OAAO;CACT,CAAC;CACD,OAAO;EAAE,GAAI,KAAK,cAAc,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW,KAAK,UAAU;EAAI;CAAQ;AAC3F;AAEA,eAAsB,SAAS,OAA0C;CACvE,MAAM,EAAE,aAAa,gBAAgB,gBAAgB,eAAe,iBAAiB,MAAM,OAAO;CAElG,MAAM,UAAU,YAAY;CAC5B,IAAI,YAAY,Q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AU;EAAS;CAAI;CACtF,MAAM,SAAS,QAAQ,KAAK,QAAQ,UAClC,KAAK,IAAI,OAAO,QAAQ,GAAG,KAAK,KAAI,SAAQ,IAAI,UAAU,GAAA,CAAI,MAAM,CAAC,CAAC;CACxE,MAAM,QAAQ,YACZ,QAAQ,KAAK,QAAQ,UAAU,OAAO,OAAO,OAAO,MAAO,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,QAAQ;CAEnF,QAAQ,OAAO,MAAM,GAAG,KAAK,KAAK,OAAO,CAAC,EAAE,GAAG;CAC/C,KAAK,MAAM,OAAO,MAChB,QAAQ,OAAO,MAAM,GAAG,KAAK,GAAG,EAAE,GAAG;CAEvC,IAAI,KAAK,cAAc,KAAA,GACrB,QAAQ,OAAO,MAAM,GAAG,IAAI,iEAAiE,EAAE,GAAG;AACtG;AAEA,IAAa,eAAe,cAAc;CACxC,MAAM,EAAE,MAAM,QAAQ;CACtB,MAAM;CACN,MAAM,IAAI,EAAE,QAAQ;EAClB,IAAI;GACF,MAAM,SAAS,EAAE,MAAM,KAAK,KAAK,CAAC;EACpC,SACO,OAAO;GACZ,KAAK,aAAa,KAAK,CAAC;EAC1B;CACF;AACF,CAAC"}
|
|
@@ -1,85 +1,72 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
|
|
2
2
|
import { t as appVersion } from "../cli.js";
|
|
3
|
-
import {
|
|
4
|
-
import { t as writeFileAtomic } from "./atomic-
|
|
5
|
-
import { n as readStateFile } from "./config-text-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { F as workspacesPath, t as DEFAULT_WORKSPACE_ID } from "./paths-C34-TJLh.js";
|
|
4
|
+
import { t as writeFileAtomic } from "./atomic-SZUwDtGD.js";
|
|
5
|
+
import { n as readStateFile } from "./config-text-DxMOQQnk.js";
|
|
6
|
+
import { t as isRecord } from "./shape-CDGeYl_J.js";
|
|
7
|
+
import { r as parseTolerant } from "./parse-DVMPLUDe.js";
|
|
8
|
+
import { t as lazy } from "./lazy-kfcBNeqj.js";
|
|
9
|
+
import { L as newWorkspaceIdSchema, lt as workspaceSchema } from "./contracts-CxZ7u1L3.js";
|
|
10
|
+
import { o as metaSchema } from "./schema-CZ6f-PHD.js";
|
|
11
|
+
import path from "node:path";
|
|
9
12
|
import { type } from "arktype";
|
|
10
13
|
//#region src/config/workspaces.ts
|
|
11
14
|
var workspaces_exports = /* @__PURE__ */ __exportAll({
|
|
12
15
|
WorkspaceError: () => WorkspaceError,
|
|
13
16
|
WorkspaceRegistry: () => WorkspaceRegistry,
|
|
14
17
|
defaultWorkspaceId: () => defaultWorkspaceId,
|
|
18
|
+
parseWorkspacesFile: () => parseWorkspacesFile,
|
|
15
19
|
readDefaultWorkspaceId: () => readDefaultWorkspaceId,
|
|
16
20
|
readWorkspaceIds: () => readWorkspaceIds,
|
|
17
|
-
slugifyWorkspaceId: () => slugifyWorkspaceId
|
|
18
|
-
workspacesFileSchema: () => workspacesFileSchema
|
|
21
|
+
slugifyWorkspaceId: () => slugifyWorkspaceId
|
|
19
22
|
});
|
|
20
|
-
/**
|
|
21
|
-
* The workspace registry: which workspaces exist, in the order the selector shows
|
|
22
|
-
* them. Kept apart from any workspace's own files so it can be read before they
|
|
23
|
-
* are, and so creating or removing one is a single small write.
|
|
24
|
-
*/
|
|
23
|
+
/** The workspace registry, kept apart from any workspace's files so it can be read before them. */
|
|
25
24
|
var workspacesFileSchema = lazy(() => type({
|
|
26
25
|
$schema: "string?",
|
|
27
26
|
meta: metaSchema.optional(),
|
|
28
27
|
workspaces: workspaceSchema.array()
|
|
29
28
|
}).onUndeclaredKey("reject"));
|
|
29
|
+
/** Reads a registry from any release: unknown keys are dropped and listed, never a refusal. */
|
|
30
|
+
function parseWorkspacesFile(raw) {
|
|
31
|
+
const unknownKeys = [];
|
|
32
|
+
const parsed = parseTolerant(raw, workspacesFileSchema, "workspaces.json", unknownKeys);
|
|
33
|
+
if (parsed.error !== null) return {
|
|
34
|
+
workspaces: null,
|
|
35
|
+
unknownKeys,
|
|
36
|
+
error: parsed.error
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
workspaces: parsed.value.workspaces,
|
|
40
|
+
unknownKeys,
|
|
41
|
+
error: null
|
|
42
|
+
};
|
|
43
|
+
}
|
|
30
44
|
/**
|
|
31
|
-
* The workspace a command acts in when none was named: `default` if
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* **The panel already answers this question, and the CLI was answering a different one.** Every
|
|
35
|
-
* workspace-scoped `/api` and `/_hh` route resolves an omitted `?workspace` through
|
|
36
|
-
* `PanelService.requireWorkspace` → `WorkspaceRegistry.defaultId`, i.e. this rule. The two CLI
|
|
37
|
-
* commands that take a workspace id read `DEFAULT_WORKSPACE_ID` literally instead — so on a host
|
|
38
|
-
* whose registry lists one workspace that is not called `default` (a colleague's panel, or one
|
|
39
|
-
* where `default` was removed), `start <id>` reached that workspace while `logs <id>` looked in
|
|
40
|
-
* `.hh/default/.logs/`, a directory that does not exist. Measured: `logs` answered "no output yet"
|
|
41
|
-
* and exited 0 for a log that was on disk, on the one command a diagnostic session starts with.
|
|
42
|
-
*
|
|
43
|
-
* One function, called by every surface that asks, so a third caller cannot re-derive it.
|
|
45
|
+
* The workspace a command acts in when none was named: `default` if declared, else the first one.
|
|
46
|
+
* The one rule for the panel and the CLI alike.
|
|
44
47
|
*/
|
|
45
48
|
function defaultWorkspaceId(workspaces) {
|
|
46
49
|
return workspaces.find((entry) => entry.id === "default")?.id ?? workspaces[0]?.id ?? "default";
|
|
47
50
|
}
|
|
48
|
-
/**
|
|
49
|
-
* `defaultWorkspaceId`, for a command that has a registry file and no panel.
|
|
50
|
-
*
|
|
51
|
-
* Tolerant for the same reason the panel's own startup guard is the one that refuses a broken
|
|
52
|
-
* registry: a diagnostic command reading one log must not be the thing that fails loudly about a
|
|
53
|
-
* file it only needed one id from. Missing, unparseable or empty falls back to `default`, which is
|
|
54
|
-
* what the seed declares.
|
|
55
|
-
*/
|
|
51
|
+
/** `defaultWorkspaceId` from a registry file with no panel; missing, unparseable or empty means `default`. */
|
|
56
52
|
function readDefaultWorkspaceId(file) {
|
|
57
53
|
try {
|
|
58
|
-
const
|
|
59
|
-
if (
|
|
60
|
-
return defaultWorkspaceId(
|
|
54
|
+
const { workspaces } = parseWorkspacesFile(JSON.parse(readStateFile(file)));
|
|
55
|
+
if (workspaces === null || workspaces.length === 0) return DEFAULT_WORKSPACE_ID;
|
|
56
|
+
return defaultWorkspaceId(workspaces);
|
|
61
57
|
} catch {
|
|
62
58
|
return DEFAULT_WORKSPACE_ID;
|
|
63
59
|
}
|
|
64
60
|
}
|
|
65
61
|
/**
|
|
66
|
-
* The
|
|
67
|
-
*
|
|
68
|
-
* `readDefaultWorkspaceId`'s sibling for a command that must tell "that workspace does not exist"
|
|
69
|
-
* from "I cannot tell": a diagnostic that answers an empty log for a typo'd `--workspace` is the
|
|
70
|
-
* same false answer as one that answers it for a typo'd server id. `null` keeps the caller silent
|
|
71
|
-
* on a registry it could not read, because unreadable is not "it names none".
|
|
72
|
-
*
|
|
73
|
-
* An **empty** registry is `null` too, for the same reason its sibling falls back to `default`: a
|
|
74
|
-
* registry listing nothing is what a hand-edit or a partially written file looks like, and the panel
|
|
75
|
-
* treats it as `default` rather than as "no workspace exists". Answering `[]` there made `logs <id>`
|
|
76
|
-
* refuse the default workspace that `start` and the panel both serve.
|
|
62
|
+
* The ids a registry declares, or `null` when it cannot answer (unreadable or empty, which the panel
|
|
63
|
+
* treats as `default`), so a caller can tell "no such workspace" from "cannot tell".
|
|
77
64
|
*/
|
|
78
65
|
function readWorkspaceIds(file) {
|
|
79
66
|
try {
|
|
80
|
-
const
|
|
81
|
-
if (
|
|
82
|
-
return
|
|
67
|
+
const { workspaces } = parseWorkspacesFile(JSON.parse(readStateFile(file)));
|
|
68
|
+
if (workspaces === null || workspaces.length === 0) return null;
|
|
69
|
+
return workspaces.map((workspace) => workspace.id);
|
|
83
70
|
} catch {
|
|
84
71
|
return null;
|
|
85
72
|
}
|
|
@@ -96,14 +83,18 @@ var seed = () => [{
|
|
|
96
83
|
id: DEFAULT_WORKSPACE_ID,
|
|
97
84
|
label: "Default"
|
|
98
85
|
}];
|
|
99
|
-
|
|
86
|
+
var ID_LENGTH = 40;
|
|
87
|
+
/** Names Windows reserves for devices: no directory can carry one there. */
|
|
88
|
+
var RESERVED_IDS = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/;
|
|
89
|
+
/** `My Project AB!` -> `my-project-ab`, and never an empty id, a reserved name or one over 40 characters. */
|
|
100
90
|
function slugifyWorkspaceId(label, taken = []) {
|
|
101
|
-
const base = label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0,
|
|
91
|
+
const base = label.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, ID_LENGTH);
|
|
102
92
|
const used = new Set(taken);
|
|
103
93
|
const candidate = base.length > 0 ? base : "workspace";
|
|
104
|
-
if (!used.has(candidate)) return candidate;
|
|
94
|
+
if (!used.has(candidate) && !RESERVED_IDS.test(candidate)) return candidate;
|
|
105
95
|
for (let index = 2; index < 1e3; index++) {
|
|
106
|
-
const
|
|
96
|
+
const suffix = `-${index}`;
|
|
97
|
+
const next = `${candidate.slice(0, ID_LENGTH - suffix.length).replace(/-+$/, "")}${suffix}`;
|
|
107
98
|
if (!used.has(next)) return next;
|
|
108
99
|
}
|
|
109
100
|
throw new WorkspaceError("could not derive a unique workspace id");
|
|
@@ -111,7 +102,10 @@ function slugifyWorkspaceId(label, taken = []) {
|
|
|
111
102
|
var WorkspaceRegistry = class {
|
|
112
103
|
file;
|
|
113
104
|
list = [];
|
|
105
|
+
/** The file as last read, so a write keeps the keys a newer release put there. */
|
|
106
|
+
raw = {};
|
|
114
107
|
error = null;
|
|
108
|
+
warnings = [];
|
|
115
109
|
listeners = /* @__PURE__ */ new Set();
|
|
116
110
|
constructor(file = workspacesPath) {
|
|
117
111
|
this.file = file;
|
|
@@ -119,10 +113,14 @@ var WorkspaceRegistry = class {
|
|
|
119
113
|
get path() {
|
|
120
114
|
return this.file;
|
|
121
115
|
}
|
|
122
|
-
/** Blocking problems; the caller refuses to start on one
|
|
116
|
+
/** Blocking problems; the caller refuses to start on one. */
|
|
123
117
|
get configError() {
|
|
124
118
|
return this.error;
|
|
125
119
|
}
|
|
120
|
+
/** Keys a newer release wrote that this one ignores, and keeps on disk. */
|
|
121
|
+
get configWarnings() {
|
|
122
|
+
return [...this.warnings];
|
|
123
|
+
}
|
|
126
124
|
all() {
|
|
127
125
|
return [...this.list];
|
|
128
126
|
}
|
|
@@ -132,7 +130,6 @@ var WorkspaceRegistry = class {
|
|
|
132
130
|
has(id) {
|
|
133
131
|
return this.get(id) !== void 0;
|
|
134
132
|
}
|
|
135
|
-
/** The id a workspace-scoped request resolves to when none is given. */
|
|
136
133
|
get defaultId() {
|
|
137
134
|
return defaultWorkspaceId(this.list);
|
|
138
135
|
}
|
|
@@ -159,30 +156,38 @@ var WorkspaceRegistry = class {
|
|
|
159
156
|
this.error = `cannot read ${this.file}: ${error.message}`;
|
|
160
157
|
return;
|
|
161
158
|
}
|
|
162
|
-
const
|
|
163
|
-
if (
|
|
164
|
-
this.error = `${this.file}: ${
|
|
159
|
+
const { workspaces, unknownKeys, error } = parseWorkspacesFile(parsed);
|
|
160
|
+
if (workspaces === null) {
|
|
161
|
+
this.error = `${this.file}: ${error}`;
|
|
165
162
|
return;
|
|
166
163
|
}
|
|
167
|
-
if (
|
|
164
|
+
if (workspaces.length === 0) {
|
|
168
165
|
this.error = `${this.file} declares no workspace — at least one is required`;
|
|
169
166
|
return;
|
|
170
167
|
}
|
|
171
168
|
this.error = null;
|
|
172
|
-
this.
|
|
169
|
+
this.warnings = unknownKeys.length === 0 ? [] : [`${path.basename(this.file)} carries ${unknownKeys.length} unrecognized key(s) this release ignores: ${unknownKeys.join(", ")}`];
|
|
170
|
+
this.raw = parsed;
|
|
171
|
+
this.list = workspaces.map((entry) => ({ ...entry }));
|
|
173
172
|
this.notify();
|
|
174
173
|
}
|
|
175
|
-
create(input)
|
|
174
|
+
/** Validates what `create(input)` would register without writing, so the directory can be built first. */
|
|
175
|
+
prepare(input) {
|
|
176
176
|
const label = (input.label ?? input.id ?? "").trim();
|
|
177
177
|
const id = input.id ?? slugifyWorkspaceId(label, this.list.map((entry) => entry.id));
|
|
178
|
+
const checkedId = newWorkspaceIdSchema(id);
|
|
179
|
+
if (checkedId instanceof type.errors) throw new WorkspaceError(`id ${checkedId.summary}`);
|
|
178
180
|
const validated = workspaceSchema({
|
|
179
181
|
id,
|
|
180
182
|
label: label.length > 0 ? label : id
|
|
181
183
|
});
|
|
182
184
|
if (validated instanceof type.errors) throw new WorkspaceError(validated.summary);
|
|
183
185
|
if (this.has(id)) throw new WorkspaceError(`workspace "${id}" already exists`, "WORKSPACE_EXISTS");
|
|
184
|
-
|
|
185
|
-
|
|
186
|
+
return validated;
|
|
187
|
+
}
|
|
188
|
+
create(input) {
|
|
189
|
+
const validated = this.prepare(input);
|
|
190
|
+
this.commit([...this.list, validated]);
|
|
186
191
|
return validated;
|
|
187
192
|
}
|
|
188
193
|
rename(id, label) {
|
|
@@ -206,15 +211,22 @@ var WorkspaceRegistry = class {
|
|
|
206
211
|
return entry;
|
|
207
212
|
}
|
|
208
213
|
commit(next) {
|
|
214
|
+
const { $schema: _schema, meta: _meta, workspaces: previous, ...extra } = this.raw;
|
|
215
|
+
const before = new Map((Array.isArray(previous) ? previous : []).filter((entry) => isRecord(entry) && typeof entry.id === "string").map((entry) => [entry.id, entry]));
|
|
209
216
|
const stamped = {
|
|
210
217
|
$schema: "./workspaces.schema.json",
|
|
211
218
|
meta: {
|
|
212
219
|
writtenBy: appVersion(),
|
|
213
220
|
schema: 1
|
|
214
221
|
},
|
|
215
|
-
|
|
222
|
+
...extra,
|
|
223
|
+
workspaces: next.map((entry) => ({
|
|
224
|
+
...before.get(entry.id),
|
|
225
|
+
...entry
|
|
226
|
+
}))
|
|
216
227
|
};
|
|
217
228
|
writeFileAtomic(this.file, `${JSON.stringify(stamped, null, 2)}\n`);
|
|
229
|
+
this.raw = stamped;
|
|
218
230
|
this.list = next.map((entry) => ({ ...entry }));
|
|
219
231
|
this.error = null;
|
|
220
232
|
this.notify();
|
|
@@ -224,6 +236,6 @@ var WorkspaceRegistry = class {
|
|
|
224
236
|
}
|
|
225
237
|
};
|
|
226
238
|
//#endregion
|
|
227
|
-
export { workspaces_exports as i, WorkspaceRegistry as n,
|
|
239
|
+
export { workspaces_exports as i, WorkspaceRegistry as n, parseWorkspacesFile as r, WorkspaceError as t };
|
|
228
240
|
|
|
229
|
-
//# sourceMappingURL=workspaces-
|
|
241
|
+
//# sourceMappingURL=workspaces-D9akpzU8.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspaces-D9akpzU8.js","names":[],"sources":["../../src/config/workspaces.ts"],"sourcesContent":["import type { Workspace } from '#src/shared/contracts'\nimport path from 'node:path'\nimport { type } from 'arktype'\nimport { parseTolerant } from '#src/config/parse'\nimport { metaSchema } from '#src/config/schema'\nimport { writeFileAtomic } from '#src/helpers/atomic'\nimport { readStateFile } from '#src/helpers/config-text'\nimport { DEFAULT_WORKSPACE_ID, workspacesPath } from '#src/helpers/paths'\nimport { appVersion } from '#src/helpers/version'\nimport { newWorkspaceIdSchema, workspaceSchema } from '#src/shared/contracts'\nimport { lazy } from '#src/shared/lazy'\nimport { isRecord } from '#src/shared/shape'\n\n/** The workspace registry, kept apart from any workspace's files so it can be read before them. */\nconst workspacesFileSchema = lazy(() => type({\n $schema: 'string?',\n meta: metaSchema.optional(),\n workspaces: workspaceSchema.array(),\n}).onUndeclaredKey('reject'))\n\n/** Reads a registry from any release: unknown keys are dropped and listed, never a refusal. */\nexport function parseWorkspacesFile(raw: unknown): { workspaces: Workspace[] | null, unknownKeys: string[], error: string | null } {\n const unknownKeys: string[] = []\n const parsed = parseTolerant(raw, workspacesFileSchema as unknown as (input: unknown) => unknown, 'workspaces.json', unknownKeys)\n if (parsed.error !== null)\n return { workspaces: null, unknownKeys, error: parsed.error }\n return { workspaces: (parsed.value as typeof workspacesFileSchema.infer).workspaces, unknownKeys, error: null }\n}\n\n/** The kind of registry failure, for a caller that branches on it (404 / 409 / 400). */\nexport type WorkspaceErrorCode = 'UNKNOWN_WORKSPACE' | 'WORKSPACE_EXISTS'\n\n/**\n * The workspace a command acts in when none was named: `default` if declared, else the first one.\n * The one rule for the panel and the CLI alike.\n */\nexport function defaultWorkspaceId(workspaces: ReadonlyArray<Readonly<{ id: string }>>): string {\n return workspaces.find(entry => entry.id === DEFAULT_WORKSPACE_ID)?.id ?? workspaces[0]?.id ?? DEFAULT_WORKSPACE_ID\n}\n\n/** `defaultWorkspaceId` from a registry file with no panel; missing, unparseable or empty means `default`. */\nexport function readDefaultWorkspaceId(file: string): string {\n try {\n const { workspaces } = parseWorkspacesFile(JSON.parse(readStateFile(file)) as unknown)\n if (workspaces === null || workspaces.length === 0)\n return DEFAULT_WORKSPACE_ID\n return defaultWorkspaceId(workspaces)\n }\n catch {\n return DEFAULT_WORKSPACE_ID\n }\n}\n\n/**\n * The ids a registry declares, or `null` when it cannot answer (unreadable or empty, which the panel\n * treats as `default`), so a caller can tell \"no such workspace\" from \"cannot tell\".\n */\nexport function readWorkspaceIds(file: string): string[] | null {\n try {\n const { workspaces } = parseWorkspacesFile(JSON.parse(readStateFile(file)) as unknown)\n if (workspaces === null || workspaces.length === 0)\n return null\n return workspaces.map(workspace => workspace.id)\n }\n catch {\n return null\n }\n}\n\nexport class WorkspaceError extends Error {\n override name = 'WorkspaceError'\n readonly code: WorkspaceErrorCode | undefined\n\n constructor(message: string, code?: WorkspaceErrorCode) {\n super(message)\n this.code = code\n }\n}\n\nconst seed = (): Workspace[] => [{ id: DEFAULT_WORKSPACE_ID, label: 'Default' }]\n\nconst ID_LENGTH = 40\n/** Names Windows reserves for devices: no directory can carry one there. */\nconst RESERVED_IDS = /^(?:con|prn|aux|nul|com[1-9]|lpt[1-9])$/\n\n/** `My Project AB!` -> `my-project-ab`, and never an empty id, a reserved name or one over 40 characters. */\nexport function slugifyWorkspaceId(label: string, taken: Iterable<string> = []): string {\n const base = label\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, '-')\n .replace(/^-+|-+$/g, '')\n .slice(0, ID_LENGTH)\n const used = new Set(taken)\n const candidate = base.length > 0 ? base : 'workspace'\n if (!used.has(candidate) && !RESERVED_IDS.test(candidate))\n return candidate\n for (let index = 2; index < 1000; index++) {\n const suffix = `-${index}`\n const next = `${candidate.slice(0, ID_LENGTH - suffix.length).replace(/-+$/, '')}${suffix}`\n if (!used.has(next))\n return next\n }\n throw new WorkspaceError('could not derive a unique workspace id')\n}\n\nexport class WorkspaceRegistry {\n private list: Workspace[] = []\n /** The file as last read, so a write keeps the keys a newer release put there. */\n private raw: Record<string, unknown> = {}\n private error: string | null = null\n private warnings: string[] = []\n private readonly listeners = new Set<() => void>()\n\n constructor(private readonly file: string = workspacesPath) {}\n\n get path(): string {\n return this.file\n }\n\n /** Blocking problems; the caller refuses to start on one. */\n get configError(): string | null {\n return this.error\n }\n\n /** Keys a newer release wrote that this one ignores, and keeps on disk. */\n get configWarnings(): string[] {\n return [...this.warnings]\n }\n\n all(): Workspace[] {\n return [...this.list]\n }\n\n get(id: string): Workspace | undefined {\n return this.list.find(entry => entry.id === id)\n }\n\n has(id: string): boolean {\n return this.get(id) !== undefined\n }\n\n get defaultId(): string {\n return defaultWorkspaceId(this.list)\n }\n\n onChange(listener: () => void): () => void {\n this.listeners.add(listener)\n return () => this.listeners.delete(listener)\n }\n\n /** Reads the registry, seeding a missing one; `{ write: false }` holds the seed in memory only. */\n load(options: { write?: boolean } = {}): void {\n let parsed: unknown\n try {\n parsed = JSON.parse(readStateFile(this.file))\n }\n catch (error) {\n if ((error as NodeJS.ErrnoException).code === 'ENOENT') {\n if (options.write === false) {\n this.list = seed()\n this.error = null\n this.notify()\n return\n }\n this.commit(seed())\n return\n }\n this.error = `cannot read ${this.file}: ${(error as Error).message}`\n return\n }\n\n const { workspaces, unknownKeys, error } = parseWorkspacesFile(parsed)\n if (workspaces === null) {\n this.error = `${this.file}: ${error}`\n return\n }\n if (workspaces.length === 0) {\n this.error = `${this.file} declares no workspace — at least one is required`\n return\n }\n\n this.error = null\n this.warnings = unknownKeys.length === 0\n ? []\n : [`${path.basename(this.file)} carries ${unknownKeys.length} unrecognized key(s) this release ignores: ${unknownKeys.join(', ')}`]\n this.raw = parsed as Record<string, unknown>\n this.list = workspaces.map(entry => ({ ...entry }))\n this.notify()\n }\n\n /** Validates what `create(input)` would register without writing, so the directory can be built first. */\n prepare(input: { id?: string, label?: string }): Workspace {\n const label = (input.label ?? input.id ?? '').trim()\n const id = input.id ?? slugifyWorkspaceId(label, this.list.map(entry => entry.id))\n\n const checkedId = newWorkspaceIdSchema(id)\n if (checkedId instanceof type.errors)\n throw new WorkspaceError(`id ${checkedId.summary}`)\n const validated = workspaceSchema({ id, label: label.length > 0 ? label : id })\n if (validated instanceof type.errors)\n throw new WorkspaceError(validated.summary)\n if (this.has(id))\n throw new WorkspaceError(`workspace \"${id}\" already exists`, 'WORKSPACE_EXISTS')\n return validated\n }\n\n create(input: { id?: string, label?: string }): Workspace {\n const validated = this.prepare(input)\n this.commit([...this.list, validated])\n return validated\n }\n\n rename(id: string, label: string): Workspace {\n const index = this.list.findIndex(entry => entry.id === id)\n if (index < 0)\n throw new WorkspaceError(`unknown workspace \"${id}\"`, 'UNKNOWN_WORKSPACE')\n\n const validated = workspaceSchema({ id, label: label.trim() })\n if (validated instanceof type.errors)\n throw new WorkspaceError(validated.summary)\n\n const next = [...this.list]\n next[index] = validated\n this.commit(next)\n return validated\n }\n\n remove(id: string): Workspace {\n const entry = this.get(id)\n if (entry === undefined)\n throw new WorkspaceError(`unknown workspace \"${id}\"`, 'UNKNOWN_WORKSPACE')\n if (this.list.length <= 1)\n throw new WorkspaceError('cannot remove the only workspace')\n\n this.commit(this.list.filter(candidate => candidate.id !== id))\n return entry\n }\n\n private commit(next: Workspace[]): void {\n // Keys a newer release added are written back as they were read.\n const { $schema: _schema, meta: _meta, workspaces: previous, ...extra } = this.raw\n const before = new Map((Array.isArray(previous) ? previous : [])\n .filter((entry): entry is Record<string, unknown> => isRecord(entry) && typeof entry.id === 'string')\n .map(entry => [entry.id as string, entry]))\n const stamped = {\n $schema: './workspaces.schema.json',\n meta: { writtenBy: appVersion(), schema: 1 },\n ...extra,\n workspaces: next.map(entry => ({ ...before.get(entry.id), ...entry })),\n }\n writeFileAtomic(this.file, `${JSON.stringify(stamped, null, 2)}\\n`)\n this.raw = stamped\n this.list = next.map(entry => ({ ...entry }))\n this.error = null\n this.notify()\n }\n\n private notify(): void {\n for (const listener of this.listeners) listener()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAcA,IAAM,uBAAuB,WAAW,KAAK;CAC3C,SAAS;CACT,MAAM,WAAW,SAAS;CAC1B,YAAY,gBAAgB,MAAM;AACpC,CAAC,CAAC,CAAC,gBAAgB,QAAQ,CAAC;;AAG5B,SAAgB,oBAAoB,KAA+F;CACjI,MAAM,cAAwB,CAAC;CAC/B,MAAM,SAAS,cAAc,KAAK,sBAAgE,mBAAmB,WAAW;CAChI,IAAI,OAAO,UAAU,MACnB,OAAO;EAAE,YAAY;EAAM;EAAa,OAAO,OAAO;CAAM;CAC9D,OAAO;EAAE,YAAa,OAAO,MAA4C;EAAY;EAAa,OAAO;CAAK;AAChH;;;;;AASA,SAAgB,mBAAmB,YAA6D;CAC9F,OAAO,WAAW,MAAK,UAAS,MAAM,OAAA,SAA2B,CAAC,EAAE,MAAM,WAAW,EAAE,EAAE,MAAA;AAC3F;;AAGA,SAAgB,uBAAuB,MAAsB;CAC3D,IAAI;EACF,MAAM,EAAE,eAAe,oBAAoB,KAAK,MAAM,cAAc,IAAI,CAAC,CAAY;EACrF,IAAI,eAAe,QAAQ,WAAW,WAAW,GAC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